@ovok/core 0.4.49-dev.502 → 0.4.49-dev.504

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,78 +10,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
15
  };
38
16
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.mapSignalsError = exports.isSignalsError = exports.SignalsError = exports.saveMeasurement = exports.MAX_OBSERVATION_BUNDLE_BYTES = exports.MAX_CONDITIONAL_OBSERVATION_ENTRIES = exports.LoginError = exports.OvokClient = exports.Medplum = void 0;
40
- const MedplumCore = __importStar(require("@medplum/core"));
41
- __exportStar(require("./types"), exports);
42
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
- const { MedplumClient, ...Medplum } = MedplumCore;
44
- exports.Medplum = Medplum;
45
- var ovok_client_1 = require("./client/ovok-client");
46
- Object.defineProperty(exports, "OvokClient", { enumerable: true, get: function () { return ovok_client_1.OvokClient; } });
47
- __exportStar(require("./client/errors/rate-limit-error"), exports);
48
- __exportStar(require("./client/errors/sign-in-required-error"), exports);
49
- __exportStar(require("./client/errors/ovok-error"), exports);
50
- __exportStar(require("./client/auth/errors"), exports);
51
- var LoginError_1 = require("./client/auth/types/LoginError");
52
- Object.defineProperty(exports, "LoginError", { enumerable: true, get: function () { return LoginError_1.LoginError; } });
53
- var ovok_client_2 = require("./client/ovok-client");
54
- Object.defineProperty(exports, "MAX_CONDITIONAL_OBSERVATION_ENTRIES", { enumerable: true, get: function () { return ovok_client_2.MAX_CONDITIONAL_OBSERVATION_ENTRIES; } });
55
- Object.defineProperty(exports, "MAX_OBSERVATION_BUNDLE_BYTES", { enumerable: true, get: function () { return ovok_client_2.MAX_OBSERVATION_BUNDLE_BYTES; } });
56
- __exportStar(require("./client/offline"), exports);
57
- __exportStar(require("./hooks"), exports);
58
- __exportStar(require("./utils"), exports);
59
- __exportStar(require("./client/observation/services"), exports);
60
- __exportStar(require("./client/observation/methods"), exports);
61
- __exportStar(require("./client/observation/measurement-fields"), exports);
62
- __exportStar(require("./client/observation/series"), exports);
63
- var saveMeasurement_1 = require("./client/observation/methods/saveMeasurement");
64
- Object.defineProperty(exports, "saveMeasurement", { enumerable: true, get: function () { return saveMeasurement_1.saveMeasurement; } });
65
- __exportStar(require("./conformance/capability-requirements"), exports);
66
- __exportStar(require("./conformance/api-requirements"), exports);
67
- __exportStar(require("./conformance/capability"), exports);
68
- __exportStar(require("./client/platform/types"), exports);
69
- __exportStar(require("./client/change-history"), exports);
70
- __exportStar(require("./client/consent"), exports);
71
- __exportStar(require("./client/email"), exports);
72
- __exportStar(require("./client/cms"), exports);
73
- __exportStar(require("./client/invites"), exports);
74
- __exportStar(require("./client/notifications"), exports);
75
- __exportStar(require("./client/slim/types"), exports);
76
- __exportStar(require("./client/slim/paging"), exports);
77
- __exportStar(require("./client/experience/types"), exports);
78
- __exportStar(require("./client/patient/types"), exports);
79
- __exportStar(require("./client/patient-sharing"), exports);
80
- __exportStar(require("./client/wearables"), exports);
81
- var errors_1 = require("./client/signals/errors");
82
- Object.defineProperty(exports, "SignalsError", { enumerable: true, get: function () { return errors_1.SignalsError; } });
83
- Object.defineProperty(exports, "isSignalsError", { enumerable: true, get: function () { return errors_1.isSignalsError; } });
84
- Object.defineProperty(exports, "mapSignalsError", { enumerable: true, get: function () { return errors_1.mapSignalsError; } });
85
- __exportStar(require("./client/storage"), exports);
86
- __exportStar(require("./client/questionnaire-response/methods"), exports);
87
- __exportStar(require("./client/questionnaire-response/types"), exports);
17
+ __exportStar(require("./next"), exports);
@@ -17,7 +17,7 @@ export type { CreateOptions, PatchOperation } from "./resources/fhir-resource";
17
17
  export type { HealthCheck } from "./resources/health-resource";
