@ovok/core 0.4.51 → 0.4.52

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.
@@ -6,15 +6,23 @@ const MeasurementTypeKey_1 = require("./types/MeasurementTypeKey");
6
6
  const UCUM_CODES = {
7
7
  "%": "%",
8
8
  "°C": "Cel",
9
+ "10³/µL": "10*3/uL",
9
10
  bpm: "/min",
10
11
  "breaths/min": "/min",
12
+ g: "g",
13
+ "g/dL": "g/dL",
14
+ INR: "{INR}",
15
+ kcal: "kcal",
11
16
  kg: "kg",
12
17
  "mg/dL": "mg/dL",
18
+ mL: "mL",
13
19
  "mL/kg/min": "mL/kg/min",
14
20
  mmHg: "mm[Hg]",
21
+ "mmol/L": "mmol/L",
15
22
  ms: "ms",
16
23
  mV: "mV",
17
24
  s: "s",
25
+ score: "{score}",
18
26
  steps: "{steps}",
19
27
  };
20
28
  /** A quantity in `unit`, coded in UCUM when the unit has a UCUM code. */
@@ -5,9 +5,18 @@ const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
5
5
  const fhir_systems_1 = require("../fhir-systems");
6
6
  const observation_coding_1 = require("../observation-coding");
7
7
  const measurement_time_1 = require("./measurement-time");
8
- /** Waveforms are coded in the ISO/IEEE 11073 nomenclature, everything else in LOINC. */
8
+ /** Waveforms are coded in the ISO/IEEE 11073 nomenclature, values LOINC lacks in Ovok's own, everything else in LOINC. */
9
9
  const MDC_CODES = new Set([MeasurementTypes_1.ObservationCode.ECG, MeasurementTypes_1.ObservationCode.PULSE_WAVE]);
