@ovok/core 0.2.47
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/README.md +40 -0
- package/dist/client/ai-fhir/methods/AIFhirResources.d.ts +14 -0
- package/dist/client/ai-fhir/methods/AIFhirResources.js +16 -0
- package/dist/client/ai-fhir/methods/index.d.ts +1 -0
- package/dist/client/ai-fhir/methods/index.js +17 -0
- package/dist/client/ai-fhir/types/AIFhirPlan.d.ts +6 -0
- package/dist/client/ai-fhir/types/AIFhirPlan.js +2 -0
- package/dist/client/ai-fhir/types/AIFhirPlanRequest.d.ts +5 -0
- package/dist/client/ai-fhir/types/AIFhirPlanRequest.js +2 -0
- package/dist/client/ai-fhir/types/AIFhirRequest.d.ts +7 -0
- package/dist/client/ai-fhir/types/AIFhirRequest.js +2 -0
- package/dist/client/ai-fhir/types/AIFhirResponse.d.ts +18 -0
- package/dist/client/ai-fhir/types/AIFhirResponse.js +2 -0
- package/dist/client/ai-fhir/types/index.d.ts +4 -0
- package/dist/client/ai-fhir/types/index.js +20 -0
- package/dist/client/auth/methods/appleLogin.d.ts +4 -0
- package/dist/client/auth/methods/appleLogin.js +11 -0
- package/dist/client/auth/methods/changePassword.d.ts +4 -0
- package/dist/client/auth/methods/changePassword.js +6 -0
- package/dist/client/auth/methods/googleLogin.d.ts +4 -0
- package/dist/client/auth/methods/googleLogin.js +11 -0
- package/dist/client/auth/methods/index.d.ts +8 -0
- package/dist/client/auth/methods/index.js +24 -0
- package/dist/client/auth/methods/login.d.ts +4 -0
- package/dist/client/auth/methods/login.js +38 -0
- package/dist/client/auth/methods/refetchProfile.d.ts +2 -0
- package/dist/client/auth/methods/refetchProfile.js +9 -0
- package/dist/client/auth/methods/register.d.ts +4 -0
- package/dist/client/auth/methods/register.js +15 -0
- package/dist/client/auth/methods/requestDeleteUser.d.ts +11 -0
- package/dist/client/auth/methods/requestDeleteUser.js +13 -0
- package/dist/client/auth/methods/resetPassword.d.ts +13 -0
- package/dist/client/auth/methods/resetPassword.js +19 -0
- package/dist/client/auth/types/AppleLoginBody.d.ts +68 -0
- package/dist/client/auth/types/AppleLoginBody.js +17 -0
- package/dist/client/auth/types/AuthResponse.d.ts +15 -0
- package/dist/client/auth/types/AuthResponse.js +2 -0
- package/dist/client/auth/types/ChangePasswordBody.d.ts +5 -0
- package/dist/client/auth/types/ChangePasswordBody.js +2 -0
- package/dist/client/auth/types/GoogleLoginBody.d.ts +26 -0
- package/dist/client/auth/types/GoogleLoginBody.js +2 -0
- package/dist/client/auth/types/LoginBody.d.ts +26 -0
- package/dist/client/auth/types/LoginBody.js +2 -0
- package/dist/client/auth/types/RegisterBody.d.ts +8 -0
- package/dist/client/auth/types/RegisterBody.js +2 -0
- package/dist/client/auth/types/RequestDeleteUserBody.d.ts +11 -0
- package/dist/client/auth/types/RequestDeleteUserBody.js +2 -0
- package/dist/client/auth/types/RequestDeleteUserResponse.d.ts +12 -0
- package/dist/client/auth/types/RequestDeleteUserResponse.js +2 -0
- package/dist/client/auth/types/ResetPasswordBody.d.ts +14 -0
- package/dist/client/auth/types/ResetPasswordBody.js +2 -0
- package/dist/client/auth/types/StartLoginResponse.d.ts +34 -0
- package/dist/client/auth/types/StartLoginResponse.js +2 -0
- package/dist/client/bot/methods/executeBot.d.ts +10 -0
- package/dist/client/bot/methods/executeBot.js +14 -0
- package/dist/client/bot/methods/index.d.ts +1 -0
- package/dist/client/bot/methods/index.js +17 -0
- package/dist/client/chat/ai/methods/createAiSession.d.ts +4 -0
- package/dist/client/chat/ai/methods/createAiSession.js +17 -0
- package/dist/client/chat/ai/methods/index.d.ts +1 -0
- package/dist/client/chat/ai/methods/index.js +17 -0
- package/dist/client/chat/ai/types/CreateAiSessionProps.d.ts +51 -0
- package/dist/client/chat/ai/types/CreateAiSessionProps.js +2 -0
- package/dist/client/chat/ai/types/CreateAiSessionResponse.d.ts +21 -0
- package/dist/client/chat/ai/types/CreateAiSessionResponse.js +2 -0
- package/dist/client/chat/ai/types/SessionMessagesResponse.d.ts +9 -0
- package/dist/client/chat/ai/types/SessionMessagesResponse.js +2 -0
- package/dist/client/observation/methods/generateObservationBodiesByMeasurement.d.ts +4 -0
- package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +40 -0
- package/dist/client/observation/methods/getLatestObservationsByCodes.d.ts +4 -0
- package/dist/client/observation/methods/getLatestObservationsByCodes.js +19 -0
- package/dist/client/observation/methods/index.d.ts +2 -0
- package/dist/client/observation/methods/index.js +18 -0
- package/dist/client/observation/services/base-observation-service.d.ts +22 -0
- package/dist/client/observation/services/base-observation-service.js +70 -0
- package/dist/client/observation/services/blood-glucose.d.ts +12 -0
- package/dist/client/observation/services/blood-glucose.js +36 -0
- package/dist/client/observation/services/blood-oxygen.d.ts +14 -0
- package/dist/client/observation/services/blood-oxygen.js +57 -0
- package/dist/client/observation/services/blood-pressure.d.ts +15 -0
- package/dist/client/observation/services/blood-pressure.js +72 -0
- package/dist/client/observation/services/body-temperature.d.ts +13 -0
- package/dist/client/observation/services/body-temperature.js +36 -0
- package/dist/client/observation/services/body-weight.d.ts +13 -0
- package/dist/client/observation/services/body-weight.js +36 -0
- package/dist/client/observation/services/creator.d.ts +10 -0
- package/dist/client/observation/services/creator.js +54 -0
- package/dist/client/observation/services/ecg.d.ts +16 -0
- package/dist/client/observation/services/ecg.js +110 -0
- package/dist/client/observation/services/heart-rate-variability.d.ts +13 -0
- package/dist/client/observation/services/heart-rate-variability.js +38 -0
- package/dist/client/observation/services/heart-rate.d.ts +13 -0
- package/dist/client/observation/services/heart-rate.js +39 -0
- package/dist/client/observation/services/index.d.ts +1 -0
- package/dist/client/observation/services/index.js +17 -0
- package/dist/client/observation/services/respiratory-rate.d.ts +13 -0
- package/dist/client/observation/services/respiratory-rate.js +38 -0
- package/dist/client/observation/services/resting-heart-rate.d.ts +13 -0
- package/dist/client/observation/services/resting-heart-rate.js +38 -0
- package/dist/client/observation/services/step-count.d.ts +15 -0
- package/dist/client/observation/services/step-count.js +55 -0
- package/dist/client/observation/services/uric-acid-service.d.ts +21 -0
- package/dist/client/observation/services/uric-acid-service.js +120 -0
- package/dist/client/observation/services/vo2-max.d.ts +13 -0
- package/dist/client/observation/services/vo2-max.js +38 -0
- package/dist/client/observation/services/walking-heart-rate-average.d.ts +12 -0
- package/dist/client/observation/services/walking-heart-rate-average.js +38 -0
- package/dist/client/observation/types/GetLatestObservationsByCodeParams.d.ts +9 -0
- package/dist/client/observation/types/GetLatestObservationsByCodeParams.js +2 -0
- package/dist/client/observation/types/IObservationService.d.ts +15 -0
- package/dist/client/observation/types/IObservationService.js +2 -0
- package/dist/client/observation/types/MeasurementTypeKey.d.ts +20 -0
- package/dist/client/observation/types/MeasurementTypeKey.js +24 -0
- package/dist/client/observation/types/ObservationCode.d.ts +37 -0
- package/dist/client/observation/types/ObservationCode.js +41 -0
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +641 -0
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +45 -0
- package/dist/client/observation/types/generate-measurement/Sample.d.ts +32 -0
- package/dist/client/observation/types/generate-measurement/Sample.js +2 -0
- package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.d.ts +1 -0
- package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.js +2 -0
- package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +7 -0
- package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.js +2 -0
- package/dist/client/observation/types/generate-observation-body/ObservationValue.d.ts +14 -0
- package/dist/client/observation/types/generate-observation-body/ObservationValue.js +2 -0
- package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/BloodPressureMeasurement.d.ts +10 -0
- package/dist/client/observation/types/measurement/BloodPressureMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/BloodPressureStates.d.ts +7 -0
- package/dist/client/observation/types/measurement/BloodPressureStates.js +11 -0
- package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/BodyWeightMeasurmement.d.ts +7 -0
- package/dist/client/observation/types/measurement/BodyWeightMeasurmement.js +2 -0
- package/dist/client/observation/types/measurement/EcgDiagnosticFlag.d.ts +15 -0
- package/dist/client/observation/types/measurement/EcgDiagnosticFlag.js +19 -0
- package/dist/client/observation/types/measurement/EcgMeasurement.d.ts +13 -0
- package/dist/client/observation/types/measurement/EcgMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/HeartRateMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/HeartRateMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/Measurement.d.ts +4 -0
- package/dist/client/observation/types/measurement/Measurement.js +2 -0
- package/dist/client/observation/types/measurement/MeasurementDevice.d.ts +7 -0
- package/dist/client/observation/types/measurement/MeasurementDevice.js +2 -0
- package/dist/client/observation/types/measurement/PulseOximeterMeasurement.d.ts +9 -0
- package/dist/client/observation/types/measurement/PulseOximeterMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/SpirometryMeasurement.d.ts +21 -0
- package/dist/client/observation/types/measurement/SpirometryMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/StepCountMeasurement.d.ts +8 -0
- package/dist/client/observation/types/measurement/StepCountMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.d.ts +23 -0
- package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/Vo2MaxMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/Vo2MaxMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/index.d.ts +11 -0
- package/dist/client/observation/types/measurement/index.js +27 -0
- package/dist/client/observation/types/service/ObservationMetadata.d.ts +8 -0
- package/dist/client/observation/types/service/ObservationMetadata.js +2 -0
- package/dist/client/observation/utils/getDeviceObject.d.ts +3 -0
- package/dist/client/observation/utils/getDeviceObject.js +34 -0
- package/dist/client/observation/utils/getObservationValueDisplay.d.ts +15 -0
- package/dist/client/observation/utils/getObservationValueDisplay.js +25 -0
- package/dist/client/observation/utils/index.d.ts +1 -0
- package/dist/client/observation/utils/index.js +17 -0
- package/dist/client/ovok-client.d.ts +35 -0
- package/dist/client/ovok-client.js +85 -0
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.d.ts +3 -0
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +28 -0
- package/dist/client/questionnaire-response/methods/index.d.ts +1 -0
- package/dist/client/questionnaire-response/methods/index.js +17 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +58 -0
- package/dist/index.d.ts +666 -0
- package/dist/index.js +49 -0
- package/dist/types/ValidationError.d.ts +6 -0
- package/dist/types/ValidationError.js +2 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.js +38 -0
- package/dist/utils/auth/exchange-code.d.ts +14 -0
- package/dist/utils/auth/exchange-code.js +17 -0
- package/dist/utils/auth/generate-code-challenge-and-verifier.d.ts +6 -0
- package/dist/utils/auth/generate-code-challenge-and-verifier.js +45 -0
- package/dist/utils/auth/handle-tenant-code.d.ts +6 -0
- package/dist/utils/auth/handle-tenant-code.js +21 -0
- package/dist/utils/auth/sha256.d.ts +8 -0
- package/dist/utils/auth/sha256.js +300 -0
- package/dist/utils/auth/start-login.d.ts +10 -0
- package/dist/utils/auth/start-login.js +19 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/patch/getPatchOperationType.d.ts +2 -0
- package/dist/utils/patch/getPatchOperationType.js +16 -0
- package/package.json +83 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ResetPasswordBody {
|
|
2
|
+
/**
|
|
3
|
+
* The email address of the user to reset the password for
|
|
4
|
+
*/
|
|
5
|
+
email: string;
|
|
6
|
+
/**
|
|
7
|
+
* The type of user to reset the password for
|
|
8
|
+
*/
|
|
9
|
+
type: "Patient" | "Practitioner";
|
|
10
|
+
/**
|
|
11
|
+
* The client ID to use for the request
|
|
12
|
+
*/
|
|
13
|
+
clientId?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ContactPoint, HumanName, Patient, Practitioner, ProjectLink, Reference } from "@medplum/fhirtypes";
|
|
2
|
+
export interface StartLoginResponse {
|
|
3
|
+
nextStep: string;
|
|
4
|
+
sessionCode: string;
|
|
5
|
+
profiles?: ProfileElement[];
|
|
6
|
+
}
|
|
7
|
+
interface ProfileElement {
|
|
8
|
+
tenantCode: string;
|
|
9
|
+
project: Project;
|
|
10
|
+
profile: ProfileProfile;
|
|
11
|
+
}
|
|
12
|
+
interface ProfileProfile {
|
|
13
|
+
resourceType: "Practitioner" | "Patient";
|
|
14
|
+
meta: Meta;
|
|
15
|
+
name: HumanName[];
|
|
16
|
+
telecom: ContactPoint[];
|
|
17
|
+
id: string;
|
|
18
|
+
gender: string;
|
|
19
|
+
birthDate: string;
|
|
20
|
+
active: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface Meta {
|
|
23
|
+
project: string;
|
|
24
|
+
compartment: ProjectLink[];
|
|
25
|
+
versionId: string;
|
|
26
|
+
lastUpdated: Date;
|
|
27
|
+
author: Reference<Practitioner> | Reference<Patient>;
|
|
28
|
+
}
|
|
29
|
+
interface Project {
|
|
30
|
+
id: string;
|
|
31
|
+
resourceType: "Project";
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OvokClient } from "../../ovok-client";
|
|
2
|
+
/**
|
|
3
|
+
* Executes a bot by identifier using the Ovok API
|
|
4
|
+
* Implementation based on https://ovok-internal.readme.io/reference/botscontroller_execbotbyidentifierpost
|
|
5
|
+
*
|
|
6
|
+
* @param identifier Bot identifier in format "system|value" (e.g. "https://example.com|get-users")
|
|
7
|
+
* @param parameters Additional parameters to pass to the bot
|
|
8
|
+
* @returns Promise with the bot execution result
|
|
9
|
+
*/
|
|
10
|
+
export declare function executeBot(this: OvokClient, identifier: string, parameters: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeBot = executeBot;
|
|
4
|
+
/**
|
|
5
|
+
* Executes a bot by identifier using the Ovok API
|
|
6
|
+
* Implementation based on https://ovok-internal.readme.io/reference/botscontroller_execbotbyidentifierpost
|
|
7
|
+
*
|
|
8
|
+
* @param identifier Bot identifier in format "system|value" (e.g. "https://example.com|get-users")
|
|
9
|
+
* @param parameters Additional parameters to pass to the bot
|
|
10
|
+
* @returns Promise with the bot execution result
|
|
11
|
+
*/
|
|
12
|
+
async function executeBot(identifier, parameters) {
|
|
13
|
+
return this.post(`/bots?identifier=${encodeURIComponent(identifier)}`, parameters, "application/json");
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./executeBot";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./executeBot"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OvokClient } from "../../../ovok-client";
|
|
2
|
+
import { CreateAiSessionProps } from "../types/CreateAiSessionProps";
|
|
3
|
+
import { CreateAiSessionResponse } from "../types/CreateAiSessionResponse";
|
|
4
|
+
export declare function createAiSession(this: OvokClient, props: CreateAiSessionProps): Promise<CreateAiSessionResponse>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAiSession = createAiSession;
|
|
4
|
+
const core_1 = require("@medplum/core");
|
|
5
|
+
async function createAiSession(props) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const participant = (_a = props.participant) !== null && _a !== void 0 ? _a : (0, core_1.getReferenceString)((_b = (await this.getProfileAsync())) !== null && _b !== void 0 ? _b : {});
|
|
8
|
+
if (!participant) {
|
|
9
|
+
throw new Error("Participant not found");
|
|
10
|
+
}
|
|
11
|
+
return this.post("/ai/session", {
|
|
12
|
+
assistant: props.assistant,
|
|
13
|
+
title: props.title,
|
|
14
|
+
participant,
|
|
15
|
+
messages: props.messages,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./createAiSession";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./createAiSession"), exports);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for creating a chat session between a user and an AI participant.
|
|
3
|
+
* Requires Socket.IO connection to receive AI replies.
|
|
4
|
+
*/
|
|
5
|
+
export interface CreateAiSessionProps {
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the AI assistant
|
|
8
|
+
*/
|
|
9
|
+
assistant: {
|
|
10
|
+
/**
|
|
11
|
+
* System prompt that defines AI assistant's behavior and constraints
|
|
12
|
+
*/
|
|
13
|
+
system: string;
|
|
14
|
+
/**
|
|
15
|
+
* The Practitioner resource reference that represents the AI assistant
|
|
16
|
+
* Format: "Practitioner/{id}"
|
|
17
|
+
*/
|
|
18
|
+
participant: string;
|
|
19
|
+
/**
|
|
20
|
+
* Number of last messages to consider for context for the AI Assistant
|
|
21
|
+
*/
|
|
22
|
+
history: number;
|
|
23
|
+
/**
|
|
24
|
+
* List of FHIR resource queries to fetch latest data for AI context
|
|
25
|
+
*/
|
|
26
|
+
context: string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Title of the chat session
|
|
30
|
+
*/
|
|
31
|
+
title: string;
|
|
32
|
+
/**
|
|
33
|
+
* The Patient resource reference that represents the user, if not provided, the current user will be used
|
|
34
|
+
* Format: "Patient/{id}"
|
|
35
|
+
*/
|
|
36
|
+
participant?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Initial messages to start the conversation
|
|
39
|
+
*/
|
|
40
|
+
messages: {
|
|
41
|
+
/**
|
|
42
|
+
* Resource reference of the message sender
|
|
43
|
+
* Format: "Practitioner/{id}" or "Patient/{id}"
|
|
44
|
+
*/
|
|
45
|
+
sender: string;
|
|
46
|
+
/**
|
|
47
|
+
* Content of the message
|
|
48
|
+
*/
|
|
49
|
+
content: string;
|
|
50
|
+
}[];
|
|
51
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CreateAiSessionResponse {
|
|
2
|
+
title: string;
|
|
3
|
+
reference: `Communication/${string}`;
|
|
4
|
+
participant: string;
|
|
5
|
+
messages: Message[];
|
|
6
|
+
assistant: Assistant;
|
|
7
|
+
}
|
|
8
|
+
interface Message {
|
|
9
|
+
content: string;
|
|
10
|
+
mode: "assistant" | "user";
|
|
11
|
+
reference: `Communication/${string}`;
|
|
12
|
+
sender: string;
|
|
13
|
+
sentAt: string;
|
|
14
|
+
}
|
|
15
|
+
interface Assistant {
|
|
16
|
+
system: string;
|
|
17
|
+
participant: string;
|
|
18
|
+
history: number;
|
|
19
|
+
context: string[];
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Observation } from "@medplum/fhirtypes";
|
|
2
|
+
import { OvokClient } from "../../ovok-client";
|
|
3
|
+
import { GenerateObservationBodyParams } from "../types/generate-observation-body/GenerateObservationBodyParams";
|
|
4
|
+
export declare function generateObservationBodiesByMeasurement(this: OvokClient, params: GenerateObservationBodyParams): Promise<Observation[]>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateObservationBodiesByMeasurement = generateObservationBodiesByMeasurement;
|
|
4
|
+
const core_1 = require("@medplum/core");
|
|
5
|
+
const creator_1 = require("../services/creator");
|
|
6
|
+
const getDeviceObject_1 = require("../utils/getDeviceObject");
|
|
7
|
+
const getPatientReference = async (client, patientId) => {
|
|
8
|
+
if (patientId) {
|
|
9
|
+
return `Patient/${patientId}`;
|
|
10
|
+
}
|
|
11
|
+
const profile = (await client.getProfileAsync());
|
|
12
|
+
return (0, core_1.getReferenceString)(profile);
|
|
13
|
+
};
|
|
14
|
+
async function generateObservationBodiesByMeasurement(params) {
|
|
15
|
+
const { device, measurement } = params;
|
|
16
|
+
const measurementTypeKey = measurement.measurementTypeKey;
|
|
17
|
+
const patientReference = await getPatientReference(this, params.patientId);
|
|
18
|
+
const observationService = creator_1.ObservationServiceCreator.getInstance().getService(measurementTypeKey);
|
|
19
|
+
const observationCodes = observationService.getObservationCodes();
|
|
20
|
+
const values = observationService.generateValues(measurement);
|
|
21
|
+
const additionalProperties = observationService.getAdditionalProperties(measurement);
|
|
22
|
+
const deviceObject = (0, getDeviceObject_1.getDeviceObject)(device);
|
|
23
|
+
const observationBodies = observationCodes.map((code, index) => ({
|
|
24
|
+
resourceType: "Observation",
|
|
25
|
+
status: "registered",
|
|
26
|
+
subject: {
|
|
27
|
+
reference: patientReference,
|
|
28
|
+
},
|
|
29
|
+
device: deviceObject,
|
|
30
|
+
...values[index],
|
|
31
|
+
code,
|
|
32
|
+
...(additionalProperties[index] || {}),
|
|
33
|
+
}));
|
|
34
|
+
return observationBodies.filter((observation) => {
|
|
35
|
+
var _a, _b, _c, _d, _e;
|
|
36
|
+
return ((_a = observation.valueQuantity) === null || _a === void 0 ? void 0 : _a.value) ||
|
|
37
|
+
((_b = observation.valueSampledData) === null || _b === void 0 ? void 0 : _b.data) ||
|
|
38
|
+
((_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);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Bundle, Observation } from "@medplum/fhirtypes";
|
|
2
|
+
import { OvokClient } from "../../ovok-client";
|
|
3
|
+
import { GetLatestObservationsByCodeParams } from "../types/GetLatestObservationsByCodeParams";
|
|
4
|
+
export declare function getLatestObservationsByCodes(this: OvokClient, params: GetLatestObservationsByCodeParams): Promise<Bundle<Observation>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLatestObservationsByCodes = getLatestObservationsByCodes;
|
|
4
|
+
async function getLatestObservationsByCodes(params) {
|
|
5
|
+
var _a;
|
|
6
|
+
let patientId = "patientId" in params ? params.patientId : "";
|
|
7
|
+
if (params.me) {
|
|
8
|
+
const currentUser = await this.getProfileAsync();
|
|
9
|
+
patientId = (_a = currentUser === null || currentUser === void 0 ? void 0 : currentUser.id) !== null && _a !== void 0 ? _a : "";
|
|
10
|
+
}
|
|
11
|
+
const codes = params.codes.join(",");
|
|
12
|
+
const urlParams = new URLSearchParams({
|
|
13
|
+
max: "1",
|
|
14
|
+
code: codes,
|
|
15
|
+
patient: `Patient/${patientId}`,
|
|
16
|
+
...(params.date ? { date: `ge${params.date}` } : {}),
|
|
17
|
+
});
|
|
18
|
+
return this.get(`/fhir/Observation/$lastn?${urlParams.toString()}`);
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getLatestObservationsByCodes"), exports);
|
|
18
|
+
__exportStar(require("./generateObservationBodiesByMeasurement"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CodeableConcept, Observation } from "@medplum/fhirtypes";
|
|
2
|
+
import { MeasurementTypeKey } from "../../../types";
|
|
3
|
+
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
4
|
+
import { Sample } from "../types/generate-measurement/Sample";
|
|
5
|
+
import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
|
|
6
|
+
import { IObservationService } from "../types/IObservationService";
|
|
7
|
+
import { Measurement } from "../types/measurement/Measurement";
|
|
8
|
+
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
9
|
+
export declare abstract class BaseObservationService<T extends Measurement> implements IObservationService {
|
|
10
|
+
protected abstract observationMetadata: ObservationMetadata<T>[];
|
|
11
|
+
protected abstract measurementTypeKey: MeasurementTypeKey;
|
|
12
|
+
protected abstract measurementTypeName: string;
|
|
13
|
+
abstract convertSamplesToMeasurement(samples: Sample[]): T;
|
|
14
|
+
abstract convertRecordToMeasurement(record: RecordResult<RecordType>): T;
|
|
15
|
+
protected getCastedMeasurement(measurement: Measurement): T;
|
|
16
|
+
generateValues(measurement: Measurement): ObservationValue[];
|
|
17
|
+
getObservationCodes(): CodeableConcept[];
|
|
18
|
+
getAdditionalProperties(_measurement: Measurement): Partial<Observation>[];
|
|
19
|
+
getUnits(): string[];
|
|
20
|
+
getMeasurementDisplay(measurement: Measurement): string;
|
|
21
|
+
getObservationDisplay(observations: Observation[]): string | undefined;
|
|
22
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseObservationService = void 0;
|
|
4
|
+
class BaseObservationService {
|
|
5
|
+
getCastedMeasurement(measurement) {
|
|
6
|
+
if (measurement.measurementTypeKey !== this.measurementTypeKey) {
|
|
7
|
+
throw new Error(`Measurement is not a ${this.measurementTypeName} measurement`);
|
|
8
|
+
}
|
|
9
|
+
return measurement;
|
|
10
|
+
}
|
|
11
|
+
generateValues(measurement) {
|
|
12
|
+
const castedMeasurement = this.getCastedMeasurement(measurement);
|
|
13
|
+
return this.observationMetadata.map((metadata) => {
|
|
14
|
+
const value = castedMeasurement[metadata.valueKey];
|
|
15
|
+
if (value === undefined) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
const numberValue = Number(value);
|
|
19
|
+
if (Number.isNaN(numberValue)) {
|
|
20
|
+
throw new Error(`${metadata.valueKey} must be a number but got ${value}`);
|
|
21
|
+
}
|
|
22
|
+
const fixedValue = numberValue.toFixed(metadata.toFixed);
|
|
23
|
+
return {
|
|
24
|
+
valueQuantity: {
|
|
25
|
+
value: Number(fixedValue),
|
|
26
|
+
unit: metadata.unit,
|
|
27
|
+
code: metadata.primaryCode,
|
|
28
|
+
system: "http://loinc.org",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getObservationCodes() {
|
|
34
|
+
return this.observationMetadata.map((metadata) => ({
|
|
35
|
+
coding: [
|
|
36
|
+
{
|
|
37
|
+
code: metadata.primaryCode,
|
|
38
|
+
display: metadata.display,
|
|
39
|
+
system: "http://loinc.org",
|
|
40
|
+
},
|
|
41
|
+
...metadata.additionalCodes.map((code) => ({
|
|
42
|
+
code,
|
|
43
|
+
display: metadata.display,
|
|
44
|
+
system: "http://loinc.org",
|
|
45
|
+
})),
|
|
46
|
+
],
|
|
47
|
+
text: metadata.display,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
getAdditionalProperties(_measurement) {
|
|
51
|
+
return Object.values(this.observationMetadata).map(() => ({
|
|
52
|
+
effectiveDateTime: new Date().toISOString(),
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
getUnits() {
|
|
56
|
+
return this.observationMetadata.map((metadata) => metadata.unit);
|
|
57
|
+
}
|
|
58
|
+
getMeasurementDisplay(measurement) {
|
|
59
|
+
const castedMeasurement = this.getCastedMeasurement(measurement);
|
|
60
|
+
const firstMetadata = this.observationMetadata[0];
|
|
61
|
+
const value = castedMeasurement[firstMetadata.valueKey];
|
|
62
|
+
return `${value !== null && value !== void 0 ? value : 0}`;
|
|
63
|
+
}
|
|
64
|
+
getObservationDisplay(observations) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
const value = (_b = (_a = observations[0]) === null || _a === void 0 ? void 0 : _a.valueQuantity) === null || _b === void 0 ? void 0 : _b.value;
|
|
67
|
+
return value !== undefined && value !== null ? value.toString() : undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.BaseObservationService = BaseObservationService;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BloodGlucoseMeasurement, MeasurementTypeKey } from "../../../types";
|
|
2
|
+
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
3
|
+
import { Sample } from "../types/generate-measurement/Sample";
|
|
4
|
+
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
5
|
+
import { BaseObservationService } from "./base-observation-service";
|
|
6
|
+
export declare class BloodGlucoseService extends BaseObservationService<BloodGlucoseMeasurement> {
|
|
7
|
+
protected measurementTypeKey: MeasurementTypeKey;
|
|
8
|
+
protected measurementTypeName: string;
|
|
9
|
+
protected observationMetadata: ObservationMetadata<BloodGlucoseMeasurement>[];
|
|
10
|
+
convertSamplesToMeasurement(samples: Sample[]): BloodGlucoseMeasurement;
|
|
11
|
+
convertRecordToMeasurement(record: RecordResult<RecordType>): BloodGlucoseMeasurement;
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BloodGlucoseService = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const base_observation_service_1 = require("./base-observation-service");
|
|
6
|
+
class BloodGlucoseService extends base_observation_service_1.BaseObservationService {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.measurementTypeKey = types_1.MeasurementTypeKey.bloodGlucose;
|
|
10
|
+
this.measurementTypeName = "blood glucose";
|
|
11
|
+
this.observationMetadata = [
|
|
12
|
+
{
|
|
13
|
+
primaryCode: types_1.ObservationCode.BLOOD_GLUCOSE,
|
|
14
|
+
additionalCodes: [],
|
|
15
|
+
display: "Blood Glucose",
|
|
16
|
+
unit: "mg/dL",
|
|
17
|
+
valueKey: "bloodGlucose",
|
|
18
|
+
toFixed: 1,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
convertSamplesToMeasurement(samples) {
|
|
23
|
+
return {
|
|
24
|
+
bloodGlucose: samples.length > 0 ? samples[0].quantity : undefined,
|
|
25
|
+
measurementTypeKey: types_1.MeasurementTypeKey.bloodGlucose,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
convertRecordToMeasurement(record) {
|
|
29
|
+
const bloodGlucoseRecord = record;
|
|
30
|
+
return {
|
|
31
|
+
bloodGlucose: bloodGlucoseRecord.level.inMilligramsPerDeciliter,
|
|
32
|
+
measurementTypeKey: types_1.MeasurementTypeKey.bloodGlucose,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.BloodGlucoseService = BloodGlucoseService;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Measurement, MeasurementTypeKey } from "../../../types";
|
|
2
|
+
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
3
|
+
import { Sample } from "../types/generate-measurement/Sample";
|
|
4
|
+
import { PulseOximeterMeasurement } from "../types/measurement/PulseOximeterMeasurement";
|
|
5
|
+
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
6
|
+
import { BaseObservationService } from "./base-observation-service";
|
|
7
|
+
export declare class BloodOxygenService extends BaseObservationService<PulseOximeterMeasurement> {
|
|
8
|
+
protected measurementTypeKey: MeasurementTypeKey;
|
|
9
|
+
protected measurementTypeName: string;
|
|
10
|
+
protected observationMetadata: ObservationMetadata<PulseOximeterMeasurement>[];
|
|
11
|
+
getMeasurementDisplay(measurement: Measurement): string;
|
|
12
|
+
convertSamplesToMeasurement(samples: Sample[]): PulseOximeterMeasurement;
|
|
13
|
+
convertRecordToMeasurement(record: RecordResult<RecordType>): PulseOximeterMeasurement;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BloodOxygenService = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const base_observation_service_1 = require("./base-observation-service");
|
|
6
|
+
class BloodOxygenService extends base_observation_service_1.BaseObservationService {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.measurementTypeKey = types_1.MeasurementTypeKey.bloodOxygenPulseRate;
|
|
10
|
+
this.measurementTypeName = "blood oxygen";
|
|
11
|
+
this.observationMetadata = [
|
|
12
|
+
{
|
|
13
|
+
primaryCode: types_1.ObservationCode.OXYGEN_SATURATION,
|
|
14
|
+
additionalCodes: [],
|
|
15
|
+
display: "Oxygen Saturation",
|
|
16
|
+
unit: "%",
|
|
17
|
+
valueKey: "bloodOxygen",
|
|
18
|
+
toFixed: 0,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
primaryCode: types_1.ObservationCode.OXYGEN_SATURATION_HEART_RATE,
|
|
22
|
+
additionalCodes: [types_1.ObservationCode.HEART_RATE],
|
|
23
|
+
display: "Heart Rate",
|
|
24
|
+
unit: "bpm",
|
|
25
|
+
valueKey: "pulseRate",
|
|
26
|
+
toFixed: 0,
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
getMeasurementDisplay(measurement) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const castedMeasurement = this.getCastedMeasurement(measurement);
|
|
33
|
+
return `${(_a = castedMeasurement.pulseRate) !== null && _a !== void 0 ? _a : 0}/${(_b = castedMeasurement.bloodOxygen) !== null && _b !== void 0 ? _b : 0}`;
|
|
34
|
+
}
|
|
35
|
+
convertSamplesToMeasurement(samples) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const pulseRate = (_a = samples.find((x) => x.quantityType === "HKQuantityTypeIdentifierHeartRate")) === null || _a === void 0 ? void 0 : _a.quantity;
|
|
38
|
+
const bloodOxygenQuantity = (_b = samples.find((x) => x.quantityType === "HKQuantityTypeIdentifierOxygenSaturation")) === null || _b === void 0 ? void 0 : _b.quantity;
|
|
39
|
+
const bloodOxygen = bloodOxygenQuantity
|
|
40
|
+
? bloodOxygenQuantity * 100
|
|
41
|
+
: undefined;
|
|
42
|
+
return {
|
|
43
|
+
pulseRate,
|
|
44
|
+
bloodOxygen,
|
|
45
|
+
measurementTypeKey: types_1.MeasurementTypeKey.bloodOxygenPulseRate,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
convertRecordToMeasurement(record) {
|
|
49
|
+
const pulseOximeterRecord = record;
|
|
50
|
+
return {
|
|
51
|
+
pulseRate: 0,
|
|
52
|
+
bloodOxygen: pulseOximeterRecord.percentage,
|
|
53
|
+
measurementTypeKey: types_1.MeasurementTypeKey.bloodOxygenPulseRate,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.BloodOxygenService = BloodOxygenService;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observation } from "@medplum/fhirtypes";
|
|
2
|
+
import { BloodPressureMeasurement, Measurement, MeasurementTypeKey } from "../../../types";
|
|
3
|
+
import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
|
|
4
|
+
import { Sample } from "../types/generate-measurement/Sample";
|
|
5
|
+
import { ObservationMetadata } from "../types/service/ObservationMetadata";
|
|
6
|
+
import { BaseObservationService } from "./base-observation-service";
|
|
7
|
+
export declare class BloodPressureService extends BaseObservationService<BloodPressureMeasurement> {
|
|
8
|
+
protected measurementTypeKey: MeasurementTypeKey;
|
|
9
|
+
protected measurementTypeName: string;
|
|
10
|
+
protected observationMetadata: ObservationMetadata<BloodPressureMeasurement>[];
|
|
11
|
+
getMeasurementDisplay(measurement: Measurement): string;
|
|
12
|
+
getObservationDisplay(observations: Observation[]): string | undefined;
|
|
13
|
+
convertSamplesToMeasurement(samples: Sample[]): BloodPressureMeasurement;
|
|
14
|
+
convertRecordToMeasurement(record: RecordResult<RecordType>): BloodPressureMeasurement;
|
|
15
|
+
}
|