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

Treatment Summary UI Enhancement #10563

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Feb 11, 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

  • Style
    • Enhanced the visual presentation of patient-related screens by refining borders and padding.
    • Improved the appearance in varied states such as loading and when no content is available.
    • Enabled flexible styling options to ensure a more consistent and polished user interface.
    • Added a new localization entry for displaying a message when no medication records are available.
    • Introduced conditional rendering for displaying messages when no medication records are found.
    • Adjusted badge styling based on print preview mode for better clarity and presentation.
    • Enhanced layout styling capabilities for Allergy, Diagnosis, and Symptoms lists.
    • Improved the display of symptom notes in print preview mode for better user experience.

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner February 11, 2025 18:32
Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Walkthrough

The changes update the visual styling in several patient components. The modifications remove the border-none class and add a p-2 class to the Card components while also introducing support for a custom className prop in layout components. In the Treatment Summary, class names have been altered to use explicit black borders along with padding adjustments. Additionally, a new localization entry for "No Medication Recorded" has been added. No changes were made to the underlying logic or public API of the components.

Changes

Files Change Summary
src/components/Patient/MedicationStatementList.tsx, src/components/Patient/allergy/list.tsx, src/components/Patient/diagnosis/list.tsx, src/components/Patient/symptoms/list.tsx Removed border-none from Card components, added p-2, and enabled className prop support in layout components for enhanced styling control.
src/components/Patient/TreatmentSummary.tsx Updated border styling by replacing border-none shadow-none with border border-black shadow-none and added p-3; also, the height class was updated to min-h-screen.
public/locale/en.json Added new localization entry "no_medication_recorded": "No Medication Recorded".
src/components/Medicine/MedicationsTable.tsx Introduced conditional rendering for displaying a message when no medication records are available.
src/components/Patient/diagnosis/DiagnosisTable.tsx, src/components/Patient/symptoms/SymptomTable.tsx Modified Badge components to conditionally apply class names based on the isPrintPreview prop, affecting their visual representation.

Possibly related PRs

  • Treatment Summary UI #10447: The changes in the main PR, particularly in the MedicationStatementList component, are related to the modifications in the TreatmentSummary component from the retrieved PR, as both involve the handling of the isPrintPreview prop and adjustments to the visual presentation of medication-related information.
  • fix: Align and format cards in Health Profile #10298: The changes in the main PR are related to the modifications in the MedicationStatementList component's layout and styling, which align with the adjustments made to the CardContent in the retrieved PR, specifically regarding the presentation of messages when no records are available.

Suggested reviewers

  • rithviknishad
  • Jacobjeevan
  • amjithtitus09

Poem

I’m a bouncy little rabbit, coding with delight,
Adjusting borders and paddings, making everything just right.
With tweaks in every component, my hops are full of cheer,
The code now shines in grayscale, a vision oh so clear!
Leaping through the changes with joy and bunny pride,
Celebrating styled-up elements on this coding ride!
🐇 Hop on, dear devs, let’s enjoy this festive stride!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f293a73 and 650eb1b.

📒 Files selected for processing (1)
  • src/components/Patient/MedicationStatementList.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Patient/MedicationStatementList.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)

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 Feb 11, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 650eb1b
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67adb53561c40500086d9c8d
😎 Deploy Preview https://deploy-preview-10563.preview.ohc.network
📱 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
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

🔭 Outside diff range comments (1)
src/components/Patient/MedicationStatementList.tsx (1)

179-179: 🛠️ Refactor suggestion

Remove inconsistent border styling.

The Card component still has border-none which conflicts with the parent component's border styling in TreatmentSummary.

-    <Card className={cn("border-none rounded-sm", className)}>
+    <Card className={cn("rounded-sm", className)}>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29060ed and 14bb055.

📒 Files selected for processing (5)
  • src/components/Patient/MedicationStatementList.tsx (2 hunks)
  • src/components/Patient/TreatmentSummary.tsx (3 hunks)
  • src/components/Patient/allergy/list.tsx (3 hunks)
  • src/components/Patient/diagnosis/list.tsx (3 hunks)
  • src/components/Patient/symptoms/list.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (5)
src/components/Patient/TreatmentSummary.tsx (1)

194-230: LGTM! Consistent border styling across components.

The border styling changes are consistent across all components (AllergyList, SymptomsList, DiagnosisList, MedicationStatementList), improving the visual consistency of the treatment summary.

src/components/Patient/diagnosis/list.tsx (1)

142-142: LGTM! Consistent Card styling.

