@ovok/native 1.17.0-dev.2260 → 1.17.0-dev.2262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/modules/next/bluetooth/adapters/chosen-patient.js +12 -5
- package/lib/commonjs/modules/next/bluetooth/adapters/chosen-patient.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/adapters/ovok-reading-sink.js +27 -119
- package/lib/commonjs/modules/next/bluetooth/adapters/ovok-reading-sink.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/adapters/reading-measurements.js +118 -0
- package/lib/commonjs/modules/next/bluetooth/adapters/reading-measurements.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/adapters/series-saving.js +14 -8
- package/lib/commonjs/modules/next/bluetooth/adapters/series-saving.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/index.js +9 -1
- package/lib/commonjs/modules/next/bluetooth/index.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/web/index.js +9 -1
- package/lib/commonjs/modules/next/bluetooth/web/index.js.map +1 -1
- package/lib/module/modules/next/bluetooth/adapters/chosen-patient.js +11 -5
- package/lib/module/modules/next/bluetooth/adapters/chosen-patient.js.map +1 -1
- package/lib/module/modules/next/bluetooth/adapters/ovok-reading-sink.js +28 -120
- package/lib/module/modules/next/bluetooth/adapters/ovok-reading-sink.js.map +1 -1
- package/lib/module/modules/next/bluetooth/adapters/reading-measurements.js +115 -0
- package/lib/module/modules/next/bluetooth/adapters/reading-measurements.js.map +1 -0
- package/lib/module/modules/next/bluetooth/adapters/series-saving.js +13 -8
- package/lib/module/modules/next/bluetooth/adapters/series-saving.js.map +1 -1
- package/lib/module/modules/next/bluetooth/index.js +1 -0
- package/lib/module/modules/next/bluetooth/index.js.map +1 -1
- package/lib/module/modules/next/bluetooth/web/index.js +1 -0
- package/lib/module/modules/next/bluetooth/web/index.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/chosen-patient.d.ts +13 -5
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/chosen-patient.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-measurements.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-measurements.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/series-saving.d.ts +3 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/series-saving.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/web/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/web/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/chosen-patient.d.ts +13 -5
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/chosen-patient.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-measurements.d.ts +7 -0
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-measurements.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/series-saving.d.ts +3 -1
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/series-saving.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/web/index.d.ts +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/web/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -3,19 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.chosenPatientOf = void 0;
|
|
6
|
+
exports.chosenPatientOf = exports.HOLD = void 0;
|
|
7
7
|
var _errors = require("../core/errors.js");
|
|
8
|
+
/**
|
|
9
|
+
* What `savesFor` returns to keep a reading on the device, unsent, until `ovok.outbox.assign` names who was measured:
|
|
10
|
+
* for a shared monitor set to ask each time.
|
|
11
|
+
*/
|
|
12
|
+
const HOLD = exports.HOLD = Symbol("ovok.hold");
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Names the patient a reading is saved for, when the person measuring isn't the patient (a clinician): read at every
|
|
10
|
-
* save, so it follows whoever is chosen now. `
|
|
16
|
+
* save, so it follows whoever is chosen now. `HOLD` keeps the reading until a patient is assigned, and `undefined`
|
|
17
|
+
* means nobody is chosen, so the reading is not saved.
|
|
11
18
|
*/
|
|
12
19
|
|
|
13
|
-
/** The patient `savesFor` names, or `undefined` for the signed-in patient or guest; throws when nobody is chosen. */
|
|
14
|
-
const chosenPatientOf = savesFor => {
|
|
20
|
+
/** The patient `savesFor` names, `HOLD`, or `undefined` for the signed-in patient or guest; throws when nobody is chosen. */
|
|
21
|
+
const chosenPatientOf = (savesFor, reading, device) => {
|
|
15
22
|
if (!savesFor) {
|
|
16
23
|
return undefined;
|
|
17
24
|
}
|
|
18
|
-
const patientId = savesFor();
|
|
25
|
+
const patientId = savesFor(reading, device);
|
|
19
26
|
if (!patientId) {
|
|
20
27
|
throw new _errors.DeviceError("save-failed", "Choose the patient being measured before saving a reading");
|
|
21
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_errors","require","chosenPatientOf","savesFor","undefined","patientId","DeviceError"
|
|
1
|
+
{"version":3,"names":["_errors","require","HOLD","exports","Symbol","chosenPatientOf","savesFor","reading","device","undefined","patientId","DeviceError"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/chosen-patient.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAGE,MAAM,CAAC,WAAW,CAAC;;AAEhC;AACA;AACA;AACA;AACA;;AAGA;AACA,MAAMC,eAAe,GAAGA,CAACC,QAA8B,EAAEC,OAAgB,EAAEC,MAAsB,KAAuC;EACtI,IAAI,CAACF,QAAQ,EAAE;IACb,OAAOG,SAAS;EAClB;EAEA,MAAMC,SAAS,GAAGJ,QAAQ,CAACC,OAAO,EAAEC,MAAM,CAAC;EAE3C,IAAI,CAACE,SAAS,EAAE;IACd,MAAM,IAAIC,mBAAW,CAAC,aAAa,EAAE,2DAA2D,CAAC;EACnG;EAEA,OAAOD,SAAS;AAClB,CAAC;AAACP,OAAA,CAAAE,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -4,122 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ovokReadingSink = void 0;
|
|
7
|
-
var _next = require("@ovok/core/next");
|
|
8
7
|
var _errors = require("../core/errors.js");
|
|
9
8
|
var _chosenPatient = require("./chosen-patient.js");
|
|
10
|
-
var _ecgMeasurements = require("./ecg-measurements.js");
|
|
11
9
|
var _liveSupersession = require("./live-supersession.js");
|
|
10
|
+
var _readingMeasurements = require("./reading-measurements.js");
|
|
12
11
|
var _readingSourceId = require("./reading-source-id.js");
|
|
13
|
-
var _readingValues = require("./reading-values.js");
|
|
14
12
|
var _seriesSaving = require("./series-saving.js");
|
|
15
|
-
var _urineMeasurements = require("./urine-measurements.js");
|
|
16
|
-
const flagSet = (reading, code) => reading.deviceFlags.some(flag => flag.code === code && flag.raw !== 0) ? true : undefined;
|
|
17
|
-
const bloodPressure = reading => ({
|
|
18
|
-
measurementTypeKey: _next.MeasurementTypeKey.bloodPressure,
|
|
19
|
-
systolic: (0, _readingValues.ovokValueOf)(reading, "systolic"),
|
|
20
|
-
diastolic: (0, _readingValues.ovokValueOf)(reading, "diastolic"),
|
|
21
|
-
meanArterialPressure: (0, _readingValues.ovokValueOf)(reading, "mean_arterial_pressure"),
|
|
22
|
-
heartRate: (0, _readingValues.valueOf)(reading, "pulse_rate"),
|
|
23
|
-
irregularHeartbeat: flagSet(reading, "irregular_pulse"),
|
|
24
|
-
recordedAt: reading.takenAt ?? undefined
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
/** A reading without its main value, or with it in an unconvertible unit, cannot be saved. */
|
|
28
|
-
const bloodGlucose = reading => {
|
|
29
|
-
const bloodGlucoseValue = (0, _readingValues.ovokValueOf)(reading, "blood_glucose");
|
|
30
|
-
return bloodGlucoseValue === undefined ? undefined : {
|
|
31
|
-
measurementTypeKey: _next.MeasurementTypeKey.bloodGlucose,
|
|
32
|
-
bloodGlucose: bloodGlucoseValue,
|
|
33
|
-
recordedAt: reading.takenAt ?? undefined
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
const bodyWeight = reading => {
|
|
37
|
-
const weight = (0, _readingValues.ovokValueOf)(reading, "body_weight");
|
|
38
|
-
return weight === undefined ? undefined : {
|
|
39
|
-
measurementTypeKey: _next.MeasurementTypeKey.bodyWeight,
|
|
40
|
-
bodyWeight: weight,
|
|
41
|
-
recordedAt: reading.takenAt ?? undefined
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
const bodyTemperature = reading => {
|
|
45
|
-
const temperature = (0, _readingValues.ovokValueOf)(reading, "body_temperature");
|
|
46
|
-
return temperature === undefined ? undefined : {
|
|
47
|
-
measurementTypeKey: _next.MeasurementTypeKey.temperature,
|
|
48
|
-
bodyTemp: temperature,
|
|
49
|
-
recordedAt: reading.takenAt ?? undefined
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
const pulseOximetry = reading => ({
|
|
53
|
-
measurementTypeKey: _next.MeasurementTypeKey.bloodOxygenPulseRate,
|
|
54
|
-
bloodOxygen: (0, _readingValues.valueOf)(reading, "spo2"),
|
|
55
|
-
pulseRate: (0, _readingValues.valueOf)(reading, "pulse_rate"),
|
|
56
|
-
perfusionIndex: (0, _readingValues.valueOf)(reading, "perfusion_index"),
|
|
57
|
-
recordedAt: reading.takenAt ?? undefined
|
|
58
|
-
});
|
|
59
|
-
const heartRate = reading => ({
|
|
60
|
-
measurementTypeKey: _next.MeasurementTypeKey.heartRate,
|
|
61
|
-
heartRate: (0, _readingValues.valueOf)(reading, "heart_rate"),
|
|
62
|
-
recordedAt: reading.takenAt ?? undefined
|
|
63
|
-
});
|
|
64
|
-
const respiratoryRate = reading => ({
|
|
65
|
-
measurementTypeKey: _next.MeasurementTypeKey.respiratoryRate,
|
|
66
|
-
respiratoryRate: (0, _readingValues.valueOf)(reading, "respiration_rate"),
|
|
67
|
-
recordedAt: reading.takenAt ?? undefined
|
|
68
|
-
});
|
|
69
|
-
const LIPID_METRICS = ["blood_cholesterol", "hdl_cholesterol", "ldl_cholesterol", "triglycerides"];
|
|
70
|
-
const LIPID_UNITS = ["mg/dL", "mmol/L"];
|
|
71
|
-
const isLipidUnit = unit => LIPID_UNITS.some(lipidUnit => lipidUnit === unit);
|
|
72
|
-
|
|
73
|
-
/** Ovok keeps a panel in one unit, so a reading whose values use two units, or a unit it has no codes for, cannot be saved. */
|
|
74
|
-
const lipidPanel = reading => {
|
|
75
|
-
const units = new Set(LIPID_METRICS.flatMap(metric => reading.values[metric]?.unit ?? []));
|
|
76
|
-
const [unit] = units;
|
|
77
|
-
return units.size === 1 && isLipidUnit(unit) ? {
|
|
78
|
-
measurementTypeKey: _next.MeasurementTypeKey.lipidPanel,
|
|
79
|
-
totalCholesterol: (0, _readingValues.valueOf)(reading, "blood_cholesterol"),
|
|
80
|
-
hdlCholesterol: (0, _readingValues.valueOf)(reading, "hdl_cholesterol"),
|
|
81
|
-
ldlCholesterol: (0, _readingValues.valueOf)(reading, "ldl_cholesterol"),
|
|
82
|
-
triglycerides: (0, _readingValues.valueOf)(reading, "triglycerides"),
|
|
83
|
-
unit,
|
|
84
|
-
recordedAt: reading.takenAt ?? undefined
|
|
85
|
-
} : undefined;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/** A spirometry test without any value in Ovok's units cannot be saved. */
|
|
89
|
-
const spirometry = reading => {
|
|
90
|
-
const values = {
|
|
91
|
-
fvc: (0, _readingValues.ovokValueOf)(reading, "fvc"),
|
|
92
|
-
fev1: (0, _readingValues.ovokValueOf)(reading, "fev1"),
|
|
93
|
-
"fev1/fvc": (0, _readingValues.ovokValueOf)(reading, "fev1_fvc_ratio"),
|
|
94
|
-
pef: (0, _readingValues.ovokValueOf)(reading, "pef"),
|
|
95
|
-
fef2575: (0, _readingValues.ovokValueOf)(reading, "fef25_75")
|
|
96
|
-
};
|
|
97
|
-
return Object.values(values).some(value => value !== undefined) ? {
|
|
98
|
-
measurementTypeKey: _next.MeasurementTypeKey.spirometryPanel,
|
|
99
|
-
...values,
|
|
100
|
-
recordedAt: reading.takenAt ?? undefined
|
|
101
|
-
} : undefined;
|
|
102
|
-
};
|
|
103
|
-
const single = measure => reading => {
|
|
104
|
-
const measurement = measure(reading);
|
|
105
|
-
return measurement ? [measurement] : [];
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/** How each reading type becomes Ovok measurements, one for most and one per channel for an ECG; a type missing here cannot be saved yet. */
|
|
109
|
-
const MEASUREMENTS = {
|
|
110
|
-
blood_pressure: single(bloodPressure),
|
|
111
|
-
blood_glucose: single(bloodGlucose),
|
|
112
|
-
blood_cholesterol: single(lipidPanel),
|
|
113
|
-
ecg: _ecgMeasurements.ecgMeasurements,
|
|
114
|
-
heart_rate: single(heartRate),
|
|
115
|
-
oxygen_saturation: single(pulseOximetry),
|
|
116
|
-
respiration_rate: single(respiratoryRate),
|
|
117
|
-
spirometry: single(spirometry),
|
|
118
|
-
temperature: single(bodyTemperature),
|
|
119
|
-
triglycerides: single(lipidPanel),
|
|
120
|
-
urine_test: single(_urineMeasurements.urineAnalysis),
|
|
121
|
-
weight: single(bodyWeight)
|
|
122
|
-
};
|
|
123
13
|
const deviceOf = (reading, device) => ({
|
|
124
14
|
id: reading.source.address,
|
|
125
15
|
name: device.model.id,
|
|
@@ -142,14 +32,17 @@ const unsupported = what => new _errors.DeviceError("unsupported", `Ovok cannot
|
|
|
142
32
|
/** Live numbers are saved as series and a live ECG as a recording; any other live trace has no place in Ovok yet. */
|
|
143
33
|
const isUnsavableLive = reading => reading.live !== undefined && reading.series === undefined && reading.type !== "ecg";
|
|
144
34
|
const hasValues = reading => Object.keys(reading.values).length > 0;
|
|
145
|
-
|
|
146
|
-
|
|
35
|
+
|
|
36
|
+
/** Stores one measurement's observations: saves them, or holds them. */
|
|
37
|
+
|
|
38
|
+
const storeMeasurements = async (store, reading, device, patientId) => {
|
|
39
|
+
const measurements = _readingMeasurements.MEASUREMENTS[reading.type]?.(reading) ?? [];
|
|
147
40
|
if (measurements.length === 0) {
|
|
148
41
|
throw unsupported(`a ${reading.type} reading of this shape`);
|
|
149
42
|
}
|
|
150
43
|
const results = [];
|
|
151
44
|
for (const [index, measurement] of measurements.entries()) {
|
|
152
|
-
results.push(await
|
|
45
|
+
results.push(await store({
|
|
153
46
|
measurement,
|
|
154
47
|
...(0, _readingSourceId.sourceIdsOf)(reading, device.sn, index),
|
|
155
48
|
effectiveDateTime: reading.takenAt ?? undefined,
|
|
@@ -173,9 +66,21 @@ const receiptOf = results => {
|
|
|
173
66
|
};
|
|
174
67
|
};
|
|
175
68
|
|
|
69
|
+
/** Keeps a reading on the device for the guest, until `ovok.outbox.assign` names the patient; its live recordings stay. */
|
|
70
|
+
const holdReading = async (client, reading, device) => {
|
|
71
|
+
const results = [];
|
|
72
|
+
if ((0, _seriesSaving.isSeriesReading)(reading)) {
|
|
73
|
+
results.push(await (0, _seriesSaving.holdSeries)(client, reading, device));
|
|
74
|
+
}
|
|
75
|
+
if (!(0, _seriesSaving.isSeriesReading)(reading) || hasValues(reading)) {
|
|
76
|
+
results.push(...(await storeMeasurements(params => client.measurements.hold(params), reading, device, undefined)));
|
|
77
|
+
}
|
|
78
|
+
return results;
|
|
79
|
+
};
|
|
80
|
+
|
|
176
81
|
/**
|
|
177
82
|
* Saves readings through the Ovok measurements API, queueing them offline: for the signed-in account, or for the
|
|
178
|
-
* patient `savesFor` names
|
|
83
|
+
* patient `savesFor` names, or holds them when it returns `HOLD`. A reading with a series also saves it; a stored record then removes the live recordings it
|
|
179
84
|
* replaces, once it is saved.
|
|
180
85
|
*/
|
|
181
86
|
const ovokReadingSink = (client, savesFor) => ({
|
|
@@ -183,16 +88,19 @@ const ovokReadingSink = (client, savesFor) => ({
|
|
|
183
88
|
if (isUnsavableLive(reading)) {
|
|
184
89
|
throw unsupported(`a live ${reading.live?.metric} recording`);
|
|
185
90
|
}
|
|
186
|
-
const
|
|
91
|
+
const chosen = (0, _chosenPatient.chosenPatientOf)(savesFor, reading, device);
|
|
187
92
|
const target = deviceOf(reading, device);
|
|
93
|
+
if (chosen === _chosenPatient.HOLD) {
|
|
94
|
+
return receiptOf(await holdReading(client, reading, target));
|
|
95
|
+
}
|
|
188
96
|
const results = [];
|
|
189
97
|
if ((0, _seriesSaving.isSeriesReading)(reading)) {
|
|
190
|
-
results.push(await (0, _seriesSaving.saveSeries)(client, reading, target,
|
|
98
|
+
results.push(await (0, _seriesSaving.saveSeries)(client, reading, target, chosen));
|
|
191
99
|
}
|
|
192
100
|
if (!(0, _seriesSaving.isSeriesReading)(reading) || hasValues(reading)) {
|
|
193
|
-
results.push(...(await
|
|
101
|
+
results.push(...(await storeMeasurements(params => client.measurements.save(params), reading, target, chosen)));
|
|
194
102
|
}
|
|
195
|
-
await (0, _liveSupersession.replaceLiveRecordings)(client, reading,
|
|
103
|
+
await (0, _liveSupersession.replaceLiveRecordings)(client, reading, chosen);
|
|
196
104
|
return receiptOf(results);
|
|
197
105
|
}
|
|
198
106
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_errors","require","_chosenPatient","_liveSupersession","_readingMeasurements","_readingSourceId","_seriesSaving","deviceOf","reading","device","id","source","address","name","model","localName","manufacturerData","manufacturerName","identity","manufacturer","undefined","sn","serial","variant","vendor","batteryPercentage","battery","percent","unsupported","what","DeviceError","isUnsavableLive","live","series","type","hasValues","Object","keys","values","length","storeMeasurements","store","patientId","measurements","MEASUREMENTS","results","index","measurement","entries","push","sourceIdsOf","effectiveDateTime","takenAt","receiptOf","queueIds","flatMap","result","status","queueId","holdReading","client","isSeriesReading","holdSeries","params","hold","ovokReadingSink","savesFor","save","metric","chosen","chosenPatientOf","target","HOLD","saveSeries","replaceLiveRecordings","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ovok-reading-sink.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,MAAMM,QAAQ,GAAGA,CAACC,OAAgB,EAAEC,MAAsB,MAAyB;EACjFC,EAAE,EAAEF,OAAO,CAACG,MAAM,CAACC,OAAO;EAC1BC,IAAI,EAAEJ,MAAM,CAACK,KAAK,CAACJ,EAAE;EACrBK,SAAS,EAAEN,MAAM,CAACI,IAAI;EACtBG,gBAAgB,EAAE,EAAE;EACpBC,gBAAgB,EAAER,MAAM,CAACS,QAAQ,EAAEC,YAAY,IAAIC,SAAS;EAC5DN,KAAK,EAAEL,MAAM,CAACS,QAAQ,EAAEJ,KAAK,IAAIM,SAAS;EAC1CC,EAAE,EAAEZ,MAAM,CAACS,QAAQ,EAAEI,MAAM,IAAI,EAAE;EACj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
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MEASUREMENTS = void 0;
|
|
7
|
+
var _next = require("@ovok/core/next");
|
|
8
|
+
var _ecgMeasurements = require("./ecg-measurements.js");
|
|
9
|
+
var _readingValues = require("./reading-values.js");
|
|
10
|
+
var _urineMeasurements = require("./urine-measurements.js");
|
|
11
|
+
const flagSet = (reading, code) => reading.deviceFlags.some(flag => flag.code === code && flag.raw !== 0) ? true : undefined;
|
|
12
|
+
const bloodPressure = reading => ({
|
|
13
|
+
measurementTypeKey: _next.MeasurementTypeKey.bloodPressure,
|
|
14
|
+
systolic: (0, _readingValues.ovokValueOf)(reading, "systolic"),
|
|
15
|
+
diastolic: (0, _readingValues.ovokValueOf)(reading, "diastolic"),
|
|
16
|
+
meanArterialPressure: (0, _readingValues.ovokValueOf)(reading, "mean_arterial_pressure"),
|
|
17
|
+
heartRate: (0, _readingValues.valueOf)(reading, "pulse_rate"),
|
|
18
|
+
irregularHeartbeat: flagSet(reading, "irregular_pulse"),
|
|
19
|
+
recordedAt: reading.takenAt ?? undefined
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** A reading without its main value, or with it in an unconvertible unit, cannot be saved. */
|
|
23
|
+
const bloodGlucose = reading => {
|
|
24
|
+
const bloodGlucoseValue = (0, _readingValues.ovokValueOf)(reading, "blood_glucose");
|
|
25
|
+
return bloodGlucoseValue === undefined ? undefined : {
|
|
26
|
+
measurementTypeKey: _next.MeasurementTypeKey.bloodGlucose,
|
|
27
|
+
bloodGlucose: bloodGlucoseValue,
|
|
28
|
+
recordedAt: reading.takenAt ?? undefined
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const bodyWeight = reading => {
|
|
32
|
+
const weight = (0, _readingValues.ovokValueOf)(reading, "body_weight");
|
|
33
|
+
return weight === undefined ? undefined : {
|
|
34
|
+
measurementTypeKey: _next.MeasurementTypeKey.bodyWeight,
|
|
35
|
+
bodyWeight: weight,
|
|
36
|
+
recordedAt: reading.takenAt ?? undefined
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const bodyTemperature = reading => {
|
|
40
|
+
const temperature = (0, _readingValues.ovokValueOf)(reading, "body_temperature");
|
|
41
|
+
return temperature === undefined ? undefined : {
|
|
42
|
+
measurementTypeKey: _next.MeasurementTypeKey.temperature,
|
|
43
|
+
bodyTemp: temperature,
|
|
44
|
+
recordedAt: reading.takenAt ?? undefined
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const pulseOximetry = reading => ({
|
|
48
|
+
measurementTypeKey: _next.MeasurementTypeKey.bloodOxygenPulseRate,
|
|
49
|
+
bloodOxygen: (0, _readingValues.valueOf)(reading, "spo2"),
|
|
50
|
+
pulseRate: (0, _readingValues.valueOf)(reading, "pulse_rate"),
|
|
51
|
+
perfusionIndex: (0, _readingValues.valueOf)(reading, "perfusion_index"),
|
|
52
|
+
recordedAt: reading.takenAt ?? undefined
|
|
53
|
+
});
|
|
54
|
+
const heartRate = reading => ({
|
|
55
|
+
measurementTypeKey: _next.MeasurementTypeKey.heartRate,
|
|
56
|
+
heartRate: (0, _readingValues.valueOf)(reading, "heart_rate"),
|
|
57
|
+
recordedAt: reading.takenAt ?? undefined
|
|
58
|
+
});
|
|
59
|
+
const respiratoryRate = reading => ({
|
|
60
|
+
measurementTypeKey: _next.MeasurementTypeKey.respiratoryRate,
|
|
61
|
+
respiratoryRate: (0, _readingValues.valueOf)(reading, "respiration_rate"),
|
|
62
|
+
recordedAt: reading.takenAt ?? undefined
|
|
63
|
+
});
|
|
64
|
+
const LIPID_METRICS = ["blood_cholesterol", "hdl_cholesterol", "ldl_cholesterol", "triglycerides"];
|
|
65
|
+
const LIPID_UNITS = ["mg/dL", "mmol/L"];
|
|
66
|
+
const isLipidUnit = unit => LIPID_UNITS.some(lipidUnit => lipidUnit === unit);
|
|
67
|
+
|
|
68
|
+
/** Ovok keeps a panel in one unit, so a reading whose values use two units, or a unit it has no codes for, cannot be saved. */
|
|
69
|
+
const lipidPanel = reading => {
|
|
70
|
+
const units = new Set(LIPID_METRICS.flatMap(metric => reading.values[metric]?.unit ?? []));
|
|
71
|
+
const [unit] = units;
|
|
72
|
+
return units.size === 1 && isLipidUnit(unit) ? {
|
|
73
|
+
measurementTypeKey: _next.MeasurementTypeKey.lipidPanel,
|
|
74
|
+
totalCholesterol: (0, _readingValues.valueOf)(reading, "blood_cholesterol"),
|
|
75
|
+
hdlCholesterol: (0, _readingValues.valueOf)(reading, "hdl_cholesterol"),
|
|
76
|
+
ldlCholesterol: (0, _readingValues.valueOf)(reading, "ldl_cholesterol"),
|
|
77
|
+
triglycerides: (0, _readingValues.valueOf)(reading, "triglycerides"),
|
|
78
|
+
unit,
|
|
79
|
+
recordedAt: reading.takenAt ?? undefined
|
|
80
|
+
} : undefined;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/** A spirometry test without any value in Ovok's units cannot be saved. */
|
|
84
|
+
const spirometry = reading => {
|
|
85
|
+
const values = {
|
|
86
|
+
fvc: (0, _readingValues.ovokValueOf)(reading, "fvc"),
|
|
87
|
+
fev1: (0, _readingValues.ovokValueOf)(reading, "fev1"),
|
|
88
|
+
"fev1/fvc": (0, _readingValues.ovokValueOf)(reading, "fev1_fvc_ratio"),
|
|
89
|
+
pef: (0, _readingValues.ovokValueOf)(reading, "pef"),
|
|
90
|
+
fef2575: (0, _readingValues.ovokValueOf)(reading, "fef25_75")
|
|
91
|
+
};
|
|
92
|
+
return Object.values(values).some(value => value !== undefined) ? {
|
|
93
|
+
measurementTypeKey: _next.MeasurementTypeKey.spirometryPanel,
|
|
94
|
+
...values,
|
|
95
|
+
recordedAt: reading.takenAt ?? undefined
|
|
96
|
+
} : undefined;
|
|
97
|
+
};
|
|
98
|
+
const single = measure => reading => {
|
|
99
|
+
const measurement = measure(reading);
|
|
100
|
+
return measurement ? [measurement] : [];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** How each reading type becomes Ovok measurements, one for most and one per channel for an ECG; a type missing here cannot be saved yet. */
|
|
104
|
+
const MEASUREMENTS = exports.MEASUREMENTS = {
|
|
105
|
+
blood_pressure: single(bloodPressure),
|
|
106
|
+
blood_glucose: single(bloodGlucose),
|
|
107
|
+
blood_cholesterol: single(lipidPanel),
|
|
108
|
+
ecg: _ecgMeasurements.ecgMeasurements,
|
|
109
|
+
heart_rate: single(heartRate),
|
|
110
|
+
oxygen_saturation: single(pulseOximetry),
|
|
111
|
+
respiration_rate: single(respiratoryRate),
|
|
112
|
+
spirometry: single(spirometry),
|
|
113
|
+
temperature: single(bodyTemperature),
|
|
114
|
+
triglycerides: single(lipidPanel),
|
|
115
|
+
urine_test: single(_urineMeasurements.urineAnalysis),
|
|
116
|
+
weight: single(bodyWeight)
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=reading-measurements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_next","require","_ecgMeasurements","_readingValues","_urineMeasurements","flagSet","reading","code","deviceFlags","some","flag","raw","undefined","bloodPressure","measurementTypeKey","MeasurementTypeKey","systolic","ovokValueOf","diastolic","meanArterialPressure","heartRate","valueOf","irregularHeartbeat","recordedAt","takenAt","bloodGlucose","bloodGlucoseValue","bodyWeight","weight","bodyTemperature","temperature","bodyTemp","pulseOximetry","bloodOxygenPulseRate","bloodOxygen","pulseRate","perfusionIndex","respiratoryRate","LIPID_METRICS","LIPID_UNITS","isLipidUnit","unit","lipidUnit","lipidPanel","units","Set","flatMap","metric","values","size","totalCholesterol","hdlCholesterol","ldlCholesterol","triglycerides","spirometry","fvc","fev1","pef","fef2575","Object","value","spirometryPanel","single","measure","measurement","MEASUREMENTS","exports","blood_pressure","blood_glucose","blood_cholesterol","ecg","ecgMeasurements","heart_rate","oxygen_saturation","respiration_rate","urine_test","urineAnalysis"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/reading-measurements.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAiBA,IAAA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,UAAU,EAAEb,MAAM,CAACc,gCAAa,CAAC;EACjChD,MAAM,EAAEkC,MAAM,CAACnC,UAAU;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.seriesObservationsOf = exports.seriesFieldOf = exports.saveSeries = exports.ownPatientId = exports.isSeriesReading = void 0;
|
|
6
|
+
exports.seriesObservationsOf = exports.seriesFieldOf = exports.saveSeries = exports.ownPatientId = exports.isSeriesReading = exports.holdSeries = void 0;
|
|
7
7
|
var _next = require("@ovok/core/next");
|
|
8
8
|
var _errors = require("../core/errors.js");
|
|
9
9
|
var _readingSourceId = require("./reading-source-id.js");
|
|
@@ -70,12 +70,9 @@ const seriesObservationsOf = (field, {
|
|
|
70
70
|
...rest
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
/**
|
|
74
|
-
* Saves a series, in Ovok's unit, under a stable id; saving a longer version of it writes over the earlier one. It is
|
|
75
|
-
* saved for `patientId` when given, otherwise for the signed-in patient or the guest.
|
|
76
|
-
*/
|
|
73
|
+
/** The observations of a reading's series, in Ovok's unit, under a stable id, for `patientId`. */
|
|
77
74
|
exports.seriesObservationsOf = seriesObservationsOf;
|
|
78
|
-
const
|
|
75
|
+
const seriesObservationsFor = async (client, reading, device, patientId) => {
|
|
79
76
|
const {
|
|
80
77
|
series
|
|
81
78
|
} = reading;
|
|
@@ -84,7 +81,7 @@ const saveSeries = async (client, reading, device, patientId) => {
|
|
|
84
81
|
if (!field || !toOvokUnit) {
|
|
85
82
|
throw unsupported(`${series.metric} in ${series.unit}`);
|
|
86
83
|
}
|
|
87
|
-
|
|
84
|
+
return seriesObservationsOf(field, {
|
|
88
85
|
...series,
|
|
89
86
|
values: series.values.map(value => value === null ? null : toOvokUnit(value))
|
|
90
87
|
}, {
|
|
@@ -92,7 +89,16 @@ const saveSeries = async (client, reading, device, patientId) => {
|
|
|
92
89
|
...(0, _readingSourceId.sourceIdsOf)(reading, device.sn),
|
|
93
90
|
device
|
|
94
91
|
});
|
|
95
|
-
return client.measurements.saveObservations(observations);
|
|
96
92
|
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Saves a series, in Ovok's unit, under a stable id; saving a longer version of it writes over the earlier one. It is
|
|
96
|
+
* saved for `patientId` when given, otherwise for the signed-in patient or the guest.
|
|
97
|
+
*/
|
|
98
|
+
const saveSeries = async (client, reading, device, patientId) => client.measurements.saveObservations(await seriesObservationsFor(client, reading, device, patientId));
|
|
99
|
+
|
|
100
|
+
/** Keeps a series on the device, naming the guest, until `ovok.outbox.assign` names the patient. */
|
|
97
101
|
exports.saveSeries = saveSeries;
|
|
102
|
+
const holdSeries = async (client, reading, device) => client.measurements.holdObservations(await seriesObservationsFor(client, reading, device, _next.GUEST_PATIENT_ID));
|
|
103
|
+
exports.holdSeries = holdSeries;
|
|
98
104
|
//# sourceMappingURL=series-saving.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_next","require","_errors","_readingSourceId","_readingValues","SERIES_FIELDS","heart_rate","type","MeasurementTypeKey","heartRate","property","pulse_rate","bloodOxygenPulseRate","spo2","respiration_rate","respiratoryRate","body_temperature","temperature","unsupported","what","DeviceError","isSeriesReading","reading","series","undefined","exports","seriesFieldOf","metric","ownPatientId","session","reference","current","profile","slice","indexOf","GUEST_PATIENT_ID","seriesObservationsOf","field","start","intervalMs","values","rest","seriesObservations","measurementTypeKey","periodMs","
|
|
1
|
+
{"version":3,"names":["_next","require","_errors","_readingSourceId","_readingValues","SERIES_FIELDS","heart_rate","type","MeasurementTypeKey","heartRate","property","pulse_rate","bloodOxygenPulseRate","spo2","respiration_rate","respiratoryRate","body_temperature","temperature","unsupported","what","DeviceError","isSeriesReading","reading","series","undefined","exports","seriesFieldOf","metric","ownPatientId","session","reference","current","profile","slice","indexOf","GUEST_PATIENT_ID","seriesObservationsOf","field","start","intervalMs","values","rest","seriesObservations","measurementTypeKey","periodMs","seriesObservationsFor","client","device","patientId","toOvokUnit","TO_OVOK_UNIT","unit","map","value","sourceIdsOf","sn","saveSeries","measurements","saveObservations","holdSeries","holdObservations"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/series-saving.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAUA,IAAAC,OAAA,GAAAD,OAAA;AAIA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAIA;;AAGA;;AAGA;;AAGA,MAAMI,aAAuD,GAAG;EAC9DC,UAAU,EAAE;IAAEC,IAAI,EAAEC,wBAAkB,CAACC,SAAS;IAAEC,QAAQ,EAAE;EAAY,CAAC;EACzEC,UAAU,EAAE;IAAEJ,IAAI,EAAEC,wBAAkB,CAACI,oBAAoB;IAAEF,QAAQ,EAAE;EAAY,CAAC;EACpFG,IAAI,EAAE;IAAEN,IAAI,EAAEC,wBAAkB,CAACI,oBAAoB;IAAEF,QAAQ,EAAE;EAAc,CAAC;EAChFI,gBAAgB,EAAE;IAAEP,IAAI,EAAEC,wBAAkB,CAACO,eAAe;IAAEL,QAAQ,EAAE;EAAkB,CAAC;EAC3FM,gBAAgB,EAAE;IAAET,IAAI,EAAEC,wBAAkB,CAACS,WAAW;IAAEP,QAAQ,EAAE;EAAW;AACjF,CAAC;AAED,MAAMQ,WAAW,GAAIC,IAAY,IAAkB,IAAIC,mBAAW,CAAC,aAAa,EAAE,oBAAoBD,IAAI,cAAc,CAAC;AAEzH,MAAME,eAAe,GAAIC,OAAgB,IAA+BA,OAAO,CAACC,MAAM,KAAKC,SAAS;;AAEpG;AAAAC,OAAA,CAAAJ,eAAA,GAAAA,eAAA;AACA,MAAMK,aAAa,GAAIC,MAAc,IAA8BtB,aAAa,CAACsB,MAAM,CAAe;;AAEtG;AAAAF,OAAA,CAAAC,aAAA,GAAAA,aAAA;AACA,MAAME,YAAY,GAAG,MAAAA,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CAACiB,MAAM,CAACY,GAAG,CAAEC,KAAK,IAAMA,KAAK,KAAK,IAAI,GAAG,IAAI,GAAGJ,UAAU,CAACI,KAAK,CAAE;EAAE,CAAC,EAChG;IAAEL,SAAS,EAAEA,SAAS,KAAK,MAAMpB,YAAY,CAACkB,MAAM,CAAC,CAAC;IAAE,GAAG,IAAAQ,4BAAW,EAAChC,OAAO,EAAEyB,MAAM,CAACQ,EAAE,CAAC;IAAER;EAAO,CACrG,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMS,UAAU,GAAG,MAAAA,CACjBV,MAAoB,EACpBxB,OAAsB,EACtByB,MAAyB,EACzBC,SAAkB,KAElBF,MAAM,CAACW,YAAY,CAACC,gBAAgB,CAAC,MAAMb,qBAAqB,CAACC,MAAM,EAAExB,OAAO,EAAEyB,MAAM,EAAEC,SAAS,CAAC,CAAC;;AAEvG;AAAAvB,OAAA,CAAA+B,UAAA,GAAAA,UAAA;AACA,MAAMG,UAAU,GAAG,MAAAA,CAAOb,MAAoB,EAAExB,OAAsB,EAAEyB,MAAyB,KAC/FD,MAAM,CAACW,YAAY,CAACG,gBAAgB,CAAC,MAAMf,qBAAqB,CAACC,MAAM,EAAExB,OAAO,EAAEyB,MAAM,EAAEZ,sBAAgB,CAAC,CAAC;AAACV,OAAA,CAAAkC,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -8,8 +8,15 @@ var _exportNames = {
|
|
|
8
8
|
blePlxCentral: true,
|
|
9
9
|
osBluetoothPermissions: true,
|
|
10
10
|
reactNativeLifecycle: true,
|
|
11
|
-
createBluetooth: true
|
|
11
|
+
createBluetooth: true,
|
|
12
|
+
HOLD: true
|
|
12
13
|
};
|
|
14
|
+
Object.defineProperty(exports, "HOLD", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _chosenPatient.HOLD;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
13
20
|
Object.defineProperty(exports, "androidForegroundService", {
|
|
14
21
|
enumerable: true,
|
|
15
22
|
get: function () {
|
|
@@ -57,4 +64,5 @@ var _blePlxCentral = require("./adapters/ble-plx-central.js");
|
|
|
57
64
|
var _osPermissions = require("./adapters/os-permissions.js");
|
|
58
65
|
var _reactNativeLifecycle = require("./adapters/react-native-lifecycle.js");
|
|
59
66
|
var _createBluetooth = require("./create-bluetooth.js");
|
|
67
|
+
var _chosenPatient = require("./adapters/chosen-patient.js");
|
|
60
68
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_shared","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_androidForegroundService","_blePlxCentral","_osPermissions","_reactNativeLifecycle","_createBluetooth"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_shared","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_androidForegroundService","_blePlxCentral","_osPermissions","_reactNativeLifecycle","_createBluetooth","_chosenPatient"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,yBAAA,GAAAb,OAAA;AAEA,IAAAc,cAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAf,OAAA;AACA,IAAAgB,qBAAA,GAAAhB,OAAA;AACA,IAAAiB,gBAAA,GAAAjB,OAAA;AACA,IAAAkB,cAAA,GAAAlB,OAAA","ignoreList":[]}
|
|
@@ -5,8 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
webBluetoothCentral: true,
|
|
8
|
-
createWebBluetooth: true
|
|
8
|
+
createWebBluetooth: true,
|
|
9
|
+
HOLD: true
|
|
9
10
|
};
|
|
11
|
+
Object.defineProperty(exports, "HOLD", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _chosenPatient.HOLD;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
10
17
|
Object.defineProperty(exports, "createWebBluetooth", {
|
|
11
18
|
enumerable: true,
|
|
12
19
|
get: function () {
|
|
@@ -33,4 +40,5 @@ Object.keys(_shared).forEach(function (key) {
|
|
|
33
40
|
});
|
|
34
41
|
var _webBluetoothCentral = require("../adapters/web-bluetooth-central.js");
|
|
35
42
|
var _createWebBluetooth = require("./create-web-bluetooth.js");
|
|
43
|
+
var _chosenPatient = require("../adapters/chosen-patient.js");
|
|
36
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_shared","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_webBluetoothCentral","_createWebBluetooth"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_shared","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_webBluetoothCentral","_createWebBluetooth","_chosenPatient"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/web/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,oBAAA,GAAAb,OAAA;AAEA,IAAAc,mBAAA,GAAAd,OAAA;AACA,IAAAe,cAAA,GAAAf,OAAA","ignoreList":[]}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { DeviceError } from "../core/errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* What `savesFor` returns to keep a reading on the device, unsent, until `ovok.outbox.assign` names who was measured:
|
|
6
|
+
* for a shared monitor set to ask each time.
|
|
7
|
+
*/
|
|
8
|
+
const HOLD = Symbol("ovok.hold");
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* Names the patient a reading is saved for, when the person measuring isn't the patient (a clinician): read at every
|
|
7
|
-
* save, so it follows whoever is chosen now. `
|
|
12
|
+
* save, so it follows whoever is chosen now. `HOLD` keeps the reading until a patient is assigned, and `undefined`
|
|
13
|
+
* means nobody is chosen, so the reading is not saved.
|
|
8
14
|
*/
|
|
9
15
|
|
|
10
|
-
/** The patient `savesFor` names, or `undefined` for the signed-in patient or guest; throws when nobody is chosen. */
|
|
11
|
-
const chosenPatientOf = savesFor => {
|
|
16
|
+
/** The patient `savesFor` names, `HOLD`, or `undefined` for the signed-in patient or guest; throws when nobody is chosen. */
|
|
17
|
+
const chosenPatientOf = (savesFor, reading, device) => {
|
|
12
18
|
if (!savesFor) {
|
|
13
19
|
return undefined;
|
|
14
20
|
}
|
|
15
|
-
const patientId = savesFor();
|
|
21
|
+
const patientId = savesFor(reading, device);
|
|
16
22
|
if (!patientId) {
|
|
17
23
|
throw new DeviceError("save-failed", "Choose the patient being measured before saving a reading");
|
|
18
24
|
}
|
|
19
25
|
return patientId;
|
|
20
26
|
};
|
|
21
|
-
export { chosenPatientOf };
|
|
27
|
+
export { chosenPatientOf, HOLD };
|
|
22
28
|
//# sourceMappingURL=chosen-patient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DeviceError","chosenPatientOf","savesFor","undefined","patientId"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/chosen-patient.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["DeviceError","HOLD","Symbol","chosenPatientOf","savesFor","reading","device","undefined","patientId"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/chosen-patient.ts"],"mappings":";;AACA,SAASA,WAAW,QAAQ,mBAAgB;AAG5C;AACA;AACA;AACA;AACA,MAAMC,IAAI,GAAGC,MAAM,CAAC,WAAW,CAAC;;AAEhC;AACA;AACA;AACA;AACA;;AAGA;AACA,MAAMC,eAAe,GAAGA,CAACC,QAA8B,EAAEC,OAAgB,EAAEC,MAAsB,KAAuC;EACtI,IAAI,CAACF,QAAQ,EAAE;IACb,OAAOG,SAAS;EAClB;EAEA,MAAMC,SAAS,GAAGJ,QAAQ,CAACC,OAAO,EAAEC,MAAM,CAAC;EAE3C,IAAI,CAACE,SAAS,EAAE;IACd,MAAM,IAAIR,WAAW,CAAC,aAAa,EAAE,2DAA2D,CAAC;EACnG;EAEA,OAAOQ,SAAS;AAClB,CAAC;AAED,SAASL,eAAe,EAAEF,IAAI","ignoreList":[]}
|