-
Notifications
You must be signed in to change notification settings - Fork 522
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 Registration form refactor #9854
Conversation
* forgot password mutation * updated
Co-authored-by: Rithvik Nishad <[email protected]>
…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.
- 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.
- 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.
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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bodhisha Thomas <[email protected]> Co-authored-by: Bodhish Thomas <[email protected]>
…tiple components (#9793)
* 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
…anizationSelector 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.
… patient registration
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: 2
🧹 Nitpick comments (1)
src/components/Patient/PatientRegistration.tsx (1)
261-262
: Avoid type casting with proper typingThe type casting of
geo_organization
could be avoided by properly typing the API response.Consider updating the
PatientModel
type to include the correct type forgeo_organization
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/Patient/PatientRegistration.tsx
(8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Cloudflare Pages: care-fe
🔇 Additional comments (3)
src/components/Patient/PatientRegistration.tsx (3)
150-157
:⚠️ Potential issueSet default value for same_address checkbox
According to the PR objectives, the "Use this address for permanent address" checkbox should be selected by default.
Apply this diff:
defaultValues: { nationality: "India", phone_number: phone_number || "+91", emergency_phone_number: "+91", age_or_dob: "dob", same_phone_number: false, - same_address: true, + same_address: true, // Set to true by default as per requirements },Likely invalid or redundant comment.
250-265
: 🛠️ Refactor suggestionAdd form to useEffect dependencies
The
useEffect
hook depends onpatientQuery.data
, but it should also includeform
in its dependency array to ensure thatform.reset
has the latest reference.Apply this diff:
- }, [patientQuery.data]); // eslint-disable-line react-hooks/exhaustive-deps + }, [patientQuery.data, form]); // eslint-disable-line react-hooks/exhaustive-depsLikely invalid or redundant comment.
497-510
: 🛠️ Refactor suggestionAdd validation for date of birth fields
The date input fields lack validation for valid dates (e.g., preventing invalid dates like February 30th).
Apply this diff to add validation:
<Input type="number" placeholder="DD" + min={1} + max={31} {...field} value={ - form.watch("date_of_birth")?.split("-")[2] + form.watch("date_of_birth")?.split("-")?.[2] || "" } onChange={(e) => { + const day = Number(e.target.value); + if (day < 1 || day > 31) return; form.setValue( "date_of_birth", `${form.watch("date_of_birth")?.split("-")?.[0] || ""}-${form.watch("date_of_birth")?.split("-")?.[1] || ""}-${e.target.value}`, ) }}Apply similar validation for month (1-12) and year inputs.
Likely invalid or redundant comment.
phone_number: z | ||
.string() | ||
.regex(/^\+\d{12}$/, t("phone_number_must_be_10_digits")), |
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.
Fix phone number validation to match requirements
The regex pattern /^\+\d{12}$/
requires exactly 12 digits after the '+' sign, but according to the PR objectives, phone numbers should be limited to 10 digits.
Apply this diff to fix the validation:
- .regex(/^\+\d{12}$/, t("phone_number_must_be_10_digits")),
+ .regex(/^\+\d{10}$/, t("phone_number_must_be_10_digits")),
Make the same change for emergency_phone_number
validation as well.
Also applies to: 93-95
<Input | ||
{...field} | ||
maxLength={13} | ||
onChange={(e) => { | ||
form.setValue("phone_number", e.target.value); | ||
if (form.watch("same_phone_number")) { | ||
form.setValue( | ||
"emergency_phone_number", | ||
e.target.value, | ||
); | ||
} | ||
}} | ||
data-cy="patient-phone-input" | ||
/> |
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.
🛠️ Refactor suggestion
Improve phone number input validation
The phone number input should validate the format as the user types and prevent invalid characters.
Apply this diff:
<Input
{...field}
maxLength={13}
+ pattern="[+][0-9]+"
onChange={(e) => {
+ const value = e.target.value.replace(/[^+0-9]/g, '');
- form.setValue("phone_number", e.target.value);
+ form.setValue("phone_number", value);
if (form.watch("same_phone_number")) {
form.setValue(
"emergency_phone_number",
- e.target.value,
+ value,
);
}
}}
+ inputMode="numeric"
data-cy="patient-phone-input"
/>
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<Input | |
{...field} | |
maxLength={13} | |
onChange={(e) => { | |
form.setValue("phone_number", e.target.value); | |
if (form.watch("same_phone_number")) { | |
form.setValue( | |
"emergency_phone_number", | |
e.target.value, | |
); | |
} | |
}} | |
data-cy="patient-phone-input" | |
/> | |
<Input | |
{...field} | |
maxLength={13} | |
pattern="[+][0-9]+" | |
onChange={(e) => { | |
const value = e.target.value.replace(/[^+0-9]/g, ''); | |
form.setValue("phone_number", value); | |
if (form.watch("same_phone_number")) { | |
form.setValue( | |
"emergency_phone_number", | |
value, | |
); | |
} | |
}} | |
inputMode="numeric" | |
data-cy="patient-phone-input" | |
/> |
LGTM |
@khavinshankar 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! 🙌 |
Summary by CodeRabbit
Release Notes
Localization
Patient Registration
Plugin System
Configuration