-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add full patient's demographic details to patients summary #48
Conversation
This logic here retrieves the patient from the client registry and then adds it to the patients summary
WalkthroughThis update focuses on version upgrades and enhancements in handling patient summaries. The Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant fetchPatientSummaries
participant fetchPatientById
participant MPI
Client->>fetchPatientSummaries: Request Patient Summaries
fetchPatientSummaries->>fetchPatientById: Fetch Patient by ID (async)
fetchPatientById->>MPI: Request Patient Data
MPI-->>fetchPatientById: Return Patient Data
fetchPatientById-->>fetchPatientSummaries: Return Full Patient Data
fetchPatientSummaries-->>Client: Return Summarized Patient Data
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 0
Outside diff range and nitpick comments (2)
src/routes/handlers/fetchPatientSummaries.ts (1)
Line range hint
30-45
: Refactored to use async mapping and enhanced error handling.Consider adding more specific error handling or logging for different status codes, especially for non-404 HTTP errors.
tests/unit/middlewares.ts (1)
Line range hint
303-305
: Convert function expressions to arrow functions.- function () { + () => {This change will make the code more concise and modern, aligning with ES6+ standards.
Also applies to: 363-365, 424-426, 453-455, 512-514
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- package.json (1 hunks)
- src/openhim/mediatorConfig.json (1 hunks)
- src/routes/handlers/fetchPatientSummaries.ts (4 hunks)
- tests/unit/fetchPatientSummaries.ts (3 hunks)
- tests/unit/middlewares.ts (8 hunks)
Files skipped from review due to trivial changes (2)
- package.json
- src/openhim/mediatorConfig.json
Additional context used
Learnings (1)
src/routes/handlers/fetchPatientSummaries.ts (1)
User: bradsawadye PR: jembi/mpi-mediator#45 File: src/routes/index.ts:75-79 Timestamp: 2024-05-14T09:04:31.151Z Learning: The `fetchPatientById` function in `src/routes/handlers/fetchPatient.ts` includes internal error handling and returns a formatted response object, making additional try-catch blocks in the route handler unnecessary.
Biome
tests/unit/middlewares.ts
[error] 303-305: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 363-365: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 424-426: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 453-455: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
[error] 512-514: This function expression can be turned into an arrow function. (lint/complexity/useArrowFunction)
Function expressions that don't use this can be turned into arrow functions.
Safe fix: Use an arrow function instead.
Additional comments not posted (8)
src/routes/handlers/fetchPatientSummaries.ts (2)
14-14
: Import statement added forfetchPatientById
.This import is necessary for the new functionality to fetch patient details asynchronously.
70-78
: Integration of demographic data into the patient summaries.This change aligns with the PR's objective to enhance patient summaries with full demographic details. Ensure that the
fullPatient.body.response.body
is always in the expected format to avoid runtime errors.tests/unit/fetchPatientSummaries.ts (3)
11-12
: New imports forpatientMethods
andsinon
.These imports are essential for the new testing setup that involves stubbing
fetchPatientById
.
193-253
: Introduction of a detailedmpiPatient
object for testing.This detailed object will help in creating more robust and realistic test cases.
Line range hint
257-275
: Use ofsinon.stub
to mockfetchPatientById
calls.This is a good practice to isolate the unit tests from external dependencies. Ensure that all stubs are restored after the tests to prevent side effects.
Also applies to: 279-300, 306-320, 323-337
tests/unit/middlewares.ts (3)
5-5
: Import ofsinon
.Necessary for stubbing and mocking in middleware tests.
14-14
: Import ofpatientMethods
.Essential for accessing patient-related methods within the middleware tests.
119-179
: Introduction of a detailedmpiPatient
object for middleware testing.This object is crucial for testing the middleware's handling of patient data.
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.
LGTM
Summary by CodeRabbit
New Features
Bug Fixes
Tests