From 90c433af0b23698d36d34cc32047041b52991612 Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Tue, 2 Apr 2024 08:51:37 +0530 Subject: [PATCH 1/6] Ventilator Parameters Input - Validate Consultation Bed for Linked Ventilator Asset is getting resolved --- src/Components/Common/DialogModal.res | 20 ++++++++++++++++++ .../CriticalCare__API.tsx | 21 +++++++++++++++++++ ...iticalCare__VentilatorParametersEditor.res | 17 +++++++++++++++ .../Facility/Consultations/Beds.res | 13 ++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 src/Components/Common/DialogModal.res create mode 100644 src/Components/Facility/Consultations/Beds.res diff --git a/src/Components/Common/DialogModal.res b/src/Components/Common/DialogModal.res new file mode 100644 index 00000000000..17bfbdd6d9a --- /dev/null +++ b/src/Components/Common/DialogModal.res @@ -0,0 +1,20 @@ +type reactClass +module DialogModal = { + @module("./Dialog.tsx") @react.component + external make: ( + ~title: React.element, + ~show: bool, + ~onClose: unit => unit, + ~className: string, + ~children: React.element, + ) => React.element = "default" +} + +@react.component +let make = ( + ~title: React.element, + ~show: bool, + ~onClose: unit => unit, + ~className: string, + ~children: React.element, +) => {children} \ No newline at end of file diff --git a/src/Components/CriticalCareRecording/CriticalCare__API.tsx b/src/Components/CriticalCareRecording/CriticalCare__API.tsx index 48b58faa167..7701b658f27 100644 --- a/src/Components/CriticalCareRecording/CriticalCare__API.tsx +++ b/src/Components/CriticalCareRecording/CriticalCare__API.tsx @@ -1,4 +1,6 @@ import { fireRequestV2 } from "../../Redux/fireRequest"; +import routes from "../../Redux/api"; +import request from "../../Utils/request/request"; export const loadDailyRound = ( consultationId: string, @@ -24,3 +26,22 @@ export const updateDailyRound = ( id, }); }; + +export const getAsset = (consultationId: string) => { + return request(routes.listConsultationBeds, { + query: { consultation: consultationId }, + }).then((result) => { + console.log( + "result: ", + result.data?.results[0].assets_objects?.filter( + (asset) => asset.asset_class == "VENTILATOR" + ) + ); + const data = result.data?.results[0].assets_objects?.filter( + (asset) => asset.asset_class == "VENTILATOR" + ); + console.log(data?.length); + return data?.length; + }); + // return len +}; diff --git a/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res b/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res index 0e928e57f38..dad6929fc26 100644 --- a/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res +++ b/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res @@ -5,6 +5,9 @@ open CriticalCare__Types external updateDailyRound: (string, string, Js.Json.t, _ => unit, _ => unit) => unit = "updateDailyRound" +@module("../CriticalCare__API") +external getAsset: (string) => Js.Promise.t = "getAsset"; + open VentilatorParameters let string_of_int = data => Belt.Option.mapWithDefault(data, "", Js.Int.toString) @@ -206,6 +209,8 @@ let initialState: VentilatorParameters.t => VentilatorParameters.state = ventila @react.component let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId, ~updateCB) => { let (state, send) = React.useReducer(reducer, initialState(ventilatorParameters)) + let (isOpen, setIsOpen) = React.useState(() => false); + let toggleOpen = () => setIsOpen(prevState => !prevState); let editor = switch state.ventilator_interface { | INVASIVE => @@ -286,6 +291,18 @@ let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId, className="btn btn-primary btn-large w-full"> {str("Update Details")} + toggleOpen()} + className="md:max-w-3xl" + > + toggleOpen()} + /> + } diff --git a/src/Components/Facility/Consultations/Beds.res b/src/Components/Facility/Consultations/Beds.res new file mode 100644 index 00000000000..72df9cec62a --- /dev/null +++ b/src/Components/Facility/Consultations/Beds.res @@ -0,0 +1,13 @@ +type reactClass +module Beds = { + @module("./Beds.tsx") @react.component + external make: ( + ~patientId: string, + ~consultationId: string, + ~setState: unit => unit, + ) => React.element = "default" +} + +@react.component +let make = (~patientId: string, ~consultationId: string, ~setState: unit => unit) => + \ No newline at end of file From 24383f31d5d8c6bdc45d92f0480115d0ce9e3687 Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Fri, 5 Apr 2024 21:30:32 +0530 Subject: [PATCH 2/6] done --- src/Components/Common/DialogModal.res | 2 +- .../CriticalCare__API.tsx | 17 ++--- .../Recording/CriticalCare__Recording.res | 2 + ...iticalCare__VentilatorParametersEditor.res | 74 +++++++++++++------ .../Facility/Consultations/Beds.res | 9 ++- 5 files changed, 66 insertions(+), 38 deletions(-) diff --git a/src/Components/Common/DialogModal.res b/src/Components/Common/DialogModal.res index 17bfbdd6d9a..ae03ad8139c 100644 --- a/src/Components/Common/DialogModal.res +++ b/src/Components/Common/DialogModal.res @@ -17,4 +17,4 @@ let make = ( ~onClose: unit => unit, ~className: string, ~children: React.element, -) => {children} \ No newline at end of file +) => {children} diff --git a/src/Components/CriticalCareRecording/CriticalCare__API.tsx b/src/Components/CriticalCareRecording/CriticalCare__API.tsx index 7701b658f27..e2c228d3810 100644 --- a/src/Components/CriticalCareRecording/CriticalCare__API.tsx +++ b/src/Components/CriticalCareRecording/CriticalCare__API.tsx @@ -27,21 +27,16 @@ export const updateDailyRound = ( }); }; -export const getAsset = (consultationId: string) => { - return request(routes.listConsultationBeds, { +export const getAsset = ( + consultationId: string, + setAsset: React.Dispatch> +) => { + request(routes.listConsultationBeds, { query: { consultation: consultationId }, }).then((result) => { - console.log( - "result: ", - result.data?.results[0].assets_objects?.filter( - (asset) => asset.asset_class == "VENTILATOR" - ) - ); const data = result.data?.results[0].assets_objects?.filter( (asset) => asset.asset_class == "VENTILATOR" ); - console.log(data?.length); - return data?.length; + setAsset(data?.length || 0); }); - // return len }; diff --git a/src/Components/CriticalCareRecording/Recording/CriticalCare__Recording.res b/src/Components/CriticalCareRecording/Recording/CriticalCare__Recording.res index 2903ab3e406..e8bfb91e21c 100644 --- a/src/Components/CriticalCareRecording/Recording/CriticalCare__Recording.res +++ b/src/Components/CriticalCareRecording/Recording/CriticalCare__Recording.res @@ -164,6 +164,8 @@ let make = (~id, ~facilityId, ~patientId, ~consultationId, ~dailyRound) => { updateCB={updateDailyRound(send, VentilatorParametersEditor)} id consultationId + patientId + facilityId /> | ArterialBloodGasAnalysisEditor => unit, _ => unit) => "updateDailyRound" @module("../CriticalCare__API") -external getAsset: (string) => Js.Promise.t = "getAsset"; +external getAsset: (string, (int => int) => unit) => option unit> = "getAsset" open VentilatorParameters @@ -17,19 +17,19 @@ let reducer = (state: VentilatorParameters.state, action: VentilatorParameters.a switch action { | SetBilateralAirEntry(bilateral_air_entry) => { ...state, - bilateral_air_entry: bilateral_air_entry, + bilateral_air_entry, } | SetETCO2(etco2) => { ...state, - etco2: etco2, + etco2, } | SetVentilatorInterface(ventilator_interface) => { ...state, - ventilator_interface: ventilator_interface, + ventilator_interface, } | SetVentilatorMode(ventilator_mode) => { ...state, - ventilator_mode: ventilator_mode, + ventilator_mode, } | SetOxygenModality(oxygen_modality) => { @@ -62,7 +62,7 @@ let reducer = (state: VentilatorParameters.state, action: VentilatorParameters.a } | SetOxygenModalityOxygenRate(ventilator_oxygen_modality_oxygen_rate) => { ...state, - ventilator_oxygen_modality_oxygen_rate: ventilator_oxygen_modality_oxygen_rate, + ventilator_oxygen_modality_oxygen_rate, } | SetOxygenModalityFlowRate(oxygen_modality_flow_rate) => { ...state, @@ -207,10 +207,22 @@ let initialState: VentilatorParameters.t => VentilatorParameters.state = ventila } @react.component -let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId, ~updateCB) => { +let make = ( + ~ventilatorParameters: VentilatorParameters.t, + ~id, + ~consultationId, + ~updateCB, + ~facilityId, + ~patientId, +) => { let (state, send) = React.useReducer(reducer, initialState(ventilatorParameters)) - let (isOpen, setIsOpen) = React.useState(() => false); - let toggleOpen = () => setIsOpen(prevState => !prevState); + let (isOpen, setIsOpen) = React.useState(() => false) + let toggleOpen = () => setIsOpen(prevState => !prevState) + let (asset, setAsset) = React.useState(() => 0) + + React.useEffect1(() => { + getAsset(consultationId, setAsset) + }, [isOpen]) let editor = switch state.ventilator_interface { | INVASIVE => @@ -221,7 +233,7 @@ let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId,
-
+
{str("Bilateral Air Entry")}
@@ -230,19 +242,18 @@ let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId, id="bilateral-air-entry-yes" label="Yes" checked={switch state.bilateral_air_entry { - | Some(bae) => bae - | None => false + | Some(bae) => bae + | None => false }} onChange={_ => send(SetBilateralAirEntry(Some(true)))} /> - !bae - | None => false + | Some(bae) => !bae + | None => false }} onChange={_ => send(SetBilateralAirEntry(Some(false)))} /> @@ -260,7 +271,6 @@ let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId, hasError={ValidationUtils.isInputInRangeInt(0, 200, state.etco2)} />
-

