From 6739c26240e8955effbbacd793aed290ba0baebb Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 11 Jul 2024 12:42:26 +0530 Subject: [PATCH] Add caution for encounter date field if date is beyond 30 days. (#8125) * Add caution for encounter date field if beyond 30 days. * add translations --- src/Components/Facility/ConsultationForm.tsx | 28 +++++++++++++------- src/Locale/en/Common.json | 3 ++- src/Locale/en/Consultation.json | 7 +++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index a728ffc805..436f8f19e0 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -1230,16 +1230,9 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { required={["A", "DC", "OP"].includes( state.form.suggestion, )} - label={ - { - A: "Date & Time of Admission to the Facility", - DC: "Date & Time of Domiciliary Care commencement", - OP: "Date & Time of Out-patient visit", - DD: "Date & Time of Consultation", - HI: "Date & Time of Consultation", - R: "Date & Time of Consultation", - }[state.form.suggestion] - } + label={t( + `encounter_date_field_label__${state.form.suggestion}`, + )} type="datetime-local" value={dayjs(state.form.encounter_date).format( "YYYY-MM-DDTHH:mm", @@ -1251,6 +1244,21 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => { : undefined } /> + {dayjs().diff(state.form.encounter_date, "day") > 30 && ( +
+ + + {t("caution")}:{" "} + {t("back_dated_encounter_date_caution")}{" "} + + {dayjs(state.form.encounter_date).fromNow()}. + + +
+ )} {state.form.route_to_facility === 30 && ( diff --git a/src/Locale/en/Common.json b/src/Locale/en/Common.json index f6ee4f1032..a85572b8d0 100644 --- a/src/Locale/en/Common.json +++ b/src/Locale/en/Common.json @@ -171,5 +171,6 @@ "treating_doctor": "Treating Doctor", "ration_card__NO_CARD": "Non-card holder", "ration_card__BPL": "BPL", - "ration_card__APL": "APL" + "ration_card__APL": "APL", + "caution": "Caution" } \ No newline at end of file diff --git a/src/Locale/en/Consultation.json b/src/Locale/en/Consultation.json index fa0a54290b..d811680d0f 100644 --- a/src/Locale/en/Consultation.json +++ b/src/Locale/en/Consultation.json @@ -37,5 +37,12 @@ "next_sessions": "Next Sessions", "no_changes": "No changes", "encounter_suggestion_edit_disallowed": "Not allowed to switch to this option in edit consultation", + "encounter_date_field_label__A": "Date & Time of Admission to the Facility", + "encounter_date_field_label__DC": "Date & Time of Domiciliary Care commencement", + "encounter_date_field_label__OP": "Date & Time of Out-patient visit", + "encounter_date_field_label__DD": "Date & Time of Consultation", + "encounter_date_field_label__HI": "Date & Time of Consultation", + "encounter_date_field_label__R": "Date & Time of Consultation", + "back_dated_encounter_date_caution": "You are creating an encounter for", "encounter_duration_confirmation": "The duration of this encounter would be" } \ No newline at end of file