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

fix(service-portal): Health Directorate - Fixes #15728

Merged
merged 16 commits into from
Sep 9, 2024

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Aug 21, 2024

Service Portal - Health Directorate

What

  • Refactor resolvers and service
  • Connect to xroad dev service
  • Refactor UI

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

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 new health services for organ donation and vaccinations, enhancing API capabilities.
    • Added new endpoints and data structures for improved handling of vaccination and organ donation data.
    • Enhanced user interface components for better interaction and feedback during data loading.
  • Bug Fixes

    • Improved error handling in various services and components to provide clearer feedback.
  • Refactor

    • Streamlined component logic for vaccinations and organ donation, consolidating multiple components into unified structures.
  • Style

    • Enhanced UI elements for better user experience during data fetching and display.

Copy link
Contributor

coderabbitai bot commented Aug 21, 2024

Walkthrough

The changes introduce new functionalities related to organ donation and vaccinations within the health directorate module. This includes the addition of new API endpoints, updates to GraphQL queries and mutations, modifications to service and resolver logic, and enhancements to data models. The updates streamline the handling of donor and vaccination data, improve data structure, and enhance user interaction through a more organized interface.

Changes

Files Change Summary
apps/api/infra/api.ts Added imports for HealthDirectorateOrganDonation and HealthDirectorateVaccination and included them in serviceSetup.
charts/islandis/values.dev.yaml, charts/islandis/values.prod.yaml, charts/islandis/values.staging.yaml Introduced new API paths for organ donation and vaccination services.
infra/src/dsl/xroad.ts Added constants for HealthDirectorateOrganDonation and HealthDirectorateVaccination with environment configurations.
libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts Updated GraphQL queries and mutations related to organ donation and vaccinations, modifying return types and parameters.
libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts Updated method signatures to reflect new data structures and improve error handling.
libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts Renamed classes and fields for organ donation data, enhancing clarity and structure.
libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql Updated GraphQL queries for donor status and exceptions, enhancing data structure.
libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx Modified query fetching logic to ensure latest data retrieval and simplified rendering logic.
libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx Refactored logic to streamline donor registration process using a single query.
libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql Significant modifications to vaccination query structure, enhancing data representation.
libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx Introduced a wrapper component for managing vaccination data display and user interaction.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend
    participant API
    participant Database

    User->>Frontend: Request donor status
    Frontend->>API: Fetch donor status with locale
    API->>Database: Query donor data
    Database-->>API: Return donor data
    API-->>Frontend: Send donor data
    Frontend-->>User: Display donor status
Loading
sequenceDiagram
    participant User
    participant Frontend
    participant API
    participant Database

    User->>Frontend: Request vaccinations
    Frontend->>API: Fetch vaccinations
    API->>Database: Query vaccination data
    Database-->>API: Return vaccination data
    API-->>Frontend: Send vaccination data
    Frontend-->>User: Display vaccinations
Loading

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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.

@datadog-island-is
Copy link

datadog-island-is bot commented Aug 21, 2024

Datadog Report

All test runs ed06a2b 🔗

6 Total Test Services: 0 Failed, 5 Passed
➡️ Test Sessions change in coverage: 32 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.23s 1 no change Link
application-system-api 0 0 0 122 2 2m 58.34s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 57.83s 1 no change Link
application-ui-shell 0 0 0 74 0 38.37s 1 no change Link
service-portal-core 0 0 0 5 0 2.36s N/A Link
service-portal-health 0 0 0 0 0 619.03ms 1 no change Link

