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

Enhancement of Immunisation Records Tab in patient details page #9441

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

Conversation

Rishith25
Copy link
Contributor

@Rishith25 Rishith25 commented Dec 15, 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 search functionality for immunisation records.
    • Added a dropdown filter for vaccine statuses: "Completed," "In-Progress," and "Not-Done."
    • Enhanced the immunisation records table with new columns: "Immunisation Type," "Covin ID," "Vaccine Name," "Status," and "Series Progress."
    • Improved layout and styling for better user experience.
  • Bug Fixes

    • Updated rendering logic to display a message when no immunisation records are available.

Copy link
Contributor

coderabbitai bot commented Dec 15, 2024

Walkthrough

The pull request modifies the ImmunisationRecords component to introduce a search and filter functionality for vaccine records. The changes include adding a search input for vaccine names, implementing a dropdown filter for vaccine statuses, and restructuring the immunisation records table. The component now supports case-insensitive searching, filtering by status, and provides a more comprehensive display of immunisation details with additional columns and improved layout.

Changes

File Change Summary
src/components/Patient/PatientDetailsTab/ImmunisationRecords.tsx - Added search functionality with searchTerm state variable
- Implemented handleSearchChange function for case-insensitive search
- Added dropdown filter for vaccine statuses
- Restructured table with new columns (Immunisation Type, Covin ID, Vaccine Name, Status, Series Progress)
- Updated import statements to include new components

Assessment against linked issues

