@ovok/core 0.4.49-dev.494 → 0.4.49-dev.496
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/observation/measurement-fields.d.ts +1 -1
- package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
- package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
- package/dist/client/observation/services/base-observation-service.d.ts +1 -1
- package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
- package/dist/client/observation/services/blood-oxygen.js +7 -7
- package/dist/client/observation/services/blood-pressure.d.ts +1 -1
- package/dist/client/observation/services/blood-pressure.js +16 -16
- package/dist/client/observation/services/component-observation-services.d.ts +1 -1
- package/dist/client/observation/services/component-observation-services.js +3 -3
- package/dist/client/observation/services/creator.d.ts +1 -1
- package/dist/client/observation/services/creator.js +10 -10
- package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
- package/dist/client/observation/services/ecg.d.ts +1 -1
- package/dist/client/observation/services/ecg.js +10 -10
- package/dist/client/observation/services/lipid-panel.d.ts +1 -1
- package/dist/client/observation/services/lipid-panel.js +13 -13
- package/dist/client/observation/services/single-value-services.d.ts +1 -1
- package/dist/client/observation/services/single-value-services.js +19 -19
- package/dist/client/observation/services/step-count.d.ts +1 -1
- package/dist/client/observation/services/step-count.js +5 -5
- package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
- package/dist/client/observation/services/uric-acid-service.js +7 -7
- package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
- package/dist/client/wearables/types.d.ts +5 -0
- package/dist/conformance/capability-requirements.js +1 -1
- package/dist/next/auth/access-token.d.ts +9 -0
- package/dist/next/auth/access-token.js +18 -0
- package/dist/next/auth/client-credentials.d.ts +16 -0
- package/dist/next/auth/client-credentials.js +40 -0
- package/dist/next/auth/credentials.d.ts +5 -0
- package/dist/next/auth/credentials.js +7 -0
- package/dist/next/auth/session-store.d.ts +12 -0
- package/dist/next/auth/session-store.js +33 -0
- package/dist/next/auth/session.d.ts +28 -0
- package/dist/next/auth/session.js +27 -0
- package/dist/next/auth/token-endpoint.d.ts +12 -0
- package/dist/next/auth/token-endpoint.js +28 -0
- package/dist/next/auth/user-session.d.ts +27 -0
- package/dist/next/auth/user-session.js +82 -0
- package/dist/next/config/ovok-config.d.ts +42 -0
- package/dist/next/config/ovok-config.js +2 -0
- package/dist/next/config/settings.d.ts +6 -0
- package/dist/next/config/settings.js +74 -0
- package/dist/next/errors/error-from-response.d.ts +2 -0
- package/dist/next/errors/error-from-response.js +35 -0
- package/dist/next/errors/ovok-errors.d.ts +42 -0
- package/dist/next/errors/ovok-errors.js +74 -0
- package/dist/next/http/http-client.d.ts +35 -0
- package/dist/next/http/http-client.js +113 -0
- package/dist/next/http/retry-after.d.ts +1 -0
- package/dist/next/http/retry-after.js +16 -0
- package/dist/next/http/retry-policy.d.ts +13 -0
- package/dist/next/http/retry-policy.js +27 -0
- package/dist/next/http/transmit.d.ts +14 -0
- package/dist/next/http/transmit.js +57 -0
- package/dist/next/http/url.d.ts +6 -0
- package/dist/next/http/url.js +22 -0
- package/dist/next/index.d.ts +69 -0
- package/dist/next/index.js +33 -0
- package/dist/next/ovok.d.ts +52 -0
- package/dist/next/ovok.js +74 -0
- package/dist/next/paging/bundle-page.d.ts +4 -0
- package/dist/next/paging/bundle-page.js +25 -0
- package/dist/next/paging/cursor-pages.d.ts +7 -0
- package/dist/next/paging/cursor-pages.js +14 -0
- package/dist/next/paging/numbered-pages.d.ts +15 -0
- package/dist/next/paging/numbered-pages.js +20 -0
- package/dist/next/paging/page.d.ts +12 -0
- package/dist/next/paging/page.js +17 -0
- package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
- package/dist/next/resources/accounts/accounts-resource.js +13 -0
- package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
- package/dist/next/resources/ai/ai-chat-resource.js +12 -0
- package/dist/next/resources/ai/ai-resource.d.ts +16 -0
- package/dist/next/resources/ai/ai-resource.js +19 -0
- package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
- package/dist/next/resources/ai/chat-messages-resource.js +18 -0
- package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
- package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
- package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
- package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
- package/dist/next/resources/auth/registration.d.ts +35 -0
- package/dist/next/resources/auth/registration.js +24 -0
- package/dist/next/resources/auth/social-login.d.ts +8 -0
- package/dist/next/resources/auth/social-login.js +7 -0
- package/dist/next/resources/auth-resource.d.ts +63 -0
- package/dist/next/resources/auth-resource.js +119 -0
- package/dist/next/resources/bots/bots-resource.d.ts +10 -0
- package/dist/next/resources/bots/bots-resource.js +15 -0
- package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
- package/dist/next/resources/cms/cms-delivery.js +36 -0
- package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
- package/dist/next/resources/cms/cms-documents-resource.js +17 -0
- package/dist/next/resources/cms/cms-resource.d.ts +17 -0
- package/dist/next/resources/cms/cms-resource.js +38 -0
- package/dist/next/resources/cms/payload-pages.d.ts +6 -0
- package/dist/next/resources/cms/payload-pages.js +15 -0
- package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
- package/dist/next/resources/cms/release-notes-resource.js +15 -0
- package/dist/next/resources/cms/translation-tree.d.ts +3 -0
- package/dist/next/resources/cms/translation-tree.js +45 -0
- package/dist/next/resources/consent/consent-resource.d.ts +23 -0
- package/dist/next/resources/consent/consent-resource.js +43 -0
- package/dist/next/resources/content/content-resource.d.ts +19 -0
- package/dist/next/resources/content/content-resource.js +41 -0
- package/dist/next/resources/documents/documents-resource.d.ts +26 -0
- package/dist/next/resources/documents/documents-resource.js +41 -0
- package/dist/next/resources/email/email-resource.d.ts +6 -0
- package/dist/next/resources/email/email-resource.js +10 -0
- package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
- package/dist/next/resources/email/email-templates-resource.js +13 -0
- package/dist/next/resources/fhir-resource.d.ts +28 -0
- package/dist/next/resources/fhir-resource.js +64 -0
- package/dist/next/resources/health-resource.d.ts +17 -0
- package/dist/next/resources/health-resource.js +14 -0
- package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
- package/dist/next/resources/invites/invite-flow-resource.js +19 -0
- package/dist/next/resources/invites/invites-resource.d.ts +17 -0
- package/dist/next/resources/invites/invites-resource.js +14 -0
- package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
- package/dist/next/resources/localization/i18next-resource.js +18 -0
- package/dist/next/resources/localization/locales-resource.d.ts +9 -0
- package/dist/next/resources/localization/locales-resource.js +16 -0
- package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
- package/dist/next/resources/localization/localizations-resource.js +27 -0
- package/dist/next/resources/measurements/measurements-resource.d.ts +42 -0
- package/dist/next/resources/measurements/measurements-resource.js +77 -0
- package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
- package/dist/next/resources/measurements/observation-builder.js +57 -0
- package/dist/next/resources/measurements/save-error.d.ts +5 -0
- package/dist/next/resources/measurements/save-error.js +18 -0
- package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
- package/dist/next/resources/measurements/signed-in-account.js +26 -0
- package/dist/next/resources/patient/fhir-records.d.ts +19 -0
- package/dist/next/resources/patient/fhir-records.js +33 -0
- package/dist/next/resources/patient/patient-resource.d.ts +21 -0
- package/dist/next/resources/patient/patient-resource.js +38 -0
- package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
- package/dist/next/resources/projects/project-features-resource.js +17 -0
- package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
- package/dist/next/resources/projects/project-members-resource.js +25 -0
- package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
- package/dist/next/resources/projects/project-settings-resource.js +21 -0
- package/dist/next/resources/projects/projects-resource.d.ts +20 -0
- package/dist/next/resources/projects/projects-resource.js +21 -0
- package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
- package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
- package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
- package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
- package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
- package/dist/next/resources/sharing/sharing-resource.js +14 -0
- package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
- package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
- package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
- package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
- package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
- package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
- package/dist/next/resources/signals/signals-resource.d.ts +13 -0
- package/dist/next/resources/signals/signals-resource.js +19 -0
- package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
- package/dist/next/resources/signals/undeliverable-resource.js +18 -0
- package/dist/next/resources/slim/live-reads.d.ts +12 -0
- package/dist/next/resources/slim/live-reads.js +76 -0
- package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
- package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
- package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
- package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
- package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
- package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
- package/dist/next/resources/slim/slim-devices-resource.d.ts +28 -0
- package/dist/next/resources/slim/slim-devices-resource.js +80 -0
- package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
- package/dist/next/resources/slim/slim-exports-resource.js +14 -0
- package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
- package/dist/next/resources/slim/slim-locations-resource.js +30 -0
- package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
- package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
- package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
- package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
- package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
- package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
- package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
- package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
- package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
- package/dist/next/resources/slim/slim-paths.d.ts +6 -0
- package/dist/next/resources/slim/slim-paths.js +9 -0
- package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
- package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
- package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
- package/dist/next/resources/slim/slim-patients-resource.js +39 -0
- package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
- package/dist/next/resources/slim/slim-policies-resource.js +29 -0
- package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
- package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
- package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
- package/dist/next/resources/slim/slim-projects-resource.js +35 -0
- package/dist/next/resources/slim/slim-queries.d.ts +34 -0
- package/dist/next/resources/slim/slim-queries.js +2 -0
- package/dist/next/resources/slim/slim-resource.d.ts +38 -0
- package/dist/next/resources/slim/slim-resource.js +44 -0
- package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
- package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
- package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
- package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-trends-resource.js +19 -0
- package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
- package/dist/next/resources/slim/slim-users-resource.js +15 -0
- package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
- package/dist/next/resources/slim/slim-zones-resource.js +24 -0
- package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
- package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
- package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
- package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
- package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
- package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
- package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
- package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
- package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
- package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
- package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
- package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
- package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
- package/dist/next/resources/wearables/wearables-resource.js +14 -0
- package/dist/next/storage/ovok-storage.d.ts +11 -0
- package/dist/next/storage/ovok-storage.js +19 -0
- package/dist/types/MeasurementTypes.d.ts +5 -0
- package/dist/types/MeasurementTypes.js +21 -0
- package/dist/types/index.d.ts +1 -5
- package/dist/types/index.js +1 -5
- package/next/index.d.ts +1 -0
- package/next/index.js +3 -0
- package/package.json +3 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { OvokDocumentFile, OvokDocumentMetadataUpdate, OvokDocumentReplacement, OvokDocumentSearchQuery, OvokDocumentSearchResponse, OvokDocumentUploadRequest } from "../../../client/experience/types";
|
|
2
|
+
import { HttpClient } from "../../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../../http/transmit";
|
|
4
|
+
export type DocumentDownloadParams = {
|
|
5
|
+
width?: string | number;
|
|
6
|
+
height?: string | number;
|
|
7
|
+
fit?: string;
|
|
8
|
+
};
|
|
9
|
+
export type DeletedDocument = {
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class DocumentsResource {
|
|
13
|
+
private readonly http;
|
|
14
|
+
private readonly baseUrl;
|
|
15
|
+
constructor(http: HttpClient, baseUrl: string);
|
|
16
|
+
list(params?: OvokDocumentSearchQuery, options?: RequestOptions): Promise<OvokDocumentSearchResponse>;
|
|
17
|
+
createUpload(body: OvokDocumentUploadRequest, options?: RequestOptions): Promise<OvokDocumentFile>;
|
|
18
|
+
replaceUpload(documentId: string, body: OvokDocumentReplacement, options?: RequestOptions): Promise<OvokDocumentFile>;
|
|
19
|
+
updateMetadata(documentId: string, body: OvokDocumentMetadataUpdate, options?: RequestOptions): Promise<OvokDocumentFile>;
|
|
20
|
+
delete(documentId: string, options?: RequestOptions): Promise<DeletedDocument>;
|
|
21
|
+
/** The signed-in route: fetched with the bearer, it redirects to a signed download URL. */
|
|
22
|
+
downloadUrl(documentId: string, params?: DocumentDownloadParams): string;
|
|
23
|
+
/** Needs no bearer, so it fits an image, download or media element. */
|
|
24
|
+
publicDownloadUrl(publicToken: string, params?: DocumentDownloadParams): string;
|
|
25
|
+
private urlFor;
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentsResource = void 0;
|
|
4
|
+
const query_string_1 = require("../../../client/query-string");
|
|
5
|
+
const url_1 = require("../../http/url");
|
|
6
|
+
const DOCUMENT_PATH = "document";
|
|
7
|
+
const PUBLIC_DOCUMENT_PATH = "document/public";
|
|
8
|
+
const documentPath = (documentId) => `${DOCUMENT_PATH}/${(0, url_1.pathSegment)(documentId)}`;
|
|
9
|
+
class DocumentsResource {
|
|
10
|
+
constructor(http, baseUrl) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.baseUrl = baseUrl;
|
|
13
|
+
}
|
|
14
|
+
list(params = {}, options) {
|
|
15
|
+
return this.http.get(`${DOCUMENT_PATH}${(0, query_string_1.toQueryString)(params)}`, options);
|
|
16
|
+
}
|
|
17
|
+
createUpload(body, options) {
|
|
18
|
+
return this.http.post(DOCUMENT_PATH, body, options);
|
|
19
|
+
}
|
|
20
|
+
replaceUpload(documentId, body, options) {
|
|
21
|
+
return this.http.post(documentPath(documentId), body, options);
|
|
22
|
+
}
|
|
23
|
+
updateMetadata(documentId, body, options) {
|
|
24
|
+
return this.http.patch(documentPath(documentId), body, options);
|
|
25
|
+
}
|
|
26
|
+
delete(documentId, options) {
|
|
27
|
+
return this.http.delete(documentPath(documentId), options);
|
|
28
|
+
}
|
|
29
|
+
/** The signed-in route: fetched with the bearer, it redirects to a signed download URL. */
|
|
30
|
+
downloadUrl(documentId, params = {}) {
|
|
31
|
+
return this.urlFor(documentPath(documentId), params);
|
|
32
|
+
}
|
|
33
|
+
/** Needs no bearer, so it fits an image, download or media element. */
|
|
34
|
+
publicDownloadUrl(publicToken, params = {}) {
|
|
35
|
+
return this.urlFor(`${PUBLIC_DOCUMENT_PATH}/${(0, url_1.pathSegment)(publicToken)}`, params);
|
|
36
|
+
}
|
|
37
|
+
urlFor(path, params) {
|
|
38
|
+
return `${(0, url_1.joinPath)(this.baseUrl, path)}${(0, query_string_1.toQueryString)(params)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.DocumentsResource = DocumentsResource;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailResource = void 0;
|
|
4
|
+
const email_templates_resource_1 = require("./email-templates-resource");
|
|
5
|
+
class EmailResource {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.templates = new email_templates_resource_1.EmailTemplatesResource(http);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.EmailResource = EmailResource;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OvokEmailTemplates } from "../../../client/email/types";
|
|
2
|
+
import { HttpClient } from "../../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../../http/transmit";
|
|
4
|
+
export declare class EmailTemplatesResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
list(options?: RequestOptions): Promise<OvokEmailTemplates>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailTemplatesResource = void 0;
|
|
4
|
+
const EMAIL_TEMPLATES_PATH = "v1/email/templates";
|
|
5
|
+
class EmailTemplatesResource {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
list(options) {
|
|
10
|
+
return this.http.get(EMAIL_TEMPLATES_PATH, options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.EmailTemplatesResource = EmailTemplatesResource;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Bundle, ExtractResource, Resource, ResourceType } from "@medplum/fhirtypes";
|
|
2
|
+
import { HttpClient } from "../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../http/transmit";
|
|
4
|
+
import { QueryParams } from "../http/url";
|
|
5
|
+
import { PagePromise } from "../paging/page";
|
|
6
|
+
export type PatchOperation = {
|
|
7
|
+
op: "add" | "remove" | "replace" | "copy" | "move" | "test";
|
|
8
|
+
path: string;
|
|
9
|
+
value?: unknown;
|
|
10
|
+
from?: string;
|
|
11
|
+
};
|
|
12
|
+
export type CreateOptions = RequestOptions & {
|
|
13
|
+
ifNoneExist?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare class FhirResource {
|
|
16
|
+
private readonly http;
|
|
17
|
+
constructor(http: HttpClient);
|
|
18
|
+
read<K extends ResourceType>(type: K, id: string, options?: RequestOptions): Promise<ExtractResource<K>>;
|
|
19
|
+
search<K extends ResourceType>(type: K, params?: QueryParams, options?: RequestOptions): PagePromise<ExtractResource<K>>;
|
|
20
|
+
searchOne<K extends ResourceType>(type: K, params?: QueryParams, options?: RequestOptions): Promise<ExtractResource<K> | null>;
|
|
21
|
+
/** With `ifNoneExist`, a retry cannot create a duplicate, so the request is safe to repeat. */
|
|
22
|
+
create<T extends Resource>(resource: T, options?: CreateOptions): Promise<T>;
|
|
23
|
+
update<T extends Resource>(resource: T, options?: RequestOptions): Promise<T>;
|
|
24
|
+
patch<K extends ResourceType>(type: K, id: string, operations: PatchOperation[], options?: RequestOptions): Promise<ExtractResource<K>>;
|
|
25
|
+
delete(type: ResourceType, id: string, options?: RequestOptions): Promise<void>;
|
|
26
|
+
batch(bundle: Bundle, options?: RequestOptions): Promise<Bundle>;
|
|
27
|
+
private searchPage;
|
|
28
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FhirResource = void 0;
|
|
4
|
+
const ovok_errors_1 = require("../errors/ovok-errors");
|
|
5
|
+
const url_1 = require("../http/url");
|
|
6
|
+
const bundle_page_1 = require("../paging/bundle-page");
|
|
7
|
+
const page_1 = require("../paging/page");
|
|
8
|
+
const FHIR_JSON = "application/fhir+json";
|
|
9
|
+
const READ_HEADERS = { Accept: FHIR_JSON };
|
|
10
|
+
const WRITE_HEADERS = { Accept: FHIR_JSON, "Content-Type": FHIR_JSON };
|
|
11
|
+
const PATCH_HEADERS = { Accept: FHIR_JSON, "Content-Type": "application/json-patch+json" };
|
|
12
|
+
class FhirResource {
|
|
13
|
+
constructor(http) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
}
|
|
16
|
+
read(type, id, options) {
|
|
17
|
+
return this.http.send({ method: "GET", path: resourcePath(type, id), headers: READ_HEADERS }, options);
|
|
18
|
+
}
|
|
19
|
+
search(type, params = {}, options) {
|
|
20
|
+
return (0, page_1.pagePromise)(() => this.searchPage(type, (0, url_1.toSearchQuery)(params), options));
|
|
21
|
+
}
|
|
22
|
+
async searchOne(type, params = {}, options) {
|
|
23
|
+
var _a;
|
|
24
|
+
const page = await this.search(type, { ...params, _count: 1 }, options);
|
|
25
|
+
return (_a = page.data[0]) !== null && _a !== void 0 ? _a : null;
|
|
26
|
+
}
|
|
27
|
+
/** With `ifNoneExist`, a retry cannot create a duplicate, so the request is safe to repeat. */
|
|
28
|
+
create(resource, options = {}) {
|
|
29
|
+
const { ifNoneExist, ...requestOptions } = options;
|
|
30
|
+
const condition = ifNoneExist === undefined ? {} : { "If-None-Exist": ifNoneExist };
|
|
31
|
+
return this.http.send({
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: resource.resourceType,
|
|
34
|
+
body: resource,
|
|
35
|
+
headers: { ...WRITE_HEADERS, ...condition },
|
|
36
|
+
idempotent: ifNoneExist !== undefined,
|
|
37
|
+
}, requestOptions);
|
|
38
|
+
}
|
|
39
|
+
update(resource, options) {
|
|
40
|
+
const path = resourcePath(resource.resourceType, requireId(resource));
|
|
41
|
+
return this.http.send({ method: "PUT", path, body: resource, headers: WRITE_HEADERS }, options);
|
|
42
|
+
}
|
|
43
|
+
patch(type, id, operations, options) {
|
|
44
|
+
return this.http.send({ method: "PATCH", path: resourcePath(type, id), body: operations, headers: PATCH_HEADERS }, options);
|
|
45
|
+
}
|
|
46
|
+
delete(type, id, options) {
|
|
47
|
+
return this.http.send({ method: "DELETE", path: resourcePath(type, id), headers: READ_HEADERS }, options);
|
|
48
|
+
}
|
|
49
|
+
batch(bundle, options) {
|
|
50
|
+
return this.http.send({ method: "POST", path: "", body: bundle, headers: WRITE_HEADERS }, options);
|
|
51
|
+
}
|
|
52
|
+
async searchPage(type, query, options) {
|
|
53
|
+
const bundle = await this.http.send({ method: "GET", path: `${type}${query}`, headers: READ_HEADERS }, options);
|
|
54
|
+
return (0, bundle_page_1.bundlePage)(bundle, (nextQuery) => this.searchPage(type, nextQuery, options));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.FhirResource = FhirResource;
|
|
58
|
+
const resourcePath = (type, id) => `${type}/${(0, url_1.pathSegment)(id)}`;
|
|
59
|
+
const requireId = (resource) => {
|
|
60
|
+
if (resource.id === undefined) {
|
|
61
|
+
throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)(`update needs ${resource.resourceType}.id.`));
|
|
62
|
+
}
|
|
63
|
+
return resource.id;
|
|
64
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HttpClient } from "../http/http-client";
|
|
2
|
+
import { RequestOptions } from "../http/transmit";
|
|
3
|
+
export type HealthCheck = {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
dependencies: Record<string, {
|
|
6
|
+
ok: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
version?: string | null;
|
|
9
|
+
buildEnv?: string | null;
|
|
10
|
+
commitHash?: string | null;
|
|
11
|
+
};
|
|
12
|
+
export declare class HealthResource {
|
|
13
|
+
private readonly http;
|
|
14
|
+
constructor(http: HttpClient);
|
|
15
|
+
/** Always answers 200: read `ok`, not the status. */
|
|
16
|
+
check(options?: RequestOptions): Promise<HealthCheck>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HealthResource = void 0;
|
|
4
|
+
const HEALTHCHECK_PATH = "healthcheck";
|
|
5
|
+
class HealthResource {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
/** Always answers 200: read `ok`, not the status. */
|
|
10
|
+
check(options) {
|
|
11
|
+
return this.http.get(HEALTHCHECK_PATH, options);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.HealthResource = HealthResource;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InviteSent } from "../../../client/invites/types";
|
|
2
|
+
import { HttpClient } from "../../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../../http/transmit";
|
|
4
|
+
/** One invite kind: `create` sends it to `path`, `accept` redeems it at `path/accept`. */
|
|
5
|
+
export declare class InviteFlowResource<Invite, Acceptance, Accepted> {
|
|
6
|
+
private readonly http;
|
|
7
|
+
private readonly path;
|
|
8
|
+
private readonly acceptPath;
|
|
9
|
+
constructor(http: HttpClient, path: string);
|
|
10
|
+
create(body: Invite, options?: RequestOptions): Promise<InviteSent>;
|
|
11
|
+
accept(body: Acceptance, options?: RequestOptions): Promise<Accepted>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InviteFlowResource = void 0;
|
|
4
|
+
const ACCEPT_SEGMENT = "accept";
|
|
5
|
+
/** One invite kind: `create` sends it to `path`, `accept` redeems it at `path/accept`. */
|
|
6
|
+
class InviteFlowResource {
|
|
7
|
+
constructor(http, path) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
this.path = path;
|
|
10
|
+
this.acceptPath = `${path}/${ACCEPT_SEGMENT}`;
|
|
11
|
+
}
|
|
12
|
+
create(body, options) {
|
|
13
|
+
return this.http.post(this.path, body, options);
|
|
14
|
+
}
|
|
15
|
+
accept(body, options) {
|
|
16
|
+
return this.http.post(this.acceptPath, body, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.InviteFlowResource = InviteFlowResource;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AcceptInviteBody, AcceptRecordShareBody, InviteBody, RecordShareAccepted, RecordShareBody } from "../../../client/invites/types";
|
|
2
|
+
import type { PatientSharingPractitionerShare } from "../../../client/patient-sharing/types";
|
|
3
|
+
import { HttpClient } from "../../http/http-client";
|
|
4
|
+
import { InviteFlowResource } from "./invite-flow-resource";
|
|
5
|
+
export type RecordShareFlow = InviteFlowResource<RecordShareBody, AcceptRecordShareBody, RecordShareAccepted>;
|
|
6
|
+
export type PersonInviteFlow = InviteFlowResource<InviteBody, AcceptInviteBody, PatientSharingPractitionerShare>;
|
|
7
|
+
export declare class InvitesResource {
|
|
8
|
+
/** A patient shares their record with a practitioner, or some codes with a carer. */
|
|
9
|
+
readonly recordShares: RecordShareFlow;
|
|
10
|
+
/** A practitioner invites a patient into their care. */
|
|
11
|
+
readonly care: PersonInviteFlow;
|
|
12
|
+
/** @deprecated Use `recordShares` with `recipient: "practitioner"`; the route sunsets on 2026-12-01. */
|
|
13
|
+
readonly practitioners: PersonInviteFlow;
|
|
14
|
+
/** @deprecated Use `care`; the route sunsets on 2026-12-01. */
|
|
15
|
+
readonly patients: PersonInviteFlow;
|
|
16
|
+
constructor(http: HttpClient);
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvitesResource = void 0;
|
|
4
|
+
const invite_flow_resource_1 = require("./invite-flow-resource");
|
|
5
|
+
const INVITES_PATH = "v1/invites";
|
|
6
|
+
class InvitesResource {
|
|
7
|
+
constructor(http) {
|
|
8
|
+
this.recordShares = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/record-share`);
|
|
9
|
+
this.care = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/care`);
|
|
10
|
+
this.practitioners = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/practitioner`);
|
|
11
|
+
this.patients = new invite_flow_resource_1.InviteFlowResource(http, `${INVITES_PATH}/patient`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.InvitesResource = InvitesResource;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OvokI18nDocument, OvokI18nValue } from "../../../client/platform/types";
|
|
2
|
+
import { HttpClient } from "../../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../../http/transmit";
|
|
4
|
+
export declare class I18nextResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
retrieve(language: string, options?: RequestOptions): Promise<OvokI18nDocument>;
|
|
8
|
+
/** The server queues the write (202), so a read right after may not show it yet. */
|
|
9
|
+
update(language: string, document: Record<string, OvokI18nValue>, options?: RequestOptions): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.I18nextResource = void 0;
|
|
4
|
+
const url_1 = require("../../http/url");
|
|
5
|
+
const i18nextPath = (language) => `localization/i18next/${(0, url_1.pathSegment)(language)}`;
|
|
6
|
+
class I18nextResource {
|
|
7
|
+
constructor(http) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
}
|
|
10
|
+
retrieve(language, options) {
|
|
11
|
+
return this.http.get(i18nextPath(language), options);
|
|
12
|
+
}
|
|
13
|
+
/** The server queues the write (202), so a read right after may not show it yet. */
|
|
14
|
+
update(language, document, options) {
|
|
15
|
+
return this.http.patch(i18nextPath(language), document, options);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.I18nextResource = I18nextResource;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OvokLocales } from "../../../client/platform/types";
|
|
2
|
+
import { HttpClient } from "../../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../../http/transmit";
|
|
4
|
+
export declare class LocalesResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
retrieve(options?: RequestOptions): Promise<OvokLocales>;
|
|
8
|
+
update(locales: OvokLocales, options?: RequestOptions): Promise<OvokLocales>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalesResource = void 0;
|
|
4
|
+
const LOCALES_PATH = "locales";
|
|
5
|
+
class LocalesResource {
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
retrieve(options) {
|
|
10
|
+
return this.http.get(LOCALES_PATH, options);
|
|
11
|
+
}
|
|
12
|
+
update(locales, options) {
|
|
13
|
+
return this.http.patch(LOCALES_PATH, locales, options);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.LocalesResource = LocalesResource;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OvokLocalization, OvokLocalizationQuery, OvokLocalizationUpdate } from "../../../client/platform/types";
|
|
2
|
+
import { HttpClient } from "../../http/http-client";
|
|
3
|
+
import { RequestOptions } from "../../http/transmit";
|
|
4
|
+
import { I18nextResource } from "./i18next-resource";
|
|
5
|
+
export type LocalizationList = {
|
|
6
|
+
total: number;
|
|
7
|
+
resources: OvokLocalization[];
|
|
8
|
+
};
|
|
9
|
+
export declare class LocalizationsResource {
|
|
10
|
+
private readonly http;
|
|
11
|
+
readonly i18next: I18nextResource;
|
|
12
|
+
constructor(http: HttpClient);
|
|
13
|
+
list(language: string, query?: OvokLocalizationQuery, options?: RequestOptions): Promise<LocalizationList>;
|
|
14
|
+
retrieve(language: string, key: string, options?: RequestOptions): Promise<OvokLocalization>;
|
|
15
|
+
update(language: string, key: string, body: OvokLocalizationUpdate, options?: RequestOptions): Promise<OvokLocalization>;
|
|
16
|
+
delete(language: string, key: string, options?: RequestOptions): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalizationsResource = void 0;
|
|
4
|
+
const query_string_1 = require("../../../client/query-string");
|
|
5
|
+
const url_1 = require("../../http/url");
|
|
6
|
+
const i18next_resource_1 = require("./i18next-resource");
|
|
7
|
+
const languagePath = (language) => `localization/${(0, url_1.pathSegment)(language)}`;
|
|
8
|
+
const entryPath = (language, key) => `${languagePath(language)}/${(0, url_1.pathSegment)(key)}`;
|
|
9
|
+
class LocalizationsResource {
|
|
10
|
+
constructor(http) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
this.i18next = new i18next_resource_1.I18nextResource(http);
|
|
13
|
+
}
|
|
14
|
+
list(language, query = {}, options) {
|
|
15
|
+
return this.http.get(`${languagePath(language)}${(0, query_string_1.toQueryString)(query)}`, options);
|
|
16
|
+
}
|
|
17
|
+
retrieve(language, key, options) {
|
|
18
|
+
return this.http.get(entryPath(language, key), options);
|
|
19
|
+
}
|
|
20
|
+
update(language, key, body, options) {
|
|
21
|
+
return this.http.put(entryPath(language, key), body, options);
|
|
22
|
+
}
|
|
23
|
+
delete(language, key, options) {
|
|
24
|
+
return this.http.delete(entryPath(language, key), options);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.LocalizationsResource = LocalizationsResource;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { GetLatestObservationsByCodeParams } from "../../../client/observation/types/GetLatestObservationsByCodeParams";
|
|
2
|
+
import type { Bundle, Observation } from "@medplum/fhirtypes";
|
|
3
|
+
import { observationCodesForTypes } from "../../../client/observation/methods/observationsToMeasurements";
|
|
4
|
+
import { HttpClient } from "../../http/http-client";
|
|
5
|
+
import { RequestOptions } from "../../http/transmit";
|
|
6
|
+
import { FhirResource } from "../fhir-resource";
|
|
7
|
+
import { BuildObservationsParams } from "./observation-builder";
|
|
8
|
+
import { SessionSource } from "./signed-in-account";
|
|
9
|
+
export type SaveObservationsOptions = RequestOptions & {
|
|
10
|
+
/** Identifier systems that name a reading for good; the SDK's device-reading id always counts. */
|
|
11
|
+
identifierSystems?: readonly string[];
|
|
12
|
+
/** Write over the observation saved under the same reading identifiers, for a value that changes. */
|
|
13
|
+
replace?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type SaveObservationsResult = {
|
|
16
|
+
status: "saved";
|
|
17
|
+
response: Bundle;
|
|
18
|
+
};
|
|
19
|
+
export type LatestObservationsParams = GetLatestObservationsByCodeParams;
|
|
20
|
+
export type LastObservationsQuery = {
|
|
21
|
+
code: string;
|
|
22
|
+
max?: number;
|
|
23
|
+
};
|
|
24
|
+
export type MeasurementCodeTypes = Parameters<typeof observationCodesForTypes>[0];
|
|
25
|
+
export declare class MeasurementsResource {
|
|
26
|
+
private readonly http;
|
|
27
|
+
private readonly fhir;
|
|
28
|
+
private readonly account;
|
|
29
|
+
constructor(http: HttpClient, fhir: FhirResource, session: SessionSource | null);
|
|
30
|
+
save(params: BuildObservationsParams, options?: SaveObservationsOptions): Promise<SaveObservationsResult>;
|
|
31
|
+
/** One reading, main observation first, created conditionally so a retry cannot duplicate it. */
|
|
32
|
+
saveObservations(observations: Observation[], options?: SaveObservationsOptions): Promise<SaveObservationsResult>;
|
|
33
|
+
build(params: BuildObservationsParams): Promise<Observation[]>;
|
|
34
|
+
latest(params: LatestObservationsParams, options?: RequestOptions): Promise<Bundle<Observation>>;
|
|
35
|
+
lastForPatient(patientId: string, query: LastObservationsQuery, options?: RequestOptions): Promise<Bundle<Observation>>;
|
|
36
|
+
/** The comma-joined codes the types are saved under, as `latest` and FHIR `code` searches take them. */
|
|
37
|
+
codesFor(types: MeasurementCodeTypes): string;
|
|
38
|
+
private latestPatientId;
|
|
39
|
+
/** A reading split over several requests stops once another account signs in, so none of it lands elsewhere. */
|
|
40
|
+
private send;
|
|
41
|
+
private requireOwner;
|
|
42
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeasurementsResource = void 0;
|
|
4
|
+
const observationsToMeasurements_1 = require("../../../client/observation/methods/observationsToMeasurements");
|
|
5
|
+
const observation_bundle_utils_1 = require("../../../client/observation/observation-bundle-utils");
|
|
6
|
+
const offline_measurement_queue_1 = require("../../../client/offline/offline-measurement-queue");
|
|
7
|
+
const query_string_1 = require("../../../client/query-string");
|
|
8
|
+
const ovok_errors_1 = require("../../errors/ovok-errors");
|
|
9
|
+
const url_1 = require("../../http/url");
|
|
10
|
+
const observation_builder_1 = require("./observation-builder");
|
|
11
|
+
const save_error_1 = require("./save-error");
|
|
12
|
+
const signed_in_account_1 = require("./signed-in-account");
|
|
13
|
+
const LATEST_OBSERVATIONS_PATH = "fhir/Observation/$lastn";
|
|
14
|
+
const LATEST_PER_CODE = 1;
|
|
15
|
+
class MeasurementsResource {
|
|
16
|
+
constructor(http, fhir, session) {
|
|
17
|
+
this.http = http;
|
|
18
|
+
this.fhir = fhir;
|
|
19
|
+
this.account = new signed_in_account_1.SignedInAccount(session);
|
|
20
|
+
}
|
|
21
|
+
async save(params, options) {
|
|
22
|
+
return this.saveObservations(await this.build(params), options);
|
|
23
|
+
}
|
|
24
|
+
/** One reading, main observation first, created conditionally so a retry cannot duplicate it. */
|
|
25
|
+
async saveObservations(observations, options = {}) {
|
|
26
|
+
const { identifierSystems, replace, ...requestOptions } = options;
|
|
27
|
+
const entry = (0, observation_bundle_utils_1.linkObservationMembers)(observations).map((observation) => (0, offline_measurement_queue_1.entryForObservation)(observation, { identifierSystems, replace }));
|
|
28
|
+
const response = await this.send({ resourceType: "Bundle", type: "transaction", entry }, requestOptions);
|
|
29
|
+
return { status: "saved", response };
|
|
30
|
+
}
|
|
31
|
+
async build(params) {
|
|
32
|
+
const subject = params.patientId ? `Patient/${params.patientId}` : await this.account.profileReference();
|
|
33
|
+
return (0, observation_builder_1.buildObservations)(params, subject);
|
|
34
|
+
}
|
|
35
|
+
async latest(params, options) {
|
|
36
|
+
const query = (0, query_string_1.toQueryString)({
|
|
37
|
+
max: LATEST_PER_CODE,
|
|
38
|
+
code: params.codes,
|
|
39
|
+
patient: `Patient/${await this.latestPatientId(params)}`,
|
|
40
|
+
date: params.date ? `ge${params.date}` : undefined,
|
|
41
|
+
});
|
|
42
|
+
return this.http.get(`${LATEST_OBSERVATIONS_PATH}${query}`, options);
|
|
43
|
+
}
|
|
44
|
+
lastForPatient(patientId, query, options) {
|
|
45
|
+
return this.http.get(`patient/${(0, url_1.pathSegment)(patientId)}/observation${(0, query_string_1.toQueryString)(query)}`, options);
|
|
46
|
+
}
|
|
47
|
+
/** The comma-joined codes the types are saved under, as `latest` and FHIR `code` searches take them. */
|
|
48
|
+
codesFor(types) {
|
|
49
|
+
return (0, observationsToMeasurements_1.observationCodesForTypes)(types);
|
|
50
|
+
}
|
|
51
|
+
async latestPatientId(params) {
|
|
52
|
+
if (params.me) {
|
|
53
|
+
return idOf(await this.account.profileReference());
|
|
54
|
+
}
|
|
55
|
+
return params.patientId;
|
|
56
|
+
}
|
|
57
|
+
/** A reading split over several requests stops once another account signs in, so none of it lands elsewhere. */
|
|
58
|
+
async send(bundle, options) {
|
|
59
|
+
const owner = await this.account.key();
|
|
60
|
+
try {
|
|
61
|
+
return await (0, observation_bundle_utils_1.executeObservationBundle)(bundle, async (request) => {
|
|
62
|
+
await this.requireOwner(owner);
|
|
63
|
+
return this.fhir.batch(request, options);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw (0, save_error_1.isBundle)(error) ? (0, save_error_1.saveErrorFrom)(error) : error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async requireOwner(owner) {
|
|
71
|
+
if (owner !== (await this.account.key())) {
|
|
72
|
+
throw new ovok_errors_1.OvokConflictError((0, ovok_errors_1.detailsFor)("The signed-in account changed during the save; the rest was not sent."));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.MeasurementsResource = MeasurementsResource;
|
|
77
|
+
const idOf = (reference) => reference.slice(reference.indexOf("/") + 1);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GenerateObservationBodyParams } from "../../../client/observation/types/generate-observation-body/GenerateObservationBodyParams";
|
|
2
|
+
import type { Observation } from "@medplum/fhirtypes";
|
|
3
|
+
export type BuildObservationsParams = GenerateObservationBodyParams;
|
|
4
|
+
/** One measurement's Observations about `subject`, a reference such as `Patient/1`. */
|
|
5
|
+
export declare function buildObservations(params: BuildObservationsParams, subject: string): Observation[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildObservations = buildObservations;
|
|
4
|
+
const fhir_systems_1 = require("../../../client/observation/fhir-systems");
|
|
5
|
+
const creator_1 = require("../../../client/observation/services/creator");
|
|
6
|
+
const getDeviceObject_1 = require("../../../client/observation/utils/getDeviceObject");
|
|
7
|
+
/** One measurement's Observations about `subject`, a reference such as `Patient/1`. */
|
|
8
|
+
function buildObservations(params, subject) {
|
|
9
|
+
const service = creator_1.ObservationServiceCreator.getInstance().getService(params.measurement.measurementTypeKey);
|
|
10
|
+
const device = (0, getDeviceObject_1.getDeviceObject)(params.device);
|
|
11
|
+
const observations = fragmentsOf(service, params.measurement)
|
|
12
|
+
.map((fragment) => observationOf(fragment, subject, device))
|
|
13
|
+
.filter(hasValue)
|
|
14
|
+
.map((observation) => datedAt(observation, params.effectiveDateTime));
|
|
15
|
+
return params.sourceId ? namedAfterSource(observations, subject, params.sourceId) : observations;
|
|
16
|
+
}
|
|
17
|
+
/** Services without fragments describe their observations as parallel code, value and property lists. */
|
|
18
|
+
const fragmentsOf = (service, measurement) => { var _a, _b; return (_b = (_a = service.generateObservationFragments) === null || _a === void 0 ? void 0 : _a.call(service, measurement)) !== null && _b !== void 0 ? _b : codeValueFragments(service, measurement); };
|
|
19
|
+
const codeValueFragments = (service, measurement) => {
|
|
20
|
+
const values = service.generateValues(measurement);
|
|
21
|
+
const additionalProperties = service.getAdditionalProperties(measurement);
|
|
22
|
+
return service.getObservationCodes().map((code, index) => ({
|
|
23
|
+
code,
|
|
24
|
+
value: values[index],
|
|
25
|
+
additionalProperties: additionalProperties[index],
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
const observationOf = (fragment, subject, device) => ({
|
|
29
|
+
resourceType: "Observation",
|
|
30
|
+
status: "registered",
|
|
31
|
+
subject: { reference: subject },
|
|
32
|
+
device,
|
|
33
|
+
...fragment.value,
|
|
34
|
+
code: fragment.code,
|
|
35
|
+
...fragment.additionalProperties,
|
|
36
|
+
});
|
|
37
|
+
const hasValue = (observation) => {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f;
|
|
39
|
+
return ((_a = observation.valueQuantity) === null || _a === void 0 ? void 0 : _a.value) !== undefined ||
|
|
40
|
+
Boolean((_b = observation.valueSampledData) === null || _b === void 0 ? void 0 : _b.data) ||
|
|
41
|
+
Boolean((_e = (_d = (_c = observation.valueCodeableConcept) === null || _c === void 0 ? void 0 : _c.coding) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.code) ||
|
|
42
|
+
Boolean((_f = observation.component) === null || _f === void 0 ? void 0 : _f.length);
|
|
43
|
+
};
|
|
44
|
+
/** A period the service set wins over the measurement's time. */
|
|
45
|
+
const datedAt = (observation, effectiveDateTime) => effectiveDateTime && !observation.effectivePeriod
|
|
46
|
+
? { ...observation, effectiveDateTime: effectiveDateTime.toISOString() }
|
|
47
|
+
: observation;
|
|
48
|
+
const namedAfterSource = (observations, subject, sourceId) => observations.map((observation, index) => {
|
|
49
|
+
var _a;
|
|
50
|
+
return ({
|
|
51
|
+
...observation,
|
|
52
|
+
identifier: [
|
|
53
|
+
...((_a = observation.identifier) !== null && _a !== void 0 ? _a : []),
|
|
54
|
+
{ system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM, value: `${subject}/${sourceId}/${index}` },
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Bundle } from "@medplum/fhirtypes";
|
|
2
|
+
import { OvokError } from "../../errors/ovok-errors";
|
|
3
|
+
export declare const isBundle: (value: unknown) => value is Bundle;
|
|
4
|
+
/** A save's response that refused or left out an observation; a refused one gives its own status. */
|
|
5
|
+
export declare function saveErrorFrom(response: Bundle): OvokError;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isBundle = void 0;
|
|
4
|
+
exports.saveErrorFrom = saveErrorFrom;
|
|
5
|
+
const ovok_errors_1 = require("../../errors/ovok-errors");
|
|
6
|
+
const FAILED_STATUS = /^[45]/;
|
|
7
|
+
const isBundle = (value) => typeof value === "object" && value !== null && value.resourceType === "Bundle";
|
|
8
|
+
exports.isBundle = isBundle;
|
|
9
|
+
/** A save's response that refused or left out an observation; a refused one gives its own status. */
|
|
10
|
+
function saveErrorFrom(response) {
|
|
11
|
+
var _a;
|
|
12
|
+
const statuses = ((_a = response.entry) !== null && _a !== void 0 ? _a : []).map((entry) => { var _a, _b; return (_b = (_a = entry.response) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : ""; });
|
|
13
|
+
const refused = statuses.find((status) => FAILED_STATUS.test(status));
|
|
14
|
+
const message = refused
|
|
15
|
+
? `The server refused an observation of the reading: ${refused}.`
|
|
16
|
+
: "The server's response left out an observation of the reading.";
|
|
17
|
+
return (0, ovok_errors_1.errorForStatus)({ ...(0, ovok_errors_1.detailsFor)(message), status: refused ? Number.parseInt(refused, 10) : null });
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UserSession } from "../../auth/user-session";
|
|
2
|
+
export type SessionSource = Pick<UserSession, "current">;
|
|
3
|
+
/** The account a measurement belongs to; a machine client has none. */
|
|
4
|
+
export declare class SignedInAccount {
|
|
5
|
+
private readonly session;
|
|
6
|
+
constructor(session: SessionSource | null);
|
|
7
|
+
/** The project and profile signed in now, or null when no one is. */
|
|
8
|
+
key(): Promise<string | null>;
|
|
9
|
+
profileReference(): Promise<string>;
|
|
10
|
+
private current;
|
|
11
|
+
}
|