@disaerna disaerna added the deploy-feature Deploys features to dev label Aug 21, 2024
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 36.82%. Comparing base (10cd895) to head (1cff6b8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ib/clients/organ-donation/organDonation.service.ts 25.00% 3 Missing ⚠️
...b/clients/organ-donation/organDonation.provider.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #15728   +/-   ##
=======================================
  Coverage   36.82%   36.82%           
=======================================
  Files        6692     6692           
  Lines      137101   137100    -1     
  Branches    38975    38975           
=======================================
+ Hits        50481    50482    +1     
+ Misses      86620    86618    -2     
Flag Coverage Δ
api 3.39% <ø> (ø)
application-system-api 41.68% <33.33%> (+<0.01%) ⬆️
application-template-api-modules 23.55% <ø> (-0.02%) ⬇️
application-ui-shell 21.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
libs/clients/health-directorate/src/index.ts 100.00% <100.00%> (ø)
...c/lib/clients/vaccinations/vaccinations.service.ts 34.78% <ø> (ø)
libs/service-portal/core/src/index.ts 0.00% <ø> (ø)
libs/service-portal/health/src/lib/messages.ts 0.00% <ø> (ø)
libs/service-portal/health/src/module.tsx 0.00% <ø> (ø)
...b/clients/organ-donation/organDonation.provider.ts 42.85% <0.00%> (ø)
...ib/clients/organ-donation/organDonation.service.ts 34.61% <25.00%> (+2.47%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10cd895...1cff6b8. Read the comment docs.

@disaerna disaerna marked this pull request as ready for review September 6, 2024 09:07
@disaerna disaerna requested review from a team as code owners September 6, 2024 09:07
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: 3

Outside diff range, codebase verification and nitpick comments (2)
libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts (1)

41-68: Class Vaccination is well-designed for handling complex health data.

The nullable fields allow for flexibility in data representation, which is crucial in health applications. Consider adding documentation comments to explain the purpose and usage of each field, especially for fields like status, statusName, and statusColor which might not be immediately clear to other developers or API consumers.

libs/service-portal/core/src/index.ts (1)

32-32: Review of New Export in index.ts

The addition of the export * from './components/TabNavigation/TabBar' statement at line 32 is a straightforward enhancement to the module's functionality. Here are some considerations:

  • Consistency and Reusability: Ensure that the TabBar component is designed to be reusable across different parts of the application. This aligns with the PR's objective of enhancing reusability.
  • TypeScript Usage: Confirm that the TabBar component and its props are fully typed to leverage TypeScript's benefits for safer code.
  • Tree-shaking and Bundling: Verify that the export does not negatively impact the tree-shaking process or increase the bundle size unnecessarily. This is crucial for maintaining performance, especially in a large-scale application like a service portal.

Overall, the change is positive, but keep the above points in mind to ensure optimal integration and performance.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a4c7324 and a3538ae.

Files selected for processing (30)
  • apps/api/infra/api.ts (2 hunks)
  • charts/islandis/values.dev.yaml (1 hunks)
  • charts/islandis/values.prod.yaml (1 hunks)
  • charts/islandis/values.staging.yaml (1 hunks)
  • infra/src/dsl/xroad.ts (1 hunks)
  • libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts (3 hunks)
  • libs/api/domains/health-directorate/src/lib/health-directorate.service.ts (2 hunks)
  • libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts (1 hunks)
  • libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts (1 hunks)
  • libs/clients/health-directorate/src/index.ts (1 hunks)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (6 hunks)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts (1 hunks)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.provider.ts (1 hunks)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts (3 hunks)
  • libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json (17 hunks)
  • libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts (1 hunks)
  • libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts (2 hunks)
  • libs/service-portal/core/src/index.ts (1 hunks)
  • libs/service-portal/health/src/lib/messages.ts (2 hunks)
  • libs/service-portal/health/src/module.tsx (2 hunks)
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql (1 hunks)
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx (2 hunks)
  • libs/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx (2 hunks)
  • libs/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx (1 hunks)
  • libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx (4 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql (1 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx (1 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx (1 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx (1 hunks)
  • libs/service-portal/health/src/utils/tagSelector.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.provider.ts
Additional context used
Path-based instructions (26)
libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql (1)

Pattern 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/clients/health-directorate/src/index.ts (1)

Pattern 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/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts (1)

Pattern 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/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts (1)

Pattern 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/service-portal/health/src/utils/tagSelector.ts (1)

Pattern 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/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql (1)

Pattern 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/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx (1)

Pattern 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/api/domains/health-directorate/src/lib/models/organ-donation.model.ts (1)

Pattern 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/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts (1)

Pattern 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/api/domains/health-directorate/src/lib/models/vaccinations.model.ts (1)

Pattern 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/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx (1)

Pattern 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/api/domains/health-directorate/src/lib/health-directorate.resolver.ts (1)

Pattern 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/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts (1)

Pattern 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/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx (1)

Pattern 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/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx (1)

Pattern 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/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx (1)

Pattern 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/service-portal/core/src/index.ts (1)

Pattern 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/api/domains/health-directorate/src/lib/health-directorate.service.ts (1)

Pattern 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/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx (1)

Pattern 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/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx (1)

Pattern 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/service-portal/health/src/module.tsx (1)

Pattern 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/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (1)

Pattern 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."
apps/api/infra/api.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json (1)

Pattern 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."
infra/src/dsl/xroad.ts (1)

Pattern infra/src/dsl/**/*: "Confirm that the code adheres to the following:

  • The clarity and expressiveness of the DSL syntax.
  • Integration with Helm charts and Kubernetes resources.
  • Documentation on how to use the DSL to create complex Helm values."
libs/service-portal/health/src/lib/messages.ts (1)

Pattern 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."
Additional comments not posted (54)
libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql (1)

2-24: Verify integration with frontend components.

The GraphQL query getVaccinations has been significantly restructured. Ensure that the frontend components consuming this query have been updated to handle the new fields and structure. Check for any potential breaking changes due to the removal of old fields and the addition of new ones.

libs/clients/health-directorate/src/index.ts (1)

15-15: Verify usage of new export.

The addition of DiseaseVaccinationDtoVaccinationStatusEnum to the exports enhances type safety. Verify that this new type is being used correctly across the application and does not conflict with existing types.

Verification successful

Verification successful: Usage of DiseaseVaccinationDtoVaccinationStatusEnum is correct.

The DiseaseVaccinationDtoVaccinationStatusEnum is appropriately used in the codebase. It is imported and registered as a GraphQL enum type, which aligns with its intended use. No conflicts or issues were found.

  • libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts: The enum is registered as a GraphQL enum type.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `DiseaseVaccinationDtoVaccinationStatusEnum` across the application.

# Test: Search for the usage of `DiseaseVaccinationDtoVaccinationStatusEnum`. Expect: Correct usage and no conflicts.
rg --type ts -A 5 $'DiseaseVaccinationDtoVaccinationStatusEnum'

Length of output: 1232

libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.config.ts (1)

17-20: Verify new configuration settings.

The updates to XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH and the expansion of the scope property in HealthDirectorateVaccinationsClientConfig are significant. Ensure that these changes are correctly integrated into the system and do not conflict with other configurations.

libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.config.ts (1)

17-20: Review of Configuration Changes

The updates to the HealthDirectorateOrganDonationClientConfig are well-aligned with the PR's objectives to enhance the organ donation services. The changes to the environment variable key and default value are appropriate and improve the specificity of the configuration. Additionally, the inclusion of a specific scope for organ donations is a positive change.

However, it's crucial to ensure that these new configurations are properly integrated and utilized across the application. This includes updating any dependent services or components that rely on the old configuration key.

libs/service-portal/health/src/utils/tagSelector.ts (1)

4-14: Enhancements to tagSelector Function

The modifications to the tagSelector function enhance its flexibility and robustness by allowing it to handle optional and null inputs effectively. The use of isDefined to check for undefined or null inputs before returning a default color is a good practice, ensuring that the function behaves predictably in various scenarios.

The update to the mapping object to include new states ('undetermined' and 'valid') and the removal of the 'vaccinated' state are aligned with the evolving requirements of the application. It's important to ensure that these changes are reflected in the UI components that utilize this function to maintain consistency.

Overall, the changes are positive and improve the function's utility in the application.

libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql (1)

1-36: Refactoring of GraphQL Schema for Organ Donation

The updates to the GraphQL schema in the OrganDonation module significantly enhance the structure and clarity of the data returned by the queries and mutation. The introduction of nested objects and detailed fields for donor information and organ lists aligns with best practices for GraphQL.

The changes to the queries (getDonorStatus and getOrgansList) and the mutation (updateOrganDonationInfo) are well-thought-out and improve the granularity of the data. It's crucial to ensure that these changes are properly supported by the backend and correctly integrated with the frontend components to avoid any disruptions in functionality.

libs/service-portal/health/src/screens/OrganDonationRegistration/Loader.tsx (1)

1-32: Well-structured and responsive loader component.

The Loader component is well-implemented with clear usage of conditional rendering based on the device type and efficient rendering of multiple loaders using array mapping. The use of TypeScript for props definition enhances type safety and code readability.

  • Props Handling: The default prop for amount is set correctly, allowing flexibility in how many loader items are displayed.
  • Responsive Design: The component adjusts the size of the loader based on the device type, which is a good practice for responsive design.
  • Performance: Using React.Fragment for keying each loader item in the list is a good practice to avoid unnecessary re-renders.

Overall, the component adheres to good React and TypeScript practices and should perform well in the service portal environment.

libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts (1)

1-56: Comprehensive enhancements to organ donation models.

The changes to the GraphQL models in the organ-donation.model.ts file are well-thought-out and effectively enhance the data structure for organ donation:

  • New and Renamed Classes: The transition from DonorStatus to Donor with the addition of Limitations and Organ classes allows for a more detailed representation of donor preferences and limitations.
  • Field Decorators: The use of @Field decorators with type specifications and descriptions improves the API's self-documentation and usability.
  • Nullable Fields: The optionality of certain fields like limitedOrgansList and comment in Limitations provides flexibility in how data can be provided and stored, which is crucial for handling real-world scenarios where not all data might be available.

These changes align well with the objectives of enhancing the clarity and functionality of the organ donation module, ensuring that the data model can accommodate complex scenarios related to organ donation preferences.

libs/clients/health-directorate/src/lib/clients/vaccinations/vaccinations.service.ts (1)

45-45: Simplified method signature in getVaccinationDiseaseDetail.

The removal of the input parameter from the getVaccinationDiseaseDetail method simplifies the method signature and potentially improves the clarity of the service's API. This change should make the method easier to use and maintain, assuming that the necessary data can still be fetched without the removed parameter.

  • Clarity and Maintainability: Simplifying method signatures where possible is a good practice, especially in public APIs.
  • Error Handling: The continued use of .catch(handle404) ensures that the method gracefully handles cases where no data is available, which is crucial for robustness.

Ensure that all dependent services and components that use this method are updated to reflect this change in the method signature.

Run the following script to verify the method usage:

Verification successful

Method signature update verified successfully.

The getVaccinationDiseaseDetail method's signature change has been correctly reflected in its usage within the codebase. The call in health-directorate.service.ts matches the new signature, confirming that the necessary updates have been made.

  • Location of Method Call: libs/api/domains/health-directorate/src/lib/health-directorate.service.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all method calls to `getVaccinationDiseaseDetail` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type typescript -A 5 $'getVaccinationDiseaseDetail'

Length of output: 90


Script:

#!/bin/bash
# Description: Verify all method calls to `getVaccinationDiseaseDetail` match the new signature.

# Test: Search for the method usage. Expect: Only occurrences of the new signature.
rg --type ts -A 5 $'getVaccinationDiseaseDetail'

Length of output: 1491

libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts (4)

4-6: Enum registration is correct.

The registration of DiseaseVaccinationDtoVaccinationStatusEnum as HealthDirectorateVaccinationsStatus is correctly implemented using registerEnumType.


9-13: Class Age is well-defined.

The nullable fields years and months are appropriate, allowing for partial age information which is a common scenario in health data.


17-35: Class Info is correctly structured for optional data handling.

The use of nullable fields for optional data like name, date, age, url, and comment is well-implemented, making the API flexible for various data availability scenarios.


74-78: Class Vaccinations is correctly implemented as a container for Vaccination objects.

This design pattern is effective for handling collections of data items in GraphQL APIs, facilitating easier data management and queries.

libs/service-portal/health/src/screens/Vaccinations/tables/SortedVaccinationsTable.tsx (4)

1-12: Approved import changes.

The new imports are essential for the updated functionality of the component, such as handling empty states and sorting capabilities.


22-34: Approved localization changes.

Using formatMessage for table headers enhances internationalization support, making the application more accessible to a broader audience.


37-38: Approved addition of empty state handling.

The conditional rendering for an empty state is a user-friendly feature that improves the UX by providing clear feedback when no data is available.


15-15: Approved change in data prop type.

Making the data prop optional is a good practice for robustness, especially in asynchronous scenarios. Ensure that all usages of data properly handle the case when it is undefined.

Verification successful

Optional data prop is handled correctly.

The use of optional chaining (data?.map) throughout the codebase ensures that the optional nature of the data prop is properly managed, preventing runtime errors when data is undefined. This confirms the robustness of the implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `data` handle the case when it is undefined.

# Test: Search for the usage of `data` in the component. Expect: Proper handling of undefined.
rg --type typescript -A 5 $'data\\?\\.map'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify all usages of `data` handle the case when it is undefined.

# Test: Search for the usage of `data` in the component. Expect: Proper handling of undefined.
rg --type ts -A 5 $'data\\?\\.map'

Length of output: 18530

libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (4)

4-4: Endpoint Renaming and Description Updates Approved

The renaming of the endpoint to /v1/me/organ-donor-status and the updates to the operation descriptions are clear and align with the enhanced focus on organ donation. These changes improve API clarity and specificity.

Also applies to: 66-66


8-22: Addition of ip and locale Parameters Approved

The introduction of optional ip and locale parameters to the get and post operations enhances the API's flexibility and usability, allowing for responses tailored to the user's geographical and language preferences.

Also applies to: 71-78


226-229: Schema Modification in OrganDonorDto Approved

The change in the OrganDonorDto schema to reference OrganDto objects instead of simple strings for the exceptions property enhances data representation and validation.

Also applies to: 233-233


213-213: Addition of Locale and OrganDto Schemas Approved

The new Locale and OrganDto schemas provide necessary and clear definitions for data types used in the API, enhancing data integrity and validation.

Also applies to: 214-220

apps/api/infra/api.ts (1)

50-51: Addition of Health Directorate Services Approved

The integration of HealthDirectorateOrganDonation and HealthDirectorateVaccination into the service setup is correctly implemented and aligns with the PR's objectives to expand health-related functionalities.

Also applies to: 432-433

libs/clients/health-directorate/src/lib/clients/vaccinations/clientConfig.json (3)

575-597: Addition of New Endpoints and Properties Approved

The new endpoints /v1/vaccines and /v1/vaccines/{vaccineId} along with the new properties in the VaccineDto schema enhance the API's functionality and allow for more detailed management and retrieval of vaccine data.

Also applies to: 706-730


Line range hint 760-791: Updates to DiseaseVaccinationDto Schema Approved

The addition of isFeatured and vaccinationStatusColor properties to the DiseaseVaccinationDto schema enhances the clarity and usability of the API by providing more detailed information about the vaccination status.


841-841: Changes to type Properties in Schemas Approved

The modification of the type property from string to object in various schemas allows for a more complex and detailed data representation, aligning with the needs of the API to handle more intricate data structures.

Also applies to: 959-959, 1005-1005

charts/islandis/values.staging.yaml (2)

355-355: Review of New API Path for Organ Donation

The new API path for organ donation has been added correctly under the api section. This path is specific to the development environment (IS-DEV), which aligns with the PR's intent to enhance health-related functionalities.


357-357: Review of New API Path for Vaccination

The new API path for vaccination services is also correctly placed under the api section. It is designated for the development environment, consistent with the organ donation path, ensuring uniformity in the configuration.

charts/islandis/values.prod.yaml (2)

345-345: Review of New API Path for Organ Donation

The addition of the XROAD_HEALTH_DIRECTORATE_ORGAN_DONATION_PATH is correctly formatted and follows the established pattern for X-Road API paths. This path is crucial for integrating organ donation functionalities.


347-347: Review of New API Path for Vaccination

The addition of the XROAD_HEALTH_DIRECTORATE_VACCINATION_PATH is correctly formatted and follows the established pattern for X-Road API paths. This path is crucial for integrating vaccination functionalities.

charts/islandis/values.dev.yaml (2)

355-355: Review of New API Path for Organ Donation

The new API path for organ donation has been added correctly. The format and placement are consistent with existing entries, ensuring uniformity in the configuration.


357-357: Review of New API Path for Vaccination

The new API path for vaccination services has been added correctly. It follows the same format as other API paths in the configuration, maintaining consistency and clarity.

libs/service-portal/health/src/screens/Vaccinations/tables/VaccinationsDetailTable.tsx (1)

52-56: Enhanced handling of empty states in the UI.

The updated conditional rendering logic and the addition of a Box component around the EmptyTable improve the clarity and structure of the UI when no data is present. This change enhances user experience by making the empty state more visually consistent and informative.

libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts (3)

34-45: Improved localization and data structure in getDonorStatus.

The addition of the locale parameter allows for localized responses, enhancing the flexibility and usability of the API. The change in the return type to OrganDonation aligns with the updated data models, providing a more structured and informative response.


46-53: Enhanced data retrieval in resolveOrganList.

The use of the @ResolveField decorator to resolve a list of Organ objects based on the OrganDonation context is a robust enhancement. This method improves the API's capability to fetch relevant data efficiently, leveraging user context and locale.


69-74: Simplified API method in getVaccinations.

The method now directly returns Vaccinations, simplifying the API and potentially enhancing performance by reducing the complexity of data retrieval.

libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts (2)

28-33: Enhanced functionality with localization in getOrganDonation.

The addition of the Locale parameter allows for localized data retrieval, enhancing the method's functionality and aligning with the PR objectives to provide more tailored services.


48-56: Improved error handling and data structure in updateOrganDonation.

The change in input type to UpdateOrganDonorDto allows for more structured updates. The inclusion of error.message in the error handling provides clearer feedback on issues, enhancing the robustness of the method.

libs/service-portal/health/src/screens/OrganDonationRegistration/Limitations.tsx (5)

1-1: Review of imports and initial setup.

The imports are correctly organized, and the component uses appropriate hooks and components from the libraries. The use of useState from React for managing state is appropriate for this component's functionality.

Also applies to: 3-4


7-8: Update to interface LimitationsProps.

The change in the data type from HealthDirectorateOrganDonationExceptionObject[] to HealthDirectorateOrganDonationOrgan[] and the addition of the selected prop are aligned with the PR's objectives to handle different data structures and enhance component flexibility.


11-11: Initialization of the Limitations component.

The component now accepts an additional selected prop which is used to initialize the checked state. This is a good practice as it allows the component to reflect pre-selected values, enhancing user experience.


13-13: State management and checkbox handling logic.

The state is initialized based on the selected prop, which is a robust way to handle optional pre-selections. The handleCheckboxChange function is well-implemented, using functional updates to the state for better performance in asynchronous updates. The use of the id property for managing checkbox states is a good practice, ensuring that the checkboxes are uniquely identifiable and correctly reflect the component's state.

Also applies to: 37-44


30-30: Rendering logic and checkbox component setup.

The rendering logic correctly maps over the data array to produce checkboxes for each item. The use of the id property for both the id and value attributes of the Checkbox component ensures that the checkboxes are uniquely identifiable. This is crucial for correctly managing the state of the checkboxes and is a significant improvement in handling potential issues with non-unique names.

Also applies to: 37-44

libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx (3)

4-4: Introduction of CardLoader and update to data fetching policy.

The addition of CardLoader enhances the user experience by providing a visual indicator during data loading. The adjustment of the fetchPolicy to 'no-cache' is a strategic choice to ensure that the component always fetches the latest data, which is essential for displaying accurate donor status.

Also applies to: 18-20


22-31: Refinement of donor status handling and rendering logic.

The new implementation simplifies the handling of donor status by directly checking if the donor has limitations and constructing a cardText string accordingly. This reduces complexity and enhances clarity in the rendering logic, making the component easier to maintain and understand.


39-81: Updates to component rendering and conditional logic.

The component now conditionally displays different messages based on the donor's status, which improves user feedback. The use of CardLoader during the loading state and the simplified conditional rendering logic for displaying the ActionCard are well-implemented, enhancing the responsiveness and clarity of the user interface.

libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx (4)

24-24: Introduction of new data fetching query and loader component.

The use of useGetOrgansListQuery simplifies the data fetching process by consolidating the logic into a single query. The introduction of the Loader component during the loading state enhances user experience by providing visual feedback.

Also applies to: 38-38


42-55: Simplification of state management for donor status.

The state management for the donor's registration status has been significantly simplified, directly mapping the donor's status to radio button values. This reduces complexity and enhances the clarity of the component's logic.


68-71: Refinement of form submission logic and state synchronization.

The form submission logic has been adjusted to reflect the new data structure, ensuring that the component functions correctly with the updated backend logic. The synchronization of the radioValue state with the donorStatus in the useEffect hook ensures that the UI is always in sync with the fetched data.

Also applies to: 78-87


102-186: Enhancements to form rendering and user interaction.

The form now includes a loading state that displays a Loader component, enhancing user experience during asynchronous operations. The conditional rendering logic for the form and the inclusion of the Limitations component based on the donor's status are well-implemented, improving the clarity and functionality of the user interface.

libs/service-portal/health/src/module.tsx (2)

65-66: Correct implementation of lazy loading for the Vaccinations component.

The lazy loading syntax is correctly used, and the path to the component is accurately specified.


223-223: Proper use of the Vaccinations component in routing configuration.

The Vaccinations component is correctly integrated into the routing configuration, ensuring that it renders appropriately for the relevant route.

infra/src/dsl/xroad.ts (2)

894-903: Correct configuration of HealthDirectorateOrganDonation.

The constant is well-defined with appropriate environment-specific paths, ensuring consistent configuration across different deployment stages.


905-913: Correct configuration of HealthDirectorateVaccination.

The constant is well-defined with appropriate environment-specific paths, ensuring consistent configuration across different deployment stages.

libs/service-portal/health/src/lib/messages.ts (1)

1001-1020: Proper addition of new message entries for organ donation and medical prescriptions.

The new message entries are correctly defined with unique IDs and provide clear, comprehensive translations for the related features.

Also applies to: 1126-1137

infra/src/dsl/xroad.ts Outdated Show resolved Hide resolved
infra/src/dsl/xroad.ts Outdated Show resolved Hide resolved
Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

Cool, some GraphQL issues

Copy link
Member

@svanaeinars svanaeinars left a comment

Choose a reason for hiding this comment

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

LGTM

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

Outside diff range, codebase verification and nitpick comments (1)
libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx (1)

Line range hint 24-186: Refactoring of Organ Donation Registration Form

The refactoring of the Form2 component in RegistrationForm.tsx significantly improves the clarity and efficiency of the organ donation registration process. The use of useGetOrgansListQuery to streamline data fetching and the simplified state management for donor status are notable improvements.

Consider further enhancing the component by possibly abstracting some of the logic into custom hooks or utilities if the component grows in complexity. This can help maintain readability and testability.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a3538ae and bef6497.

Files selected for processing (10)
  • charts/islandis/values.staging.yaml (1 hunks)
  • infra/src/dsl/xroad.ts (1 hunks)
  • libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts (2 hunks)
  • libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts (1 hunks)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts (3 hunks)
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql (1 hunks)
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx (2 hunks)
  • libs/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx (4 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql (1 hunks)
  • libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (8)
  • charts/islandis/values.staging.yaml
  • infra/src/dsl/xroad.ts
  • libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts
  • libs/api/domains/health-directorate/src/lib/models/vaccinations.model.ts
  • libs/clients/health-directorate/src/lib/clients/organ-donation/organDonation.service.ts
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.graphql
  • libs/service-portal/health/src/screens/OrganDonation/OrganDonation.tsx
  • libs/service-portal/health/src/screens/Vaccinations/VaccinationsWrapper.tsx
Additional context used
Path-based instructions (2)
libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql (1)

Pattern 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/service-portal/health/src/screens/OrganDonationRegistration/RegistrationForm.tsx (1)

Pattern 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."
Additional comments not posted (1)
libs/service-portal/health/src/screens/Vaccinations/Vaccinations.graphql (1)

2-24: GraphQL Query Update: Enhanced Vaccination Data Structure

The modifications to the GraphQL query getVaccinations enhance the data structure by focusing more on relevant vaccination details rather than disease-specific information. The addition of fields like isFeatured, statusName, statusColor, and the nested vaccinationsInfo are likely to provide a more comprehensive and useful view of the vaccination records.

Please ensure that these changes are well integrated with the backend API and the UI components that consume this data. It might be beneficial to check if the backend supports these new fields and if the UI components are updated to display this new structure effectively.

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bef6497 and 42ba863.

Files selected for processing (1)
  • libs/api/domains/health-directorate/src/lib/health-directorate.service.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • libs/api/domains/health-directorate/src/lib/health-directorate.service.ts

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 42ba863 and c41ce06.

Files selected for processing (2)
  • libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts (2 hunks)
  • libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • libs/api/domains/health-directorate/src/lib/health-directorate.resolver.ts
  • libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts

Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

LGTM 🥃

@disaerna disaerna added automerge Merge this PR as soon as all checks pass and removed deploy-feature Deploys features to dev labels Sep 9, 2024
@kodiakhq kodiakhq bot merged commit e3254de into main Sep 9, 2024
52 checks passed
@kodiakhq kodiakhq bot deleted the service-portal/health-fixes branch September 9, 2024 10:05
thoreyjona pushed a commit that referenced this pull request Sep 9, 2024
* fix: resolver naming and logic

* health fixes

* refactor: after service added

* chore: nx format:write update dirty files

* refactor: service update

* feat: add loaders

* chore: charts update dirty files

* fix: charts values for staging

* fix: PR comments

* fix: pr comments vol 2

* fix: null

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
jonnigs pushed a commit that referenced this pull request Sep 12, 2024
* fix: resolver naming and logic

* health fixes

* refactor: after service added

* chore: nx format:write update dirty files

* refactor: service update

* feat: add loaders

* chore: charts update dirty files

* fix: charts values for staging

* fix: PR comments

* fix: pr comments vol 2

* fix: null

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants