@ovok/core 0.4.51 → 0.4.53
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/dist/client/observation/measurement-context.d.ts +36 -0
- package/dist/client/observation/measurement-context.js +61 -0
- package/dist/client/observation/observation-coding.js +8 -0
- package/dist/client/observation/services/base-observation-service.js +11 -2
- package/dist/client/observation/services/single-value-services.js +27 -0
- package/dist/client/observation/types/MeasurementTypeKey.d.ts +33 -1
- package/dist/client/observation/types/MeasurementTypeKey.js +32 -0
- package/dist/client/observation/types/ObservationCode.d.ts +29 -1
- package/dist/client/observation/types/ObservationCode.js +28 -0
- package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +3 -0
- package/dist/client/observation/types/measurement/SingleValueMeasurements.d.ts +109 -0
- package/dist/client/observation/types/measurement/SingleValueMeasurements.js +2 -0
- package/dist/client/observation/types/measurement/index.d.ts +1 -0
- package/dist/client/observation/types/measurement/index.js +1 -0
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/next/index.d.ts +2 -0
- package/dist/next/index.js +3 -1
- package/dist/next/resources/measurements/observation-builder.js +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CodeableConcept, Observation } from "@medplum/fhirtypes";
|
|
2
|
+
/**
|
|
3
|
+
* The body position during a reading.
|
|
4
|
+
*
|
|
5
|
+
* @category measurements
|
|
6
|
+
*/
|
|
7
|
+
export type MeasurementBodyPosition = "sitting" | "standing" | "lying";
|
|
8
|
+
/**
|
|
9
|
+
* How the person said they felt when they took a reading.
|
|
10
|
+
*
|
|
11
|
+
* @category measurements
|
|
12
|
+
*/
|
|
13
|
+
export type MeasurementFeeling = "great" | "good" | "okay" | "bad" | "awful";
|
|
14
|
+
/**
|
|
15
|
+
* What the person noted about a reading. It is saved on the reading's main observation.
|
|
16
|
+
*
|
|
17
|
+
* @category measurements
|
|
18
|
+
*/
|
|
19
|
+
export type MeasurementContext = {
|
|
20
|
+
/** Where on the body it was measured, such as the left arm. */
|
|
21
|
+
bodySite?: CodeableConcept;
|
|
22
|
+
/** Sitting, standing or lying. */
|
|
23
|
+
bodyPosition?: MeasurementBodyPosition;
|
|
24
|
+
/** How the person felt. */
|
|
25
|
+
feeling?: MeasurementFeeling;
|
|
26
|
+
/** Anything else the person wrote down. */
|
|
27
|
+
note?: string;
|
|
28
|
+
};
|
|
29
|
+
/** `observation` with the context's fields added; a field the context leaves out stays as it was. */
|
|
30
|
+
export declare function withMeasurementContext(observation: Observation, context: MeasurementContext): Observation;
|
|
31
|
+
/**
|
|
32
|
+
* The context saved on a reading's main observation.
|
|
33
|
+
*
|
|
34
|
+
* @category measurements
|
|
35
|
+
*/
|
|
36
|
+
export declare function readMeasurementContext(observation: Observation): MeasurementContext;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withMeasurementContext = withMeasurementContext;
|
|
4
|
+
exports.readMeasurementContext = readMeasurementContext;
|
|
5
|
+
const fhir_systems_1 = require("./fhir-systems");
|
|
6
|
+
/** The FHIR core extension for a vital sign's body position. */
|
|
7
|
+
const BODY_POSITION_URL = "http://hl7.org/fhir/StructureDefinition/observation-bodyPosition";
|
|
8
|
+
const FEELING_URL = `${fhir_systems_1.OVOK_EXTENSION_BASE_URL}/measurement-feeling`;
|
|
9
|
+
const FEELINGS = ["great", "good", "okay", "bad", "awful"];
|
|
10
|
+
const BODY_POSITION_CODES = {
|
|
11
|
+
sitting: { code: "33586001", display: "Sitting position" },
|
|
12
|
+
standing: { code: "10904000", display: "Orthostatic body position" },
|
|
13
|
+
lying: { code: "102538003", display: "Recumbent body position" },
|
|
14
|
+
};
|
|
15
|
+
const bodyPositionExtension = (position) => ({
|
|
16
|
+
url: BODY_POSITION_URL,
|
|
17
|
+
valueCodeableConcept: { coding: [{ system: fhir_systems_1.SNOMED_SYSTEM, ...BODY_POSITION_CODES[position] }] },
|
|
18
|
+
});
|
|
19
|
+
/** `observation` with the context's fields added; a field the context leaves out stays as it was. */
|
|
20
|
+
function withMeasurementContext(observation, context) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const { bodySite, bodyPosition, feeling, note } = context;
|
|
23
|
+
const extension = [
|
|
24
|
+
...(bodyPosition ? [bodyPositionExtension(bodyPosition)] : []),
|
|
25
|
+
...(feeling ? [{ url: FEELING_URL, valueCode: feeling }] : []),
|
|
26
|
+
];
|
|
27
|
+
return {
|
|
28
|
+
...observation,
|
|
29
|
+
...(bodySite && { bodySite }),
|
|
30
|
+
...(extension.length > 0 && { extension: [...((_a = observation.extension) !== null && _a !== void 0 ? _a : []), ...extension] }),
|
|
31
|
+
...(note && { note: [...((_b = observation.note) !== null && _b !== void 0 ? _b : []), { text: note }] }),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const positionOf = (observation) => {
|
|
35
|
+
var _a, _b, _c, _d, _e;
|
|
36
|
+
const code = (_e = (_d = (_c = (_b = (_a = observation.extension) === null || _a === void 0 ? void 0 : _a.find(({ url }) => url === BODY_POSITION_URL)) === null || _b === void 0 ? void 0 : _b.valueCodeableConcept) === null || _c === void 0 ? void 0 : _c.coding) === null || _d === void 0 ? void 0 : _d.find(({ system }) => system === fhir_systems_1.SNOMED_SYSTEM)) === null || _e === void 0 ? void 0 : _e.code;
|
|
37
|
+
return Object.keys(BODY_POSITION_CODES)
|
|
38
|
+
.find((position) => BODY_POSITION_CODES[position].code === code);
|
|
39
|
+
};
|
|
40
|
+
const feelingOf = (observation) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const code = (_b = (_a = observation.extension) === null || _a === void 0 ? void 0 : _a.find(({ url }) => url === FEELING_URL)) === null || _b === void 0 ? void 0 : _b.valueCode;
|
|
43
|
+
return FEELINGS.find((feeling) => feeling === code);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The context saved on a reading's main observation.
|
|
47
|
+
*
|
|
48
|
+
* @category measurements
|
|
49
|
+
*/
|
|
50
|
+
function readMeasurementContext(observation) {
|
|
51
|
+
var _a;
|
|
52
|
+
const note = (_a = observation.note) === null || _a === void 0 ? void 0 : _a.map(({ text }) => text).filter(Boolean).join("\n");
|
|
53
|
+
const bodyPosition = positionOf(observation);
|
|
54
|
+
const feeling = feelingOf(observation);
|
|
55
|
+
return {
|
|
56
|
+
...(observation.bodySite && { bodySite: observation.bodySite }),
|
|
57
|
+
...(bodyPosition && { bodyPosition }),
|
|
58
|
+
...(feeling && { feeling }),
|
|
59
|
+
...(note && { note }),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -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
|
|
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.
|
package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Measurement } from "../../../../types";
|
|
2
|
+
import { MeasurementContext } from "../../measurement-context";
|
|
2
3
|
import { MeasurementDevice } from "../measurement/MeasurementDevice";
|
|
3
4
|
/**
|
|
4
5
|
* Input for building an Observation body from a measurement.
|
|
@@ -18,4 +19,6 @@ export type GenerateObservationBodyParams = {
|
|
|
18
19
|
formerSourceIds?: string[];
|
|
19
20
|
/** The measurement to convert. */
|
|
20
21
|
measurement: Measurement;
|
|
22
|
+
/** What the person noted about the reading, saved on its main observation. */
|
|
23
|
+
context?: MeasurementContext;
|
|
21
24
|
};
|
|
@@ -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">;
|
|
@@ -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.
|
|
29
|
+
version: "0.4.53",
|
|
30
30
|
},
|
|
31
31
|
fhirVersion: "4.0.1",
|
|
32
32
|
format: ["json"],
|
package/dist/next/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { MemoryStorage } from "./storage/ovok-storage";
|
|
|
4
4
|
export { seriesObservations, readSeries, summarizeSeries } from "../client/observation/series";
|
|
5
5
|
export type { ReadSeries, SeriesObservationParams, SeriesSummary } from "../client/observation/series";
|
|
6
6
|
export { SEGMENT_IDENTIFIER_SYSTEM, SERIES_IDENTIFIER_SYSTEM } from "../client/observation/fhir-systems";
|
|
7
|
+
export { readMeasurementContext } from "../client/observation/measurement-context";
|
|
8
|
+
export type { MeasurementBodyPosition, MeasurementContext, MeasurementFeeling, } from "../client/observation/measurement-context";
|
|
7
9
|
export { IndexedDbOutboxStore } from "./outbox/indexed-db-outbox-store";
|
|
8
10
|
export { MemoryOutboxStore } from "./outbox/memory-outbox-store";
|
|
9
11
|
export { outboxStoreContract } from "./outbox/store-contract";
|
package/dist/next/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.OvokAccountError = exports.OvokValidationError = exports.OvokTimeoutError = exports.OvokServiceError = exports.OvokRateLimitError = exports.OvokPermissionError = exports.OvokNotFoundError = exports.OvokError = exports.OvokConnectionError = exports.OvokConflictError = exports.OvokConfigError = exports.OvokAuthenticationError = exports.browserLifecycle = exports.browserConnectivity = exports.outboxStoreContract = exports.MemoryOutboxStore = exports.IndexedDbOutboxStore = exports.SERIES_IDENTIFIER_SYSTEM = exports.SEGMENT_IDENTIFIER_SYSTEM = exports.summarizeSeries = exports.readSeries = exports.seriesObservations = exports.MemoryStorage = exports.Ovok = void 0;
|
|
17
|
+
exports.OvokAccountError = exports.OvokValidationError = exports.OvokTimeoutError = exports.OvokServiceError = exports.OvokRateLimitError = exports.OvokPermissionError = exports.OvokNotFoundError = exports.OvokError = exports.OvokConnectionError = exports.OvokConflictError = exports.OvokConfigError = exports.OvokAuthenticationError = exports.browserLifecycle = exports.browserConnectivity = exports.outboxStoreContract = exports.MemoryOutboxStore = exports.IndexedDbOutboxStore = exports.readMeasurementContext = exports.SERIES_IDENTIFIER_SYSTEM = exports.SEGMENT_IDENTIFIER_SYSTEM = exports.summarizeSeries = exports.readSeries = exports.seriesObservations = exports.MemoryStorage = exports.Ovok = void 0;
|
|
18
18
|
var ovok_1 = require("./ovok");
|
|
19
19
|
Object.defineProperty(exports, "Ovok", { enumerable: true, get: function () { return ovok_1.Ovok; } });
|
|
20
20
|
var ovok_storage_1 = require("./storage/ovok-storage");
|
|
@@ -26,6 +26,8 @@ Object.defineProperty(exports, "summarizeSeries", { enumerable: true, get: funct
|
|
|
26
26
|
var fhir_systems_1 = require("../client/observation/fhir-systems");
|
|
27
27
|
Object.defineProperty(exports, "SEGMENT_IDENTIFIER_SYSTEM", { enumerable: true, get: function () { return fhir_systems_1.SEGMENT_IDENTIFIER_SYSTEM; } });
|
|
28
28
|
Object.defineProperty(exports, "SERIES_IDENTIFIER_SYSTEM", { enumerable: true, get: function () { return fhir_systems_1.SERIES_IDENTIFIER_SYSTEM; } });
|
|
29
|
+
var measurement_context_1 = require("../client/observation/measurement-context");
|
|
30
|
+
Object.defineProperty(exports, "readMeasurementContext", { enumerable: true, get: function () { return measurement_context_1.readMeasurementContext; } });
|
|
29
31
|
var indexed_db_outbox_store_1 = require("./outbox/indexed-db-outbox-store");
|
|
30
32
|
Object.defineProperty(exports, "IndexedDbOutboxStore", { enumerable: true, get: function () { return indexed_db_outbox_store_1.IndexedDbOutboxStore; } });
|
|
31
33
|
var memory_outbox_store_1 = require("./outbox/memory-outbox-store");
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildObservations = buildObservations;
|
|
4
4
|
const fhir_systems_1 = require("../../../client/observation/fhir-systems");
|
|
5
|
+
const measurement_context_1 = require("../../../client/observation/measurement-context");
|
|
5
6
|
const observation_coding_1 = require("../../../client/observation/observation-coding");
|
|
6
7
|
const reading_group_1 = require("../../../client/observation/reading-group");
|
|
7
8
|
const creator_1 = require("../../../client/observation/services/creator");
|
|
@@ -17,13 +18,17 @@ function buildObservations(params, subject) {
|
|
|
17
18
|
.map((fragment) => observationOf(fragment, subject, device, readingFields))
|
|
18
19
|
.filter(hasValue)
|
|
19
20
|
.map((observation) => datedAt(observation, params.effectiveDateTime));
|
|
20
|
-
const parts = (0, observation_coding_1.withDeviceUser)(observations, measurement.memorySlot);
|
|
21
|
+
const parts = withContext((0, observation_coding_1.withDeviceUser)(observations, measurement.memorySlot), params.context);
|
|
21
22
|
const group = (0, reading_group_1.readingGroupOf)(measurement.measurementTypeKey, parts);
|
|
22
23
|
const reading = group ? [...parts, group] : parts;
|
|
23
24
|
return params.sourceId
|
|
24
25
|
? namedAfterSources(reading, subject, [params.sourceId, ...((_a = params.formerSourceIds) !== null && _a !== void 0 ? _a : [])])
|
|
25
26
|
: reading;
|
|
26
27
|
}
|
|
28
|
+
/** The reading's main observation, its first, carries what the person noted. */
|
|
29
|
+
const withContext = (observations, context) => context && observations[0]
|
|
30
|
+
? [(0, measurement_context_1.withMeasurementContext)(observations[0], context), ...observations.slice(1)]
|
|
31
|
+
: observations;
|
|
27
32
|
/** The caller's time stands in for a measurement that carries none, so every observation of it shares one time. */
|
|
28
33
|
const timedMeasurement = (measurement, effectiveDateTime) => measurement.recordedAt || !effectiveDateTime ? measurement : { ...measurement, recordedAt: effectiveDateTime };
|
|
29
34
|
/** Services without fragments describe their observations as parallel code, value and property lists. */
|