-
Notifications
You must be signed in to change notification settings - Fork 68
RELEASE Retry CW + Validate before IO + Don't load bundle unnecessarily #3783
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
Conversation
Ref eng-141 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Ref eng-141 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Ref eng-141 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Ref eng-238 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Backmerge master into develop
Ref eng-237 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Ref eng-237 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Ref eng-237 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
Ref: #000 - api@1.27.2-alpha.0 - @metriport/api-sdk@14.14.2-alpha.0 - @metriport/carequality-cert-runner@1.18.2-alpha.0 - @metriport/carequality-sdk@1.6.2-alpha.0 - @metriport/commonwell-cert-runner@1.26.2-alpha.0 - @metriport/commonwell-jwt-maker@1.24.2-alpha.0 - @metriport/commonwell-sdk@5.9.0-alpha.0 - @metriport/core@1.24.2-alpha.0 - @metriport/ihe-gateway-sdk@0.19.2-alpha.0 - infrastructure@1.22.2-alpha.0 - mllp-server@0.3.2-alpha.0 - @metriport/shared@0.23.2-alpha.0 - utils@1.25.2-alpha.0 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
…ibution ENG-238 Validate contributed bundle before hitting the DB
…doesnt-load-bundle ENG-191 Only load the bundle when converting
ENG-237 Retry CW patient create on 500
WalkthroughThis set of changes introduces retry logic for HTTP 500 errors in the CommonWell SDK, updates several package versions and dependencies, and modifies the handling of consolidated patient data and data contr
8000
ibution workflows. The CommonWell client now accepts options for retrying failed requests. The consolidated data flow is refactored to propagate a Changes
Sequence Diagram(s)CommonWell Client Retry LogicsequenceDiagram
participant Caller
participant CommonWell
participant Network
Caller->>CommonWell: registerPatient(meta, patient)
CommonWell->>CommonWell: executeWithRetriesOn500(fn)
alt onError500.retry == true
CommonWell->>Network: API call (retry on 500)
Network-->>CommonWell: Response (may retry up to 3 times)
else onError500.retry == false
CommonWell->>Network: API call (no retry)
Network-->>CommonWell: Response
end
CommonWell-->>Caller: Patient result
Consolidated Data Contribution FlowsequenceDiagram
participant Route
participant handleDataContribution
participant handleBundleToMedicalRecord
participant Analytics
Route->>handleDataContribution: ({ requestId, patient, cxId, bundle })
handleDataContribution->>handleBundleToMedicalRecord: ({ bundle, patient, requestId, ... })
handleBundleToMedicalRecord->>Analytics: analytics('consolidatedQuery', ...)
handleBundleToMedicalRecord-->>handleDataContribution: Converted bundle
handleDataContribution-->>Route: Result
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
🪧 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 (
|
Backmerge master into develop
Ref: #000 - api@1.27.2 - @metriport/api-sdk@14.14.2 - @metriport/carequality-cert-runner@1.18.2 - @metriport/carequality-sdk@1.6.2 - @metriport/commonwell-cert-runner@1.26.2 - @metriport/commonwell-jwt-maker@1.24.2 - @metriport/commonwell-sdk@5.9.0 - @metriport/core@1.24.2 - @metriport/ihe-gateway-sdk@0.19.2 - infrastructure@1.22.2 - mllp-server@0.3.2 - @metriport/shared@0.23.2 - utils@1.25.2 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
ENG-237 Publish packages to NPM
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: 1
🧹 Nitpick comments (5)
packages/api/src/command/medical/patient/consolidated-recreate.ts (1)
45-54
: Good implementation of alternative flow when conversion type is absent.The implementation now provides two paths:
- Using
getConsolidated
when conversion type is specified- Using the snapshot connector with
isAsync: false
when conversion type is missingThis aligns with the PR objectives to avoid unnecessary bundle loading.
Consider updating the error message in line 64 to reflect that either
getConsolidated
or the snapshot connector might be used:- processAsyncError(`Post-DQ getConsolidated`, log)(err); + processAsyncError(`Post-DQ consolidated recreation`, log)(err);packages/api/src/command/medical/patient/data-contribution/handle-data-contributions.ts (2)
43-49
: Improved parallel execution by removing patient fetch.The Promise.all now only needs to fetch the organization since patient is passed directly, improving efficiency.
The log message on line 50 should be updated to reflect that we're no longer fetching the patient:
- log(`${Date.now() - mainStartedAt}ms to get org and patient, and store on S3`); + log(`${Date.now() - mainStartedAt}ms to get org and store bundle on S3`);
53-56
: Update log timing description to match code flow.The validation timing log message refers to hydration and validation steps that now occur before the timing starts.
Update the log message to reflect when these operations actually occur:
- log(`${Date.now() - validationStartedAt}ms to hydrate, validate, and check limits`); + log(`${Date.now() - validationStartedAt}ms to convert organization to FHIR and check resource limits`);packages/core/src/command/consolidated/get-snapshot-local.ts (1)
128-138
: Add analytics tracking for consolidated query performance.This implementation tracks query duration and resource count, aligning with the PR objectives for improved monitoring.
Consider adding a null check for the consolidated query progress:
- const currentConsolidatedProgress = getConsolidatedQueryByRequestId(patient, requestId); - analytics({ - distinctId: cxId, - event: EventTypes.consolidatedQuery, - properties: { - patientId: patientId, - conversionType: "bundle", - duration: elapsedTimeFromNow(currentConsolidatedProgress?.startedAt), - resourceCount: resultBundle.entry?.length, - }, - }); + const currentConsolidatedProgress = getConsolidatedQueryByRequestId(patient, requestId); + if (requestId) { + analytics({ + distinctId: cxId, + event: EventTypes.consolidatedQuery, + properties: { + patientId: patientId, + conversionType: "bundle", + duration: currentConsolidatedProgress?.startedAt + ? elapsedTimeFromNow(currentConsolidatedProgress.startedAt) + : undefined, + resourceCount: resultBundle.entry?.length, + }, + }); + }packages/api/src/command/medical/patient/convert-fhir-bundle.ts (1)
88-98
: Add analytics tracking for consolidated query performance.This implementation complements the tracking added in get-snapshot-local.ts, centralizing analytics for medical record conversions.
Similar to the previous file, consider adding checks for requestId and query progress:
- const currentConsolidatedProgress = getConsolidatedQueryByRequestId(patient, requestId); - analytics({ - distinctId: patient.cxId, - event: EventTypes.consolidatedQuery, - properties: { - patientId: patient.id, - conversionType, - duration: elapsedTimeFromNow(currentConsolidatedProgress?.startedAt), - resourceCount: newBundle.entry?.length, - }, - }); + if (requestId) { + const currentConsolidatedProgress = getConsolidatedQueryByRequestId(patient, requestId); + analytics({ + distinctId: patient.cxId, + event: EventTypes.consolidatedQuery, + properties: { + patientId: patient.id, + conversionType, + duration: currentConsolidatedProgress?.startedAt + ? elapsedTimeFromNow(currentConsolidatedProgress.startedAt) + : undefined, + resourceCount: newBundle.entry?.length, + }, + }); + }Also, consider using a try/catch block to prevent analytics errors from affecting the main function flow:
if (requestId) { try { // Analytics code here } catch (err) { log(`Failed to send analytics: ${err}`); } }
📜 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 (26)
packages/api-sdk/package.json
(2 hunks)packages/api/package.json
(1 hunks)packages/api/src/command/medical/patient/consolidated-get.ts
(5 hunks)packages/api/src/command/medical/patient/consolidated-recreate.ts
(2 hunks)packages/api/src/command/medical/patient/convert-fhir-bundle.ts
(3 hunks)packages/api/src/command/medical/patient/data-contribution/handle-data-contributions.ts
(2 hunks)packages/api/src/external/commonwell/api.ts
(3 hunks)packages/api/src/routes/helpers/default-error-handler.ts
(1 hunks)packages/api/src/routes/medical/patient.ts
(1 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/commonwell-sdk/src/client/commonwell.ts
(8 hunks)packages/commonwell-sdk/src/common/metriport-error.ts
(0 hunks)packages/core/package.json
(1 hunks)packages/core/src/command/consolidated/get-snapshot-local.ts
(7 hunks)packages/core/src/domain/patient.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/shared/src/error/metriport-error.ts
(1 hunks)packages/shared/src/net/retry.ts
(2 hunks)packages/utils/package.json
(1 hunks)
💤 Files with no reviewable changes (1)
- packages/commonwell-sdk/src/common/metriport-error.ts
🧰 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/src/routes/medical/patient.ts
packages/shared/src/net/retry.ts
packages/api/src/external/commonwell/api.ts
packages/shared/src/error/metriport-error.ts
packages/api/src/routes/helpers/default-error-handler.ts
packages/core/src/domain/patient.ts
packages/api/src/command/medical/patient/consolidated-recreate.ts
packages/api/src/command/medical/patient/consolidated-get.ts
packages/core/src/command/consolidated/get-snapshot-local.ts
packages/api/src/command/medical/patient/convert-fhir-bundle.ts
packages/api/src/command/medical/patient/data-contribution/handle-data-contributions.ts
packages/commonwell-sdk/src/client/commonwell.ts
🧠 Learnings (2)
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/shared/src/error/metriport-error.ts (1)
Learnt from: husainsyed
PR: metriport/metriport#3655
File: packages/shared/src/validators/driver-license/index.ts:1-89
Timestamp: 2025-04-10T21:17:35.036Z
Learning: MetriportError constructor takes three separate parameters: message (string), cause (optional unknown), and additionalInfo (optional object), not a single object with these properties. The correct instantiation is: new MetriportError(message, cause, additionalInfo).
🧬 Code Graph Analysis (4)
packages/api/src/routes/medical/patient.ts (1)
packages/api/src/command/medical/patient/data-contribution/handle-data-contributions.ts (1)
handleDataContribution
(19-90)
packages/shared/src/net/retry.ts (1)
packages/shared/src/error/metriport-error.ts (1)
isMetriportError
(13-15)
packages/api/src/external/commonwell/api.ts (1)
packages/commonwell-sdk/src/client/commonwell.ts (2)
CommonWellOptions
(71-74)CommonWell
(76-1017)
packages/commonwell-sdk/src/client/commonwell.ts (2)
packages/shared/src/common/retry.ts (1)
ExecuteWithRetriesOptions
(21-45)packages/shared/src/net/retry.ts (2)
executeWithNetworkRetries
(108-135)defaultOptionsRequestNotAccepted
(26-33)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: check-pr / lint-build-test
- GitHub Check: check-pr / lint-build-test
- GitHub Check: api / deploy
- GitHub Check: mllp-server / deploy
- GitHub Check: infra-api-lambdas / deploy
- GitHub Check: infra-hl7-notification / deploy
🔇 Additional comments (54)
packages/utils/package.json (1)
3-3
: Approve version bump to 1.25.2
The version increment is consistent with the coordinated release plan and introduces no breaking changes.packages/api/package.json (1)
3-3
: Version bump to 1.27.2
The package version has been correctly incremented to align with the coordinated release across related Metriport packages.packages/infra/package.json (1)
3-3
: Approve version bump to 1.22.2
This update correctly increments the package version to align with the coordinated release across related packages.
Note: The AI-generated summary describes additional code changes that aren’t present here—this file only contains the version bump.Likely an incorrect or invalid review comment.
packages/carequality-sdk/package.json (1)
3-3
: Approve version bump to 1.6.2
Theversion
field has been correctly updated from1.6.1
to1.6.2
with no other changes.packages/shared/package.json (1)
3-3
: Consistent version bump for @metriport/shared
The package version has been updated from 0.23.1 to 0.23.2 in line with the coordinated releases across the monorepo.packages/core/package.json (1)
3-3
: Consistent version bump for @metriport/core
The package version has been updated from 1.24.1 to 1.24.2 to align with the shared release plan.packages/commonwell-sdk/package.json (2)
3-3
: Consistent SDK version bump for @metriport/commonwell-sdk
The package version has been incremented from 5.8.1 to 5.9.0, matching the PR’s release strategy.
63-63
: Upgrade dependency on @metriport/shared
The dependency on@metriport/shared
has been updated to^0.23.2
to reflect the new shared package version.packages/commonwell-jwt-maker/package.json (1)
3-3
: Consistent version bump for @metriport/commonwell-jwt-maker
The package version has been updated from 1.24.1 to 1.24.2, aligning with the SDK’s release.packages/ihe-gateway-sdk/package.json (2)
3-3
: Consistent version bump for @metriport/ihe-gateway-sdk
The package version has been updated from 0.19.1 to 0.19.2, consistent with the shared release increments.
56-56
: Upgrade dependency on @metriport/shared
The dependency on@metriport/shared
has been updated to^0.23.2
to maintain cross-package compatibility.packages/commonwell-cert-runner/package.json (2)
3-3
: Version increment looks good.Version has been incremented from 1.26.1 to 1.26.2 as part of the coordinated release.
45-45
:✅ Verification successful
Dependency update for CommonWell SDK aligns with release.
The dependency on
@metriport/commonwell-sdk
has been updated to ^5.9.0 to incorporate the new retry logic for HTTP 500 errors.
🏁 Script executed:
#!/bin/bash # Verify that the CommonWell SDK 5.9.0 version exists on NPM npm view @metriport/commonwell-sdk versions --json | jq 'map(select(. == "5.9.0"))'Length of output: 99
Approve CommonWell SDK update to ^5.9.0
Confirmed that
@metriport/commonwell-sdk@5.9.0
exists on npm, and this update brings in the new retry logic for HTTP 500 errors as intended.• packages/commonwell-cert-runner/package.json: line 45
packages/api-sdk/package.json (3)
3-3
: Version increment looks good.Version has been incremented from 14.14.1 to 14.14.2 as part of the coordinated release.
1-81
: Reminder: Publish alpha version to NPM before merging.Based on previous learnings, when changes are made to SDK packages like
api-sdk
, alpha versions need to be published to NPM before merging the PR.
61-62
:✅ Verification successful
Dependency updates align with the coordinated release.
The updates to both dependencies are consistent with the version changes across the ecosystem:
@metriport/commonwell-sdk
from 5.8.1 to ^5.9.0@metriport/shared
from 0.23.1 to ^0.23.2
🏁 Script executed:
#!/bin/bash # Verify that the required dependency versions exist on NPM echo "Checking CommonWell SDK 5.9.0..." npm view @metriport/commonwell-sdk versions --json | jq 'map(select(. == "5.9.0"))' echo "Checking Shared 0.23.2..." npm view @metriport/shared versions --json | jq 'map(select(. == "0.23.2"))'Length of output: 329
Approve coordinated dependency updates
Verified that@metriport/commonwell-sdk@5.9.0
and@metriport/shared@0.23.2
are published on NPM and the version bumps align with the coordinated release.• File: packages/api-sdk/package.json (lines 61–62)
"@metriport/commonwell-sdk": "^5.9.0", "@metriport/shared": "^0.23.2",packages/shared/src/error/metriport-error.ts (1)
13-15
: Well-implemented type guard for MetriportError.The
isMetriportError
function follows TypeScript best practices by:
- Using the type predicate pattern
err is MetriportError
to narrow down the type- Correctly implementing the instance check using
instanceof
- Taking
unknown
as the parameter type to enforce type safetyThis will improve error handling consistency throughout the codebase.
packages/carequality-cert-runner/package.json (2)
3-3
: Version increment looks good.Version has been incremented from 1.18.1 to 1.18.2 as part of the coordinated release.
44-45
:✅ Verification successful
Dependency updates align with the coordinated release.
The updates to both dependencies are consistent with the version changes across the ecosystem:
@metriport/ihe-gateway-sdk
from ^0.19.1 to ^0.19.2@metriport/shared
from ^0.23.1 to ^0.23.2
🏁 Script executed:
#!/bin/bash # Verify that the required dependency versions exist on NPM echo "Checking IHE Gateway SDK 0.19.2..." npm view @metriport/ihe-gateway-sdk versions --json | jq 'map(select(. == "0.19.2"))' echo "Checking Shared 0.23.2..." npm view @metriport/shared versions --json | jq 'map(select(. == "0.23.2"))'Length of output: 336
Dependencies updated successfully and align with coordinated release
- File:
packages/carequality-cert-runner/package.json
(lines 44–45)- Verified that:
@metriport/ihe-gateway-sdk@^0.19.2
is published on NPM@metriport/shared@^0.23.2
is published on NPM- These bumps match the ecosystem’s move from 0.19.1→0.19.2 and 0.23.1→0.23.2
All set to approve.
packages/shared/src/net/retry.ts (2)
10-10
: Good import of the new type guard.Properly importing the newly created
isMetriportError
type guard from the error module.
51-52
: Improved error handling with type safety.Two important improvements to the error handling:
Changed from property access pattern checking with
"cause" in error
to a more direct truthiness check witherror.cause
, which is cleaner and follows the coding guidelines.Added proper type-safe error handling using the new
isMetriportError
type guard, enhancing the reliability of status code extraction.packages/api/src/routes/medical/patient.ts (2)
365-365
: Update to pass full patient object instead of just patient ID.The function now correctly extracts the full patient object rather than just the ID, supporting the updated method signature of
handleDataContribution
.
367-367
: Correctly updates handleDataContribution parameter.This change passes the complete patient object to
handleDataContribution
instead of just the patient ID, ensuring proper function invocation with the updated signature.packages/core/src/domain/patient.ts (1)
128-133
: Good implementation o 8000 f a utility function.This function provides a clean way to find a consolidated query by requestId. The implementation is:
- Type-safe (uses proper parameter typing)
- Functional (pure function with single input/output)
- Concise (uses optional chaining for null safety)
packages/api/src/routes/helpers/default-error-handler.ts (1)
108-120
: Improved error handling consistency.This change enhances error handling by checking both
err.statusCode
anderr.status
properties, ensuring consistent status extraction regardless of which property is present. This is a good practice since different error implementations might use different property names.packages/api/src/external/commonwell/api.ts (4)
9-9
: Added import for CommonWellOptions.Correctly imports the CommonWellOptions type to support the new retry configuration.
48-54
: Added retry logic for HTTP 500 errors.This configuration implements a resilient approach to handling HTTP 500 errors from CommonWell:
- Retries up to 3 attempts
- Uses an initial delay of 1 second
- Follows best practices for error resilience
This is a valuable improvement that will help handle transient server errors without application failure.
58-65
: Added retry options to member API constructor.Correctly passes the retry options to the member API instance of CommonWell.
68-75
: Added retry options to organization API constructor.Correctly passes the retry options to the organization API instance of CommonWell.
packages/api/src/command/medical/patient/consolidated-recreate.ts (1)
3-4
: New imports support the alternative consolidated recreation flow.These imports enable the new code path for recreating consolidated bundle without a conversion type.
packages/api/src/command/medical/patient/data-contribution/handle-data-contributions.ts (4)
3-3
: Import of Patient type to support the signature change.This import enables the function to accept a full Patient object instead of just a patient ID.
19-28
: Good refactoring to accept Patient object directly instead of patientId.This change eliminates the need to fetch the patient separately, improving efficiency and aligning with the PR objectives.
30-30
: Extract patientId from patient object.This extraction maintains backward compatibility in the function implementation while using the newly passed patient object.
39-41
: Good restructuring to perform normalization and validation earlier.Moving these operations earlier in the function follows the "fail fast" principle, which can improve error handling and performance.
packages/core/src/command/consolidated/get-snapshot-local.ts (6)
11-12
: Import analytics and query tracking capabilities.These imports support the new analytics features added to track consolidated query performance.
38-39
: Improved parameter destructuring.The code now properly extracts patient and requestId from params, and patientId and cxId from patient, making the data flow more explicit.
44-44
: Directly use patient object from the extracted parameters.This change makes the code more consistent with the parameter destructuring above.
66-66
: Introduce resultBundle to standardize bundle references.This improves code consistency by using a standard variable name for the final bundle result.
69-69
: Use resultBundle consistently for validation and error handling.The code now consistently uses resultBundle where it previously used normalizedBundle.
Also applies to: 80-80
89-89
: Update Promise.all array destructuring and S3 upload references.The code correctly uses resultBundle for S3 uploads and destructures resultS3Info from the Promise results.
Also applies to: 105-105, 110-110
packages/api/src/command/medical/patient/convert-fhir-bundle.ts (3)
13-14
: Import analytics and query tracking utilities.These imports support the new analytics tracking functionality for consolidated queries.
18-18
: Import elapsed time calculation utility.This utility enables measurement of query duration for analytics purposes.
44-44
: Add optional requestId parameter to enable query tracking.This parameter allows the function to track and report analytics for specific query requests.
Also applies to: 52-52
packages/api/src/command/medical/patient/consolidated-get.ts (3)
54-54
: Type modification follows consistent patternAdding the optional requestId parameter to GetConsolidatedPatientData type follows the existing pattern in the code and enables proper request tracing through the system.
264-264
: Properly propagating requestId parameterThe requestId is now being correctly passed to getConsolidatedPatientData, which aligns with the goal of propagating this identifier throughout the data flow.
281-281
: Correctly forwarding requestId to bundle conversionThe requestId is now being properly passed to handleBundleToMedicalRecord, ensuring consistent tracking throughout the process. This change works alongside the analytics centralization mentioned in the summary.
packages/commonwell-sdk/src/client/commonwell.ts (8)
1-7
: Improved imports from shared packageGood use of shared utilities for error handling and retry logic. This promotes code reuse and standardization across the application.
48-52
: Well-structured default options for 500 error handlingThe default configuration is well-defined with conservative defaults (retry disabled), ensuring backward compatibility with existing behavior.
67-74
: Well-designed type definitions for retry optionsThe type definitions are clean and follow TypeScript best practices. The OnError500Options type properly extends ExecuteWithRetriesOptions while adding the necessary retry flag, and CommonWellOptions provides a clear interface for configuring the client.
94-94
: Private property follows naming conventionsThe private onError500 property follows the established naming conventions in the class and properly encapsulates the configuration.
113-113
: Backward-compatible constructor parameterMaking the options parameter optional with a default empty object ensures backward compatibility with existing code that doesn't specify options.
129-129
: Proper initialization with defaultsGood use of object spreading to merge default options with user-provided options, following the best practice for handling configuration objects.
634-642
: Added retry mechanism for registerPatientThe implementation correctly wraps the API call with the retry logic. This addresses the PR objective to add retry capability for the CommonWell client, specifically targeting HTTP 500 errors.
1005-1016
: Well-implemented retry utility methodThe executeWithRetriesOn500 method is well-designed and:
- Conditionally applies retry logic based on configuration
- Properly merges all HTTP codes to retry
- Specifically adds the 500 status code to the retry list
- Falls back to direct function execution when retries are disabled
This implementation follows functional programming principles with minimal state changes.
Ref metriport/metriport-internal#799 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
…rock-access 799 Always add permission to bedrock on FHIR Converter
Ref metriport/metriport-internal#1040 Signed-off-by: Rafael Leite <2132564+leite08@users.noreply.github.com>
1040 E2E: Add "text" to allergy intollerance and doc ref
The merge-base changed after approval.
Issues:
Dependencies
none
Description
Testing
Check each PR.
Release Plan
master
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Chores