From d84caf0c3a958273887831bb6af1c0ad61b921bc Mon Sep 17 00:00:00 2001
From: Jacob John Jeevan <40040905+Jacobjeevan@users.noreply.github.com>
Date: Sun, 10 Nov 2024 09:09:43 +0530
Subject: [PATCH 1/9] Ventilator mode/oxygen modality data on consultation page
(#8781)
* Ventilator Data
- Added ventilator data as table on Ventilator tab
- Added Marker Area to graphs under ventilator tab
* MarkerLine and MarkerArea
- To do: cleanup (only keep whichever one is chosen, cleanup commented out code)
* MarkLine, rm MarkArea code
- Choosing markLine as that represents the data accurately (when switching to bar graph)
* Rm markArea import
* added overflow to table/mobile view
* render most recent mode/modality on graph
* log fixes
* IV/NIV log text modification
* Fixes and cleanup
- Switched VentilatorPlot to use getDailyReports (instead of getDailyRoundsAnalyse).
- Changed end_date to be based on next daily round (rather than round with ventilator data)
- Pagination on top level (in the tab, instead of in Plots)
- Applies to both Table and the Graphs
* Cleanup
- Removed filtering items in VentorTable beforehand
- allowing to fetch the right end date
- as well as only combining rounds with same NIV/IV/Oxygen mode/modality if there are consecutive (i.e. no round in between them)
- VentilatorPlot
- adjust label position for the first data point (to avoid overflow of line label into y axis labels)
* Pagination Limit
- Added limit of 36 (same as before for pagination in VentilatorPlot)
* using date utils
* improvement suggestions
* Nitpick fixes
* type fix
* lint fix
---
public/locale/en.json | 20 ++
.../ConsultationVentilatorTab.tsx | 34 ++-
.../ConsultationDetails/Events/EventsList.tsx | 6 +
.../Facility/Consultations/VentilatorPlot.tsx | 275 ++++++++++++++----
.../Consultations/VentilatorTable.tsx | 129 ++++++++
.../components/BinaryChronologicalChart.tsx | 2 +-
.../Consultations/components/LinePlot.tsx | 32 +-
.../Consultations/components/ReactEcharts.tsx | 2 +
8 files changed, 443 insertions(+), 57 deletions(-)
create mode 100644 src/components/Facility/Consultations/VentilatorTable.tsx
diff --git a/public/locale/en.json b/public/locale/en.json
index b6ccb84de08..ef591130213 100644
--- a/public/locale/en.json
+++ b/public/locale/en.json
@@ -133,9 +133,13 @@
"ORAL_ISSUE__NO_ISSUE": "No issues",
"ORAL_ISSUE__ODYNOPHAGIA": "Odynophagia",
"OXYGEN_MODALITY__HIGH_FLOW_NASAL_CANNULA": "High Flow Nasal Cannula",
+ "OXYGEN_MODALITY__HIGH_FLOW_NASAL_CANNULA_short": "HFNC",
"OXYGEN_MODALITY__NASAL_PRONGS": "Nasal Prongs",
+ "OXYGEN_MODALITY__NASAL_PRONGS_short": "NP",
"OXYGEN_MODALITY__NON_REBREATHING_MASK": "Non Rebreathing Mask",
+ "OXYGEN_MODALITY__NON_REBREATHING_MASK_short": "NRM",
"OXYGEN_MODALITY__SIMPLE_FACE_MASK": "Simple Face Mask",
+ "OXYGEN_MODALITY__SIMPLE_FACE_MASK_short": "SFM",
"PRESCRIPTION_FREQUENCY_BD": "Twice daily",
"PRESCRIPTION_FREQUENCY_HS": "Night only",
"PRESCRIPTION_FREQUENCY_OD": "Once daily",
@@ -206,12 +210,19 @@
"URINATION_FREQUENCY__NORMAL": "Normal",
"VENTILATOR": "Detailed Update",
"VENTILATOR_MODE__CMV": "Control Mechanical Ventilation (CMV)",
+ "VENTILATOR_MODE__CMV_short": "CMV",
"VENTILATOR_MODE__PCV": "Pressure Control Ventilation (PCV)",
+ "VENTILATOR_MODE__PCV_short": "PCV",
"VENTILATOR_MODE__PC_SIMV": "Pressure Controlled SIMV (PC-SIMV)",
+ "VENTILATOR_MODE__PC_SIMV_short": "PC-SIMV",
"VENTILATOR_MODE__PSV": "C-PAP / Pressure Support Ventilation (PSV)",
+ "VENTILATOR_MODE__PSV_short": "C-PAP/PSV",
"VENTILATOR_MODE__SIMV": "Synchronised Intermittent Mandatory Ventilation (SIMV)",
+ "VENTILATOR_MODE__SIMV_short": "SIMV",
"VENTILATOR_MODE__VCV": "Volume Control Ventilation (VCV)",
+ "VENTILATOR_MODE__VCV_short": "VCV",
"VENTILATOR_MODE__VC_SIMV": "Volume Controlled SIMV (VC-SIMV)",
+ "VENTILATOR_MODE__VC_SIMV_short": "VC-SIMV",
"View Facility": "View Facility",
"aadhaar_number": "Aadhaar Number",
"aadhaar_number_will_not_be_stored": "Aadhaar number will not be stored by CARE",
@@ -611,6 +622,7 @@
"encounter_suggestion__OP": "Out-patient visit",
"encounter_suggestion__R": "Consultation",
"encounter_suggestion_edit_disallowed": "Not allowed to switch to this option in edit consultation",
+ "end_datetime": "End Date/Time",
"enter_aadhaar_number": "Enter a 12-digit Aadhaar ID",
"enter_aadhaar_otp": "Enter OTP sent to the registered mobile with Aadhaar",
"enter_abha_address": "Enter ABHA Address",
@@ -1145,6 +1157,7 @@
"spokes": "Spoke Facilities",
"srf_id": "SRF ID",
"staff_list": "Staff List",
+ "start_datetime": "Start Date/Time",
"start_dosage": "Start Dosage",
"state": "State",
"status": "Status",
@@ -1236,6 +1249,13 @@
"vacant": "Vacant",
"vehicle_preference": "Vehicle preference",
"vendor_name": "Vendor Name",
+ "ventilator_interface": "Respiratory Support Type",
+ "ventilator_log": "Ventilator Log",
+ "ventilator_modality": "Modality",
+ "ventilator_mode": "Ventilator Mode",
+ "ventilator_oxygen_modality": "Oxygen Modality",
+ "ventilator_oxygen_modality_oxygen_rate": "Oxygen Flow Rate",
+ "ventilator_spo2": "SpO₂",
"verify_and_link": "Verify and Link",
"verify_otp": "Verify OTP",
"verify_otp_error": "Failed to verify OTP. Please try again later.",
diff --git a/src/components/Facility/ConsultationDetails/ConsultationVentilatorTab.tsx b/src/components/Facility/ConsultationDetails/ConsultationVentilatorTab.tsx
index 1ded0ba7684..b26ea6e0e53 100644
--- a/src/components/Facility/ConsultationDetails/ConsultationVentilatorTab.tsx
+++ b/src/components/Facility/ConsultationDetails/ConsultationVentilatorTab.tsx
@@ -1,8 +1,30 @@
+import Loading from "@/components/Common/Loading";
import PageTitle from "@/components/Common/PageTitle";
import { ConsultationTabProps } from "@/components/Facility/ConsultationDetails/index";
import { VentilatorPlot } from "@/components/Facility/Consultations/VentilatorPlot";
+import VentilatorTable from "@/components/Facility/Consultations/VentilatorTable";
+
+import useFilters from "@/hooks/useFilters";
+
+import routes from "@/Utils/request/api";
+import useQuery from "@/Utils/request/useQuery";
export const ConsultationVentilatorTab = (props: ConsultationTabProps) => {
+ const { consultationId } = props;
+ const { qParams, Pagination, resultsPerPage } = useFilters({ limit: 36 });
+
+ const { loading: isLoading, data } = useQuery(routes.getDailyReports, {
+ pathParams: { consultationId },
+ query: {
+ limit: resultsPerPage,
+ offset: (qParams.page ? qParams.page - 1 : 0) * resultsPerPage,
+ },
+ });
+
+ if (isLoading) {
+ return
{t("start_datetime")} | +{t("end_datetime")} | +{t("ventilator_modality")} | ++ {`${t("ventilator_mode")} / ${t("ventilator_oxygen_modality")}`} + | +
---|
Dosage &
-- {prescriptions[0]?.dosage_type !== "PRN" - ? "Frequency" - : "Indicator"} -
- -{t("dosage")} &
++ {prescriptions[0]?.dosage_type !== "PRN" + ? t("frequency") + : t("indicator")} +
+{prescription.base_dosage}
+ ) : ( ++ {prescription.base_dosage} - {prescription.target_dosage} +
+ )} + ++ {prescription.dosage_type !== "PRN" + ? t("PRESCRIPTION_FREQUENCY_" + prescription.frequency) + : prescription.indicator} +
+{prescription.base_dosage}
- ) : ( -- {prescription.base_dosage} - {prescription.target_dosage} -
- )} - -- {prescription.dosage_type !== "PRN" - ? t("PRESCRIPTION_FREQUENCY_" + prescription.frequency) - : prescription.indicator} -
+