10
- const systemOf = (code) => (MDC_CODES.has(code) ? fhir_systems_1.MDC_SYSTEM : fhir_systems_1.LOINC_SYSTEM);
10
+ const OVOK_CODES = new Set([MeasurementTypes_1.ObservationCode.GLUCOSE_KETONE_INDEX]);
11
+ const systemOf = (code) => {
12
+ if (MDC_CODES.has(code)) {
13
+ return fhir_systems_1.MDC_SYSTEM;
14
+ }
15
+ if (OVOK_CODES.has(code)) {
16
+ return fhir_systems_1.MEASUREMENT_TYPE_SYSTEM;
17
+ }
18
+ return fhir_systems_1.LOINC_SYSTEM;
19
+ };
11
20
  class BaseObservationService {
12
21
  getFields() {
13
22
  return this.observationMetadata.map(({ valueKey, primaryCode, unit, toFixed, display }) => ({
@@ -90,7 +90,34 @@ const specs = [
90
90
  // Health Connect has no walking-heart-rate-average record.
91
91
  fromRecord: () => 0,
92
92
  },
93
+ ...enteredValueSpecs([
94
+ [MeasurementTypes_1.MeasurementTypeKey.hemoglobinA1c, "hemoglobinA1c", MeasurementTypes_1.ObservationCode.HEMOGLOBIN_A1C, "HbA1c", "%", 1],
95
+ [MeasurementTypes_1.MeasurementTypeKey.bloodKetone, "bloodKetone", MeasurementTypes_1.ObservationCode.BLOOD_KETONE, "Blood Ketone", "mmol/L", 1],
96
+ [MeasurementTypes_1.MeasurementTypeKey.bloodLactate, "bloodLactate", MeasurementTypes_1.ObservationCode.LACTATE, "Blood Lactate", "mmol/L", 1],
97
+ [MeasurementTypes_1.MeasurementTypeKey.creatinine, "creatinine", MeasurementTypes_1.ObservationCode.CREATININE, "Creatinine", "mg/dL", 2],
98
+ [MeasurementTypes_1.MeasurementTypeKey.serumUricAcid, "serumUricAcid", MeasurementTypes_1.ObservationCode.SERUM_URIC_ACID, "Uric Acid", "mg/dL", 1],
99
+ [MeasurementTypes_1.MeasurementTypeKey.inr, "inr", MeasurementTypes_1.ObservationCode.INR, "INR", "INR", 1],
100
+ [MeasurementTypes_1.MeasurementTypeKey.hemoglobin, "hemoglobin", MeasurementTypes_1.ObservationCode.HEMOGLOBIN, "Hemoglobin", "g/dL", 1],
101
+ [MeasurementTypes_1.MeasurementTypeKey.hematocrit, "hematocrit", MeasurementTypes_1.ObservationCode.HEMATOCRIT, "Hematocrit", "%", 1],
102
+ [MeasurementTypes_1.MeasurementTypeKey.totalProtein, "totalProtein", MeasurementTypes_1.ObservationCode.TOTAL_PROTEIN, "Total Protein", "g/dL", 1],
103
+ [MeasurementTypes_1.MeasurementTypeKey.whiteBloodCells, "whiteBloodCells", MeasurementTypes_1.ObservationCode.WHITE_BLOOD_CELLS, "White Blood Cells", "10³/µL", 1],
104
+ [MeasurementTypes_1.MeasurementTypeKey.glucoseKetoneIndex, "glucoseKetoneIndex", MeasurementTypes_1.ObservationCode.GLUCOSE_KETONE_INDEX, "Glucose Ketone Index", "", 1],
105
+ [MeasurementTypes_1.MeasurementTypeKey.stressLevel, "stressLevel", MeasurementTypes_1.ObservationCode.STRESS_LEVEL, "Stress Level", "score", 0],
106
+ [MeasurementTypes_1.MeasurementTypeKey.bloodAlcoholContent, "bloodAlcoholContent", MeasurementTypes_1.ObservationCode.BLOOD_ALCOHOL, "Blood Alcohol", "%", 3],
107
+ [MeasurementTypes_1.MeasurementTypeKey.waterIntake, "waterIntake", MeasurementTypes_1.ObservationCode.WATER_INTAKE, "Water Intake", "mL", 0],
108
+ [MeasurementTypes_1.MeasurementTypeKey.caloriesConsumed, "caloriesConsumed", MeasurementTypes_1.ObservationCode.CALORIE_INTAKE, "Calories Consumed", "kcal", 0],
109
+ [MeasurementTypes_1.MeasurementTypeKey.carbohydrateIntake, "carbohydrateIntake", MeasurementTypes_1.ObservationCode.CARBOHYDRATE_INTAKE, "Carbohydrates", "g", 0],
110
+ ]),
93
111
  ];
112
+ /** Values a person types in or a device reports; Apple Health and Health Connect imports don't produce them. */
113
+ function enteredValueSpecs(rows) {
114
+ return rows.map(([measurementTypeKey, valueKey, primaryCode, display, unit, toFixed]) => ({
115
+ measurementTypeKey,
116
+ measurementTypeName: display.toLowerCase(),
117
+ metadata: { primaryCode, display, unit, valueKey, toFixed },
118
+ fromRecord: () => undefined,
119
+ }));
120
+ }
94
121
  const singleValueObservationServices = () => specs.map((spec) => [spec.measurementTypeKey, new SingleValueObservationService(spec)]);
95
122
  exports.singleValueObservationServices = singleValueObservationServices;
96
123
  /** Value key and LOINC code of each single-value type, for reading observations back into measurements. */
@@ -47,5 +47,37 @@ export declare enum MeasurementTypeKey {
47
47
  /** Respiratory therapy session. */
48
48
  respiratoryTherapy = "respiratory-therapy",
49
49
  /** Baby sleep data. */
50
- babySleep = "baby-sleep"
50
+ babySleep = "baby-sleep",
51
+ /** HbA1c, the share of haemoglobin with glucose attached. */
52
+ hemoglobinA1c = "hemoglobin-a1c",
53
+ /** Blood ketone (beta-hydroxybutyrate). */
54
+ bloodKetone = "blood-ketone",
55
+ /** Blood lactate. */
56
+ bloodLactate = "blood-lactate",
57
+ /** Creatinine. */
58
+ creatinine = "creatinine",
59
+ /** Uric acid in blood. */
60
+ serumUricAcid = "serum-uric-acid",
61
+ /** International normalised ratio (INR) of blood coagulation. */
62
+ inr = "inr",
63
+ /** Haemoglobin. */
64
+ hemoglobin = "hemoglobin",
65
+ /** Haematocrit. */
66
+ hematocrit = "hematocrit",
67
+ /** Total protein. */
68
+ totalProtein = "total-protein",
69
+ /** White blood cell count. */
70
+ whiteBloodCells = "white-blood-cells",
71
+ /** Glucose ketone index. */
72
+ glucoseKetoneIndex = "glucose-ketone-index",
73
+ /** Stress level score. */
74
+ stressLevel = "stress-level",
75
+ /** Blood alcohol content. */
76
+ bloodAlcoholContent = "blood-alcohol-content",
77
+ /** Water drunk. */
78
+ waterIntake = "water-intake",
79
+ /** Food energy eaten. */
80
+ caloriesConsumed = "calories-consumed",
81
+ /** Carbohydrates eaten. */
82
+ carbohydrateIntake = "carbohydrate-intake"
51
83
  }
@@ -52,4 +52,36 @@ var MeasurementTypeKey;
52
52
  MeasurementTypeKey["respiratoryTherapy"] = "respiratory-therapy";
53
53
  /** Baby sleep data. */
54
54
  MeasurementTypeKey["babySleep"] = "baby-sleep";
55
+ /** HbA1c, the share of haemoglobin with glucose attached. */
56
+ MeasurementTypeKey["hemoglobinA1c"] = "hemoglobin-a1c";
57
+ /** Blood ketone (beta-hydroxybutyrate). */
58
+ MeasurementTypeKey["bloodKetone"] = "blood-ketone";
59
+ /** Blood lactate. */
60
+ MeasurementTypeKey["bloodLactate"] = "blood-lactate";
61
+ /** Creatinine. */
62
+ MeasurementTypeKey["creatinine"] = "creatinine";
63
+ /** Uric acid in blood. */
64
+ MeasurementTypeKey["serumUricAcid"] = "serum-uric-acid";
65
+ /** International normalised ratio (INR) of blood coagulation. */
66
+ MeasurementTypeKey["inr"] = "inr";
67
+ /** Haemoglobin. */
68
+ MeasurementTypeKey["hemoglobin"] = "hemoglobin";
69
+ /** Haematocrit. */
70
+ MeasurementTypeKey["hematocrit"] = "hematocrit";
71
+ /** Total protein. */
72
+ MeasurementTypeKey["totalProtein"] = "total-protein";
73
+ /** White blood cell count. */
74
+ MeasurementTypeKey["whiteBloodCells"] = "white-blood-cells";
75
+ /** Glucose ketone index. */
76
+ MeasurementTypeKey["glucoseKetoneIndex"] = "glucose-ketone-index";
77
+ /** Stress level score. */
78
+ MeasurementTypeKey["stressLevel"] = "stress-level";
79
+ /** Blood alcohol content. */
80
+ MeasurementTypeKey["bloodAlcoholContent"] = "blood-alcohol-content";
81
+ /** Water drunk. */
82
+ MeasurementTypeKey["waterIntake"] = "water-intake";
83
+ /** Food energy eaten. */
84
+ MeasurementTypeKey["caloriesConsumed"] = "calories-consumed";
85
+ /** Carbohydrates eaten. */
86
+ MeasurementTypeKey["carbohydrateIntake"] = "carbohydrate-intake";
55
87
  })(MeasurementTypeKey || (exports.MeasurementTypeKey = MeasurementTypeKey = {}));
@@ -119,7 +119,35 @@ export declare enum ObservationCode {
119
119
  /** Respiratory therapy session (Ovok code). */
120
120
  RESPIRATORY_THERAPY = "respiratory-therapy",
121
121
  /** Baby sleep (Ovok code). */
122
- BABY_SLEEP = "baby-sleep"
122
+ BABY_SLEEP = "baby-sleep",
123
+ /** Hemoglobin A1c/Hemoglobin.total in Blood. */
124
+ HEMOGLOBIN_A1C = "4548-4",
125
+ /** Beta hydroxybutyrate [Moles/volume] in Blood. */
126
+ BLOOD_KETONE = "104816-4",
127
+ /** Creatinine [Mass/volume] in Serum or Plasma. */
128
+ CREATININE = "2160-0",
129
+ /** Urate [Mass/volume] in Serum or Plasma. */
130
+ SERUM_URIC_ACID = "3084-1",
131
+ /** INR in Blood by Coagulation assay. */
132
+ INR = "34714-6",
133
+ /** Hemoglobin [Mass/volume] in Blood. */
134
+ HEMOGLOBIN = "718-7",
135
+ /** Hematocrit [Volume Fraction] of Blood by Automated count. */
136
+ HEMATOCRIT = "4544-3",
137
+ /** Protein [Mass/volume] in Serum or Plasma. */
138
+ TOTAL_PROTEIN = "2885-2",
139
+ /** Leukocytes [#/volume] in Blood by Automated count. */
140
+ WHITE_BLOOD_CELLS = "6690-2",
141
+ /** Glucose ketone index (Ovok code; LOINC has none). */
142
+ GLUCOSE_KETONE_INDEX = "glucose-ketone-index",
143
+ /** Ethanol [Mass/volume] in Blood. */
144
+ BLOOD_ALCOHOL = "5640-8",
145
+ /** Fluid intake oral Measured. */
146
+ WATER_INTAKE = "9000-1",
147
+ /** Calorie intake total. */
148
+ CALORIE_INTAKE = "9052-2",
149
+ /** Carbohydrate intake Estimated. */
150
+ CARBOHYDRATE_INTAKE = "9059-7"
123
151
  }
124
152
  /**
125
153
  * SNOMED CT concepts used to represent the result of a blood-pressure rhythm check.
@@ -124,6 +124,34 @@ var ObservationCode;
124
124
  ObservationCode["RESPIRATORY_THERAPY"] = "respiratory-therapy";
125
125
  /** Baby sleep (Ovok code). */
126
126
  ObservationCode["BABY_SLEEP"] = "baby-sleep";
127
+ /** Hemoglobin A1c/Hemoglobin.total in Blood. */
128
+ ObservationCode["HEMOGLOBIN_A1C"] = "4548-4";
129
+ /** Beta hydroxybutyrate [Moles/volume] in Blood. */
130
+ ObservationCode["BLOOD_KETONE"] = "104816-4";
131
+ /** Creatinine [Mass/volume] in Serum or Plasma. */
132
+ ObservationCode["CREATININE"] = "2160-0";
133
+ /** Urate [Mass/volume] in Serum or Plasma. */
134
+ ObservationCode["SERUM_URIC_ACID"] = "3084-1";
135
+ /** INR in Blood by Coagulation assay. */
136
+ ObservationCode["INR"] = "34714-6";
137
+ /** Hemoglobin [Mass/volume] in Blood. */
138
+ ObservationCode["HEMOGLOBIN"] = "718-7";
139
+ /** Hematocrit [Volume Fraction] of Blood by Automated count. */
140
+ ObservationCode["HEMATOCRIT"] = "4544-3";
141
+ /** Protein [Mass/volume] in Serum or Plasma. */
142
+ ObservationCode["TOTAL_PROTEIN"] = "2885-2";
143
+ /** Leukocytes [#/volume] in Blood by Automated count. */
144
+ ObservationCode["WHITE_BLOOD_CELLS"] = "6690-2";
145
+ /** Glucose ketone index (Ovok code; LOINC has none). */
146
+ ObservationCode["GLUCOSE_KETONE_INDEX"] = "glucose-ketone-index";
147
+ /** Ethanol [Mass/volume] in Blood. */
148
+ ObservationCode["BLOOD_ALCOHOL"] = "5640-8";
149
+ /** Fluid intake oral Measured. */
150
+ ObservationCode["WATER_INTAKE"] = "9000-1";
151
+ /** Calorie intake total. */
152
+ ObservationCode["CALORIE_INTAKE"] = "9052-2";
153
+ /** Carbohydrate intake Estimated. */
154
+ ObservationCode["CARBOHYDRATE_INTAKE"] = "9059-7";
127
155
  })(ObservationCode || (exports.ObservationCode = ObservationCode = {}));
