Skip to content

Commit

Permalink
Ask for facility for other cases
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Mar 11, 2024
1 parent 5ea55c1 commit f33db31
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/Components/Common/components/SwitchTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { classNames } from "../../../Utils/utils";
export default function SwitchTabs(props: {
className?: string;
isTab2Active: boolean;
onClickTab1: () => void;
onClickTab2: () => void;
onClickTab1?: () => void;
onClickTab2?: () => void;
tab1: ReactNode;
tab2: ReactNode;
}) {
Expand Down
9 changes: 2 additions & 7 deletions src/Components/Facility/DischargedPatientsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DischargedPatientsList = ({
options={
<>
<SearchInput
className="mr-4 w-full max-w-md"
className="mr-4 w-full max-w-sm"
placeholder="Search by patient name"
name="name"
value={search.name}
Expand All @@ -45,12 +45,7 @@ const DischargedPatientsList = ({
tab1="Live"
tab2="Discharged"
className="mr-4"
onClickTab1={() =>
navigate(`/patients?facility=${facility_external_id}`)
}
onClickTab2={() => {
// Voluntarily doing nothing since we are already in the dedicated discharged patients list page...
}}
onClickTab1={() => navigate("/patients")}
isTab2Active
/>
</>
Expand Down
73 changes: 36 additions & 37 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const PatientManager = () => {
});
const authUser = useAuthUser();
const [diagnoses, setDiagnoses] = useState<ICD11DiagnosisModel[]>([]);
const [showDialog, setShowDialog] = useState(false);
const [showDialog, setShowDialog] = useState<"create" | "list-discharged">();
const [showDoctors, setShowDoctors] = useState(false);
const [showDoctorConnect, setShowDoctorConnect] = useState(false);
const [phone_number, setPhoneNumber] = useState("");
Expand Down Expand Up @@ -743,7 +743,7 @@ export const PatientManager = () => {
navigate(`/facility/${qParams.facility}/patient`);
else if (onlyAccessibleFacility)
navigate(`/facility/${onlyAccessibleFacility.id}/patient`);
else setShowDialog(true);
else setShowDialog("create");
}}
className="w-full lg:w-fit"
>
Expand All @@ -754,40 +754,30 @@ export const PatientManager = () => {
</ButtonV2>
</div>
<div className="flex w-full flex-col items-center justify-end gap-2 lg:ml-3 lg:w-fit lg:flex-row lg:gap-3">
{(authUser.user_type === "StateAdmin" ||
authUser.user_type === "StateReadOnlyAdmin" ||
permittedFacilities?.count === 1 ||
qParams.facility) && (
<SwitchTabs
tab1="Live"
tab2="Discharged"
onClickTab1={() => updateQuery({ is_active: "True" })}
onClickTab2={() => {
if (qParams.facility) {
navigate(
`facility/${qParams.facility}/discharged-patients`
);
return;
}
<SwitchTabs
tab1="Live"
tab2="Discharged"
onClickTab1={() => updateQuery({ is_active: "True" })}
onClickTab2={() => {
// Navigate to dedicated discharged list page if filtered by a facility or user has access only to one facility.
const id = qParams.facility || onlyAccessibleFacility?.id;
if (id) {
navigate(`facility/${id}/discharged-patients`);
return;
}

if (onlyAccessibleFacility) {
navigate(
`facility/${onlyAccessibleFacility.id}/discharged-patients`
);
return;
}
if (
authUser.user_type === "StateAdmin" ||
authUser.user_type === "StateReadOnlyAdmin"
) {
updateQuery({ is_active: "False" });
return;
}

if (
authUser.user_type === "StateAdmin" ||
authUser.user_type === "StateReadOnlyAdmin"
) {
updateQuery({ is_active: "False" });
return;
}
}}
isTab2Active={tabValue ? true : false}
/>
)}
setShowDialog("list-discharged");
}}
isTab2Active={!!tabValue}
/>
{showDoctorConnect && (
<ButtonV2
id="doctor-connect-patient-button"
Expand Down Expand Up @@ -865,12 +855,21 @@ export const PatientManager = () => {
}
>
<FacilitiesSelectDialogue
show={showDialog}
show={!!showDialog}
setSelected={(e) => setSelectedFacility(e)}
selectedFacility={selectedFacility}
handleOk={() => navigate(`facility/${selectedFacility.id}/patient`)}
handleOk={() => {
switch (showDialog) {
case "create":
navigate(`facility/${selectedFacility.id}/patient`);
break;
case "list-discharged":
navigate(`facility/${selectedFacility.id}/discharged-patients`);
break;
}
}}
handleCancel={() => {
setShowDialog(false);
setShowDialog(undefined);
setSelectedFacility({ name: "" });
}}
/>
Expand Down

0 comments on commit f33db31

Please sign in to comment.