Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ids): new scope for health directorate #17820

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Feb 5, 2025

Scope - Health directorate

What

Add new scope for Landlæknir Health APIs

Why

✨ new new new ✨
New apis for referrals, waiting lists and prescriptions for "Heilsa" 💊 📝 👨🏼‍⚕️

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features
    • Introduced a new integration that enables secure access to health-related information including referrals, waiting lists, and prescriptions for authorized users.

@disaerna disaerna requested review from a team as code owners February 5, 2025 11:49
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

A new file has been added that seeds a scope for the health module. The file exports an up function created by composing the result of createScope with a configuration object. This object defines properties such as name, displayName, description, and includes an array with client identifiers under addToClients. The configuration facilitates setting up access to health-related information like referrals, waiting lists, and prescriptions.

Changes

File Change Summary
libs/auth-api-lib/.../scope-landlaeknir-health.ts Introduced new file that exports an up function. The function composes createScope with a configuration object, specifying properties such as name ('@landlaeknir.is/health'), displayName ('health'), description, and addToClients with a client identifier.

Suggested labels

automerge

Suggested reviewers

  • magnearun
  • thorkellmani

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
libs/auth-api-lib/seeders/data/scopes-landlaeknir.ts (1)

22-28: Consider a more specific displayName for the health scope.

While the implementation is correct, the displayName: 'health' is quite generic compared to other scopes like 'Vaccinations' and 'organ-donations'. Consider using a more specific name that reflects its purpose (referrals, waiting lists, and prescriptions).

-    displayName: 'health',
+    displayName: 'health-services',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63a7e74 and 60ae22a.

📒 Files selected for processing (1)
  • libs/auth-api-lib/seeders/data/scopes-landlaeknir.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`libs/**/*`: "Confirm that the code adheres to the following...

libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
  • libs/auth-api-lib/seeders/data/scopes-landlaeknir.ts
🔇 Additional comments (2)
libs/auth-api-lib/seeders/data/scopes-landlaeknir.ts (2)

1-3: LGTM! File structure follows TypeScript best practices.

The imports and composition setup are well-organized and consistent with the existing pattern.


1-29: Verify scope naming consistency across the codebase.

The new scope follows the established pattern. Let's verify that all Landlæknir scopes follow the same naming convention.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check for consistent scope naming patterns

# Search for scope definitions
rg --type typescript "createScope\({[\s\S]*?name: '@landlaeknir\.is/" -g '!node_modules'

Length of output: 236


Let's re-run the verification using a simplified regex pattern. This should help us list all occurrences of scope definitions using the expected naming pattern.


🏁 Script executed:

#!/bin/bash
# Description: Simplified search for consistent scope naming in the repository.
rg --type typescript "name:\s*'@landlaeknir\.is" -g '!node_modules'

Length of output: 107


Let's try a modified command targeting all TypeScript files instead of relying on the "typescript" file type.


🏁 Script executed:

#!/bin/bash
# Description: Search for consistent scope naming in the repository for TypeScript files.
rg -g '*.ts' "createScope\(\{[^}]*name:\s*'@landlaeknir\.is" -n

Length of output: 68


Let's try a more simplified command that directly checks for occurrences of scope names starting with @landlaeknir.is in all TypeScript files:


🏁 Script executed:

#!/bin/bash
# Description: Search for scope name occurrences in TypeScript files
rg -g '*.ts' "name:\\s*'@landlaeknir\\.is" -n

Length of output: 442


Scope naming verified across the codebase

The scope names in the file libs/auth-api-lib/seeders/data/scopes-landlaeknir.ts are consistent with the established pattern. All scopes correctly use the @landlaeknir.is prefix and follow the expected naming structure.

  • Scopes:
    • @landlaeknir.is/vaccinations:admin
    • @landlaeknir.is/vaccinations
    • @landlaeknir.is/organ-donations
    • @landlaeknir.is/health

Copy link

nx-cloud bot commented Feb 5, 2025

View your CI Pipeline Execution ↗ for commit 9c7ec45.

Command Status Duration Result
nx run-many --projects services-auth-admin-api ... ✅ Succeeded 8m 57s View ↗
nx run-many --projects services-auth-delegation... ✅ Succeeded 8m 32s View ↗
nx run-many --projects application-template-api... ✅ Succeeded 8m 8s View ↗
nx run-many --projects services-auth-ids-api,se... ✅ Succeeded 6m 15s View ↗
nx run-many --projects application-system-api -... ✅ Succeeded 9m 3s View ↗
nx run-many --target=build --projects=applicati... ✅ Succeeded 4m 21s View ↗
nx run-many --projects auth-api-lib --target te... ✅ Succeeded 1m 15s View ↗
nx run-many --projects clients-auth-admin-api,c... ✅ Succeeded 35s View ↗
Additional runs (10) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2025-02-05 15:41:19 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60ae22a and 9c7ec45.

📒 Files selected for processing (1)
  • libs/auth-api-lib/seeders/data/scope-landlaeknir-health.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`libs/**/*`: "Confirm that the code adheres to the following...

libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
  • libs/auth-api-lib/seeders/data/scope-landlaeknir-health.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: formatting
  • GitHub Check: linting-workspace
🔇 Additional comments (1)
libs/auth-api-lib/seeders/data/scope-landlaeknir-health.ts (1)

1-1: LGTM!

The imports are clean and follow the modular pattern using helper functions.

Comment on lines +3 to +11
export const up = compose(
createScope({
name: '@landlaeknir.is/health',
displayName: 'health',
description:
'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir',
addToClients: ['@island.is/clients/api'],
}),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add TypeScript types and consider internationalization.

  1. Consider adding TypeScript interface for the scope configuration to improve type safety and documentation:
+interface ScopeConfig {
+  name: string;
+  displayName: string;
+  description: string;
+  addToClients: string[];
+}

 export const up = compose(
-  createScope({
+  createScope<ScopeConfig>({
     name: '@landlaeknir.is/health',
     displayName: 'health',
     description:
       'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir',
     addToClients: ['@island.is/clients/api'],
   }),
 )
  1. Consider adding an English translation for the description to improve maintainability:
     description:
-      'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir',
+      'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir' + 
+      ' | Provides access to information about referrals, waiting lists and prescriptions',
  1. Consider extracting the client ID to a constant for better reusability:
+const API_CLIENT_ID = '@island.is/clients/api';

 export const up = compose(
   createScope({
     name: '@landlaeknir.is/health',
     displayName: 'health',
     description:
       'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir',
-    addToClients: ['@island.is/clients/api'],
+    addToClients: [API_CLIENT_ID],
   }),
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const up = compose(
createScope({
name: '@landlaeknir.is/health',
displayName: 'health',
description:
'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir',
addToClients: ['@island.is/clients/api'],
}),
)
interface ScopeConfig {
name: string;
displayName: string;
description: string;
addToClients: string[];
}
const API_CLIENT_ID = '@island.is/clients/api';
export const up = compose(
createScope<ScopeConfig>({
name: '@landlaeknir.is/health',
displayName: 'health',
description:
'Veitir aðgang að upplýsingum um tilvísanir, biðlista og lyfjaávísanir' +
' | Provides access to information about referrals, waiting lists and prescriptions',
addToClients: [API_CLIENT_ID],
}),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant