From 654123e07eb7722f00a758d7d54ff75290506028 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 27 Nov 2023 13:48:58 +0530 Subject: [PATCH 1/5] Rename `admission_date` to `encounter_date` --- src/Components/DeathReport/DeathReport.tsx | 4 +- src/Components/Facility/ConsultationCard.tsx | 4 +- .../Facility/ConsultationDetails/index.tsx | 10 +-- src/Components/Facility/ConsultationForm.tsx | 65 +++++++++---------- src/Components/Facility/DischargeModal.tsx | 6 +- src/Components/Facility/TreatmentSummary.tsx | 2 +- src/Components/Facility/models.tsx | 2 +- src/Components/Patient/ManagePatients.tsx | 18 ++--- src/Components/Patient/PatientFilter.tsx | 30 ++++----- src/Components/Patient/PatientInfoCard.tsx | 2 +- src/Components/Shifting/ShiftDetails.tsx | 5 +- 11 files changed, 71 insertions(+), 77 deletions(-) diff --git a/src/Components/DeathReport/DeathReport.tsx b/src/Components/DeathReport/DeathReport.tsx index 9908b4fa852..3901996e119 100644 --- a/src/Components/DeathReport/DeathReport.tsx +++ b/src/Components/DeathReport/DeathReport.tsx @@ -115,8 +115,8 @@ export default function PrintDeathReport(props: { id: string }) { date_declared_positive: res.data?.date_declared_positive ? dayjs(res.data?.date_declared_positive).toDate() : "", - date_of_admission: res.data?.last_consultation?.admission_date - ? dayjs(res.data?.last_consultation?.admission_date).toDate() + date_of_admission: res.data?.last_consultation?.encounter_date + ? dayjs(res.data?.last_consultation?.encounter_date).toDate() : "", date_of_test: res.data?.date_of_test ? dayjs(res.data?.date_of_test).toDate() diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index 2c0fa54db21..c402853f366 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -63,14 +63,14 @@ export const ConsultationCard = (props: ConsultationProps) => { )} - {itemData.admitted && itemData.admission_date && ( + {itemData.admitted && itemData.encounter_date && (
Admitted on
- {formatDateTime(itemData.admission_date)} + {formatDateTime(itemData.encounter_date)} {itemData.is_readmission && ( { name: consultationData.suggestion === "A" ? `Admitted on ${formatDateTime( - consultationData.admission_date! + consultationData.encounter_date! )}` : consultationData.suggestion_text, }, @@ -400,19 +400,19 @@ export const ConsultationDetails = (props: any) => { {consultationData.admitted_to}
- {(consultationData.admission_date ?? + {(consultationData.encounter_date ?? consultationData.discharge_date) && (
{relativeTime( consultationData.discharge_date ? consultationData.discharge_date - : consultationData.admission_date + : consultationData.encounter_date )}
)}
- {consultationData.admission_date && - formatDateTime(consultationData.admission_date)} + {consultationData.encounter_date && + formatDateTime(consultationData.encounter_date)} {consultationData.discharge_date && ` - ${formatDateTime(consultationData.discharge_date)}`}
diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 091be6b5968..22fb50ab9b6 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -89,7 +89,7 @@ type FormDetails = { admitted: BooleanStrings; admitted_to: string; category: string; - admission_date?: Date; + encounter_date?: Date; icu_admission_date?: Date; discharge_date: null; referred_to?: string; @@ -139,7 +139,7 @@ const initForm: FormDetails = { admitted: "false", admitted_to: "", category: "", - admission_date: new Date(), + encounter_date: new Date(), icu_admission_date: undefined, discharge_date: null, referred_to: "", @@ -375,7 +375,7 @@ export const ConsultationForm = (props: any) => { const formData = { ...res.data, symptoms_onset_date: isoStringToDate(res.data.symptoms_onset_date), - admission_date: isoStringToDate(res.data.admission_date), + encounter_date: isoStringToDate(res.data.encounter_date), icu_admission_date: isoStringToDate(res.data.icu_admission_date), admitted: res.data.admitted ? String(res.data.admitted) : "false", admitted_to: res.data.admitted_to ? res.data.admitted_to : "", @@ -483,11 +483,8 @@ export const ConsultationForm = (props: any) => { invalidForm = true; } return; - case "admission_date": - if ( - ["A", "DC"].includes(state.form.suggestion) && - !state.form[field] - ) { + case "encounter_date": + if (!state.form[field]) { errors[field] = "Field is required"; invalidForm = true; } @@ -679,9 +676,7 @@ export const ConsultationForm = (props: any) => { suggestion: state.form.suggestion, route_to_facility: state.form.route_to_facility, admitted: state.form.suggestion === "A", - admission_date: ["A", "DC"].includes(state.form.suggestion) - ? state.form.admission_date - : undefined, + encounter_date: state.form.encounter_date, category: state.form.category, is_kasp: state.form.is_kasp, kasp_enabled_date: JSON.parse(state.form.is_kasp) ? new Date() : null, @@ -1191,32 +1186,30 @@ export const ConsultationForm = (props: any) => { )} - {["A", "DC"].includes(state.form.suggestion) && ( -
+ - -
- )} + max={dayjs().format("YYYY-MM-DDTHH:mm")} + /> +
{state.form.route_to_facility && [20, 30].includes(state.form.route_to_facility) && ( diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 138e74fb9b9..94128c9407e 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -272,7 +272,7 @@ const DischargeModal = ({ name="discharge_date" value={dayjs(preDischargeForm?.discharge_date).toDate()} min={dayjs( - consultationData?.admission_date ?? + consultationData?.encounter_date ?? consultationData?.created_date ).toDate()} disableFuture={true} @@ -306,7 +306,7 @@ const DischargeModal = ({ }); }} required - min={dayjs(consultationData?.admission_date).format( + min={dayjs(consultationData?.encounter_date).format( "YYYY-MM-DDTHH:mm" )} max={dayjs().format("YYYY-MM-DDTHH:mm")} @@ -335,7 +335,7 @@ const DischargeModal = ({ name="discharge_date" value={dayjs(preDischargeForm.discharge_date).toDate()} min={dayjs( - consultationData?.admission_date ?? + consultationData?.encounter_date ?? consultationData?.created_date ).toDate()} disableFuture={true} diff --git a/src/Components/Facility/TreatmentSummary.tsx b/src/Components/Facility/TreatmentSummary.tsx index 3ff5d47d5e0..f8c38d40008 100644 --- a/src/Components/Facility/TreatmentSummary.tsx +++ b/src/Components/Facility/TreatmentSummary.tsx @@ -139,7 +139,7 @@ const TreatmentSummary = (props: any) => { Date of admission : {consultationData.admitted - ? formatDateTime(consultationData.admission_date) + ? formatDateTime(consultationData.encounter_date) : " --/--/----"}
diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 8dcc5f71e0d..cadd5492ad3 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -91,7 +91,7 @@ export type PatientCategory = | "Critical"; export interface ConsultationModel { - admission_date?: string; + encounter_date?: string; icu_admission_date?: string; admitted?: boolean; test_id?: string; diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 6a52d68130c..678dd83a025 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -194,10 +194,10 @@ export const PatientManager = () => { date_of_result_after: qParams.date_of_result_after || undefined, last_consultation_medico_legal_case: qParams.last_consultation_medico_legal_case || undefined, - last_consultation_admission_date_before: - qParams.last_consultation_admission_date_before || undefined, - last_consultation_admission_date_after: - qParams.last_consultation_admission_date_after || undefined, + last_consultation_encounter_date_before: + qParams.last_consultation_encounter_date_before || undefined, + last_consultation_encounter_date_after: + qParams.last_consultation_encounter_date_after || undefined, last_consultation_discharge_date_before: qParams.last_consultation_discharge_date_before || undefined, last_consultation_discharge_date_after: @@ -239,8 +239,8 @@ export const PatientManager = () => { [params.date_of_result_before, params.date_of_result_after], [params.last_vaccinated_date_before, params.last_vaccinated_date_after], [ - params.last_consultation_admission_date_before, - params.last_consultation_admission_date_after, + params.last_consultation_encounter_date_before, + params.last_consultation_encounter_date_after, ], [ params.last_consultation_discharge_date_before, @@ -345,8 +345,8 @@ export const PatientManager = () => { }, [ dispatch, qParams.last_consultation_medico_legal_case, - qParams.last_consultation_admission_date_before, - qParams.last_consultation_admission_date_after, + qParams.last_consultation_encounter_date_before, + qParams.last_consultation_encounter_date_after, qParams.last_consultation_discharge_date_before, qParams.last_consultation_discharge_date_after, qParams.age_max, @@ -964,7 +964,7 @@ export const PatientManager = () => { badge("IP/OP number", "patient_no"), ...dateRange("Modified", "modified_date"), ...dateRange("Created", "created_date"), - ...dateRange("Admitted", "last_consultation_admission_date"), + ...dateRange("Admitted", "last_consultation_encounter_date"), ...dateRange("Discharged", "last_consultation_discharge_date"), // Admitted to type badges badge("No. of vaccination doses", "number_of_doses"), diff --git a/src/Components/Patient/PatientFilter.tsx b/src/Components/Patient/PatientFilter.tsx index 4ab7f14c895..b136433487e 100644 --- a/src/Components/Patient/PatientFilter.tsx +++ b/src/Components/Patient/PatientFilter.tsx @@ -68,10 +68,10 @@ export default function PatientFilter(props: any) { date_declared_positive: filter.date_declared_positive || null, last_consultation_medico_legal_case: filter.last_consultation_medico_legal_case || null, - last_consultation_admission_date_before: - filter.last_consultation_admission_date_before || null, - last_consultation_admission_date_after: - filter.last_consultation_admission_date_after || null, + last_consultation_encounter_date_before: + filter.last_consultation_encounter_date_before || null, + last_consultation_encounter_date_after: + filter.last_consultation_encounter_date_after || null, last_consultation_discharge_date_before: filter.last_consultation_discharge_date_before || null, last_consultation_discharge_date_after: @@ -126,8 +126,8 @@ export default function PatientFilter(props: any) { date_of_result: null, date_declared_positive: null, last_consultation_medico_legal_case: null, - last_consultation_admission_date_before: "", - last_consultation_admission_date_after: "", + last_consultation_encounter_date_before: "", + last_consultation_encounter_date_after: "", last_consultation_discharge_date_before: "", last_consultation_discharge_date_after: "", last_consultation_admitted_to_list: [], @@ -237,8 +237,8 @@ export default function PatientFilter(props: any) { age_max, date_of_result, last_consultation_medico_legal_case, - last_consultation_admission_date_before, - last_consultation_admission_date_after, + last_consultation_encounter_date_before, + last_consultation_encounter_date_after, last_consultation_discharge_date_before, last_consultation_discharge_date_after, last_consultation_admitted_bed_type_list, @@ -279,11 +279,11 @@ export default function PatientFilter(props: any) { date_of_result: dateQueryString(date_of_result), last_consultation_medico_legal_case: last_consultation_medico_legal_case || "", - last_consultation_admission_date_before: dateQueryString( - last_consultation_admission_date_before + last_consultation_encounter_date_before: dateQueryString( + last_consultation_encounter_date_before ), - last_consultation_admission_date_after: dateQueryString( - last_consultation_admission_date_after + last_consultation_encounter_date_after: dateQueryString( + last_consultation_encounter_date_after ), last_consultation_discharge_date_before: dateQueryString( last_consultation_discharge_date_before @@ -539,13 +539,13 @@ export default function PatientFilter(props: any) { /> import("../Common/Loading")); @@ -316,7 +317,7 @@ export default function ShiftDetails(props: { id: string }) { const printData = (data: any) => { const patientData = data.patient_object; - const consultation = data.patient.last_consultation; + const consultation = data.patient.last_consultation as ConsultationModel; const patientGender = GENDER_TYPES.find( (i) => i.id === patientData?.gender )?.text; @@ -409,7 +410,7 @@ export default function ShiftDetails(props: { id: string }) { {t("date_of_admission")}:{" "} {formatDateTime( - consultation.admission_date || consultation.created_date + consultation.encounter_date || consultation.created_date ) || "-"}
From b4c8de2edc013d4edd60d679ec229a5f8930f5dc Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Mon, 27 Nov 2023 14:00:15 +0530 Subject: [PATCH 2/5] Whitelabel fields --- src/Common/constants.tsx | 5 ++++- src/Components/Facility/ConsultationForm.tsx | 20 ++++++++++++++------ src/Components/Facility/models.tsx | 3 ++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 065e7ccd759..1a6e9f3e77b 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -330,7 +330,10 @@ export const CONSULTATION_SUGGESTION = [ { id: "OP", text: "OP Consultation" }, { id: "DC", text: "Domiciliary Care" }, { id: "DD", text: "Declare Death" }, -]; +] as const; + +export type ConsultationSuggestionValue = + (typeof CONSULTATION_SUGGESTION)[number]["id"]; export const ADMITTED_TO = [ { id: "1", text: "Isolation" }, diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 22fb50ab9b6..c267fcca015 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, + ConsultationSuggestionValue, PATIENT_CATEGORIES, REVIEW_AT_CHOICES, TELEMEDICINE_ACTIONS, @@ -82,7 +83,7 @@ type FormDetails = { symptoms: number[]; other_symptoms: string; symptoms_onset_date?: Date; - suggestion: string; + suggestion: ConsultationSuggestionValue; route_to_facility?: RouteToFacility; patient: string; facility: string; @@ -1120,7 +1121,7 @@ export const ConsultationForm = (props: any) => { label="Decision after consultation" {...selectField("suggestion")} options={CONSULTATION_SUGGESTION.filter( - ({ deprecated }) => !deprecated + (option) => !("deprecated" in option) )} />
@@ -1197,11 +1198,18 @@ export const ConsultationForm = (props: any) => { > Date: Mon, 27 Nov 2023 15:02:51 +0530 Subject: [PATCH 3/5] fix colaescing issue --- src/Components/Patient/PatientInfoCard.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Components/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index 471c5562c0c..43cc606e6fb 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -290,13 +290,7 @@ export default function PatientInfoCard(props: { suggestion.id === consultation?.suggestion )?.text }{" "} - on{" "} - {formatDateTime( - ["A", "DC"].includes(consultation?.suggestion ?? "") - ? consultation?.encounter_date - : consultation?.created_date - )} - , + on {formatDateTime(consultation.encounter_date)}, {consultation?.discharge_reason === "EXP" ? ( {" "} From 4b7bd949a154cfd41af85e4385d7b73f69b226ba Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 5 Dec 2023 18:55:52 +0530 Subject: [PATCH 4/5] fix minor bug --- src/Components/Facility/ConsultationDetails/index.tsx | 4 ++-- src/Components/Facility/models.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 4f948b88a1d..0af071984b1 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -345,8 +345,8 @@ export const ConsultationDetails = (props: any) => { {consultationData.admitted_to} - {(consultationData.encounter_date ?? - consultationData.discharge_date) && ( + {(consultationData.discharge_date ?? + consultationData.encounter_date) && (
{relativeTime( consultationData.discharge_date diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 7df1db93620..f3ef6b03dfd 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -92,7 +92,7 @@ export type PatientCategory = | "Critical"; export interface ConsultationModel { - encounter_date?: string; + encounter_date: string; icu_admission_date?: string; admitted?: boolean; test_id?: string; From 6092d77de6355ff43436395f3013cbe72fc4021f Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 6 Dec 2023 17:56:56 +0530 Subject: [PATCH 5/5] minor fix --- src/Components/Facility/ConsultationForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index 8be79862e9e..90c25a731be 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -489,7 +489,7 @@ export const ConsultationForm = (props: any) => { errors[field] = "Field is required"; invalidForm = true; } - if (dayjs(state.form.admission_date).isBefore(dayjs("2000-01-01"))) { + if (dayjs(state.form.encounter_date).isBefore(dayjs("2000-01-01"))) { errors[field] = "Admission date cannot be before 01/01/2000"; invalidForm = true; }