Skip to content

Redesign print preview of drug chart#16446

Open
NikhilA8606 wants to merge 2 commits into
developfrom
ENG-521-redesign-drug-chart-print-preview
Open

Redesign print preview of drug chart#16446
NikhilA8606 wants to merge 2 commits into
developfrom
ENG-521-redesign-drug-chart-print-preview

Conversation

@NikhilA8606

@NikhilA8606 NikhilA8606 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Proposed Changes

Fix ENG-521

Screenshot:
image

figma link: https://www.figma.com/design/Z93EYKSa1MdBmXndsMBJSQ/Care---Master?node-id=7346-4302&t=N7lK1t394FeEWD6j-1

Tagging: @ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate the bug or test the new feature.
  • Update product documentation.
  • Ensure that UI text is placed in I18n files.
  • Prepare a screenshot or demo video for the changelog entry and attach it to the issue.
  • Request peer reviews.
  • Complete QA on mobile devices.
  • Complete QA on desktop devices.
  • Add or update Playwright tests for related changes

Summary by CodeRabbit

  • New Features
    • Added support for four fixed medication administration time slots: Bedtime, Morning, Afternoon, and Night
    • Added a screen-only filter to choose which slots appear in the print view
    • Enhanced medication print layout with patient location breadcrumbs and a hospital identifier
    • Medication charts now aggregate and display patient instructions and clinical notes per medication group, with improved per-slot details and checkmark rendering
  • Localization
    • Added new English labels for time-of-day fields and related administration/patient identifiers

@NikhilA8606 NikhilA8606 requested review from a team June 8, 2026 08:16
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0174aedf-0ef5-4f61-86ff-0828e37f8e57

📥 Commits

Reviewing files that changed from the base of the PR and between 93151d4 and 0892337.

📒 Files selected for processing (1)
  • public/locale/en.json
💤 Files with no reviewable changes (1)
  • public/locale/en.json

Walkthrough

The PR refactors medication administration print UI by introducing fixed four-slot administration times (Morning, Afternoon, Night, Bedtime) replacing dynamic slot generation, adds checkbox-driven filtering for displayed slots, enriches the print header with location breadcrumbs and hospital ID, and redesigns the drug chart table with abbreviated slot headers and footer rows containing aggregated patient instructions and notes.

Changes

Medication Administration Print UI Refactoring

Layer / File(s) Summary
Localization keys for time slots and new fields
public/locale/en.json
Seven new English localization entries added for the four fixed administration time slots (each with bold letter abbreviations), plus labels for hospital_id, patient_ip_location, and administration_times.
Fixed time slots and filtering state
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx
Replaces dynamic time-slot generation with ADMIN_TIME_SLOTS constant (four fixed slots with i18n keys and start/end ranges), adds formatSlotHour 12-hour formatter, introduces selectedSlotKeys state for checkbox-driven filtering, and computes timeSlots by filtering and mapping fixed slots. Imports Bed icon and React hooks plus checkbox UI.
Header metadata: location breadcrumb and hospital ID
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx
Adds locationPath memo walking encounter's location parent chain (with bed icon for location type bd), computes hospitalId from patient's official instance identifier with fallback to encounter external ID, and imports formatDosage, formatFrequency, formatDuration utilities. Sets hideFacilityHeader on PrintPreview.
Print interface: slot filter and header layout
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx
Removes prior discontinued-medication toggle and slots-per-day selector, adds screen-only checkbox filter for time slots. Redesigns print header to display logo, patient/encounter info, age/sex, optional hospital ID, and optional location breadcrumb. Updates regular medications section layout and styling.
PRN medications section styling
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx
Updates PRN section header markup and styling while maintaining same chart table rendering structure for PRN groups and date ranges.
Instruction and notes aggregation for table footer
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx
Adds collectInstructionsAndNotes helper that aggregates de-duplicated patient instructions (from dosage and additional instructions) and clinical notes (from request note) per medication group for footer row display.
Drug chart table header, body, and footer
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx
Extends slot prop shape to include abbreviation, start, end. Rewrites table header to show slot abbreviations with conditional styling. Overhauls row/cell rendering: checkmarks display in print-only simple view and screen popover detail view; conditionally appends footer row per medication group with aggregated instructions and notes; updates cell shading and borders.

