@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.
Files changed (99) hide show
  1. package/dist/client/auth/account-storage.d.ts +1 -0
  2. package/dist/client/auth/account-storage.js +2 -1
  3. package/dist/{utils → client}/auth/exchange-code.d.ts +1 -1
  4. package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.js +5 -17
  5. package/dist/{utils → client}/auth/handle-tenant-code.d.ts +1 -1
  6. package/dist/{utils → client}/auth/handle-tenant-code.js +1 -1
  7. package/dist/client/auth/methods/appleLogin.js +2 -6
  8. package/dist/client/auth/methods/changePassword.js +2 -1
  9. package/dist/client/auth/methods/getSessions.js +2 -1
  10. package/dist/client/auth/methods/googleLogin.js +2 -6
  11. package/dist/client/auth/methods/login.js +26 -44
  12. package/dist/client/auth/methods/logout.js +2 -1
  13. package/dist/client/auth/methods/requestDeleteUser.js +5 -4
  14. package/dist/client/auth/methods/revokeSessions.js +2 -1
  15. package/dist/client/auth/methods/socialLogin.d.ts +7 -0
  16. package/dist/client/auth/methods/socialLogin.js +11 -0
  17. package/dist/client/auth/session-fetch.js +5 -6
  18. package/dist/client/auth/session-http.js +8 -19
  19. package/dist/client/auth/sha256.d.ts +2 -0
  20. package/dist/client/auth/sha256.js +65 -0
  21. package/dist/{utils → client}/auth/start-login.d.ts +2 -2
  22. package/dist/client/change-history/methods.js +2 -1
  23. package/dist/client/cms/methods.js +16 -28
  24. package/dist/client/consent/methods.js +3 -2
  25. package/dist/client/email/methods.js +2 -1
  26. package/dist/client/errors/ovok-error-utils.d.ts +6 -0
  27. package/dist/client/errors/ovok-error-utils.js +10 -1
  28. package/dist/client/errors/ovok-error.js +6 -13
  29. package/dist/client/errors/rate-limit-error.js +2 -6
  30. package/dist/client/experience/methods.js +13 -12
  31. package/dist/client/invites/methods.js +8 -12
  32. package/dist/client/notifications/methods.js +4 -3
  33. package/dist/client/observation/fhir-systems.d.ts +4 -0
  34. package/dist/client/observation/fhir-systems.js +7 -0
  35. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +23 -29
  36. package/dist/client/observation/methods/getLatestObservationsByCodes.js +6 -9
  37. package/dist/client/observation/methods/observationsToMeasurements.js +44 -91
  38. package/dist/client/observation/services/base-observation-service.js +4 -3
  39. package/dist/client/observation/services/blood-pressure.js +1 -4
  40. package/dist/client/observation/services/{baby-sleep.d.ts → component-observation-services.d.ts} +18 -13
  41. package/dist/client/observation/services/component-observation-services.js +69 -0
  42. package/dist/client/observation/services/creator.d.ts +1 -2
  43. package/dist/client/observation/services/creator.js +14 -18
  44. package/dist/client/observation/services/ecg-observation-fragments.js +5 -6
  45. package/dist/client/observation/services/ecg.js +3 -2
  46. package/dist/client/observation/services/lipid-panel.js +8 -12
  47. package/dist/client/observation/services/measurement-time.d.ts +4 -0
  48. package/dist/client/observation/services/measurement-time.js +6 -0
  49. package/dist/client/observation/services/single-value-services.d.ts +5 -0
  50. package/dist/client/observation/services/single-value-services.js +6 -1
  51. package/dist/client/observation/services/uric-acid-service.js +6 -7
  52. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +2 -458
  53. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +0 -6
  54. package/dist/client/offline/offline-measurement-queue.js +31 -28
  55. package/dist/client/ovok-client.d.ts +5 -2
  56. package/dist/client/ovok-client.js +46 -42
  57. package/dist/client/patient/methods.js +25 -25
  58. package/dist/client/patient-sharing/methods.js +4 -3
  59. package/dist/client/platform/methods.js +17 -16
  60. package/dist/client/platform/types.d.ts +3 -6
  61. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -1
  62. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +2 -1
  63. package/dist/client/request-options.d.ts +2 -0
  64. package/dist/client/request-options.js +6 -0
  65. package/dist/client/signals/errors.js +2 -6
  66. package/dist/client/signals/methods.js +14 -13
  67. package/dist/client/slim/live-read.d.ts +4 -0
  68. package/dist/client/slim/live-read.js +87 -0
  69. package/dist/client/slim/methods.d.ts +3 -0
  70. package/dist/client/slim/methods.js +63 -146
  71. package/dist/client/storage.js +3 -2
  72. package/dist/conformance/capability-requirements.js +1 -1
  73. package/dist/conformance/capability.js +8 -7
  74. package/dist/hooks/account-hooks.js +1 -1
  75. package/dist/hooks/api-hooks.d.ts +5 -6
  76. package/dist/hooks/api-hooks.js +10 -24
  77. package/dist/hooks/cms-hooks.js +8 -13
  78. package/dist/hooks/experience-hooks.js +1 -1
  79. package/dist/hooks/index.d.ts +2 -2
  80. package/dist/hooks/index.js +4 -4
  81. package/dist/hooks/invites-hooks.js +0 -1
  82. package/dist/hooks/notification-hooks.d.ts +4 -1
  83. package/dist/hooks/notification-hooks.js +28 -35
  84. package/dist/hooks/notification-invalidation.d.ts +1 -1
  85. package/dist/hooks/notification-note-hooks.js +13 -28
  86. package/dist/hooks/observation-hooks.js +2 -4
  87. package/dist/hooks/patient-hooks.js +1 -1
  88. package/dist/hooks/patient-sharing-hooks.js +1 -2
  89. package/dist/hooks/poll-hooks.js +10 -8
  90. package/dist/hooks/signals-alert-hooks.js +4 -6
  91. package/package.json +1 -1
  92. package/dist/client/observation/services/baby-sleep.js +0 -69
  93. package/dist/client/observation/services/respiratory-therapy.d.ts +0 -28
  94. package/dist/client/observation/services/respiratory-therapy.js +0 -69
  95. package/dist/utils/auth/sha256.d.ts +0 -8
  96. package/dist/utils/auth/sha256.js +0 -300
  97. /package/dist/{utils → client}/auth/exchange-code.js +0 -0
  98. /package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.d.ts +0 -0
  99. /package/dist/{utils → client}/auth/start-login.js +0 -0
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optionalArg = void 0;
4
+ /** Forwards an optional trailing argument only when the caller gave one, so call arity stays the same. */
5
+ const optionalArg = (value) => (value === undefined ? [] : [value]);
6
+ exports.optionalArg = optionalArg;
@@ -4,6 +4,7 @@ exports.SignalsError = void 0;
4
4
  exports.isSignalsError = isSignalsError;
5
5
  exports.mapSignalsError = mapSignalsError;
6
6
  const ovok_error_1 = require("../errors/ovok-error");
7
+ const ovok_error_utils_1 = require("../errors/ovok-error-utils");
7
8
  const SIGNALS_ERROR_STATUSES = {
8
9
  signals_threshold_not_editable: 409,
9
10
  signals_patient_not_enrolled: 409,
@@ -33,12 +34,7 @@ class SignalsError extends Error {
33
34
  this.status = status;
34
35
  this.fieldErrors = (_a = options.fieldErrors) !== null && _a !== void 0 ? _a : [];
35
36
  if (options.cause !== undefined) {
36
- Object.defineProperty(this, "cause", {
37
- configurable: true,
38
- enumerable: false,
39
- value: options.cause,
40
- writable: false,
41
- });
37
+ (0, ovok_error_utils_1.withCause)(this, options.cause);
42
38
  }
43
39
  }
44
40
  }
@@ -22,6 +22,7 @@ exports.getSignalsRawAlert = getSignalsRawAlert;
22
22
  exports.acknowledgeSignalsRawAlert = acknowledgeSignalsRawAlert;
23
23
  exports.getSignalsSettings = getSignalsSettings;
24
24
  exports.updateSignalsSettings = updateSignalsSettings;
25
+ const request_options_1 = require("../request-options");
25
26
  /**
26
27
  * Enables Signals for an existing patient. The operation is idempotent; retry after 409 or 503.
27
28
  * Observations saved through Ovok are forwarded by the backend, so callers should not submit
@@ -31,10 +32,10 @@ function enableSignalsForPatient(patientId, requestOptions) {
31
32
  return this.post(`/fhir/Patient/${encodeURIComponent(patientId)}/$enable-signals`, undefined, undefined, requestOptions);
32
33
  }
33
34
  function getSignalsThresholds(patientId, requestOptions) {
34
- return this.get(`/v1/signals/patients/${encodeURIComponent(patientId)}/thresholds`, ...(requestOptions === undefined ? [] : [requestOptions]));
35
+ return this.get(`/v1/signals/patients/${encodeURIComponent(patientId)}/thresholds`, ...(0, request_options_1.optionalArg)(requestOptions));
35
36
  }
36
37
  function listUnconfirmedLimits(requestOptions) {
37
- return this.get("/signals/config/unconfirmed", ...(requestOptions === undefined ? [] : [requestOptions]));
38
+ return this.get("/signals/config/unconfirmed", ...(0, request_options_1.optionalArg)(requestOptions));
38
39
  }
39
40
  function repushUnconfirmedLimits(requestOptions) {
40
41
  return this.post("/signals/config/unconfirmed/repush", undefined, undefined, requestOptions);
@@ -43,7 +44,7 @@ function setSignalsThreshold(patientId, code, body, requestOptions) {
43
44
  return this.put(`/v1/signals/patients/${encodeURIComponent(patientId)}/thresholds/${encodeURIComponent(code)}`, body, undefined, requestOptions);
44
45
  }
45
46
  function removeSignalsThreshold(patientId, code, reason, requestOptions) {
46
- return this.delete(`/v1/signals/patients/${encodeURIComponent(patientId)}/thresholds/${encodeURIComponent(code)}?reason=${encodeURIComponent(reason)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
47
+ return this.delete(`/v1/signals/patients/${encodeURIComponent(patientId)}/thresholds/${encodeURIComponent(code)}?reason=${encodeURIComponent(reason)}`, ...(0, request_options_1.optionalArg)(requestOptions));
47
48
  }
48
49
  // Each route's own filters, in the order they are sent: a key outside the list is never sent, so
49
50
  // a wider object passed as an episode query can't turn into a refused request.
@@ -71,22 +72,22 @@ function serializeSignalsAlertsQuery(query = {}, keys = EPISODE_QUERY_KEYS) {
71
72
  }
72
73
  function listSignalsAlerts(query = {}, requestOptions) {
73
74
  const serialized = serializeSignalsAlertsQuery(query);
74
- return this.get(`/v1/signals/alerts${serialized ? `?${serialized}` : ""}`, { ...{ cache: "reload" }, ...requestOptions });
75
+ return this.get(`/v1/signals/alerts${serialized ? `?${serialized}` : ""}`, { cache: "reload", ...requestOptions });
75
76
  }
76
77
  function getSignalsAlert(episodeId, requestOptions) {
77
- return this.get(`/v1/signals/alerts/${encodeURIComponent(episodeId)}`, { ...{ cache: "reload" }, ...requestOptions });
78
+ return this.get(`/v1/signals/alerts/${encodeURIComponent(episodeId)}`, { cache: "reload", ...requestOptions });
78
79
  }
79
80
  function acknowledgeSignalsAlert(episodeId, requestOptions) {
80
81
  return this.post(`/v1/signals/alerts/${encodeURIComponent(episodeId)}/ack`, undefined, undefined, requestOptions);
81
82
  }
82
83
  function listSignalsAlertNotes(episodeId, requestOptions) {
83
- return this.get(`/v1/signals/alerts/${encodeURIComponent(episodeId)}/notes`, { ...{ cache: "reload" }, ...requestOptions });
84
+ return this.get(`/v1/signals/alerts/${encodeURIComponent(episodeId)}/notes`, { cache: "reload", ...requestOptions });
84
85
  }
85
86
  function createSignalsAlertNote(episodeId, body, requestOptions) {
86
87
  return this.post(`/v1/signals/alerts/${encodeURIComponent(episodeId)}/notes`, body, undefined, requestOptions);
87
88
  }
88
89
  function listSignalsRawAlertNotes(alertId, requestOptions) {
89
- return this.get(`/v1/signals/raw-alerts/${encodeURIComponent(alertId)}/notes`, { ...{ cache: "reload" }, ...requestOptions });
90
+ return this.get(`/v1/signals/raw-alerts/${encodeURIComponent(alertId)}/notes`, { cache: "reload", ...requestOptions });
90
91
  }
91
92
  function createSignalsRawAlertNote(alertId, body, requestOptions) {
92
93
  return this.post(`/v1/signals/raw-alerts/${encodeURIComponent(alertId)}/notes`, body, undefined, requestOptions);
@@ -95,10 +96,10 @@ function updateSignalsNote(noteId, body, requestOptions) {
95
96
  return this.put(`/v1/signals/notes/${encodeURIComponent(noteId)}`, body, undefined, requestOptions);
96
97
  }
97
98
  function patchSignalsNote(noteId, body, requestOptions) {
98
- return this.patch(`/v1/signals/notes/${encodeURIComponent(noteId)}`, body, ...(requestOptions === undefined ? [] : [requestOptions]));
99
+ return this.patch(`/v1/signals/notes/${encodeURIComponent(noteId)}`, body, ...(0, request_options_1.optionalArg)(requestOptions));
99
100
  }
100
101
  async function deleteSignalsNote(noteId, requestOptions) {
101
- await this.delete(`/v1/signals/notes/${encodeURIComponent(noteId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
102
+ await this.delete(`/v1/signals/notes/${encodeURIComponent(noteId)}`, ...(0, request_options_1.optionalArg)(requestOptions));
102
103
  }
103
104
  /**
104
105
  * The project's individual Signals alerts, not episodes: works whether or not the project's
@@ -106,10 +107,10 @@ async function deleteSignalsNote(noteId, requestOptions) {
106
107
  */
107
108
  function listSignalsRawAlerts(query = {}, requestOptions) {
108
109
  const serialized = serializeSignalsAlertsQuery(query, RAW_ALERT_QUERY_KEYS);
109
- return this.get(`/v1/signals/raw-alerts${serialized ? `?${serialized}` : ""}`, { ...{ cache: "reload" }, ...requestOptions });
110
+ return this.get(`/v1/signals/raw-alerts${serialized ? `?${serialized}` : ""}`, { cache: "reload", ...requestOptions });
110
111
  }
111
112
  function getSignalsRawAlert(alertId, requestOptions) {
112
- return this.get(`/v1/signals/raw-alerts/${encodeURIComponent(alertId)}`, { ...{ cache: "reload" }, ...requestOptions });
113
+ return this.get(`/v1/signals/raw-alerts/${encodeURIComponent(alertId)}`, { cache: "reload", ...requestOptions });
113
114
  }
114
115
  /**
115
116
  * Acknowledges one alert: it resolves, and `acknowledgedAt` and `acknowledgedActor` record when
@@ -120,11 +121,11 @@ function acknowledgeSignalsRawAlert(alertId, requestOptions) {
120
121
  return this.post(`/v1/signals/raw-alerts/${encodeURIComponent(alertId)}/ack`, undefined, undefined, requestOptions);
121
122
  }
122
123
  function getSignalsSettings(requestOptions) {
123
- return this.get("/v1/signals/settings", ...(requestOptions === undefined ? [] : [requestOptions]));
124
+ return this.get("/v1/signals/settings", ...(0, request_options_1.optionalArg)(requestOptions));
124
125
  }
125
126
  function updateSignalsSettings(patch, reason, requestOptions) {
126
127
  return this.patch("/v1/signals/settings", {
127
128
  ...patch,
128
129
  ...(reason !== undefined ? { reason } : {}),
129
- }, ...(requestOptions === undefined ? [] : [requestOptions]));
130
+ }, ...(0, request_options_1.optionalArg)(requestOptions));
130
131
  }
@@ -0,0 +1,4 @@
1
+ import type { MedplumRequestOptions } from "@medplum/core";
2
+ import { OvokClient } from "../ovok-client";
3
+ /** A `cache: "reload"` GET that shares one in-flight request between identical live reads. */
4
+ export declare const liveGet: <T>(client: OvokClient, path: string, requestOptions?: MedplumRequestOptions) => Promise<T>;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.liveGet = void 0;
4
+ const ovok_error_utils_1 = require("../errors/ovok-error-utils");
5
+ const inFlightLiveReads = new Map();
6
+ const dedupeLiveRead = (client, path, load, options) => {
7
+ var _a, _b, _c, _d, _e, _f, _g;
8
+ const signal = (_a = options === null || options === void 0 ? void 0 : options.signal) !== null && _a !== void 0 ? _a : undefined;
9
+ const canShare = Object.keys(options !== null && options !== void 0 ? options : {}).every((key) => key === "signal" || key === "cache");
10
+ if (!canShare) {
11
+ return load(signal);
12
+ }
13
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
14
+ return Promise.reject((_b = signal.reason) !== null && _b !== void 0 ? _b : abortError());
15
+ }
16
+ const login = client.getActiveLogin();
17
+ const key = [
18
+ client.getBaseUrl(),
19
+ (_d = (_c = login === null || login === void 0 ? void 0 : login.profile) === null || _c === void 0 ? void 0 : _c.reference) !== null && _d !== void 0 ? _d : "",
20
+ (_f = (_e = login === null || login === void 0 ? void 0 : login.project) === null || _e === void 0 ? void 0 : _e.reference) !== null && _f !== void 0 ? _f : "",
21
+ (_g = options === null || options === void 0 ? void 0 : options.cache) !== null && _g !== void 0 ? _g : "reload",
22
+ path,
23
+ ].join("\0");
24
+ let inFlight = inFlightLiveReads.get(key);
25
+ if (!inFlight) {
26
+ const controller = new AbortController();
27
+ const sharedRead = {
28
+ controller,
29
+ promise: Promise.resolve(),
30
+ subscribers: 0,
31
+ settled: false,
32
+ };
33
+ let request;
34
+ try {
35
+ request = load(signal ? controller.signal : undefined);
36
+ }
37
+ catch (error) {
38
+ request = Promise.reject(error);
39
+ }
40
+ sharedRead.promise = request.finally(() => {
41
+ if (inFlightLiveReads.get(key) === sharedRead) {
42
+ inFlightLiveReads.delete(key);
43
+ }
44
+ sharedRead.settled = true;
45
+ });
46
+ inFlight = sharedRead;
47
+ inFlightLiveReads.set(key, sharedRead);
48
+ void sharedRead.promise.catch(() => undefined);
49
+ }
50
+ const shared = inFlight;
51
+ return new Promise((resolve, reject) => {
52
+ let active = true;
53
+ shared.subscribers += 1;
54
+ const release = () => {
55
+ if (!active) {
56
+ return false;
57
+ }
58
+ active = false;
59
+ signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", onAbort);
60
+ shared.subscribers -= 1;
61
+ if (!shared.settled && shared.subscribers === 0) {
62
+ shared.controller.abort();
63
+ }
64
+ return true;
65
+ };
66
+ const onAbort = () => {
67
+ var _a;
68
+ if (release()) {
69
+ reject((_a = signal === null || signal === void 0 ? void 0 : signal.reason) !== null && _a !== void 0 ? _a : abortError());
70
+ }
71
+ };
72
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
73
+ shared.promise.then((value) => {
74
+ if (release()) {
75
+ resolve(value);
76
+ }
77
+ }, (error) => {
78
+ if (release()) {
79
+ reject(error);
80
+ }
81
+ });
82
+ });
83
+ };
84
+ const abortError = () => (0, ovok_error_utils_1.namedError)("AbortError", "The request was aborted.");
85
+ /** A `cache: "reload"` GET that shares one in-flight request between identical live reads. */
86
+ const liveGet = (client, path, requestOptions) => dedupeLiveRead(client, path, (signal) => client.get(path, { cache: "reload", ...requestOptions, ...(signal ? { signal } : {}) }), requestOptions);
87
+ exports.liveGet = liveGet;
@@ -30,14 +30,17 @@ export declare function getRecentSlimNotifications(this: OvokClient, count?: num
30
30
  export declare function listSlimAlarms(this: OvokClient, params?: SlimAlarmQuery, requestOptions?: MedplumRequestOptions): Promise<SlimAlarmsPage>;
31
31
  export declare function acknowledgeSlimAlarm(this: OvokClient, notificationId: string, requestOptions?: MedplumRequestOptions): Promise<SlimNotification>;
32
32
  export declare function getRecentSlimAlarms(this: OvokClient, count?: number, requestOptions?: MedplumRequestOptions): Promise<SlimRecentAlarms>;
33
+ /** Same as `getRecentSlimAlarms`. */
33
34
  export declare function getRecentAlarms(this: OvokClient, count?: number, requestOptions?: MedplumRequestOptions): Promise<SlimRecentAlarms>;
34
35
  export declare function getRecentSlimOutOfBed(this: OvokClient, count?: number, requestOptions?: MedplumRequestOptions): Promise<SlimRecentOutOfBed>;
36
+ /** Same as `getRecentSlimOutOfBed`. */
35
37
  export declare function getRecentOutOfBed(this: OvokClient, count?: number, requestOptions?: MedplumRequestOptions): Promise<SlimRecentOutOfBed>;
36
38
  export declare function listSlimOutOfBedNotifications(this: OvokClient, params?: Omit<SlimNotificationsQuery, "type">, requestOptions?: MedplumRequestOptions): Promise<SlimNotificationsResponse>;
37
39
  export declare function listSlimMedicalNotifications(this: OvokClient, params?: SlimMedicalNotificationsQuery, requestOptions?: MedplumRequestOptions): Promise<SlimMedicalNotificationsPage>;
38
40
  export declare function getRecentSlimMedicalNotifications(this: OvokClient, count?: number, requestOptions?: MedplumRequestOptions): Promise<SlimRecentNotificationsResponse>;
39
41
  export declare function getSlimMedicalNotification(this: OvokClient, episodeId: string, requestOptions?: MedplumRequestOptions): Promise<SlimMedicalNotificationDetail>;
40
42
  export declare function acknowledgeSlimMedicalNotification(this: OvokClient, episodeId: string, requestOptions?: MedplumRequestOptions): Promise<SlimMedicalNotificationRow>;
43
+ /** Same as `acknowledgeSlimAlarm`. */
41
44
  export declare function acknowledgeSlimNotification(this: OvokClient, notificationId: string, requestOptions?: MedplumRequestOptions): Promise<SlimNotification>;
42
45
  export declare function getSlimThreshold(this: OvokClient, requestOptions?: MedplumRequestOptions): Promise<SlimThreshold>;
43
46
  export declare function updateSlimThreshold(this: OvokClient, body: {