From e2a638b7350d4f25f04e1b89f55b5de4b1a581b2 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Tue, 30 Apr 2024 17:58:30 +0530 Subject: [PATCH 1/6] updated discharged patients page --- src/CAREUI/misc/PaginatedList.tsx | 12 +- .../Facility/DischargedPatientsList.tsx | 136 +++- src/Components/Patient/PatientFilter.tsx | 691 +++++++++--------- 3 files changed, 500 insertions(+), 339 deletions(-) diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index db68c6f042..ec270bf813 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -1,4 +1,4 @@ -import { createContext, useContext, useState } from "react"; +import { createContext, useContext, useEffect, useState } from "react"; import { PaginatedResponse, QueryRoute } from "../../Utils/request/types"; import useQuery, { QueryOptions } from "../../Utils/request/useQuery"; import ButtonV2, { @@ -33,6 +33,9 @@ function useContextualized() { interface Props extends QueryOptions> { route: QueryRoute>; perPage?: number; + queryCB?: ( + query: ReturnType>>, + ) => void; children: ( ctx: PaginatedListContext, query: ReturnType>>, @@ -43,6 +46,7 @@ export default function PaginatedList({ children, route, perPage = DEFAULT_PER_PAGE_LIMIT, + queryCB, ...queryOptions }: Props) { const [currentPage, setPage] = useState(1); @@ -57,6 +61,12 @@ export default function PaginatedList({ const items = query.data?.results ?? []; + useEffect(() => { + if (queryCB) { + queryCB(query); + } + }, [query]); + return ( (name: string, defaultValue?: T) => { + return { + name, + value: qParams[name] || defaultValue, + onChange: (e: FieldChangeEvent) => updateQuery({ [e.name]: e.value }), + className: "grow w-full mb-2", + }; + }; + + const [phone_number, setPhoneNumber] = useState(""); + const [phoneNumberError, setPhoneNumberError] = useState(""); + const [emergency_phone_number, setEmergencyPhoneNumber] = useState(""); + const [emergencyPhoneNumberError, setEmergencyPhoneNumberError] = + useState(""); + const [count, setCount] = useState(0); + + const setPhoneNum = (phone_number: string) => { + setPhoneNumber(phone_number); + if (phone_number.length >= 13) { + setPhoneNumberError(""); + updateQuery({ phone_number }); + return; + } + + if (phone_number === "+91" || phone_number === "") { + setPhoneNumberError(""); + qParams.phone_number && updateQuery({ phone_number: null }); + return; + } + + setPhoneNumberError("Enter a valid number"); + }; + + const setEmergencyPhoneNum = (emergency_phone_number: string) => { + setEmergencyPhoneNumber(emergency_phone_number); + if (emergency_phone_number.length >= 13) { + setEmergencyPhoneNumberError(""); + updateQuery({ emergency_phone_number }); + return; + } + + if (emergency_phone_number === "+91" || emergency_phone_number === "") { + setEmergencyPhoneNumberError(""); + qParams.emergency_phone_number && + updateQuery({ emergency_phone_number: null }); + return; + } + + setEmergencyPhoneNumberError("Enter a valid number"); + }; return ( - updateQuery({ name: e.value }))} - />
navigate("/patients")} isTab2Active /> + advancedFilter.setShow(true)} + /> } > +
+
+
+ +
+
+
+
+
+ + +
+
+ setPhoneNum(e.value)} + error={phoneNumberError} + types={["mobile", "landline"]} + /> + setEmergencyPhoneNum(e.value)} + error={emergencyPhoneNumberError} + types={["mobile", "landline"]} + /> +
+
+
+
[ordering()]} />
@@ -70,9 +178,12 @@ const DischargedPatientsList = ({ route={routes.listFacilityDischargedPatients} pathParams={{ facility_external_id }} query={{ ordering: "-modified_date", ...qParams }} + queryCB={(query) => { + setCount(query.data?.count || 0); + }} > {() => ( -
+
{t("discharged_patients_empty")} @@ -99,6 +210,11 @@ const DischargedPatientsList = ({
)} + ); }; diff --git a/src/Components/Patient/PatientFilter.tsx b/src/Components/Patient/PatientFilter.tsx index 79a0424217..efbdc09d0d 100644 --- a/src/Components/Patient/PatientFilter.tsx +++ b/src/Components/Patient/PatientFilter.tsx @@ -318,17 +318,23 @@ export default function PatientFilter(props: any) { onChange={(v) => setFilterState({ ...filterState, gender: v })} />
-
- Category - o.text} - optionValue={(o) => o.id} - value={filterState.category} - onChange={(v) => setFilterState({ ...filterState, category: v })} - /> -
+ {!props.discharged && ( + <> +
+ Category + o.text} + optionValue={(o) => o.id} + value={filterState.category} + onChange={(v) => + setFilterState({ ...filterState, category: v }) + } + /> +
+ + )}
Age
@@ -360,72 +366,81 @@ export default function PatientFilter(props: any) { />
-
- Admitted to (Bed Types) - o.id} - optionLabel={(o) => o.text} - onChange={(o) => - setFilterState({ - ...filterState, - last_consultation_admitted_bed_type_list: o, - }) - } - /> -
-
- Discharge Reason - o.id} - optionLabel={(o) => o.text} - onChange={(o) => - setFilterState({ - ...filterState, - last_consultation__new_discharge_reason: o, - }) - } - /> -
-
- Telemedicine - o.text} - optionValue={(o) => o.id} - value={filterState.last_consultation_is_telemedicine} - onChange={(v) => - setFilterState({ - ...filterState, - last_consultation_is_telemedicine: v, - }) - } - /> -
-
- Respiratory Support - o.text} - optionValue={(o) => o.id} - value={filterState.ventilator_interface} - onChange={(v) => - setFilterState({ - ...filterState, - ventilator_interface: v, - }) - } - /> -
+ {!props.discharged && ( + <> +
+ + Admitted to (Bed Types) + + o.id} + optionLabel={(o) => o.text} + onChange={(o) => + setFilterState({ + ...filterState, + last_consultation_admitted_bed_type_list: o, + }) + } + /> +
+ +
+ Discharge Reason + o.id} + optionLabel={(o) => o.text} + onChange={(o) => + setFilterState({ + ...filterState, + last_consultation__new_discharge_reason: o, + }) + } + /> +
+ +
+ Telemedicine + o.text} + optionValue={(o) => o.id} + value={filterState.last_consultation_is_telemedicine} + onChange={(v) => + setFilterState({ + ...filterState, + last_consultation_is_telemedicine: v, + }) + } + /> +
+ +
+ Respiratory Support + o.text} + optionValue={(o) => o.id} + value={filterState.ventilator_interface} + onChange={(v) => + setFilterState({ + ...filterState, + ventilator_interface: v, + }) + } + /> +
+ + )}
Is Antenatal
-
- Review Missed - (o === "true" ? "Yes" : "No")} - value={filterState.review_missed} - onChange={(v) => - setFilterState({ ...filterState, review_missed: v }) - } - /> -
-
- Is Medico-Legal Case - - o === "true" ? "Medico-Legal" : "Non-Medico-Legal" - } - value={filterState.last_consultation_medico_legal_case} - onChange={(v) => - setFilterState({ - ...filterState, - last_consultation_medico_legal_case: v, - }) - } - /> -
+ {!props.discharged && ( + <> +
+ Review Missed + (o === "true" ? "Yes" : "No")} + value={filterState.review_missed} + onChange={(v) => + setFilterState({ ...filterState, review_missed: v }) + } + /> +
+
+ + Is Medico-Legal Case + + + o === "true" ? "Medico-Legal" : "Non-Medico-Legal" + } + value={filterState.last_consultation_medico_legal_case} + onChange={(v) => + setFilterState({ + ...filterState, + last_consultation_medico_legal_case: v, + }) + } + /> +
+ + )}
- - ICD-11 Diagnoses based - - } - expanded - className="w-full" - > - {FILTER_BY_DIAGNOSES_KEYS.map((name) => ( - - ))} - + {!props.discharged && ( + <> + + ICD-11 Diagnoses based + + } + expanded + className="w-full" + > + {FILTER_BY_DIAGNOSES_KEYS.map((name) => ( + + ))} + + + )} @@ -564,217 +589,227 @@ export default function PatientFilter(props: any) { /> - - Geography based - - } - expanded={true} - className="rounded-md" - > -
-
- Facility - setFilterWithRef("facility", obj)} - /> -
- {filterState.facility && ( -
- Location - - setFilterState({ - ...filterState, - last_consultation_current_bed__location: selected, - }) - } - /> -
- )} -
- Facility type - o.text} - optionValue={(o) => o.text} - value={filterState.facility_type} - onChange={(v) => - setFilterState({ ...filterState, facility_type: v }) - } - optionIcon={() => ( - + {!props.discharged && ( + <> + + Geography based + + } + expanded={true} + className="rounded-md" + > +
+
+ Facility + setFilterWithRef("facility", obj)} + /> +
+ {filterState.facility && ( +
+ Location + + setFilterState({ + ...filterState, + last_consultation_current_bed__location: selected, + }) + } + /> +
)} - /> -
-
- LSG Body -
- setFilterWithRef("lsgBody", obj)} - optionLabel={(option) => option.name} - compareBy="id" - /> -
-
+
+ Facility type + o.text} + optionValue={(o) => o.text} + value={filterState.facility_type} + onChange={(v) => + setFilterState({ ...filterState, facility_type: v }) + } + optionIcon={() => ( + + )} + /> +
+
+ LSG Body +
+ setFilterWithRef("lsgBody", obj)} + optionLabel={(option) => option.name} + compareBy="id" + /> +
+
-
- District - setFilterWithRef("district", obj)} - errors={""} - /> -
-
- - - COVID Details based - - } - expanded={false} - className="w-full rounded-md" - > -
- {kasp_enabled && ( -
- {kasp_string} - - o ? `Show ${kasp_string}` : `Show Non ${kasp_string}` - } - value={filterState.is_kasp} - onChange={(v) => setFilterState({ ...filterState, is_kasp: v })} - /> +
+ District + setFilterWithRef("district", obj)} + errors={""} + /> +
- )} - -
- COVID Disease status - o} - value={filterState.disease_status} - onChange={(v) => - setFilterState({ ...filterState, disease_status: v }) - } - /> -
-
- COVID Vaccinated - text} - optionValue={({ id }) => id} - optionIcon={({ id }) => ( - <> - - {id} - + + + COVID Details based + + } + expanded={false} + className="w-full rounded-md" + > +
+ {kasp_enabled && ( +
+ {kasp_string} + + o ? `Show ${kasp_string}` : `Show Non ${kasp_string}` + } + value={filterState.is_kasp} + onChange={(v) => + setFilterState({ ...filterState, is_kasp: v }) + } + /> +
)} - value={filterState.number_of_doses} - onChange={(v) => - setFilterState({ ...filterState, number_of_doses: v }) - } - /> -
-
- - Declared as COVID Positive - - o.text} - optionValue={(o) => o.id} - value={filterState.is_declared_positive} - onChange={(v) => - setFilterState({ ...filterState, is_declared_positive: v }) - } - /> -
-
- SRF ID} - value={filterState.srf_id} - onChange={handleFormFieldChange} - errorClassName="hidden" - /> -
-
- CoWIN ID} - value={filterState.covin_id} - onChange={handleFormFieldChange} - errorClassName="hidden" - /> -
+
+ + COVID Disease status + + o} + value={filterState.disease_status} + onChange={(v) => + setFilterState({ ...filterState, disease_status: v }) + } + /> +
+
+ COVID Vaccinated + text} + optionValue={({ id }) => id} + optionIcon={({ id }) => ( + <> + + {id} + + )} + value={filterState.number_of_doses} + onChange={(v) => + setFilterState({ ...filterState, number_of_doses: v }) + } + /> +
+
+ + Declared as COVID Positive + + o.text} + optionValue={(o) => o.id} + value={filterState.is_declared_positive} + onChange={(v) => + setFilterState({ ...filterState, is_declared_positive: v }) + } + /> +
- - +
+ SRF ID} + value={filterState.srf_id} + onChange={handleFormFieldChange} + errorClassName="hidden" + /> +
+
+ CoWIN ID} + value={filterState.covin_id} + onChange={handleFormFieldChange} + errorClassName="hidden" + /> +
- -
- + + + + +
+
+ + )} ); } From 6828c5e9589f994cd21fb4567f15aa4c84f67799 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Tue, 30 Apr 2024 18:07:20 +0530 Subject: [PATCH 2/6] fixed filter badges --- .../Facility/DischargedPatientsList.tsx | 45 +++++++++- src/Components/Patient/PatientFilter.tsx | 90 ++++++++++--------- 2 files changed, 93 insertions(+), 42 deletions(-) diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx index 4c36a34139..eddd4a7b08 100644 --- a/src/Components/Facility/DischargedPatientsList.tsx +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -23,6 +23,7 @@ import CountBlock from "../../CAREUI/display/Count"; import { FieldChangeEvent } from "../Form/FormFields/Utils"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; import { useState } from "react"; +import { parseOptionId } from "../../Common/utils"; const DischargedPatientsList = ({ facility_external_id, @@ -172,7 +173,49 @@ const DischargedPatientsList = ({
- [ordering()]} /> + [ + phoneNumber("Primary number", "phone_number"), + phoneNumber("Emergency number", "emergency_phone_number"), + badge("Patient name", "name"), + badge("IP/OP number", "patient_no"), + ...dateRange("Modified", "modified_date"), + ...dateRange("Created", "created_date"), + badge("No. of vaccination doses", "number_of_doses"), + kasp(), + badge("COWIN ID", "covin_id"), + badge("Is Antenatal", "is_antenatal"), + badge("Review Missed", "review_missed"), + badge("Facility Type", "facility_type"), + ordering(), + badge("Disease Status", "disease_status"), + value( + "Respiratory Support", + "ventilator_interface", + qParams.ventilator_interface && + t(`RESPIRATORY_SUPPORT_${qParams.ventilator_interface}`), + ), + value( + "Gender", + "gender", + parseOptionId(GENDER_TYPES, qParams.gender) || "", + ), + ...range("Age", "age"), + badge("SRF ID", "srf_id"), + badge("Declared Status", "is_declared_positive"), + ...dateRange("Result", "date_of_result"), + ...dateRange("Declared positive", "date_declared_positive"), + ...dateRange("Last vaccinated", "last_vaccinated_date"), + ]} + />
- - - + {!props.discharged && ( + <> + + + + + )}
{!props.discharged && ( From 7624a225b004b16e29ad5aba79c5023fbe54b38f Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Sat, 11 May 2024 04:09:19 +0530 Subject: [PATCH 3/6] updated filters --- src/Components/Patient/PatientFilter.tsx | 73 +++++++++++++----------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/src/Components/Patient/PatientFilter.tsx b/src/Components/Patient/PatientFilter.tsx index 756b521984..23fea04793 100644 --- a/src/Components/Patient/PatientFilter.tsx +++ b/src/Components/Patient/PatientFilter.tsx @@ -387,25 +387,27 @@ export default function PatientFilter(props: any) { } /> - -
- Discharge Reason - o.id} - optionLabel={(o) => o.text} - onChange={(o) => - setFilterState({ - ...filterState, - last_consultation__new_discharge_reason: o, - }) - } - /> -
- + + )} +
+ Discharge Reason + o.id} + optionLabel={(o) => o.text} + onChange={(o) => + setFilterState({ + ...filterState, + last_consultation__new_discharge_reason: o, + }) + } + /> +
+ {!props.discharged && ( + <>
Telemedicine - + + )} + + + {!props.discharged && ( + <> Date: Wed, 15 May 2024 11:44:12 +0530 Subject: [PATCH 4/6] fixed responsiveness and removed geo filters --- .../Facility/DischargedPatientsList.tsx | 2 +- src/Components/Patient/PatientFilter.tsx | 56 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx index 9cc90aa656..bc49989742 100644 --- a/src/Components/Facility/DischargedPatientsList.tsx +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -104,7 +104,7 @@ const DischargedPatientsList = ({ }} options={ <> -
+
-
- Facility - setFilterWithRef("facility", obj)} - /> -
+ {!props.dischargePage && ( +
+ Facility + setFilterWithRef("facility", obj)} + /> +
+ )} {filterState.facility && (
Location @@ -609,22 +611,24 @@ export default function PatientFilter(props: any) { />
)} -
- Facility type - o.text} - optionValue={(o) => o.text} - value={filterState.facility_type} - onChange={(v) => - setFilterState({ ...filterState, facility_type: v }) - } - optionIcon={() => ( - - )} - /> -
+ {!props.dischargePage && ( +
+ Facility type + o.text} + optionValue={(o) => o.text} + value={filterState.facility_type} + onChange={(v) => + setFilterState({ ...filterState, facility_type: v }) + } + optionIcon={() => ( + + )} + /> +
+ )}
LSG Body
From bccdd2426bdd7732077cbf65d2606a95b8131cda Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Wed, 15 May 2024 12:05:29 +0530 Subject: [PATCH 5/6] changed per page limit --- src/Components/Facility/DischargedPatientsList.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx index bc49989742..1494693542 100644 --- a/src/Components/Facility/DischargedPatientsList.tsx +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -218,6 +218,7 @@ const DischargedPatientsList = ({ />
Date: Wed, 15 May 2024 12:13:02 +0530 Subject: [PATCH 6/6] switched to 12 --- src/Components/Facility/DischargedPatientsList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/DischargedPatientsList.tsx b/src/Components/Facility/DischargedPatientsList.tsx index 1494693542..95a888a86c 100644 --- a/src/Components/Facility/DischargedPatientsList.tsx +++ b/src/Components/Facility/DischargedPatientsList.tsx @@ -218,7 +218,7 @@ const DischargedPatientsList = ({ />