128
156
  /**
129
157
  * SNOMED CT concepts used to represent the result of a blood-pressure rhythm check.
@@ -0,0 +1,109 @@
1
+ import { MeasurementTypeKey } from "../MeasurementTypeKey";
2
+ import { Measurement } from "./Measurement";
3
+ /**
4
+ * A measurement of type `K` with one optional value under `V`.
5
+ *
6
+ * @category measurements
7
+ */
8
+ export type SingleValue<K extends MeasurementTypeKey, V extends string> = Measurement & {
9
+ /** The measurement's type. */
10
+ measurementTypeKey: K;
11
+ } & {
12
+ [value in V]?: number;
13
+ };
14
+ /**
15
+ * HbA1c, in %.
16
+ *
17
+ * @category measurements
18
+ */
19
+ export type HemoglobinA1cMeasurement = SingleValue<MeasurementTypeKey.hemoglobinA1c, "hemoglobinA1c">;
20
+ /**
21
+ * Blood ketone (beta-hydroxybutyrate), in mmol/L.
22
+ *
23
+ * @category measurements
24
+ */
25
+ export type BloodKetoneMeasurement = SingleValue<MeasurementTypeKey.bloodKetone, "bloodKetone">;
26
+ /**
27
+ * Blood lactate, in mmol/L.
28
+ *
29
+ * @category measurements
30
+ */
31
+ export type BloodLactateMeasurement = SingleValue<MeasurementTypeKey.bloodLactate, "bloodLactate">;
32
+ /**
33
+ * Creatinine, in mg/dL.
34
+ *
35
+ * @category measurements
36
+ */
37
+ export type CreatinineMeasurement = SingleValue<MeasurementTypeKey.creatinine, "creatinine">;
38
+ /**
39
+ * Uric acid in blood, in mg/dL.
40
+ *
41
+ * @category measurements
42
+ */
43
+ export type SerumUricAcidMeasurement = SingleValue<MeasurementTypeKey.serumUricAcid, "serumUricAcid">;
44
+ /**
45
+ * International normalised ratio (INR) of blood coagulation.
46
+ *
47
+ * @category measurements
48
+ */
49
+ export type InrMeasurement = SingleValue<MeasurementTypeKey.inr, "inr">;
50
+ /**
51
+ * Haemoglobin, in g/dL.
52
+ *
53
+ * @category measurements
54
+ */
55
+ export type HemoglobinMeasurement = SingleValue<MeasurementTypeKey.hemoglobin, "hemoglobin">;
56
+ /**
57
+ * Haematocrit, in %.
58
+ *
59
+ * @category measurements
60
+ */
61
+ export type HematocritMeasurement = SingleValue<MeasurementTypeKey.hematocrit, "hematocrit">;
62
+ /**
63
+ * Total protein, in g/dL.
64
+ *
65
+ * @category measurements
66
+ */
67
+ export type TotalProteinMeasurement = SingleValue<MeasurementTypeKey.totalProtein, "totalProtein">;
68
+ /**
69
+ * White blood cell count, in 10³/µL.
70
+ *
71
+ * @category measurements
72
+ */
73
+ export type WhiteBloodCellsMeasurement = SingleValue<MeasurementTypeKey.whiteBloodCells, "whiteBloodCells">;
74
+ /**
75
+ * Glucose ketone index, a ratio without a unit.
76
+ *
77
+ * @category measurements
78
+ */
79
+ export type GlucoseKetoneIndexMeasurement = SingleValue<MeasurementTypeKey.glucoseKetoneIndex, "glucoseKetoneIndex">;
80
+ /**
81
+ * Stress level score.
82
+ *
83
+ * @category measurements
84
+ */
85
+ export type StressLevelMeasurement = SingleValue<MeasurementTypeKey.stressLevel, "stressLevel">;
86
+ /**
87
+ * Blood alcohol content, in %.
88
+ *
89
+ * @category measurements
90
+ */
91
+ export type BloodAlcoholContentMeasurement = SingleValue<MeasurementTypeKey.bloodAlcoholContent, "bloodAlcoholContent">;
92
+ /**
93
+ * Water drunk, in mL.
94
+ *
95
+ * @category measurements
96
+ */
97
+ export type WaterIntakeMeasurement = SingleValue<MeasurementTypeKey.waterIntake, "waterIntake">;
98
+ /**
99
+ * Food energy eaten, in kcal.
100
+ *
101
+ * @category measurements
102
+ */
103
+ export type CaloriesConsumedMeasurement = SingleValue<MeasurementTypeKey.caloriesConsumed, "caloriesConsumed">;
104
+ /**
105
+ * Carbohydrates eaten, in g.
106
+ *
107
+ * @category measurements
108
+ */
109
+ export type CarbohydrateIntakeMeasurement = SingleValue<MeasurementTypeKey.carbohydrateIntake, "carbohydrateIntake">;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,4 +18,5 @@ export * from "./WalkingHeartRateAverageMeasurement";
18
18
  export * from "./LipidPanelMeasurement";
19
19
  export * from "./RespiratoryTherapyMeasurement";
20
20
  export * from "./BabySleepMeasurement";
21
+ export * from "./SingleValueMeasurements";
21
22
  export * from "./MeasurementSeries";
@@ -34,4 +34,5 @@ __exportStar(require("./WalkingHeartRateAverageMeasurement"), exports);
34
34
  __exportStar(require("./LipidPanelMeasurement"), exports);
35
35
  __exportStar(require("./RespiratoryTherapyMeasurement"), exports);
36
36
  __exportStar(require("./BabySleepMeasurement"), exports);
37
+ __exportStar(require("./SingleValueMeasurements"), exports);
37
38
  __exportStar(require("./MeasurementSeries"), exports);
@@ -26,7 +26,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
26
26
  description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
27
27
  software: {
28
28
  name: "@ovok/core",
29
- version: "0.4.51",
29
+ version: "0.4.52",
30
30
  },
31
31
  fhirVersion: "4.0.1",
32
32
  format: ["json"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.51",
3
+ "version": "0.4.52",
4
4
  "private": false,
5
5
  "main": "dist/next/index.js",
6
6
  "types": "dist/next/index.d.ts",