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

New Patient Search and Register UI #9400

Open
wants to merge 20 commits into
base: form-field-v1
Choose a base branch
from

Conversation

shivankacker
Copy link
Member

@shivankacker shivankacker commented Dec 12, 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 SectionNavigator component for improved navigation within sections.
    • Added PatientIndex and PatientRegistration components for enhanced patient management and registration.
    • Implemented new search options and filters in the FacilityList and ManagePatients components.
  • Enhancements

    • Updated language strings for improved clarity and user experience.
    • Enhanced input components with error handling and label support.
  • Bug Fixes

    • Improved error handling in various components for better user feedback.
  • Chores

    • Updated dependency versions for improved stability and performance.

Copy link
Contributor

coderabbitai bot commented Dec 12, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces comprehensive updates across multiple components of a healthcare application. The changes span dependency version updates, internationalization improvements, UI component enhancements, and patient management functionalities. Key modifications include introducing new components like SectionNavigator, PatientIndex, and PatientRegistration, updating utility functions, refining search and filter mechanisms, and improving form validation and error handling across various UI elements.

Changes

File Change Summary
package.json Updated dependency versions for @radix-ui/react-checkbox, @radix-ui/react-radio-group, and i18next-browser-languagedetector
public/locale/en.json Added multiple new localization strings for patient registration, error messages, and UI guidance
src/components/Patient/* Introduced new components PatientIndex, PatientRegistration, updated Utils.ts, modified models.tsx
src/components/ui/* Enhanced input components (checkbox, input, radio-group, select, textarea) with label and error handling support
src/Routers/routes/PatientRoutes.tsx Updated routes to use new PatientIndex and PatientRegistration components

Suggested labels

P1

Suggested reviewers

  • rithviknishad
  • nihal467
  • Jacobjeevan

Poem

🐰 A Rabbit's Ode to Code Renewal 🐰

Packages bumped, components refined,
Patient flows now beautifully designed.
Checkboxes dance, inputs gleam bright,
Our codebase leaps with pure delight!

Hop, hop, hooray for clean UI! 🎉


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.

@shivankacker shivankacker changed the title search page New Patient Search and Register UI Dec 12, 2024
Copy link

cloudflare-workers-and-pages bot commented Dec 12, 2024

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4f17160
Status: ✅  Deploy successful!
Preview URL: https://470907f0.care-fe.pages.dev
Branch Preview URL: https://patient-registration.care-fe.pages.dev

View logs

@shivankacker shivankacker self-assigned this Dec 12, 2024
@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 13, 2024
Copy link

👋 Hi, @shivankacker,
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 removed the merge conflict pull requests with merge conflict label Dec 14, 2024
@nihal467
Copy link
Member

nihal467 commented Dec 15, 2024

Bug Report

Major Functionality


image
image

  • When we create a patient with a 20-digit number, the system successfully redirects to the consultation page. However, when I check the respective patient details page, it reflects as 'undefined'.
  • A similar issue arises when we fill only the date in the DOB field and leave the month and year blank. Ensure that all the fields have proper validation.

image

  • No New Patient Registration is possible either with DOB or Age, in all scenario, the formatting issue is thrown and the registration fails

image

  • The entire insurance details section is missing from the patient registration form.

image

  • When a patient is registered with age instead of DOB, only display the age in the 'Search Patient' UI.
  • Rename the column name from DOB to Age/DOB

Minor Functionality


image

  • The Shift+P shortcut is not working on the Windows OS.
  • The representation of the key on the button doesn't look good at all. stick to the figma

image

  • Reset the search input field when the corresponding badge is manually closed.

image

  • The placeholder of the IP/OP number is clipping in.

image

  • Add a skeleton loader to the 'Search Patient' page while the data is being fetched based on the input.

image

  • Keep the DOB format as DD-MM-YYYY on the 'Search Patient' page.

image

  • Remove the "*" for Landmark and Ward as they are non-mandatory fields.
  • Add placeholders for all dropdowns as shown in our latest Figma design.

image

  • Rename 'Non-binary' to 'Transgender' in the sex field.

image

  • Keep the phone number hardcoded to have +91 in the field.
  • The phone number should only accept 10 digits.

image

  • Emergency contact person is missing field validation

image

  • The autofill is not working for the district because the field enabling is facing some delay.

image

  • The tab switching functionality does not properly use colors, making it difficult for users to identify the currently active tab on the initial load of the 'All Patients' page.

image

  • add spacing between the badges and the search field in the patient list page

Question needs clarification


image

  • Why are we mixing the IP/OP column with the name? Isn't it better to keep them separate?

image

  • Disabling ABDM and HCX on this deploy was intentional? We need to enable them for testing purposes.

image

  • The entire volunteer section and related items are missing from the registration form. Is this intentional?

  • The entire patient transfer workflow from the patient registration form seems to be missing. How do we plan to handle this?

@shivankacker
Copy link
Member Author

@nihal467 we are not including insurance and volunteer details right now.

  • Fixed the field validations
  • A lot of UI bugs in the minor issues you pointed out happened when i pulled form field branch. I let them be for now because I didn't want to break any functionality
  • Pushing the other minor changes in a while

@shivankacker
Copy link
Member Author

shivankacker commented Dec 15, 2024

Made all changes, except :

Add placeholders for all dropdowns as shown in our latest Figma design.

This will add a lot of translations to manage. The label of the field is sufficient enough i think

Rename 'Non-binary' to 'Transgender' in the sex field.

I let it be as what it already was (specified in translations)

The phone number should only accept 10 digits.

Will completely replace with a new phone number field after this PR.


Reset the search input field when the corresponding badge is manually closed.
The tab switching functionality does not properly use colors, making it difficult for users to identify the currently active tab on the initial load of the 'All Patients' page.

Will fix these later

@shivankacker shivankacker marked this pull request as ready for review December 15, 2024 14:32
@shivankacker shivankacker requested a review from a team as a code owner December 15, 2024 14:32
@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 16, 2024
Copy link

👋 Hi, @shivankacker,
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.

@nihal467
Copy link
Member

nihal467 commented Dec 16, 2024

Fix the below Issue before requesting another review

  • Add a validation rule to ensure the phone number field accepts exactly 10 digits. Currently, patients can be created with a 9-digit number. Ensure proper error messages are displayed.
  • Add a mandatory validation for the age field in the patient registration form.
  • Unable to create a new patient / Edit a existing patient by mentioning patient age only
  • When a patient is created with a DOB, and we later visit the patient’s edit page, the DOB field is replaced by the calculated age based on the provided DOB. If we manually switch back to the DOB field, it appears blank.
  • the ration card details are not been stored while creating new patient or updating existing one
  • the occupation details are been stored but when we open the edit registration form page, the field is blank

Issue that can be taken in another PR

  • Add a translation for non-binary sex to transgender in patient registration form
  • Reset the patient search field when the related badge are been removed
  • Add a placeholders for all dropdown as per the figma file
  • The tab switching functionality does not properly use colors, making it difficult for users to identify the currently active tab on the initial load of the 'All Patients' page.
  • Restore Draft feature is missing in the new patient registration form
  • ABDM , HCX workflow
  • Entire Insurance Section

Question

image

  • When filling out the patient registration form, the patient transfer form pops up for matching phone number. Can't we consider implementing this workflow in the patient search instead? Since we are already searching for all patients with the same number, couldn't the workflow be incorporated there?

@@ -64,7 +64,7 @@
"DOMESTIC_HEALTHCARE_SUPPORT__PAID_CAREGIVER": "Paid caregiver",
"GENDER__1": "Male",
"GENDER__2": "Female",
"GENDER__3": "Non-binary",
"GENDER__3": "Transgender",
Copy link
Contributor

Choose a reason for hiding this comment

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

This reminds me of something I came across while testing the user redesign (forgot about it 😅 ) - Back end designates 3 as Non-binary, so we need to update it there as well.

Copy link
Member

Choose a reason for hiding this comment

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

Lets be in sync with the BE

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 18, 2024
Copy link

👋 Hi, @shivankacker,
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.

@shivankacker shivankacker removed the merge conflict pull requests with merge conflict label Dec 18, 2024
@rithviknishad
Copy link
Member

rithviknishad commented Dec 18, 2024

Just noticed

  • Duplicate requests to /patient API on every query change. One with offset and one without.

image

@gigincg
Copy link
Member

gigincg commented Dec 19, 2024

@coderabbitai full review

Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

✅ Actions performed

Full review triggered.

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

🔭 Outside diff range comments (2)
src/pages/Facility/FacilityDetailsPage.tsx (2)

Line range hint 44-54: Enhance error handling for user data fetching

The current error handling could be improved in several ways:

  1. The generic error message doesn't provide enough context for debugging
  2. The silent: true flag might suppress important errors

Consider this improvement:

 const { data: docResponse } = useQuery<
   RequestResult<PaginatedResponse<UserAssignedModel>>
 >({
   queryKey: [routes.getFacilityUsers, id],
   queryFn: async () => {
     const response = await request(routes.getFacilityUsers, {
       pathParams: { facility_id: id },
-      silent: true,
     });
     if (response.res?.status !== 200) {
-      Notification.Error({ msg: "Error while fetching users data" });
+      Notification.Error({
+        msg: t("error_fetching_users", {
+          status: response.res?.status,
+          facility: id
+        })
+      });
     }
     return response;
   },
 });

Line range hint 37-39: Fix pagination implementation

There are two issues with the current pagination:

  1. Using users.length for totalCount is incorrect as it only represents the current page count
  2. The hard-coded limit of 18 might not be optimal for all screen sizes

Consider these fixes:

 const { Pagination } = useFilters({
-  limit: 18,
+  limit: 12, // Standard grid-friendly number
 });

 // Later in the code
-<Pagination totalCount={users.length ?? 0} />
+<Pagination totalCount={docResponse?.data?.count ?? 0} />

Also applies to: 146-146

♻️ Duplicate comments (2)
src/Utils/utils.ts (1)

243-243: ⚠️ Potential issue

Reconsider phone number length validation

The strict length check might reject valid phone numbers:

  1. Toll-free numbers and landlines can have different lengths
  2. Returning an empty string for invalid numbers could mask validation errors

Consider this alternative implementation:

-if (parsedNumber.length < 12) return "";
+// Allow numbers between 8 and 15 digits (inclusive) to support various formats
+if (parsedNumber.length < 8 || parsedNumber.length > 15) return undefined;
public/locale/en.json (1)

67-67: ⚠️ Potential issue

Consider updating backend enum to match frontend gender options.

The gender option for key "GENDER__3" has been changed from "Non-binary" to "Transgender". As noted in a previous review comment by Jacobjeevan, the backend designates 3 as "Non-binary", so this needs to be synchronized.

🧹 Nitpick comments (18)
src/components/Patient/PatientIndex.tsx (3)

1-8: Optimize and group imports to reduce overhead.

While these imports are correct and necessary, consider whether you can lazy-load certain components or group related common utilities together. This can help streamline the import process and potentially improve application performance.


207-227: Add a keydown event fallback for SHIFT+P.

Although you use useKeyboardShortcut, some environments or custom browsers might not support it well. Consider adding a fallback keydown listener or instructions for alternative input methods.


236-361: Consider caution with large queries and frequent re-renders.

The tabbed interface triggers patient queries once isValidSearch is true. If the user toggles tabs frequently, it could lead to repeated fetches. Consider memoizing or implementing query caching to reduce redundant calls.

src/components/Patient/PatientFilter.tsx (1)

795-799: Children passing practice.

At line 1044 in the static analysis hints, there's a recommendation to avoid passing children as a prop. React convention encourages directly embedding children. Consider refactoring if the usage can be replaced with a direct rendering pattern.

src/components/Patient/PatientRegistration.tsx (1)

355-404: Validate date_of_birth thoroughly for boundary checks.

Although there's a regex check for date format, consider validating real feasible dates (e.g., year range, closing unrealistic entries). Tools like date-fns or dayjs can help. This helps avoid invalid but properly formatted dates.

src/components/ui/input.tsx (1)

18-23: Consider improving label accessibility.

While the label implementation is good, consider adding aria-required="true" when the field is required for better screen reader support.

 <Label className="mb-2">
   {label}
-  {required && <span className="text-red-500">*</span>}
+  {required && (
+    <span className="text-red-500" aria-hidden="true">
+      *
+    </span>
+  )}
 </Label>
src/components/ui/radio-group.tsx (2)

19-24: Maintain consistent label accessibility.

For consistency with the Input component, apply the same accessibility improvements to the label implementation.

 <Label className="mb-4">
   {label}
-  {props.required && <span className="text-red-500">*</span>}
+  {props.required && (
+    <span className="text-red-500" aria-hidden="true">
+      *
+    </span>
+  )}
 </Label>

25-31: Consider adding role attribute for better accessibility.

While using Radix UI primitives provides good accessibility, consider adding an explicit role for the error messages container.

- <InputErrors errors={errors} />
+ <div role="alert" aria-live="polite">
+   <InputErrors errors={errors} />
+ </div>
src/Routers/routes/PatientRoutes.tsx (1)

Line range hint 1-53: Consider adding route documentation.

Given the significant changes to the routing structure and the introduction of new components, consider adding JSDoc comments to document the purpose and requirements of each route.

src/CAREUI/misc/SectionNavigator.tsx (2)

28-37: Consider adjusting IntersectionObserver threshold

The current threshold of 0.1 means sections are considered "visible" when only 10% is in view. This might lead to premature section activation, especially for shorter sections.

Consider adjusting the configuration:

-      { rootMargin: "0px 0px -80% 0px", threshold: 0.1 },
+      { rootMargin: "0px 0px -80% 0px", threshold: 0.3 },

15-56: Consider debouncing scroll updates

The current implementation might trigger frequent state updates during rapid scrolling, which could impact performance.

Consider adding debounce to the scroll updates:

import { debounce } from "lodash";

// Inside useEffect
const debouncedUpdate = debounce(updateActiveSection, 100);
// Use debouncedUpdate instead of updateActiveSection
src/components/ui/tabs.tsx (1)

75-96: Consider adding error boundary for section content

The TabbedSections component directly renders user-provided section content without error handling.

Consider wrapping the section content in an error boundary to gracefully handle rendering errors:

import { ErrorBoundary } from 'react-error-boundary';

const TabbedSections = (props: {
  tabs: { label: string; value: string; section: React.ReactNode }[];
}) => {
  // ... existing code ...
  return (
    <>
      <SectionTabs
        tabs={props.tabs}
        activeTab={activeTab}
        onChange={(t) => setActiveTab(t)}
      />
      <div>
        {props.tabs.map(({ value, section }) => (
          <ErrorBoundary key={value} fallback={<div>Error loading section</div>}>
            <div hidden={activeTab !== value}>
              {section}
            </div>
          </ErrorBoundary>
        ))}
      </div>
    </>
  );
};
src/components/Common/Breadcrumbs.tsx (1)

Line range hint 10-16: Consider moving MENU_TAGS to a configuration file

The MENU_TAGS mapping contains business logic that might need frequent updates as new routes are added.

Consider moving this to a dedicated configuration file for better maintainability:

// src/config/navigation.ts
export const MENU_TAGS: Record<string, string> = {
  facility: "Facilities",
  patients: "Patients",
  // ... rest of the tags
};
src/components/ui/select.tsx (1)

27-50: Consider extracting label rendering to a separate component

The label rendering logic could be extracted to improve maintainability and reusability across other form components.

+const SelectLabel: React.FC<{ label?: string; required?: boolean }> = ({
+  label,
+  required,
+}) =>
+  label ? (
+    <Label className="mb-2">
+      {label}
+      {required && <span className="text-red-500">*</span>}
+    </Label>
+  ) : null;

 const SelectTrigger = React.forwardRef<
   React.ElementRef<typeof SelectPrimitive.Trigger>,
   React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & {
     label?: string;
     errors?: string[];
     required?: boolean;
   }
 >(({ className, children, label, errors, required, ...props }, ref) => (
   <>
-    {label && (
-      <Label className="mb-2">
-        {label}
-        {required && <span className="text-red-500">*</span>}
-      </Label>
-    )}
+    <SelectLabel label={label} required={required} />
     <SelectPrimitive.Trigger
       // ... rest of the component
     />
   </>
 ));
src/components/Common/SearchByMultipleFields.tsx (1)

254-254: Consider adding flex properties to the wrapper div

The wrapper div might need flex properties to ensure proper layout alignment with the search icon button.

-<div className="w-full">{renderSearchInput}</div>
+<div className="w-full flex items-center">{renderSearchInput}</div>
src/components/Patient/ManagePatients.tsx (2)

842-857: Improve accessibility of Doctor Connect button

The button needs accessibility improvements:

  1. Missing aria-label for better screen reader support
  2. Missing keyboard shortcut
 <ButtonV2
   className="w-full lg:w-fit"
   id="doctor-connect-patient-button"
+  aria-label="Connect with doctor"
+  accessKey="d"
   onClick={() => {
     triggerGoal("Doctor Connect Clicked", {
       facilityId: qParams.facility,
       userId: authUser.id,
       page: "FacilityPatientsList",
     });
     setShowDoctors(true);
   }}
 >

884-905: Simplify export menu implementation

The export menu implementation could be simplified by moving the data transformation logic to a separate utility function.

+const transformExportData = (data: string) => {
+  const lines = data.split("\n");
+  const idsMap = new Map();
+  lines.forEach((line, i) => {
+    const patientId = line.split(",")[0];
+    if (idsMap.has(patientId)) {
+      idsMap.get(patientId).push(i);
+    } else {
+      idsMap.set(patientId, [i]);
+    }
+  });
+  // ... rest of the transformation logic
+  return cleanedData;
+};

 <ExportMenu
   disabled={!isExportAllowed}
   exportItems={[
     {
       label: "Export Live patients",
       action: async () => {
         const query = {
           ...params,
           csv: true,
           facility: qParams.facility,
         };
-        delete qParams.is_active;
+        const { is_active, ...restParams } = qParams;
         const { data } = await request(routes.patientList, {
           query,
         });
         return data ?? null;
       },
-      parse: preventDuplicatePatientsDuetoPolicyId,
+      parse: transformExportData,
     },
   ]}
 />
🧰 Tools
🪛 Biome (1.9.4)

[error] 895-895: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

public/locale/en.json (1)

1221-1221: Inconsistent phone number field labels.

There are inconsistencies in how phone number fields are labeled:

  • "Primary ph. no." vs "Primary Ph No."
  • Different punctuation and capitalization patterns

Consider standardizing the format:

-  "phone_number_min_error": "Phone number must be at least 10 characters long",
-  "primary_phone_no": "Primary ph. no.",
+  "phone_number_min_error": "Phone number must be at least 10 digits",
+  "primary_phone_no": "Primary Phone Number"

Also applies to: 1277-1277

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6691441 and 9231ecf.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (24)
  • package.json (2 hunks)
  • public/locale/en.json (20 hunks)
  • src/CAREUI/misc/SectionNavigator.tsx (1 hunks)
  • src/Routers/routes/PatientRoutes.tsx (2 hunks)
  • src/Utils/utils.ts (1 hunks)
  • src/components/Common/Breadcrumbs.tsx (1 hunks)
  • src/components/Common/SearchByMultipleFields.tsx (2 hunks)
  • src/components/Facility/FacilityList.tsx (0 hunks)
  • src/components/Patient/ManagePatients.tsx (3 hunks)
  • src/components/Patient/PatientFilter.tsx (4 hunks)
  • src/components/Patient/PatientIndex.tsx (1 hunks)
  • src/components/Patient/PatientRegistration.tsx (1 hunks)
  • src/components/Patient/Utils.ts (1 hunks)
  • src/components/Patient/models.tsx (0 hunks)
  • src/components/ui/checkbox.tsx (1 hunks)
  • src/components/ui/errors.tsx (1 hunks)
  • src/components/ui/input.tsx (1 hunks)
  • src/components/ui/radio-group.tsx (1 hunks)
  • src/components/ui/select.tsx (2 hunks)
  • src/components/ui/tabs.tsx (1 hunks)
  • src/components/ui/textarea.tsx (1 hunks)
  • src/hooks/useFilters.tsx (1 hunks)
  • src/pages/Facility/FacilitiesPage.tsx (0 hunks)
  • src/pages/Facility/FacilityDetailsPage.tsx (1 hunks)
💤 Files with no reviewable changes (3)
  • src/components/Patient/models.tsx
  • src/pages/Facility/FacilitiesPage.tsx
  • src/components/Facility/FacilityList.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/Patient/PatientFilter.tsx

[error] 1044-1044: Avoid passing children using a prop

The canonical way to pass children in React is to use JSX elements

(lint/correctness/noChildrenProp)

src/CAREUI/misc/SectionNavigator.tsx

[error] 61-72: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

src/components/Patient/PatientRegistration.tsx

[error] 533-536: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 537-537: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 555-555: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 571-571: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 749-749: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 780-780: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 815-815: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 848-848: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 873-873: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 911-911: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 929-929: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 953-953: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 954-954: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 977-977: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 978-978: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

src/components/Patient/ManagePatients.tsx

[error] 895-895: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🔇 Additional comments (19)
src/pages/Facility/FacilityDetailsPage.tsx (2)

20-20: Verify the FeatureBadge component implementation

The import looks correct, but let's ensure the component is properly implemented since it's being used for facility features display.

✅ Verification successful

Import and implementation of FeatureBadge is correct

The FeatureBadge component is properly implemented in Utils.tsx and correctly used in FacilityDetailsPage.tsx. It:

  • Has proper TypeScript typing with featureId prop
  • Uses the FACILITY_FEATURE_TYPES constant from common constants
  • Implements proper UI rendering with Badge component and styling
  • Is correctly imported and used with required props in FacilityDetailsPage
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the implementation of FeatureBadge component
ast-grep --pattern 'export const FeatureBadge = $_' src/pages/Facility/Utils.ts*

Length of output: 1838


Script:

#!/bin/bash
# Check if FeatureBadge is used in FacilityDetailsPage
ast-grep --pattern 'FeatureBadge' src/pages/Facility/FacilityDetailsPage.tsx

# Check for FACILITY_FEATURE_TYPES constant
ast-grep --pattern 'const FACILITY_FEATURE_TYPES = $_' src/pages/Facility/Utils.tsx

Length of output: 376


Script:

#!/bin/bash
# Let's check the FACILITY_FEATURE_TYPES with a broader pattern to catch possible variations
ast-grep --pattern 'FACILITY_FEATURE_TYPES' src/pages/Facility/Utils.tsx

# Also check for any type definitions related to facility features
ast-grep --pattern 'type $_FacilityFeature' src/pages/Facility/Utils.tsx

Length of output: 345


Line range hint 1-150: Verify integration with new Patient Search/Register UI

This facility details page seems tangential to the main PR objective of implementing a new patient search and registration UI. We should verify how this component integrates with the new patient flow.

src/components/Patient/PatientIndex.tsx (1)

100-122: Recommend clarifying input sanitation for dynamic query parameters.

The logic for searching phone numbers, name, and patient_no is robust at a glance. However, we recommend sanitizing input to handle potential edge cases at the boundaries (like partial or special-character inputs).

Would you like a deeper codebase scan to check whether these fields are validated or sanitized in downstream services?

src/components/Patient/PatientRegistration.tsx (1)

755-882: **** Switch to absolute imports.

A prior review comment had suggestions to use absolute imports consistently. This code segment mostly uses absolute imports (like "@/hooks/..."), but ensure consistency across all new lines.

🧰 Tools
🪛 Biome (1.9.4)

[error] 780-780: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 815-815: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 848-848: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 873-873: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

src/components/ui/errors.tsx (1)

1-11: Good approach to error rendering.

Using the InputErrors component is a clean way to handle validations without cluttering individual inputs. This approach is easily composable for various form fields.

src/components/Patient/Utils.ts (1)

21-37: ⚠️ Potential issue

Verify URL generation logic for edge cases

The URL generation logic needs additional validation to prevent potential issues:

  1. The function assumes patient.id exists but doesn't validate it
  2. There's no validation for patient.facility before using it in the URL
  3. The last_consultation check could be simplified

This might be related to the reported issue where "Patient creation with 20-digit number redirects correctly but shows 'undefined' on patient details page".

 export const getPatientUrl = (patient: PatientModel) => {
+  if (!patient?.id) {
+    throw new Error("Patient ID is required");
+  }
   let patientUrl = "";
   if (!isPatientMandatoryDataFilled(patient)) {
-    patientUrl = `/facility/${patient.facility}/patient/${patient.id}`;
+    patientUrl = patient.facility 
+      ? `/facility/${patient.facility}/patient/${patient.id}`
+      : `/patient/${patient.id}`;
   } else if (
     patient.last_consultation &&
     patient.last_consultation?.facility === patient.facility &&
     !(patient.last_consultation?.discharge_date && patient.is_active)
   ) {
     patientUrl = `/facility/${patient.facility}/patient/${patient.id}/consultation/${patient.last_consultation.id}`;
   } else if (patient.facility) {
     patientUrl = `/facility/${patient.facility}/patient/${patient.id}`;
   } else {
     patientUrl = `/patient/${patient.id}`;
   }
   return patientUrl;
 };

Let's verify the usage:

src/components/ui/input.tsx (2)

9-13: LGTM! Well-structured props interface.

The InputProps interface properly extends React's input props while adding type-safe label and errors properties.


28-30: LGTM! Clear error state handling.

The error state styling is well-implemented with clear visual feedback through border color changes.

src/components/ui/radio-group.tsx (1)

11-15: LGTM! Consistent props interface.

The props interface follows the same pattern as other form components, maintaining consistency across the UI library.

src/Routers/routes/PatientRoutes.tsx (1)

20-22: Verify route parameter changes.

The switch from PatientRegister to PatientRegistration includes parameter changes (idpatientId). Let's verify this change is consistent across the codebase.

Also applies to: 40-40

✅ Verification successful

Let me gather more specific information about the parameter usage.


Let me gather more focused information about the parameter usage.


Let me try a different search pattern to get the component definition and usage.


Based on the evidence gathered, I can now provide the final response:

Parameter changes are correctly implemented.

The codebase shows consistent usage of parameters:

  • The PatientRegistration component accepts facilityId and optional patientId as defined in its interface
  • All usages in routes follow this pattern:
    • New patient route: facilityId only
    • Update route: both facilityId and patientId (mapped from route param id)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to PatientRegister and old parameter patterns
rg -l 'PatientRegister|patientId.*PatientRegistration'

# Search for potential parameter mismatches in component usage
ast-grep --pattern 'PatientRegistration facilityId={$_} patientId={$_}'

Length of output: 413


Script:

#!/bin/bash
# Check the actual props interface and usage in PatientRegistration
rg -A 5 "interface.*PatientRegistration" src/components/Patient/PatientRegistration.tsx

# Look for actual usage patterns of PatientRegistration
rg -B 2 -A 2 "<PatientRegistration"

# Check if there are any remaining PatientRegister component definitions
ast-grep --pattern 'const PatientRegister = $_'

Length of output: 67855


Script:

#!/bin/bash
# Check the actual component props and usage in PatientRegistration
rg -B 2 -A 2 "PatientRegistration.*=.*{" src/components/Patient/PatientRegistration.tsx

# Look for any references to old parameter names
rg "id.*PatientRegistration|patientId.*PatientRegistration" src/components/Patient/PatientRegistration.tsx src/Routers/routes/PatientRoutes.tsx

Length of output: 349


Script:

#!/bin/bash
# Check the component definition and interface
rg "interface.*PatientRegistration|export.*function.*PatientRegistration" src/components/Patient/PatientRegistration.tsx

# Look for actual usage of PatientRegistration component with parameters
rg -B 1 -A 1 "<PatientRegistration.*?>" -U --multiline

Length of output: 757

src/components/Common/Breadcrumbs.tsx (1)

112-112: LGTM: Padding adjustment improves visual alignment

The padding reduction from p-1 to p-0 helps align the Home link with other navigation elements.

src/components/ui/select.tsx (2)

11-12: LGTM: Good separation of concerns

The imports for error and label components are appropriately separated, following the component-based architecture.


22-26: LGTM: Well-typed props interface

The new props are properly typed and optional, following TypeScript best practices.

package.json (1)

61-61: Verify compatibility with i18next-browser-languagedetector downgrade

While the Radix UI updates are minor version bumps, the downgrade of i18next-browser-languagedetector from 8.0.2 to 8.0.0 requires verification.

Also applies to: 67-67, 96-96

✅ Verification successful

Downgrade of i18next-browser-languagedetector is safe

The codebase uses basic language detection functionality through a simple import, and the downgrade from 8.0.2 to 8.0.0 within the same major version is safe as:

  • The usage pattern is straightforward with no complex configurations
  • Both versions are compatible with the current i18next v23.16.4
  • No breaking changes exist between 8.0.0 and 8.0.2 as they are patch versions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes in i18next-browser-languagedetector

# Search for usage patterns that might be affected by the downgrade
rg -l "languageDetector|i18next.*detect" 

# Check package.json in node_modules for peer dependency conflicts
cat node_modules/i18next-browser-languagedetector/package.json | jq '.peerDependencies'

Length of output: 317


Script:

#!/bin/bash
# Let's check the actual usage of the language detector in the codebase
rg -A 5 "languageDetector|i18next.*detect" src/i18n.ts

# Also check the current version of i18next being used
cat package.json | jq '.dependencies["i18next"]'

Length of output: 346

src/components/Common/SearchByMultipleFields.tsx (1)

245-245: LGTM: Improved keyboard shortcut display

Using option.shortcutKey directly is more maintainable than deriving it from the label.

src/hooks/useFilters.tsx (1)

212-212: LGTM! UI spacing adjustment

The removal of mt-6 class helps maintain consistent spacing in the filter badges container.

public/locale/en.json (3)

338-339: Clear and informative age input warning messages.

The warning messages effectively communicate:

  1. That age input is optional
  2. Only year of birth will be captured
  3. When age input is recommended (when DOB is unknown)

835-835: Well-structured section descriptions for patient registration form.

The descriptions for each section (general info, insurance details, social profile, etc.) provide clear guidance to users about the information needed and its purpose.

Also applies to: 900-900, 954-954, 1455-1455, 1652-1652


1587-1587: Clear checkbox label texts for address and phone number reuse.

The checkbox labels are clear and unambiguous:

  • "Use this address for permanent address"
  • "Use this phone number for emergency contact"

Also applies to: 1589-1589

src/components/Patient/PatientIndex.tsx Outdated Show resolved Hide resolved
src/components/Patient/PatientIndex.tsx Show resolved Hide resolved
src/components/Patient/PatientFilter.tsx Show resolved Hide resolved
src/components/Patient/PatientRegistration.tsx Outdated Show resolved Hide resolved
src/Routers/routes/PatientRoutes.tsx Show resolved Hide resolved
src/CAREUI/misc/SectionNavigator.tsx Outdated Show resolved Hide resolved
src/components/ui/tabs.tsx Show resolved Hide resolved
src/components/Patient/ManagePatients.tsx Show resolved Hide resolved
public/locale/en.json Outdated Show resolved Hide resolved
Copy link
Member

@bodhish bodhish left a comment

Choose a reason for hiding this comment

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

package.json Show resolved Hide resolved
@@ -64,7 +64,7 @@
"DOMESTIC_HEALTHCARE_SUPPORT__PAID_CAREGIVER": "Paid caregiver",
"GENDER__1": "Male",
"GENDER__2": "Female",
"GENDER__3": "Non-binary",
"GENDER__3": "Transgender",
Copy link
Member

Choose a reason for hiding this comment

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

Lets be in sync with the BE

src/Routers/routes/PatientRoutes.tsx Show resolved Hide resolved
src/Routers/routes/PatientRoutes.tsx Show resolved Hide resolved
src/Utils/utils.ts Show resolved Hide resolved
Comment on lines +825 to +855
<Select
{...selectProps("local_body")}
onValueChange={(value) =>
setForm((f) => ({
...f,
local_body: Number(value),
ward: undefined,
}))
}
disabled={
!form.district ||
localBodyQuery.isLoading ||
!localBodyQuery.data?.length
}
>
<SelectTrigger
label={t("local_body")}
required
errors={errors["local_body"]}
className="w-full"
>
<SelectValue />
</SelectTrigger>
<SelectContent>
{localBodyQuery.data?.map((localbody) => (
<SelectItem value={localbody.id.toString()}>
{localbody.name}
</SelectItem>
))}
</SelectContent>
</Select>
Copy link
Member

Choose a reason for hiding this comment

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

image All of these should be a search select, its really hard to find something from this large list.

!!duplicatePatients?.length &&
!!parsePhoneNumber(debouncedNumber || "") &&
!suppressDuplicateWarning && (
<DuplicatePatientDialog
Copy link
Member

Choose a reason for hiding this comment

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

image Since we are updating it, why not change it to use shadcn buttons. would look prittier.

@@ -4,24 +4,38 @@ import * as React from "react";

import { cn } from "@/lib/utils";

import { Label } from "./label";
Copy link
Member

Choose a reason for hiding this comment

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

We should not be updating ShadCN components. If we want a different version that clubs both, we make a component.

It will be painfull to upgrade at a later stage if we keep editing shadcn components.

@@ -2,18 +2,39 @@ import * as React from "react";

import { cn } from "@/lib/utils";

const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
({ className, type, ...props }, ref) => {
import { Label } from "@/components/ui/label";
Copy link
Member

Choose a reason for hiding this comment

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

Lets not extend input, maybe make a InputWithLabel 🤔

@@ -50,4 +50,50 @@ const TabsContent = React.forwardRef<
));
TabsContent.displayName = TabsPrimitive.Content.displayName;

export { Tabs, TabsList, TabsTrigger, TabsContent };
interface SectionTabsProps {
Copy link
Member

Choose a reason for hiding this comment

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

Lets not exapnd Shadcn components

Copy link

Reminder: To add the "needs testing" label, comment "ready for testing" on this PR.

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 20, 2024
Copy link

👋 Hi, @shivankacker,
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.

@bodhish
Copy link
Member

bodhish commented Dec 20, 2024

@shivankacker can you update the status here

@shivankacker
Copy link
Member Author

@bodhish working on converting Scribe to support microfrontends. I will take this up after it. Or whatever is in more priority 😅

@bodhish
Copy link
Member

bodhish commented Dec 20, 2024

I would say wrap this 👆, just minor
Changes required

Cc @gigincg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes required merge conflict pull requests with merge conflict needs review
Projects
Status: Review required
Development

Successfully merging this pull request may close these issues.

7 participants