The Card styling changes align with other components, maintaining visual consistency.

src/components/Patient/symptoms/list.tsx (1)

140-140: LGTM! Consistent Card styling.

The Card styling changes align with other components, maintaining visual consistency.

src/components/Patient/allergy/list.tsx (2)

98-98: LGTM! Consistent className prop forwarding.

The className prop is now consistently forwarded to AllergyListLayout across all rendering paths (loading, empty, and main states), improving the component's styling flexibility.

Also applies to: 122-122


310-310: LGTM! Enhanced Card styling with proper className composition.

The styling changes:

  • Add consistent padding with p-2
  • Apply subtle border radius with rounded-sm
  • Maintain className extensibility through proper composition with the cn() utility

src/components/Patient/TreatmentSummary.tsx Outdated Show resolved Hide resolved
AdityaJ2305 and others added 2 commits February 12, 2025 00:09
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Jacobjeevan
Copy link
Contributor

Jacobjeevan commented Feb 12, 2025

Don't need colors for the badges here:

image

Modify the filteredMedications length check to display no medications recorded, and the table row styling as well when there's data:

image

cc: @amjithtitus09

@amjithtitus09
Copy link
Contributor

Don't need colors for the badges here:

image

Is this done @AdityaJ2305 ?
cc @Jacobjeevan @rithviknishad

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 12, 2025
@AdityaJ2305
Copy link
Contributor Author

AdityaJ2305 commented Feb 12, 2025

@amjithtitus09
No, just about to make the changes. I’m planning to use isPrintPreview to disable CSS for it—applied only to status. It’ll look like this:

Screenshot 2025-02-12 at 9 20 20 PM

LMK your thoughts

<Badge
            variant="outline"
            className={
              isPrintPreview
                ? ""
                : `whitespace-nowrap ${ALLERGY_CLINICAL_STATUS_STYLES[allergy.clinical_status]}`
            }
          >
            {t(allergy.clinical_status)}
</Badge>

@AdityaJ2305
Copy link
Contributor Author

@amjithtitus09 Done with the changes . Ready for review 🙂

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

🧹 Nitpick comments (2)
src/components/Patient/diagnosis/DiagnosisTable.tsx (1)

74-104: Consider extracting the badge styling logic.

The badge styling logic is duplicated across multiple badges. Consider extracting it into a reusable helper function or component.

+const getBadgeClassName = (isPrintPreview: boolean, styles: string) => 
+  isPrintPreview ? "" : `whitespace-nowrap ${styles}`;

 <Badge
   variant="outline"
-  className={
-    isPrintPreview
-      ? ""
-      : `whitespace-nowrap ${
-          DIAGNOSIS_CLINICAL_STATUS_STYLES[
-            diagnosis.clinical_status
-          ]
-        }`
-  }
+  className={getBadgeClassName(
+    isPrintPreview,
+    DIAGNOSIS_CLINICAL_STATUS_STYLES[diagnosis.clinical_status]
+  )}
 >
src/components/Patient/symptoms/SymptomTable.tsx (1)

75-87: Consider sharing badge styling logic between components.

The badge styling implementation is identical to DiagnosisTable.tsx. Consider:

  1. Creating a shared helper function for badge styling
  2. Creating a shared styled badge component

This would improve maintainability and ensure consistent behavior across components.

// src/components/Common/PrintAwareBadge.tsx
interface PrintAwareBadgeProps {
  isPrintPreview?: boolean;
  styles: string;
  children: React.ReactNode;
}

export function PrintAwareBadge({
  isPrintPreview = false,
  styles,
  children,
  ...props
}: PrintAwareBadgeProps) {
  return (
    <Badge
      variant="outline"
      className={isPrintPreview ? "" : `whitespace-nowrap ${styles}`}
      {...props}
    >
      {children}
    </Badge>
  );
}

Usage:

-<Badge
-  variant="outline"
-  className={
-    isPrintPreview
-      ? ""
-      : `whitespace-nowrap ${
-          SYMPTOM_SEVERITY_STYLES[symptom.severity]
-        }`
-  }
->
+<PrintAwareBadge
+  isPrintPreview={isPrintPreview}
+  styles={SYMPTOM_SEVERITY_STYLES[symptom.severity]}
+>
   {t(symptom.severity)}
-</Badge>
+</PrintAwareBadge>

Also applies to: 89-101, 103-117

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1e2a51 and c8a45cb.

