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

Fix: Discharge patient showing live #9415

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

Conversation

AdityaJ2305
Copy link
Contributor

@AdityaJ2305 AdityaJ2305 commented Dec 14, 2024

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

  • New Features

    • Introduced a new section in the Consultation Card for displaying patient status with a visual indicator.
  • Bug Fixes

    • Improved layout and structure of the Consultation Card for better organization and clarity.
  • Refactor

    • Removed the patient status display from the Demography component, streamlining the user interface while maintaining core functionality.
  • Style

    • Adjusted layout and positioning of elements within the Demography component for enhanced user experience.

@AdityaJ2305 AdityaJ2305 requested a review from a team as a code owner December 14, 2024 08:22
Copy link
Contributor

coderabbitai bot commented Dec 14, 2024

Walkthrough

The pull request focuses on addressing patient status display inconsistencies across two components: ConsultationCard.tsx and Demography.tsx. In ConsultationCard.tsx, a new section is introduced to display patient status using a Chip component, while in Demography.tsx, the patient status section is removed entirely. These changes aim to resolve issues with how patient status (live or discharged) is represented in the user interface.

Changes

File Change Summary
src/components/Facility/ConsultationCard.tsx Added new section with Chip to display patient status, improved layout using flexbox
src/components/Patient/PatientDetailsTab/Demography.tsx Removed patient status section and associated Chip component

Assessment against linked issues

Objective Addressed Explanation
Resolve discharged patient status showing as "live" [#9289]

Possibly related PRs

Suggested labels

needs review, tested, P1

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 A rabbit's tale of patient care,
Where status chips now dance with flair,
No more confusion, clear and bright,
Live or discharged, we set it right!
Code hops forward with each new line 🏥

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


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 Dec 14, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 00fb42b
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/675d40a37f213d000857a77a
😎 Deploy Preview https://deploy-preview-9415--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
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

🧹 Outside diff range and nitpick comments (3)
src/components/Facility/ConsultationCard.tsx (3)

Line range hint 18-22: Consider renaming isLastConsultation prop for clarity

The isLastConsultation prop is being used to determine if a patient is discharged, but its name doesn't clearly convey this purpose. This could lead to confusion and maintenance issues.

Consider renaming it to something more explicit like isDischargedConsultation or adding a JSDoc comment to clarify its purpose:

 interface ConsultationProps {
   itemData: ConsultationModel;
-  isLastConsultation?: boolean;
+  /** Indicates if this consultation resulted in patient discharge */
+  isDischargedConsultation?: boolean;
   refetch: () => void;
 }

57-72: Simplify the layout structure

The current layout uses nested flex containers with translation transforms, which makes it harder to maintain and could cause layout issues across different screen sizes.

Consider simplifying the layout:

-<div className="flex flex-wrap items-center gap-4 mt-4">
-  <div className="flex flex-col gap-1">
+<div className="grid grid-cols-1 sm:grid-cols-2 gap-4 mt-4">
+  <div className="flex items-center gap-4">
     <Chip
       size="small"
       variant={itemData.suggestion === "A" ? "alert" : "primary"}
       text={
         itemData.suggestion === "A"
           ? t("ip_encounter")
           : t("op_encounter")
       }
-      className="-translate-y-2"
     />
-    <div className="text-sm">
+    <div className="text-sm whitespace-nowrap">
       {dayjs(itemData.created_date).format("DD/MM/YYYY")}
     </div>
   </div>

83-88: Reconsider the implementation approach for patient status

The current implementation relies on isLastConsultation to determine patient status, but this might not be the most reliable indicator. The itemData.discharge_date would be a more direct and reliable way to determine if a patient is discharged.

Consider these points:

  1. A patient's discharge status should be determined by the presence of discharge_date
  2. The isLastConsultation prop might not always correlate with discharge status
  3. This change should be coordinated with the removal of status display from Demography.tsx to ensure consistent status display across the application
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8963ad and 00fb42b.

📒 Files selected for processing (2)
  • src/components/Facility/ConsultationCard.tsx (2 hunks)
  • src/components/Patient/PatientDetailsTab/Demography.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Patient/PatientDetailsTab/Demography.tsx
🔇 Additional comments (1)
src/components/Facility/ConsultationCard.tsx (1)

74-89: ⚠️ Potential issue

Multiple improvements needed in the patient status section

  1. The status text "LIVE" and "DISCHARGED" should use i18n translations
  2. The negative translate value (-translate-y-5) suggests a layout issue
  3. The status logic might be incorrect based on the PR title "Fix: Discharge patient showing live"

Here's the suggested fix:

 {/* Patient Status Section */}
-<div className="flex items-center gap-2 -translate-y-5 ">
+<div className="flex items-center gap-2">
   <div className="text-sm font-normal leading-5">
     {t("patient_status")}
   </div>
   <Chip
     size="medium"
     variant="custom"
     className={
-      !isLastConsultation
+      itemData.discharge_date
         ? "bg-red-100 text-red-800"
         : "bg-blue-100 text-blue-800"
     }
-    text={!isLastConsultation ? "LIVE" : "DISCHARGED"}
+    text={itemData.discharge_date ? t("discharged") : t("live")}
   />
 </div>

Let's verify the discharge status logic across the codebase:

✅ Verification successful

The review comment suggestions are correct and should be implemented

The codebase analysis confirms:

  1. The hardcoded "LIVE" and "DISCHARGED" strings should use translations as they are already available in multiple language files (en.json, kn.json, ta.json, etc.) with keys "live" and "discharged"

  2. The -translate-y-5 appears to be an arbitrary value not used elsewhere in similar contexts, suggesting it's a hacky fix

  3. The logic for determining status should indeed be based on discharge_date as suggested in the review, as this is the consistent pattern used throughout the codebase for determining patient discharge status (seen in multiple components like PatientHome.tsx, PatientInfoCard.tsx, etc.)

The suggested fix in the review comment is the correct approach:

  • Uses proper i18n translations
  • Removes the hacky translation
  • Uses the correct discharge_date based logic which aligns with the rest of the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other components that determine patient discharge status
rg -A 5 "discharge_date|isLastConsultation" --type tsx

Length of output: 84


Script:

#!/bin/bash
# Search for discharge status related code with proper file extensions
rg -t ts -t tsx -A 5 "discharge_date|isLastConsultation"

# Also search for translation keys related to patient status
rg -t ts -t tsx -t json "\"live\"|\"discharged\"|\"patient_status\""

Length of output: 179


Script:

#!/bin/bash
# Search for discharge status related code
rg -g "*.{ts,tsx,js,jsx}" "discharge_date|isLastConsultation" -A 5

# Search for translation keys related to patient status
rg -g "*.{ts,tsx,js,jsx,json}" "\"live\"|\"discharged\"|\"patient_status\"" 

Length of output: 44391

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.

Discharged Patient status showing as "live"
1 participant