Possibly related PRs

  • ohcnetwork/care_fe#16355: Both PRs heavily modify PrintMedicationAdministration.tsx with changes to drug chart/table rendering and print output layout, header behavior, and sectioning.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete: it lacks a detailed bulleted list of changes, provides no explanation of modifications beyond a screenshot, and several checklist items remain unchecked including specs/tests and desktop QA. Add detailed bullet points describing the key changes (e.g., four fixed time slots, breadcrumb header, de-duplicated instructions/notes, stateful filtering), explain the localization additions, and update checklist items to reflect actual completion status.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change—redesigning the print preview of the drug chart component, which is the primary focus of the substantial changes to PrintMedicationAdministration.tsx.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ENG-521-redesign-drug-chart-print-preview

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR redesigns the drug-chart print preview to match an updated Figma spec. The time-slot model moves from a dynamic generator (1–4 equal slots) to four fixed, named slots (Bedtime/Morning/Afternoon/Night), each user-selectable via a new checkbox panel. The header gains facility address, patient location breadcrumbs, and a hospital-ID field; each medication row gains a deduplicated instruction/note footer strip.

  • Fixed ADMIN_TIME_SLOTS constant replaces generateTimeSlots, carrying per-slot abbreviations so the column labels stay correct when slots are filtered out; adminIndex continues to use the label string as its key, so lookup is unaffected.
  • collectInstructionsAndNotes helper de-duplicates patient instructions and clinical notes across all requests in a group and renders them as a sub-row beneath each medication entry.
  • Four new locale keys (bed_time, morning_time, afternoon_time, night_time) embed <strong> tags in their string values; these work correctly with Trans today but may render as literal text if the keys are consumed via plain t() in the future.

Confidence Score: 5/5

Safe to merge — the change is scoped entirely to the print preview component and its locale strings, with no shared logic affected.

The refactor is self-contained: the fixed ADMIN_TIME_SLOTS constant replaces the dynamic slot generator cleanly, adminIndex keying is consistent throughout, and the new helpers (locationPath, collectInstructionsAndNotes) are straightforward. The only concern is the HTML embedded in four locale strings, which is a future-maintenance risk rather than a current defect.

public/locale/en.json — the four new keys with embedded HTML markup are worth revisiting if these strings ever need to be consumed outside a Trans context.

Important Files Changed

Filename Overview
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx Redesigned print preview: replaces the dynamic time-slot generator with four fixed ADMIN_TIME_SLOTS (B/M/A/N), adds location breadcrumbs, hospital ID, patient-instruction footer strips, and a new per-slot checkbox filter. Logic is sound; all previously flagged threads cover the remaining style nits.
public/locale/en.json Adds 6 new i18n keys; four of them (bed_time, morning_time, afternoon_time, night_time) embed raw HTML ( tags) inside the string values, which is an unusual pattern that could mislead translators or break if the keys are ever consumed with plain t().

Reviews (2): Last reviewed commit: "Merge branch 'develop' into ENG-521-rede..." | Re-trigger Greptile

Comment on lines +444 to +476
<div className="mb-2 border border-gray-400 p-2 flex items-center justify-between">
<span className="text-gray-950 text-xl font-semibold ">
{t("regular_medications")}
</span>
<div className="text-gray-600 text-base">
<Trans
i18nKey="bed_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="morning_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="afternoon_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="night_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Legend doesn't reflect selected time slots

The legend in the "Regular Medications" header hardcodes all four abbreviations (B, M, A, N) unconditionally. When a user deselects e.g. "Bedtime" and "Night" via the checkboxes, the table will only render "M" and "A" columns, but the legend still reads "B-Bedtime, M-Morning, A-Afternoon, N-Night" — making the printed chart misleading. The legend should be derived from timeSlots (the already-filtered list) rather than the full ADMIN_TIME_SLOTS constant.

