From 3b6492fd3861cb85739b6c173574486186ba5391 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 26 Jul 2023 12:24:46 +0530 Subject: [PATCH] fixes #5922 --- src/Components/Facility/ConsultationForm.tsx | 2 +- .../Facility/Consultations/Beds.tsx | 15 +---- src/Components/Facility/DischargeModal.tsx | 55 +++++++++---------- src/Components/Patient/DailyRounds.tsx | 8 +-- 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 116186a94b2..0d4bbcd93eb 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -1013,7 +1013,7 @@ export const ConsultationForm = (props: any) => { string = () => { - const current = new Date(); - const yyyy = String(current.getFullYear()).padStart(4, "0"); - const mm = String(current.getMonth() + 1).padStart(2, "0"); - const dd = String(current.getDate()).padStart(2, "0"); - const hh = String(current.getHours()).padStart(2, "0"); - const min = String(current.getMinutes()).padStart(2, "0"); - - return `${yyyy}-${mm}-${dd}T${hh}:${min}`; -}; - interface BedsProps { facilityId: string; patientId: string; @@ -45,7 +34,9 @@ const Beds = (props: BedsProps) => { const dispatch = useDispatch(); const { facilityId, consultationId, discharged } = props; const [bed, setBed] = React.useState({}); - const [startDate, setStartDate] = React.useState(formatDateTime()); + const [startDate, setStartDate] = React.useState( + moment().format("YYYY-MM-DDTHH:mm") + ); const [consultationBeds, setConsultationBeds] = React.useState( [] ); diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index fa861cd7807..37d4d1a7bb3 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -28,9 +28,9 @@ import CircularProgress from "../Common/components/CircularProgress"; interface PreDischargeFormInterface { discharge_reason: string; discharge_notes: string; - discharge_date: string | null; - death_datetime: string | null; - death_confirmed_doctor: string | null; + discharge_date?: string; + death_datetime?: string; + death_confirmed_doctor?: string; } interface IProps { @@ -40,8 +40,8 @@ interface IProps { afterSubmit?: () => void; discharge_reason?: string; discharge_notes?: string; - discharge_date?: string | null; - death_datetime?: string | null; + discharge_date?: string; + death_datetime?: string; } const DischargeModal = ({ @@ -54,8 +54,8 @@ const DischargeModal = ({ }, discharge_reason = "", discharge_notes = "", - discharge_date = new Date().toISOString(), - death_datetime = null, + discharge_date = moment().format("YYYY-MM-DDTHH:mm"), + death_datetime = moment().format("YYYY-MM-DDTHH:mm"), }: IProps) => { const { enable_hcx } = useConfig(); const dispatch: any = useDispatch(); @@ -65,7 +65,7 @@ const DischargeModal = ({ discharge_notes, discharge_date, death_datetime, - death_confirmed_doctor: null, + death_confirmed_doctor: undefined, }); const [latestClaim, setLatestClaim] = useState(); const [isCreateClaimLoading, setIsCreateClaimLoading] = useState(false); @@ -256,26 +256,25 @@ const DischargeModal = ({ )} {preDischargeForm.discharge_reason === "EXP" && (
-
- Death Date and Time - {" *"} - { - setPreDischargeForm((form) => { - return { - ...form, - death_datetime: e.target.value, - }; - }); - }} - /> -
+ { + setPreDischargeForm((form) => { + return { + ...form, + death_datetime: e.value, + }; + }); + }} + required + min={moment(consultationData?.admission_date).format( + "YYYY-MM-DDTHH:mm" + )} + max={moment().format("YYYY-MM-DDTHH:mm")} + /> { className="w-full" label="Measured at" type="datetime-local" - value={ - state.form.taken_at ?? new Date().toISOString().slice(0, 16) - } - max={new Date().toISOString().slice(0, 16)} + value={moment(state.form.taken_at || undefined).format( + "YYYY-MM-DDTHH:mm" + )} + max={moment().format("YYYY-MM-DDTHH:mm")} />