Skip to content

Commit

Permalink
Add Consultation button is now conditionally active (ohcnetwork#6260)
Browse files Browse the repository at this point in the history
* Add Consultation button is now conditionally active

* updated logic for add consultation button to be active
  • Loading branch information
thtauhid authored Sep 12, 2023
1 parent 87f36ba commit 3fdf1d5
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ export const PatientHome = (props: any) => {
);
};

const isPatientEligibleForNewConsultation = (patientData: PatientModel) => {
return !patientData.last_consultation ||
patientData.last_consultation?.discharge_date
? true
: false;
};

return (
<Page
title={"Patient Details"}
Expand Down Expand Up @@ -1105,23 +1112,31 @@ export const PatientHome = (props: any) => {
<div
className={classNames(
"w-full rounded-lg border",
patientData.is_active &&
(!patientData?.last_consultation ||
patientData?.last_consultation?.discharge_date)
isPatientEligibleForNewConsultation(patientData)
? "cursor-pointer border-green-700 hover:bg-primary-400"
: "border-gray-700 text-gray-700 hover:cursor-not-allowed"
)}
onClick={() =>
patientData.is_active &&
(!patientData?.last_consultation ||
patientData?.last_consultation?.discharge_date) &&
isPatientEligibleForNewConsultation(patientData) &&
navigate(
`/facility/${patientData?.facility}/patient/${id}/consultation`
)
}
>
<div className="h-full space-y-2 rounded-lg bg-white p-4 shadow">
<div className="text-center">
<div
className={classNames(
"h-full space-y-2 rounded-lg bg-white p-4 shadow",
isPatientEligibleForNewConsultation(patientData) &&
"hover:bg-gray-200"
)}
>
<div
className={classNames(
"text-center",
isPatientEligibleForNewConsultation(patientData) &&
"text-green-700"
)}
>
<span>
<CareIcon className="care-l-chat-bubble-user text-5xl" />
</span>
Expand Down

0 comments on commit 3fdf1d5

Please sign in to comment.