-
Notifications
You must be signed in to change notification settings - Fork 72
199/72 canvas/elation/athena contribution plumbing #3788
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
WalkthroughThis change set refactors and modularizes the EHR bundle/resource diff job infrastructure, removing legacy Canvas-specific resource diff logic and generalizing the workflow to support multiple EHRs. It introduces new utility modules for bundle and job management, updates API routes and handlers, and replaces direct Lambda invocations with SQS-driven job orchestration. Several files are deleted or replaced, type definitions are updated, and error handling and retry logic are improved throughout the codebase. Changes
Sequence Diagram(s)Generalized Resource Diff Bundle Job FlowsequenceDiagram
participant API as API Route
participant JobStarter as startCreateResourceDiffBundlesJob
participant JobDB as PatientJob Store
participant BundleRefresher as refreshEhrBundles
participant SQS as SQS Queue
participant Lambda as Lambda Worker
participant S3 as S3 Storage
API->>JobStarter: POST /internal/ehr/:ehrId/patient/:id/resource/diff (start job)
JobStarter->>JobDB: Create patient job (type: resource-diff)
JobStarter->>BundleRefresher: For each supported resource type, refreshEhrBundles(...)
BundleRefresher->>SQS: Send refresh job message
SQS->>Lambda: Trigger Lambda for refresh
Lambda->>S3: Create/replace empty diff bundles (Metriport-only, EHR-only)
Lambda->>SQS: Send compute diff job message
SQS->>Lambda: Trigger Lambda for compute
Lambda->>S3: Fetch resources, compute diff, update bundles
Lambda->>JobDB: Update job entry status (successful/failed)
Fetching Resource Diff Job PayloadsequenceDiagram
participant API as API Route
participant JobDB as PatientJob Store
participant BundleFetcher as fetchBundlePreSignedUrls
API->>JobDB: Fetch patient job by jobId
alt job.status == "completed"
API->>BundleFetcher: fetchBundlePreSignedUrls(...)
BundleFetcher->>API: Return pre-signed URLs
API->>API: Compose and return job payload with URLs
else
API->>API: Return job payload (no URLs)
end
Refreshing EHR BundlessequenceDiagram
participant API as API Route
participant BundleRefresher as refreshEhrBundles
participant SQS as SQS Queue
participant Lambda as Lambda Worker
participant S3 as S3 Storage
API->>BundleRefresher: POST /internal/ehr/:ehrId/patient/:id/resource/refresh
BundleRefresher->>SQS: Send refresh job message
SQS->>Lambda: Trigger Lambda for refresh
Lambda->>S3: Refresh EHR bundle for resource type
Lambda->>JobDB: Update job entry status
JWT Token Management (Generalized)sequenceDiagram
participant API as API Route
participant JWTUtils as checkJwtToken/saveJwtToken
participant TokenStore as JWT Token Store
API->>JWTUtils: checkJwtToken({token, source})
JWTUtils->>TokenStore: getJwtToken({token, source})
TokenStore-->>JWTUtils: Token info
JWTUtils-->>API: {active, expired?}
API->>JWTUtils: saveJwtToken({token, source, exp, data})
JWTUtils->>TokenStore: findOrCreateJwtToken(...)
TokenStore-->>JWTUtils: (persisted)
JWTUtils-->>API: (done)
SQS-Based Resource Diff ComputationsequenceDiagram
participant JobStarter as startCreateResourceDiffBundlesJob
participant SQS as SQS Queue
participant Lambda as Lambda Worker
participant S3 as S3 Storage
JobStarter->>SQS: Send compute diff job message (per resource type)
SQS->>Lambda: Trigger Lambda for compute
Lambda->>S3: Fetch resources, compute diff, update bundles
Lambda->>JobDB: Update job entry status
These diagrams represent the new modular, EHR-agnostic resource diff and bundle management workflows, reflecting the new control flow and infrastructure introduced by this change set. 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 🪧 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 (
|
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
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.
moved into /shared/utils/jwt-token.ts
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.
JWT stuff moved into /shared/utils/jwt-token.ts
Appointments stuff moved into /shared/utils/appointment.ts
External ID stuff moved into /shared/utils/external-id.ts
Client stuff moved into /shared/utils/client.ts
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
… 199-elation-contribution Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
@@ -56,7 +55,6 @@ export async function recreateConsolidated({ | |||
createResourceDiffBundles({ | |||
cxId: patient.cxId, | |||
patientId: patient.id, | |||
direction: ResourceDiffDirection.METRIPORT_ONLY, |
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.
The resource diff job now computes both directions at once.
@@ -45,7 +48,3 @@ export async function createCanvasClient( | |||
getClient: CanvasApi.create, | |||
}); | |||
} | |||
|
|||
export function getCreateCanvasResourceDiffBundlesJobType(direction: ResourceDiffDirection) { |
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.
Moved to jobs utils file
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-199 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
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.
Taken from old shared file.
Issues:
Dependencies
Description
Testing
Release Plan
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Chores
Documentation