// Filter state
const [showDiscontinued, setShowDiscontinued] = useState(false);
const [slotsPerDay, setSlotsPerDay] = useState(4);
const [showDiscontinued] = useState(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 showDiscontinued is always false — the setter was dropped when the toggle UI was removed. Since the value never changes, useState adds noise here; a plain constant is clearer and keeps the intent explicit.

Suggested change
const [showDiscontinued] = useState(false);
const showDiscontinued = false;

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +574 to +576
const slotLabels = timeSlots.map((slot) => slot.abbreviation);

// Thicker divider after the final slot of a day; zebra shade alternate slots.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 slotLabels is built solely to be indexed by slotIdx inside the same timeSlots.map callback where slot.abbreviation is already in scope. The extra array is unnecessary indirection.

Suggested change
const slotLabels = timeSlots.map((slot) => slot.abbreviation);
// Thicker divider after the final slot of a day; zebra shade alternate slots.
// Thicker divider after the final slot of a day; zebra shade alternate slots.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx`:
- Around line 449-475: The legend currently always renders all four Trans labels
inside PrintMedicationAdministration; change it to render only the labels that
match the component's current slot filter state/prop (e.g.,
selectedSlots/slotFilters) so the legend stays in sync with the table columns.
Locate the legend block in PrintMedicationAdministration and wrap each Trans
(i18nKey="bed_time"/"morning_time"/"afternoon_time"/"night_time") in a
conditional that checks the slot is included in the active filter array
(preserve ordering and comma separators when multiple are shown). Ensure you use
the existing slot filter state/prop used by the table (the same variable that
determines which columns render) so both legend and columns stay consistent.
- Around line 327-333: The checkbox onCheckedChange currently allows removing
the last selected slot which leads to timeSlots.length === 0 and colSpan being
set to 0; change the handler that updates selectedSlotKeys (the onCheckedChange
using setSelectedSlotKeys) to guard against removing the final key: if the
change is an uncheck and prev contains only that slot, do not update state (keep
at least one selected). Update any related selection update paths that can
produce an empty array (selectedSlotKeys/timeSlots) so the table header colSpan
logic (where colSpan is derived) never receives 0.
- Around line 739-744: The button element that serves as a popover trigger in
the PrintMedicationAdministration component currently lacks an explicit ARIA
label, making it inaccessible to screen readers. Add an aria-label attribute to
the button that provides contextual information about the medication, date, and
slot being represented by the checkmark. This label should convey what action
the button triggers and what medication/administration data it relates to,
ensuring screen reader users understand the purpose and context of the
interaction.
- Around line 53-58: formatSlotHour and several direct date/format(...) usages
hardcode English AM/PM and formats; replace these with locale-aware formatting:
use Intl.DateTimeFormat (or toLocaleTimeString/toLocaleDateString) with the app
locale (e.g., i18n.language) to produce the hour display instead of hardcoded
"AM"/"PM" and update all format(...) usages to pass the locale or use
IntlDateTimeFormatter; any visible strings like "AM"/"PM" or other date labels
must be routed through i18next (t(...)) where appropriate; specifically update
the formatSlotHour function to create a Date from the hour and return
Intl.DateTimeFormat(i18n.language, { hour: '2-digit', hour12: true
}).format(date) and change the other calls that use format(...) to use
toLocaleString/toLocaleDateString or Intl.DateTimeFormat with i18n.language,
keeping function names like formatSlotHour and existing format(...) call sites
intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3f975b18-2cab-4206-bc49-4a67d7d1affd

📥 Commits

Reviewing files that changed from the base of the PR and between ea4902a and 93151d4.

📒 Files selected for processing (2)
  • public/locale/en.json
  • src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx

