-
Notifications
You must be signed in to change notification settings - Fork 68
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
base: develop
Are you sure you want to change the base?
Conversation
Part of cs-463 Signed-off-by: Jorge Orta <36802074+Orta21@users.noreply.github.com>
WalkthroughThis update introduces a new optional boolean property, Changes
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)
Possibly related PRs
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit 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. Note ⚡️ Faster reviews with cachingCodeRabbit 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 ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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>
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>
There was a problem hiding this 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 from1.25.3
to1.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 thealpha
tag.packages/api/src/routes/medical/dtos/patientDTO.ts (1)
8-14
: Consider explicit documentation for filtering behaviorThe addition of the
hieOptOut
property is well-implemented. Consider adding a JSDoc comment explaining that patients with this flag set totrue
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
⛔ 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
, preferisDisabled
- For numeric values, if the type doesn’t convey the unit, add the unit to the name
- Typescript
- Use types
- Prefer
const
instead oflet
- Avoid
any
and casting fromany
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 toundefined
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 (seeprocessAsyncError
andemptyFunction
depending on the case)- Date and Time
- Always use
buildDayjs()
to createdayjs
instances- Prefer
dayjs.duration(...)
to create duration consts and keep them asduration
- 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)
notif ('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
andconsole.error
in packages other than utils, infra and shared,
and try to useout().log
instead- Avoid multi-line logs
- don't send objects as a second parameter to
console.log()
orout().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 from0.3.3
to0.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 forhieOptOut
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 thehieOptOut
flagThe 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 workflowThe 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 workflowThe 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 workflowThe 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 goodThe 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 implementationDependencies 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 defaultThe
hieOptOut
field has been correctly added to the Patient domain object with a appropriate default value offalse
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 filteringThe 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 listThe 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 versioningThe package version has been correctly incremented to an alpha pre-release for including the new HIE opt-out feature.
44-45
: Dependencies properly updatedDependencies 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 typeThe 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 dtoFromModelProperly 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 internalDtoFromModelCorrectly maps the hieOptOut property to the internal DTO, maintaining consistency between regular and internal DTOs.
Part of cs-463
Issues:
Dependencies
Description
Testing
Release Plan
Summary by CodeRabbit
New Features
Chores