Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes date time initial value formatting for Log update measured at, Discharge (death date time) and Bed start date time #5927

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ export const ConsultationForm = (props: any) => {
<TextFormField
{...field("death_datetime")}
type="datetime-local"
max={new Date().toISOString().slice(0, 16)}
max={moment().format("YYYY-MM-DDTHH:mm")}
required={state.form.suggestion === "DD"}
label="Date & Time of Death"
value={state.form.death_datetime}
Expand Down
15 changes: 3 additions & 12 deletions src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ import { formatDate } from "../../../Utils/utils";
import moment from "moment";
import { useDispatch } from "react-redux";

const formatDateTime: () => 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;
Expand All @@ -45,7 +34,9 @@ const Beds = (props: BedsProps) => {
const dispatch = useDispatch<any>();
const { facilityId, consultationId, discharged } = props;
const [bed, setBed] = React.useState<BedModel>({});
const [startDate, setStartDate] = React.useState<string>(formatDateTime());
const [startDate, setStartDate] = React.useState<string>(
moment().format("YYYY-MM-DDTHH:mm")
);
const [consultationBeds, setConsultationBeds] = React.useState<CurrentBed[]>(
[]
);
Expand Down
55 changes: 27 additions & 28 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 = ({
Expand All @@ -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();
Expand All @@ -65,7 +65,7 @@ const DischargeModal = ({
discharge_notes,
discharge_date,
death_datetime,
death_confirmed_doctor: null,
death_confirmed_doctor: undefined,
});
const [latestClaim, setLatestClaim] = useState<HCXClaimModel>();
const [isCreateClaimLoading, setIsCreateClaimLoading] = useState(false);
Expand Down Expand Up @@ -256,26 +256,25 @@ const DischargeModal = ({
)}
{preDischargeForm.discharge_reason === "EXP" && (
<div>
<div>
Death Date and Time
<span className="text-danger-500">{" *"}</span>
<input
type="datetime-local"
className="block w-[calc(100%-5px)] rounded border border-gray-400 bg-gray-100 px-4 py-2 text-sm hover:bg-gray-200 focus:border-primary-500 focus:bg-white focus:outline-none focus:ring-primary-500"
value={preDischargeForm.death_datetime ?? ""}
required
min={consultationData?.admission_date?.substring(0, 16)}
max={moment(new Date()).format("YYYY-MM-DDThh:mm")}
onChange={(e) => {
setPreDischargeForm((form) => {
return {
...form,
death_datetime: e.target.value,
};
});
}}
/>
</div>
<TextFormField
name="death_datetime"
label="Death Date and Time"
type="datetime-local"
value={preDischargeForm.death_datetime}
onChange={(e) => {
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")}
/>
<TextFormField
name="death_confirmed_by"
label="Confirmed By"
Expand Down
8 changes: 4 additions & 4 deletions src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ export const DailyRounds = (props: any) => {
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")}
/>
</div>
<div className="w-full md:w-1/3">
Expand Down
Loading