Comment on lines +53 to 58
const formatSlotHour = (hour: number) => {
const normalized = hour % 24;
const period = normalized < 12 ? "AM" : "PM";
const display = normalized % 12 === 0 ? 12 : normalized % 12;
return `${String(display).padStart(2, "0")} ${period}`;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Localize time/date output instead of hardcoded English formats.

formatSlotHour hardcodes "AM"/"PM", and several format(...) calls render without locale. This will keep the print UI in English-style formats even when the app language changes.

Suggested fix
+ import { enIN } from "date-fns/locale";
+ // map i18n.language -> date-fns locale in project utility if available
+ const dateLocale = enIN;

- const formatSlotHour = (hour: number) => {
-   const normalized = hour % 24;
-   const period = normalized < 12 ? "AM" : "PM";
-   const display = normalized % 12 === 0 ? 12 : normalized % 12;
-   return `${String(display).padStart(2, "0")} ${period}`;
- };
+ const formatSlotHour = (hour: number, locale: string) => {
+   const d = new Date();
+   d.setHours(hour % 24, 0, 0, 0);
+   return new Intl.DateTimeFormat(locale, {
+     hour: "2-digit",
+     minute: "2-digit",
+     hour12: true,
+   }).format(d);
+ };

- {format(new Date(encounter.period.start), "dd MMM yyyy, EEEE")}
+ {format(new Date(encounter.period.start), "dd MMM yyyy, EEEE", { locale: dateLocale })}

As per coding guidelines, "All user-facing strings must use i18next for internationalization" and "Use proper date/time formatting for multiple language support."

Also applies to: 343-344, 393-396, 609-610, 771-776

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx`
around lines 53 - 58, formatSlotHour and several direct date/format(...) usages
hardcode English AM/PM and formats; replace these with locale-aware formatting:
use Intl.DateTimeFormat (or toLocaleTimeString/toLocaleDateString) with the app
locale (e.g., i18n.language) to produce the hour display instead of hardcoded
"AM"/"PM" and update all format(...) usages to pass the locale or use
IntlDateTimeFormatter; any visible strings like "AM"/"PM" or other date labels
must be routed through i18next (t(...)) where appropriate; specifically update
the formatSlotHour function to create a Date from the hour and return
Intl.DateTimeFormat(i18n.language, { hour: '2-digit', hour12: true
}).format(date) and change the other calls that use format(...) to use
toLocaleString/toLocaleDateString or Intl.DateTimeFormat with i18n.language,
keeping function names like formatSlotHour and existing format(...) call sites
intact.

Source: Coding guidelines

Comment on lines +327 to +333
onCheckedChange={(value) =>
setSelectedSlotKeys((prev) =>
value
? [...prev, slot.key]
: prev.filter((key) => key !== slot.key),
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Prevent deselecting the last slot to avoid invalid table structure.

At Line 327, users can uncheck every slot, which makes timeSlots.length === 0; then Line 603 sets colSpan={0}, causing unstable/invalid header rendering and a broken chart layout.

Suggested fix
- onCheckedChange={(value) =>
-   setSelectedSlotKeys((prev) =>
-     value
-       ? [...prev, slot.key]
-       : prev.filter((key) => key !== slot.key),
-   )
- }
+ onCheckedChange={(value) =>
+   setSelectedSlotKeys((prev) => {
+     if (value) {
+       return prev.includes(slot.key) ? prev : [...prev, slot.key];
+     }
+     if (prev.length === 1) return prev; // keep at least one slot selected
+     return prev.filter((key) => key !== slot.key);
+   })
+ }

Also applies to: 603-607

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx`
around lines 327 - 333, The checkbox onCheckedChange currently allows removing
the last selected slot which leads to timeSlots.length === 0 and colSpan being
set to 0; change the handler that updates selectedSlotKeys (the onCheckedChange
using setSelectedSlotKeys) to guard against removing the final key: if the
change is an uncheck and prev contains only that slot, do not update state (keep
at least one selected). Update any related selection update paths that can
produce an empty array (selectedSlotKeys/timeSlots) so the table header colSpan
logic (where colSpan is derived) never receives 0.

Comment on lines +449 to +475
<Trans
i18nKey="bed_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="morning_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="afternoon_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="night_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep the administration-times legend in sync with selected slot filters.

This block always renders all 4 slot labels, even when the user filters to a subset. The table columns and legend can diverge, which is misleading in a medication print view.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx`
around lines 449 - 475, The legend currently always renders all four Trans
labels inside PrintMedicationAdministration; change it to render only the labels
that match the component's current slot filter state/prop (e.g.,
selectedSlots/slotFilters) so the legend stays in sync with the table columns.
Locate the legend block in PrintMedicationAdministration and wrap each Trans
(i18nKey="bed_time"/"morning_time"/"afternoon_time"/"night_time") in a
conditional that checks the slot is included in the active filter array
(preserve ordering and comma separators when multiple are shown). Ensure you use
the existing slot filter state/prop used by the table (the same variable that
determines which columns render) so both legend and columns stay consistent.

Comment on lines +739 to +744
<button
type="button"
className="flex h-full min-h-[28px] w-full cursor-pointer items-center justify-center transition-colors hover:bg-green-100 print:hidden"
>
{cellContent}
</button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add an explicit ARIA label for the checkmark-only popover trigger.

The button currently exposes only visual symbols (), so screen readers lack medication/date/slot context for the interaction.

Suggested fix
<button
  type="button"
+ aria-label={t("med_admin_details_aria_label", {
+   medication: group.productName,
+   date: format(date, "dd MMM yyyy"),
+   slot: slot.abbreviation,
+   count: admins.length,
+ })}
  className="flex h-full min-h-[28px] w-full cursor-pointer items-center justify-center transition-colors hover:bg-green-100 print:hidden"
>

As per coding guidelines, "Add ARIA labels for critical medical data (patient names, vital signs, medication alerts)" and "Ensure keyboard navigation works in components."

📝 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
<button
type="button"
className="flex h-full min-h-[28px] w-full cursor-pointer items-center justify-center transition-colors hover:bg-green-100 print:hidden"
>
{cellContent}
</button>
<button
type="button"
aria-label={t("med_admin_details_aria_label", {
medication: group.productName,
date: format(date, "dd MMM yyyy"),
slot: slot.abbreviation,
count: admins.length,
})}
className="flex h-full min-h-[28px] w-full cursor-pointer items-center justify-center transition-colors hover:bg-green-100 print:hidden"
>
{cellContent}
</button>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx`
around lines 739 - 744, The button element that serves as a popover trigger in
the PrintMedicationAdministration component currently lacks an explicit ARIA
label, making it inaccessible to screen readers. Add an aria-label attribute to
the button that provides contextual information about the medication, date, and
slot being represented by the checkmark. This label should convey what action
the button triggers and what medication/administration data it relates to,
ensuring screen reader users understand the purpose and context of the
interaction.

Source: Coding guidelines

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

🎭 Playwright Test Results

Status: ❌ Failed
Test Shards: 3

Metric Count
Total Tests 321
✅ Passed 319
❌ Failed 2
⏭️ Skipped 0

📊 Detailed results are available in the playwright-final-report artifact.

Run: #9556

Copilot AI review requested due to automatic review settings June 16, 2026 09:44
@netlify

netlify Bot commented Jun 16, 2026

Copy link
Copy Markdown

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 0892337
🔍 Latest deploy log https://app.netlify.com/projects/care-ohc/deploys/6a311b005364f50008939b3a
😎 Deploy Preview https://deploy-preview-16446.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0892337
Status: ✅  Deploy successful!
Preview URL: https://d91ea8d4.care-preview-a7w.pages.dev
Branch Preview URL: https://eng-521-redesign-drug-chart.care-preview-a7w.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR redesigns the medication administration print preview to match the new ENG-521 layout, including fixed administration time slots and a more information-dense header/footer suitable for printing.

Changes:

  • Replaced variable “slots per day” logic with four fixed administration time slots (B/M/A/N) and a slot filter in the print preview UI.
  • Updated the print header to include facility details, patient location breadcrumb, and a derived hospital identifier.
  • Enhanced the drug chart rows to include dosage form, duration, and aggregated instructions/clinical notes per medication group.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
src/components/Medicine/MedicationAdministration/PrintMedicationAdministration.tsx Reworks print layout, adds fixed administration slots + filtering, header breadcrumb/hospital ID, and richer row/footer content.
public/locale/en.json Adds new i18n keys for administration time slots, filter label, hospital ID, and IP location label.

// Filter state
const [showDiscontinued, setShowDiscontinued] = useState(false);
const [slotsPerDay, setSlotsPerDay] = useState(4);
const [showDiscontinued] = useState(false);
Comment on lines +311 to +316
{/* Administration time slot filter (screen only) */}
<div className="print:hidden rounded-lg bg-gray-50 p-4 mb-4">
<p className="mb-3 text-sm font-medium text-gray-700">
{t("administration_times")}:
</p>
<div className="flex flex-wrap gap-x-8 gap-y-3">
Comment on lines +320 to +334
<label
key={slot.key}
className="flex cursor-pointer items-start gap-2"
>
{num}
</Button>
))}
</div>
<Checkbox
className="mt-0.5"
checked={checked}
onCheckedChange={(value) =>
setSelectedSlotKeys((prev) =>
value
? [...prev, slot.key]
: prev.filter((key) => key !== slot.key),
)
}
/>
Comment on lines +383 to +386
<span className="font-semibold">
{":"}
{encounter.patient.name}
</span>
Comment on lines +391 to +398
<span className="font-semibold">
{":"}
{format(
new Date(encounter.period.start),
"dd MMM yyyy, EEEE",
)}
</span>
</div>
Comment on lines +404 to +409
<span className="font-semibold">
{":"}
{`${formatPatientAge(encounter.patient, true)}, ${t(
`GENDER__${encounter.patient.gender}`,
)}`}
</span>
Comment on lines +414 to +417
<span className="font-semibold">
{":"}
{hospitalId}
</span>
Comment on lines +444 to +476
<div className="mb-2 border border-gray-400 p-2 flex items-center justify-between">
<span className="text-gray-950 text-xl font-semibold ">
{t("regular_medications")}
</span>
<div className="text-gray-600 text-base">
<Trans
i18nKey="bed_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="morning_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="afternoon_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
,{" "}
<Trans
i18nKey="night_time"
components={{
strong: <span className="text-gray-950" />,
}}
/>
</div>