18
18
  export type { PatientRegistration, PractitionerRegistration, RegisterResult } from "./resources/auth/registration";
19
19
  export type { SocialCredentials, SocialProvider } from "./resources/auth/social-login";
20
- export type { LastObservationsQuery, LatestObservationsParams, MeasurementCodeTypes, SaveObservationsOptions, SaveObservationsResult, } from "./resources/measurements/measurements-resource";
20
+ export type { LastObservationsQuery, LastnQuery, LatestObservationsParams, MeasurementCodeTypes, SaveObservationsOptions, SaveObservationsResult, } from "./resources/measurements/measurements-resource";
21
21
  export type { OfflineMeasurementFailure, OfflineMeasurementFlushOptions, OfflineMeasurementFlushResult, OfflineMeasurementQueueApi, } from "./resources/measurements/offline-measurement-queue";
22
22
  export type { BuildObservationsParams } from "./resources/measurements/observation-builder";
23
23
  export type { SignalsDeliveryRepair, SignalsDeliveryRepairResult, SignalsUndeliverable, SignalsUndeliverableResident, } from "./resources/signals/undeliverable-resource";
@@ -5,6 +5,7 @@ import type { Bundle, Observation } from "@medplum/fhirtypes";
5
5
  import { observationCodesForTypes } from "../../../client/observation/methods/observationsToMeasurements";
6
6
  import { HttpClient } from "../../http/http-client";
7
7
  import { RequestOptions } from "../../http/transmit";
8
+ import { QueryParams } from "../../http/url";
8
9
  import { FhirResource } from "../fhir-resource";
9
10
  import { BuildObservationsParams } from "./observation-builder";
10
11
  import { SessionSource } from "./signed-in-account";
@@ -31,6 +32,11 @@ export type LastObservationsQuery = {
31
32
  code: string;
32
33
  max?: number;
33
34
  };
35
+ /** `$lastn` search parameters: the comma-joined codes, how many of each, and any others such as `_elements`. */
36
+ export type LastnQuery = QueryParams & {
37
+ code: string;
38
+ max?: number;
39
+ };
34
40
  export type MeasurementCodeTypes = Parameters<typeof observationCodesForTypes>[0];
