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

Restrict Unauthorized Users from Accessing Facility's Patient Registration #7268

Closed
wants to merge 15 commits into from
Closed
10 changes: 9 additions & 1 deletion src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -734,13 +734,21 @@ export const PatientManager = () => {
<ButtonV2
id="add-patient-details"
onClick={() => {
const showAllFacilityUsers = ["DistrictAdmin", "StateAdmin"];
AshrafMd-1 marked this conversation as resolved.
Show resolved Hide resolved
if (qParams.facility)
navigate(`/facility/${qParams.facility}/patient`);
else if (permittedFacilities?.results.length === 1)
navigate(
`/facility/${permittedFacilities?.results[0].id}/patient`
);
else setShowDialog(true);
else if (
!showAllFacilityUsers.includes(authUser.user_type) &&
authUser.home_facility_object?.id
) {
navigate(
`/facility/${authUser.home_facility_object?.id}/patient`
);
} else setShowDialog(true);
}}
className="w-full lg:w-fit"
>
Expand Down
10 changes: 10 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,16 @@ export const PatientRegister = (props: PatientRegisterProps) => {
}
}, [careExtId, formField]);

useEffect(() => {
const showAllFacilityUsers = ["DistrictAdmin", "StateAdmin"];
if (
!showAllFacilityUsers.includes(authUser.user_type) &&
authUser.home_facility_object?.id !== facilityId
) {
navigate("/facility");
}
}, []);
AshrafMd-1 marked this conversation as resolved.
Show resolved Hide resolved

const headerText = !id ? "Add Details of Patient" : "Update Patient Details";
const buttonText = !id ? "Add Patient" : "Save Details";

Expand Down
Loading