Skip to content

Commit

Permalink
Adds support for capturing time in Discharge Date
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Nov 30, 2023
1 parent 31b7690 commit c2ea000
Showing 1 changed file with 34 additions and 31 deletions.
65 changes: 34 additions & 31 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import ClaimDetailCard from "../HCX/ClaimDetailCard";
import { ConsultationModel } from "./models";
import CreateClaimCard from "../HCX/CreateClaimCard";
import { DISCHARGE_REASONS } from "../../Common/constants";
import DateFormField from "../Form/FormFields/DateFormField";
import DialogModal from "../Common/Dialog";
import { FieldChangeEvent } from "../Form/FormFields/Utils";
import { FieldLabel } from "../Form/FormFields/FormField";
import { HCXActions } from "../../Redux/actions";
import { HCXClaimModel } from "../HCX/models";
Expand Down Expand Up @@ -161,11 +159,6 @@ const DischargeModal = ({

setIsSendingDischargeApi(false);
if (dischargeResponse?.status === 200) {
// TODO: check this later
// const dischargeData = Object.assign({}, patientData);
// dischargeData["discharge"] = value;
// setPatientData(dischargeData);

Notification.Success({
msg: "Patient Discharged Successfully",
});
Expand All @@ -174,15 +167,6 @@ const DischargeModal = ({
}
};

const handleDateChange = (e: FieldChangeEvent<Date>) => {
setPreDischargeForm((form) => {
return {
...form,
discharge_date: e.value.toString(),
};
});
};

const handleFacilitySelect = (selected: FacilityModel) => {
setFacility(selected);
const { id, name } = selected || {};
Expand Down Expand Up @@ -266,18 +250,27 @@ const DischargeModal = ({
/>
{preDischargeForm.discharge_reason === "REC" && (
<div>
<DateFormField
position="LEFT"
label="Discharge Date"
<TextFormField
label="Date and Time of Discharge"
name="discharge_date"
value={dayjs(preDischargeForm?.discharge_date).toDate()}
required
type="datetime-local"
value={dayjs(preDischargeForm?.discharge_date).format(
"YYYY-MM-DDTHH:mm"
)}
min={dayjs(
consultationData?.admission_date ??
consultationData?.created_date
).toDate()}
disableFuture={true}
required
onChange={handleDateChange}
).format("YYYY-MM-DDTHH:mm")}
max={dayjs().format("YYYY-MM-DDTHH:mm")}
onChange={(e) => {
setPreDischargeForm((form) => {
return {
...form,
discharge_date: e.value,
};
});
}}
/>

<div className="mb-4">
Expand Down Expand Up @@ -330,17 +323,27 @@ const DischargeModal = ({
)}
{["REF", "LAMA"].includes(preDischargeForm.discharge_reason) && (
<div>
<DateFormField
label="Date of Discharge"
<TextFormField
label="Date and Time of Discharge"
name="discharge_date"
value={dayjs(preDischargeForm.discharge_date).toDate()}
required
type="datetime-local"
value={dayjs(preDischargeForm?.discharge_date).format(
"YYYY-MM-DDTHH:mm"
)}
min={dayjs(
consultationData?.admission_date ??
consultationData?.created_date
).toDate()}
disableFuture={true}
required
onChange={handleDateChange}
).format("YYYY-MM-DDTHH:mm")}
max={dayjs().format("YYYY-MM-DDTHH:mm")}
onChange={(e) => {
setPreDischargeForm((form) => {
return {
...form,
discharge_date: e.value,
};
});
}}
/>
</div>
)}
Expand Down

0 comments on commit c2ea000

Please sign in to comment.