-
Notifications
You must be signed in to change notification settings - Fork 68
feat(healthie): supporting group sessions #3773
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
WalkthroughThe changes update the handling of appointment attendees across several modules to support multiple patients per appointment, rather than just a single patient. The function for retrieving patients from an appointment now returns all attendee IDs as an array. Downstream logic in the appointment processing and webhook handler modules is updated to iterate over all patients from each appointment, applying updates and synchronization per patient. Additionally, internal logic for constructing attendee arrays in the Healthie API integration is modified to prepend the first attendee to the list, preserving all attendees. A queue alarm threshold is also increased from 2 to 12 hours. Changes
Sequence Diagram(s)sequenceDiagram
participant Webhook as Appointment Webhook
participant HealthieAPI as Healthie API
participant PatientUpdater as Patient Quick Note Updater
participant SyncHandler as Patient Sync Handler
Webhook->>HealthieAPI: getHealthiePatientsFromAppointment(appointmentId)
HealthieAPI-->>Webhook: [patientId1, patientId2, ...]
alt No patients
Webhook-->>Webhook: Return early, no action
else Patients found
loop For each patientId
Webhook->>PatientUpdater: updateQuickNote(patientId)
alt Patient processing enabled
Webhook->>SyncHandler: buildSyncHandler()
Webhook->>SyncHandler: processPatientSync(patientId, ...)
end
end
end
sequenceDiagram
participant Processor as Appointment Processor
participant HealthieAPI as Healthie API
Processor->>HealthieAPI: getAppointments()
HealthieAPI-->>Processor: [appointment1, appointment2, ...]
loop For each appointment
loop For each attendee in appointment.attendees
Processor-->>Processor: Map to { cxId, practiceId, patientId: attendee.id }
end
end
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error code ERR_SSL_WRONG_VERSION_NUMBER 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (4)
✨ 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 (
|
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 (1)
packages/core/src/external/ehr/healthie/index.ts (1)
346-346
: Same duplication pattern applied in getAppointment method.This implements the same pattern of duplicating the first attendee at the beginning of the array as seen in the
getAppointments
method. Consider if this duplication is necessary or if it would be cleaner to have a distinct array without duplicates.If backward compatibility isn't a concern, consider returning a deduplicated array:
-return { ...appointment, attendees: [attendee, ...appointment.attendees] }; +return { ...appointment, attendees: [...new Set([attendee, ...appointment.attendees].map(a => a.id))].map(id => + appointment.attendees.find(a => a.id === id)!) +};
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/api/src/external/ehr/healthie/command/get-patients-from-appointment.ts
(1 hunks)packages/api/src/external/ehr/healthie/command/process-patients-from-appointments.ts
(1 hunks)packages/api/src/routes/ehr/healthie/appointment-webhook.ts
(2 hunks)packages/core/src/external/ehr/healthie/index.ts
(2 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- A 8000 void 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/core/src/external/ehr/healthie/index.ts
packages/api/src/routes/ehr/healthie/appointment-webhook.ts
packages/api/src/external/ehr/healthie/command/get-patients-from-appointment.ts
packages/api/src/external/ehr/healthie/command/process-patients-from-appointments.ts
🧬 Code Graph Analysis (2)
packages/api/src/routes/ehr/healthie/appointment-webhook.ts (2)
packages/api/src/external/ehr/healthie/command/get-patients-from-appointment.ts (1)
getHealthiePatientsFromAppointment
(11-24)packages/api/src/external/ehr/healthie/command/sync-patient.ts (1)
updateHealthiePatientQuickNotes
(187-200)
packages/api/src/external/ehr/healthie/command/get-patients-from-appointment.ts (1)
packages/api/src/external/ehr/healthie/shared.ts (1)
createHealthieClient
(100-109)
⏰ 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 (6)
packages/api/src/external/ehr/healthie/command/process-patients-from-appointments.ts (1)
188-191
: Great implementation for supporting multiple attendees per appointment.The change from processing only the first attendee to mapping across all attendees aligns perfectly with the PR objective of supporting group sessions. The use of
flatMap
followed bymap
is a clean functional approach that produces one object per attendee, enabling patient record creation for all group session participants.packages/api/src/external/ehr/healthie/command/get-patients-from-appointment.ts (2)
11-16
: Good function renaming to reflect multiple patients.The renaming from
getHealthiePatientFromAppointment
togetHealthiePatientsFromAppointment
and the return type change toPromise<string[]>
clearly communicate that multiple patients are now being returned, improving code readability.
22-23
: Clean implementation for returning all patient IDs.The change correctly returns an empty array when no appointment is found and maps all attendees to extract their IDs when an appointment exists. This approach is concise and aligns well with functional programming principles recommended in the coding guidelines.
packages/api/src/routes/ehr/healthie/appointment-webhook.ts (3)
10-10
: Updated import to use new multiple patients function.The import change correctly reflects the renamed function that now returns multiple patient IDs.
46-51
: Good pattern for fetching and validating multiple patients.The implementation now correctly retrieves an array of patient IDs and checks if the array is empty before proceeding, adapting well to the new multi-patient model.
52-69
: Well-structured loop for processing multiple patients.The for-loop implementation efficiently processes each patient individually, applying the same logic (updating quick notes and optional sync) to each patient. The use of
continue
when patient processing is disabled is a clean way to skip unnecessary operations while maintaining the loop structure.One minor observation: This implementation processes patients sequentially. If the number of patients in group sessions could be large, consider using a parallel processing approach similar to how
executeAsynchronously
is used elsewhere in the codebase.
… 1040-patch-healthie Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-00 Ref: #1040 Signed-off-by: Thomas Yopes <thomasyopes@Thomass-MBP.attlocal.net>
Ref: ENG-82
Ref: #1040
Issues:
Description
Testing
Release Plan
Summary by CodeRabbit