Objective Addressed Explanation
Enhance Immunisation tab design [#9357]
Implement search functionality
Add status filter dropdown

Possibly related PRs

  • No strongly related PRs identified based on the provided information.

Poem

🐰 Hop, hop, through vaccine's domain,
Search and filter, no record's a pain!
Dropdown dancing, search input bright,
Immunisation records now shine with might!
A rabbit's guide to medical delight! 🏥💉


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 15, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit df216e3
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/676a617b0d6cce00083ca977
😎 Deploy Preview https://deploy-preview-9441--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.

@Rishith25
Copy link
Contributor Author

Rishith25 commented Dec 16, 2024

Hi @bodhish Currently we have only covid vaccine details. So, for now i just displayed covid vaccine details in pateint details immunisation tab.

This is how its look like now
image

Will we get immunisation record form as you mentioned earlier that we should have structure form to capture Immunisation records in encounter form.

is this fine for now or should i hold this PR till we get encounter form ready.

@github-actions github-actions bot added needs-triage question Further information is requested labels Dec 16, 2024
Copy link

👋 Hi, @Rishith25,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 17, 2024
@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Dec 17, 2024
@Rishith25 Rishith25 marked this pull request as ready for review December 17, 2024 12:37
@Rishith25 Rishith25 requested a review from a team as a code owner December 17, 2024 12:37
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: 3

🧹 Nitpick comments (5)
src/components/Patient/PatientDetailsTab/ImmunisationRecords.tsx (5)

54-58: Simplify the conditional expression using optional chaining

You can simplify the conditional check by using optional chaining (?.) to handle cases where patientData.vaccine_name might be undefined or null. This makes the code more concise and readable.

Apply this diff to simplify the expression:

 const filteredData =
   !searchTerm ||
-  (patientData.vaccine_name &&
-    patientData.vaccine_name.toLowerCase().includes(searchTerm));
+  patientData.vaccine_name?.toLowerCase().includes(searchTerm);
🧰 Tools
🪛 Biome (1.9.4)

[error] 56-57: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


54-58: Rename filteredData to reflect its boolean nature

The variable filteredData holds a boolean value indicating whether the data matches the search criteria. Renaming it to something like matchesSearchTerm would improve code clarity.

Apply this diff to rename the variable:

-const filteredData =
+const matchesSearchTerm =

Remember to update all instances where filteredData is used accordingly.

🧰 Tools
🪛 Biome (1.9.4)

[error] 56-57: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


87-95: Add onSelect handler to DropdownMenuItem

To make the filter operational, add an onSelect handler to each DropdownMenuItem to update the selected status in the state.

Apply this diff to add the handler:

 {vaccineStatuses.map((status) => (
   <DropdownMenuItem
     key={status}
     className="hover:font-bold cursor-pointer"
+    onSelect={() => setSelectedStatus(status)}
   >
     {status}
   </DropdownMenuItem>
 ))}

Ensure you define selectedStatus using useState and adjust the data filtering logic accordingly.


144-185: Avoid redundant checks in conditional rendering

Since patientData.is_vaccinated is already checked in the parent conditional at line 144, you can remove redundant patientData.is_vaccinated checks within the child elements to simplify the code.

Apply this diff to remove redundant checks:

 {patientData.is_vaccinated && filteredData ? (
   <tr>
     <td className="...">
-      {patientData.is_vaccinated && patientData.covin_id
+      {patientData.covin_id
         ? patientData.covin_id
         : "-"}
     </td>
     <!-- Repeat for other fields -->
   </tr>
 ) : (
   <!-- No records available row -->
 )}

189-189: Consider handling multiple immunisation records

Currently, the component is set up to display only COVID-19 vaccine details. If you plan to expand this to handle multiple immunisation records, consider iterating over an array of records.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f56e6f5 and a30c93f.

📒 Files selected for processing (1)
  • src/components/Patient/PatientDetailsTab/ImmunisationRecords.tsx (2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Patient/PatientDetailsTab/ImmunisationRecords.tsx

[error] 56-57: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (3)
src/components/Patient/PatientDetailsTab/ImmunisationRecords.tsx (3)

48-49: Initialize state variables and constants effectively

The initialization of searchTerm and vaccineStatuses is appropriate and correctly implemented.


51-53: Ensure consistent handling of search input

The handleSearchChange function correctly updates the searchTerm state with a lowercase value for case-insensitive searching.


98-115: Confirm edit permission logic and notification

The edit button correctly checks for patient activity and user permissions before allowing edits. The notification for permission denial is appropriate.

Comment on lines +67 to +95
<div className="flex flex-col sm:flex-row sm:justify-between sm:items-center mb-4">
<SearchInput
className="w-72 sm:w-108 mb-4 sm:mb-0"
value={searchTerm}
onChange={handleSearchChange}
placeholder="Search by Vaccine Name"
name="vaccineNameSearch"
/>
<div className="flex sm:ml-4 sm:space-x-4 w-full sm:w-auto mb-4 sm:mb-0">
<DropdownMenu modal={false}>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
className="flex items-center w-full sm:w-auto"
>
<CareIcon icon="l-filter" className="mr-2" />
{t("filter")}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-full font-medium">
{vaccineStatuses.map((status) => (
<DropdownMenuItem
key={status}
className="hover:font-bold cursor-pointer"
>
{status}
</DropdownMenuItem>
))}
</DropdownMenuContent>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Implement state management for filter functionality

Currently, the filter dropdown for vaccine statuses is rendered, but there's no state variable to store the selected status or logic to filter the data based on the selected status. Implementing this will make the filter functional.

Would you like assistance in implementing the state management and filtering logic for vaccine statuses?

Comment on lines +161 to +163
text="Completed"
className="text-green rounded-full text-sm font-semibold"
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make the immunisation status dynamic

The text prop for the Chip component is hardcoded to "Completed". To reflect the actual status of the immunisation record, consider making this value dynamic based on patient data.

Apply this diff to use dynamic status:

 <Chip
-  text="Completed"
+  text={patientData.immunisation_status || "Status Unknown"}
   className="text-green rounded-full text-sm font-semibold"
/>

Ensure that patientData includes an immunisation_status field or adjust accordingly.

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +171 to +173
{patientData.is_vaccinated && patientData.number_of_doses
? patientData.number_of_doses + "/3"
: "-"}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid hardcoding total doses in Series Progress

The total number of vaccine doses ("/3") is hardcoded. To make the component adaptable to different vaccines with varying dose requirements, consider making the total number of doses dynamic.

Apply this diff to make total doses dynamic:

 {patientData.number_of_doses
-  ? patientData.number_of_doses + "/3"
+  ? `${patientData.number_of_doses}/${patientData.total_doses || "N/A"}`
   : "-"}

Ensure that patientData includes a total_doses field representing the required doses for the vaccine.

Committable suggestion skipped: line range outside the PR's diff.

@Jacobjeevan Jacobjeevan added work-in-progress and removed question Further information is requested needs-triage labels Dec 18, 2024
@Jacobjeevan
Copy link
Contributor

Jacobjeevan commented Dec 23, 2024

@Rishith25 Are you waiting on the backend/input from Vignesh? 🤔

@Rishith25
Copy link
Contributor Author

@Rishith25 Are you waiting on the backend/input from Vignesh? 🤔

Yes

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.

Enhancement of Immunisation tab in patient details page
2 participants