diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 69fd2ef304f..05e3ef13837 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -792,3 +792,5 @@ export const FACILITY_FEATURE_TYPES = [ icon: "droplet", }, ]; + +export const WAVEFORM_VIEWABLE_LENGTH = 400; diff --git a/src/Components/TeleIcu/Patient/Waveform.tsx b/src/Components/TeleIcu/Patient/Waveform.tsx index 0ee1cb4ffa3..9d64a43f361 100644 --- a/src/Components/TeleIcu/Patient/Waveform.tsx +++ b/src/Components/TeleIcu/Patient/Waveform.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from "react"; +import { WAVEFORM_VIEWABLE_LENGTH } from "../../../Common/constants"; import { LinePlot } from "../../Facility/Consultations/components/LinePlot"; export type WaveformType = { @@ -26,16 +27,17 @@ export default function Waveform(props: { }) { const wave = props.wave; const data = wave.data.split(" ").map(Number); - const [queueData, setQueueData] = useState(Array(200).fill(0)); + const [queueData, setQueueData] = useState( + Array(WAVEFORM_VIEWABLE_LENGTH).fill(0) + ); const [xData, setXData] = useState([]); const [lastStream, setLastStream] = useState(0); - const viewable = 400; const tpf = 4000 / data.length; useEffect(() => { setQueueData(queueData.concat(data)); - setXData(Array.from(Array(viewable).keys())); + setXData(Array.from(Array(WAVEFORM_VIEWABLE_LENGTH).keys())); let seconds = 1; setLastStream(0); @@ -62,7 +64,7 @@ export default function Waveform(props: { title={props.title} name={props.title} xData={xData} - yData={queueData.slice(0, viewable)} + yData={queueData.slice(0, WAVEFORM_VIEWABLE_LENGTH)} yStart={Math.min(...queueData)} yEnd={Math.max(...queueData)} classes={props.classes || "h-[90px]"} @@ -74,14 +76,20 @@ export default function Waveform(props: { {props.metrics && (
-
Lowest: {Math.min(...queueData.slice(0, viewable))}
-
Highest: {Math.max(...queueData.slice(0, viewable))}
+
+ Lowest:{" "} + {Math.min(...queueData.slice(0, WAVEFORM_VIEWABLE_LENGTH))} +
+
+ Highest:{" "} + {Math.max(...queueData.slice(0, WAVEFORM_VIEWABLE_LENGTH))} +
Stream Length: {data.length}
Lag:{" "} - {Number((tpf * (queueData.length - viewable)) / 1000).toFixed( - 2 - )}{" "} + {Number( + (tpf * (queueData.length - WAVEFORM_VIEWABLE_LENGTH)) / 1000 + ).toFixed(2)}{" "} sec
@@ -92,10 +100,12 @@ export default function Waveform(props: {
Last response: {lastStream} sec ago
- {queueData.length > viewable && ( + {queueData.length > WAVEFORM_VIEWABLE_LENGTH && (