10000 build: filter out patients that are opted out by Orta21 · Pull Request #3830 · metriport/metriport · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

build: filter out patients that are opted out #3830

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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Orta21
Copy link
Member
@Orta21 Orta21 commented May 13, 2025

Part of cs-463

Issues:

Dependencies

  • Upstream: NONE
  • Downstream: NONE

Description

  • If opt out true dont share back data

Testing

  • Local
    • If opted out data not being shared back
  • Staging
    • If opted out data not being shared back
  • Production
    • If opted out data not being shared back

Release Plan

  • Release NPM packages
  • Merge this

Summary by CodeRabbit

  • New Features

    • Added support for a new optional "HIE Opt-Out" property for patients, allowing the system to recognize and respect patients who have opted out of Health Information Exchange.
    • Patient matching now excludes individuals who have opted out of HIE.
  • Chores

    • Updated multiple package versions and dependencies to new alpha releases across the platform.

Part of cs-463

Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
Copy link
linear bot commented May 13, 2025

Copy link
coderabbitai bot commented May 13, 2025

Walkthrough

This update introduces a new optional boolean property, hieOptOut, to patient data transfer objects (DTOs) and propagates this property through the API, core, and matching logic. The patient matching process now excludes patients who have opted out of the Health Information Exchange. Additionally, multiple package versions and dependencies are incremented to new alpha releases.

Changes

File(s) Change Summary
packages/api-sdk/package.json Bumped version to 14.14.4-alpha.0; upgraded @metriport/commonwell-sdk and @metriport/shared dependencies.
packages/api/package.json Bumped version to 1.27.4-alpha.0.
packages/carequality-cert-runner/package.json Bumped version to 1.18.4-alpha.0; upgraded @metriport/ihe-gateway-sdk and @metriport/shared dependencies.
packages/carequality-sdk/package.json Bumped version to 1.6.4-alpha.0.
packages/commonwell-cert-runner/package.json, packages/commonwell-jwt-maker/package.json Bumped versions; upgraded @metriport/commonwell-sdk dependency to alpha version.
packages/commonwell-sdk/package.json, packages/ihe-gateway-sdk/package.json, packages/shared/package.json Bumped versions; upgraded @metriport/shared dependency to alpha version.
packages/core/package.json, packages/infra/package.json, packages/mllp-server/package.json, packages/utils/package.json Bumped versions to new alpha releases.
packages/api-sdk/src/medical/models/patientDTO.ts Added optional hieOptOut?: boolean to PatientDTO type.
packages/api/src/routes/medical/dtos/patientDTO.ts Added hieOptOut?: boolean to PatientDTO; updated DTO mapping functions to include hieOptOut.
packages/core/src/command/patient-loader-metriport-api.ts Updated getDomainFromDTO to include hieOptOut (defaulting to false).
packages/core/src/mpi/inbound-patient-mpi-metriport-api.ts Patient matching now excludes patients with hieOptOut set to true.

Sequence Diagram(s)

sequenceDiagram
    participant API
    participant Core
    participant MatchingLogic
    participant Client

    Client->>API: Request patient data
    API->>API: Retrieve PatientWithIdentifiers
    API->>API: Map to PatientDTO (includes hieOptOut)
    API-->>Client: Return PatientDTO (with hieOptOut)
    Client->>Core: Provide PatientDTO
    Core->>Core: getDomainFromDTO (maps hieOptOut, default false)
    Core->>MatchingLogic: Perform patient matching
    MatchingLogic->>MatchingLogic: Filter out patients where hieOptOut == true
    MatchingLogic-->>Core: Return matched patient (if any)
Loading

Possibly related PRs

  • chore(release): publish #3641: Updates @metriport/api-sdk and dependencies to stable versions; related due to similar package version and dependency updates.

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
Part of cs-463

Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
Orta21 added 2 commits May 15, 2025 13:54
Ref: #000

 - api@1.27.4-alpha.0
 - @metriport/api-sdk@14.14.4-alpha.0
 - @metriport/carequality-cert-runner@1.18.4-alpha.0
 - @metriport/carequality-sdk@1.6.4-alpha.0
 - @metriport/commonwell-cert-runner@1.26.4-alpha.0
 - @metriport/commonwell-jwt-maker@1.24.4-alpha.0
 - @metriport/commonwell-sdk@5.9.2-alpha.0
 - @metriport/core@1.24.4-alpha.0
 - @metriport/ihe-gateway-sdk@0.19.4-alpha.0
 - infrastructure@1.22.4-alpha.0
 - mllp-server@0.3.4-alpha.0
 - @metriport/shared@0.23.4-alpha.0
 - utils@1.25.4-alpha.0

Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
Part of cs-463

Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
Part of cs-463

Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
@Orta21 Orta21 marked this pull request as ready for review May 15, 2025 20:50
Copy link
@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 (2)
packages/utils/package.json (1)

