@ovok/core 0.4.36 → 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.d.ts +35 -0
- package/dist/client/auth/session-fetch.js +206 -0
- package/dist/client/auth/session-http.d.ts +11 -0
- package/dist/client/auth/session-http.js +169 -0
- 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 +28 -37
- package/dist/client/invites/methods.js +8 -12
- package/dist/client/notifications/methods.js +5 -5
- 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 +15 -33
- 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 +36 -0
- package/dist/client/observation/services/single-value-services.js +100 -0
- 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 +7 -15
- package/dist/client/ovok-client.js +54 -398
- package/dist/client/patient/methods.js +27 -36
- package/dist/client/patient-sharing/methods.js +4 -4
- package/dist/client/platform/methods.js +21 -30
- package/dist/client/platform/types.d.ts +3 -6
- package/dist/client/query-string.d.ts +3 -0
- package/dist/client/query-string.js +15 -0
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -1
- package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.js +1 -2
- package/dist/client/questionnaire-response/methods/populateQuestionnaire.js +1 -2
- 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 +22 -22
- 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 +73 -166
- 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 +6 -68
- package/dist/hooks/api-hooks.d.ts +10 -6
- package/dist/hooks/api-hooks.js +29 -88
- package/dist/hooks/cms-hooks.js +8 -13
- package/dist/hooks/email-hooks.js +1 -40
- package/dist/hooks/experience-hooks.js +4 -60
- 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 +29 -86
- package/dist/hooks/notification-invalidation.d.ts +6 -0
- package/dist/hooks/notification-invalidation.js +52 -0
- package/dist/hooks/notification-note-hooks.js +13 -28
- package/dist/hooks/observation-hooks.js +2 -4
- package/dist/hooks/patient-hooks.js +13 -113
- package/dist/hooks/patient-sharing-hooks.js +2 -7
- package/dist/hooks/platform-hooks.js +3 -51
- package/dist/hooks/poll-hooks.js +10 -8
- package/dist/hooks/signals-alert-hooks.js +4 -6
- package/dist/hooks/signals-hooks.js +2 -45
- package/package.json +1 -1
- package/dist/client/observation/services/baby-sleep.js +0 -69
- package/dist/client/observation/services/blood-glucose.d.ts +0 -12
- package/dist/client/observation/services/blood-glucose.js +0 -36
- package/dist/client/observation/services/body-temperature.d.ts +0 -13
- package/dist/client/observation/services/body-temperature.js +0 -36
- package/dist/client/observation/services/body-weight.d.ts +0 -13
- package/dist/client/observation/services/body-weight.js +0 -36
- package/dist/client/observation/services/heart-rate-variability.d.ts +0 -13
- package/dist/client/observation/services/heart-rate-variability.js +0 -38
- package/dist/client/observation/services/heart-rate.d.ts +0 -13
- package/dist/client/observation/services/heart-rate.js +0 -39
- package/dist/client/observation/services/respiratory-rate.d.ts +0 -13
- package/dist/client/observation/services/respiratory-rate.js +0 -38
- package/dist/client/observation/services/respiratory-therapy.d.ts +0 -28
- package/dist/client/observation/services/respiratory-therapy.js +0 -69
- package/dist/client/observation/services/resting-heart-rate.d.ts +0 -13
- package/dist/client/observation/services/resting-heart-rate.js +0 -38
- package/dist/client/observation/services/vo2-max.d.ts +0 -13
- package/dist/client/observation/services/vo2-max.js +0 -38
- package/dist/client/observation/services/walking-heart-rate-average.d.ts +0 -12
- package/dist/client/observation/services/walking-heart-rate-average.js +0 -38
- 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
|
@@ -2,27 +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
|
-
const blood_glucose_1 = require("./blood-glucose");
|
|
7
5
|
const blood_oxygen_1 = require("./blood-oxygen");
|
|
8
6
|
const blood_pressure_1 = require("./blood-pressure");
|
|
9
|
-
const
|
|
10
|
-
const body_weight_1 = require("./body-weight");
|
|
7
|
+
const component_observation_services_1 = require("./component-observation-services");
|
|
11
8
|
const ecg_1 = require("./ecg");
|
|
12
|
-
const heart_rate_1 = require("./heart-rate");
|
|
13
|
-
const heart_rate_variability_1 = require("./heart-rate-variability");
|
|
14
9
|
const lipid_panel_1 = require("./lipid-panel");
|
|
15
|
-
const
|
|
16
|
-
const respiratory_therapy_1 = require("./respiratory-therapy");
|
|
17
|
-
const resting_heart_rate_1 = require("./resting-heart-rate");
|
|
10
|
+
const single_value_services_1 = require("./single-value-services");
|
|
18
11
|
const step_count_1 = require("./step-count");
|
|
19
12
|
const uric_acid_service_1 = require("./uric-acid-service");
|
|
20
|
-
const vo2_max_1 = require("./vo2-max");
|
|
21
|
-
const walking_heart_rate_average_1 = require("./walking-heart-rate-average");
|
|
22
13
|
class ObservationServiceCreator {
|
|
23
14
|
constructor() {
|
|
24
|
-
|
|
25
|
-
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
|
+
]);
|
|
26
28
|
}
|
|
27
29
|
static getInstance() {
|
|
28
30
|
if (!ObservationServiceCreator.instance) {
|
|
@@ -30,26 +32,6 @@ class ObservationServiceCreator {
|
|
|
30
32
|
}
|
|
31
33
|
return ObservationServiceCreator.instance;
|
|
32
34
|
}
|
|
33
|
-
initializeServices() {
|
|
34
|
-
this.services.set(types_1.MeasurementTypeKey.bodyWeight, new body_weight_1.BodyWeightService());
|
|
35
|
-
this.services.set(types_1.MeasurementTypeKey.bloodPressure, new blood_pressure_1.BloodPressureService());
|
|
36
|
-
this.services.set(types_1.MeasurementTypeKey.bloodGlucose, new blood_glucose_1.BloodGlucoseService());
|
|
37
|
-
this.services.set(types_1.MeasurementTypeKey.temperature, new body_temperature_1.BodyTemperatureService());
|
|
38
|
-
this.services.set(types_1.MeasurementTypeKey.bloodOxygenPulseRate, new blood_oxygen_1.BloodOxygenService());
|
|
39
|
-
this.services.set(types_1.MeasurementTypeKey.ecg, new ecg_1.EcgService());
|
|
40
|
-
this.services.set(types_1.MeasurementTypeKey.stepCount, new step_count_1.StepCountService());
|
|
41
|
-
this.services.set(types_1.MeasurementTypeKey.restingHeartRate, new resting_heart_rate_1.RestingHeartRateService());
|
|
42
|
-
this.services.set(types_1.MeasurementTypeKey.walkingHeartRateAverage, new walking_heart_rate_average_1.WalkingHeartRateAverageService());
|
|
43
|
-
this.services.set(types_1.MeasurementTypeKey.heartRateVariability, new heart_rate_variability_1.HeartRateVariabilityService());
|
|
44
|
-
this.services.set(types_1.MeasurementTypeKey.heartRate, new heart_rate_1.HeartRateService());
|
|
45
|
-
this.services.set(types_1.MeasurementTypeKey.respiratoryRate, new respiratory_rate_1.RespiratoryRateService());
|
|
46
|
-
this.services.set(types_1.MeasurementTypeKey.vo2Max, new vo2_max_1.Vo2MaxService());
|
|
47
|
-
this.services.set(types_1.MeasurementTypeKey.urineAnalysis, new uric_acid_service_1.UricAcidService());
|
|
48
|
-
this.services.set(types_1.MeasurementTypeKey.uricAcid, new uric_acid_service_1.UricAcidService());
|
|
49
|
-
this.services.set(types_1.MeasurementTypeKey.lipidPanel, new lipid_panel_1.LipidPanelService());
|
|
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());
|
|
52
|
-
}
|
|
53
35
|
getService(type) {
|
|
54
36
|
const service = this.services.get(type);
|
|
55
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;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MeasurementTypeKey } from "../../../types";
|
|
2
|
+
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
3
|
+
import { Sample } from "../types/generate-measurement/Sample";
|
|
4
|
+
import { Measurement } from "../types/measurement/Measurement";
|
|
5
|
+
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
6
|
+
/** A measurement whose one value sits under the spec's `valueKey`. */
|
|
7
|
+
type SingleValueMeasurement = Measurement & {
|
|
8
|
+
[value: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
import { BaseObservationService } from "./base-observation-service";
|
|
11
|
+
type SingleValueSpec = {
|
|
12
|
+
measurementTypeKey: MeasurementTypeKey;
|
|
13
|
+
measurementTypeName: string;
|
|
14
|
+
metadata: Omit<ObservationMetadata<SingleValueMeasurement>, "additionalCodes">;
|
|
15
|
+
/** HealthKit quantity type to read; the first sample is used when omitted. */
|
|
16
|
+
sampleType?: string;
|
|
17
|
+
fromRecord: (record: RecordResult<RecordType>) => number | undefined;
|
|
18
|
+
};
|
|
19
|
+
/** An observation with one value: what varies per measurement is data, not code. */
|
|
20
|
+
declare class SingleValueObservationService extends BaseObservationService<SingleValueMeasurement> {
|
|
21
|
+
private readonly spec;
|
|
22
|
+
protected measurementTypeKey: MeasurementTypeKey;
|
|
23
|
+
protected measurementTypeName: string;
|
|
24
|
+
protected observationMetadata: ObservationMetadata<SingleValueMeasurement>[];
|
|
25
|
+
constructor(spec: SingleValueSpec);
|
|
26
|
+
convertSamplesToMeasurement(samples: Sample[]): SingleValueMeasurement;
|
|
27
|
+
convertRecordToMeasurement(record: RecordResult<RecordType>): SingleValueMeasurement;
|
|
28
|
+
private measurement;
|
|
29
|
+
}
|
|
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
|
+
}>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.singleValueFields = exports.singleValueObservationServices = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const base_observation_service_1 = require("./base-observation-service");
|
|
6
|
+
/** An observation with one value: what varies per measurement is data, not code. */
|
|
7
|
+
class SingleValueObservationService extends base_observation_service_1.BaseObservationService {
|
|
8
|
+
constructor(spec) {
|
|
9
|
+
super();
|
|
10
|
+
this.spec = spec;
|
|
11
|
+
this.measurementTypeKey = spec.measurementTypeKey;
|
|
12
|
+
this.measurementTypeName = spec.measurementTypeName;
|
|
13
|
+
this.observationMetadata = [{ ...spec.metadata, additionalCodes: [] }];
|
|
14
|
+
}
|
|
15
|
+
convertSamplesToMeasurement(samples) {
|
|
16
|
+
const sample = this.spec.sampleType
|
|
17
|
+
? samples.find((x) => x.quantityType === this.spec.sampleType)
|
|
18
|
+
: samples[0];
|
|
19
|
+
return this.measurement(sample === null || sample === void 0 ? void 0 : sample.quantity);
|
|
20
|
+
}
|
|
21
|
+
convertRecordToMeasurement(record) {
|
|
22
|
+
return this.measurement(this.spec.fromRecord(record));
|
|
23
|
+
}
|
|
24
|
+
measurement(value) {
|
|
25
|
+
return {
|
|
26
|
+
[this.spec.metadata.valueKey]: value,
|
|
27
|
+
measurementTypeKey: this.measurementTypeKey,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const specs = [
|
|
32
|
+
{
|
|
33
|
+
measurementTypeKey: types_1.MeasurementTypeKey.bloodGlucose,
|
|
34
|
+
measurementTypeName: "blood glucose",
|
|
35
|
+
metadata: { primaryCode: types_1.ObservationCode.BLOOD_GLUCOSE, display: "Blood Glucose", unit: "mg/dL", valueKey: "bloodGlucose", toFixed: 1 },
|
|
36
|
+
fromRecord: (record) => record.level.inMilligramsPerDeciliter,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
measurementTypeKey: types_1.MeasurementTypeKey.temperature,
|
|
40
|
+
measurementTypeName: "body temperature",
|
|
41
|
+
metadata: { primaryCode: types_1.ObservationCode.BODY_TEMPERATURE, display: "Body Temperature", unit: "°C", valueKey: "bodyTemp", toFixed: 2 },
|
|
42
|
+
fromRecord: (record) => record.temperature.inCelsius,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
measurementTypeKey: types_1.MeasurementTypeKey.bodyWeight,
|
|
46
|
+
measurementTypeName: "body weight",
|
|
47
|
+
metadata: { primaryCode: types_1.ObservationCode.BODY_WEIGHT, display: "Body Weight", unit: "kg", valueKey: "bodyWeight", toFixed: 2 },
|
|
48
|
+
fromRecord: (record) => record.weight.inKilograms,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
measurementTypeKey: types_1.MeasurementTypeKey.heartRateVariability,
|
|
52
|
+
measurementTypeName: "heart rate variability",
|
|
53
|
+
metadata: { primaryCode: types_1.ObservationCode.HEART_RATE_VARIABILITY, display: "Heart Rate Variability", unit: "ms", valueKey: "heartRateVariability", toFixed: 1 },
|
|
54
|
+
sampleType: "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
|
|
55
|
+
fromRecord: (record) => record.heartRateVariabilityMillis,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
measurementTypeKey: types_1.MeasurementTypeKey.heartRate,
|
|
59
|
+
measurementTypeName: "heart rate",
|
|
60
|
+
metadata: { primaryCode: types_1.ObservationCode.HEART_RATE, display: "Heart Rate", unit: "bpm", valueKey: "heartRate", toFixed: 0 },
|
|
61
|
+
sampleType: "HKQuantityTypeIdentifierHeartRate",
|
|
62
|
+
fromRecord: (record) => { var _a, _b; return (_b = (_a = record.samples) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.beatsPerMinute; },
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
measurementTypeKey: types_1.MeasurementTypeKey.respiratoryRate,
|
|
66
|
+
measurementTypeName: "respiratory rate",
|
|
67
|
+
metadata: { primaryCode: types_1.ObservationCode.RESPIRATORY_RATE, display: "Respiratory Rate", unit: "breaths/min", valueKey: "respiratoryRate", toFixed: 1 },
|
|
68
|
+
sampleType: "HKQuantityTypeIdentifierRespiratoryRate",
|
|
69
|
+
fromRecord: (record) => record.rate,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
measurementTypeKey: types_1.MeasurementTypeKey.restingHeartRate,
|
|
73
|
+
measurementTypeName: "resting heart rate",
|
|
74
|
+
metadata: { primaryCode: types_1.ObservationCode.RESTING_HEART_RATE, display: "Resting Heart Rate", unit: "bpm", valueKey: "restingHeartRate", toFixed: 0 },
|
|
75
|
+
sampleType: "HKQuantityTypeIdentifierRestingHeartRate",
|
|
76
|
+
fromRecord: (record) => record.beatsPerMinute,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
measurementTypeKey: types_1.MeasurementTypeKey.vo2Max,
|
|
80
|
+
measurementTypeName: "VO2 max",
|
|
81
|
+
metadata: { primaryCode: types_1.ObservationCode.VO2_MAX, display: "VO2 Max", unit: "mL/kg/min", valueKey: "vo2Max", toFixed: 1 },
|
|
82
|
+
sampleType: "HKQuantityTypeIdentifierVO2Max",
|
|
83
|
+
fromRecord: (record) => record.vo2MillilitersPerMinuteKilogram,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
measurementTypeKey: types_1.MeasurementTypeKey.walkingHeartRateAverage,
|
|
87
|
+
measurementTypeName: "walking heart rate average",
|
|
88
|
+
metadata: { primaryCode: types_1.ObservationCode.WALKING_HEART_RATE_AVERAGE, display: "Walking Heart Rate Average", unit: "bpm", valueKey: "walkingHeartRateAverage", toFixed: 0 },
|
|
89
|
+
sampleType: "HKQuantityTypeIdentifierWalkingHeartRateAverage",
|
|
90
|
+
// Health Connect has no walking-heart-rate-average record.
|
|
91
|
+
fromRecord: () => 0,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
const singleValueObservationServices = () => specs.map((spec) => [spec.measurementTypeKey, new SingleValueObservationService(spec)]);
|
|
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
|
},
|