@ovok/core 0.3.23 → 0.3.24
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/methods/observationsToMeasurements.d.ts +2 -2
- package/dist/client/observation/methods/observationsToMeasurements.js +11 -0
- package/dist/client/observation/services/baby-sleep.d.ts +28 -0
- package/dist/client/observation/services/baby-sleep.js +69 -0
- package/dist/client/observation/services/creator.js +2 -0
- package/dist/client/observation/types/MeasurementTypeKey.d.ts +2 -1
- package/dist/client/observation/types/MeasurementTypeKey.js +1 -0
- package/dist/client/observation/types/ObservationCode.d.ts +2 -1
- package/dist/client/observation/types/ObservationCode.js +1 -0
- package/dist/client/observation/types/measurement/BabySleepMeasurement.d.ts +12 -0
- package/dist/client/observation/types/measurement/BabySleepMeasurement.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/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observation } from "@medplum/fhirtypes";
|
|
2
|
-
import { BloodGlucoseMeasurement, BloodPressureMeasurement, BodyTemperatureMeasurement, BodyWeightMeasurement, EcgMeasurement, HeartRateMeasurement, HeartRateVariabilityMeasurement, LipidPanelMeasurement, Measurement, MeasurementTypeKey, PulseOximeterMeasurement, RespiratoryRateMeasurement, RespiratoryTherapyMeasurement, RestingHeartRateMeasurement, StepCountMeasurement, UrineAnalyzeMeasurement, Vo2MaxMeasurement, WalkingHeartRateAverageMeasurement } from "../../../types";
|
|
3
|
-
export type SupportedMeasurement = BloodGlucoseMeasurement | BloodPressureMeasurement | BodyTemperatureMeasurement | BodyWeightMeasurement | EcgMeasurement | HeartRateMeasurement | HeartRateVariabilityMeasurement | LipidPanelMeasurement | PulseOximeterMeasurement | RespiratoryRateMeasurement | RespiratoryTherapyMeasurement | RestingHeartRateMeasurement | StepCountMeasurement | UrineAnalyzeMeasurement | Vo2MaxMeasurement | WalkingHeartRateAverageMeasurement | Measurement;
|
|
2
|
+
import { BabySleepMeasurement, BloodGlucoseMeasurement, BloodPressureMeasurement, BodyTemperatureMeasurement, BodyWeightMeasurement, EcgMeasurement, HeartRateMeasurement, HeartRateVariabilityMeasurement, LipidPanelMeasurement, Measurement, MeasurementTypeKey, PulseOximeterMeasurement, RespiratoryRateMeasurement, RespiratoryTherapyMeasurement, RestingHeartRateMeasurement, StepCountMeasurement, UrineAnalyzeMeasurement, Vo2MaxMeasurement, WalkingHeartRateAverageMeasurement } from "../../../types";
|
|
3
|
+
export type SupportedMeasurement = BloodGlucoseMeasurement | BabySleepMeasurement | BloodPressureMeasurement | BodyTemperatureMeasurement | BodyWeightMeasurement | EcgMeasurement | HeartRateMeasurement | HeartRateVariabilityMeasurement | LipidPanelMeasurement | PulseOximeterMeasurement | RespiratoryRateMeasurement | RespiratoryTherapyMeasurement | RestingHeartRateMeasurement | StepCountMeasurement | UrineAnalyzeMeasurement | Vo2MaxMeasurement | WalkingHeartRateAverageMeasurement | Measurement;
|
|
4
4
|
type SupportedType = Exclude<MeasurementTypeKey, MeasurementTypeKey.symptomQuestionnaire>;
|
|
5
5
|
export type ObservationGrouping = "hasMember" | "time" | ((observation: Observation, index: number, observations: readonly Observation[]) => string);
|
|
6
6
|
export interface ObservationsToMeasurementsOptions {
|
|
@@ -384,6 +384,12 @@ const inverseGroup = (type, observations) => {
|
|
|
384
384
|
measurementTypeKey: type,
|
|
385
385
|
components: respiratoryComponents(observations),
|
|
386
386
|
};
|
|
387
|
+
case types_1.MeasurementTypeKey.babySleep:
|
|
388
|
+
return {
|
|
389
|
+
...measurement,
|
|
390
|
+
measurementTypeKey: type,
|
|
391
|
+
components: respiratoryComponents(observations),
|
|
392
|
+
};
|
|
387
393
|
default:
|
|
388
394
|
return measurement;
|
|
389
395
|
}
|
|
@@ -415,6 +421,7 @@ const codesForType = {
|
|
|
415
421
|
...LIPID_FIELDS.flatMap(({ codes }) => codes),
|
|
416
422
|
],
|
|
417
423
|
[types_1.MeasurementTypeKey.respiratoryTherapy]: [types_1.ObservationCode.RESPIRATORY_THERAPY],
|
|
424
|
+
[types_1.MeasurementTypeKey.babySleep]: [types_1.ObservationCode.BABY_SLEEP],
|
|
418
425
|
};
|
|
419
426
|
const observationCodesForTypes = (types) => [...new Set(types.flatMap((type) => { var _a; return (_a = codesForType[type]) !== null && _a !== void 0 ? _a : []; }))].join(",");
|
|
420
427
|
exports.observationCodesForTypes = observationCodesForTypes;
|
|
@@ -437,6 +444,10 @@ const observationsToMeasurements = (observations, types, options = {}) => {
|
|
|
437
444
|
respiratoryComponents(group.observations).length === 0) {
|
|
438
445
|
return;
|
|
439
446
|
}
|
|
447
|
+
if (type === types_1.MeasurementTypeKey.babySleep &&
|
|
448
|
+
respiratoryComponents(group.observations).length === 0) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
440
451
|
output.push(inverseGroup(type, group.observations));
|
|
441
452
|
});
|
|
442
453
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Observation } from "@medplum/fhirtypes";
|
|
2
|
+
import { BabySleepMeasurement, Measurement, MeasurementTypeKey, ObservationCode } from "../../../types";
|
|
3
|
+
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
4
|
+
import { Sample } from "../types/generate-measurement/Sample";
|
|
5
|
+
import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
|
|
6
|
+
import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
|
|
7
|
+
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
8
|
+
import { BaseObservationService } from "./base-observation-service";
|
|
9
|
+
export declare class BabySleepService extends BaseObservationService<BabySleepMeasurement> {
|
|
10
|
+
protected measurementTypeKey: MeasurementTypeKey;
|
|
11
|
+
protected measurementTypeName: string;
|
|
12
|
+
protected observationMetadata: ObservationMetadata<BabySleepMeasurement>[];
|
|
13
|
+
generateObservationFragments(measurement: Measurement): ObservationFragment[];
|
|
14
|
+
getObservationCodes(): {
|
|
15
|
+
coding: {
|
|
16
|
+
code: ObservationCode;
|
|
17
|
+
display: string;
|
|
18
|
+
system: string;
|
|
19
|
+
}[];
|
|
20
|
+
}[];
|
|
21
|
+
getAdditionalProperties(measurement: Measurement): Partial<Observation>[];
|
|
22
|
+
generateValues(_measurement: Measurement): ObservationValue[];
|
|
23
|
+
getUnits(): string[];
|
|
24
|
+
getMeasurementDisplay(measurement: Measurement): string;
|
|
25
|
+
getObservationDisplay(observations: Observation[]): string | undefined;
|
|
26
|
+
convertSamplesToMeasurement(_samples: Sample[]): BabySleepMeasurement;
|
|
27
|
+
convertRecordToMeasurement(_record: RecordResult<RecordType>): BabySleepMeasurement;
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BabySleepService = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const base_observation_service_1 = require("./base-observation-service");
|
|
6
|
+
const BABY_SLEEP_SYSTEM = "https://sdk.ovok.com/fhir/CodeSystem/measurement-type";
|
|
7
|
+
const recordedAt = (measurement) => measurement.recordedAt instanceof Date &&
|
|
8
|
+
!Number.isNaN(measurement.recordedAt.getTime())
|
|
9
|
+
? measurement.recordedAt.toISOString()
|
|
10
|
+
: new Date().toISOString();
|
|
11
|
+
class BabySleepService extends base_observation_service_1.BaseObservationService {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.measurementTypeKey = types_1.MeasurementTypeKey.babySleep;
|
|
15
|
+
this.measurementTypeName = "baby sleep";
|
|
16
|
+
this.observationMetadata = [];
|
|
17
|
+
}
|
|
18
|
+
generateObservationFragments(measurement) {
|
|
19
|
+
const babySleep = this.getCastedMeasurement(measurement);
|
|
20
|
+
if (babySleep.components.length === 0) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return [{
|
|
24
|
+
code: {
|
|
25
|
+
coding: [{
|
|
26
|
+
code: types_1.ObservationCode.BABY_SLEEP,
|
|
27
|
+
display: "Baby sleep observation",
|
|
28
|
+
system: BABY_SLEEP_SYSTEM,
|
|
29
|
+
}],
|
|
30
|
+
},
|
|
31
|
+
additionalProperties: {
|
|
32
|
+
effectiveDateTime: recordedAt(babySleep),
|
|
33
|
+
component: babySleep.components,
|
|
34
|
+
},
|
|
35
|
+
}];
|
|
36
|
+
}
|
|
37
|
+
getObservationCodes() {
|
|
38
|
+
return [{
|
|
39
|
+
coding: [{
|
|
40
|
+
code: types_1.ObservationCode.BABY_SLEEP,
|
|
41
|
+
display: "Baby sleep observation",
|
|
42
|
+
system: BABY_SLEEP_SYSTEM,
|
|
43
|
+
}],
|
|
44
|
+
}];
|
|
45
|
+
}
|
|
46
|
+
getAdditionalProperties(measurement) {
|
|
47
|
+
return [{ effectiveDateTime: recordedAt(this.getCastedMeasurement(measurement)) }];
|
|
48
|
+
}
|
|
49
|
+
generateValues(_measurement) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
getUnits() {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
getMeasurementDisplay(measurement) {
|
|
56
|
+
return `${this.getCastedMeasurement(measurement).components.length} baby sleep metrics`;
|
|
57
|
+
}
|
|
58
|
+
getObservationDisplay(observations) {
|
|
59
|
+
const count = observations.reduce((total, observation) => { var _a, _b; return total + ((_b = (_a = observation.component) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
60
|
+
return count ? `${count} baby sleep metrics` : undefined;
|
|
61
|
+
}
|
|
62
|
+
convertSamplesToMeasurement(_samples) {
|
|
63
|
+
throw new Error("Baby sleep samples are not supported.");
|
|
64
|
+
}
|
|
65
|
+
convertRecordToMeasurement(_record) {
|
|
66
|
+
throw new Error("Baby sleep Health Connect records are not supported.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.BabySleepService = BabySleepService;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObservationServiceCreator = void 0;
|
|
4
4
|
const types_1 = require("../../../types");
|
|
5
|
+
const baby_sleep_1 = require("./baby-sleep");
|
|
5
6
|
const blood_glucose_1 = require("./blood-glucose");
|
|
6
7
|
const blood_oxygen_1 = require("./blood-oxygen");
|
|
7
8
|
const blood_pressure_1 = require("./blood-pressure");
|
|
@@ -47,6 +48,7 @@ class ObservationServiceCreator {
|
|
|
47
48
|
this.services.set(types_1.MeasurementTypeKey.uricAcid, new uric_acid_service_1.UricAcidService());
|
|
48
49
|
this.services.set(types_1.MeasurementTypeKey.lipidPanel, new lipid_panel_1.LipidPanelService());
|
|
49
50
|
this.services.set(types_1.MeasurementTypeKey.respiratoryTherapy, new respiratory_therapy_1.RespiratoryTherapyService());
|
|
51
|
+
this.services.set(types_1.MeasurementTypeKey.babySleep, new baby_sleep_1.BabySleepService());
|
|
50
52
|
}
|
|
51
53
|
getService(type) {
|
|
52
54
|
const service = this.services.get(type);
|
|
@@ -20,5 +20,6 @@ export declare enum MeasurementTypeKey {
|
|
|
20
20
|
restingHeartRate = "resting-heart-rate",
|
|
21
21
|
walkingHeartRateAverage = "walking-heart-rate-average",
|
|
22
22
|
lipidPanel = "lipid-panel",
|
|
23
|
-
respiratoryTherapy = "respiratory-therapy"
|
|
23
|
+
respiratoryTherapy = "respiratory-therapy",
|
|
24
|
+
babySleep = "baby-sleep"
|
|
24
25
|
}
|
|
@@ -25,4 +25,5 @@ var MeasurementTypeKey;
|
|
|
25
25
|
MeasurementTypeKey["walkingHeartRateAverage"] = "walking-heart-rate-average";
|
|
26
26
|
MeasurementTypeKey["lipidPanel"] = "lipid-panel";
|
|
27
27
|
MeasurementTypeKey["respiratoryTherapy"] = "respiratory-therapy";
|
|
28
|
+
MeasurementTypeKey["babySleep"] = "baby-sleep";
|
|
28
29
|
})(MeasurementTypeKey || (exports.MeasurementTypeKey = MeasurementTypeKey = {}));
|
|
@@ -45,5 +45,6 @@ export declare enum ObservationCode {
|
|
|
45
45
|
TRIGLYCERIDES_MASS = "2571-8",
|
|
46
46
|
TRIGLYCERIDES_MOLAR = "14927-8",
|
|
47
47
|
TOTAL_CHOLESTEROL_HDL_RATIO = "9830-1",
|
|
48
|
-
RESPIRATORY_THERAPY = "respiratory-therapy"
|
|
48
|
+
RESPIRATORY_THERAPY = "respiratory-therapy",
|
|
49
|
+
BABY_SLEEP = "baby-sleep"
|
|
49
50
|
}
|
|
@@ -50,4 +50,5 @@ var ObservationCode;
|
|
|
50
50
|
ObservationCode["TRIGLYCERIDES_MOLAR"] = "14927-8";
|
|
51
51
|
ObservationCode["TOTAL_CHOLESTEROL_HDL_RATIO"] = "9830-1";
|
|
52
52
|
ObservationCode["RESPIRATORY_THERAPY"] = "respiratory-therapy";
|
|
53
|
+
ObservationCode["BABY_SLEEP"] = "baby-sleep";
|
|
53
54
|
})(ObservationCode || (exports.ObservationCode = ObservationCode = {}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ObservationComponent } from "@medplum/fhirtypes";
|
|
2
|
+
import { MeasurementTypeKey } from "../MeasurementTypeKey";
|
|
3
|
+
import { Measurement } from "./Measurement";
|
|
4
|
+
/**
|
|
5
|
+
* One BabySleep observation, such as a clip sample or a session summary.
|
|
6
|
+
* Core preserves the coded components supplied by the device adapter rather than
|
|
7
|
+
* assigning vendor-specific meaning to sleep states, posture, or device status.
|
|
8
|
+
*/
|
|
9
|
+
export type BabySleepMeasurement = Measurement & {
|
|
10
|
+
measurementTypeKey: MeasurementTypeKey.babySleep;
|
|
11
|
+
components: ObservationComponent[];
|
|
12
|
+
};
|
|
@@ -33,3 +33,4 @@ __exportStar(require("./Vo2MaxMeasurement"), exports);
|
|
|
33
33
|
__exportStar(require("./WalkingHeartRateAverageMeasurement"), exports);
|
|
34
34
|
__exportStar(require("./LipidPanelMeasurement"), exports);
|
|
35
35
|
__exportStar(require("./RespiratoryTherapyMeasurement"), exports);
|
|
36
|
+
__exportStar(require("./BabySleepMeasurement"), exports);
|
|
@@ -48,7 +48,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
|
|
|
48
48
|
description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
|
|
49
49
|
software: {
|
|
50
50
|
name: "@ovok/core",
|
|
51
|
-
version: "0.3.
|
|
51
|
+
version: "0.3.24",
|
|
52
52
|
},
|
|
53
53
|
fhirVersion: "4.0.1",
|
|
54
54
|
format: ["json"],
|