@ovok/core 0.4.49-dev.495 → 0.4.49-dev.497

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 (243) hide show
  1. package/dist/client/observation/measurement-fields.d.ts +1 -1
  2. package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
  3. package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
  4. package/dist/client/observation/services/base-observation-service.d.ts +1 -1
  5. package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
  6. package/dist/client/observation/services/blood-oxygen.js +7 -7
  7. package/dist/client/observation/services/blood-pressure.d.ts +1 -1
  8. package/dist/client/observation/services/blood-pressure.js +16 -16
  9. package/dist/client/observation/services/component-observation-services.d.ts +1 -1
  10. package/dist/client/observation/services/component-observation-services.js +3 -3
  11. package/dist/client/observation/services/creator.d.ts +1 -1
  12. package/dist/client/observation/services/creator.js +10 -10
  13. package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
  14. package/dist/client/observation/services/ecg.d.ts +1 -1
  15. package/dist/client/observation/services/ecg.js +10 -10
  16. package/dist/client/observation/services/lipid-panel.d.ts +1 -1
  17. package/dist/client/observation/services/lipid-panel.js +13 -13
  18. package/dist/client/observation/services/single-value-services.d.ts +1 -1
  19. package/dist/client/observation/services/single-value-services.js +19 -19
  20. package/dist/client/observation/services/step-count.d.ts +1 -1
  21. package/dist/client/observation/services/step-count.js +5 -5
  22. package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
  23. package/dist/client/observation/services/uric-acid-service.js +7 -7
  24. package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
  25. package/dist/client/wearables/types.d.ts +5 -0
  26. package/dist/conformance/capability-requirements.js +1 -1
  27. package/dist/next/auth/access-token.d.ts +9 -0
  28. package/dist/next/auth/access-token.js +18 -0
  29. package/dist/next/auth/client-credentials.d.ts +16 -0
  30. package/dist/next/auth/client-credentials.js +40 -0
  31. package/dist/next/auth/credentials.d.ts +5 -0
  32. package/dist/next/auth/credentials.js +7 -0
  33. package/dist/next/auth/saved-accounts-store.d.ts +26 -0
  34. package/dist/next/auth/saved-accounts-store.js +93 -0
  35. package/dist/next/auth/session-store.d.ts +12 -0
  36. package/dist/next/auth/session-store.js +33 -0
  37. package/dist/next/auth/session.d.ts +28 -0
  38. package/dist/next/auth/session.js +27 -0
  39. package/dist/next/auth/token-endpoint.d.ts +12 -0
  40. package/dist/next/auth/token-endpoint.js +28 -0
  41. package/dist/next/auth/user-session.d.ts +39 -0
  42. package/dist/next/auth/user-session.js +183 -0
  43. package/dist/next/config/ovok-config.d.ts +42 -0
  44. package/dist/next/config/ovok-config.js +2 -0
  45. package/dist/next/config/settings.d.ts +6 -0
  46. package/dist/next/config/settings.js +74 -0
  47. package/dist/next/errors/error-from-response.d.ts +2 -0
  48. package/dist/next/errors/error-from-response.js +35 -0
  49. package/dist/next/errors/ovok-account-error.d.ts +5 -0
  50. package/dist/next/errors/ovok-account-error.js +13 -0
  51. package/dist/next/errors/ovok-errors.d.ts +42 -0
  52. package/dist/next/errors/ovok-errors.js +74 -0
  53. package/dist/next/http/http-client.d.ts +36 -0
  54. package/dist/next/http/http-client.js +116 -0
  55. package/dist/next/http/retry-after.d.ts +1 -0
  56. package/dist/next/http/retry-after.js +16 -0
  57. package/dist/next/http/retry-policy.d.ts +13 -0
  58. package/dist/next/http/retry-policy.js +27 -0
  59. package/dist/next/http/transmit.d.ts +14 -0
  60. package/dist/next/http/transmit.js +57 -0
  61. package/dist/next/http/url.d.ts +6 -0
  62. package/dist/next/http/url.js +22 -0
  63. package/dist/next/index.d.ts +74 -0
  64. package/dist/next/index.js +35 -0
  65. package/dist/next/ovok.d.ts +54 -0
  66. package/dist/next/ovok.js +77 -0
  67. package/dist/next/paging/bundle-page.d.ts +4 -0
  68. package/dist/next/paging/bundle-page.js +25 -0
  69. package/dist/next/paging/cursor-pages.d.ts +7 -0
  70. package/dist/next/paging/cursor-pages.js +14 -0
  71. package/dist/next/paging/numbered-pages.d.ts +15 -0
  72. package/dist/next/paging/numbered-pages.js +20 -0
  73. package/dist/next/paging/page.d.ts +12 -0
  74. package/dist/next/paging/page.js +17 -0
  75. package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
  76. package/dist/next/resources/accounts/accounts-resource.js +13 -0
  77. package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
  78. package/dist/next/resources/ai/ai-chat-resource.js +12 -0
  79. package/dist/next/resources/ai/ai-resource.d.ts +16 -0
  80. package/dist/next/resources/ai/ai-resource.js +19 -0
  81. package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
  82. package/dist/next/resources/ai/chat-messages-resource.js +18 -0
  83. package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
  84. package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
  85. package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
  86. package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
  87. package/dist/next/resources/auth/registration.d.ts +35 -0
  88. package/dist/next/resources/auth/registration.js +24 -0
  89. package/dist/next/resources/auth/social-login.d.ts +8 -0
  90. package/dist/next/resources/auth/social-login.js +7 -0
  91. package/dist/next/resources/auth-resource.d.ts +63 -0
  92. package/dist/next/resources/auth-resource.js +119 -0
  93. package/dist/next/resources/bots/bots-resource.d.ts +10 -0
  94. package/dist/next/resources/bots/bots-resource.js +15 -0
  95. package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
  96. package/dist/next/resources/cms/cms-delivery.js +36 -0
  97. package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
  98. package/dist/next/resources/cms/cms-documents-resource.js +17 -0
  99. package/dist/next/resources/cms/cms-resource.d.ts +17 -0
  100. package/dist/next/resources/cms/cms-resource.js +38 -0
  101. package/dist/next/resources/cms/payload-pages.d.ts +6 -0
  102. package/dist/next/resources/cms/payload-pages.js +15 -0
  103. package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
  104. package/dist/next/resources/cms/release-notes-resource.js +15 -0
  105. package/dist/next/resources/cms/translation-tree.d.ts +3 -0
  106. package/dist/next/resources/cms/translation-tree.js +45 -0
  107. package/dist/next/resources/consent/consent-resource.d.ts +23 -0
  108. package/dist/next/resources/consent/consent-resource.js +43 -0
  109. package/dist/next/resources/content/content-resource.d.ts +19 -0
  110. package/dist/next/resources/content/content-resource.js +41 -0
  111. package/dist/next/resources/documents/documents-resource.d.ts +26 -0
  112. package/dist/next/resources/documents/documents-resource.js +41 -0
  113. package/dist/next/resources/email/email-resource.d.ts +6 -0
  114. package/dist/next/resources/email/email-resource.js +10 -0
  115. package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
  116. package/dist/next/resources/email/email-templates-resource.js +13 -0
  117. package/dist/next/resources/fhir-resource.d.ts +28 -0
  118. package/dist/next/resources/fhir-resource.js +64 -0
  119. package/dist/next/resources/health-resource.d.ts +17 -0
  120. package/dist/next/resources/health-resource.js +14 -0
  121. package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
  122. package/dist/next/resources/invites/invite-flow-resource.js +19 -0
  123. package/dist/next/resources/invites/invites-resource.d.ts +22 -0
  124. package/dist/next/resources/invites/invites-resource.js +29 -0
  125. package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
  126. package/dist/next/resources/localization/i18next-resource.js +18 -0
  127. package/dist/next/resources/localization/locales-resource.d.ts +9 -0
  128. package/dist/next/resources/localization/locales-resource.js +16 -0
  129. package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
  130. package/dist/next/resources/localization/localizations-resource.js +27 -0
  131. package/dist/next/resources/measurements/measurements-resource.d.ts +42 -0
  132. package/dist/next/resources/measurements/measurements-resource.js +77 -0
  133. package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
  134. package/dist/next/resources/measurements/observation-builder.js +57 -0
  135. package/dist/next/resources/measurements/save-error.d.ts +5 -0
  136. package/dist/next/resources/measurements/save-error.js +18 -0
  137. package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
  138. package/dist/next/resources/measurements/signed-in-account.js +26 -0
  139. package/dist/next/resources/patient/fhir-records.d.ts +19 -0
  140. package/dist/next/resources/patient/fhir-records.js +33 -0
  141. package/dist/next/resources/patient/patient-resource.d.ts +21 -0
  142. package/dist/next/resources/patient/patient-resource.js +38 -0
  143. package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
  144. package/dist/next/resources/projects/project-features-resource.js +17 -0
  145. package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
  146. package/dist/next/resources/projects/project-members-resource.js +25 -0
  147. package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
  148. package/dist/next/resources/projects/project-settings-resource.js +21 -0
  149. package/dist/next/resources/projects/projects-resource.d.ts +20 -0
  150. package/dist/next/resources/projects/projects-resource.js +21 -0
  151. package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
  152. package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
  153. package/dist/next/resources/session/saved-accounts-resource.d.ts +13 -0
  154. package/dist/next/resources/session/saved-accounts-resource.js +44 -0
  155. package/dist/next/resources/session/session-resource.d.ts +11 -0
  156. package/dist/next/resources/session/session-resource.js +15 -0
  157. package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
  158. package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
  159. package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
  160. package/dist/next/resources/sharing/sharing-resource.js +14 -0
  161. package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
  162. package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
  163. package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
  164. package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
  165. package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
  166. package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
  167. package/dist/next/resources/signals/signals-resource.d.ts +13 -0
  168. package/dist/next/resources/signals/signals-resource.js +19 -0
  169. package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
  170. package/dist/next/resources/signals/undeliverable-resource.js +18 -0
  171. package/dist/next/resources/slim/live-reads.d.ts +13 -0
  172. package/dist/next/resources/slim/live-reads.js +87 -0
  173. package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
  174. package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
  175. package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
  176. package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
  177. package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
  178. package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
  179. package/dist/next/resources/slim/slim-devices-resource.d.ts +29 -0
  180. package/dist/next/resources/slim/slim-devices-resource.js +81 -0
  181. package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
  182. package/dist/next/resources/slim/slim-exports-resource.js +14 -0
  183. package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
  184. package/dist/next/resources/slim/slim-locations-resource.js +30 -0
  185. package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
  186. package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
  187. package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
  188. package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
  189. package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
  190. package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
  191. package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
  192. package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
  193. package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
  194. package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
  195. package/dist/next/resources/slim/slim-paths.d.ts +6 -0
  196. package/dist/next/resources/slim/slim-paths.js +9 -0
  197. package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
  198. package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
  199. package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
  200. package/dist/next/resources/slim/slim-patients-resource.js +39 -0
  201. package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
  202. package/dist/next/resources/slim/slim-policies-resource.js +29 -0
  203. package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
  204. package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
  205. package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
  206. package/dist/next/resources/slim/slim-projects-resource.js +35 -0
  207. package/dist/next/resources/slim/slim-queries.d.ts +34 -0
  208. package/dist/next/resources/slim/slim-queries.js +2 -0
  209. package/dist/next/resources/slim/slim-resource.d.ts +39 -0
  210. package/dist/next/resources/slim/slim-resource.js +44 -0
  211. package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
  212. package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
  213. package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
  214. package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
  215. package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
  216. package/dist/next/resources/slim/slim-trends-resource.js +19 -0
  217. package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
  218. package/dist/next/resources/slim/slim-users-resource.js +15 -0
  219. package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
  220. package/dist/next/resources/slim/slim-zones-resource.js +24 -0
  221. package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
  222. package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
  223. package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
  224. package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
  225. package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
  226. package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
  227. package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
  228. package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
  229. package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
  230. package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
  231. package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
  232. package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
  233. package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
  234. package/dist/next/resources/wearables/wearables-resource.js +14 -0
  235. package/dist/next/storage/ovok-storage.d.ts +11 -0
  236. package/dist/next/storage/ovok-storage.js +19 -0
  237. package/dist/types/MeasurementTypes.d.ts +5 -0
  238. package/dist/types/MeasurementTypes.js +21 -0
  239. package/dist/types/index.d.ts +1 -5
  240. package/dist/types/index.js +1 -5
  241. package/next/index.d.ts +1 -0
  242. package/next/index.js +3 -0
  243. package/package.json +3 -2
@@ -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
+ }
@@ -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
+ });