@ovok/core 0.4.35 → 0.4.36

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.
@@ -16,6 +16,15 @@ export type MeasurementDevice = {
16
16
  sn: string;
17
17
  /** Runtime association key; not written to the FHIR device identifier. */
18
18
  id: string;
19
+ /**
20
+ * The brand and model the advertised name identified, when one decoder serves several
21
+ * products (the mobile SDK's `deviceData.variant`). Preferred over `manufacturerName` and
22
+ * `model`, which often describe the Bluetooth module rather than the product.
23
+ */
24
+ variant?: {
25
+ manufacturer: string;
26
+ model: string;
27
+ };
19
28
  /**
20
29
  * Remaining charge, 0 to 100.
21
30
  *
@@ -8,6 +8,15 @@ const MANUFACTURER_NAME_URL = `${EXTENSION_BASE_URL}/device-manufacturer-name`;
8
8
  const MODEL_URL = `${EXTENSION_BASE_URL}/device-model`;
9
9
  const SERIAL_NUMBER_URL = `${EXTENSION_BASE_URL}/device-serial-number`;
10
10
  const BATTERY_PERCENTAGE_URL = `${EXTENSION_BASE_URL}/device-battery-percentage`;
11
+ const PARSER_URL = `${EXTENSION_BASE_URL}/device-parser`;
12
+ /** The product's own name: its model, prefixed with the brand unless the model already says it. */
13
+ const variantDisplay = ({ manufacturer, model, }) => {
14
+ var _a, _b;
15
+ const brand = (_b = (_a = manufacturer.split(" ")[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "";
16
+ return brand && model.toLowerCase().startsWith(brand)
17
+ ? model
18
+ : `${manufacturer} ${model}`;
19
+ };
11
20
  /**
12
21
  * The battery extension is omitted rather than defaulted when the device did not report
13
22
  * one, because a placeholder charge level would read as a real reading.
@@ -30,7 +39,7 @@ const getOptionalStringExtension = (url, value) => {
30
39
  return [{ url, valueString: value }];
31
40
  };
32
41
  const getDeviceObject = (measurementDevice) => {
33
- var _a;
42
+ var _a, _b, _c, _d, _e;
34
43
  if (!measurementDevice) {
35
44
  return {
36
45
  identifier: {
@@ -46,7 +55,9 @@ const getDeviceObject = (measurementDevice) => {
46
55
  },
47
56
  }
48
57
  : {}),
49
- display: (_a = measurementDevice.name) !== null && _a !== void 0 ? _a : "no-name",
58
+ display: measurementDevice.variant
59
+ ? variantDisplay(measurementDevice.variant)
60
+ : (_a = measurementDevice.name) !== null && _a !== void 0 ? _a : "no-name",
50
61
  extension: [
51
62
  {
52
63
  url: LOCAL_NAME_URL,
@@ -56,8 +67,11 @@ const getDeviceObject = (measurementDevice) => {
56
67
  url: MANUFACTURER_DATA_URL,
57
68
  valueString: measurementDevice.manufacturerData || "no-manufacturer-data",
58
69
  },
59
- ...getOptionalStringExtension(MANUFACTURER_NAME_URL, measurementDevice.manufacturerName),
60
- ...getOptionalStringExtension(MODEL_URL, measurementDevice.model),
70
+ ...getOptionalStringExtension(MANUFACTURER_NAME_URL, (_c = (_b = measurementDevice.variant) === null || _b === void 0 ? void 0 : _b.manufacturer) !== null && _c !== void 0 ? _c : measurementDevice.manufacturerName),
71
+ ...getOptionalStringExtension(MODEL_URL, (_e = (_d = measurementDevice.variant) === null || _d === void 0 ? void 0 : _d.model) !== null && _e !== void 0 ? _e : measurementDevice.model),
72
+ ...(measurementDevice.variant
73
+ ? getOptionalStringExtension(PARSER_URL, measurementDevice.name)
74
+ : []),
61
75
  {
62
76
  url: SERIAL_NUMBER_URL,
63
77
  valueString: measurementDevice.sn || "no-serial-number",
@@ -48,7 +48,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
48
48
  description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
49
49
  software: {
50
50
  name: "@ovok/core",
51
- version: "0.4.35",
51
+ version: "0.4.36",
52
52
  },
53
53
  fhirVersion: "4.0.1",
54
54
  format: ["json"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.35",
3
+ "version": "0.4.36",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",