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

Allergy intolerance Cleanup #9812

Merged
merged 5 commits into from
Jan 7, 2025
Merged

Allergy intolerance Cleanup #9812

merged 5 commits into from
Jan 7, 2025

Conversation

amjithtitus09
Copy link
Contributor

@amjithtitus09 amjithtitus09 commented Jan 7, 2025

Proposed Changes

  • Allergy Intolerance prefill with update existing rows
  • Request cleanup and change to upsert
  • Move status to action and style w.r.t status
  • Wrap UI in mobile
  • Allergy list in encounter overview

@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

    • Added patientId to multiple components for enhanced patient-specific data handling.
    • Improved allergy management with more flexible data fetching and request handling.
    • Introduced AllergyList component in the EncounterUpdatesTab for displaying allergy information.
  • Bug Fixes

    • Updated type definitions for allergy-related interfaces to ensure data consistency.
    • Simplified request generation for allergy intolerance data.
  • Refactor

    • Removed StructuredResponseView component.
    • Modified questionnaire and allergy-related components to streamline data processing.
    • Streamlined QuestionnaireResponsesList component by removing unnecessary state management.

@amjithtitus09 amjithtitus09 requested a review from a team as a code owner January 7, 2025 05:45
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces significant changes across various components related to patient questionnaires and allergy management. Key modifications include the removal of state management in the QuestionnaireResponsesList, the addition of patientId as a required prop in several components, and the restructuring of allergy-related interfaces to improve data handling. The changes streamline the logic for rendering questionnaire responses, enhance the flexibility of the allergy list component, and consolidate request structures for allergy data, ensuring a more efficient and consistent approach to managing patient-specific information.

Changes

File Change Summary
src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx Removed state management for expanded responses, simplified rendering logic.
src/components/Facility/ConsultationDetails/StructuredResponseView.tsx Deleted component for displaying structured responses.
src/components/Patient/allergy/list.tsx Added optional encounterId to AllergyList component.
src/components/Questionnaire/QuestionRenderer.tsx Added patientId as a required prop.
src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx Significant updates to allergy handling, data fetching, and type transformations.
src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx Added patientId as a required prop.
src/components/Questionnaire/QuestionTypes/QuestionInput.tsx Added patientId to props and integrated into existing logic.
src/components/Questionnaire/QuestionnaireForm.tsx Added patientId prop to QuestionRenderer component.
src/components/Questionnaire/structured/handlers.ts Modified getRequests for allergy intolerance to use a consolidated request structure.
src/components/Questionnaire/structured/types.ts Updated types for allergy data structures.
src/types/emr/allergyIntolerance/allergyIntolerance.ts Made several allergy-related properties required, added id to interfaces.
src/types/questionnaire/form.ts Updated type definitions for ResponseValue to use AllergyIntoleranceRequest.
src/pages/Encounters/tabs/EncounterUpdatesTab.tsx Added AllergyList component to display allergy information.

Suggested labels

needs review, tested, P1

Suggested reviewers

  • rithviknishad
  • bodhish

Poem

🐰 Hop, hop, through code so bright,
Allergies dancing left and right,
Patient data now complete,
Types aligned, oh what a treat!
CodeRabbit's magic takes its flight! 🌟

Possibly related PRs


📜 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 f8abf20 and 5042e48.

