diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 647c77ecf57..55a35bef9ab 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -294,10 +294,10 @@ export const SYMPTOM_CHOICES = [ ]; export const DISCHARGE_REASONS = [ - { id: "REC", text: "Recovered" }, - { id: "EXP", text: "Expired" }, - { id: "REF", text: "Referred" }, - { id: "LAMA", text: "LAMA" }, + { id: 1, text: "Recovered" }, + { id: 2, text: "Referred" }, + { id: 3, text: "Expired" }, + { id: 4, text: "LAMA" }, ]; export const CONSCIOUSNESS_LEVEL = [ diff --git a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx index 5e5b574dd07..4158d7f6609 100644 --- a/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx +++ b/src/Components/Facility/ConsultationDetails/ConsultationUpdatesTab.tsx @@ -176,7 +176,8 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { {props.consultationData.discharge_date && (
i.text == "Recovered")?.id && "lg:col-span-2" }`} > @@ -190,11 +191,13 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => { {DISCHARGE_REASONS.find( (d) => - d.id === props.consultationData.discharge_reason + d.id === props.consultationData.new_discharge_reason )?.text ?? "--"}
- {props.consultationData.discharge_reason === "REF" && ( + {props.consultationData.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Referred") + ?.id && (
Referred Facility {" - "} @@ -204,7 +207,9 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
)} - {props.consultationData.discharge_reason === "REC" && ( + {props.consultationData.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Recovered") + ?.id && (
Discharge Date {" - "} @@ -239,7 +244,9 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
)} - {props.consultationData.discharge_reason === "EXP" && ( + {props.consultationData.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired") + ?.id && (
Date of Death {" - "} @@ -266,8 +273,8 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
)} - {["REF", "LAMA"].includes( - props.consultationData.discharge_reason ?? "" + {[2, 4].includes( + props.consultationData.new_discharge_reason ?? 0 ) && (
diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 63e18645e13..a493d354be2 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -3,6 +3,7 @@ import * as Notification from "../../Utils/Notifications.js"; import { BedModel, FacilityModel } from "./models"; import { CONSULTATION_SUGGESTION, + DISCHARGE_REASONS, ConsultationSuggestionValue, PATIENT_CATEGORIES, REVIEW_AT_CHOICES, @@ -121,7 +122,7 @@ type FormDetails = { weight: string; height: string; bed: BedModel | null; - discharge_reason: string; + new_discharge_reason: number | null; cause_of_death: string; death_datetime: string; death_confirmed_doctor: string; @@ -171,7 +172,7 @@ const initForm: FormDetails = { weight: "", height: "", bed: null, - discharge_reason: "", + new_discharge_reason: null, cause_of_death: "", death_datetime: "", death_confirmed_doctor: "", @@ -402,7 +403,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { weight: res.data.weight ? res.data.weight : "", height: res.data.height ? res.data.height : "", bed: res.data?.current_bed?.bed_object || null, - discharge_reason: res.data?.discharge_reason || "", + new_discharge_reason: res.data?.new_discharge_reason || null, cause_of_death: res.data?.discharge_notes || "", death_datetime: res.data?.death_datetime || "", death_confirmed_doctor: res.data?.death_confirmed_doctor || "", @@ -653,7 +654,9 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { const dischargeResponse = await dispatchAction( dischargePatient( { - discharge_reason: "EXP", + new_discharge_reason: DISCHARGE_REASONS.find( + (i) => i.text === "Expired" + )?.id, discharge_notes: cause_of_death, death_datetime: death_datetime, death_confirmed_doctor: death_confirmed_doctor, diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index a15af4d3883..892be2e916b 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -26,7 +26,7 @@ import { FacilityModel } from "./models"; import dayjs from "../../Utils/dayjs"; interface PreDischargeFormInterface { - discharge_reason: string; + new_discharge_reason: number | null; discharge_notes: string; discharge_date?: string; death_datetime?: string; @@ -40,7 +40,7 @@ interface IProps { onClose: () => void; consultationData: ConsultationModel; afterSubmit?: () => void; - discharge_reason?: string; + new_discharge_reason?: number | null; discharge_notes?: string; discharge_date?: string; death_datetime?: string; @@ -51,7 +51,7 @@ const DischargeModal = ({ onClose, consultationData, afterSubmit, - discharge_reason = "", + new_discharge_reason = null, discharge_notes = "", discharge_date = dayjs().format("YYYY-MM-DDTHH:mm"), death_datetime = dayjs().format("YYYY-MM-DDTHH:mm"), @@ -60,7 +60,7 @@ const DischargeModal = ({ const dispatch: any = useDispatch(); const [preDischargeForm, setPreDischargeForm] = useState({ - discharge_reason, + new_discharge_reason, discharge_notes, discharge_date, death_datetime, @@ -110,17 +110,18 @@ const DischargeModal = ({ const handlePatientDischarge = async (value: boolean) => { setIsSendingDischargeApi(true); - if (!preDischargeForm.discharge_reason) { + if (!preDischargeForm.new_discharge_reason) { setErrors({ ...errors, - discharge_reason: "Please select a reason for discharge", + new_discharge_reason: "Please select a reason for discharge", }); setIsSendingDischargeApi(false); return; } if ( - preDischargeForm.discharge_reason == "EXP" && + preDischargeForm.new_discharge_reason == + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && !preDischargeForm.discharge_notes.trim() ) { setErrors({ @@ -196,20 +197,21 @@ const DischargeModal = ({ label="Reason" name="discharge_reason" id="discharge_reason" - value={preDischargeForm.discharge_reason} - disabled={!!discharge_reason} + value={preDischargeForm.new_discharge_reason} + disabled={!!new_discharge_reason} options={DISCHARGE_REASONS} optionValue={({ id }) => id} optionLabel={({ text }) => text} onChange={(e) => setPreDischargeForm((prev) => ({ ...prev, - discharge_reason: e.value, + new_discharge_reason: e.value, })) } - error={errors?.discharge_reason} + error={errors?.new_discharge_reason} /> - {preDischargeForm.discharge_reason === "REF" && ( + {preDischargeForm.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Referred")?.id && ( <> Referred to )} i.text == "Expired")?.id + } label={ { - EXP: "Cause of death", - REC: "Discharged Advice", - }[preDischargeForm.discharge_reason] ?? "Notes" + "3": "Cause of death", + "1": "Discharged Advice", + }[preDischargeForm.new_discharge_reason ?? 0] ?? "Notes" } name="discharge_notes" value={preDischargeForm.discharge_notes} @@ -246,19 +251,22 @@ const DischargeModal = ({ /> i.text == "Expired")?.id ? "death_datetime" : "discharge_date" } label={ - preDischargeForm.discharge_reason === "EXP" + preDischargeForm.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id ? "Date of Death" : "Date and Time of Discharge" } type="datetime-local" value={ preDischargeForm[ - preDischargeForm.discharge_reason === "EXP" + preDischargeForm.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id ? "death_datetime" : "discharge_date" ] @@ -277,13 +285,15 @@ const DischargeModal = ({ )} max={dayjs().format("YYYY-MM-DDTHH:mm")} error={ - preDischargeForm.discharge_reason === "EXP" + preDischargeForm.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id ? errors?.death_datetime : errors?.discharge_date } /> - {preDischargeForm.discharge_reason === "REC" && ( + {preDischargeForm.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Recovered")?.id && ( <>
Discharge Prescription Medications @@ -295,7 +305,8 @@ const DischargeModal = ({
)} - {preDischargeForm.discharge_reason === "EXP" && ( + {preDischargeForm.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && ( { }; const tabValue = - qParams.last_consultation_discharge_reason || qParams.is_active === "False" + qParams.last_consultation__new_discharge_reason || + qParams.is_active === "False" ? 1 : 0; @@ -163,7 +164,7 @@ export const PatientManager = () => { name: qParams.name || undefined, patient_no: qParams.patient_no || undefined, is_active: - !qParams.last_consultation_discharge_reason && + !qParams.last_consultation__new_discharge_reason && (qParams.is_active || "True"), disease_status: qParams.disease_status || undefined, phone_number: qParams.phone_number @@ -204,8 +205,8 @@ export const PatientManager = () => { qParams.last_consultation_discharge_date_after || undefined, last_consultation_admitted_bed_type_list: qParams.last_consultation_admitted_bed_type_list || undefined, - last_consultation_discharge_reason: - qParams.last_consultation_discharge_reason || undefined, + last_consultation__new_discharge_reason: + qParams.last_consultation__new_discharge_reason || undefined, last_consultation_current_bed__location: qParams.last_consultation_current_bed__location || undefined, srf_id: qParams.srf_id || undefined, @@ -352,7 +353,7 @@ export const PatientManager = () => { qParams.age_max, qParams.age_min, qParams.last_consultation_admitted_bed_type_list, - qParams.last_consultation_discharge_reason, + qParams.last_consultation__new_discharge_reason, qParams.last_consultation_current_bed__location, qParams.facility, qParams.facility_type, @@ -1022,10 +1023,10 @@ export const PatientManager = () => { }, value( "Discharge Reason", - "last_consultation_discharge_reason", + "last_consultation__new_discharge_reason", parseOptionId( DISCHARGE_REASONS, - qParams.last_consultation_discharge_reason + qParams.last_consultation__new_discharge_reason ) || "" ), ]} diff --git a/src/Components/Patient/PatientFilter.tsx b/src/Components/Patient/PatientFilter.tsx index 481d2dcc67b..4488aa755e1 100644 --- a/src/Components/Patient/PatientFilter.tsx +++ b/src/Components/Patient/PatientFilter.tsx @@ -81,8 +81,8 @@ export default function PatientFilter(props: any) { : [], last_consultation_current_bed__location: filter.last_consultation_current_bed__location || "", - last_consultation_discharge_reason: - filter.last_consultation_discharge_reason || null, + last_consultation__new_discharge_reason: + filter.last_consultation__new_discharge_reason || null, srf_id: filter.srf_id || null, number_of_doses: filter.number_of_doses || null, covin_id: filter.covin_id || null, @@ -241,7 +241,7 @@ export default function PatientFilter(props: any) { last_consultation_discharge_date_before, last_consultation_discharge_date_after, last_consultation_admitted_bed_type_list, - last_consultation_discharge_reason, + last_consultation__new_discharge_reason, last_consultation_current_bed__location, number_of_doses, covin_id, @@ -298,8 +298,8 @@ export default function PatientFilter(props: any) { age_max: age_max || "", last_consultation_admitted_bed_type_list: last_consultation_admitted_bed_type_list || [], - last_consultation_discharge_reason: - last_consultation_discharge_reason || "", + last_consultation__new_discharge_reason: + last_consultation__new_discharge_reason || "", srf_id: srf_id || "", number_of_doses: number_of_doses || "", covin_id: covin_id || "", @@ -424,16 +424,16 @@ export default function PatientFilter(props: any) {
Discharge Reason o.id} optionLabel={(o) => o.text} onChange={(o) => setFilterState({ ...filterState, - last_consultation_discharge_reason: o, + last_consultation__new_discharge_reason: o, }) } /> diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index 32118e5951e..22cc35a170e 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -1,7 +1,11 @@ import { navigate } from "raviger"; import { lazy, useCallback, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; -import { GENDER_TYPES, SAMPLE_TEST_STATUS } from "../../Common/constants"; +import { + DISCHARGE_REASONS, + GENDER_TYPES, + SAMPLE_TEST_STATUS, +} from "../../Common/constants"; import { statusType, useAbortableEffect } from "../../Common/utils"; import { getConsultationList, @@ -761,7 +765,8 @@ export const PatientHome = (props: any) => {
- {patientData.last_consultation?.discharge_reason === "EXP" && ( + {patientData.last_consultation?.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id && (
i.text == "Expired")?.id ? ( {" "} Expired on {formatDate(consultation?.death_datetime)} @@ -379,17 +380,18 @@ export default function PatientInfoCard(props: { Discharge Reason
- {!consultation?.discharge_reason ? ( + {!consultation?.new_discharge_reason ? ( {consultation.suggestion === "OP" ? "OP file closed" : "UNKNOWN"} - ) : consultation?.discharge_reason === "EXP" ? ( + ) : consultation?.new_discharge_reason === + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id ? ( EXPIRED ) : ( DISCHARGE_REASONS.find( - (reason) => reason.id === consultation?.discharge_reason + (reason) => reason.id === consultation?.new_discharge_reason )?.text )}
diff --git a/src/Components/Shifting/ShiftDetailsUpdate.tsx b/src/Components/Shifting/ShiftDetailsUpdate.tsx index 36d2d120585..a726150c9e1 100644 --- a/src/Components/Shifting/ShiftDetailsUpdate.tsx +++ b/src/Components/Shifting/ShiftDetailsUpdate.tsx @@ -2,6 +2,7 @@ import * as Notification from "../../Utils/Notifications.js"; import { BREATHLESSNESS_LEVEL, + DISCHARGE_REASONS, FACILITY_TYPES, PATIENT_CATEGORIES, SHIFTING_CHOICES_PEACETIME, @@ -282,7 +283,9 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => { show={showDischargeModal} onClose={() => setShowDischargeModal(false)} consultationData={consultationData} - discharge_reason="EXP" + new_discharge_reason={ + DISCHARGE_REASONS.find((i) => i.text == "Expired")?.id + } afterSubmit={() => { handleSubmit(true); }}