Skip to content

Conversation

@abhimanyurajeesh
Copy link
Contributor

@abhimanyurajeesh abhimanyurajeesh commented Jan 21, 2026

…ell rendering and styling

Proposed Changes

Fixes #issue_number

  • Change 1
  • Change 2
  • Additional context if needed

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

    • Enhanced table customization with per-cell rendering and styling for printed lists
    • Added configurable footer styling for printed prescriptions
    • Enabled keyboard shortcut for patient search in medication entry
  • Style

    • Prescription date format changed to dd/MM/yy
    • Compacted typography and layout for prescription header, address, and signature

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds per-cell rendering and styling APIs to PrintTable (new props: className, classNameCell, cellConfig, renderCell; HeaderRow.className). PrescriptionPreview updated to use these props and a compact dd/MM/yy date format and reduced typography. MedicationBillForm toggles shortcut sub-context usage (patient search enabled; facility general removed).

Changes

Cohort / File(s) Summary
PrintTable component
src/components/Common/PrintTable.tsx
Adds CellConfig type and HeaderRow.className; expands GenericTableProps and PrintTable props with className, classNameCell, cellConfig, renderCell. Implements getCellContent (render priority) and composes row/cell classNames; adjusts some utility classes (e.g., rounded, word-wrapping).
Prescription preview (consumer of PrintTable)
src/components/Prescription/PrescriptionPreview.tsx
Passes className and cellConfig into PrintTable instances; reduces header/address/signature text sizes; changes encounter date format to dd/MM/yy; forwards className to PrintFooter.
Pharmacy form shortcut context
src/pages/Facility/services/pharmacy/MedicationBillForm.tsx
Enables useShortcutSubContext("patient:search:-global", { ignoreInputFields: true }) in AddMedicationSheet and removes useShortcutSubContext("facility:general") from MedicationBillForm, changing shortcut scope.
🚥 Pre-merge checks | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description uses the template structure but provides only placeholder content ('Change 1', 'Change 2', '#issue_number') without actual change details, making it incomplete and uninformative. Replace placeholder content with specific changes: actual issue number, detailed list of what changed in each component, and relevant implementation context.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is truncated and incomplete ('…ell rendering and styling'), making it unclear and failing to fully convey the main changes even though the changes involve PrintTable and PrescriptionPreview refactoring. Complete the title to clearly summarize the main change; consider 'Refactor PrintTable and PrescriptionPreview components for improved cell rendering and styling'.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch manyu/print/phar

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

The PR refactors the PrintTable and PrescriptionPreview components to enhance cell rendering flexibility and improve print layout styling. The changes focus on making tables more customizable through cell-specific configurations and adjusting font sizes and spacing for better print output.

Changes:

  • Enhanced PrintTable component with flexible cell rendering and styling options via cellConfig and renderCell props
  • Adjusted font sizes and spacing throughout PrescriptionPreview for improved print aesthetics
  • Re-enabled keyboard shortcuts in MedicationBillForm and removed redundant shortcut context

Reviewed changes

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

File Description
src/components/Common/PrintTable.tsx Added cell-specific configuration support with custom render functions and className overrides
src/components/Prescription/PrescriptionPreview.tsx Applied new PrintTable configurations and adjusted typography for print optimization
src/pages/Facility/services/pharmacy/MedicationBillForm.tsx Re-enabled keyboard shortcuts and removed duplicate shortcut context

Comment on lines 257 to 258
? format(new Date(encounter.period.start), "dd/mm/yy")
: format(new Date(), "dd/mm/yy")
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The date format string uses lowercase 'mm' which represents minutes, not months. This will produce incorrect dates. Use 'dd/MM/yy' instead where 'MM' represents months.

Suggested change
? format(new Date(encounter.period.start), "dd/mm/yy")
: format(new Date(), "dd/mm/yy")
? format(new Date(encounter.period.start), "dd/MM/yy")
: format(new Date(), "dd/MM/yy")

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 21, 2026

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 53baa85
Status: ✅  Deploy successful!
Preview URL: https://b402caf5.care-preview-a7w.pages.dev
Branch Preview URL: https://manyu-print-phar.care-preview-a7w.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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/components/Common/PrintTable.tsx (1)

71-105: Fix Tailwind utility typo (warp-break-words).

warp-break-words isn't a valid Tailwind utility; use wrap-break-word instead to enable proper overflow wrapping for long words.

🛠️ Proposed fix
-                      "warp-break-words whitespace-normal text-center",
+                      "wrap-break-word whitespace-normal text-center",
src/components/Prescription/PrescriptionPreview.tsx (1)

253-259: Date format uses minutes instead of month.

In date-fns, mm represents minutes (00–59); this produces incorrect timestamp output. Use MM for month (01–12).

🛠️ Proposed fix
-                    ? format(new Date(encounter.period.start), "dd/mm/yy")
-                    : format(new Date(), "dd/mm/yy")
+                    ? format(new Date(encounter.period.start), "dd/MM/yy")
+                    : format(new Date(), "dd/MM/yy")
🤖 Fix all issues with AI agents
In `@src/components/Common/PrintTable.tsx`:
- Around line 22-26: The CellConfig.value field is defined but never used in
getCellContent, so callers cannot override displayed cell text; update the
getCellContent function in PrintTable.tsx to prefer CellConfig.value (if
defined) over deriving the value from row data, and pass that chosen value into
any cellConfig.render callback (and into any fallback formatting logic) so both
plain-value and rendered paths respect the override; reference the CellConfig
type, the getCellContent function, and the render property when making this
change.
- Around line 14-18: The HeaderRow.className property is never applied when
rendering table headers in PrintTable; update the header-rendering code paths
(where PrintTable maps over headers in TableHead / headers.map) to add the
header.className to the header cell element (e.g., the <th> or TableCell used
for header rows), merging it with any existing classes (safely handling
undefined) and keeping the existing key and width handling; make the same change
for the second header-rendering block (the other headers.map usage) so
per-header styling via HeaderRow.className takes effect everywhere.

