diff --git a/package-lock.json b/package-lock.json index 5e75a190ffb..b3eeb9e919f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,6 +55,7 @@ "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", + "@types/events": "^3.0.3", "@types/google.maps": "^3.55.8", "@types/lodash-es": "^4.17.12", "@types/qrcode.react": "^1.0.5", @@ -4478,6 +4479,12 @@ "@types/estree": "*" } }, + "node_modules/@types/events": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", + "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", + "dev": true + }, "node_modules/@types/google.maps": { "version": "3.55.8", "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.55.8.tgz", diff --git a/package.json b/package.json index 22a6ee87d83..d57aee0fda4 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.13", + "@types/events": "^3.0.3", "@types/google.maps": "^3.55.8", "@types/lodash-es": "^4.17.12", "@types/qrcode.react": "^1.0.5", @@ -151,4 +152,4 @@ "node": ">=20.12.0" }, "packageManager": "npm@10.5.0" -} \ No newline at end of file +} diff --git a/src/Components/Patient/Waveform.tsx b/src/Components/Patient/Waveform.tsx deleted file mode 100644 index d567739a3d2..00000000000 --- a/src/Components/Patient/Waveform.tsx +++ /dev/null @@ -1,150 +0,0 @@ -import { useEffect, useRef, useState } from "react"; -import { LinePlot } from "../Facility/Consultations/components/LinePlot"; - -export type WaveformType = { - data: string; - "data-baseline": number; - "data-high-limit": number; - "data-low-limit": number; - "date-time": string; - device_id: string; - observation_id: "waveform"; - "patient-id": number; - "patient-name": string; - resolution: `${number}uV`; - "sampling rate": `${number}/sec`; - "wave-name": string; -}; - -export default function Waveform(props: { - wave: WaveformType; - color?: string; - title: string; - metrics?: boolean; - classes?: string; - defaultSpace?: boolean; - wavetype?: "STREAM" | "REFRESH"; -}) { - const wave = props.wave; - const data = wave.data.split(" ").map(Number); - const viewable = data.length; - const [queueData, setQueueData] = useState( - Array(viewable).fill(null), - ); - const [refreshData, setRefreshData] = useState([]); - const [lastData, setLastData] = useState([]); - const [xData, setXData] = useState([]); - const [lastStream, setLastStream] = useState(0); - const [rPointer, setRPointer] = useState(0); - - const initialRender = useRef(true); - - useEffect(() => { - if (props.wavetype === "STREAM") { - setQueueData(queueData.concat(data)); - } else { - if (lastData.length === 0) { - setLastData(data); - } else { - setRefreshData(data); - } - setRPointer(0); - } - setXData(Array.from(Array(viewable).keys())); - - let seconds = 1; - setLastStream(0); - const timer = setInterval(() => { - setLastStream(seconds); - seconds++; - }, 1000); - return () => clearInterval(timer); - }, [props.wave]); - - useEffect(() => { - const timeout = setTimeout(() => { - if (props.wavetype === "STREAM") { - if (queueData.length > 30000) { - setQueueData(queueData.slice(-viewable)); - } else { - setQueueData(queueData.slice(2)); - } - } - }, 6); - return () => clearTimeout(timeout); - }, [queueData]); - - useEffect(() => { - let timeout: NodeJS.Timeout; - if (initialRender.current) { - initialRender.current = false; - } else { - timeout = setTimeout(() => { - setRefreshData([ - ...data.slice(0, rPointer - 25), - ...Array(50).fill(null), - ...lastData.slice(rPointer - 25), - ]); - setRPointer(rPointer + Math.round(viewable / 150)); - }, 2); - } - return () => clearTimeout(timeout); - }, [refreshData]); - - useEffect(() => { - if (refreshData.length === 0) { - setRefreshData(data); - } - }, [lastData]); - - useEffect(() => { - if (rPointer >= data.length) { - setLastData(data); - } - }, [rPointer]); - - return ( -
-
- {props.title} -
- -
- {props.metrics && ( -
-
Lowest: {Math.min(...queueData.slice(0, viewable))}
-
Highest: {Math.max(...queueData.slice(0, viewable))}
-
Stream Length: {data.length}
-
Buffer Length: {queueData.length}
-
Sampling Rate: {wave["sampling rate"]}
-
Lag: {Math.round(queueData.length / viewable)} seconds
-
Last response: {lastStream} sec ago
- {queueData.length > viewable && ( - - )} -
- )} -
-
- ); -} diff --git a/src/Utils/useTimer.tsx b/src/Utils/useTimer.tsx index e017bf917b8..f7157f65b86 100644 --- a/src/Utils/useTimer.tsx +++ b/src/Utils/useTimer.tsx @@ -27,7 +27,7 @@ export const useTimer = () => { const [time, setTime] = useState(0); useEffect(() => { - let interval: NodeJS.Timeout; + let interval: number; if (running) { interval = setInterval(() => { setTime((prevTime) => prevTime + 1);