Skip to content
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

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Print Prescription cleanup #9991

merged 1 commit into from
Jan 15, 2025

Conversation

amjithtitus09
Copy link
Contributor

@amjithtitus09 amjithtitus09 commented Jan 15, 2025

Proposed Changes

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

Release Notes

  • Localization

    • Added new translation entries for prescription-related messages
    • Improved clarity for encounter and medication prescription terminology
  • User Interface

    • Enhanced print preview styling with borders, rounded corners, and shadow
    • Refined prescription print layout for better readability
  • Data Handling

    • Updated medication request data type for improved type safety
    • Simplified medication display in prescription view
  • Performance

    • Added pagination support for medication requests

These updates improve the application's localization, user interface, and data management capabilities.

@amjithtitus09 amjithtitus09 requested a review from a team as a code owner January 15, 2025 11:46
Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Walkthrough

This 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 PrintPreview component's styling, modifying the API request type for medication requests, and refactoring the PrintPrescription page to improve type safety and user interface. The modifications aim to provide a more comprehensive and clear representation of medication prescriptions and encounter details.

Changes

File Change Summary
public/locale/en.json Added 7 new localization keys for prescription and encounter-related messages
src/CAREUI/misc/PrintPreview.tsx Added border, rounded corners, and shadow effect to the main container
src/Utils/request/api.tsx Updated import and response type for medication requests from MedicationRequest to MedicationRequestRead
src/pages/Encounters/PrintPrescription.tsx Refactored type definitions, updated query types, simplified medication display, and improved UI layout

Possibly related issues

Possibly related PRs

Suggested labels

needs review, tested

Suggested reviewers

  • rithviknishad
  • bodhish

Poem

🐰 A Rabbit's Prescription Rhyme 🩺

In JSON's realm, new words take flight,
Prescriptions printed, crisp and bright
Types refined with coding grace
A medical dance in digital space
Localization's magic, clear and true!


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Jan 15, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit b689468
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/6787a00b2bcde300098f2bfa
😎 Deploy Preview https://deploy-preview-9991--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: b689468
Status: ✅  Deploy successful!
Preview URL: https://d548e78f.care-fe.pages.dev
Branch Preview URL: https://print-prescription-cleanup.care-fe.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2fc9e33 and b689468.

📒 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 and MedicationRequestRead 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 to MedicationRequestRead 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

Comment on lines +111 to +121
// 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;
}, {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
// 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;
}, {});

Copy link

cypress bot commented Jan 15, 2025

CARE    Run #4331

Run Properties:  status check passed Passed #4331  •  git commit b689468077: Print Prescription cleanup
Project CARE
Branch Review print-prescription-cleanup
Run status status check passed Passed #4331
Run duration 02m 11s
Commit git commit b689468077: Print Prescription cleanup
Committer Amjith Titus
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5
View all changes introduced in this branch ↗︎

@gigincg gigincg merged commit 86d110a into develop Jan 15, 2025
29 checks passed
@gigincg gigincg deleted the print-prescription-cleanup branch January 15, 2025 12:12
Copy link

@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! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants