@ovok/native 1.17.0-dev.2258 → 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/adapters/sqlite-database-outbox-store.js +80 -0
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database-outbox-store.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database.js +0 -22
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-schema.js +1 -1
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-schema.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-store.js +16 -67
- package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-store.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/sqlite/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/commonjs/modules/next/index.js.map +1 -1
- package/lib/commonjs/modules/next/ovok.js +25 -2
- package/lib/commonjs/modules/next/ovok.js.map +1 -1
- package/lib/commonjs/modules/next/react-native-outbox-triggers.js +40 -0
- package/lib/commonjs/modules/next/react-native-outbox-triggers.js.map +1 -0
- 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/adapters/sqlite-database-outbox-store.js +77 -0
- package/lib/module/modules/next/bluetooth/adapters/sqlite-database-outbox-store.js.map +1 -0
- package/lib/module/modules/next/bluetooth/adapters/sqlite-database.js +0 -18
- package/lib/module/modules/next/bluetooth/adapters/sqlite-database.js.map +1 -1
- package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-schema.js +1 -1
- package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-schema.js.map +1 -1
- package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-store.js +16 -67
- package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-store.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/sqlite/index.js +3 -2
- package/lib/module/modules/next/bluetooth/sqlite/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/module/modules/next/index.js +1 -1
- package/lib/module/modules/next/index.js.map +1 -1
- package/lib/module/modules/next/ovok.js +25 -2
- package/lib/module/modules/next/ovok.js.map +1 -1
- package/lib/module/modules/next/react-native-outbox-triggers.js +37 -0
- package/lib/module/modules/next/react-native-outbox-triggers.js.map +1 -0
- package/lib/typescript/commonjs/src/modules/data-sync/services/managers/sync-progress-manager.d.ts +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/adapters/sqlite-database-outbox-store.d.ts +38 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database-outbox-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database.d.ts +9 -7
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts +5 -33
- package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts +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/sqlite/index.d.ts +5 -3
- package/lib/typescript/commonjs/src/modules/next/bluetooth/sqlite/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/commonjs/src/modules/next/index.d.ts +2 -1
- package/lib/typescript/commonjs/src/modules/next/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/ovok.d.ts +11 -3
- package/lib/typescript/commonjs/src/modules/next/ovok.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/react-native-outbox-triggers.d.ts +7 -0
- package/lib/typescript/commonjs/src/modules/next/react-native-outbox-triggers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/theme/hooks/use-app-theme.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/theme/utils/generate-theme.d.ts +1 -1
- package/lib/typescript/module/src/modules/data-sync/services/managers/sync-progress-manager.d.ts +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/adapters/sqlite-database-outbox-store.d.ts +38 -0
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database-outbox-store.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database.d.ts +9 -7
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts +5 -33
- package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts +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/sqlite/index.d.ts +5 -3
- package/lib/typescript/module/src/modules/next/bluetooth/sqlite/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/lib/typescript/module/src/modules/next/index.d.ts +2 -1
- package/lib/typescript/module/src/modules/next/index.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/ovok.d.ts +11 -3
- package/lib/typescript/module/src/modules/next/ovok.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/react-native-outbox-triggers.d.ts +7 -0
- package/lib/typescript/module/src/modules/next/react-native-outbox-triggers.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/theme/hooks/use-app-theme.d.ts +1 -1
- package/lib/typescript/module/src/modules/theme/utils/generate-theme.d.ts +1 -1
- package/package.json +2 -2
|
@@ -4,78 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SqliteOutboxStore = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _sqliteOutboxSchema = require("./sqlite-outbox-schema.js");
|
|
10
|
-
/** How `SqliteOutboxStore` finds its database; every field has a default for a phone app. */
|
|
7
|
+
var _sqliteDatabaseOutboxStore = require("./sqlite-database-outbox-store.js");
|
|
8
|
+
/** Every field has a default for a phone app; `open` defaults to `expo-sqlite`'s `openDatabaseAsync`. */
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const DUE = `SELECT ${_sqliteOutboxRows.ITEM_COLUMN_LIST} FROM outbox_items
|
|
18
|
-
WHERE owner_key = ? AND state = ? AND next_attempt_at <= ?
|
|
19
|
-
ORDER BY recorded_at DESC, COALESCE(seq, 0), id
|
|
20
|
-
LIMIT ?`;
|
|
21
|
-
const SUMMARIES = `SELECT ${_sqliteOutboxRows.SUMMARY_COLUMN_LIST} FROM outbox_items WHERE owner_key = ? ORDER BY recorded_at DESC`;
|
|
22
|
-
const COUNT = "SELECT COUNT(*) AS total FROM outbox_items WHERE owner_key = ? AND state = ?";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* An `OutboxStore` on `expo-sqlite`, for phones: one row per item in `outbox_items`, the entries as one JSON text
|
|
26
|
-
* column, so listing and counting never read them. `expo-sqlite` is an optional peer dependency, loaded on first use.
|
|
27
|
-
*/
|
|
28
|
-
class SqliteOutboxStore {
|
|
29
|
-
database = null;
|
|
30
|
-
constructor(options = {}) {
|
|
31
|
-
this.options = options;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Stores an item, replacing the one with the same id. */
|
|
35
|
-
async put(item) {
|
|
36
|
-
await (await this.open()).runAsync(PUT, (0, _sqliteOutboxRows.bindValuesOf)(item));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Returns an item, or `null` when there is none. */
|
|
40
|
-
async get(id) {
|
|
41
|
-
const row = await (await this.open()).getFirstAsync(GET, [id]);
|
|
42
|
-
return row && (0, _sqliteOutboxRows.itemOf)(row);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Deletes an item; an unknown id is not an error. */
|
|
46
|
-
async remove(id) {
|
|
47
|
-
await (await this.open()).runAsync(REMOVE, [id]);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** The owner's pending items that are due, newest recorded first, then by position in the recording. */
|
|
51
|
-
async due(ownerKey, now, limit) {
|
|
52
|
-
const rows = await (await this.open()).getAllAsync(DUE, [ownerKey, PENDING, now, limit]);
|
|
53
|
-
return rows.map(_sqliteOutboxRows.itemOf);
|
|
10
|
+
const loadExpoSqlite = () => {
|
|
11
|
+
try {
|
|
12
|
+
return require("expo-sqlite");
|
|
13
|
+
} catch {
|
|
14
|
+
throw new Error("SqliteOutboxStore requires the optional expo-sqlite peer dependency");
|
|
54
15
|
}
|
|
16
|
+
};
|
|
55
17
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const rows = await (await this.open()).getAllAsync(SUMMARIES, [ownerKey]);
|
|
59
|
-
return rows.map(_sqliteOutboxRows.summaryOf);
|
|
60
|
-
}
|
|
18
|
+
/** Opens the named database with `expo-sqlite`, which an app without the package never loads. */
|
|
19
|
+
const openExpoSqlite = name => loadExpoSqlite().openDatabaseAsync(name);
|
|
61
20
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this.database ??= this.connect().catch(error => {
|
|
69
|
-
this.database = null;
|
|
70
|
-
throw error;
|
|
21
|
+
/** The outbox store on `expo-sqlite`, for phones; `expo-sqlite` is an optional peer dependency, loaded on first use. */
|
|
22
|
+
class SqliteOutboxStore extends _sqliteDatabaseOutboxStore.SqliteDatabaseOutboxStore {
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
super({
|
|
25
|
+
...options,
|
|
26
|
+
open: options.open ?? openExpoSqlite
|
|
71
27
|
});
|
|
72
|
-
return this.database;
|
|
73
|
-
}
|
|
74
|
-
async connect() {
|
|
75
|
-
const open = this.options.open ?? _sqliteDatabase.openExpoSqlite;
|
|
76
|
-
const database = await open(this.options.name ?? DEFAULT_DATABASE_NAME);
|
|
77
|
-
await (0, _sqliteOutboxSchema.migrateOutboxSchema)(database, this.options.logger);
|
|
78
|
-
return database;
|
|
79
28
|
}
|
|
80
29
|
}
|
|
81
30
|
exports.SqliteOutboxStore = SqliteOutboxStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_sqliteDatabaseOutboxStore","require","loadExpoSqlite","Error","openExpoSqlite","name","openDatabaseAsync","SqliteOutboxStore","SqliteDatabaseOutboxStore","constructor","options","open","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/sqlite-outbox-store.ts"],"mappings":";;;;;;AAEA,IAAAA,0BAAA,GAAAC,OAAA;AAGA;;AAGA,MAAMC,cAAc,GAAGA,CAAA,KAAkB;EACvC,IAAI;IACF,OAAOD,OAAO,CAAC,aAAa,CAAC;EAC/B,CAAC,CAAC,MAAM;IACN,MAAM,IAAIE,KAAK,CAAC,qEAAqE,CAAC;EACxF;AACF,CAAC;;AAED;AACA,MAAMC,cAAc,GAAIC,IAAY,IAA8BH,cAAc,CAAC,CAAC,CAACI,iBAAiB,CAACD,IAAI,CAAC;;AAE1G;AACA,MAAME,iBAAiB,SAASC,oDAAyB,CAAC;EACjDC,WAAWA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAE;IACpD,KAAK,CAAC;MAAE,GAAGA,OAAO;MAAEC,IAAI,EAAED,OAAO,CAACC,IAAI,IAAIP;IAAe,CAAC,CAAC;EAC7D;AACF;AAACQ,OAAA,CAAAL,iBAAA,GAAAA,iBAAA","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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_sqliteOutboxStore","require"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/sqlite/index.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"names":["_sqliteOutboxStore","require"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/sqlite/index.ts"],"mappings":";;;;;;;;;;;AAOA,IAAAA,kBAAA,GAAAC,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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_next","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_ovok","_secureStoreStorage"],"sourceRoot":"../../../../src","sources":["modules/next/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,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,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,KAAA,GAAAb,OAAA;
|
|
1
|
+
{"version":3,"names":["_next","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_ovok","_secureStoreStorage"],"sourceRoot":"../../../../src","sources":["modules/next/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,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,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,KAAA,GAAAb,OAAA;AAIA,IAAAc,mBAAA,GAAAd,OAAA","ignoreList":[]}
|
|
@@ -5,11 +5,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Ovok = void 0;
|
|
7
7
|
var _next = require("@ovok/core/next");
|
|
8
|
+
var _sqliteDatabaseOutboxStore = require("./bluetooth/adapters/sqlite-database-outbox-store.js");
|
|
8
9
|
var _randomValues = require("./random-values.js");
|
|
10
|
+
var _reactNativeOutboxTriggers = require("./react-native-outbox-triggers.js");
|
|
9
11
|
var _secureStoreStorage = require("./secure-store-storage.js");
|
|
10
12
|
/** No clientSecret: anything shipped inside an app can be extracted from it. */
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
const outboxStoreOf = ({
|
|
15
|
+
outboxStore,
|
|
16
|
+
sqlite
|
|
17
|
+
}) => {
|
|
18
|
+
if (outboxStore) {
|
|
19
|
+
return outboxStore;
|
|
20
|
+
}
|
|
21
|
+
if (!sqlite) {
|
|
22
|
+
throw new TypeError("Pass the Ovok client sqlite (the expo-sqlite module) or an outboxStore for unsent measurements.");
|
|
23
|
+
}
|
|
24
|
+
return new _sqliteDatabaseOutboxStore.SqliteDatabaseOutboxStore({
|
|
25
|
+
open: name => sqlite.openDatabaseAsync(name)
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The @ovok/core/next client with the session kept in the device's secure store and unsent measurements in SQLite,
|
|
31
|
+
* sent when the network returns and when the app comes to the foreground.
|
|
32
|
+
*/
|
|
13
33
|
class Ovok extends _next.Ovok {
|
|
14
34
|
/** Base URL of the Ovok API, with a trailing slash. */
|
|
15
35
|
|
|
@@ -29,7 +49,10 @@ class Ovok extends _next.Ovok {
|
|
|
29
49
|
super({
|
|
30
50
|
...shared,
|
|
31
51
|
clientSecret: undefined,
|
|
32
|
-
storage
|
|
52
|
+
storage,
|
|
53
|
+
outboxStore: outboxStoreOf(config),
|
|
54
|
+
connectivity: shared.connectivity ?? _reactNativeOutboxTriggers.netInfoConnectivity,
|
|
55
|
+
lifecycle: shared.lifecycle ?? _reactNativeOutboxTriggers.appStateLifecycle
|
|
33
56
|
});
|
|
34
57
|
this.baseUrl = shared.baseUrl.endsWith("/") ? shared.baseUrl : `${shared.baseUrl}/`;
|
|
35
58
|
this.tenantCode = shared.tenantCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_next","require","_randomValues","_secureStoreStorage","Ovok","CoreOvok","constructor","config","secureStore","secureStoreOptions","getRandomValues","shared","storage","SecureStoreStorage","installRandomValues","clientSecret","undefined","baseUrl","endsWith","tenantCode","exports"],"sourceRoot":"../../../../src","sources":["modules/next/ovok.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_next","require","_sqliteDatabaseOutboxStore","_randomValues","_reactNativeOutboxTriggers","_secureStoreStorage","outboxStoreOf","outboxStore","sqlite","TypeError","SqliteDatabaseOutboxStore","open","name","openDatabaseAsync","Ovok","CoreOvok","constructor","config","secureStore","secureStoreOptions","getRandomValues","shared","storage","SecureStoreStorage","installRandomValues","clientSecret","undefined","connectivity","netInfoConnectivity","lifecycle","appStateLifecycle","baseUrl","endsWith","tenantCode","exports"],"sourceRoot":"../../../../src","sources":["modules/next/ovok.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAOA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,0BAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AAIA;;AAmBA,MAAMK,aAAa,GAAGA,CAAC;EAAEC,WAAW;EAAEC;AAAyD,CAAC,KAAkB;EAChH,IAAID,WAAW,EAAE;IACf,OAAOA,WAAW;EACpB;EAEA,IAAI,CAACC,MAAM,EAAE;IACX,MAAM,IAAIC,SAAS,CAAC,iGAAiG,CAAC;EACxH;EAEA,OAAO,IAAIC,oDAAyB,CAAC;IAAEC,IAAI,EAAGC,IAAI,IAAKJ,MAAM,CAACK,iBAAiB,CAACD,IAAI;EAAE,CAAC,CAAC;AAC1F,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAME,IAAI,SAASC,UAAQ,CAAC;EAC1B;;EAGA;;EAGA;;EAGAC,WAAWA,CAACC,MAAwB,EAAE;IACpC,MAAM;MAAEC,WAAW;MAAEC,kBAAkB;MAAEC,eAAe;MAAE,GAAGC;IAAO,CAAC,GAAGJ,MAAM;IAC9E,MAAMK,OAAO,GAAG,IAAIC,sCAAkB,CAACL,WAAW,EAAEC,kBAAkB,CAAC;IAEvE,IAAAK,iCAAmB,EAACJ,eAAe,CAAC;IACpC,KAAK,CAAC;MACJ,GAAGC,MAAM;MACTI,YAAY,EAAEC,SAAS;MACvBJ,OAAO;MACPf,WAAW,EAAED,aAAa,CAACW,MAAM,CAAC;MAClCU,YAAY,EAAEN,MAAM,CAACM,YAAY,IAAIC,8CAAmB;MACxDC,SAAS,EAAER,MAAM,CAACQ,SAAS,IAAIC;IACjC,CAAC,CAAC;IACF,IAAI,CAACC,OAAO,GAAGV,MAAM,CAACU,OAAO,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAGX,MAAM,CAACU,OAAO,GAAG,GAAGV,MAAM,CAACU,OAAO,GAAG;IACnF,IAAI,CAACE,UAAU,GAAGZ,MAAM,CAACY,UAAU;IACnC,IAAI,CAACX,OAAO,GAAGA,OAAO;EACxB;AACF;AAACY,OAAA,CAAApB,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.netInfoConnectivity = exports.appStateLifecycle = void 0;
|
|
7
|
+
var _netinfo = require("@react-native-community/netinfo");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/** An unknown internet reachability counts as online, as on the first report after launch. */
|
|
10
|
+
const isOnline = ({
|
|
11
|
+
isConnected,
|
|
12
|
+
isInternetReachable
|
|
13
|
+
}) => isConnected === true && isInternetReachable !== false;
|
|
14
|
+
|
|
15
|
+
/** The device's connection through NetInfo: the outbox hears each time it comes back after going offline. */
|
|
16
|
+
const netInfoConnectivity = exports.netInfoConnectivity = {
|
|
17
|
+
subscribe: onOnline => {
|
|
18
|
+
let wasOnline = true;
|
|
19
|
+
return (0, _netinfo.addEventListener)(state => {
|
|
20
|
+
const online = isOnline(state);
|
|
21
|
+
if (online && !wasOnline) {
|
|
22
|
+
onOnline();
|
|
23
|
+
}
|
|
24
|
+
wasOnline = online;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** The app's foreground through React Native's `AppState`. */
|
|
30
|
+
const appStateLifecycle = exports.appStateLifecycle = {
|
|
31
|
+
subscribe: onForeground => {
|
|
32
|
+
const subscription = _reactNative.AppState.addEventListener("change", state => {
|
|
33
|
+
if (state === "active") {
|
|
34
|
+
onForeground();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return () => subscription.remove();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=react-native-outbox-triggers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_netinfo","require","_reactNative","isOnline","isConnected","isInternetReachable","netInfoConnectivity","exports","subscribe","onOnline","wasOnline","addNetworkListener","state","online","appStateLifecycle","onForeground","subscription","AppState","addEventListener","remove"],"sourceRoot":"../../../../src","sources":["modules/next/react-native-outbox-triggers.ts"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAKA;AACA,MAAME,QAAQ,GAAGA,CAAC;EAAEC,WAAW;EAAEC;AAAkC,CAAC,KAClED,WAAW,KAAK,IAAI,IAAIC,mBAAmB,KAAK,KAAK;;AAEvD;AACA,MAAMC,mBAAuC,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EAC9CE,SAAS,EAAGC,QAAQ,IAAK;IACvB,IAAIC,SAAS,GAAG,IAAI;IAEpB,OAAO,IAAAC,yBAAkB,EAAEC,KAAK,IAAK;MACnC,MAAMC,MAAM,GAAGV,QAAQ,CAACS,KAAK,CAAC;MAE9B,IAAIC,MAAM,IAAI,CAACH,SAAS,EAAE;QACxBD,QAAQ,CAAC,CAAC;MACZ;MACAC,SAAS,GAAGG,MAAM;IACpB,CAAC,CAAC;EACJ;AACF,CAAC;;AAED;AACA,MAAMC,iBAAkC,GAAAP,OAAA,CAAAO,iBAAA,GAAG;EACzCN,SAAS,EAAGO,YAAY,IAAK;IAC3B,MAAMC,YAAY,GAAGC,qBAAQ,CAACC,gBAAgB,CAAC,QAAQ,EAAGN,KAAK,IAAK;MAClE,IAAIA,KAAK,KAAK,QAAQ,EAAE;QACtBG,YAAY,CAAC,CAAC;MAChB;IACF,CAAC,CAAC;IAEF,OAAO,MAAMC,YAAY,CAACG,MAAM,CAAC,CAAC;EACpC;AACF,CAAC","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":[]}
|
|
@@ -1,121 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { MeasurementTypeKey } from "@ovok/core/next";
|
|
4
3
|
import { DeviceError } from "../core/errors.js";
|
|
5
|
-
import { chosenPatientOf } from "./chosen-patient.js";
|
|
6
|
-
import { ecgMeasurements } from "./ecg-measurements.js";
|
|
4
|
+
import { chosenPatientOf, HOLD } from "./chosen-patient.js";
|
|
7
5
|
import { replaceLiveRecordings } from "./live-supersession.js";
|
|
6
|
+
import { MEASUREMENTS } from "./reading-measurements.js";
|
|
8
7
|
import { sourceIdsOf } from "./reading-source-id.js";
|
|
9
|
-
import {
|
|
10
|
-
import { isSeriesReading, saveSeries } from "./series-saving.js";
|
|
11
|
-
import { urineAnalysis } from "./urine-measurements.js";
|
|
12
|
-
const flagSet = (reading, code) => reading.deviceFlags.some(flag => flag.code === code && flag.raw !== 0) ? true : undefined;
|
|
13
|
-
const bloodPressure = reading => ({
|
|
14
|
-
measurementTypeKey: MeasurementTypeKey.bloodPressure,
|
|
15
|
-
systolic: ovokValueOf(reading, "systolic"),
|
|
16
|
-
diastolic: ovokValueOf(reading, "diastolic"),
|
|
17
|
-
meanArterialPressure: ovokValueOf(reading, "mean_arterial_pressure"),
|
|
18
|
-
heartRate: valueOf(reading, "pulse_rate"),
|
|
19
|
-
irregularHeartbeat: flagSet(reading, "irregular_pulse"),
|
|
20
|
-
recordedAt: reading.takenAt ?? undefined
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/** A reading without its main value, or with it in an unconvertible unit, cannot be saved. */
|
|
24
|
-
const bloodGlucose = reading => {
|
|
25
|
-
const bloodGlucoseValue = ovokValueOf(reading, "blood_glucose");
|
|
26
|
-
return bloodGlucoseValue === undefined ? undefined : {
|
|
27
|
-
measurementTypeKey: MeasurementTypeKey.bloodGlucose,
|
|
28
|
-
bloodGlucose: bloodGlucoseValue,
|
|
29
|
-
recordedAt: reading.takenAt ?? undefined
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
const bodyWeight = reading => {
|
|
33
|
-
const weight = ovokValueOf(reading, "body_weight");
|
|
34
|
-
return weight === undefined ? undefined : {
|
|
35
|
-
measurementTypeKey: MeasurementTypeKey.bodyWeight,
|
|
36
|
-
bodyWeight: weight,
|
|
37
|
-
recordedAt: reading.takenAt ?? undefined
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const bodyTemperature = reading => {
|
|
41
|
-
const temperature = ovokValueOf(reading, "body_temperature");
|
|
42
|
-
return temperature === undefined ? undefined : {
|
|
43
|
-
measurementTypeKey: MeasurementTypeKey.temperature,
|
|
44
|
-
bodyTemp: temperature,
|
|
45
|
-
recordedAt: reading.takenAt ?? undefined
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
const pulseOximetry = reading => ({
|
|
49
|
-
measurementTypeKey: MeasurementTypeKey.bloodOxygenPulseRate,
|
|
50
|
-
bloodOxygen: valueOf(reading, "spo2"),
|
|
51
|
-
pulseRate: valueOf(reading, "pulse_rate"),
|
|
52
|
-
perfusionIndex: valueOf(reading, "perfusion_index"),
|
|
53
|
-
recordedAt: reading.takenAt ?? undefined
|
|
54
|
-
});
|
|
55
|
-
const heartRate = reading => ({
|
|
56
|
-
measurementTypeKey: MeasurementTypeKey.heartRate,
|
|
57
|
-
heartRate: valueOf(reading, "heart_rate"),
|
|
58
|
-
recordedAt: reading.takenAt ?? undefined
|
|
59
|
-
});
|
|
60
|
-
const respiratoryRate = reading => ({
|
|
61
|
-
measurementTypeKey: MeasurementTypeKey.respiratoryRate,
|
|
62
|
-
respiratoryRate: valueOf(reading, "respiration_rate"),
|
|
63
|
-
recordedAt: reading.takenAt ?? undefined
|
|
64
|
-
});
|
|
65
|
-
const LIPID_METRICS = ["blood_cholesterol", "hdl_cholesterol", "ldl_cholesterol", "triglycerides"];
|
|
66
|
-
const LIPID_UNITS = ["mg/dL", "mmol/L"];
|
|
67
|
-
const isLipidUnit = unit => LIPID_UNITS.some(lipidUnit => lipidUnit === unit);
|
|
68
|
-
|
|
69
|
-
/** 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. */
|
|
70
|
-
const lipidPanel = reading => {
|
|
71
|
-
const units = new Set(LIPID_METRICS.flatMap(metric => reading.values[metric]?.unit ?? []));
|
|
72
|
-
const [unit] = units;
|
|
73
|
-
return units.size === 1 && isLipidUnit(unit) ? {
|
|
74
|
-
measurementTypeKey: MeasurementTypeKey.lipidPanel,
|
|
75
|
-
totalCholesterol: valueOf(reading, "blood_cholesterol"),
|
|
76
|
-
hdlCholesterol: valueOf(reading, "hdl_cholesterol"),
|
|
77
|
-
ldlCholesterol: valueOf(reading, "ldl_cholesterol"),
|
|
78
|
-
triglycerides: valueOf(reading, "triglycerides"),
|
|
79
|
-
unit,
|
|
80
|
-
recordedAt: reading.takenAt ?? undefined
|
|
81
|
-
} : undefined;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/** A spirometry test without any value in Ovok's units cannot be saved. */
|
|
85
|
-
const spirometry = reading => {
|
|
86
|
-
const values = {
|
|
87
|
-
fvc: ovokValueOf(reading, "fvc"),
|
|
88
|
-
fev1: ovokValueOf(reading, "fev1"),
|
|
89
|
-
"fev1/fvc": ovokValueOf(reading, "fev1_fvc_ratio"),
|
|
90
|
-
pef: ovokValueOf(reading, "pef"),
|
|
91
|
-
fef2575: ovokValueOf(reading, "fef25_75")
|
|
92
|
-
};
|
|
93
|
-
return Object.values(values).some(value => value !== undefined) ? {
|
|
94
|
-
measurementTypeKey: MeasurementTypeKey.spirometryPanel,
|
|
95
|
-
...values,
|
|
96
|
-
recordedAt: reading.takenAt ?? undefined
|
|
97
|
-
} : undefined;
|
|
98
|
-
};
|
|
99
|
-
const single = measure => reading => {
|
|
100
|
-
const measurement = measure(reading);
|
|
101
|
-
return measurement ? [measurement] : [];
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/** 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. */
|
|
105
|
-
const MEASUREMENTS = {
|
|
106
|
-
blood_pressure: single(bloodPressure),
|
|
107
|
-
blood_glucose: single(bloodGlucose),
|
|
108
|
-
blood_cholesterol: single(lipidPanel),
|
|
109
|
-
ecg: ecgMeasurements,
|
|
110
|
-
heart_rate: single(heartRate),
|
|
111
|
-
oxygen_saturation: single(pulseOximetry),
|
|
112
|
-
respiration_rate: single(respiratoryRate),
|
|
113
|
-
spirometry: single(spirometry),
|
|
114
|
-
temperature: single(bodyTemperature),
|
|
115
|
-
triglycerides: single(lipidPanel),
|
|
116
|
-
urine_test: single(urineAnalysis),
|
|
117
|
-
weight: single(bodyWeight)
|
|
118
|
-
};
|
|
8
|
+
import { holdSeries, isSeriesReading, saveSeries } from "./series-saving.js";
|
|
119
9
|
const deviceOf = (reading, device) => ({
|
|
120
10
|
id: reading.source.address,
|
|
121
11
|
name: device.model.id,
|
|
@@ -138,14 +28,17 @@ const unsupported = what => new DeviceError("unsupported", `Ovok cannot save ${w
|
|
|
138
28
|
/** Live numbers are saved as series and a live ECG as a recording; any other live trace has no place in Ovok yet. */
|
|
139
29
|
const isUnsavableLive = reading => reading.live !== undefined && reading.series === undefined && reading.type !== "ecg";
|
|
140
30
|
const hasValues = reading => Object.keys(reading.values).length > 0;
|
|
141
|
-
|
|
31
|
+
|
|
32
|
+
/** Stores one measurement's observations: saves them, or holds them. */
|
|
33
|
+
|
|
34
|
+
const storeMeasurements = async (store, reading, device, patientId) => {
|
|
142
35
|
const measurements = MEASUREMENTS[reading.type]?.(reading) ?? [];
|
|
143
36
|
if (measurements.length === 0) {
|
|
144
37
|
throw unsupported(`a ${reading.type} reading of this shape`);
|
|
145
38
|
}
|
|
146
39
|
const results = [];
|
|
147
40
|
for (const [index, measurement] of measurements.entries()) {
|
|
148
|
-
results.push(await
|
|
41
|
+
results.push(await store({
|
|
149
42
|
measurement,
|
|
150
43
|
...sourceIdsOf(reading, device.sn, index),
|
|
151
44
|
effectiveDateTime: reading.takenAt ?? undefined,
|
|
@@ -169,9 +62,21 @@ const receiptOf = results => {
|
|
|
169
62
|
};
|
|
170
63
|
};
|
|
171
64
|
|
|
65
|
+
/** Keeps a reading on the device for the guest, until `ovok.outbox.assign` names the patient; its live recordings stay. */
|
|
66
|
+
const holdReading = async (client, reading, device) => {
|
|
67
|
+
const results = [];
|
|
68
|
+
if (isSeriesReading(reading)) {
|
|
69
|
+
results.push(await holdSeries(client, reading, device));
|
|
70
|
+
}
|
|
71
|
+
if (!isSeriesReading(reading) || hasValues(reading)) {
|
|
72
|
+
results.push(...(await storeMeasurements(params => client.measurements.hold(params), reading, device, undefined)));
|
|
73
|
+
}
|
|
74
|
+
return results;
|
|
75
|
+
};
|
|
76
|
+
|
|
172
77
|
/**
|
|
173
78
|
* Saves readings through the Ovok measurements API, queueing them offline: for the signed-in account, or for the
|
|
174
|
-
* patient `savesFor` names
|
|
79
|
+
* 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
|
|
175
80
|
* replaces, once it is saved.
|
|
176
81
|
*/
|
|
177
82
|
const ovokReadingSink = (client, savesFor) => ({
|
|
@@ -179,16 +84,19 @@ const ovokReadingSink = (client, savesFor) => ({
|
|
|
179
84
|
if (isUnsavableLive(reading)) {
|
|
180
85
|
throw unsupported(`a live ${reading.live?.metric} recording`);
|
|
181
86
|
}
|
|
182
|
-
const
|
|
87
|
+
const chosen = chosenPatientOf(savesFor, reading, device);
|
|
183
88
|
const target = deviceOf(reading, device);
|
|
89
|
+
if (chosen === HOLD) {
|
|
90
|
+
return receiptOf(await holdReading(client, reading, target));
|
|
91
|
+
}
|
|
184
92
|
const results = [];
|
|
185
93
|
if (isSeriesReading(reading)) {
|
|
186
|
-
results.push(await saveSeries(client, reading, target,
|
|
94
|
+
results.push(await saveSeries(client, reading, target, chosen));
|
|
187
95
|
}
|
|
188
96
|
if (!isSeriesReading(reading) || hasValues(reading)) {
|
|
189
|
-
results.push(...(await
|
|
97
|
+
results.push(...(await storeMeasurements(params => client.measurements.save(params), reading, target, chosen)));
|
|
190
98
|
}
|
|
191
|
-
await replaceLiveRecordings(client, reading,
|
|
99
|
+
await replaceLiveRecordings(client, reading, chosen);
|
|
192
100
|
return receiptOf(results);
|
|
193
101
|
}
|
|
194
102
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["DeviceError","chosenPatientOf","HOLD","replaceLiveRecordings","MEASUREMENTS","sourceIdsOf","holdSeries","isSeriesReading","saveSeries","deviceOf","reading","device","id","source","address","name","model","localName","manufacturerData","manufacturerName","identity","manufacturer","undefined","sn","serial","variant","vendor","batteryPercentage","battery","percent","unsupported","what","isUnsavableLive","live","series","type","hasValues","Object","keys","values","length","storeMeasurements","store","patientId","measurements","results","index","measurement","entries","push","effectiveDateTime","takenAt","receiptOf","queueIds","flatMap","result","status","queueId","holdReading","client","params","hold","ovokReadingSink","savesFor","save","metric","chosen","target"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ovok-reading-sink.ts"],"mappings":";;AAGA,SAASA,WAAW,QAAQ,mBAAgB;AAK5C,SAASC,eAAe,EAAEC,IAAI,QAAkB,qBAAkB;AAClE,SAASC,qBAAqB,QAA4B,wBAAqB;AAC/E,SAASC,YAAY,QAAQ,2BAAwB;AACrD,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,UAAU,EAAEC,eAAe,EAAqBC,UAAU,QAAQ,oBAAiB;AAE5F,MAAMC,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;EACjCC,OAAO,EAA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