{str("Respiratory Support")}

@@ -287,20 +297,36 @@ let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId,
toggleOpen()} - className="md:max-w-3xl" - > + onClose={_ => toggleOpen()} + className="md:max-w-3xl"> toggleOpen()} + facilityId={facilityId} + patientId={patientId} + consultationId={consultationId} + setState={_ => toggleOpen()} />
diff --git a/src/Components/Facility/Consultations/Beds.res b/src/Components/Facility/Consultations/Beds.res index 72df9cec62a..6e356172147 100644 --- a/src/Components/Facility/Consultations/Beds.res +++ b/src/Components/Facility/Consultations/Beds.res @@ -2,6 +2,7 @@ type reactClass module Beds = { @module("./Beds.tsx") @react.component external make: ( + ~facilityId: string, ~patientId: string, ~consultationId: string, ~setState: unit => unit, @@ -9,5 +10,9 @@ module Beds = { } @react.component -let make = (~patientId: string, ~consultationId: string, ~setState: unit => unit) => - \ No newline at end of file +let make = ( + ~facilityId: string, + ~patientId: string, + ~consultationId: string, + ~setState: unit => unit, +) => From dfc4cae890fc4dcd7bac251b3ecc07f84aaa1b0b Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Tue, 16 Apr 2024 21:44:56 +0530 Subject: [PATCH 3/6] requested changes done --- .../CriticalCareRecording/CriticalCare__API.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/CriticalCareRecording/CriticalCare__API.tsx b/src/Components/CriticalCareRecording/CriticalCare__API.tsx index e2c228d3810..e26c5a217a7 100644 --- a/src/Components/CriticalCareRecording/CriticalCare__API.tsx +++ b/src/Components/CriticalCareRecording/CriticalCare__API.tsx @@ -32,11 +32,11 @@ export const getAsset = ( setAsset: React.Dispatch> ) => { request(routes.listConsultationBeds, { - query: { consultation: consultationId }, - }).then((result) => { - const data = result.data?.results[0].assets_objects?.filter( + query: { consultation: consultationId, limit: 1 }, + }).then(({ data }) => { + const assets = data?.results[0].assets_objects?.filter( (asset) => asset.asset_class == "VENTILATOR" ); - setAsset(data?.length || 0); + setAsset(assets?.length || 0); }); }; From c1b2a16cdeb7bee28e2252e9bd9bcfcf45742640 Mon Sep 17 00:00:00 2001 From: Manasvi Gaur <120303997+manasvi-gaur@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:41:30 +0530 Subject: [PATCH 4/6] lint error solved --- src/Components/CriticalCareRecording/CriticalCare__API.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/CriticalCareRecording/CriticalCare__API.tsx b/src/Components/CriticalCareRecording/CriticalCare__API.tsx index e873ed49c0b..4f54a5714ba 100644 --- a/src/Components/CriticalCareRecording/CriticalCare__API.tsx +++ b/src/Components/CriticalCareRecording/CriticalCare__API.tsx @@ -29,13 +29,13 @@ export const updateDailyRound = ( export const getAsset = ( consultationId: string, - setAsset: React.Dispatch> + setAsset: React.Dispatch>, ) => { request(routes.listConsultationBeds, { query: { consultation: consultationId, limit: 1 }, }).then(({ data }) => { const assets = data?.results[0].assets_objects?.filter( - (asset) => asset.asset_class == "VENTILATOR" + (asset) => asset.asset_class == "VENTILATOR", ); setAsset(assets?.length || 0); }); From d5ff4249e4d327758da86bbca13f29c193c8a8ec Mon Sep 17 00:00:00 2001 From: Manasvi Gaur Date: Sat, 11 May 2024 20:37:52 +0530 Subject: [PATCH 5/6] clarifying solution --- src/Components/CriticalCareRecording/CriticalCare__API.tsx | 1 + .../CriticalCare__VentilatorParametersEditor.res | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Components/CriticalCareRecording/CriticalCare__API.tsx b/src/Components/CriticalCareRecording/CriticalCare__API.tsx index 4f54a5714ba..7bddbf9eaee 100644 --- a/src/Components/CriticalCareRecording/CriticalCare__API.tsx +++ b/src/Components/CriticalCareRecording/CriticalCare__API.tsx @@ -34,6 +34,7 @@ export const getAsset = ( request(routes.listConsultationBeds, { query: { consultation: consultationId, limit: 1 }, }).then(({ data }) => { + // here its fetching the ventilator type assets const assets = data?.results[0].assets_objects?.filter( (asset) => asset.asset_class == "VENTILATOR", ); diff --git a/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res b/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res index e6eb9e9976a..9c731beb6a9 100644 --- a/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res +++ b/src/Components/CriticalCareRecording/VentilatorParametersEditor/CriticalCare__VentilatorParametersEditor.res @@ -298,6 +298,7 @@ let make = (