dhti-cli 0.1.0 → 0.3.0
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 +2 -0
- package/dist/commands/compose.d.ts +14 -0
- package/dist/commands/compose.js +112 -0
- package/dist/commands/conch.d.ts +19 -0
- package/dist/commands/conch.js +119 -0
- package/dist/commands/docker.d.ts +16 -0
- package/dist/commands/docker.js +76 -0
- package/dist/commands/elixir.d.ts +20 -0
- package/dist/commands/elixir.js +129 -0
- package/dist/commands/mimic.d.ts +9 -0
- package/dist/commands/mimic.js +157 -0
- package/dist/commands/synthetic.d.ts +17 -0
- package/dist/commands/synthetic.js +88 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/resources/docker-compose-master.yml +238 -0
- package/dist/resources/genai/Dockerfile +27 -0
- package/dist/resources/genai/README.md +1 -0
- package/dist/resources/genai/app/__init__.py +0 -0
- package/dist/resources/genai/app/bootstrap.py +43 -0
- package/dist/resources/genai/app/server.py +57 -0
- package/dist/resources/genai/pyproject.toml +84 -0
- package/dist/resources/genai/whl/placeholder.md +0 -0
- package/dist/resources/spa/Dockerfile +16 -0
- package/dist/resources/spa/def/importmap.json +39 -0
- package/dist/resources/spa/def/routes.registry.json +1599 -0
- package/dist/resources/spa/def/spa-assemble-config.json +40 -0
- package/dist/utils/bootstrap.d.ts +3 -0
- package/dist/utils/bootstrap.js +57 -0
- package/dist/utils/card.d.ts +58 -0
- package/dist/utils/card.js +76 -0
- package/dist/utils/chain.d.ts +5 -0
- package/dist/utils/chain.js +17 -0
- package/dist/utils/getCard.d.ts +3 -0
- package/dist/utils/getCard.js +11 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/request.d.ts +30 -0
- package/dist/utils/request.js +34 -0
- package/dist/utils/useDhti.d.ts +5 -0
- package/dist/utils/useDhti.js +21 -0
- package/oclif.manifest.json +442 -2
- package/package.json +7 -5
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"coreVersion": "5.4.0",
|
|
3
|
+
"frontendModules": {
|
|
4
|
+
"@openmrs/esm-home-app": "5.2.2",
|
|
5
|
+
"@openmrs/esm-patient-attachments-app": "7.0.1",
|
|
6
|
+
"@openmrs/esm-patient-flags-app": "7.0.1",
|
|
7
|
+
"@openmrs/esm-patient-appointments-app": "7.0.1",
|
|
8
|
+
"@openmrs/esm-patient-banner-app": "7.0.1",
|
|
9
|
+
"@openmrs/esm-patient-conditions-app": "7.0.1",
|
|
10
|
+
"@openmrs/esm-patient-immunizations-app": "7.0.1",
|
|
11
|
+
"@openmrs/esm-generic-patient-widgets-app": "7.0.1",
|
|
12
|
+
"@openmrs/esm-patient-chart-app": "7.0.1",
|
|
13
|
+
"@openmrs/esm-patient-forms-app": "7.0.1",
|
|
14
|
+
"@openmrs/esm-patient-labs-app": "7.0.1",
|
|
15
|
+
"@openmrs/esm-patient-programs-app": "7.0.1",
|
|
16
|
+
"@openmrs/esm-patient-orders-app": "7.0.1",
|
|
17
|
+
"@openmrs/esm-patient-list-management-app": "6.0.0",
|
|
18
|
+
"@openmrs/esm-patient-allergies-app": "7.0.1",
|
|
19
|
+
"@openmrs/esm-patient-lists-app": "7.0.1",
|
|
20
|
+
"@openmrs/esm-system-admin-app": "4.0.1",
|
|
21
|
+
"@openmrs/esm-form-entry-app": "7.0.1",
|
|
22
|
+
"@openmrs/esm-service-queues-app": "6.0.0",
|
|
23
|
+
"@openmrs/esm-patient-medications-app": "7.0.1",
|
|
24
|
+
"@openmrs/esm-patient-notes-app": "7.0.1",
|
|
25
|
+
"@openmrs/esm-patient-search-app": "6.0.0",
|
|
26
|
+
"@openmrs/esm-openconceptlab-app": "4.0.1",
|
|
27
|
+
"@openmrs/esm-login-app": "5.4.0",
|
|
28
|
+
"@openmrs/esm-active-visits-app": "6.0.0",
|
|
29
|
+
"@openmrs/esm-devtools-app": "5.4.0",
|
|
30
|
+
"@openmrs/esm-cohort-builder-app": "3.0.1-pre.183",
|
|
31
|
+
"@openmrs/esm-primary-navigation-app": "5.4.0",
|
|
32
|
+
"@openmrs/esm-patient-registration-app": "6.0.0",
|
|
33
|
+
"@openmrs/esm-implementer-tools-app": "5.4.0",
|
|
34
|
+
"@openmrs/esm-patient-vitals-app": "7.0.1",
|
|
35
|
+
"@openmrs/esm-appointments-app": "6.0.0",
|
|
36
|
+
"@openmrs/esm-dispensing-app": "1.3.0",
|
|
37
|
+
"@openmrs/esm-fast-data-entry-app": "1.0.1-pre.128",
|
|
38
|
+
"@openmrs/esm-form-builder-app": "2.3.1-pre.677"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
2
|
+
import { Ollama } from "@langchain/ollama";
|
|
3
|
+
import "reflect-metadata";
|
|
4
|
+
import { container } from "tsyringe";
|
|
5
|
+
// import { VertexAI } from "@langchain/google-vertexai";
|
|
6
|
+
// import { GoogleVertexAIEmbeddings } from "@langchain/community/embeddings/googlevertexai";
|
|
7
|
+
import { FakeListChatModel } from "@langchain/core/utils/testing";
|
|
8
|
+
const bootstrap = async () => {
|
|
9
|
+
let main_llm = null;
|
|
10
|
+
// try{
|
|
11
|
+
// const vertex = new VertexAI({
|
|
12
|
+
// temperature: 0.6,
|
|
13
|
+
// maxOutputTokens: 256,
|
|
14
|
+
// model: "gemini-pro",
|
|
15
|
+
// })
|
|
16
|
+
// main_llm = vertex;
|
|
17
|
+
// } catch (error) {
|
|
18
|
+
const ollama = new Ollama({
|
|
19
|
+
baseUrl: process.env.NEXT_PUBLIC_OLLAMA_URL || "http://localhost:11434",
|
|
20
|
+
model: process.env.NEXT_PUBLIC_OLLAMA_MODEL || "phi3:mini",
|
|
21
|
+
numPredict: 128,
|
|
22
|
+
temperature: 0.6,
|
|
23
|
+
});
|
|
24
|
+
const fake_llm = new FakeListChatModel({
|
|
25
|
+
responses: ["I'll callback later.", "You 'console' them!"],
|
|
26
|
+
});
|
|
27
|
+
main_llm = fake_llm;
|
|
28
|
+
// }
|
|
29
|
+
// const main_llm = new OllamaFunctions({
|
|
30
|
+
// temperature: 0.6,
|
|
31
|
+
// model: "phi3:mini",
|
|
32
|
+
// numPredict: 32,
|
|
33
|
+
// });
|
|
34
|
+
const gen_prompt = ChatPromptTemplate.fromMessages([
|
|
35
|
+
[
|
|
36
|
+
"system",
|
|
37
|
+
"You are a medical doctor.",
|
|
38
|
+
],
|
|
39
|
+
["human", "{input}"],
|
|
40
|
+
]);
|
|
41
|
+
const instruct_prompt = ChatPromptTemplate.fromMessages([
|
|
42
|
+
[
|
|
43
|
+
"system",
|
|
44
|
+
"You are a HL7 FHIR expert.",
|
|
45
|
+
],
|
|
46
|
+
["human", "{prompt} {input}"],
|
|
47
|
+
]);
|
|
48
|
+
const prompt = instruct_prompt;
|
|
49
|
+
container.register("main-llm", {
|
|
50
|
+
useValue: main_llm,
|
|
51
|
+
});
|
|
52
|
+
container.register("prompt", {
|
|
53
|
+
useValue: prompt,
|
|
54
|
+
});
|
|
55
|
+
return container;
|
|
56
|
+
};
|
|
57
|
+
export default bootstrap;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript models for CDS Hook Card
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* {
|
|
6
|
+
* "summary": "Patient is at high risk for opioid overdose.",
|
|
7
|
+
* "detail": "According to CDC guidelines, the patient's opioid dosage should be tapered to less than 50 MME. [Link to CDC Guideline](https://www.cdc.gov/drugoverdose/prescribing/guidelines.html)",
|
|
8
|
+
* "indicator": "warning",
|
|
9
|
+
* "source": {
|
|
10
|
+
* "label": "CDC Opioid Prescribing Guidelines",
|
|
11
|
+
* "url": "https://www.cdc.gov/drugoverdose/prescribing/guidelines.html",
|
|
12
|
+
* "icon": "https://example.org/img/cdc-icon.png"
|
|
13
|
+
* },
|
|
14
|
+
* "links": [
|
|
15
|
+
* {
|
|
16
|
+
* "label": "View MME Conversion Table",
|
|
17
|
+
* "url": "https://www.cdc.gov/drugoverdose/prescribing/mme.html"
|
|
18
|
+
* }
|
|
19
|
+
* ]
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The allowed indicators for a CDS Hook Card.
|
|
24
|
+
* Mirrors: Literal["info", "warning", "hard-stop"]
|
|
25
|
+
*/
|
|
26
|
+
export type CDSHookCardIndicator = 'hard-stop' | 'info' | 'warning';
|
|
27
|
+
/**
|
|
28
|
+
* Source of the CDS Hook Card
|
|
29
|
+
*/
|
|
30
|
+
export declare class CDSHookCardSource {
|
|
31
|
+
icon?: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
url?: string;
|
|
34
|
+
constructor(init?: Partial<CDSHookCardSource>);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Link associated with the CDS Hook Card
|
|
38
|
+
*/
|
|
39
|
+
export declare class CDSHookCardLink {
|
|
40
|
+
label?: string;
|
|
41
|
+
url?: string;
|
|
42
|
+
constructor(init?: Partial<CDSHookCardLink>);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* CDS Hook Card Model
|
|
46
|
+
*/
|
|
47
|
+
export declare class CDSHookCard {
|
|
48
|
+
detail?: string;
|
|
49
|
+
indicator?: CDSHookCardIndicator;
|
|
50
|
+
links?: CDSHookCardLink[];
|
|
51
|
+
source?: CDSHookCardSource;
|
|
52
|
+
summary?: string;
|
|
53
|
+
constructor(init?: Partial<CDSHookCard>);
|
|
54
|
+
/**
|
|
55
|
+
* Factory to build a CDSHookCard from a plain object, ensuring nested types are instantiated.
|
|
56
|
+
*/
|
|
57
|
+
static from(obj: Partial<CDSHookCard>): CDSHookCard;
|
|
58
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript models for CDS Hook Card
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* {
|
|
6
|
+
* "summary": "Patient is at high risk for opioid overdose.",
|
|
7
|
+
* "detail": "According to CDC guidelines, the patient's opioid dosage should be tapered to less than 50 MME. [Link to CDC Guideline](https://www.cdc.gov/drugoverdose/prescribing/guidelines.html)",
|
|
8
|
+
* "indicator": "warning",
|
|
9
|
+
* "source": {
|
|
10
|
+
* "label": "CDC Opioid Prescribing Guidelines",
|
|
11
|
+
* "url": "https://www.cdc.gov/drugoverdose/prescribing/guidelines.html",
|
|
12
|
+
* "icon": "https://example.org/img/cdc-icon.png"
|
|
13
|
+
* },
|
|
14
|
+
* "links": [
|
|
15
|
+
* {
|
|
16
|
+
* "label": "View MME Conversion Table",
|
|
17
|
+
* "url": "https://www.cdc.gov/drugoverdose/prescribing/mme.html"
|
|
18
|
+
* }
|
|
19
|
+
* ]
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Source of the CDS Hook Card
|
|
24
|
+
*/
|
|
25
|
+
export class CDSHookCardSource {
|
|
26
|
+
icon;
|
|
27
|
+
label;
|
|
28
|
+
url;
|
|
29
|
+
constructor(init) {
|
|
30
|
+
Object.assign(this, init);
|
|
31
|
+
// Optionally, set a default value for label if desired:
|
|
32
|
+
// if (this.label === undefined) this.label = '';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Link associated with the CDS Hook Card
|
|
37
|
+
*/
|
|
38
|
+
export class CDSHookCardLink {
|
|
39
|
+
label;
|
|
40
|
+
url;
|
|
41
|
+
constructor(init) {
|
|
42
|
+
Object.assign(this, init);
|
|
43
|
+
// Optionally, set default values for label and url if desired:
|
|
44
|
+
// if (this.label === undefined) this.label = '';
|
|
45
|
+
// if (this.url === undefined) this.url = '';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* CDS Hook Card Model
|
|
50
|
+
*/
|
|
51
|
+
export class CDSHookCard {
|
|
52
|
+
detail;
|
|
53
|
+
indicator;
|
|
54
|
+
links;
|
|
55
|
+
source;
|
|
56
|
+
summary;
|
|
57
|
+
constructor(init) {
|
|
58
|
+
if (init) {
|
|
59
|
+
// Shallow assign for primitives; nested objects handled below if present
|
|
60
|
+
const { links, source, ...rest } = init;
|
|
61
|
+
Object.assign(this, rest);
|
|
62
|
+
if (source)
|
|
63
|
+
this.source = new CDSHookCardSource(source);
|
|
64
|
+
if (links)
|
|
65
|
+
this.links = links.map((l) => new CDSHookCardLink(l));
|
|
66
|
+
}
|
|
67
|
+
// Optionally, set a default value for summary if desired:
|
|
68
|
+
// if (this.summary === undefined) this.summary = '';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Factory to build a CDSHookCard from a plain object, ensuring nested types are instantiated.
|
|
72
|
+
*/
|
|
73
|
+
static from(obj) {
|
|
74
|
+
return new CDSHookCard(obj);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StringOutputParser } from "@langchain/core/output_parsers";
|
|
2
|
+
import { RunnablePassthrough, RunnableSequence } from "@langchain/core/runnables";
|
|
3
|
+
export class ChainService {
|
|
4
|
+
container;
|
|
5
|
+
constructor(container) {
|
|
6
|
+
this.container = container;
|
|
7
|
+
}
|
|
8
|
+
async Chain(input) {
|
|
9
|
+
const output = RunnableSequence.from([
|
|
10
|
+
new RunnablePassthrough(),
|
|
11
|
+
this.container.resolve("prompt"),
|
|
12
|
+
this.container.resolve("main-llm"),
|
|
13
|
+
new StringOutputParser(),
|
|
14
|
+
]);
|
|
15
|
+
return output.invoke(input);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CDSHookCard } from './card.js';
|
|
2
|
+
const Cards = (response) => {
|
|
3
|
+
const _cards = response?.data?.cards;
|
|
4
|
+
if (Array.isArray(_cards) && _cards.length > 0) {
|
|
5
|
+
const lastCard = _cards.at(-1);
|
|
6
|
+
const card = new CDSHookCard(lastCard);
|
|
7
|
+
return [card];
|
|
8
|
+
}
|
|
9
|
+
return [new CDSHookCard()];
|
|
10
|
+
};
|
|
11
|
+
export default Cards;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDS Hook Request Model (TypeScript)
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* {
|
|
6
|
+
* "hookInstance": "d1577c69-dfbe-44ad-ba6d-3e05e953b2ea",
|
|
7
|
+
* "fhirServer": "https://example.com/fhir",
|
|
8
|
+
* "fhirAuthorization": { ... },
|
|
9
|
+
* "hook": "patient-view",
|
|
10
|
+
* "context": { ... },
|
|
11
|
+
* "prefetch": { ... }
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export declare class CDSHookRequest {
|
|
15
|
+
/** Context object passed by the EHR */
|
|
16
|
+
context?: Record<string, any> | null;
|
|
17
|
+
/** Authorization details (opaque to this model) */
|
|
18
|
+
fhirAuthorization?: Record<string, any> | null;
|
|
19
|
+
/** Base URL of the FHIR server associated with the hook */
|
|
20
|
+
fhirServer?: string;
|
|
21
|
+
/** Name of the hook (e.g., "patient-view", "order-select", etc.) */
|
|
22
|
+
hook?: string;
|
|
23
|
+
/** A unique identifier for this hook invocation */
|
|
24
|
+
hookInstance?: string;
|
|
25
|
+
/** Prefetched FHIR resources keyed by name */
|
|
26
|
+
prefetch?: Record<string, any> | null;
|
|
27
|
+
constructor(init?: Partial<CDSHookRequest>);
|
|
28
|
+
/** Factory to build a CDSHookRequest from a plain object. */
|
|
29
|
+
static from(obj: Partial<CDSHookRequest>): CDSHookRequest;
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDS Hook Request Model (TypeScript)
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* {
|
|
6
|
+
* "hookInstance": "d1577c69-dfbe-44ad-ba6d-3e05e953b2ea",
|
|
7
|
+
* "fhirServer": "https://example.com/fhir",
|
|
8
|
+
* "fhirAuthorization": { ... },
|
|
9
|
+
* "hook": "patient-view",
|
|
10
|
+
* "context": { ... },
|
|
11
|
+
* "prefetch": { ... }
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export class CDSHookRequest {
|
|
15
|
+
/** Context object passed by the EHR */
|
|
16
|
+
context;
|
|
17
|
+
/** Authorization details (opaque to this model) */
|
|
18
|
+
fhirAuthorization;
|
|
19
|
+
/** Base URL of the FHIR server associated with the hook */
|
|
20
|
+
fhirServer;
|
|
21
|
+
/** Name of the hook (e.g., "patient-view", "order-select", etc.) */
|
|
22
|
+
hook;
|
|
23
|
+
/** A unique identifier for this hook invocation */
|
|
24
|
+
hookInstance;
|
|
25
|
+
/** Prefetched FHIR resources keyed by name */
|
|
26
|
+
prefetch;
|
|
27
|
+
constructor(init) {
|
|
28
|
+
Object.assign(this, init);
|
|
29
|
+
}
|
|
30
|
+
/** Factory to build a CDSHookRequest from a plain object. */
|
|
31
|
+
static from(obj) {
|
|
32
|
+
return new CDSHookRequest(obj);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { CDSHookRequest } from './request.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sends a CDS Hook Request where the request.context contains the user's input message.
|
|
5
|
+
*/
|
|
6
|
+
const handleBundle = (newMessage) => {
|
|
7
|
+
const request = new CDSHookRequest({
|
|
8
|
+
context: { input: newMessage },
|
|
9
|
+
});
|
|
10
|
+
// TODO: Investigate why nested input is required
|
|
11
|
+
const _request = {
|
|
12
|
+
input: request,
|
|
13
|
+
};
|
|
14
|
+
const endpoint = process.env.LANGSERVE_POST_ENDPOINT || '/langserve/dhti_elixir_template/cds-services/dhti-service';
|
|
15
|
+
return axios.post(endpoint, {
|
|
16
|
+
config: {},
|
|
17
|
+
input: _request,
|
|
18
|
+
kwargs: {},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export default handleBundle;
|