-
Notifications
You must be signed in to change notification settings - Fork 517
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
Print Prescription cleanup #9991
Conversation
WalkthroughThis pull request introduces enhancements to the application's localization and prescription printing functionality. The changes include adding new localization keys in the English JSON file to support prescription-related terminology, updating the Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Deploying care-fe with Cloudflare Pages
|
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 (2)
src/pages/Encounters/PrintPrescription.tsx (2)
Line range hint
29-74
: Add JSDoc documentation to helper functions.The helper functions are well-implemented but would benefit from JSDoc documentation to explain their purpose, parameters, and return values.
Add documentation like this:
+/** + * Formats the frequency display for medication timing + * @param timing - The timing instructions for the medication + * @returns The formatted frequency code and display text, or undefined if timing is invalid + */ function getFrequencyDisplay( timing?: MedicationRequestDosageInstruction["timing"], ) {
98-98
: Extract pagination limit to a constant.The pagination limit is hardcoded. Consider extracting it to a named constant for better maintainability.
+const MEDICATIONS_PAGE_SIZE = 50; + const { data: medications } = useQuery({ queryKey: ["medications", encounter?.patient?.id], queryFn: query(api.medicationRequest.list, { pathParams: { patientId: encounter?.patient?.id || "" }, - queryParams: { encounter: encounterId, limit: 50, offset: 0 }, + queryParams: { encounter: encounterId, limit: MEDICATIONS_PAGE_SIZE, offset: 0 }, }),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
public/locale/en.json
(7 hunks)src/CAREUI/misc/PrintPreview.tsx
(1 hunks)src/Utils/request/api.tsx
(2 hunks)src/pages/Encounters/PrintPrescription.tsx
(5 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/CAREUI/misc/PrintPreview.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: cypress-run (1)
- GitHub Check: OSSAR-Scan
🔇 Additional comments (5)
src/pages/Encounters/PrintPrescription.tsx (3)
22-26
: LGTM! Type imports look good.The new types
MedicationRequestDosageInstruction
andMedicationRequestRead
provide better type safety for medication request handling.
132-262
: LGTM! Well-structured UI with proper internationalization.The UI implementation is clean with:
- Clear section organization
- Proper error handling
- Consistent use of translation keys
270-287
: LGTM! DetailRow component is well-implemented.The component is well-typed and handles undefined values appropriately with good default styling options.
src/Utils/request/api.tsx (1)
23-23
: LGTM! Type update is consistent.The change from
MedicationRequest
toMedicationRequestRead
aligns with the type updates in PrintPrescription.tsx.Also applies to: 653-653
public/locale/en.json (1)
596-596
: LGTM! Translation keys are complete and consistent.Added all necessary translation keys for prescription-related text:
- computer_generated_prescription
- encounter_date
- generated_on
- medicine_prescription
- prescriptions
- print_prescriptions
Also applies to: 869-869, 1069-1069, 1294-1294, 1621-1621, 1636-1636
// Group medications by prescriber | ||
const medicationsByPrescriber = medications.results.reduce< | ||
Record<string, MedicationRequestRead[]> | ||
>((acc, med) => { | ||
const prescriberId = med.created_by.id.toString(); | ||
if (!acc[prescriberId]) { | ||
acc[prescriberId] = []; | ||
} | ||
acc[prescriberId].push(med); | ||
return acc; | ||
}, {}); |
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.
Add null check for prescriber ID.
The toString()
call on prescriber ID could throw if the ID is undefined. Add a null check or provide a fallback.
-const prescriberId = med.created_by.id.toString();
+const prescriberId = med.created_by?.id?.toString() || 'unknown';
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Group medications by prescriber | |
const medicationsByPrescriber = medications.results.reduce< | |
Record<string, MedicationRequestRead[]> | |
>((acc, med) => { | |
const prescriberId = med.created_by.id.toString(); | |
if (!acc[prescriberId]) { | |
acc[prescriberId] = []; | |
} | |
acc[prescriberId].push(med); | |
return acc; | |
}, {}); | |
// Group medications by prescriber | |
const medicationsByPrescriber = medications.results.reduce< | |
Record<string, MedicationRequestRead[]> | |
>((acc, med) => { | |
const prescriberId = med.created_by?.id?.toString() || 'unknown'; | |
if (!acc[prescriberId]) { | |
acc[prescriberId] = []; | |
} | |
acc[prescriberId].push(med); | |
return acc; | |
}, {}); |
CARE Run #4331
Run Properties:
|
Project |
CARE
|
Branch Review |
print-prescription-cleanup
|
Run status |
Passed #4331
|
Run duration | 02m 11s |
Commit |
b689468077: Print Prescription cleanup
|
Committer | Amjith Titus |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
5
|
View all changes introduced in this branch ↗︎ |
@amjithtitus09 Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
Release Notes
Localization
User Interface
Data Handling
Performance
These updates improve the application's localization, user interface, and data management capabilities.