📒 Files selected for processing (6)
  • src/components/Patient/MedicationStatementList.tsx (2 hunks)
  • src/components/Patient/allergy/list.tsx (4 hunks)
  • src/components/Patient/diagnosis/DiagnosisTable.tsx (1 hunks)
  • src/components/Patient/diagnosis/list.tsx (3 hunks)
  • src/components/Patient/symptoms/SymptomTable.tsx (1 hunks)
  • src/components/Patient/symptoms/list.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/components/Patient/diagnosis/list.tsx
  • src/components/Patient/MedicationStatementList.tsx
  • src/components/Patient/symptoms/list.tsx
  • src/components/Patient/allergy/list.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (3)
src/components/Patient/diagnosis/DiagnosisTable.tsx (2)

74-88: LGTM! Clinical status badge styling implementation.

The conditional styling based on isPrintPreview aligns with the PR objectives and reviewer feedback about badge colors.


90-104: LGTM! Verification status badge styling implementation.

The conditional styling based on isPrintPreview aligns with the PR objectives and reviewer feedback about badge colors.

src/components/Patient/symptoms/SymptomTable.tsx (1)

75-117: Verify badge styling behavior in print preview.

The changes align with the PR objectives and reviewer feedback. However, let's verify the print preview appearance matches the expected design.

✅ Verification successful

🌐 Web query:

What is the recommended way to test print preview in React applications?

💡 Result:

To test print preview functionality in React applications effectively, developers should combine specific testing strategies and leverage the react-to-print library's features. Here's a structured approach:

1. Component Inspection with React Testing Library

  • Use screen.debug() to inspect rendered components:
    test('verify printable content', () => {
      render(<PrintableComponent />);
      screen.debug(undefined, Infinity); // Shows full component structure[10]
    });
  • This exposes hidden elements wrapped in <div style={{ display: "none" }}> that are only visible during printing[3][6].

2. State Synchronization Testing

  • Test asynchronous state handling required for printing:
    test('state updates before printing', async () => {
      const { getByText } = render(<PrintButton />);
      fireEvent.click(getByText('Print'));
      await waitFor(() => expect(screen.getByTestId('print-content')).toBeVisible());
    });
  • Ensures components properly use Promises to wait for DOM updates[2][3][7].

3. Print Iframe Preservation

  • Enable preserveAfterPrint flag during testing:
    <ReactToPrint
      preserveAfterPrint={true}
      content={() => componentRef.current}
    />
  • Allows post-print inspection of generated iframe content[7].

4. CSS Media Query Verification

Test print-specific styles using:

@media print {
  .no-print { display: none; }
}

Validate styles with tools like:

expect(getComputedStyle(element).display).toBe('none');

5. Browser Print Dialog Mocking

Mock window.print() in tests:

const printMock = jest.spyOn(window, 'print').mockImplementation();
// ... test execution ...
expect(printMock).toHaveBeenCalled();

Key Considerations

Aspect Implementation Source
Hidden Components Use display: none wrapper [3][7]
Async State Promise resolution in onBeforePrint [2][3][7]
Style Isolation Dedicated @media print CSS [1][4]
Debugging preserveAfterPrint + screen.debug [7][10]

For comprehensive testing, combine visual inspection of preserved print iframes with state/behavior assertions to ensure all printable elements render correctly while non-essential UI remains hidden[1][3][7].

Citations:


Print Preview Badge Styling: Behavior Verified

  • The conditional logic using isPrintPreview correctly bypasses the addition of extra style classes in print preview mode.
  • The code omits badge-specific styling when printing, which is in line with the expected design.
  • Recommended testing approaches (e.g., with React Testing Library and react-to-print) support verifying that print-specific rendering omits non-print styles.

@amjithtitus09
Copy link
Contributor

@AdityaJ2305
image

In the right direction but few more changes needed here.

There is still bg colour, and coloured labels. Also border needs to be consistent for all tables. Check if there's shadow for the questionnaire responses at the bottom.

@AdityaJ2305
Copy link
Contributor Author

@amjithtitus09n, Let me know ur input

I just want to confirm if I’ve understood the requirements correctly:

  • Green color dots – The background is present only here and needs to be removed. Everywhere else, there’s no background, right?
  • Red color dot – Missed removing the color from this badge.
  • Blue color – Need to check the shadow here only.
    WhatsApp Image 2025-02-13 at 12 14 28

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 13, 2025
@AdityaJ2305
Copy link
Contributor Author

  • Red color dot – Missed removing the color from this badge.
  • Also border needs to be consistent for all tables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage question Further information is requested work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Treatment Summary UI | Reduce colours
4 participants