-
Notifications
You must be signed in to change notification settings - Fork 627
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
Patient Questionnaire: Org Access #10988
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces new localization keys and a new route to enhance questionnaire functionality. It updates several components by making the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (7)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (1)
104-115
: 💡 Verification agent🧩 Analysis chain
Verify that QuestionInput component handles optional facilityId
The
QuestionGroup
component passes the potentially undefinedfacilityId
toQuestionInput
. Ensure thatQuestionInput
has also been updated to handle an optionalfacilityId
.
🏁 Script executed:
#!/bin/bash # Check if QuestionInput has been updated to handle optional facilityId # Check the QuestionInput interface definition rg -A 10 "interface QuestionInputProps" "src/components/Questionnaire/QuestionTypes/QuestionInput.tsx" # Check for any direct usage of facilityId without optional chaining or checks rg "facilityId\." "src/components/Questionnaire/QuestionTypes/QuestionInput.tsx"Length of output: 494
Action Required: Update QuestionInput to Handle Optional facilityId
- The
QuestionGroup
passes afacilityId
prop which is potentially undefined, but theQuestionInput
props (as defined insrc/components/Questionnaire/QuestionTypes/QuestionInput.tsx
) do not include afacilityId
property.- Please update the
QuestionInputProps
interface to include an optionalfacilityId
(e.g.,facilityId?: string
) and ensure that any internal usage withinQuestionInput
safely handles cases where it might be undefined.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
public/locale/en.json
(2 hunks)src/Routers/routes/ConsultationRoutes.tsx
(1 hunks)src/components/Patient/EncounterQuestionnaire.tsx
(3 hunks)src/components/Patient/PatientDetailsTab/patientUpdates.tsx
(2 hunks)src/components/Questionnaire/QuestionRenderer.tsx
(1 hunks)src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx
(1 hunks)src/components/Questionnaire/QuestionTypes/QuestionInput.tsx
(8 hunks)src/components/Questionnaire/QuestionnaireForm.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: cypress-run (1)
🔇 Additional comments (16)
src/Routers/routes/ConsultationRoutes.tsx (1)
90-92
: New route successfully implements organization access to patient questionnaireThis new route allows direct access to a patient's questionnaire by only providing the patient ID, without requiring a facility ID. This aligns perfectly with the PR objective of enabling organizational roles (like volunteers) to submit questionnaires on behalf of patients.
src/components/Questionnaire/QuestionnaireForm.tsx (2)
59-59
: Good change: Making facilityId optional improves component flexibilityMaking the
facilityId
property optional is a necessary change to support the new organization access route where a facility ID may not be available.
266-266
:✅ Verification successful
Verify potential issue with undefined facilityId in context object
When
facilityId
is made optional, we need to ensure the code handles the case when it's undefined. On line 266, you're creating a context object withfacilityId
without checking if it exists. While this might work (as undefined values in objects are valid), it could lead to unexpected behavior in the structured data requests if they expectfacilityId
to be defined.
🏁 Script executed:
#!/bin/bash # Check how structured data requests handle undefined facilityId # Look for usage of facilityId in structured request handlers rg -A 5 "facilityId" "src/components/Questionnaire/structured/handlers.ts" # Check for existence of null/undefined checks in the getStructuredRequests function rg -A 10 "getStructuredRequests" "src/components/Questionnaire/structured/handlers.ts"Length of output: 1334
Review Verification: facilityId Handling Confirmed
The context object inQuestionnaireForm.tsx
(line 266) passesfacilityId
without an explicit check, but downstream code insrc/components/Questionnaire/structured/handlers.ts
properly validates it. ThegetRequests
function checks for a falsyfacilityId
and throws an error ("Cannot create encounter without a facility") if it is missing. This confirms that the current implementation is intentional and correctly prevents unexpected behavior from an undefinedfacilityId
.src/components/Questionnaire/QuestionRenderer.tsx (1)
32-32
: Making facilityId optional maintains consistency with parent componentsMaking the
facilityId
property optional inQuestionRendererProps
is consistent with the changes made to other components in the questionnaire flow. This allows the component to be used in contexts where a facility ID is not available, such as when accessed from an organization route.src/components/Questionnaire/QuestionTypes/QuestionGroup.tsx (1)
29-29
: Making facilityId optional maintains consistency across component hierarchyMaking the
facilityId
property optional inQuestionGroupProps
is consistent with changes to parent components. This ensures that the entire questionnaire component hierarchy can handle cases where a facility ID is not provided.src/components/Patient/PatientDetailsTab/patientUpdates.tsx (2)
2-2
: Added necessary imports for the new button component.The imports for Link from raviger and Button from the UI components are correctly added to support the new functionality.
Also applies to: 9-9
45-50
: Well-implemented button for patient questionnaire access.This button addition implements the PR objective of providing organizational roles access to submit questionnaires on behalf of patients. The button:
- Uses proper styling with variant="outline_primary"
- Includes an appropriate icon for visual cues
- Uses a translation key for internationalization
- Links directly to the patient-specific questionnaire route
The placement next to the updates header is appropriate and maintains the UI's visual balance.
src/components/Questionnaire/QuestionTypes/QuestionInput.tsx (5)
1-2
: Added internationalization support.Properly imported and implemented the useTranslation hook to support internationalization within the component.
Also applies to: 59-59
44-44
: Made facilityId optional to support the organizational access route.Changed facilityId from required to optional, which is consistent with the PR objectives to support access from organizational routes where a facility ID might not be present.
130-130
: Replaced hardcoded strings with translation keys.All user-facing error messages have been properly internationalized:
- Medication request errors
- Medication statement errors
- Symptom errors
- Diagnosis errors
- General encounter errors
This ensures consistent messaging across the application and supports multilingual users.
Also applies to: 143-144, 158-158, 165-165, 178-178
169-169
: Updated conditional logic for encounter question rendering.The condition now correctly checks for both encounterId AND facilityId before rendering the EncounterQuestion component. This ensures that the component only renders when all required data is available.
264-264
: Internationalized button text.Replaced the hardcoded "Add Another" text with a translation key, maintaining consistency with the internationalization approach throughout the component.
src/components/Patient/EncounterQuestionnaire.tsx (2)
18-18
: Made facilityId optional in the Props interface.This change supports the PR objective of allowing organizational roles to access the questionnaire functionality, where a facilityId might not always be available.
75-81
: Enhanced navigation logic based on available data.The conditional navigation now properly handles both cases:
- When both encounterId and facilityId are available - navigates to the encounter-specific updates
- When either is missing - navigates to the general patient updates
This dual-path approach supports the organizational access feature while maintaining backward compatibility.
public/locale/en.json (2)
288-288
: Added translation key for "Add Another" button.New translation key supports the internationalization of the interface element.
1889-1893
: Added error message translations for encounter-related validations.Added well-named translation keys with clear, informative messages for encounter-related validation:
- Diagnosis validation
- Medication request validation
- Medication statement validation
- General encounter validation
- Symptom validation
These messages help users understand why certain actions require an active encounter, improving the overall user experience.
Also applies to: 1897-1897
Conflicts have been detected against the base branch. Please merge the base branch into your branch.
|
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Chores
Updates
component from the patient details tab, streamlining the interface.