📒 Files selected for processing (2)
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (4 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx

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 Jan 7, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 5042e48
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677cd7ac792958000891fe48
😎 Deploy Preview https://deploy-preview-9812--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

cypress bot commented Jan 7, 2025

CARE    Run #4178

Run Properties:  status check failed Failed #4178  •  git commit 5042e48430: Allergy intolerance Cleanup
Project CARE
Branch Review allergy-intolerance-prefill
Run status status check failed Failed #4178
Run duration 01m 46s
Commit git commit 5042e48430: Allergy intolerance Cleanup
Committer Amjith Titus
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 3
View all changes introduced in this branch ↗︎

Tests for review

Failed  cypress/e2e/patient_spec/patient_search.cy.ts • 1 failed test

View Output

Test Artifacts
Patient Search > search patient with phone number and verifies details Test Replay Screenshots

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

🧹 Nitpick comments (7)
src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx (3)

124-146: Optimize useEffect dependency array to prevent unnecessary re-renders

The useEffect hook at lines 124-146 includes questionnaireResponse and updateQuestionnaireResponseCB in its dependency array. Since updateQuestionnaireResponseCB might change on every render if not memoized, this could cause unnecessary re-renders or an infinite loop. Consider memoizing updateQuestionnaireResponseCB using useCallback or adjusting the dependency array to include only necessary dependencies.


223-231: Simplify nested ternary operators for better readability

The nested ternary operator used in the className prop at lines 223-231 can be hard to read and maintain. Consider refactoring it using a helper function or an object mapping to improve readability and maintainability.

Apply this refactor to simplify the className:

-  className={`p-3 space-y-3 ${
-    allergy.clinical_status === "inactive"
-      ? "opacity-60"
-      : allergy.clinical_status === "resolved"
-        ? "line-through"
-        : ""
-  }`}
+  className={`p-3 space-y-3 ${statusClassNames[allergy.clinical_status] || ""}`}

Define the statusClassNames mapping:

const statusClassNames = {
  inactive: "opacity-60",
  resolved: "line-through",
};

284-319: Reduce code duplication in DropdownMenuItems for status updates

The DropdownMenuItems for changing the clinical_status at lines 284-319 have similar structures. Consider mapping over an array of status options to generate these items dynamically, reducing code duplication and enhancing maintainability.

Here's how you can refactor the code:

const statusOptions = [
  {
    status: "active",
    label: "Mark Active",
    icon: <CheckCircledIcon className="h-4 w-4 mr-2" />,
  },
  {
    status: "inactive",
    label: "Mark Inactive",
    icon: <CircleBackslashIcon className="h-4 w-4 mr-2" />,
  },
  {
    status: "resolved",
    label: "Mark Resolved",
    icon: <CheckCircledIcon className="h-4 w-4 mr-2 text-green-600" />,
  },
];

{statusOptions
  .filter((option) => allergy.clinical_status !== option.status)
  .map((option) => (
    <DropdownMenuItem
      key={option.status}
      onClick={() => handleUpdateAllergy(index, { clinical_status: option.status })}
    >
      {option.icon}
      {option.label}
    </DropdownMenuItem>
  ))}
src/components/Questionnaire/structured/handlers.ts (1)

30-44: LGTM! Consistent implementation with other handlers.

The refactoring of the allergy_intolerance handler to use an upsert endpoint follows the same pattern as other handlers in the file, improving consistency and maintainability.

Consider adding request batching or rate limiting if handling large numbers of allergies to prevent server overload.

src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (1)

38-38: Consider using TypeScript strict mode for better type safety.

The addition of patientId prop is well-implemented. However, consider enabling TypeScript's strict mode to ensure type safety across all props, especially for the structured question types.

Add strict type checking by updating your tsconfig.json:

{
  "compilerOptions": {
+   "strict": true,
+   "noImplicitAny": true,
+   "strictNullChecks": true
  }
}

Also applies to: 50-50, 86-86

src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx (2)

188-204: Add ARIA labels for better accessibility.

The conditional rendering for created/updated status is well-implemented, but the nested spans could benefit from ARIA labels for screen readers.

Add ARIA labels to improve accessibility:

-<span className="mt-0.5 text-xs text-muted-foreground">
+<span 
+  className="mt-0.5 text-xs text-muted-foreground"
+  aria-label={`Response ${Object.values(item.structured_responses ?? {})[0]?.submit_type === "CREATE" ? "created" : "updated"} by ${item.created_by?.first_name || ""}`}
+>

211-244: Optimize rendering performance for large questionnaires.

The nested mapping of questionnaire questions could impact performance with large datasets. Consider memoizing the question components or implementing virtualization for better performance.

Consider using react-window or react-virtualized for handling large lists:

+import { FixedSizeList } from 'react-window';
+
 {item.questionnaire?.questions.map(
   (question: Question) => {
+    const QuestionComponent = React.memo(({ question, response }) => {
       if (question.type === "structured") return null;
       // ... rest of the rendering logic
+    });
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b60e720 and b3c1b78.

📒 Files selected for processing (13)
  • src/components/Facility/ConsultationDetails/QuestionnaireResponsesList.tsx (1 hunks)
  • src/components/Facility/ConsultationDetails/StructuredResponseView.tsx (0 hunks)
  • src/components/Patient/allergy/list.tsx (1 hunks)
  • src/components/Questionnaire/QuestionRenderer.tsx (3 hunks)
  • src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx (11 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (4 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (3 hunks)
  • src/components/Questionnaire/QuestionnaireForm.tsx (1 hunks)
  • src/components/Questionnaire/structured/handlers.ts (1 hunks)
  • src/components/Questionnaire/structured/types.ts (3 hunks)
  • src/pages/Encounters/tabs/EncounterUpdatesTab.tsx (2 hunks)
  • src/types/emr/allergyIntolerance/allergyIntolerance.ts (2 hunks)
  • src/types/questionnaire/form.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Facility/ConsultationDetails/StructuredResponseView.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages: care-fe
🔇 Additional comments (12)
src/types/emr/allergyIntolerance/allergyIntolerance.ts (2)

20-22: Verify the inclusion of id in AllergyIntoleranceRequest

An optional id has been added to the AllergyIntoleranceRequest interface at line 22. Ensure that the backend API supports receiving an id in the request payload. Including an id in create or update requests might have implications on how the server processes these requests.

Would you like me to check the API documentation or existing API calls to confirm whether including id in the request is appropriate?


6-11: 🛠️ Refactor suggestion

Ensure required properties are handled throughout the application

Properties clinical_status, verification_status, category, and criticality are now required in the AllergyIntolerance interface (lines 6-11). Ensure that all instances where AllergyIntolerance is instantiated or used are updated to include these required properties to prevent TypeScript errors or runtime issues.

To verify instances where these properties might be missing, consider running:

✅ Verification successful

Required properties are properly handled throughout the application

The codebase correctly implements the required properties of AllergyIntolerance. The only instances of partial objects are intentionally typed as Partial<AllergyIntoleranceRequest> in form handling components, which is a common and acceptable pattern for managing form state.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find instances where AllergyIntolerance is used without required properties.

# Search for object literals typed as AllergyIntolerance missing required properties.
ast-grep --lang typescript --pattern 'const $ID: AllergyIntolerance = {$$$}' --json | jq '.[] | select(.matched.node.fields | length < 5)'

Length of output: 140


Script:

#!/bin/bash
# Find files importing or using AllergyIntolerance
echo "=== Files referencing AllergyIntolerance ==="
rg -l "AllergyIntolerance"

echo -e "\n=== Object literal assignments ==="
# Look for object assignments that might be AllergyIntolerance
ast-grep --pattern '{
  id: $_,
  code: $_,
  $$$
}'

echo -e "\n=== Partial type usage ==="
# Check for partial type usage
rg "Pick<.*AllergyIntolerance|Omit<.*AllergyIntolerance|Partial<.*AllergyIntolerance"

Length of output: 2205

src/types/questionnaire/form.ts (1)

Line range hint 3-32: Assess impact of changing ResponseValue to use AllergyIntoleranceRequest

The ResponseValue type now uses AllergyIntoleranceRequest[] instead of AllergyIntolerance[] (lines 3 and 32). Ensure that all functions and components that consume ResponseValue are updated to handle AllergyIntoleranceRequest appropriately. This change may affect data processing, validation, and API interactions elsewhere in the application.

Consider verifying the usage of ResponseValue throughout the codebase:

src/components/Questionnaire/structured/types.ts (2)

6-6: LGTM! Consistent use of request types

The change to use AllergyIntoleranceRequest consistently improves type safety and aligns with the PR's cleanup objectives.

Also applies to: 16-16


27-27: Verify the impact of the new array structure

The change to wrap AllergyIntoleranceRequest in a datapoints array suggests support for multiple allergy records. This is a good improvement for data handling.

Let's verify that all consumers handle this new structure correctly:

✅ Verification successful

Array structure change is properly supported

The codebase already handles multiple allergy records consistently:

  • AllergyQuestion component manages arrays of allergies
  • API handlers process multiple records
  • Existing type usage aligns with the new array structure
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for direct usage of allergy_intolerance property
rg "allergy_intolerance\." -A 3

Length of output: 33


Script:

#!/bin/bash
# Search for AllergyIntoleranceRequest type usage
ast-grep --pattern 'AllergyIntoleranceRequest'

# Search for allergy_intolerance property without dot notation
rg "allergy_intolerance" -B 2 -A 2

# Search for possible destructuring patterns
rg "\{.*allergy_intolerance.*\}" -B 2 -A 2

Length of output: 8651

src/pages/Encounters/tabs/EncounterUpdatesTab.tsx (2)

3-3: LGTM! Consistent import pattern

The import follows the established pattern used for other list components.


19-22: LGTM! Well-structured UI addition

The Allergies section is appropriately placed before symptoms, following a logical medical assessment flow. The implementation maintains consistency with other list components.

src/components/Questionnaire/QuestionRenderer.tsx (2)

19-19: LGTM! Proper prop threading

The addition of the required patientId prop and its propagation to child components ensures proper data handling for patient-specific allergy information.

Also applies to: 32-32


75-75: LGTM! Consistent prop passing

The patientId prop is correctly passed to the QuestionGroup component.

src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (1)

23-23: LGTM! Complete prop threading implementation

The patientId prop is properly threaded through all necessary components:

  1. Added to the props interface
  2. Included in the component parameters
  3. Passed to QuestionInput
  4. Passed to nested QuestionGroup components

This ensures consistent access to patient data throughout the questionnaire hierarchy.

Also applies to: 87-87, 106-106, 151-151

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

23-23: LGTM! Consider adding error handling for invalid encounterId.

The addition of the optional encounterId prop and its integration with the query parameters is well-implemented. However, consider adding validation or error handling for cases where an invalid encounterId is provided.

Run this script to check for proper error handling in similar components:

Also applies to: 26-26, 28-28, 31-31

src/components/Questionnaire/QuestionnaireForm.tsx (1)

353-353: LGTM! Verify prop usage in child components.

The addition of patientId prop to QuestionRenderer aligns with the PR objectives for allergy intolerance cleanup. The prop is properly typed and consistently used throughout the component.

Let's verify the prop usage in child components:

✅ Verification successful

Prop drilling chain verified successfully

The patientId prop is properly passed down through the component hierarchy:

  • QuestionnaireForm → QuestionRenderer → QuestionGroup → QuestionInput
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that QuestionRenderer and its child components properly handle the patientId prop

# Check QuestionRenderer's prop types and usage
ast-grep --pattern 'interface QuestionRendererProps {
  $$$
  patientId: string;
  $$$
}'

# Check for potential prop drilling to child components
rg -A 5 'patientId={' src/components/Questionnaire/

Length of output: 1227


Script:

#!/bin/bash
# Find how patientId is used in QuestionRenderer
ast-grep --pattern 'const QuestionRenderer = ({ $$$, patientId, $$$ }: QuestionRendererProps) => {
  $$$
}'

# Check for patientId prop drilling with escaped braces
rg -A 5 'patientId=\{' src/components/Questionnaire/

# Find any components that might be receiving patientId
ast-grep --pattern '<$_
  $$$
  patientId={patientId}
  $$$
/>'

Length of output: 14630

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Jan 7, 2025
Copy link

github-actions bot commented Jan 7, 2025

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

Copy link

cloudflare-workers-and-pages bot commented Jan 7, 2025

Deploying care-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5042e48
Status: ✅  Deploy successful!
Preview URL: https://e8739e95.care-fe.pages.dev
Branch Preview URL: https://allergy-intolerance-prefill.care-fe.pages.dev

View logs

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Jan 7, 2025
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 (5)
src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx (5)

59-59: Add runtime validation for the required patientId prop.

Since patientId is a required prop that's crucial for fetching patient allergies, consider adding runtime validation to catch potential issues early.

+ import { z } from "zod";

  interface AllergyQuestionProps {
-   patientId: string;
+   patientId: z.string().min(1).parse(string);
    question: Question;
    // ...
  }

90-104: Enhance type safety of the conversion function.

Consider using TypeScript's Pick utility type to ensure the conversion function includes all required fields.

- function convertToAllergyRequest(
-   allergy: AllergyIntolerance,
- ): AllergyIntoleranceRequest {
+ function convertToAllergyRequest(
+   allergy: AllergyIntolerance,
+ ): Pick<AllergyIntoleranceRequest, 
+   'id' | 'code' | 'clinical_status' | 'verification_status' | 
+   'category' | 'criticality' | 'last_occurrence' | 'note' | 'encounter'
+ > {
    return {
      id: allergy.id,
      // ...
    };
  }

124-146: Optimize useEffect dependencies.

The dependency array includes the entire questionnaireResponse object, which could cause unnecessary re-renders. Consider using only the required properties.

  useEffect(() => {
    if (patientAllergies?.results && !allergies.length) {
      updateQuestionnaireResponseCB({
        ...questionnaireResponse,
        values: [
          {
            type: "allergy_intolerance",
            value: patientAllergies.results.map(convertToAllergyRequest),
          },
        ],
      });
      // ...
    }
-  }, [patientAllergies, allergies.length, questionnaireResponse, updateQuestionnaireResponseCB]);
+  }, [patientAllergies, allergies.length, updateQuestionnaireResponseCB]);

220-412: Enhance mobile view accessibility.

The mobile view implementation could benefit from improved accessibility features.

  1. Add ARIA labels to interactive elements
  2. Ensure proper heading hierarchy
  3. Add screen reader descriptions for status changes
  <div className="md:hidden divide-y divide-gray-200">
    {allergies.map((allergy, index) => (
      <div
        key={index}
+       role="region"
+       aria-label={`Allergy information for ${allergy.code.display}`}
        className={`p-3 space-y-3 ${
          // ...
        }`}
      >

Line range hint 424-605: Consider splitting AllergyTableRow into smaller components.

The component handles multiple responsibilities including rendering and state management. Consider breaking it down into smaller, more focused components for better maintainability.

Example structure:

const AllergyStatus = ({ status, onUpdate, disabled }) => {
  // Handle status-related rendering and updates
};

const AllergyNotes = ({ notes, onUpdate, disabled }) => {
  // Handle notes-related rendering and updates
};

const AllergyCriticality = ({ criticality, onUpdate, disabled }) => {
  // Handle criticality-related rendering and updates
};

const AllergyTableRow = ({ allergy, disabled, onUpdate, onRemove }) => {
  // Main component with reduced complexity
};
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b3c1b78 and f8abf20.

📒 Files selected for processing (3)
  • src/components/Questionnaire/QuestionTypes/AllergyQuestion.tsx (11 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (4 hunks)
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx
  • src/components/Questionnaire/QuestionTypes/QuestionInput.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages: care-fe

Comment on lines +193 to +194
? "Created"
: "Updated"}{" "}
Copy link
Member

Choose a reason for hiding this comment

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

i18n


{allergy.note !== undefined && (
<div>
<Label className="text-xs text-gray-500">Notes</Label>
Copy link
Member

Choose a reason for hiding this comment

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

i18n for this file missing

@bodhish bodhish merged commit bd8ac7e into develop Jan 7, 2025
22 of 24 checks passed
@bodhish bodhish deleted the allergy-intolerance-prefill branch January 7, 2025 13:08
Copy link

github-actions bot commented Jan 7, 2025

@amjithtitus09 Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

arhamathar pushed a commit to arhamathar/care_fe that referenced this pull request Jan 8, 2025
khavinshankar pushed a commit that referenced this pull request Jan 8, 2025
nihal467 added a commit that referenced this pull request Jan 13, 2025
* added patient home actions plugin hook

* expose core app env in global scope

* enable heatmap and fix appointments column size (#9713)

* Fix: Forgot password error should be handled properly  (#9707)

* forgot password mutation

* updated

* Added no user assingned message (#9666)

Co-authored-by: Rithvik Nishad <rithvikn2001@gmail.com>

* Remove facility name from facility users page (#9746)

* Enhance organization management by adding new organization types and updating related components. Refactor organization level retrieval to use metadata for improved localization. Remove deprecated organization levels constant and clean up unused code in various components.

* Cancel button fix in Book Appointment screen (#9757)

* Add public flag to facility (#9759)

* Auto-Hide Sidebar on mobile (#9758)

* Implement Permission Context and Update User Permissions Handling

- Introduced a new PermissionContext to manage user permissions and super admin status across the application.
- Updated AppRouter to utilize PermissionProvider for managing permissions.
- Changed UserModel to store permissions as strings instead of objects.
- Refactored OrganizationFacilities and OrganizationPatients components to use updated permission checks and organization identifiers.
- Enhanced OrganizationLayout to conditionally render navigation items based on user permissions.

This commit improves the permission management system and ensures consistent handling of user permissions throughout the application.

* Replaced ButtonV2's with Button in entire codebase (#9736)

* fixes overlapping text (#9767)

* Care Loading icon in organization and facility users (#9723)

* Clean up facility search in index

* Add searchPostFix prop to ValueSetSelect and related components

- Introduced a new `searchPostFix` prop in `ValueSetSelect` to allow appending a suffix to the search query.
- Updated `MedicationRequestQuestion` and `MedicationStatementQuestion` components to utilize the `searchPostFix` prop with a default value of " clinical drug".
- This change enhances search functionality by providing more context in search queries.

* Clean up patient login

* Fix cancel button in update encounter form (#9772)

* disabled image build and deploy for care stagin (#9779)

* Bump @tanstack/react-query-devtools from 5.62.11 to 5.62.15 (#9785)

Bumps [@tanstack/react-query-devtools](https://github.com/TanStack/query/tree/HEAD/packages/react-query-devtools) from 5.62.11 to 5.62.15.
- [Release notes](https://github.com/TanStack/query/releases)
- [Commits](https://github.com/TanStack/query/commits/HEAD/packages/react-query-devtools)

---
updated-dependencies:
- dependency-name: "@tanstack/react-query-devtools"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Patient encounter notes (#9617)

Co-authored-by: Bodhisha Thomas <bodhi@Bodhishas-MacBook-Air.local>
Co-authored-by: Bodhish Thomas <bodhish@gmail.com>

* Fix Auto hide without hook (#9780)

* Enhance encounter data handling by adding encounterId prop across multiple components (#9793)

* Disable encounter create during save (#9795)

* Enhance encounter data handling by adding encounterId prop across multiple components

- Added `encounterId` prop to `ObservationChart`, `ObservationHistoryTable`, `ObservationsList`, `QuestionnaireResponsesList`, and `StructuredResponseView` components to improve data fetching and display related to specific encounters.
- Updated query parameters in API calls to include `encounterId` for better data context.
- Refactored `EncounterPlotsTab` and `EncounterUpdatesTab` to pass the new `encounterId` prop, ensuring consistent data handling across the application.

This change improves the overall functionality and user experience by ensuring that encounter-specific data is accurately retrieved and displayed.

* fix: disable encounter create button during save to prevent multiple submissions #9794

* Refactor PatientHome and EncounterShow components; update FacilityOrganizationSelector labels

- Removed unused state and commented-out code in PatientHome for improved readability.
- Enhanced patient data display by updating the last updated and created by fields to use `updated_by` instead of `modified_by`.
- Updated date formatting functions to ensure consistent display of patient and encounter dates.
- Changed labels in FacilityOrganizationSelector from "Organization" to "Select Department" and adjusted related text for clarity.

These changes streamline the codebase and improve user interface clarity.

* Partial Cleanup Public Router | Public Pages Header

* Rewire enableWhen

* Remove localStorage watch from AuthUserProvider

* Implement immediate redirection after successful login

* Fix: Update the value to Home Health in Create Encounter Form (#9806)

* Update Questionnaire Styling

* Update Questionnaire Styling

* Update Auth Handling

* Cleanup Patient Auth State

* Handle Null created_by

* Types for null patient.created_by

* Bump i18next from 24.2.0 to 24.2.1 (#9818)

Bumps [i18next](https://github.com/i18next/i18next) from 24.2.0 to 24.2.1.
- [Release notes](https://github.com/i18next/i18next/releases)
- [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
- [Commits](i18next/i18next@v24.2.0...v24.2.1)

---
updated-dependencies:
- dependency-name: i18next
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump input-otp from 1.4.1 to 1.4.2 (#9819)

Bumps [input-otp](https://github.com/guilhermerodz/input-otp/tree/HEAD/packages/input-otp) from 1.4.1 to 1.4.2.
- [Changelog](https://github.com/guilhermerodz/input-otp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/guilhermerodz/input-otp/commits/HEAD/packages/input-otp)

---
updated-dependencies:
- dependency-name: input-otp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Rename dosage field to frequency in ongoing medication form (#9811)

* feat: Add new fields to Question interface (#9824)

* Cleanup Labels in Questionnaire

* Allergy intolerance Cleanup (#9812)

* cleanup CarePatientTokenKey (#9827)

* changed the facility name (#9829)

* Cleanup localStorage Management in Patient Login; Fix Time in Confirmation

* Use PatientContext from Router when required

* Cleanup Navbars

* AllergyList: Add i18n; map key

* Add Actions in Encounter

* Remove Shortcut for Nursing Care

* Update Crowdin configuration file

* Update Crowdin configuration file

* Fix: Replace InputWithError and InputErrors components with ShadCN’s components directly. (#9847)

* fixed eslint errors caused while creating plugin map

* refactored the patient registration form using react hook form

* added patient registration form plugin hook

* updated validations

* added patient info card actions plugin hook

* set same_phone_number to true by default in patient registration

* set same_address to true and same_phone_number to false by default in patient registration

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
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.

3 participants