@ovok/core 0.4.52 → 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/types/generate-observation-body/GenerateObservationBodyParams.d.ts +3 -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
|
+
}
|
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
|
};
|
|
@@ -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. */
|