diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 8b9e7d89907..e76516008e1 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -272,10 +272,10 @@ export const PATIENT_FILTER_ADMITTED_TO = [ ]; export const PATIENT_CATEGORIES = [ - "Comfort Care", - "Stable", - "Slightly Abnormal", - "Critical", + { id: "Comfort", text: "Comfort Care" }, + { id: "Stable", text: "Stable" }, + { id: "Moderate", text: "Slightly Abnormal" }, + { id: "Critical", text: "Critical" }, ]; export const PATIENT_FILTER_CATEGORIES = PATIENT_CATEGORIES; diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index be7df564b1e..f422edaeae9 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -126,7 +126,7 @@ const initForm: FormDetails = { facility: "", admitted: "false", admitted_to: "", - category: "Comfort Care", + category: "Comfort", admission_date: new Date().toISOString(), discharge_date: null, referred_to: "", @@ -264,7 +264,9 @@ export const ConsultationForm = (props: any) => { !!res.data.symptoms.filter((i: number) => i === 9).length, admitted: res.data.admitted ? String(res.data.admitted) : "false", admitted_to: res.data.admitted_to ? res.data.admitted_to : "", - category: res.data.category || "Comfort Care", + category: res.data.category + ? PATIENT_CATEGORIES.find((i) => i.text === res.data.category)?.id || "Comfort" + : "Comfort", ip_no: res.data.ip_no ? res.data.ip_no : "", verified_by: res.data.verified_by ? res.data.verified_by : "", OPconsultation: res.data.consultation_notes, @@ -313,7 +315,9 @@ export const ConsultationForm = (props: any) => { case "category": if ( !state.form[field] || - !PATIENT_CATEGORIES.includes(state.form[field]) + !PATIENT_CATEGORIES.map((category) => category.id).includes( + state.form[field] + ) ) { errors[field] = "Please select a category"; if (!error_div) error_div = field; @@ -773,12 +777,7 @@ export const ConsultationForm = (props: any) => { name="category" variant="standard" value={state.form.category} - options={PATIENT_CATEGORIES.map((c) => { - return { - id: c, - text: c, - }; - })} + options={PATIENT_CATEGORIES} onChange={handleChange} errors={state.errors.category} /> diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index d0064e64b4b..0f624402241 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -47,7 +47,7 @@ const initForm: any = { other_symptoms: "", physical_examination_info: "", other_details: "", - patient_category: "Comfort Care", + patient_category: "Comfort", current_health: 0, recommend_discharge: false, actions: null, @@ -122,6 +122,11 @@ export const DailyRounds = (props: any) => { if (res && res.data) { const data = { ...res.data, + patient_category: res.data.patient_category + ? PATIENT_CATEGORIES.find( + (i) => i.text === res.data.patient_category + )?.id || "Comfort" + : "Comfort", admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select", }; dispatch({ type: "set_form", form: data }); @@ -171,6 +176,11 @@ export const DailyRounds = (props: any) => { type: "set_form", form: { ...state.form, + patient_category: res.data.patient_category + ? PATIENT_CATEGORIES.find( + (i) => i.text === res.data.patient_category + )?.id || "Comfort" + : "Comfort", clone_last: res.data.count > 0 ? "true" : "false", }, }); @@ -534,9 +544,7 @@ export const DailyRounds = (props: any) => { variant="standard" margin="dense" value={state.form.patient_category} - options={PATIENT_CATEGORIES.map((c) => { - return { id: c, text: c }; - })} + options={PATIENT_CATEGORIES} onChange={handleChange} errors={state.errors.patient_category} /> diff --git a/src/Components/Patient/PatientFilterV2.tsx b/src/Components/Patient/PatientFilterV2.tsx index a9c55e4fd62..94145da81a8 100644 --- a/src/Components/Patient/PatientFilterV2.tsx +++ b/src/Components/Patient/PatientFilterV2.tsx @@ -586,9 +586,7 @@ export default function PatientFilterV2(props: any) { value={filterState.category} options={[ { id: "", text: "Show All" }, - ...PATIENT_FILTER_CATEGORIES.map((o) => { - return { id: o, text: o }; - }), + ...PATIENT_FILTER_CATEGORIES, ]} onChange={handleChange} className="bg-white h-10 shadow-sm md:text-sm md:leading-5 md:h-9"