Skip to content

Commit

Permalink
Added nav link for bed status in consultation form (ohcnetwork#6170)
Browse files Browse the repository at this point in the history
  • Loading branch information
suprabathk authored Sep 6, 2023
1 parent bbb07b7 commit 539beec
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ const consultationFormReducer = (state = initialState, action: FormAction) => {
type ConsultationFormSection =
| "Consultation Details"
| "Diagnosis"
| "Treatment Plan";
| "Treatment Plan"
| "Bed Status";

export const ConsultationForm = (props: any) => {
const { goBack } = useAppHistory();
Expand All @@ -223,6 +224,7 @@ export const ConsultationForm = (props: any) => {
const [consultationDetailsVisible, consultationDetailsRef] = useVisibility();
const [diagnosisVisible, diagnosisRef] = useVisibility(-300);
const [treatmentPlanVisible, treatmentPlanRef] = useVisibility(-300);
const [bedStatusVisible, bedStatusRef] = useVisibility(-300);
const [disabledFields, setDisabledFields] = useState<string[]>([]);

const sections = {
Expand All @@ -241,16 +243,27 @@ export const ConsultationForm = (props: any) => {
visible: treatmentPlanVisible,
ref: treatmentPlanRef,
},
"Bed Status": {
iconClass: "care-l-bed",
visible: bedStatusVisible,
ref: bedStatusRef,
},
};

useEffect(() => {
setCurrentSection((prev) => {
if (consultationDetailsVisible) return "Consultation Details";
if (diagnosisVisible) return "Diagnosis";
if (treatmentPlanVisible) return "Treatment Plan";
if (bedStatusVisible) return "Bed Status";
return prev;
});
}, [consultationDetailsVisible, diagnosisVisible, treatmentPlanVisible]);
}, [
consultationDetailsVisible,
diagnosisVisible,
treatmentPlanVisible,
bedStatusVisible,
]);

useEffect(() => {
async function fetchPatientName() {
Expand Down Expand Up @@ -817,6 +830,9 @@ export const ConsultationForm = (props: any) => {
if (state.form.consultation_status === 1) {
return null;
}
if (!isUpdate && sectionTitle === "Bed Status") {
return null;
}
const isCurrent = currentSection === sectionTitle;
const section = sections[sectionTitle as ConsultationFormSection];
return (
Expand Down Expand Up @@ -1306,7 +1322,7 @@ export const ConsultationForm = (props: any) => {
{isUpdate && (
<>
<div className="mx-auto mt-4 max-w-4xl rounded bg-white px-11 py-8">
<h4>Update Bed</h4>
{sectionTitle("Bed Status")}
<Beds
facilityId={facilityId}
patientId={patientId}
Expand Down

0 comments on commit 539beec

Please sign in to comment.