3-3: Pre-release version bump looks correct. Updating from 1.25.3 to 1.25.4-alpha.0 aligns with the coordinated bump to alpha across related packages. Please ensure the changelog or release notes reflect this new pre-release version and that the release pipeline is set to publish under the alpha tag.

packages/api/src/routes/medical/dtos/patientDTO.ts (1)

8-14: Consider explicit documentation for filtering behavior

The addition of the hieOptOut property is well-implemented. Consider adding a JSDoc comment explaining that patients with this flag set to true will be filtered out from patient matching results, as this is the key purpose of this flag according to the PR description.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf9d709 and 2605664.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (17)
  • packages/api-sdk/package.json (2 hunks)
  • packages/api-sdk/src/medical/models/patientDTO.ts (1 hunks)
  • packages/api/package.json (1 hunks)
  • packages/api/src/routes/medical/dtos/patientDTO.ts (3 hunks)
  • packages/carequality-cert-runner/package.json (2 hunks)
  • packages/carequality-sdk/package.json (1 hunks)
  • packages/commonwell-cert-runner/package.json (2 hunks)
  • packages/commonwell-jwt-maker/package.json (2 hunks)
  • packages/commonwell-sdk/package.json (2 hunks)
  • packages/core/package.json (1 hunks)
  • packages/core/src/command/patient-loader-metriport-api.ts (1 hunks)
  • packages/core/src/mpi/inbound-patient-mpi-metriport-api.ts (1 hunks)
  • packages/ihe-gateway-sdk/package.json (2 hunks)
  • packages/infra/package.json (1 hunks)
  • packages/mllp-server/package.json (1 hunks)
  • packages/shared/package.json (1 hunks)
  • packages/utils/package.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.ts`: - Use the Onion Pattern to organize a package's code in layers - Try to use immutable code and avoid sharing state across different functions, objects, and systems - Try...

**/*.ts: - Use the Onion Pattern to organize a package's code in layers

  • Try to use immutable code and avoid sharing state across different functions, objects, and systems
  • Try to build code that's idempotent whenever possible
  • Prefer functional programming style functions: small, deterministic, 1 input, 1 output
  • Minimize coupling / dependencies
  • Avoid modifying objects received as parameter
  • Only add comments to code to explain why something was done, not how it works
  • Naming
    • classes, enums: PascalCase
    • constants, variables, functions: camelCase
    • file names: kebab-case
    • table and column names: snake_case
    • Use meaningful names, so whoever is reading the code understands what it means
    • Don’t use negative names, like notEnabled, prefer isDisabled
    • For numeric values, if the type doesn’t convey the unit, add the unit to the name
  • Typescript
    • Use types
    • Prefer const instead of let
    • Avoid any and casting from any to other types
    • Type predicates: only applicable to narrow down the type, not to force a complete type conversion
    • Prefer deconstructing parameters for functions instead of multiple parameters that might be of
      the same type
    • Don’t use null inside the app, only on code interacting with external interfaces/services,
      like DB and HTTP; convert to undefined before sending inwards into the code
    • Use async/await instead of .then()
    • Use the strict equality operator ===, don’t use abstract equality operator ==
    • When calling a Promise-returning function asynchronously (i.e., not awaiting), use .catch() to
      handle errors (see processAsyncError and emptyFunction depending on the case)
    • Date and Time
      • Always use buildDayjs() to create dayjs instances
      • Prefer dayjs.duration(...) to create duration consts and keep them as duration
  • Prefer Nullish Coalesce (??) than the OR operator (||) to provide a default value
  • Avoid creating arrow functions
  • Use truthy syntax instead of in - i.e., if (data.link) not if ('link' in data)
  • Error handling
    • Pass the original error as the new one’s cause so the stack trace is persisted
    • Error messages should have a static message - add dynamic data to MetriportError's additionalInfo prop
    • Avoid sending multiple events to Sentry for a single error
  • Global constants and variables
    • Move literals to constants declared after imports when possible (avoid magic numbers)
    • Avoid shared, global objects
  • Avoid using console.log and console.error in packages other than utils, infra and shared,
    and try to use out().log instead
  • Avoid multi-line logs
    • don't send objects as a second parameter to console.log() or out().log()
    • don't create multi-line strings when using JSON.stringify()
  • Use eslint to enforce code style
  • Use prettier to format code
  • max column length is 100 chars
  • multi-line comments use /** */
  • scripts: top-level comments go after the import
  • packages/api-sdk/src/medical/models/patientDTO.ts
  • packages/core/src/mpi/inbound-patient-mpi-metriport-api.ts
  • packages/core/src/command/patient-loader-metriport-api.ts
  • packages/api/src/routes/medical/dtos/patientDTO.ts
🧠 Learnings (5)
packages/carequality-sdk/package.json (1)
Learnt from: leite08
PR: metriport/metriport#3463
File: packages/api-sdk/src/medical/models/patient.ts:1-1
Timestamp: 2025-03-19T13:58:17.253Z
Learning: When changes are made to SDK packages (`api-sdk`, `commonwell-sdk`, `carequality-sdk`) or `packages/shared` in the Metriport codebase, alpha versions need to be published to NPM before merging the PR.
packages/ihe-gateway-sdk/package.json (1)
Learnt from: leite08
PR: metriport/metriport#3463
File: packages/api-sdk/src/medical/models/patient.ts:1-1
Timestamp: 2025-03-19T13:58:17.253Z
Learning: When changes are made to SDK packages (`api-sdk`, `commonwell-sdk`, `carequality-sdk`) or `packages/shared` in the Metriport codebase, alpha versions need to be published to NPM before merging the PR.
packages/commonwell-jwt-maker/package.json (1)
Learnt from: leite08
PR: metriport/metriport#3463
File: packages/api-sdk/src/medical/models/patient.ts:1-1
Timestamp: 2025-03-19T13:58:17.253Z
Learning: When changes are made to SDK packages (`api-sdk`, `commonwell-sdk`, `carequality-sdk`) or `packages/shared` in the Metriport codebase, alpha versions need to be published to NPM before merging the PR.
packages/api-sdk/package.json (1)
Learnt from: leite08
PR: metriport/metriport#3463
File: packages/api-sdk/src/medical/models/patient.ts:1-1
Timestamp: 2025-03-19T13:58:17.253Z
Learning: When changes are made to SDK packages (`api-sdk`, `commonwell-sdk`, `carequality-sdk`) or `packages/shared` in the Metriport codebase, alpha versions need to be published to NPM before merging the PR.
packages/commonwell-sdk/package.json (1)
Learnt from: leite08
PR: metriport/metriport#3463
File: packages/api-sdk/src/medical/models/patient.ts:1-1
Timestamp: 2025-03-19T13:58:17.253Z
Learning: When changes are made to SDK packages (`api-sdk`, `commonwell-sdk`, `carequality-sdk`) or `packages/shared` in the Metriport codebase, alpha versions need to be published to NPM before merging the PR.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: check-pr / lint-build-test
  • GitHub Check: check-pr / lint-build-test
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (22)
packages/infra/package.json (1)

3-3: Confirm version bump aligns with release workflow.

The package version has been updated to "1.22.4-alpha.0" to match the coordinated alpha pre-release across your ecosystem. Please ensure that this pre-release tag is handled correctly in your publishing pipeline (e.g., npm publish --tag next) and that all related packages share the same pre-release versioning cadence.

packages/mllp-server/package.json (1)

3-3: Approve version bump
The package version has been correctly updated from 0.3.3 to 0.3.4-alpha.0 to align with the coordinated alpha release cycle.

packages/core/package.json (1)

3-3: Confirm version bump for pre-release
The version has been updated to "1.24.4-alpha.0" to align with other alpha release cycles. Ensure this alpha version is published to NPM before merging.

packages/carequality-sdk/package.json (1)

3-3: Confirm alpha version bump for Carequality SDK
The version has been updated to "1.6.4-alpha.0" to align with the coordinated pre-release. Please verify that this alpha package is published to NPM before merging.

packages/shared/package.json (1)

3-3: Confirm shared package pre-release version bump
The version has been updated to "0.23.4-alpha.0" in sync with other packages. Ensure this alpha release is published to NPM prior to merging.

packages/api/package.json (1)

3-3: Confirm API package pre-release version bump
The version has been updated to "1.27.4-alpha.0". Make sure that the DTO mapping changes for hieOptOut are included in this release and that the alpha package is published to NPM before merging.

packages/commonwell-sdk/package.json (2)

3-3: Confirm commonwell-sdk package pre-release version bump
The version has been updated to "5.9.2-alpha.0" to match the pre-release cadence. Verify that this alpha version is published to NPM before merging.


63-63: Confirm shared dependency pre-release bump
The dependency @metriport/shared has been updated to "^0.23.4-alpha.0". Ensure that this shared package alpha version is available on NPM before publishing @metriport/commonwell-sdk.

packages/api-sdk/src/medical/models/patientDTO.ts (1)

14-14: Good addition of the hieOptOut flag

The new optional boolean flag hieOptOut on the PatientDTO type matches the PR objective of filtering out patients who've opted out of data sharing. This is a clean and straightforward implementation.

packages/ihe-gateway-sdk/package.json (1)

3-3: Version bumps follow proper SDK release workflow

The package version has been updated to alpha (0.19.4-alpha.0) and the dependency on @metriport/shared has been similarly updated to an alpha version. This follows the required workflow for SDK packages as per the retrieved learning.

As indicated in the retrieved learning, remember that alpha versions of SDK packages need to be published to NPM before merging this PR.

Also applies to: 56-56

packages/commonwell-cert-runner/package.json (1)

3-3: Version bumps follow proper SDK release workflow

The package version has been updated to alpha (1.26.4-alpha.0) and the dependency on @metriport/commonwell-sdk has been similarly updated to an alpha version. This follows the required workflow for SDK packages.

Make sure to publish this alpha version to NPM before merging the PR.

Also applies to: 45-45

packages/commonwell-jwt-maker/package.json (1)

3-3: Version bumps follow proper SDK release workflow

The package version has been updated to alpha (1.24.4-alpha.0) and the dependency on @metriport/commonwell-sdk has been similarly updated to an alpha version. This follows the required workflow for SDK packages.

Remember to publish this alpha version to NPM as part of the release workflow prior to merging.

Also applies to: 44-44

packages/api-sdk/package.json (2)

3-3: Version increment for new feature looks good

The package version has been correctly incremented to an alpha pre-release to support the new hieOptOut property addition to patient DTOs.


61-62: Dependency updates align with feature implementation

Dependencies have been properly updated to their alpha versions to maintain compatibility with the hieOptOut feature implementation across packages.

Based on previous learnings, remember that these alpha versions will need to be published to NPM before merging the PR.

packages/core/src/command/patient-loader-metriport-api.ts (1)

121-121: Well implemented opt-out flag with proper default

The hieOptOut field has been correctly added to the Patient domain object with a appropriate default value of false when not present in the DTO.

The implementation follows coding guidelines by using the nullish coalescing operator (??) for providing the default value instead of the OR operator.

packages/core/src/mpi/inbound-patient-mpi-metriport-api.ts (2)

26-27: Good implementation of patient opt-out filtering

The code correctly filters out patients who have opted out of HIE before performing matching, which directly fulfills the PR objective of ensuring opted-out patient data is not shared back.

The implementation follows the functional programming style recommended in the coding guidelines by using filter() instead of modifying the original array, and uses a descriptive variable name for clarity.


31-31: Proper use of filtered patient list

The code now correctly passes only the opted-in patients to the matching algorithm.

packages/carequality-cert-runner/package.json (2)

3-3: Version increment follows semantic versioning

The package version has been correctly incremented to an alpha pre-release for including the new HIE opt-out feature.


44-45: Dependencies properly updated

Dependencies have been correctly updated to their alpha versions to maintain compatibility with the new feature across packages.

packages/api/src/routes/medical/dtos/patientDTO.ts (3)

13-13: Proper extension of PatientDTO type

The addition of hieOptOut as an optional boolean property follows the project's naming conventions and correctly implements the requirement to track patient opt-out status.


32-32: Correct mapping of hieOptOut in dtoFromModel

Properly maps the hieOptOut flag from the patient model to the DTO, ensuring the opt-out status is preserved during API responses.


61-61: Correct mapping of hieOptOut in internalDtoFromModel

Correctly maps the hieOptOut property to the internal DTO, maintaining consistency between regular and internal DTOs.

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.

2 participants
0