35
41
  export declare class MeasurementsResource {
36
42
  private readonly http;
@@ -44,8 +50,12 @@ export declare class MeasurementsResource {
44
50
  save(params: BuildObservationsParams, options?: SaveObservationsOptions): Promise<SaveObservationsResult>;
45
51
  /** One reading, main observation first, created conditionally so a retry cannot duplicate it. */
46
52
  saveObservations(observations: Observation[], options?: SaveObservationsOptions): Promise<SaveObservationsResult>;
53
+ /** Many readings, each main observation first, in as few requests as fit; a reading alone stays atomic. */
54
+ saveObservationGroups(groups: Observation[][], options?: SaveObservationsOptions): Promise<Bundle>;
47
55
  build(params: BuildObservationsParams): Promise<Observation[]>;
48
56
  latest(params: LatestObservationsParams, options?: RequestOptions): Promise<Bundle<Observation>>;
57
+ /** The patient's newest `max` observations of each code, in one request. */
58
+ lastn(patientId: string, query: LastnQuery, options?: RequestOptions): Promise<Bundle<Observation>>;
49
59
  lastForPatient(patientId: string, query: LastObservationsQuery, options?: RequestOptions): Promise<Bundle<Observation>>;
50
60
  /** The comma-joined codes the types are saved under, as `latest` and FHIR `code` searches take them. */
51
61
  codesFor(types: MeasurementCodeTypes): string;
@@ -43,6 +43,20 @@ class MeasurementsResource {
43
43
  ? { status: "saved", response }
44
44
  : { status: "queued", queueId: queued.id };
45
45
  }
46
+ /** Many readings, each main observation first, in as few requests as fit; a reading alone stays atomic. */
47
+ async saveObservationGroups(groups, options = {}) {
48
+ const { identifierSystems, replace, ...requestOptions } = options;
49
+ const entryGroups = groups
50
+ .filter((group) => group.length > 0)
51
+ .map((group) => (0, observation_bundle_utils_1.linkObservationMembers)(group).map((observation) => (0, offline_measurement_queue_1.entryForObservation)(observation, { identifierSystems, replace })));
52
+ const owner = await this.currentOwnerKey();
53
+ const responses = [];
54
+ for (const request of (0, observation_bundle_utils_1.packObservationGroups)(entryGroups)) {
55
+ const type = request.length === 1 ? "transaction" : "batch";
56
+ responses.push(await this.send({ resourceType: "Bundle", type, entry: request.flat() }, requestOptions, owner));
57
+ }
58
+ return { resourceType: "Bundle", type: "batch-response", entry: responses.flatMap((response) => { var _a; return (_a = response.entry) !== null && _a !== void 0 ? _a : []; }) };
59
+ }
46
60
  async build(params) {
47
61
  const subject = params.patientId ? `Patient/${params.patientId}` : await this.account.profileReference();
48
62
  return (0, observation_builder_1.buildObservations)(params, subject);
@@ -56,6 +70,10 @@ class MeasurementsResource {
56
70
  });
57
71
  return this.http.get(`${LATEST_OBSERVATIONS_PATH}${query}`, options);
58
72
  }
73
+ /** The patient's newest `max` observations of each code, in one request. */
74
+ lastn(patientId, query, options) {
75
+ return this.http.get(`${LATEST_OBSERVATIONS_PATH}${(0, query_string_1.toQueryString)({ ...query, patient: `Patient/${patientId}` })}`, options);
76
+ }
59
77
  lastForPatient(patientId, query, options) {
60
78
  return this.http.get(`patient/${(0, url_1.pathSegment)(patientId)}/observation${(0, query_string_1.toQueryString)(query)}`, options);
61
79
  }
package/package.json CHANGED
@@ -1,9 +1,53 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.49-dev.502+7d53087",
3
+ "version": "0.4.49-dev.504+10e7c18",
4
4
  "private": false,
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/next/index.js",
6
+ "types": "dist/next/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/next/index.d.ts",
10
+ "import": "./dist/next/index.js",
11
+ "require": "./dist/next/index.js",
12
+ "default": "./dist/next/index.js"
13
+ },
14
+ "./next": {
15
+ "types": "./dist/next/index.d.ts",
16
+ "import": "./dist/next/index.js",
17
+ "require": "./dist/next/index.js",
18
+ "default": "./dist/next/index.js"
19
+ },
20
+ "./next/react": {
21
+ "types": "./dist/next/react/index.d.ts",
22
+ "import": "./dist/next/react/index.js",
23
+ "require": "./dist/next/react/index.js",
24
+ "default": "./dist/next/react/index.js"
25
+ },
26
+ "./next/*.js": {
27
+ "types": "./dist/next/*.d.ts",
28
+ "import": "./dist/next/*.js",
29
+ "require": "./dist/next/*.js",
30
+ "default": "./dist/next/*.js"
31
+ },
32
+ "./next/*": {
33
+ "types": "./dist/next/*.d.ts",
34
+ "import": "./dist/next/*.js",
35
+ "require": "./dist/next/*.js",
36
+ "default": "./dist/next/*.js"
37
+ },
38
+ "./dist/*.js": {
39
+ "types": "./dist/*.d.ts",
40
+ "import": "./dist/*.js",
41
+ "require": "./dist/*.js",
42
+ "default": "./dist/*.js"
43
+ },
44
+ "./dist/*": {
45
+ "types": "./dist/*.d.ts",
46
+ "import": "./dist/*.js",
47
+ "require": "./dist/*.js",
48
+ "default": "./dist/*.js"
49
+ }
50
+ },
7
51
  "files": [
8
52
  "dist",
9
53
  "next"
@@ -55,20 +99,12 @@
55
99
  "typescript-eslint": "^8.15.0"
56
100
  },
57
101
  "peerDependencies": {
58
- "@medplum/core": ">=3.2.19",
59
102
  "@medplum/fhirtypes": ">=3.2.22",
60
- "@medplum/react-hooks": ">=3.2.19",
61
103
  "react": "*"
62
104
  },
63
105
  "peerDependenciesMeta": {
64
106
  "react": {
65
107
  "optional": true
66
- },
67
- "@medplum/core": {
68
- "optional": true
69
- },
70
- "@medplum/react-hooks": {
71
- "optional": true
72
108
  }
73
109
  }
74
110
  }