@ovok/core 0.4.37 → 0.4.38
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/auth/account-storage.d.ts +1 -0
- package/dist/client/auth/account-storage.js +2 -1
- package/dist/{utils → client}/auth/exchange-code.d.ts +1 -1
- package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.js +5 -17
- package/dist/{utils → client}/auth/handle-tenant-code.d.ts +1 -1
- package/dist/{utils → client}/auth/handle-tenant-code.js +1 -1
- package/dist/client/auth/methods/appleLogin.js +2 -6
- package/dist/client/auth/methods/changePassword.js +2 -1
- package/dist/client/auth/methods/getSessions.js +2 -1
- package/dist/client/auth/methods/googleLogin.js +2 -6
- package/dist/client/auth/methods/login.js +26 -44
- package/dist/client/auth/methods/logout.js +2 -1
- package/dist/client/auth/methods/requestDeleteUser.js +5 -4
- package/dist/client/auth/methods/revokeSessions.js +2 -1
- package/dist/client/auth/methods/socialLogin.d.ts +7 -0
- package/dist/client/auth/methods/socialLogin.js +11 -0
- package/dist/client/auth/session-fetch.js +5 -6
- package/dist/client/auth/session-http.js +8 -19
- package/dist/client/auth/sha256.d.ts +2 -0
- package/dist/client/auth/sha256.js +65 -0
- package/dist/{utils → client}/auth/start-login.d.ts +2 -2
- package/dist/client/change-history/methods.js +2 -1
- package/dist/client/cms/methods.js +16 -28
- package/dist/client/consent/methods.js +3 -2
- package/dist/client/email/methods.js +2 -1
- package/dist/client/errors/ovok-error-utils.d.ts +6 -0
- package/dist/client/errors/ovok-error-utils.js +10 -1
- package/dist/client/errors/ovok-error.js +6 -13
- package/dist/client/errors/rate-limit-error.js +2 -6
- package/dist/client/experience/methods.js +13 -12
- package/dist/client/invites/methods.js +8 -12
- package/dist/client/notifications/methods.js +4 -3
- package/dist/client/observation/fhir-systems.d.ts +4 -0
- package/dist/client/observation/fhir-systems.js +7 -0
- package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +23 -29
- package/dist/client/observation/methods/getLatestObservationsByCodes.js +6 -9
- package/dist/client/observation/methods/observationsToMeasurements.js +44 -91
- package/dist/client/observation/services/base-observation-service.js +4 -3
- package/dist/client/observation/services/blood-pressure.js +1 -4
- package/dist/client/observation/services/{baby-sleep.d.ts → component-observation-services.d.ts} +18 -13
- package/dist/client/observation/services/component-observation-services.js +69 -0
- package/dist/client/observation/services/creator.d.ts +1 -2
- package/dist/client/observation/services/creator.js +14 -18
- package/dist/client/observation/services/ecg-observation-fragments.js +5 -6
- package/dist/client/observation/services/ecg.js +3 -2
- package/dist/client/observation/services/lipid-panel.js +8 -12
- package/dist/client/observation/services/measurement-time.d.ts +4 -0
- package/dist/client/observation/services/measurement-time.js +6 -0
- package/dist/client/observation/services/single-value-services.d.ts +5 -0
- package/dist/client/observation/services/single-value-services.js +6 -1
- package/dist/client/observation/services/uric-acid-service.js +6 -7
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +2 -458
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +0 -6
- package/dist/client/offline/offline-measurement-queue.js +31 -28
- package/dist/client/ovok-client.d.ts +5 -2
- package/dist/client/ovok-client.js +46 -42
- package/dist/client/patient/methods.js +25 -25
- package/dist/client/patient-sharing/methods.js +4 -3
- package/dist/client/platform/methods.js +17 -16
- package/dist/client/platform/types.d.ts +3 -6
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -1
- package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +2 -1
- package/dist/client/request-options.d.ts +2 -0
- package/dist/client/request-options.js +6 -0
- package/dist/client/signals/errors.js +2 -6
- package/dist/client/signals/methods.js +14 -13
- package/dist/client/slim/live-read.d.ts +4 -0
- package/dist/client/slim/live-read.js +87 -0
- package/dist/client/slim/methods.d.ts +3 -0
- package/dist/client/slim/methods.js +63 -146
- package/dist/client/storage.js +3 -2
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/conformance/capability.js +8 -7
- package/dist/hooks/account-hooks.js +1 -1
- package/dist/hooks/api-hooks.d.ts +5 -6
- package/dist/hooks/api-hooks.js +10 -24
- package/dist/hooks/cms-hooks.js +8 -13
- package/dist/hooks/experience-hooks.js +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/invites-hooks.js +0 -1
- package/dist/hooks/notification-hooks.d.ts +4 -1
- package/dist/hooks/notification-hooks.js +28 -35
- package/dist/hooks/notification-invalidation.d.ts +1 -1
- package/dist/hooks/notification-note-hooks.js +13 -28
- package/dist/hooks/observation-hooks.js +2 -4
- package/dist/hooks/patient-hooks.js +1 -1
- package/dist/hooks/patient-sharing-hooks.js +1 -2
- package/dist/hooks/poll-hooks.js +10 -8
- package/dist/hooks/signals-alert-hooks.js +4 -6
- package/package.json +1 -1
- package/dist/client/observation/services/baby-sleep.js +0 -69
- package/dist/client/observation/services/respiratory-therapy.d.ts +0 -28
- package/dist/client/observation/services/respiratory-therapy.js +0 -69
- package/dist/utils/auth/sha256.d.ts +0 -8
- package/dist/utils/auth/sha256.js +0 -300
- /package/dist/{utils → client}/auth/exchange-code.js +0 -0
- /package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.d.ts +0 -0
- /package/dist/{utils → client}/auth/start-login.js +0 -0
|
@@ -35,10 +35,7 @@ class BloodPressureService extends base_observation_service_1.BaseObservationSer
|
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
primaryCode: types_1.ObservationCode.BLOOD_PRESSURE_HEART_RATE,
|
|
38
|
-
additionalCodes: [
|
|
39
|
-
types_1.ObservationCode.HEART_RATE,
|
|
40
|
-
types_1.ObservationCode.BLOOD_PRESSURE_HEART_RATE,
|
|
41
|
-
],
|
|
38
|
+
additionalCodes: [types_1.ObservationCode.HEART_RATE],
|
|
42
39
|
display: "Blood Pressure Heart Rate",
|
|
43
40
|
unit: "bpm",
|
|
44
41
|
valueKey: "heartRate",
|
package/dist/client/observation/services/{baby-sleep.d.ts → component-observation-services.d.ts}
RENAMED
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
import { Observation } from "@medplum/fhirtypes";
|
|
2
|
-
import {
|
|
1
|
+
import { CodeableConcept, Observation, ObservationComponent } from "@medplum/fhirtypes";
|
|
2
|
+
import { Measurement, MeasurementTypeKey, ObservationCode } from "../../../types";
|
|
3
3
|
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
4
4
|
import { Sample } from "../types/generate-measurement/Sample";
|
|
5
5
|
import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
|
|
6
6
|
import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
|
|
7
7
|
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
8
8
|
import { BaseObservationService } from "./base-observation-service";
|
|
9
|
-
|
|
9
|
+
type ComponentMeasurement = Measurement & {
|
|
10
|
+
components: ObservationComponent[];
|
|
11
|
+
};
|
|
12
|
+
/** One observation that carries the device adapter's coded components as they are. */
|
|
13
|
+
declare class ComponentObservationService extends BaseObservationService<ComponentMeasurement> {
|
|
10
14
|
protected measurementTypeKey: MeasurementTypeKey;
|
|
11
15
|
protected measurementTypeName: string;
|
|
12
|
-
|
|
16
|
+
private readonly code;
|
|
17
|
+
protected observationMetadata: ObservationMetadata<ComponentMeasurement>[];
|
|
18
|
+
private readonly title;
|
|
19
|
+
constructor(measurementTypeKey: MeasurementTypeKey, measurementTypeName: string, code: ObservationCode);
|
|
13
20
|
generateObservationFragments(measurement: Measurement): ObservationFragment[];
|
|
14
|
-
getObservationCodes():
|
|
15
|
-
coding: {
|
|
16
|
-
code: ObservationCode;
|
|
17
|
-
display: string;
|
|
18
|
-
system: string;
|
|
19
|
-
}[];
|
|
20
|
-
}[];
|
|
21
|
+
getObservationCodes(): CodeableConcept[];
|
|
21
22
|
getAdditionalProperties(measurement: Measurement): Partial<Observation>[];
|
|
22
23
|
generateValues(_measurement: Measurement): ObservationValue[];
|
|
23
24
|
getUnits(): string[];
|
|
24
25
|
getMeasurementDisplay(measurement: Measurement): string;
|
|
25
26
|
getObservationDisplay(observations: Observation[]): string | undefined;
|
|
26
|
-
convertSamplesToMeasurement(_samples: Sample[]):
|
|
27
|
-
convertRecordToMeasurement(_record: RecordResult<RecordType>):
|
|
27
|
+
convertSamplesToMeasurement(_samples: Sample[]): ComponentMeasurement;
|
|
28
|
+
convertRecordToMeasurement(_record: RecordResult<RecordType>): ComponentMeasurement;
|
|
29
|
+
private codeableConcept;
|
|
28
30
|
}
|
|
31
|
+
export declare const babySleepService: () => ComponentObservationService;
|
|
32
|
+
export declare const respiratoryTherapyService: () => ComponentObservationService;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.respiratoryTherapyService = exports.babySleepService = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const base_observation_service_1 = require("./base-observation-service");
|
|
6
|
+
const measurement_time_1 = require("./measurement-time");
|
|
7
|
+
const MEASUREMENT_TYPE_SYSTEM = "https://sdk.ovok.com/fhir/CodeSystem/measurement-type";
|
|
8
|
+
/** One observation that carries the device adapter's coded components as they are. */
|
|
9
|
+
class ComponentObservationService extends base_observation_service_1.BaseObservationService {
|
|
10
|
+
constructor(measurementTypeKey, measurementTypeName, code) {
|
|
11
|
+
super();
|
|
12
|
+
this.measurementTypeKey = measurementTypeKey;
|
|
13
|
+
this.measurementTypeName = measurementTypeName;
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.observationMetadata = [];
|
|
16
|
+
this.title = measurementTypeName.charAt(0).toUpperCase() + measurementTypeName.slice(1);
|
|
17
|
+
}
|
|
18
|
+
generateObservationFragments(measurement) {
|
|
19
|
+
const { components, recordedAt } = this.getCastedMeasurement(measurement);
|
|
20
|
+
if (components.length === 0) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return [{
|
|
24
|
+
code: this.codeableConcept(),
|
|
25
|
+
additionalProperties: {
|
|
26
|
+
effectiveDateTime: (0, measurement_time_1.recordedAtOrNow)({ recordedAt }).toISOString(),
|
|
27
|
+
component: components,
|
|
28
|
+
},
|
|
29
|
+
}];
|
|
30
|
+
}
|
|
31
|
+
getObservationCodes() {
|
|
32
|
+
return [this.codeableConcept()];
|
|
33
|
+
}
|
|
34
|
+
getAdditionalProperties(measurement) {
|
|
35
|
+
return [{ effectiveDateTime: (0, measurement_time_1.recordedAtOrNow)(this.getCastedMeasurement(measurement)).toISOString() }];
|
|
36
|
+
}
|
|
37
|
+
generateValues(_measurement) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
getUnits() {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
getMeasurementDisplay(measurement) {
|
|
44
|
+
return `${this.getCastedMeasurement(measurement).components.length} ${this.measurementTypeName} metrics`;
|
|
45
|
+
}
|
|
46
|
+
getObservationDisplay(observations) {
|
|
47
|
+
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);
|
|
48
|
+
return count ? `${count} ${this.measurementTypeName} metrics` : undefined;
|
|
49
|
+
}
|
|
50
|
+
convertSamplesToMeasurement(_samples) {
|
|
51
|
+
throw new Error(`${this.title} samples are not supported.`);
|
|
52
|
+
}
|
|
53
|
+
convertRecordToMeasurement(_record) {
|
|
54
|
+
throw new Error(`${this.title} Health Connect records are not supported.`);
|
|
55
|
+
}
|
|
56
|
+
codeableConcept() {
|
|
57
|
+
return {
|
|
58
|
+
coding: [{
|
|
59
|
+
code: this.code,
|
|
60
|
+
display: `${this.title} observation`,
|
|
61
|
+
system: MEASUREMENT_TYPE_SYSTEM,
|
|
62
|
+
}],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const babySleepService = () => new ComponentObservationService(types_1.MeasurementTypeKey.babySleep, "baby sleep", types_1.ObservationCode.BABY_SLEEP);
|
|
67
|
+
exports.babySleepService = babySleepService;
|
|
68
|
+
const respiratoryTherapyService = () => new ComponentObservationService(types_1.MeasurementTypeKey.respiratoryTherapy, "respiratory therapy", types_1.ObservationCode.RESPIRATORY_THERAPY);
|
|
69
|
+
exports.respiratoryTherapyService = respiratoryTherapyService;
|
|
@@ -2,9 +2,8 @@ import { MeasurementTypeKey } from "../../../types";
|
|
|
2
2
|
import { IObservationService } from "../types/IObservationService";
|
|
3
3
|
export declare class ObservationServiceCreator {
|
|
4
4
|
private static instance;
|
|
5
|
-
private services;
|
|
5
|
+
private readonly services;
|
|
6
6
|
private constructor();
|
|
7
7
|
static getInstance(): ObservationServiceCreator;
|
|
8
|
-
private initializeServices;
|
|
9
8
|
getService(type: MeasurementTypeKey): IObservationService;
|
|
10
9
|
}
|
|
@@ -2,19 +2,29 @@
|
|
|
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");
|
|
6
5
|
const blood_oxygen_1 = require("./blood-oxygen");
|
|
7
6
|
const blood_pressure_1 = require("./blood-pressure");
|
|
7
|
+
const component_observation_services_1 = require("./component-observation-services");
|
|
8
8
|
const ecg_1 = require("./ecg");
|
|
9
9
|
const lipid_panel_1 = require("./lipid-panel");
|
|
10
|
-
const respiratory_therapy_1 = require("./respiratory-therapy");
|
|
11
10
|
const single_value_services_1 = require("./single-value-services");
|
|
12
11
|
const step_count_1 = require("./step-count");
|
|
13
12
|
const uric_acid_service_1 = require("./uric-acid-service");
|
|
14
13
|
class ObservationServiceCreator {
|
|
15
14
|
constructor() {
|
|
16
|
-
|
|
17
|
-
this.
|
|
15
|
+
const uricAcid = new uric_acid_service_1.UricAcidService();
|
|
16
|
+
this.services = new Map([
|
|
17
|
+
...(0, single_value_services_1.singleValueObservationServices)(),
|
|
18
|
+
[types_1.MeasurementTypeKey.bloodPressure, new blood_pressure_1.BloodPressureService()],
|
|
19
|
+
[types_1.MeasurementTypeKey.bloodOxygenPulseRate, new blood_oxygen_1.BloodOxygenService()],
|
|
20
|
+
[types_1.MeasurementTypeKey.ecg, new ecg_1.EcgService()],
|
|
21
|
+
[types_1.MeasurementTypeKey.stepCount, new step_count_1.StepCountService()],
|
|
22
|
+
[types_1.MeasurementTypeKey.urineAnalysis, uricAcid],
|
|
23
|
+
[types_1.MeasurementTypeKey.uricAcid, uricAcid],
|
|
24
|
+
[types_1.MeasurementTypeKey.lipidPanel, new lipid_panel_1.LipidPanelService()],
|
|
25
|
+
[types_1.MeasurementTypeKey.respiratoryTherapy, (0, component_observation_services_1.respiratoryTherapyService)()],
|
|
26
|
+
[types_1.MeasurementTypeKey.babySleep, (0, component_observation_services_1.babySleepService)()],
|
|
27
|
+
]);
|
|
18
28
|
}
|
|
19
29
|
static getInstance() {
|
|
20
30
|
if (!ObservationServiceCreator.instance) {
|
|
@@ -22,20 +32,6 @@ class ObservationServiceCreator {
|
|
|
22
32
|
}
|
|
23
33
|
return ObservationServiceCreator.instance;
|
|
24
34
|
}
|
|
25
|
-
initializeServices() {
|
|
26
|
-
for (const [type, service] of (0, single_value_services_1.singleValueObservationServices)()) {
|
|
27
|
-
this.services.set(type, service);
|
|
28
|
-
}
|
|
29
|
-
this.services.set(types_1.MeasurementTypeKey.bloodPressure, new blood_pressure_1.BloodPressureService());
|
|
30
|
-
this.services.set(types_1.MeasurementTypeKey.bloodOxygenPulseRate, new blood_oxygen_1.BloodOxygenService());
|
|
31
|
-
this.services.set(types_1.MeasurementTypeKey.ecg, new ecg_1.EcgService());
|
|
32
|
-
this.services.set(types_1.MeasurementTypeKey.stepCount, new step_count_1.StepCountService());
|
|
33
|
-
this.services.set(types_1.MeasurementTypeKey.urineAnalysis, new uric_acid_service_1.UricAcidService());
|
|
34
|
-
this.services.set(types_1.MeasurementTypeKey.uricAcid, new uric_acid_service_1.UricAcidService());
|
|
35
|
-
this.services.set(types_1.MeasurementTypeKey.lipidPanel, new lipid_panel_1.LipidPanelService());
|
|
36
|
-
this.services.set(types_1.MeasurementTypeKey.respiratoryTherapy, new respiratory_therapy_1.RespiratoryTherapyService());
|
|
37
|
-
this.services.set(types_1.MeasurementTypeKey.babySleep, new baby_sleep_1.BabySleepService());
|
|
38
|
-
}
|
|
39
35
|
getService(type) {
|
|
40
36
|
const service = this.services.get(type);
|
|
41
37
|
if (!service) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateEcgObservationFragments = void 0;
|
|
4
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
5
|
+
const measurement_time_1 = require("./measurement-time");
|
|
4
6
|
const MAX_SEGMENT_DURATION_SECONDS = 5 * 60;
|
|
5
7
|
const MAX_SAMPLED_DATA_CHARACTERS = 750000;
|
|
6
8
|
const generateEcgObservationFragments = (measurement, observationCodes) => {
|
|
7
9
|
const fragments = [];
|
|
8
10
|
const diagramPoints = measurement.diagramPoints;
|
|
9
|
-
const recordedAt =
|
|
10
|
-
? measurement.recordedAt
|
|
11
|
-
: new Date();
|
|
11
|
+
const recordedAt = (0, measurement_time_1.recordedAtOrNow)(measurement);
|
|
12
12
|
const duration = typeof measurement.duration === "number" &&
|
|
13
13
|
Number.isFinite(measurement.duration) &&
|
|
14
14
|
measurement.duration > 0
|
|
@@ -71,7 +71,7 @@ const generateEcgObservationFragments = (measurement, observationCodes) => {
|
|
|
71
71
|
value: Number(measurement.heartRate.toFixed(0)),
|
|
72
72
|
unit: "bpm",
|
|
73
73
|
code: "8867-4",
|
|
74
|
-
system:
|
|
74
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
77
|
additionalProperties: {
|
|
@@ -92,7 +92,6 @@ const durationComponent = (duration) => ({
|
|
|
92
92
|
value: duration,
|
|
93
93
|
unit: "s",
|
|
94
94
|
code: "s",
|
|
95
|
-
system:
|
|
95
|
+
system: fhir_systems_1.UCUM_SYSTEM,
|
|
96
96
|
},
|
|
97
97
|
});
|
|
98
|
-
const isValidDate = (value) => value instanceof Date && !Number.isNaN(value.getTime());
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EcgService = void 0;
|
|
4
4
|
const types_1 = require("../../../types");
|
|
5
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
5
6
|
const base_observation_service_1 = require("./base-observation-service");
|
|
6
7
|
const ecg_observation_fragments_1 = require("./ecg-observation-fragments");
|
|
7
8
|
class EcgService extends base_observation_service_1.BaseObservationService {
|
|
@@ -54,7 +55,7 @@ class EcgService extends base_observation_service_1.BaseObservationService {
|
|
|
54
55
|
value: Number(fixedValue),
|
|
55
56
|
unit: "bpm",
|
|
56
57
|
code: types_1.ObservationCode.ECG_HEART_RATE,
|
|
57
|
-
system:
|
|
58
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
58
59
|
},
|
|
59
60
|
});
|
|
60
61
|
}
|
|
@@ -90,7 +91,7 @@ class EcgService extends base_observation_service_1.BaseObservationService {
|
|
|
90
91
|
value: castedMeasurement.duration,
|
|
91
92
|
unit: "s",
|
|
92
93
|
code: "s",
|
|
93
|
-
system:
|
|
94
|
+
system: fhir_systems_1.UCUM_SYSTEM,
|
|
94
95
|
},
|
|
95
96
|
},
|
|
96
97
|
],
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LipidPanelService = void 0;
|
|
4
4
|
const types_1 = require("../../../types");
|
|
5
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
5
6
|
const base_observation_service_1 = require("./base-observation-service");
|
|
6
|
-
const
|
|
7
|
-
const LOINC_SYSTEM = "http://loinc.org";
|
|
7
|
+
const measurement_time_1 = require("./measurement-time");
|
|
8
8
|
const COMPONENTS = [
|
|
9
9
|
{
|
|
10
10
|
key: "totalCholesterol",
|
|
@@ -36,10 +36,6 @@ const COMPONENTS = [
|
|
|
36
36
|
massCode: types_1.ObservationCode.TOTAL_CHOLESTEROL_HDL_RATIO,
|
|
37
37
|
},
|
|
38
38
|
];
|
|
39
|
-
const recordedAt = (measurement) => measurement.recordedAt instanceof Date &&
|
|
40
|
-
!Number.isNaN(measurement.recordedAt.getTime())
|
|
41
|
-
? measurement.recordedAt.toISOString()
|
|
42
|
-
: new Date().toISOString();
|
|
43
39
|
class LipidPanelService extends base_observation_service_1.BaseObservationService {
|
|
44
40
|
constructor() {
|
|
45
41
|
super(...arguments);
|
|
@@ -61,14 +57,14 @@ class LipidPanelService extends base_observation_service_1.BaseObservationServic
|
|
|
61
57
|
const unit = item.key === "totalCholesterolHdlRatio" ? "{ratio}" : lipidPanel.unit;
|
|
62
58
|
return [{
|
|
63
59
|
code: {
|
|
64
|
-
coding: [{ code, display: item.display, system: LOINC_SYSTEM }],
|
|
60
|
+
coding: [{ code, display: item.display, system: fhir_systems_1.LOINC_SYSTEM }],
|
|
65
61
|
text: item.display,
|
|
66
62
|
},
|
|
67
63
|
valueQuantity: {
|
|
68
64
|
value,
|
|
69
65
|
unit,
|
|
70
66
|
code: unit,
|
|
71
|
-
system: UCUM_SYSTEM,
|
|
67
|
+
system: fhir_systems_1.UCUM_SYSTEM,
|
|
72
68
|
},
|
|
73
69
|
}];
|
|
74
70
|
});
|
|
@@ -80,11 +76,11 @@ class LipidPanelService extends base_observation_service_1.BaseObservationServic
|
|
|
80
76
|
coding: [{
|
|
81
77
|
code: types_1.ObservationCode.LIPID_PANEL,
|
|
82
78
|
display: "Lipid panel - Serum or Plasma",
|
|
83
|
-
system: LOINC_SYSTEM,
|
|
79
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
84
80
|
}],
|
|
85
81
|
},
|
|
86
82
|
additionalProperties: {
|
|
87
|
-
effectiveDateTime:
|
|
83
|
+
effectiveDateTime: (0, measurement_time_1.recordedAtOrNow)(lipidPanel).toISOString(),
|
|
88
84
|
component: components,
|
|
89
85
|
},
|
|
90
86
|
}];
|
|
@@ -94,12 +90,12 @@ class LipidPanelService extends base_observation_service_1.BaseObservationServic
|
|
|
94
90
|
coding: [{
|
|
95
91
|
code: types_1.ObservationCode.LIPID_PANEL,
|
|
96
92
|
display: "Lipid panel - Serum or Plasma",
|
|
97
|
-
system: LOINC_SYSTEM,
|
|
93
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
98
94
|
}],
|
|
99
95
|
}];
|
|
100
96
|
}
|
|
101
97
|
getAdditionalProperties(measurement) {
|
|
102
|
-
return [{ effectiveDateTime:
|
|
98
|
+
return [{ effectiveDateTime: (0, measurement_time_1.recordedAtOrNow)(this.getCastedMeasurement(measurement)).toISOString() }];
|
|
103
99
|
}
|
|
104
100
|
generateValues(_measurement) {
|
|
105
101
|
return [];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recordedAtOrNow = void 0;
|
|
4
|
+
/** The measurement's `recordedAt` when it is a valid date, else now. */
|
|
5
|
+
const recordedAtOrNow = ({ recordedAt }) => recordedAt instanceof Date && !Number.isNaN(recordedAt.getTime()) ? recordedAt : new Date();
|
|
6
|
+
exports.recordedAtOrNow = recordedAtOrNow;
|
|
@@ -28,4 +28,9 @@ declare class SingleValueObservationService extends BaseObservationService<Singl
|
|
|
28
28
|
private measurement;
|
|
29
29
|
}
|
|
30
30
|
export declare const singleValueObservationServices: () => [MeasurementTypeKey, SingleValueObservationService][];
|
|
31
|
+
/** Value key and LOINC code of each single-value type, for reading observations back into measurements. */
|
|
32
|
+
export declare const singleValueFields: ReadonlyMap<MeasurementTypeKey, {
|
|
33
|
+
valueKey: string;
|
|
34
|
+
code: string;
|
|
35
|
+
}>;
|
|
31
36
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.singleValueObservationServices = void 0;
|
|
3
|
+
exports.singleValueFields = exports.singleValueObservationServices = void 0;
|
|
4
4
|
const types_1 = require("../../../types");
|
|
5
5
|
const base_observation_service_1 = require("./base-observation-service");
|
|
6
6
|
/** An observation with one value: what varies per measurement is data, not code. */
|
|
@@ -93,3 +93,8 @@ const specs = [
|
|
|
93
93
|
];
|
|
94
94
|
const singleValueObservationServices = () => specs.map((spec) => [spec.measurementTypeKey, new SingleValueObservationService(spec)]);
|
|
95
95
|
exports.singleValueObservationServices = singleValueObservationServices;
|
|
96
|
+
/** Value key and LOINC code of each single-value type, for reading observations back into measurements. */
|
|
97
|
+
exports.singleValueFields = new Map(specs.map(({ measurementTypeKey, metadata }) => [
|
|
98
|
+
measurementTypeKey,
|
|
99
|
+
{ valueKey: String(metadata.valueKey), code: metadata.primaryCode },
|
|
100
|
+
]));
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.UricAcidService = void 0;
|
|
5
5
|
const types_1 = require("../../../types");
|
|
6
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
6
7
|
const base_observation_service_1 = require("./base-observation-service");
|
|
8
|
+
const measurement_time_1 = require("./measurement-time");
|
|
7
9
|
class UricAcidService extends base_observation_service_1.BaseObservationService {
|
|
8
10
|
constructor() {
|
|
9
11
|
super(...arguments);
|
|
@@ -36,7 +38,7 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
|
|
|
36
38
|
value: problemCount,
|
|
37
39
|
unit: "problems",
|
|
38
40
|
code: types_1.ObservationCode.URIC_ACID,
|
|
39
|
-
system:
|
|
41
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
40
42
|
},
|
|
41
43
|
});
|
|
42
44
|
return values;
|
|
@@ -63,10 +65,7 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
|
|
|
63
65
|
*/
|
|
64
66
|
generateObservationFragments(measurement) {
|
|
65
67
|
const castedMeasurement = this.getCastedMeasurement(measurement);
|
|
66
|
-
const effectiveDateTime = castedMeasurement.
|
|
67
|
-
!Number.isNaN(castedMeasurement.recordedAt.getTime())
|
|
68
|
-
? castedMeasurement.recordedAt.toISOString()
|
|
69
|
-
: new Date().toISOString();
|
|
68
|
+
const effectiveDateTime = (0, measurement_time_1.recordedAtOrNow)(castedMeasurement).toISOString();
|
|
70
69
|
return types_1.URINE_ANALYTE_DEFINITIONS.flatMap((analyte) => {
|
|
71
70
|
const value = castedMeasurement[analyte.key];
|
|
72
71
|
if (value === undefined || value === null || !Number.isFinite(value)) {
|
|
@@ -79,7 +78,7 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
|
|
|
79
78
|
{
|
|
80
79
|
code: analyte.code,
|
|
81
80
|
display: analyte.display,
|
|
82
|
-
system:
|
|
81
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
83
82
|
},
|
|
84
83
|
],
|
|
85
84
|
text: analyte.display,
|
|
@@ -91,7 +90,7 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
|
|
|
91
90
|
...(analyte.unitCode
|
|
92
91
|
? {
|
|
93
92
|
code: analyte.unitCode,
|
|
94
|
-
system:
|
|
93
|
+
system: fhir_systems_1.UCUM_SYSTEM,
|
|
95
94
|
}
|
|
96
95
|
: {}),
|
|
97
96
|
},
|