@Jacobjeevan Jacobjeevan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

...

// Filter state
const [showDiscontinued, setShowDiscontinued] = useState(false);
const [slotsPerDay, setSlotsPerDay] = useState(4);
const [showDiscontinued] = useState(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm, this breaks the discontinued filter/user can now see discontinued medications by default


// Collect patient-facing instructions and clinical notes across every request
// in a medication group, de-duplicated for a compact footer strip.
const collectInstructionsAndNotes = (group: GroupedMedication) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do note that we can have note for each medication, but also a note for the prescription itself. In the latter case, doctor might add specific instructions on how prescribed medications might interact with each other (i.e. discontinue one if the other causes side effects for example).

So we will need to show both.

const form =
latestRequest.requested_product?.definitional?.dosage_form
?.display;
const { instructions: patientInstructions, notes } =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

make it clearer - might want to rename this since it combines patient instructions and additional instructions (we don't currently use the former in UI).

colSpan={totalColumns - 1}
className="border-b border-gray-300 bg-gray-50/70 px-2 py-1 text-xs leading-snug text-gray-600"
>
{patientInstructions.length > 0 && (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When we have multi-dosage, joining instructions isn't ideal.

Image

@Jacobjeevan Jacobjeevan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's an additional issue with this design as it doesn't allow user to print charts for the entire day. Here's what it looks like in previous design:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants