@ovok/core 0.4.49-rc.1 → 0.4.49-rc.2

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 (278) hide show
  1. package/README.md +27 -79
  2. package/dist/client/observation/measurement-fields.d.ts +1 -1
  3. package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
  4. package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
  5. package/dist/client/observation/services/base-observation-service.d.ts +1 -1
  6. package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
  7. package/dist/client/observation/services/blood-oxygen.js +7 -7
  8. package/dist/client/observation/services/blood-pressure.d.ts +1 -1
  9. package/dist/client/observation/services/blood-pressure.js +16 -16
  10. package/dist/client/observation/services/component-observation-services.d.ts +1 -1
  11. package/dist/client/observation/services/component-observation-services.js +3 -3
  12. package/dist/client/observation/services/creator.d.ts +1 -1
  13. package/dist/client/observation/services/creator.js +10 -10
  14. package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
  15. package/dist/client/observation/services/ecg.d.ts +1 -1
  16. package/dist/client/observation/services/ecg.js +10 -10
  17. package/dist/client/observation/services/lipid-panel.d.ts +1 -1
  18. package/dist/client/observation/services/lipid-panel.js +13 -13
  19. package/dist/client/observation/services/single-value-services.d.ts +1 -1
  20. package/dist/client/observation/services/single-value-services.js +19 -19
  21. package/dist/client/observation/services/step-count.d.ts +1 -1
  22. package/dist/client/observation/services/step-count.js +5 -5
  23. package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
  24. package/dist/client/observation/services/uric-acid-service.js +7 -7
  25. package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
  26. package/dist/client/signals/methods.d.ts +2 -23
  27. package/dist/client/signals/methods.js +10 -93
  28. package/dist/client/signals/types.d.ts +6 -132
  29. package/dist/client/wearables/types.d.ts +5 -0
  30. package/dist/conformance/api-requirements.js +2 -9
  31. package/dist/conformance/capability-requirements.js +1 -1
  32. package/dist/hooks/index.d.ts +1 -1
  33. package/dist/hooks/index.js +1 -9
  34. package/dist/hooks/notification-invalidation.d.ts +0 -7
  35. package/dist/hooks/signals-hooks.d.ts +2 -23
  36. package/dist/hooks/signals-hooks.js +1 -15
  37. package/dist/next/auth/access-token.d.ts +9 -0
  38. package/dist/next/auth/access-token.js +18 -0
  39. package/dist/next/auth/client-credentials.d.ts +16 -0
  40. package/dist/next/auth/client-credentials.js +40 -0
  41. package/dist/next/auth/credentials.d.ts +5 -0
  42. package/dist/next/auth/credentials.js +7 -0
  43. package/dist/next/auth/saved-accounts-store.d.ts +26 -0
  44. package/dist/next/auth/saved-accounts-store.js +93 -0
  45. package/dist/next/auth/session-store.d.ts +12 -0
  46. package/dist/next/auth/session-store.js +33 -0
  47. package/dist/next/auth/session.d.ts +28 -0
  48. package/dist/next/auth/session.js +27 -0
  49. package/dist/next/auth/token-endpoint.d.ts +12 -0
  50. package/dist/next/auth/token-endpoint.js +28 -0
  51. package/dist/next/auth/user-session.d.ts +39 -0
  52. package/dist/next/auth/user-session.js +183 -0
  53. package/dist/next/config/ovok-config.d.ts +42 -0
  54. package/dist/next/config/ovok-config.js +2 -0
  55. package/dist/next/config/settings.d.ts +6 -0
  56. package/dist/next/config/settings.js +74 -0
  57. package/dist/next/errors/error-from-response.d.ts +2 -0
  58. package/dist/next/errors/error-from-response.js +35 -0
  59. package/dist/next/errors/ovok-account-error.d.ts +5 -0
  60. package/dist/next/errors/ovok-account-error.js +13 -0
  61. package/dist/next/errors/ovok-errors.d.ts +42 -0
  62. package/dist/next/errors/ovok-errors.js +74 -0
  63. package/dist/next/http/http-client.d.ts +36 -0
  64. package/dist/next/http/http-client.js +116 -0
  65. package/dist/next/http/retry-after.d.ts +1 -0
  66. package/dist/next/http/retry-after.js +16 -0
  67. package/dist/next/http/retry-policy.d.ts +13 -0
  68. package/dist/next/http/retry-policy.js +27 -0
  69. package/dist/next/http/transmit.d.ts +14 -0
  70. package/dist/next/http/transmit.js +57 -0
  71. package/dist/next/http/url.d.ts +6 -0
  72. package/dist/next/http/url.js +22 -0
  73. package/dist/next/index.d.ts +77 -0
  74. package/dist/next/index.js +35 -0
  75. package/dist/next/ovok.d.ts +56 -0
  76. package/dist/next/ovok.js +86 -0
  77. package/dist/next/paging/bundle-page.d.ts +4 -0
  78. package/dist/next/paging/bundle-page.js +25 -0
  79. package/dist/next/paging/cursor-pages.d.ts +7 -0
  80. package/dist/next/paging/cursor-pages.js +14 -0
  81. package/dist/next/paging/numbered-pages.d.ts +15 -0
  82. package/dist/next/paging/numbered-pages.js +20 -0
  83. package/dist/next/paging/page.d.ts +12 -0
  84. package/dist/next/paging/page.js +17 -0
  85. package/dist/next/react/context.d.ts +4 -0
  86. package/dist/{hooks/signals-alert-item-hooks.js → next/react/context.js} +10 -26
  87. package/dist/next/react/index.d.ts +14 -0
  88. package/dist/next/react/index.js +68 -0
  89. package/dist/next/react/query-hooks.d.ts +31 -0
  90. package/dist/next/react/query-hooks.js +160 -0
  91. package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
  92. package/dist/next/resources/accounts/accounts-resource.js +13 -0
  93. package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
  94. package/dist/next/resources/ai/ai-chat-resource.js +12 -0
  95. package/dist/next/resources/ai/ai-resource.d.ts +16 -0
  96. package/dist/next/resources/ai/ai-resource.js +19 -0
  97. package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
  98. package/dist/next/resources/ai/chat-messages-resource.js +18 -0
  99. package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
  100. package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
  101. package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
  102. package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
  103. package/dist/next/resources/auth/registration.d.ts +35 -0
  104. package/dist/next/resources/auth/registration.js +24 -0
  105. package/dist/next/resources/auth/social-login.d.ts +8 -0
  106. package/dist/next/resources/auth/social-login.js +7 -0
  107. package/dist/next/resources/auth-resource.d.ts +63 -0
  108. package/dist/next/resources/auth-resource.js +119 -0
  109. package/dist/next/resources/bots/bots-resource.d.ts +10 -0
  110. package/dist/next/resources/bots/bots-resource.js +15 -0
  111. package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
  112. package/dist/next/resources/cms/cms-delivery.js +36 -0
  113. package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
  114. package/dist/next/resources/cms/cms-documents-resource.js +17 -0
  115. package/dist/next/resources/cms/cms-resource.d.ts +17 -0
  116. package/dist/next/resources/cms/cms-resource.js +38 -0
  117. package/dist/next/resources/cms/payload-pages.d.ts +6 -0
  118. package/dist/next/resources/cms/payload-pages.js +15 -0
  119. package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
  120. package/dist/next/resources/cms/release-notes-resource.js +15 -0
  121. package/dist/next/resources/cms/translation-tree.d.ts +3 -0
  122. package/dist/next/resources/cms/translation-tree.js +45 -0
  123. package/dist/next/resources/consent/consent-resource.d.ts +23 -0
  124. package/dist/next/resources/consent/consent-resource.js +43 -0
  125. package/dist/next/resources/content/content-resource.d.ts +19 -0
  126. package/dist/next/resources/content/content-resource.js +41 -0
  127. package/dist/next/resources/documents/documents-resource.d.ts +26 -0
  128. package/dist/next/resources/documents/documents-resource.js +41 -0
  129. package/dist/next/resources/email/email-resource.d.ts +6 -0
  130. package/dist/next/resources/email/email-resource.js +10 -0
  131. package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
  132. package/dist/next/resources/email/email-templates-resource.js +13 -0
  133. package/dist/next/resources/fhir-resource.d.ts +28 -0
  134. package/dist/next/resources/fhir-resource.js +64 -0
  135. package/dist/next/resources/health-resource.d.ts +17 -0
  136. package/dist/next/resources/health-resource.js +14 -0
  137. package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
  138. package/dist/next/resources/invites/invite-flow-resource.js +19 -0
  139. package/dist/next/resources/invites/invites-resource.d.ts +22 -0
  140. package/dist/next/resources/invites/invites-resource.js +29 -0
  141. package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
  142. package/dist/next/resources/localization/i18next-resource.js +18 -0
  143. package/dist/next/resources/localization/locales-resource.d.ts +9 -0
  144. package/dist/next/resources/localization/locales-resource.js +16 -0
  145. package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
  146. package/dist/next/resources/localization/localizations-resource.js +27 -0
  147. package/dist/next/resources/measurements/measurements-resource.d.ts +58 -0
  148. package/dist/next/resources/measurements/measurements-resource.js +98 -0
  149. package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
  150. package/dist/next/resources/measurements/observation-builder.js +57 -0
  151. package/dist/next/resources/measurements/offline-measurement-queue-types.d.ts +22 -0
  152. package/dist/next/resources/measurements/offline-measurement-queue-types.js +2 -0
  153. package/dist/next/resources/measurements/offline-measurement-queue.d.ts +25 -0
  154. package/dist/next/resources/measurements/offline-measurement-queue.js +154 -0
  155. package/dist/next/resources/measurements/save-error.d.ts +5 -0
  156. package/dist/next/resources/measurements/save-error.js +18 -0
  157. package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
  158. package/dist/next/resources/measurements/signed-in-account.js +26 -0
  159. package/dist/next/resources/patient/fhir-records.d.ts +19 -0
  160. package/dist/next/resources/patient/fhir-records.js +33 -0
  161. package/dist/next/resources/patient/patient-resource.d.ts +21 -0
  162. package/dist/next/resources/patient/patient-resource.js +38 -0
  163. package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
  164. package/dist/next/resources/projects/project-features-resource.js +17 -0
  165. package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
  166. package/dist/next/resources/projects/project-members-resource.js +25 -0
  167. package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
  168. package/dist/next/resources/projects/project-settings-resource.js +21 -0
  169. package/dist/next/resources/projects/projects-resource.d.ts +20 -0
  170. package/dist/next/resources/projects/projects-resource.js +21 -0
  171. package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
  172. package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
  173. package/dist/next/resources/realtime/realtime-binding.d.ts +7 -0
  174. package/dist/next/resources/realtime/realtime-binding.js +44 -0
  175. package/dist/next/resources/realtime/realtime-connection.d.ts +38 -0
  176. package/dist/next/resources/realtime/realtime-connection.js +167 -0
  177. package/dist/next/resources/realtime/realtime-resource.d.ts +13 -0
  178. package/dist/next/resources/realtime/realtime-resource.js +39 -0
  179. package/dist/next/resources/realtime/realtime-socket.d.ts +23 -0
  180. package/dist/next/resources/realtime/realtime-socket.js +152 -0
  181. package/dist/next/resources/realtime/realtime-types.d.ts +6 -0
  182. package/dist/next/resources/realtime/realtime-types.js +2 -0
  183. package/dist/next/resources/session/saved-accounts-resource.d.ts +13 -0
  184. package/dist/next/resources/session/saved-accounts-resource.js +44 -0
  185. package/dist/next/resources/session/session-resource.d.ts +12 -0
  186. package/dist/next/resources/session/session-resource.js +19 -0
  187. package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
  188. package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
  189. package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
  190. package/dist/next/resources/sharing/sharing-resource.js +14 -0
  191. package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
  192. package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
  193. package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
  194. package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
  195. package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
  196. package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
  197. package/dist/next/resources/signals/signals-resource.d.ts +13 -0
  198. package/dist/next/resources/signals/signals-resource.js +19 -0
  199. package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
  200. package/dist/next/resources/signals/undeliverable-resource.js +18 -0
  201. package/dist/next/resources/slim/live-reads.d.ts +13 -0
  202. package/dist/next/resources/slim/live-reads.js +87 -0
  203. package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
  204. package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
  205. package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
  206. package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
  207. package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
  208. package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
  209. package/dist/next/resources/slim/slim-devices-resource.d.ts +29 -0
  210. package/dist/next/resources/slim/slim-devices-resource.js +81 -0
  211. package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
  212. package/dist/next/resources/slim/slim-exports-resource.js +14 -0
  213. package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
  214. package/dist/next/resources/slim/slim-locations-resource.js +30 -0
  215. package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
  216. package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
  217. package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
  218. package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
  219. package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
  220. package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
  221. package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
  222. package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
  223. package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
  224. package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
  225. package/dist/next/resources/slim/slim-paths.d.ts +6 -0
  226. package/dist/next/resources/slim/slim-paths.js +9 -0
  227. package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
  228. package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
  229. package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
  230. package/dist/next/resources/slim/slim-patients-resource.js +39 -0
  231. package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
  232. package/dist/next/resources/slim/slim-policies-resource.js +29 -0
  233. package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
  234. package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
  235. package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
  236. package/dist/next/resources/slim/slim-projects-resource.js +35 -0
  237. package/dist/next/resources/slim/slim-queries.d.ts +34 -0
  238. package/dist/next/resources/slim/slim-queries.js +2 -0
  239. package/dist/next/resources/slim/slim-resource.d.ts +39 -0
  240. package/dist/next/resources/slim/slim-resource.js +44 -0
  241. package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
  242. package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
  243. package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
  244. package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
  245. package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
  246. package/dist/next/resources/slim/slim-trends-resource.js +19 -0
  247. package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
  248. package/dist/next/resources/slim/slim-users-resource.js +15 -0
  249. package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
  250. package/dist/next/resources/slim/slim-zones-resource.js +24 -0
  251. package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
  252. package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
  253. package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
  254. package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
  255. package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
  256. package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
  257. package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
  258. package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
  259. package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
  260. package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
  261. package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
  262. package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
  263. package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
  264. package/dist/next/resources/wearables/wearables-resource.js +14 -0
  265. package/dist/next/storage/ovok-storage.d.ts +11 -0
  266. package/dist/next/storage/ovok-storage.js +19 -0
  267. package/dist/types/MeasurementTypes.d.ts +5 -0
  268. package/dist/types/MeasurementTypes.js +21 -0
  269. package/dist/types/index.d.ts +1 -5
  270. package/dist/types/index.js +1 -5
  271. package/next/index.d.ts +1 -0
  272. package/next/index.js +3 -0
  273. package/next/react/index.d.ts +1 -0
  274. package/next/react/index.js +1 -0
  275. package/package.json +14 -2
  276. package/dist/hooks/signals-alert-hooks.d.ts +0 -22
  277. package/dist/hooks/signals-alert-hooks.js +0 -166
  278. package/dist/hooks/signals-alert-item-hooks.d.ts +0 -19
@@ -0,0 +1,22 @@
1
+ import type { RequestOptions } from "../../http/transmit";
2
+ import type { Bundle } from "@medplum/fhirtypes";
3
+ export type OfflineMeasurementFlushOptions = {
4
+ includeExhausted?: boolean;
5
+ resetExhausted?: boolean;
6
+ };
7
+ export type OfflineMeasurementFailure = {
8
+ name: string;
9
+ code?: string;
10
+ status?: number;
11
+ };
12
+ export type OfflineMeasurementFlushResult = {
13
+ attempted: number;
14
+ saved: number;
15
+ queued: number;
16
+ exhausted: number;
17
+ responses: Record<string, Bundle>;
18
+ failures: Record<string, OfflineMeasurementFailure>;
19
+ };
20
+ export type OfflineMeasurementQueueApi = {
21
+ flush: (options?: OfflineMeasurementFlushOptions, requestOptions?: RequestOptions) => Promise<OfflineMeasurementFlushResult>;
22
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,25 @@
1
+ import type { OfflineMeasurementFlushOptions, OfflineMeasurementFlushResult } from "./offline-measurement-queue-types";
2
+ import type { RequestOptions } from "../../http/transmit";
3
+ import type { OvokStorage } from "../../storage/ovok-storage";
4
+ import type { Bundle, BundleEntry, Observation } from "@medplum/fhirtypes";
5
+ export type { OfflineMeasurementFailure, OfflineMeasurementFlushOptions, OfflineMeasurementFlushResult, OfflineMeasurementQueueApi, } from "./offline-measurement-queue-types";
6
+ type MeasurementTransport = (bundle: Bundle, ownerKey: string, requestOptions?: RequestOptions) => Promise<Bundle>;
7
+ type OwnerKey = () => Promise<string | null>;
8
+ export declare const offlineMeasurementStorageKey: (tenantCode: string, baseUrl: string) => string;
9
+ export declare class OfflineMeasurementQueue {
10
+ private readonly storage;
11
+ private readonly storageKey;
12
+ private readonly getOwnerKey;
13
+ private readonly transport;
14
+ private operation;
15
+ constructor(storage: OvokStorage, storageKey: string, getOwnerKey: OwnerKey, transport: MeasurementTransport);
16
+ enqueueAndFlush: (entries: BundleEntry<Observation>[], ownerKey: string, requestOptions?: RequestOptions) => Promise<{
17
+ id: string;
18
+ flush: OfflineMeasurementFlushResult;
19
+ }>;
20
+ flush: (options?: OfflineMeasurementFlushOptions, requestOptions?: RequestOptions) => Promise<OfflineMeasurementFlushResult>;
21
+ private runExclusive;
22
+ private readQueue;
23
+ private writeQueue;
24
+ private flushQueue;
25
+ }
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OfflineMeasurementQueue = exports.offlineMeasurementStorageKey = void 0;
4
+ const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ const MAX_RETRIES = 8;
6
+ const RETRY_BACKOFF_MS = 5000;
7
+ const MAX_RETRY_BACKOFF_MS = 60 * 60 * 1000;
8
+ const offlineMeasurementStorageKey = (tenantCode, baseUrl) => {
9
+ const base = new URL(baseUrl);
10
+ const path = base.pathname.replace(/\/+$/g, "");
11
+ return `ovok:${tenantCode}:${base.origin}${path}:offline-measurements`;
12
+ };
13
+ exports.offlineMeasurementStorageKey = offlineMeasurementStorageKey;
14
+ const queueItemId = (entries) => entries.map(({ fullUrl }) => fullUrl !== null && fullUrl !== void 0 ? fullUrl : "").join("|");
15
+ const retryable = (error) => error instanceof ovok_errors_1.OvokConnectionError ||
16
+ error instanceof ovok_errors_1.OvokRateLimitError ||
17
+ error instanceof ovok_errors_1.OvokServiceError;
18
+ const summarizeFailure = (error) => {
19
+ const failure = error;
20
+ return {
21
+ name: typeof (failure === null || failure === void 0 ? void 0 : failure.name) === "string" ? failure.name : "Error",
22
+ ...(typeof (failure === null || failure === void 0 ? void 0 : failure.code) === "string" ? { code: failure.code } : {}),
23
+ ...(typeof (failure === null || failure === void 0 ? void 0 : failure.status) === "number" ? { status: failure.status } : {}),
24
+ };
25
+ };
26
+ class OfflineMeasurementQueue {
27
+ constructor(storage, storageKey, getOwnerKey, transport) {
28
+ this.storage = storage;
29
+ this.storageKey = storageKey;
30
+ this.getOwnerKey = getOwnerKey;
31
+ this.transport = transport;
32
+ this.operation = Promise.resolve();
33
+ this.enqueueAndFlush = (entries, ownerKey, requestOptions) => this.runExclusive(async () => {
34
+ const queue = await this.readQueue();
35
+ const id = queueItemId(entries);
36
+ const exists = queue.some((item) => item.id === id && item.ownerKey === ownerKey);
37
+ if (!exists) {
38
+ queue.push({
39
+ id,
40
+ ownerKey,
41
+ queuedAt: new Date().toISOString(),
42
+ attempt: 0,
43
+ nextAttemptAt: 0,
44
+ entries,
45
+ });
46
+ await this.writeQueue(queue);
47
+ }
48
+ return {
49
+ id,
50
+ flush: await this.flushQueue(queue, {}, requestOptions, true),
51
+ };
52
+ });
53
+ this.flush = (options = {}, requestOptions) => this.runExclusive(async () => this.flushQueue(await this.readQueue(), options, requestOptions, false));
54
+ this.runExclusive = (operation) => {
55
+ const next = this.operation.then(operation, operation);
56
+ this.operation = next.catch(() => undefined);
57
+ return next;
58
+ };
59
+ this.readQueue = async () => {
60
+ const serialized = await this.storage.getItem(this.storageKey);
61
+ if (serialized === null || serialized === "") {
62
+ return [];
63
+ }
64
+ const queue = JSON.parse(serialized);
65
+ if (!Array.isArray(queue)) {
66
+ throw new Error("Offline measurement queue is not an array.");
67
+ }
68
+ return queue;
69
+ };
70
+ this.writeQueue = async (queue) => {
71
+ if (queue.length === 0) {
72
+ await this.storage.removeItem(this.storageKey);
73
+ return;
74
+ }
75
+ const serialized = JSON.stringify(queue);
76
+ await this.storage.setItem(this.storageKey, serialized);
77
+ if ((await this.storage.getItem(this.storageKey)) !== serialized) {
78
+ throw new Error("Offline measurement queue could not be persisted.");
79
+ }
80
+ };
81
+ this.flushQueue = async (queue, options, requestOptions, throwNonRetryable) => {
82
+ const result = {
83
+ attempted: 0,
84
+ saved: 0,
85
+ queued: 0,
86
+ exhausted: 0,
87
+ responses: {},
88
+ failures: {},
89
+ };
90
+ let changed = false;
91
+ const now = Date.now();
92
+ for (const item of [...queue]) {
93
+ const ownerKey = await this.getOwnerKey();
94
+ if (!ownerKey || item.ownerKey !== ownerKey) {
95
+ result.queued++;
96
+ continue;
97
+ }
98
+ if (item.lastFailure) {
99
+ result.failures[item.id] = item.lastFailure;
100
+ }
101
+ if (item.exhausted && options.resetExhausted) {
102
+ item.attempt = 0;
103
+ item.exhausted = false;
104
+ item.nextAttemptAt = 0;
105
+ changed = true;
106
+ }
107
+ if ((item.exhausted && !options.includeExhausted) || item.nextAttemptAt > now) {
108
+ if (item.exhausted) {
109
+ result.exhausted++;
110
+ }
111
+ else {
112
+ result.queued++;
113
+ }
114
+ continue;
115
+ }
116
+ result.attempted++;
117
+ try {
118
+ const response = await this.transport({ resourceType: "Bundle", type: "transaction", entry: item.entries }, item.ownerKey, requestOptions);
119
+ queue.splice(queue.indexOf(item), 1);
120
+ result.saved++;
121
+ result.responses[item.id] = response;
122
+ delete result.failures[item.id];
123
+ changed = true;
124
+ }
125
+ catch (error) {
126
+ if (throwNonRetryable && !retryable(error)) {
127
+ queue.splice(queue.indexOf(item), 1);
128
+ await this.writeQueue(queue);
129
+ throw error;
130
+ }
131
+ item.attempt++;
132
+ item.exhausted = item.attempt >= MAX_RETRIES;
133
+ item.nextAttemptAt = item.exhausted
134
+ ? Number.MAX_SAFE_INTEGER
135
+ : Date.now() + Math.min(MAX_RETRY_BACKOFF_MS, RETRY_BACKOFF_MS * 2 ** (item.attempt - 1));
136
+ item.lastFailure = summarizeFailure(error);
137
+ result.failures[item.id] = item.lastFailure;
138
+ if (item.exhausted) {
139
+ result.exhausted++;
140
+ }
141
+ else {
142
+ result.queued++;
143
+ }
144
+ changed = true;
145
+ }
146
+ }
147
+ if (changed) {
148
+ await this.writeQueue(queue);
149
+ }
150
+ return result;
151
+ };
152
+ }
153
+ }
154
+ exports.OfflineMeasurementQueue = OfflineMeasurementQueue;
@@ -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
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SignedInAccount = void 0;
4
+ const ovok_errors_1 = require("../../errors/ovok-errors");
5
+ /** The account a measurement belongs to; a machine client has none. */
6
+ class SignedInAccount {
7
+ constructor(session) {
8
+ this.session = session;
9
+ }
10
+ /** The project and profile signed in now, or null when no one is. */
11
+ async key() {
12
+ const session = await this.current();
13
+ return session === null ? null : `${session.project.reference}|${session.profile.reference}`;
14
+ }
15
+ async profileReference() {
16
+ const session = await this.current();
17
+ if (session === null) {
18
+ throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)("No user is signed in; name the patient instead."));
19
+ }
20
+ return session.profile.reference;
21
+ }
22
+ async current() {
23
+ return this.session === null ? null : this.session.current();
24
+ }
25
+ }
26
+ exports.SignedInAccount = SignedInAccount;
@@ -0,0 +1,19 @@
1
+ import type { Appointment, ExtractResource, ResourceType } from "@medplum/fhirtypes";
2
+ import { RequestOptions } from "../../http/transmit";
3
+ import { QueryParams } from "../../http/url";
4
+ import { FhirResource } from "../fhir-resource";
5
+ /** Lists resolve to the first page's resources, as the Medplum client's `searchResources` did. */
6
+ export declare class FhirListResource<K extends ResourceType> {
7
+ protected readonly fhir: FhirResource;
8
+ protected readonly type: K;
9
+ constructor(fhir: FhirResource, type: K);
10
+ list(params?: QueryParams, options?: RequestOptions): Promise<ExtractResource<K>[]>;
11
+ }
12
+ export declare class FhirRecordsResource<K extends ResourceType> extends FhirListResource<K> {
13
+ retrieve(id: string, options?: RequestOptions): Promise<ExtractResource<K>>;
14
+ }
15
+ export declare class AppointmentsResource extends FhirRecordsResource<"Appointment"> {
16
+ constructor(fhir: FhirResource);
17
+ create(appointment: Appointment, options?: RequestOptions): Promise<Appointment>;
18
+ update(id: string, appointment: Appointment, options?: RequestOptions): Promise<Appointment>;
19
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppointmentsResource = exports.FhirRecordsResource = exports.FhirListResource = void 0;
4
+ /** Lists resolve to the first page's resources, as the Medplum client's `searchResources` did. */
5
+ class FhirListResource {
6
+ constructor(fhir, type) {
7
+ this.fhir = fhir;
8
+ this.type = type;
9
+ }
10
+ async list(params = {}, options) {
11
+ const page = await this.fhir.search(this.type, params, options);
12
+ return page.data;
13
+ }
14
+ }
15
+ exports.FhirListResource = FhirListResource;
16
+ class FhirRecordsResource extends FhirListResource {
17
+ retrieve(id, options) {
18
+ return this.fhir.read(this.type, id, options);
19
+ }
20
+ }
21
+ exports.FhirRecordsResource = FhirRecordsResource;
22
+ class AppointmentsResource extends FhirRecordsResource {
23
+ constructor(fhir) {
24
+ super(fhir, "Appointment");
25
+ }
26
+ create(appointment, options) {
27
+ return this.fhir.create(appointment, options);
28
+ }
29
+ update(id, appointment, options) {
30
+ return this.fhir.update({ ...appointment, id }, options);
31
+ }
32
+ }
33
+ exports.AppointmentsResource = AppointmentsResource;
@@ -0,0 +1,21 @@
1
+ import type { OvokPatientDashboard, OvokPatientDashboardQuery, OvokPatientLatestObservationsQuery, OvokPatientObservationBundle } from "../../../client/patient/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ import { FhirResource } from "../fhir-resource";
5
+ import { AppointmentsResource, FhirListResource, FhirRecordsResource } from "./fhir-records";
6
+ export declare class PatientResource {
7
+ private readonly http;
8
+ readonly appointments: AppointmentsResource;
9
+ readonly schedules: FhirListResource<"Schedule">;
10
+ readonly slots: FhirListResource<"Slot">;
11
+ readonly measurements: FhirRecordsResource<"Observation">;
12
+ readonly carePlans: FhirRecordsResource<"CarePlan">;
13
+ readonly questionnaires: FhirRecordsResource<"Questionnaire">;
14
+ readonly questionnaireResponses: FhirRecordsResource<"QuestionnaireResponse">;
15
+ readonly devices: FhirRecordsResource<"Device">;
16
+ readonly notifications: FhirRecordsResource<"CommunicationRequest">;
17
+ constructor(http: HttpClient, fhir: FhirResource);
18
+ latestObservations(params?: OvokPatientLatestObservationsQuery, options?: RequestOptions): Promise<OvokPatientObservationBundle>;
19
+ /** Every read is scoped to the signed-in patient unless its query names another. */
20
+ dashboard(params?: OvokPatientDashboardQuery, options?: RequestOptions): Promise<OvokPatientDashboard>;
21
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PatientResource = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const auth_resource_1 = require("../auth-resource");
6
+ const fhir_records_1 = require("./fhir-records");
7
+ const LATEST_OBSERVATIONS_PATH = "fhir/Observation/$lastn";
8
+ class PatientResource {
9
+ constructor(http, fhir) {
10
+ this.http = http;
11
+ this.appointments = new fhir_records_1.AppointmentsResource(fhir);
12
+ this.schedules = new fhir_records_1.FhirListResource(fhir, "Schedule");
13
+ this.slots = new fhir_records_1.FhirListResource(fhir, "Slot");
14
+ this.measurements = new fhir_records_1.FhirRecordsResource(fhir, "Observation");
15
+ this.carePlans = new fhir_records_1.FhirRecordsResource(fhir, "CarePlan");
16
+ this.questionnaires = new fhir_records_1.FhirRecordsResource(fhir, "Questionnaire");
17
+ this.questionnaireResponses = new fhir_records_1.FhirRecordsResource(fhir, "QuestionnaireResponse");
18
+ this.devices = new fhir_records_1.FhirRecordsResource(fhir, "Device");
19
+ this.notifications = new fhir_records_1.FhirRecordsResource(fhir, "CommunicationRequest");
20
+ }
21
+ latestObservations(params = {}, options) {
22
+ const { patient, max, code } = params;
23
+ return this.http.get(`${LATEST_OBSERVATIONS_PATH}${(0, query_string_1.toQueryString)({ patient, max, code })}`, options);
24
+ }
25
+ /** Every read is scoped to the signed-in patient unless its query names another. */
26
+ async dashboard(params = {}, options) {
27
+ const profile = await this.http.get(auth_resource_1.ME_PATH, options);
28
+ const patient = `Patient/${profile.profile.id}`;
29
+ const latestObservations = await this.latestObservations(withPatient(params.latestObservations, patient), options);
30
+ const [measurementHistory, carePlans] = await Promise.all([
31
+ this.measurements.list(withPatient(params.measurementHistory, patient), options),
32
+ this.carePlans.list(withPatient(params.carePlans, patient), options),
33
+ ]);
34
+ return { carePlans, latestObservations, measurementHistory, profile };
35
+ }
36
+ }
37
+ exports.PatientResource = PatientResource;
38
+ const withPatient = (query, patient) => { var _a; return ({ ...query, patient: (_a = query === null || query === void 0 ? void 0 : query.patient) !== null && _a !== void 0 ? _a : patient }); };
@@ -0,0 +1,9 @@
1
+ import type { OvokProjectFeature, OvokProjectFeatures } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class ProjectFeaturesResource {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ retrieve(options?: RequestOptions): Promise<OvokProjectFeatures>;
8
+ update(features: OvokProjectFeature[], options?: RequestOptions): Promise<OvokProjectFeatures>;
9
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectFeaturesResource = void 0;
4
+ const FEATURES_PATH = "v1/projects/me/features";
5
+ class ProjectFeaturesResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ retrieve(options) {
10
+ return this.http.get(FEATURES_PATH, options);
11
+ }
12
+ update(features, options) {
13
+ const body = { features };
14
+ return this.http.patch(FEATURES_PATH, body, options);
15
+ }
16
+ }
17
+ exports.ProjectFeaturesResource = ProjectFeaturesResource;
@@ -0,0 +1,19 @@
1
+ import type { OvokInviteProjectMember, OvokProjectMember, OvokProjectMemberResponse, OvokRemoveProjectMemberResponse, OvokUpdateProjectMember } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ import { PagePromise } from "../../paging/page";
5
+ export type ProjectMemberListQuery = {
6
+ accessPolicyId?: string;
7
+ profileId?: string;
8
+ userId?: string;
9
+ page?: number;
10
+ count?: number;
11
+ };
12
+ export declare class ProjectMembersResource {
13
+ private readonly http;
14
+ constructor(http: HttpClient);
15
+ list(query?: ProjectMemberListQuery, options?: RequestOptions): PagePromise<OvokProjectMember>;
16
+ invite(body: OvokInviteProjectMember, options?: RequestOptions): Promise<OvokProjectMemberResponse>;
17
+ update(membershipId: string, body: OvokUpdateProjectMember, options?: RequestOptions): Promise<OvokProjectMemberResponse>;
18
+ remove(membershipId: string, options?: RequestOptions): Promise<OvokRemoveProjectMemberResponse>;
19
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectMembersResource = void 0;
4
+ const url_1 = require("../../http/url");
5
+ const numbered_pages_1 = require("../../paging/numbered-pages");
6
+ const MEMBERS_PATH = "v1/projects/me/members";
7
+ const memberPath = (membershipId) => `${MEMBERS_PATH}/${(0, url_1.pathSegment)(membershipId)}`;
8
+ class ProjectMembersResource {
9
+ constructor(http) {
10
+ this.http = http;
11
+ }
12
+ list(query = {}, options) {
13
+ return (0, numbered_pages_1.numberedRoutePages)((path) => this.http.get(path, options), MEMBERS_PATH, query);
14
+ }
15
+ invite(body, options) {
16
+ return this.http.post(MEMBERS_PATH, body, options);
17
+ }
18
+ update(membershipId, body, options) {
19
+ return this.http.patch(memberPath(membershipId), body, options);
20
+ }
21
+ remove(membershipId, options) {
22
+ return this.http.delete(memberPath(membershipId), options);
23
+ }
24
+ }
25
+ exports.ProjectMembersResource = ProjectMembersResource;
@@ -0,0 +1,10 @@
1
+ import type { OvokProjectSettingKey, OvokProjectSettings, OvokProjectTextSettingKey } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class ProjectSettingsResource {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ retrieve(options?: RequestOptions): Promise<OvokProjectSettings>;
8
+ update(key: OvokProjectSettingKey, enabled: boolean, options?: RequestOptions): Promise<OvokProjectSettings>;
9
+ updateText(key: OvokProjectTextSettingKey, value: string | null, options?: RequestOptions): Promise<OvokProjectSettings>;
10
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectSettingsResource = void 0;
4
+ const url_1 = require("../../http/url");
5
+ const SETTINGS_PATH = "v1/project/settings";
6
+ const TEXT_SETTINGS_PATH = `${SETTINGS_PATH}/values`;
7
+ class ProjectSettingsResource {
8
+ constructor(http) {
9
+ this.http = http;
10
+ }
11
+ retrieve(options) {
12
+ return this.http.get(SETTINGS_PATH, options);
13
+ }
14
+ update(key, enabled, options) {
15
+ return this.http.put(`${SETTINGS_PATH}/${(0, url_1.pathSegment)(key)}`, { enabled }, options);
16
+ }
17
+ updateText(key, value, options) {
18
+ return this.http.put(`${TEXT_SETTINGS_PATH}/${(0, url_1.pathSegment)(key)}`, { value }, options);
19
+ }
20
+ }
21
+ exports.ProjectSettingsResource = ProjectSettingsResource;
@@ -0,0 +1,20 @@
1
+ import type { OvokAdministeredProject } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ import { PagePromise } from "../../paging/page";
5
+ import { ProjectFeaturesResource } from "./project-features-resource";
6
+ import { ProjectMembersResource } from "./project-members-resource";
7
+ import { ProjectSettingsResource } from "./project-settings-resource";
8
+ export type ProjectListQuery = {
9
+ page?: number;
10
+ count?: number;
11
+ };
12
+ export declare class ProjectsResource {
13
+ private readonly http;
14
+ readonly members: ProjectMembersResource;
15
+ readonly features: ProjectFeaturesResource;
16
+ readonly settings: ProjectSettingsResource;
17
+ constructor(http: HttpClient);
18
+ /** The projects the caller administers, wherever they are signed in. */
19
+ list(query?: ProjectListQuery, options?: RequestOptions): PagePromise<OvokAdministeredProject>;
20
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectsResource = void 0;
4
+ const numbered_pages_1 = require("../../paging/numbered-pages");
5
+ const project_features_resource_1 = require("./project-features-resource");
6
+ const project_members_resource_1 = require("./project-members-resource");
7
+ const project_settings_resource_1 = require("./project-settings-resource");
8
+ const PROJECTS_PATH = "v1/projects";
9
+ class ProjectsResource {
10
+ constructor(http) {
11
+ this.http = http;
12
+ this.members = new project_members_resource_1.ProjectMembersResource(http);
13
+ this.features = new project_features_resource_1.ProjectFeaturesResource(http);
14
+ this.settings = new project_settings_resource_1.ProjectSettingsResource(http);
15
+ }
16
+ /** The projects the caller administers, wherever they are signed in. */
17
+ list(query = {}, options) {
18
+ return (0, numbered_pages_1.numberedRoutePages)((path) => this.http.get(path, options), PROJECTS_PATH, query);
19
+ }
20
+ }
21
+ exports.ProjectsResource = ProjectsResource;
@@ -0,0 +1,18 @@
1
+ import type { Bundle, Observation, Parameters, QuestionnaireResponse } from "@medplum/fhirtypes";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ import { FhirResource } from "../fhir-resource";
5
+ export declare class QuestionnairesResource {
6
+ private readonly http;
7
+ constructor(http: HttpClient);
8
+ populate(questionnaireId: string, parameters?: Parameters, options?: RequestOptions): Promise<Parameters>;
9
+ }
10
+ export declare class QuestionnaireResponsesResource {
11
+ private readonly http;
12
+ private readonly fhir;
13
+ constructor(http: HttpClient, fhir: FhirResource);
14
+ submit(response: QuestionnaireResponse, options?: RequestOptions): Promise<Bundle>;
15
+ /** One transaction, so the response is never saved without its observations. */
16
+ submitWithObservations(response: QuestionnaireResponse, observations: Observation[], options?: RequestOptions): Promise<Bundle>;
17
+ extract(questionnaireResponseId: string, options?: RequestOptions): Promise<Parameters>;
18
+ }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionnaireResponsesResource = exports.QuestionnairesResource = void 0;
4
+ const url_1 = require("../../http/url");
5
+ class QuestionnairesResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ populate(questionnaireId, parameters = { resourceType: "Parameters", parameter: [] }, options) {
10
+ return this.http.post(`fhir/Questionnaire/${(0, url_1.pathSegment)(questionnaireId)}/$populate`, parameters, options);
11
+ }
12
+ }
13
+ exports.QuestionnairesResource = QuestionnairesResource;
14
+ class QuestionnaireResponsesResource {
15
+ constructor(http, fhir) {
16
+ this.http = http;
17
+ this.fhir = fhir;
18
+ }
19
+ submit(response, options) {
20
+ return this.submitWithObservations(response, [], options);
21
+ }
22
+ /** One transaction, so the response is never saved without its observations. */
23
+ submitWithObservations(response, observations, options) {
24
+ const entry = [createEntry(response), ...observations.map(createEntry)];
25
+ return this.fhir.batch({ resourceType: "Bundle", type: "transaction", entry }, options);
26
+ }
27
+ extract(questionnaireResponseId, options) {
28
+ return this.http.post(`fhir/QuestionnaireResponse/${(0, url_1.pathSegment)(questionnaireResponseId)}/$extract`, {}, options);
29
+ }
30
+ }
31
+ exports.QuestionnaireResponsesResource = QuestionnaireResponsesResource;
32
+ const createEntry = (resource) => ({
33
+ fullUrl: resource.id,
34
+ request: { method: "POST", url: resource.resourceType },
35
+ resource,
36
+ });
@@ -0,0 +1,7 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ export type RealtimeBinding = {
3
+ token: string;
4
+ url: string;
5
+ expiresAt: number;
6
+ };
7
+ export declare const fetchRealtimeBinding: (http: HttpClient, subscriptionId: string, baseUrl: string) => Promise<RealtimeBinding>;