@ovok/core 0.4.50 → 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.
- package/dist/client/cms/locale.d.ts +3 -3
- package/dist/client/cms/locale.js +14 -2
- package/dist/client/observation/observation-coding.js +8 -0
- package/dist/client/observation/series.d.ts +3 -1
- package/dist/client/observation/series.js +12 -4
- 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 +2 -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/resources/measurements/observation-builder.js +6 -3
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Ovok CMS locales
|
|
2
|
+
* The Ovok CMS locales: every ISO 639-1 language, as the CMS carries them; `en` is its default and fallback.
|
|
3
3
|
*/
|
|
4
|
-
export declare const OVOK_CMS_LOCALES: readonly ["en", "de", "
|
|
4
|
+
export declare const OVOK_CMS_LOCALES: readonly ["en", "aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az", "ba", "be", "bg", "bi", "bm", "bn", "bo", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee", "el", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "gv", "ha", "he", "hi", "ho", "hr", "ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ii", "ik", "io", "is", "it", "iu", "ja", "jv", "ka", "kg", "ki", "kj", "kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky", "la", "lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk", "ml", "mn", "mr", "ms", "mt", "my", "na", "nb", "nd", "ne", "ng", "nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa", "pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc", "sd", "se", "sg", "si", "sk", "sl", "sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn", "to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve", "vi", "vo", "wa", "wo", "xh", "yi", "yo", "za", "zh", "zu"];
|
|
5
5
|
/**
|
|
6
|
-
* One of the supported CMS locales
|
|
6
|
+
* One of the supported CMS locales, an ISO 639-1 code such as `en`, `de` or `zh`.
|
|
7
7
|
*/
|
|
8
8
|
export type OvokCmsLocale = (typeof OVOK_CMS_LOCALES)[number];
|
|
9
9
|
/**
|
|
@@ -4,9 +4,21 @@ exports.OVOK_CMS_DEFAULT_LOCALE = exports.OVOK_CMS_LOCALES = void 0;
|
|
|
4
4
|
exports.toCmsLocale = toCmsLocale;
|
|
5
5
|
exports.defaultCmsLocale = defaultCmsLocale;
|
|
6
6
|
/**
|
|
7
|
-
* The Ovok CMS locales
|
|
7
|
+
* The Ovok CMS locales: every ISO 639-1 language, as the CMS carries them; `en` is its default and fallback.
|
|
8
8
|
*/
|
|
9
|
-
exports.OVOK_CMS_LOCALES = [
|
|
9
|
+
exports.OVOK_CMS_LOCALES = [
|
|
10
|
+
"en", "aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az", "ba", "be", "bg", "bi", "bm",
|
|
11
|
+
"bn", "bo", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee",
|
|
12
|
+
"el", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "gv",
|
|
13
|
+
"ha", "he", "hi", "ho", "hr", "ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ii", "ik", "io", "is", "it",
|
|
14
|
+
"iu", "ja", "jv", "ka", "kg", "ki", "kj", "kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky",
|
|
15
|
+
"la", "lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk", "ml", "mn", "mr", "ms", "mt",
|
|
16
|
+
"my", "na", "nb", "nd", "ne", "ng", "nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa",
|
|
17
|
+
"pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc", "sd", "se", "sg", "si", "sk", "sl",
|
|
18
|
+
"sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn",
|
|
19
|
+
"to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve", "vi", "vo", "wa", "wo", "xh", "yi", "yo",
|
|
20
|
+
"za", "zh", "zu"
|
|
21
|
+
];
|
|
10
22
|
/**
|
|
11
23
|
* Locale the CMS answers in when none is requested or supported.
|
|
12
24
|
*/
|
|
@@ -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. */
|
|
@@ -21,6 +21,8 @@ export type SeriesObservationParams = {
|
|
|
21
21
|
* the series has no identifier and is saved once.
|
|
22
22
|
*/
|
|
23
23
|
sourceId?: string;
|
|
24
|
+
/** Earlier sources of the same series; each adds an identifier, so a save finds the series saved under any of them. */
|
|
25
|
+
formerSourceIds?: string[];
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* The values of a series observation, one per slot from `start`.
|
|
@@ -59,7 +61,7 @@ export type SeriesSummary = {
|
|
|
59
61
|
*
|
|
60
62
|
* @category measurements
|
|
61
63
|
*/
|
|
62
|
-
export declare const seriesObservations: ({ series, patientId, device, status, sourceId, }: SeriesObservationParams) => Observation[];
|
|
64
|
+
export declare const seriesObservations: ({ series, patientId, device, status, sourceId, formerSourceIds, }: SeriesObservationParams) => Observation[];
|
|
63
65
|
/**
|
|
64
66
|
* The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other.
|
|
65
67
|
*
|
|
@@ -8,7 +8,14 @@ const creator_1 = require("./services/creator");
|
|
|
8
8
|
const getDeviceObject_1 = require("./utils/getDeviceObject");
|
|
9
9
|
/** FHIR's mark for a slot with no value. */
|
|
10
10
|
const NO_VALUE = "E";
|
|
11
|
-
const identifierFor = (
|
|
11
|
+
const identifierFor = (sources, name, start) => sources.length > 0
|
|
12
|
+
? {
|
|
13
|
+
identifier: sources.map((source) => ({
|
|
14
|
+
system: fhir_systems_1.SERIES_IDENTIFIER_SYSTEM,
|
|
15
|
+
value: `${source}|${name}|${start.toISOString()}`,
|
|
16
|
+
})),
|
|
17
|
+
}
|
|
18
|
+
: {};
|
|
12
19
|
const sampledData = (values, decimals) => values
|
|
13
20
|
.map((value) => (value === null || !Number.isFinite(value) ? NO_VALUE : String(Number(value.toFixed(decimals)))))
|
|
14
21
|
.join(" ");
|
|
@@ -21,8 +28,9 @@ const sampledData = (values, decimals) => values
|
|
|
21
28
|
*
|
|
22
29
|
* @category measurements
|
|
23
30
|
*/
|
|
24
|
-
const seriesObservations = ({ series, patientId, device, status = "final", sourceId, }) => {
|
|
31
|
+
const seriesObservations = ({ series, patientId, device, status = "final", sourceId, formerSourceIds = [], }) => {
|
|
25
32
|
const source = sourceId !== null && sourceId !== void 0 ? sourceId : ((device === null || device === void 0 ? void 0 : device.sn) || (device === null || device === void 0 ? void 0 : device.id));
|
|
33
|
+
const sources = source ? [source, ...formerSourceIds] : [];
|
|
26
34
|
const service = creator_1.ObservationServiceCreator.getInstance().getService(series.measurementTypeKey);
|
|
27
35
|
const codes = service.getObservationCodes();
|
|
28
36
|
const slots = Math.max(0, ...Object.values(series.values).map((values) => { var _a; return (_a = values === null || values === void 0 ? void 0 : values.length) !== null && _a !== void 0 ? _a : 0; }));
|
|
@@ -50,11 +58,11 @@ const seriesObservations = ({ series, patientId, device, status = "final", sourc
|
|
|
50
58
|
dimensions: 1,
|
|
51
59
|
data: sampledData(values, field.decimals),
|
|
52
60
|
},
|
|
53
|
-
...identifierFor(
|
|
61
|
+
...identifierFor(sources, field.key, series.start),
|
|
54
62
|
}];
|
|
55
63
|
});
|
|
56
64
|
const group = (0, reading_group_1.readingGroupOf)(series.measurementTypeKey, parts);
|
|
57
|
-
return group ? [...parts, { ...group, ...identifierFor(
|
|
65
|
+
return group ? [...parts, { ...group, ...identifierFor(sources, "group", series.start) }] : parts;
|
|
58
66
|
};
|
|
59
67
|
exports.seriesObservations = seriesObservations;
|
|
60
68
|
/**
|
|
@@ -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
|
@@ -14,6 +14,8 @@ export type GenerateObservationBodyParams = {
|
|
|
14
14
|
patientId?: string;
|
|
15
15
|
/** Stable ID from the originating device reading. */
|
|
16
16
|
sourceId?: string;
|
|
17
|
+
/** Earlier stable IDs of the same reading; a save that finds an observation under any of them creates nothing. */
|
|
18
|
+
formerSourceIds?: string[];
|
|
17
19
|
/** The measurement to convert. */
|
|
18
20
|
measurement: Measurement;
|
|
19
21
|
};
|
|
@@ -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.52",
|
|
30
30
|
},
|
|
31
31
|
fhirVersion: "4.0.1",
|
|
32
32
|
format: ["json"],
|
|
@@ -8,6 +8,7 @@ const creator_1 = require("../../../client/observation/services/creator");
|
|
|
8
8
|
const getDeviceObject_1 = require("../../../client/observation/utils/getDeviceObject");
|
|
9
9
|
/** One measurement's Observations about `subject`, a reference such as `Patient/1`; several end with their group. */
|
|
10
10
|
function buildObservations(params, subject) {
|
|
11
|
+
var _a;
|
|
11
12
|
const measurement = timedMeasurement(params.measurement, params.effectiveDateTime);
|
|
12
13
|
const service = creator_1.ObservationServiceCreator.getInstance().getService(measurement.measurementTypeKey);
|
|
13
14
|
const device = (0, getDeviceObject_1.getDeviceObject)(params.device);
|
|
@@ -19,7 +20,9 @@ function buildObservations(params, subject) {
|
|
|
19
20
|
const parts = (0, observation_coding_1.withDeviceUser)(observations, measurement.memorySlot);
|
|
20
21
|
const group = (0, reading_group_1.readingGroupOf)(measurement.measurementTypeKey, parts);
|
|
21
22
|
const reading = group ? [...parts, group] : parts;
|
|
22
|
-
return params.sourceId
|
|
23
|
+
return params.sourceId
|
|
24
|
+
? namedAfterSources(reading, subject, [params.sourceId, ...((_a = params.formerSourceIds) !== null && _a !== void 0 ? _a : [])])
|
|
25
|
+
: reading;
|
|
23
26
|
}
|
|
24
27
|
/** The caller's time stands in for a measurement that carries none, so every observation of it shares one time. */
|
|
25
28
|
const timedMeasurement = (measurement, effectiveDateTime) => measurement.recordedAt || !effectiveDateTime ? measurement : { ...measurement, recordedAt: effectiveDateTime };
|
|
@@ -54,13 +57,13 @@ const hasValue = (observation) => {
|
|
|
54
57
|
const datedAt = (observation, effectiveDateTime) => effectiveDateTime && !observation.effectivePeriod
|
|
55
58
|
? { ...observation, effectiveDateTime: effectiveDateTime.toISOString() }
|
|
56
59
|
: observation;
|
|
57
|
-
const
|
|
60
|
+
const namedAfterSources = (observations, subject, sourceIds) => observations.map((observation, index) => {
|
|
58
61
|
var _a;
|
|
59
62
|
return ({
|
|
60
63
|
...observation,
|
|
61
64
|
identifier: [
|
|
62
65
|
...((_a = observation.identifier) !== null && _a !== void 0 ? _a : []),
|
|
63
|
-
{ system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM, value: `${subject}/${sourceId}/${index}` },
|
|
66
|
+
...sourceIds.map((sourceId) => ({ system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM, value: `${subject}/${sourceId}/${index}` })),
|
|
64
67
|
],
|
|
65
68
|
});
|
|
66
69
|
});
|