Comment on lines 14 to 18
type HeaderRow = {
key: string;
width?: number;
className?: string;
};
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 | 🟡 Minor

HeaderRow.className is never applied to header cells.

HeaderRow.className is added but not used in <TableHead>, so per-header styling won’t take effect.

🛠️ Proposed fix
-            {headers.map(({ key, width }, index) => (
+            {headers.map(({ key, width, className: headerClassName }, index) => (
               <TableHead
                 className={cn(
                   index == 0 && "first:rounded-l-md",
                   "h-auto py-1 pl-2 pr-2 text-black text-center ",
                   width && `w-${width}`,
+                  headerClassName,
                 )}
                 key={key}
               >

Also applies to: 75-81

🤖 Prompt for AI Agents
In `@src/components/Common/PrintTable.tsx` around lines 14 - 18, The
HeaderRow.className property is never applied when rendering table headers in
PrintTable; update the header-rendering code paths (where PrintTable maps over
headers in TableHead / headers.map) to add the header.className to the header
cell element (e.g., the <th> or TableCell used for header rows), merging it with
any existing classes (safely handling undefined) and keeping the existing key
and width handling; make the same change for the second header-rendering block
(the other headers.map usage) so per-header styling via HeaderRow.className
takes effect everywhere.

@github-actions
Copy link

github-actions bot commented Jan 21, 2026

🎭 Playwright Test Results

Status: ❌ Failed
Test Shards: 3

Metric Count
Total Tests 171
✅ Passed 147
❌ Failed 24
⏭️ Skipped 0

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

Run: #5004

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 21, 2026 17:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

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

🤖 Fix all issues with AI agents
In `@src/components/Common/PrintTable.tsx`:
- Around line 51-68: getCellContent currently calls
cellConfig[key].render(value) which prevents per-column renderers from accessing
the key or rowIndex; update getCellContent to call cellConfig[key].render with
the same signature as renderCell (e.g., render(value, key, rowIndex)) and adjust
any CellConfig type/definition for render to accept (value, key, rowIndex) so
column-specific renderers can use the extra context while keeping the existing
renderCell(key, value, rowIndex) priority logic.
♻️ Duplicate comments (3)
src/components/Common/PrintTable.tsx (3)

14-18: HeaderRow.className is declared but never applied to header cells.

The className property added to HeaderRow at line 17 is never destructured or used when rendering <TableHead> elements (lines 75-86). Per-header styling will not take effect.

🛠️ Proposed fix
-            {headers.map(({ key, width }, index) => (
+            {headers.map(({ key, width, className: headerClassName }, index) => (
               <TableHead
                 className={cn(
                   index == 0 && "first:rounded-l-md",
                   "h-auto py-1 pl-2 pr-2 text-black text-center ",
                   width && `w-${width}`,
+                  headerClassName,
                 )}
                 key={key}
               >

22-26: CellConfig.value is defined but never used.

The value property in CellConfig is declared but getCellContent never reads it. Callers cannot override a cell's displayed value via config.

🛠️ Proposed fix in getCellContent
+    // Priority 3: Cell-specific value override
+    const configuredValue = cellConfig?.[key]?.value;
+    if (configuredValue !== undefined) {
+      return configuredValue;
+    }
+
-    // Priority 3: Default value or "-"
+    // Priority 4: Default value or "-"
     return value || "-";

100-109: Invalid Tailwind class: wrap-break-words should be break-words.

wrap-break-words is not a valid Tailwind CSS utility class. The standard class for word breaking is break-words (which applies overflow-wrap: break-word).

🛠️ Proposed fix
                   <TableCell
                     className={cn(
-                      "wrap-break-words whitespace-normal text-center",
+                      "break-words whitespace-normal text-center",
                       classNameCell,
                       cellConfig?.[key]?.className,
                     )}

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: 2

🤖 Fix all issues with AI agents
In `@src/components/Prescription/PrescriptionPreview.tsx`:
- Around line 200-205: In PrescriptionPreview.tsx update the wrapping utility on
the container div (the element rendering facility.address inside the component)
by replacing the non-standard class "wrap-break-word" with Tailwind's standard
"break-words"; locate the div with className "text-gray-500 whitespace-pre-wrap
wrap-break-word text-xs" and change the class list to include "break-words" so
text wrapping behaves correctly (no other logic changes required).
- Around line 248-253: Replace the hard-coded date format usage in
PrescriptionPreview (the value prop that currently uses format(new
Date(encounter.period.start), "dd/MM/yy") or format(new Date(), "dd/MM/yy"))
with the shared utility formatDateTime by using
formatDateTime(encounter?.period?.start || new Date()); also ensure
formatDateTime is imported where PrescriptionPreview is defined so the component
uses the app-wide medical timestamp formatting.

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.

2 participants