forked from secomind/OOBE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVitalSigns.tsx
More file actions
124 lines (112 loc) · 3.46 KB
/
VitalSigns.tsx
File metadata and controls
124 lines (112 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { Card, Row, Col } from "react-bootstrap";
import ReactApexChart from "react-apexcharts";
import { useEffect, useMemo, useState } from "react";
import { FormattedMessage } from "react-intl";
import { VitalSignsData } from "types";
export type VitalSignsProps = {
vitalSigns: VitalSignsData[];
};
const VitalSigns = ({ vitalSigns }: VitalSignsProps) => {
const [chartKey, setChartKey] = useState(0);
const series = useMemo(
() => [
{
name: "ECG",
data: vitalSigns
.slice()
.slice(0, 250)
.map((v) => v.ecg),
},
],
[vitalSigns],
);
const latest = vitalSigns[0];
useEffect(() => {
const handleResize = () => setChartKey((prev) => prev + 1);
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}, []);
const options: ApexCharts.ApexOptions = {
chart: {
type: "line",
animations: { enabled: false },
toolbar: { show: false },
zoom: { enabled: false },
sparkline: { enabled: true },
},
stroke: { curve: "straight", width: 1.5 },
grid: { show: false },
xaxis: {
labels: { show: false },
axisBorder: { show: false },
axisTicks: { show: false },
},
yaxis: { labels: { show: false } },
tooltip: { enabled: true },
};
return (
<Card className="p-4 h-100">
<Card.Body>
<Card.Title className="mb-3">
<FormattedMessage
id="vital.realTimeName"
defaultMessage="Real Time Vital Signs"
/>
</Card.Title>
<Row className="mb-4 align-items-center">
<Col className="fw-bold">
<FormattedMessage
id="vital.ecgRecording"
defaultMessage="ECG Recording"
/>
</Col>
<Col className="fw-bold fs-4 text-end">
{latest?.ecg ? `${latest.ecg} bpm` : "–"}
</Col>
<Col className="text-start fw-bold">
<FormattedMessage
id="vital.bloodPressure"
defaultMessage="Blood Pressure"
/>
</Col>
</Row>
<Row className="g-3">
<Col lg={8}>
<div className="border rounded p-4 h-100">
<div className="w-100 overflow-hidden">
<ReactApexChart
key={chartKey}
options={options}
series={series}
type="line"
height={160}
/>
</div>
</div>
</Col>
<Col lg={4} className="d-flex flex-column gap-3">
<div className="border rounded p-4 text-center d-flex flex-column justify-content-center">
<div className="fs-4 fw-bold">
{latest
? `${latest.systolicPressure}/${latest.diastolicPressure} mmHg`
: "–"}
</div>
</div>
<div className="fw-bold">
<FormattedMessage
id="vital.oxygenSaturation"
defaultMessage="Oxygen Saturation"
/>
</div>
<div className="border rounded p-4 text-center d-flex flex-column justify-content-center">
<div className="fs-4 fw-bold">
{latest ? `${latest.oxygenSaturation}%` : "–"}
</div>
</div>
</Col>
</Row>
</Card.Body>
</Card>
);
};
export default VitalSigns;