@ovok/core 0.4.49-dev.502 → 0.4.49-dev.503
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.
|
@@ -48,7 +48,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
|
|
|
48
48
|
description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
|
|
49
49
|
software: {
|
|
50
50
|
name: "@ovok/core",
|
|
51
|
-
version: "0.4.49-dev.
|
|
51
|
+
version: "0.4.49-dev.503+81b3d6a",
|
|
52
52
|
},
|
|
53
53
|
fhirVersion: "4.0.1",
|
|
54
54
|
format: ["json"],
|
package/dist/next/index.d.ts
CHANGED
|
@@ -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
|
}
|