@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
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ValidationError } from "../../types/ValidationError";
|
|
2
2
|
export declare const OVOK_HTTP_ERROR_EXTENSION_URL = "https://api.ovok.com/fhir/StructureDefinition/http-error-metadata";
|
|
3
|
+
/** `reason` itself when it is an Error, else an Error carrying its string form. */
|
|
4
|
+
export declare const toError: (reason: unknown) => Error;
|
|
5
|
+
/** An Error with its `name` set, e.g. `namedError("AbortError", "The request was aborted.")`. */
|
|
6
|
+
export declare const namedError: (name: string, message: string) => Error;
|
|
7
|
+
/** Sets `cause` the way the SDK's typed errors expose it: read-only and not enumerable. */
|
|
8
|
+
export declare const withCause: <T extends Error>(error: T, cause: unknown) => T;
|
|
3
9
|
export declare const asRecord: (value: unknown) => Record<string, unknown> | undefined;
|
|
4
10
|
export declare function readMessage(payload: Record<string, unknown> | undefined, error: unknown): string;
|
|
5
11
|
export declare function readFieldErrors(payload: Record<string, unknown> | undefined): ValidationError[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asRecord = exports.OVOK_HTTP_ERROR_EXTENSION_URL = void 0;
|
|
3
|
+
exports.asRecord = exports.withCause = exports.namedError = exports.toError = exports.OVOK_HTTP_ERROR_EXTENSION_URL = void 0;
|
|
4
4
|
exports.readMessage = readMessage;
|
|
5
5
|
exports.readFieldErrors = readFieldErrors;
|
|
6
6
|
exports.codeValue = codeValue;
|
|
@@ -11,6 +11,15 @@ exports.numberValue = numberValue;
|
|
|
11
11
|
exports.stringValue = stringValue;
|
|
12
12
|
exports.parseJson = parseJson;
|
|
13
13
|
exports.OVOK_HTTP_ERROR_EXTENSION_URL = "https://api.ovok.com/fhir/StructureDefinition/http-error-metadata";
|
|
14
|
+
/** `reason` itself when it is an Error, else an Error carrying its string form. */
|
|
15
|
+
const toError = (reason) => reason instanceof Error ? reason : new Error(String(reason));
|
|
16
|
+
exports.toError = toError;
|
|
17
|
+
/** An Error with its `name` set, e.g. `namedError("AbortError", "The request was aborted.")`. */
|
|
18
|
+
const namedError = (name, message) => Object.assign(new Error(message), { name });
|
|
19
|
+
exports.namedError = namedError;
|
|
20
|
+
/** Sets `cause` the way the SDK's typed errors expose it: read-only and not enumerable. */
|
|
21
|
+
const withCause = (error, cause) => Object.defineProperty(error, "cause", { configurable: true, enumerable: false, value: cause, writable: false });
|
|
22
|
+
exports.withCause = withCause;
|
|
14
23
|
const asRecord = (value) => value && typeof value === "object" ? value : undefined;
|
|
15
24
|
exports.asRecord = asRecord;
|
|
16
25
|
function readMessage(payload, error) {
|
|
@@ -26,7 +26,7 @@ const HTTP_REASON_PHRASES = new Set([
|
|
|
26
26
|
]);
|
|
27
27
|
/** Reads the error details Medplum preserves from Ovok's non-FHIR responses. */
|
|
28
28
|
const readOvokError = (error) => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
30
30
|
if (error instanceof OvokApiError) {
|
|
31
31
|
return {
|
|
32
32
|
status: error.status,
|
|
@@ -62,15 +62,13 @@ const readOvokError = (error) => {
|
|
|
62
62
|
const missing = Array.isArray(payload === null || payload === void 0 ? void 0 : payload.missing)
|
|
63
63
|
? payload.missing.filter((entry) => typeof entry === "string")
|
|
64
64
|
: [];
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const retryAfterSec = (0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterSec);
|
|
66
|
+
const retryAfterMs = (_x = (_w = metadata.retryAfterMs) !== null && _w !== void 0 ? _w : (0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterMs)) !== null && _x !== void 0 ? _x : (retryAfterSec === undefined ? undefined : retryAfterSec * 1000);
|
|
67
|
+
const requestId = (_y = metadata.requestId) !== null && _y !== void 0 ? _y : (0, ovok_error_utils_1.stringValue)(payload === null || payload === void 0 ? void 0 : payload.requestId);
|
|
68
68
|
return {
|
|
69
69
|
status,
|
|
70
70
|
code,
|
|
71
|
-
...(
|
|
72
|
-
? {}
|
|
73
|
-
: { requestId: (_z = metadata.requestId) !== null && _z !== void 0 ? _z : (0, ovok_error_utils_1.stringValue)(payload === null || payload === void 0 ? void 0 : payload.requestId) }),
|
|
71
|
+
...(requestId === undefined ? {} : { requestId }),
|
|
74
72
|
...(retryAfterMs === undefined ? {} : { retryAfterMs }),
|
|
75
73
|
message: (0, ovok_error_utils_1.readMessage)(payload, error),
|
|
76
74
|
fieldErrors,
|
|
@@ -90,12 +88,7 @@ class OvokApiError extends Error {
|
|
|
90
88
|
this.missing = details.missing;
|
|
91
89
|
this.requestId = details.requestId;
|
|
92
90
|
this.retryAfterMs = details.retryAfterMs;
|
|
93
|
-
|
|
94
|
-
configurable: true,
|
|
95
|
-
enumerable: false,
|
|
96
|
-
value: cause,
|
|
97
|
-
writable: false,
|
|
98
|
-
});
|
|
91
|
+
(0, ovok_error_utils_1.withCause)(this, cause);
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
94
|
exports.OvokApiError = OvokApiError;
|
|
@@ -5,6 +5,7 @@ exports.isRateLimitError = isRateLimitError;
|
|
|
5
5
|
exports.mapRateLimitError = mapRateLimitError;
|
|
6
6
|
const core_1 = require("@medplum/core");
|
|
7
7
|
const ovok_error_1 = require("./ovok-error");
|
|
8
|
+
const ovok_error_utils_1 = require("./ovok-error-utils");
|
|
8
9
|
const RATE_LIMIT_RESET_EXTENSION_URL = "https://medplum.com/fhir/StructureDefinition/rate-limit-reset";
|
|
9
10
|
/** A typed error returned when the server asks the client to slow down. */
|
|
10
11
|
class RateLimitError extends Error {
|
|
@@ -14,12 +15,7 @@ class RateLimitError extends Error {
|
|
|
14
15
|
this.name = "RateLimitError";
|
|
15
16
|
this.retryAfterMs = retryAfterMs;
|
|
16
17
|
if (options) {
|
|
17
|
-
|
|
18
|
-
configurable: true,
|
|
19
|
-
enumerable: false,
|
|
20
|
-
value: options.cause,
|
|
21
|
-
writable: false,
|
|
22
|
-
});
|
|
18
|
+
(0, ovok_error_utils_1.withCause)(this, options.cause);
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
21
|
}
|
|
@@ -35,6 +35,7 @@ exports.getChatSession = getChatSession;
|
|
|
35
35
|
exports.listChatMessages = listChatMessages;
|
|
36
36
|
exports.searchAIFhir = searchAIFhir;
|
|
37
37
|
const query_string_1 = require("../query-string");
|
|
38
|
+
const request_options_1 = require("../request-options");
|
|
38
39
|
const documentUrl = (client, path, params) => `${client.getBaseUrl().replace(/\/$/, "")}${path}${(0, query_string_1.toQueryString)(params)}`;
|
|
39
40
|
async function requestConsentSignature(consentId, requestOptions) {
|
|
40
41
|
return this.post(`/consent/signature/${encodeURIComponent(consentId)}`, undefined, undefined, requestOptions);
|
|
@@ -43,7 +44,7 @@ async function createDocumentUpload(body, requestOptions) {
|
|
|
43
44
|
return this.post("/document", body, undefined, requestOptions);
|
|
44
45
|
}
|
|
45
46
|
async function listDocuments(params = {}, requestOptions) {
|
|
46
|
-
return this.get(`/document${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
47
|
+
return this.get(`/document${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
47
48
|
}
|
|
48
49
|
/** Returns the authenticated document endpoint; navigating/fetching it follows the backend redirect. */
|
|
49
50
|
async function getDocumentDownloadUrl(documentId, params = {}) {
|
|
@@ -54,16 +55,16 @@ async function getPublicDocumentDownloadUrl(token, params = {}) {
|
|
|
54
55
|
return documentUrl(this, `/document/public/${encodeURIComponent(token)}`, params);
|
|
55
56
|
}
|
|
56
57
|
async function deleteDocument(documentId, requestOptions) {
|
|
57
|
-
return (await this.delete(`/document/${encodeURIComponent(documentId)}`, ...(
|
|
58
|
+
return (await this.delete(`/document/${encodeURIComponent(documentId)}`, ...(0, request_options_1.optionalArg)(requestOptions)));
|
|
58
59
|
}
|
|
59
60
|
async function updateDocumentMetadata(documentId, body, requestOptions) {
|
|
60
|
-
return (await this.patch(`/document/${encodeURIComponent(documentId)}`, body, ...(
|
|
61
|
+
return (await this.patch(`/document/${encodeURIComponent(documentId)}`, body, ...(0, request_options_1.optionalArg)(requestOptions)));
|
|
61
62
|
}
|
|
62
63
|
async function generateDocumentReplacementUpload(documentId, body, requestOptions) {
|
|
63
64
|
return this.post(`/document/${encodeURIComponent(documentId)}`, body, undefined, requestOptions);
|
|
64
65
|
}
|
|
65
66
|
async function searchMappedContent(type, language, params = {}, requestOptions) {
|
|
66
|
-
return this.get(`/cms/${encodeURIComponent(type)}/map/${encodeURIComponent(language)}${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
67
|
+
return this.get(`/cms/${encodeURIComponent(type)}/map/${encodeURIComponent(language)}${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
67
68
|
}
|
|
68
69
|
async function copyContentsFromParent(type, language, requestOptions) {
|
|
69
70
|
return this.post(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/copy-from-parent-project`, undefined, undefined, requestOptions);
|
|
@@ -78,13 +79,13 @@ async function updateContent(type, language, key, body, requestOptions) {
|
|
|
78
79
|
return (await this.put(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, body, undefined, requestOptions));
|
|
79
80
|
}
|
|
80
81
|
async function getContent(type, language, key, requestOptions) {
|
|
81
|
-
return this.get(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, ...(
|
|
82
|
+
return this.get(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
82
83
|
}
|
|
83
84
|
async function deleteContent(type, language, key, requestOptions) {
|
|
84
|
-
await this.delete(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, ...(
|
|
85
|
+
await this.delete(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
85
86
|
}
|
|
86
87
|
async function searchContent(type, language, params = {}, requestOptions) {
|
|
87
|
-
return this.get(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
88
|
+
return this.get(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
88
89
|
}
|
|
89
90
|
async function createVideoCallAppointment(body, requestOptions) {
|
|
90
91
|
return this.post("/video-call/livekit/appointment", body, undefined, requestOptions);
|
|
@@ -93,10 +94,10 @@ async function updateVideoCallAppointment(appointmentId, body, requestOptions) {
|
|
|
93
94
|
return (await this.put(`/video-call/livekit/appointment/${encodeURIComponent(appointmentId)}`, body, undefined, requestOptions));
|
|
94
95
|
}
|
|
95
96
|
async function listVideoCallAppointments(params = {}, requestOptions) {
|
|
96
|
-
return this.get(`/video-call/livekit/appointment${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
97
|
+
return this.get(`/video-call/livekit/appointment${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
97
98
|
}
|
|
98
99
|
async function getVideoCallAccessPermission(appointmentId, requestOptions) {
|
|
99
|
-
return this.get(`/video-call/livekit/access-permission/${encodeURIComponent(appointmentId)}`, ...(
|
|
100
|
+
return this.get(`/video-call/livekit/access-permission/${encodeURIComponent(appointmentId)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
100
101
|
}
|
|
101
102
|
async function createVideoCallGuestAccess(appointmentId, body, requestOptions) {
|
|
102
103
|
return this.post(`/video-call/livekit/guest-access/${encodeURIComponent(appointmentId)}`, body, undefined, requestOptions);
|
|
@@ -126,13 +127,13 @@ async function sendChatMessage(sessionId, body, requestOptions) {
|
|
|
126
127
|
return this.post(`/ai/session/${encodeURIComponent(sessionId)}/message`, body, undefined, requestOptions);
|
|
127
128
|
}
|
|
128
129
|
async function listChatSessions(params = {}, requestOptions) {
|
|
129
|
-
return this.get(`/ai/session${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
130
|
+
return this.get(`/ai/session${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
130
131
|
}
|
|
131
132
|
async function getChatSession(sessionId, params = {}, requestOptions) {
|
|
132
|
-
return this.get(`/ai/session/${encodeURIComponent(sessionId)}${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
133
|
+
return this.get(`/ai/session/${encodeURIComponent(sessionId)}${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
133
134
|
}
|
|
134
135
|
async function listChatMessages(sessionId, params = {}, requestOptions) {
|
|
135
|
-
return this.get(`/ai/session/${encodeURIComponent(sessionId)}/message${(0, query_string_1.toQueryString)(params)}`, ...(
|
|
136
|
+
return this.get(`/ai/session/${encodeURIComponent(sessionId)}/message${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
136
137
|
}
|
|
137
138
|
async function searchAIFhir(request, requestOptions) {
|
|
138
139
|
return this.post("/ai/fhir/search", request, undefined, requestOptions);
|
|
@@ -5,6 +5,7 @@ exports.invitePatient = invitePatient;
|
|
|
5
5
|
exports.acceptPractitionerInvite = acceptPractitionerInvite;
|
|
6
6
|
exports.acceptPatientInvite = acceptPatientInvite;
|
|
7
7
|
exports.acceptInvite = acceptInvite;
|
|
8
|
+
const request_options_1 = require("../request-options");
|
|
8
9
|
function invitePractitioner(body, requestOptions) {
|
|
9
10
|
return this.post("/v1/invites/practitioner", body, undefined, requestOptions);
|
|
10
11
|
}
|
|
@@ -20,17 +21,12 @@ function acceptPatientInvite(body, requestOptions) {
|
|
|
20
21
|
function acceptInvite(body, requestOptions) {
|
|
21
22
|
var _a;
|
|
22
23
|
const resourceType = (_a = this.getProfile()) === null || _a === void 0 ? void 0 : _a.resourceType;
|
|
23
|
-
if (resourceType
|
|
24
|
-
|
|
25
|
-
this.invalidateUrl("/v1/patient-sharing/shares");
|
|
26
|
-
return result;
|
|
27
|
-
});
|
|
24
|
+
if (resourceType !== "Practitioner" && resourceType !== "Patient") {
|
|
25
|
+
throw new Error("Accepting an invite requires a signed-in Patient or Practitioner profile.");
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
throw new Error("Accepting an invite requires a signed-in Patient or Practitioner profile.");
|
|
27
|
+
const accept = resourceType === "Practitioner" ? this.acceptPractitionerInvite : this.acceptPatientInvite;
|
|
28
|
+
return accept.call(this, body, ...(0, request_options_1.optionalArg)(requestOptions)).then((result) => {
|
|
29
|
+
this.invalidateUrl("/v1/patient-sharing/shares");
|
|
30
|
+
return result;
|
|
31
|
+
});
|
|
36
32
|
}
|
|
@@ -5,6 +5,7 @@ exports.listNotificationNotes = listNotificationNotes;
|
|
|
5
5
|
exports.updateNotificationNote = updateNotificationNote;
|
|
6
6
|
exports.patchNotificationNote = patchNotificationNote;
|
|
7
7
|
exports.deleteNotificationNote = deleteNotificationNote;
|
|
8
|
+
const request_options_1 = require("../request-options");
|
|
8
9
|
const TARGET_PATH = {
|
|
9
10
|
oob: "oob",
|
|
10
11
|
alarm: "alarms",
|
|
@@ -15,14 +16,14 @@ function createNotificationNote(body, requestOptions) {
|
|
|
15
16
|
return this.post("/v1/slim/notifications/notes", body, undefined, requestOptions);
|
|
16
17
|
}
|
|
17
18
|
function listNotificationNotes(kind, id, requestOptions) {
|
|
18
|
-
return this.get(`/v1/slim/notifications/${TARGET_PATH[kind]}/${encodeURIComponent(id)}/notes`, {
|
|
19
|
+
return this.get(`/v1/slim/notifications/${TARGET_PATH[kind]}/${encodeURIComponent(id)}/notes`, { cache: "reload", ...requestOptions });
|
|
19
20
|
}
|
|
20
21
|
function updateNotificationNote(noteId, body, requestOptions) {
|
|
21
22
|
return this.put(`/v1/slim/notifications/notes/${encodeURIComponent(noteId)}`, body, undefined, requestOptions);
|
|
22
23
|
}
|
|
23
24
|
function patchNotificationNote(noteId, body, requestOptions) {
|
|
24
|
-
return this.patch(`/v1/slim/notifications/notes/${encodeURIComponent(noteId)}`, body, ...(
|
|
25
|
+
return this.patch(`/v1/slim/notifications/notes/${encodeURIComponent(noteId)}`, body, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
25
26
|
}
|
|
26
27
|
async function deleteNotificationNote(noteId, requestOptions) {
|
|
27
|
-
await this.delete(`/v1/slim/notifications/notes/${encodeURIComponent(noteId)}`, ...(
|
|
28
|
+
await this.delete(`/v1/slim/notifications/notes/${encodeURIComponent(noteId)}`, ...(0, request_options_1.optionalArg)(requestOptions));
|
|
28
29
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const LOINC_SYSTEM = "http://loinc.org";
|
|
2
|
+
export declare const UCUM_SYSTEM = "http://unitsofmeasure.org";
|
|
3
|
+
/** Identifier system of the device-side reading id that makes a save idempotent. */
|
|
4
|
+
export declare const DEVICE_READING_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/device-reading-id";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEVICE_READING_IDENTIFIER_SYSTEM = exports.UCUM_SYSTEM = exports.LOINC_SYSTEM = void 0;
|
|
4
|
+
exports.LOINC_SYSTEM = "http://loinc.org";
|
|
5
|
+
exports.UCUM_SYSTEM = "http://unitsofmeasure.org";
|
|
6
|
+
/** Identifier system of the device-side reading id that makes a save idempotent. */
|
|
7
|
+
exports.DEVICE_READING_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/device-reading-id";
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateObservationBodiesByMeasurement = generateObservationBodiesByMeasurement;
|
|
4
4
|
const core_1 = require("@medplum/core");
|
|
5
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
5
6
|
const creator_1 = require("../services/creator");
|
|
6
7
|
const getDeviceObject_1 = require("../utils/getDeviceObject");
|
|
7
|
-
const DEVICE_READING_IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/device-reading-id";
|
|
8
8
|
const getPatientReference = async (client, patientId) => {
|
|
9
9
|
if (patientId) {
|
|
10
10
|
return `Patient/${patientId}`;
|
|
@@ -20,7 +20,7 @@ const addSourceIdentifier = (observations, patientReference, sourceId) => patien
|
|
|
20
20
|
identifier: [
|
|
21
21
|
...((_a = observation.identifier) !== null && _a !== void 0 ? _a : []),
|
|
22
22
|
{
|
|
23
|
-
system: DEVICE_READING_IDENTIFIER_SYSTEM,
|
|
23
|
+
system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM,
|
|
24
24
|
value: `${patientReference}/${sourceId}/${index}`,
|
|
25
25
|
},
|
|
26
26
|
],
|
|
@@ -28,52 +28,46 @@ const addSourceIdentifier = (observations, patientReference, sourceId) => patien
|
|
|
28
28
|
})
|
|
29
29
|
: observations;
|
|
30
30
|
async function generateObservationBodiesByMeasurement(params) {
|
|
31
|
-
var _a;
|
|
31
|
+
var _a, _b;
|
|
32
32
|
const { device, measurement } = params;
|
|
33
33
|
const measurementTypeKey = measurement.measurementTypeKey;
|
|
34
34
|
const patientReference = await getPatientReference(this, params.patientId);
|
|
35
35
|
const observationService = creator_1.ObservationServiceCreator.getInstance().getService(measurementTypeKey);
|
|
36
36
|
const deviceObject = (0, getDeviceObject_1.getDeviceObject)(device);
|
|
37
|
-
const observationFragments = (_a = observationService.generateObservationFragments) === null || _a === void 0 ? void 0 : _a.call(observationService, measurement);
|
|
38
37
|
const applyEffectiveDateTime = (observation) => params.effectiveDateTime && !observation.effectivePeriod
|
|
39
38
|
? {
|
|
40
39
|
...observation,
|
|
41
40
|
effectiveDateTime: params.effectiveDateTime.toISOString(),
|
|
42
41
|
}
|
|
43
42
|
: observation;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
resourceType: "Observation",
|
|
48
|
-
status: "registered",
|
|
49
|
-
subject: {
|
|
50
|
-
reference: patientReference,
|
|
51
|
-
},
|
|
52
|
-
device: deviceObject,
|
|
53
|
-
...fragment.value,
|
|
54
|
-
code: fragment.code,
|
|
55
|
-
...(fragment.additionalProperties || {}),
|
|
56
|
-
}))
|
|
57
|
-
.filter(hasObservationValue)
|
|
58
|
-
.map(applyEffectiveDateTime);
|
|
59
|
-
return addSourceIdentifier(observations, patientReference, params.sourceId);
|
|
60
|
-
}
|
|
61
|
-
const observationCodes = observationService.getObservationCodes();
|
|
62
|
-
const values = observationService.generateValues(measurement);
|
|
63
|
-
const additionalProperties = observationService.getAdditionalProperties(measurement);
|
|
64
|
-
const observationBodies = observationCodes.map((code, index) => ({
|
|
43
|
+
const fragments = (_b = (_a = observationService.generateObservationFragments) === null || _a === void 0 ? void 0 : _a.call(observationService, measurement)) !== null && _b !== void 0 ? _b : codeValueFragments(observationService, measurement);
|
|
44
|
+
const observations = fragments
|
|
45
|
+
.map((fragment) => ({
|
|
65
46
|
resourceType: "Observation",
|
|
66
47
|
status: "registered",
|
|
67
48
|
subject: {
|
|
68
49
|
reference: patientReference,
|
|
69
50
|
},
|
|
70
51
|
device: deviceObject,
|
|
71
|
-
...
|
|
52
|
+
...fragment.value,
|
|
53
|
+
code: fragment.code,
|
|
54
|
+
...(fragment.additionalProperties || {}),
|
|
55
|
+
}))
|
|
56
|
+
.filter(hasObservationValue)
|
|
57
|
+
.map(applyEffectiveDateTime);
|
|
58
|
+
return addSourceIdentifier(observations, patientReference, params.sourceId);
|
|
59
|
+
}
|
|
60
|
+
/** Services without fragments describe their observations as parallel code, value and property lists. */
|
|
61
|
+
const codeValueFragments = (service, measurement) => {
|
|
62
|
+
const codes = service.getObservationCodes();
|
|
63
|
+
const values = service.generateValues(measurement);
|
|
64
|
+
const additionalProperties = service.getAdditionalProperties(measurement);
|
|
65
|
+
return codes.map((code, index) => ({
|
|
72
66
|
code,
|
|
73
|
-
|
|
67
|
+
value: values[index],
|
|
68
|
+
additionalProperties: additionalProperties[index],
|
|
74
69
|
}));
|
|
75
|
-
|
|
76
|
-
}
|
|
70
|
+
};
|
|
77
71
|
const hasObservationValue = (observation) => {
|
|
78
72
|
var _a, _b, _c, _d, _e, _f;
|
|
79
73
|
return ((_a = observation.valueQuantity) === null || _a === void 0 ? void 0 : _a.value) !== undefined ||
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLatestObservationsByCodes = getLatestObservationsByCodes;
|
|
4
|
+
const query_string_1 = require("../../query-string");
|
|
4
5
|
async function getLatestObservationsByCodes(params, requestOptions) {
|
|
5
6
|
var _a;
|
|
6
7
|
let patientId = "patientId" in params ? params.patientId : "";
|
|
@@ -8,14 +9,10 @@ async function getLatestObservationsByCodes(params, requestOptions) {
|
|
|
8
9
|
const currentUser = await this.getProfileAsync();
|
|
9
10
|
patientId = (_a = currentUser === null || currentUser === void 0 ? void 0 : currentUser.id) !== null && _a !== void 0 ? _a : "";
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
code: codes,
|
|
12
|
+
return this.get(`/fhir/Observation/$lastn${(0, query_string_1.toQueryString)({
|
|
13
|
+
max: 1,
|
|
14
|
+
code: params.codes,
|
|
15
15
|
patient: `Patient/${patientId}`,
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
return this.get(`/fhir/Observation/$lastn?${urlParams.toString()}`, { ...{
|
|
19
|
-
cache: "no-cache",
|
|
20
|
-
}, ...requestOptions });
|
|
16
|
+
date: params.date ? `ge${params.date}` : undefined,
|
|
17
|
+
})}`, { cache: "no-cache", ...requestOptions });
|
|
21
18
|
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.observationsToMeasurements = exports.observationCodesForTypes = void 0;
|
|
5
5
|
const types_1 = require("../../../types");
|
|
6
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
7
|
+
const single_value_services_1 = require("../services/single-value-services");
|
|
6
8
|
const DEFAULT_OBSERVATION_TIME_TOLERANCE_MS = 1000;
|
|
7
9
|
const codeOf = (observation) => {
|
|
8
10
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
|
-
return (_d = (_c = (_b = (_a = observation.code) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b.find((coding) => coding.system ===
|
|
11
|
+
return (_d = (_c = (_b = (_a = observation.code) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b.find((coding) => coding.system === fhir_systems_1.LOINC_SYSTEM)) === null || _c === void 0 ? void 0 : _c.code) !== null && _d !== void 0 ? _d : (_g = (_f = (_e = observation.code) === null || _e === void 0 ? void 0 : _e.coding) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.code;
|
|
10
12
|
};
|
|
11
13
|
const valueOf = (observation) => {
|
|
12
14
|
var _a;
|
|
@@ -199,9 +201,10 @@ const groupObservations = (observations, options, legacyKey) => {
|
|
|
199
201
|
}
|
|
200
202
|
return [...groups.values()].sort((left, right) => left.firstIndex - right.firstIndex);
|
|
201
203
|
};
|
|
202
|
-
const firstValue = (observations, code) =>
|
|
203
|
-
|
|
204
|
-
: undefined;
|
|
204
|
+
const firstValue = (observations, code) => {
|
|
205
|
+
const match = observations.find((observation) => codeOf(observation) === code);
|
|
206
|
+
return match ? valueOf(match) : undefined;
|
|
207
|
+
};
|
|
205
208
|
const LIPID_FIELDS = [
|
|
206
209
|
{ key: "totalCholesterol", codes: [types_1.ObservationCode.TOTAL_CHOLESTEROL_MASS, types_1.ObservationCode.TOTAL_CHOLESTEROL_MOLAR] },
|
|
207
210
|
{ key: "hdlCholesterol", codes: [types_1.ObservationCode.HDL_CHOLESTEROL_MASS, types_1.ObservationCode.HDL_CHOLESTEROL_MOLAR] },
|
|
@@ -220,40 +223,45 @@ const lipidValue = (observations, field) => {
|
|
|
220
223
|
}
|
|
221
224
|
return undefined;
|
|
222
225
|
};
|
|
226
|
+
const MOLAR_LIPID_CODES = [
|
|
227
|
+
types_1.ObservationCode.TOTAL_CHOLESTEROL_MOLAR,
|
|
228
|
+
types_1.ObservationCode.HDL_CHOLESTEROL_MOLAR,
|
|
229
|
+
types_1.ObservationCode.LDL_CHOLESTEROL_MOLAR,
|
|
230
|
+
types_1.ObservationCode.TRIGLYCERIDES_MOLAR,
|
|
231
|
+
];
|
|
232
|
+
const MASS_LIPID_CODES = [
|
|
233
|
+
types_1.ObservationCode.TOTAL_CHOLESTEROL_MASS,
|
|
234
|
+
types_1.ObservationCode.HDL_CHOLESTEROL_MASS,
|
|
235
|
+
types_1.ObservationCode.LDL_CHOLESTEROL_MASS,
|
|
236
|
+
types_1.ObservationCode.TRIGLYCERIDES_MASS,
|
|
237
|
+
];
|
|
238
|
+
/** The unit a lipid code implies, else the quantity's own unit when it is a lipid unit. */
|
|
239
|
+
const lipidUnitOf = (code, unit) => {
|
|
240
|
+
if (code && MOLAR_LIPID_CODES.includes(code)) {
|
|
241
|
+
return "mmol/L";
|
|
242
|
+
}
|
|
243
|
+
if (code && MASS_LIPID_CODES.includes(code)) {
|
|
244
|
+
return "mg/dL";
|
|
245
|
+
}
|
|
246
|
+
return unit === "mmol/L" || unit === "mg/dL" ? unit : undefined;
|
|
247
|
+
};
|
|
223
248
|
const lipidUnit = (observations) => {
|
|
224
|
-
var _a, _b, _c, _d, _e
|
|
249
|
+
var _a, _b, _c, _d, _e;
|
|
225
250
|
for (const observation of observations) {
|
|
226
251
|
for (const component of (_a = observation.component) !== null && _a !== void 0 ? _a : []) {
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
return "mmol/L";
|
|
252
|
+
const unit = lipidUnitOf((_c = (_b = component.code.coding) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code, (_d = component.valueQuantity) === null || _d === void 0 ? void 0 : _d.unit);
|
|
253
|
+
if (unit) {
|
|
254
|
+
return unit;
|
|
231
255
|
}
|
|
232
|
-
if ([types_1.ObservationCode.TOTAL_CHOLESTEROL_MASS, types_1.ObservationCode.HDL_CHOLESTEROL_MASS,
|
|
233
|
-
types_1.ObservationCode.LDL_CHOLESTEROL_MASS, types_1.ObservationCode.TRIGLYCERIDES_MASS].includes(code)) {
|
|
234
|
-
return "mg/dL";
|
|
235
|
-
}
|
|
236
|
-
if (((_d = component.valueQuantity) === null || _d === void 0 ? void 0 : _d.unit) === "mmol/L" || ((_e = component.valueQuantity) === null || _e === void 0 ? void 0 : _e.unit) === "mg/dL") {
|
|
237
|
-
return component.valueQuantity.unit;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const code = codeOf(observation);
|
|
241
|
-
const unit = (_f = observation.valueQuantity) === null || _f === void 0 ? void 0 : _f.unit;
|
|
242
|
-
if (code && [types_1.ObservationCode.TOTAL_CHOLESTEROL_MOLAR, types_1.ObservationCode.HDL_CHOLESTEROL_MOLAR,
|
|
243
|
-
types_1.ObservationCode.LDL_CHOLESTEROL_MOLAR, types_1.ObservationCode.TRIGLYCERIDES_MOLAR].includes(code)) {
|
|
244
|
-
return "mmol/L";
|
|
245
256
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return "mg/dL";
|
|
249
|
-
}
|
|
250
|
-
if (unit === "mmol/L" || unit === "mg/dL") {
|
|
257
|
+
const unit = lipidUnitOf(codeOf(observation), (_e = observation.valueQuantity) === null || _e === void 0 ? void 0 : _e.unit);
|
|
258
|
+
if (unit) {
|
|
251
259
|
return unit;
|
|
252
260
|
}
|
|
253
261
|
}
|
|
254
262
|
return "mg/dL";
|
|
255
263
|
};
|
|
256
|
-
const
|
|
264
|
+
const componentsOf = (observations) => observations.flatMap((observation) => { var _a; return (_a = observation.component) !== null && _a !== void 0 ? _a : []; });
|
|
257
265
|
const baseMeasurement = (measurementTypeKey, observation) => ({
|
|
258
266
|
measurementTypeKey,
|
|
259
267
|
...(observation.id ? { id: observation.id } : {}),
|
|
@@ -269,6 +277,10 @@ const inverseGroup = (type, observations) => {
|
|
|
269
277
|
})[0];
|
|
270
278
|
const measurement = baseMeasurement(type, first);
|
|
271
279
|
const value = (code) => firstValue(observations, code);
|
|
280
|
+
const single = single_value_services_1.singleValueFields.get(type);
|
|
281
|
+
if (single) {
|
|
282
|
+
return { ...measurement, measurementTypeKey: type, [single.valueKey]: value(single.code) };
|
|
283
|
+
}
|
|
272
284
|
switch (type) {
|
|
273
285
|
case types_1.MeasurementTypeKey.bloodPressure:
|
|
274
286
|
return {
|
|
@@ -280,12 +292,6 @@ const inverseGroup = (type, observations) => {
|
|
|
280
292
|
heartRate: value(types_1.ObservationCode.BLOOD_PRESSURE_HEART_RATE),
|
|
281
293
|
irregularHeartbeat: irregularHeartbeatOf(observations),
|
|
282
294
|
};
|
|
283
|
-
case types_1.MeasurementTypeKey.bloodGlucose:
|
|
284
|
-
return { ...measurement, measurementTypeKey: type, bloodGlucose: value(types_1.ObservationCode.BLOOD_GLUCOSE) };
|
|
285
|
-
case types_1.MeasurementTypeKey.bodyWeight:
|
|
286
|
-
return { ...measurement, measurementTypeKey: type, bodyWeight: value(types_1.ObservationCode.BODY_WEIGHT) };
|
|
287
|
-
case types_1.MeasurementTypeKey.temperature:
|
|
288
|
-
return { ...measurement, measurementTypeKey: type, bodyTemp: value(types_1.ObservationCode.BODY_TEMPERATURE) };
|
|
289
295
|
case types_1.MeasurementTypeKey.bloodOxygenPulseRate:
|
|
290
296
|
return {
|
|
291
297
|
...measurement,
|
|
@@ -293,42 +299,6 @@ const inverseGroup = (type, observations) => {
|
|
|
293
299
|
bloodOxygen: value(types_1.ObservationCode.OXYGEN_SATURATION),
|
|
294
300
|
pulseRate: value(types_1.ObservationCode.OXYGEN_SATURATION_HEART_RATE),
|
|
295
301
|
};
|
|
296
|
-
case types_1.MeasurementTypeKey.heartRate:
|
|
297
|
-
return {
|
|
298
|
-
...measurement,
|
|
299
|
-
measurementTypeKey: type,
|
|
300
|
-
heartRate: value(types_1.ObservationCode.HEART_RATE),
|
|
301
|
-
};
|
|
302
|
-
case types_1.MeasurementTypeKey.heartRateVariability:
|
|
303
|
-
return {
|
|
304
|
-
...measurement,
|
|
305
|
-
measurementTypeKey: type,
|
|
306
|
-
heartRateVariability: value(types_1.ObservationCode.HEART_RATE_VARIABILITY),
|
|
307
|
-
};
|
|
308
|
-
case types_1.MeasurementTypeKey.respiratoryRate:
|
|
309
|
-
return {
|
|
310
|
-
...measurement,
|
|
311
|
-
measurementTypeKey: type,
|
|
312
|
-
respiratoryRate: value(types_1.ObservationCode.RESPIRATORY_RATE),
|
|
313
|
-
};
|
|
314
|
-
case types_1.MeasurementTypeKey.restingHeartRate:
|
|
315
|
-
return {
|
|
316
|
-
...measurement,
|
|
317
|
-
measurementTypeKey: type,
|
|
318
|
-
restingHeartRate: value(types_1.ObservationCode.RESTING_HEART_RATE),
|
|
319
|
-
};
|
|
320
|
-
case types_1.MeasurementTypeKey.walkingHeartRateAverage:
|
|
321
|
-
return {
|
|
322
|
-
...measurement,
|
|
323
|
-
measurementTypeKey: type,
|
|
324
|
-
walkingHeartRateAverage: value(types_1.ObservationCode.WALKING_HEART_RATE_AVERAGE),
|
|
325
|
-
};
|
|
326
|
-
case types_1.MeasurementTypeKey.vo2Max:
|
|
327
|
-
return {
|
|
328
|
-
...measurement,
|
|
329
|
-
measurementTypeKey: type,
|
|
330
|
-
vo2Max: value(types_1.ObservationCode.VO2_MAX),
|
|
331
|
-
};
|
|
332
302
|
case types_1.MeasurementTypeKey.stepCount:
|
|
333
303
|
return {
|
|
334
304
|
...measurement,
|
|
@@ -395,34 +365,22 @@ const inverseGroup = (type, observations) => {
|
|
|
395
365
|
})),
|
|
396
366
|
};
|
|
397
367
|
case types_1.MeasurementTypeKey.respiratoryTherapy:
|
|
398
|
-
return {
|
|
399
|
-
...measurement,
|
|
400
|
-
measurementTypeKey: type,
|
|
401
|
-
components: respiratoryComponents(observations),
|
|
402
|
-
};
|
|
403
368
|
case types_1.MeasurementTypeKey.babySleep:
|
|
404
369
|
return {
|
|
405
370
|
...measurement,
|
|
406
371
|
measurementTypeKey: type,
|
|
407
|
-
components:
|
|
372
|
+
components: componentsOf(observations),
|
|
408
373
|
};
|
|
409
374
|
default:
|
|
410
375
|
return measurement;
|
|
411
376
|
}
|
|
412
377
|
};
|
|
378
|
+
const COMPONENT_TYPES = new Set([types_1.MeasurementTypeKey.respiratoryTherapy, types_1.MeasurementTypeKey.babySleep]);
|
|
413
379
|
const codesForType = {
|
|
380
|
+
...Object.fromEntries([...single_value_services_1.singleValueFields].map(([type, { code }]) => [type, [code]])),
|
|
414
381
|
[types_1.MeasurementTypeKey.bloodPressure]: [types_1.ObservationCode.SYSTOLIC_BLOOD_PRESSURE, types_1.ObservationCode.DIASTOLIC_BLOOD_PRESSURE, types_1.ObservationCode.MEAN_BLOOD_PRESSURE, types_1.ObservationCode.BLOOD_PRESSURE_HEART_RATE, types_1.PulseRhythmCoding.observation],
|
|
415
|
-
[types_1.MeasurementTypeKey.bloodGlucose]: [types_1.ObservationCode.BLOOD_GLUCOSE],
|
|
416
|
-
[types_1.MeasurementTypeKey.bodyWeight]: [types_1.ObservationCode.BODY_WEIGHT],
|
|
417
|
-
[types_1.MeasurementTypeKey.temperature]: [types_1.ObservationCode.BODY_TEMPERATURE],
|
|
418
382
|
[types_1.MeasurementTypeKey.bloodOxygenPulseRate]: [types_1.ObservationCode.OXYGEN_SATURATION, types_1.ObservationCode.OXYGEN_SATURATION_HEART_RATE],
|
|
419
383
|
[types_1.MeasurementTypeKey.stepCount]: [types_1.ObservationCode.STEPS],
|
|
420
|
-
[types_1.MeasurementTypeKey.heartRate]: [types_1.ObservationCode.HEART_RATE],
|
|
421
|
-
[types_1.MeasurementTypeKey.heartRateVariability]: [types_1.ObservationCode.HEART_RATE_VARIABILITY],
|
|
422
|
-
[types_1.MeasurementTypeKey.respiratoryRate]: [types_1.ObservationCode.RESPIRATORY_RATE],
|
|
423
|
-
[types_1.MeasurementTypeKey.restingHeartRate]: [types_1.ObservationCode.RESTING_HEART_RATE],
|
|
424
|
-
[types_1.MeasurementTypeKey.walkingHeartRateAverage]: [types_1.ObservationCode.WALKING_HEART_RATE_AVERAGE],
|
|
425
|
-
[types_1.MeasurementTypeKey.vo2Max]: [types_1.ObservationCode.VO2_MAX],
|
|
426
384
|
[types_1.MeasurementTypeKey.ecg]: [types_1.ObservationCode.ECG, types_1.ObservationCode.ECG_HEART_RATE, types_1.ObservationCode.HEART_RATE],
|
|
427
385
|
[types_1.MeasurementTypeKey.uricAcid]: [
|
|
428
386
|
types_1.ObservationCode.URIC_ACID,
|
|
@@ -456,12 +414,7 @@ const observationsToMeasurements = (observations, types, options = {}) => {
|
|
|
456
414
|
!LIPID_FIELDS.some((field) => lipidValue(group.observations, field) !== undefined)) {
|
|
457
415
|
return;
|
|
458
416
|
}
|
|
459
|
-
if (type
|
|
460
|
-
respiratoryComponents(group.observations).length === 0) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (type === types_1.MeasurementTypeKey.babySleep &&
|
|
464
|
-
respiratoryComponents(group.observations).length === 0) {
|
|
417
|
+
if (COMPONENT_TYPES.has(type) && componentsOf(group.observations).length === 0) {
|
|
465
418
|
return;
|
|
466
419
|
}
|
|
467
420
|
output.push(inverseGroup(type, group.observations));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseObservationService = void 0;
|
|
4
|
+
const fhir_systems_1 = require("../fhir-systems");
|
|
4
5
|
class BaseObservationService {
|
|
5
6
|
getCastedMeasurement(measurement) {
|
|
6
7
|
if (measurement.measurementTypeKey !== this.measurementTypeKey) {
|
|
@@ -25,7 +26,7 @@ class BaseObservationService {
|
|
|
25
26
|
value: Number(fixedValue),
|
|
26
27
|
unit: metadata.unit,
|
|
27
28
|
code: metadata.primaryCode,
|
|
28
|
-
system:
|
|
29
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
29
30
|
},
|
|
30
31
|
};
|
|
31
32
|
});
|
|
@@ -36,12 +37,12 @@ class BaseObservationService {
|
|
|
36
37
|
{
|
|
37
38
|
code: metadata.primaryCode,
|
|
38
39
|
display: metadata.display,
|
|
39
|
-
system:
|
|
40
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
40
41
|
},
|
|
41
42
|
...metadata.additionalCodes.map((code) => ({
|
|
42
43
|
code,
|
|
43
44
|
display: metadata.display,
|
|
44
|
-
system:
|
|
45
|
+
system: fhir_systems_1.LOINC_SYSTEM,
|
|
45
46
|
})),
|
|
46
47
|
],
|
|
47
48
|
text: metadata.display,
|