medpromptjs 0.1.1 → 0.2.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 +3 -28
- package/dist/agent.d.ts +31 -0
- package/dist/chain.d.ts +32 -0
- package/dist/index.d.ts +3 -3
- package/dist/medpromptjs.cjs.development.js +215 -243
- package/dist/medpromptjs.cjs.development.js.map +1 -1
- package/dist/medpromptjs.cjs.production.min.js +1 -1
- package/dist/medpromptjs.cjs.production.min.js.map +1 -1
- package/dist/medpromptjs.esm.js +214 -243
- package/dist/medpromptjs.esm.js.map +1 -1
- package/dist/mydi.d.ts +17 -0
- package/dist/tool.d.ts +27 -0
- package/package.json +2 -2
- package/src/agent.ts +79 -0
- package/src/chain.ts +72 -0
- package/src/index.ts +3 -5
- package/src/mydi.ts +25 -0
- package/src/tool.ts +59 -0
- package/dist/agents/explain_agent.d.ts +0 -6
- package/dist/agents/index.d.ts +0 -2
- package/dist/bootstrap.d.ts +0 -1
- package/dist/chains/index.d.ts +0 -2
- package/dist/chains/self_gen_cot_chain.d.ts +0 -26
- package/dist/server/index.d.ts +0 -3
- package/dist/server/sample_app.d.ts +0 -3
- package/dist/tools/find_patient.d.ts +0 -19
- package/dist/tools/index.d.ts +0 -2
- package/dist/utils/fhir_server.d.ts +0 -4
- package/dist/utils/get_medical_record.d.ts +0 -8
- package/dist/utils/hapi_server.d.ts +0 -5
- package/dist/utils/index.d.ts +0 -4
- package/src/agents/explain_agent.ts +0 -37
- package/src/agents/index.ts +0 -4
- package/src/bootstrap.ts +0 -17
- package/src/chains/index.ts +0 -2
- package/src/chains/self_gen_cot_chain.ts +0 -82
- package/src/server/index.ts +0 -5
- package/src/server/sample_app.js +0 -47
- package/src/server/sample_app.ts +0 -51
- package/src/tools/find_patient.ts +0 -51
- package/src/tools/index.ts +0 -4
- package/src/utils/fhir_server.ts +0 -11
- package/src/utils/get_medical_record.ts +0 -44
- package/src/utils/hapi_server.ts +0 -19
- package/src/utils/index.ts +0 -6
package/src/utils/fhir_server.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import "../bootstrap";
|
|
2
|
-
import { autoInjectable, inject, injectable } from "tsyringe";
|
|
3
|
-
import { FhirServer } from "./fhir_server";
|
|
4
|
-
import { Logger } from "tslog";
|
|
5
|
-
|
|
6
|
-
const logger = new Logger({ name: "MedpromptLogger" });
|
|
7
|
-
|
|
8
|
-
@autoInjectable()
|
|
9
|
-
export class GetMedicalRecord {
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
@inject("FhirServer")
|
|
13
|
-
private fhir_server: FhirServer,
|
|
14
|
-
) {}
|
|
15
|
-
|
|
16
|
-
async get(
|
|
17
|
-
patient_id: string,
|
|
18
|
-
): Promise<any> {
|
|
19
|
-
const query = this.format_query(patient_id)
|
|
20
|
-
logger.info(`query: ${query}`)
|
|
21
|
-
logger.info(`fhir_server: ${this.fhir_server.baseUrl}`)
|
|
22
|
-
const response = await this.fhir_server.call_fhir_server(
|
|
23
|
-
"",
|
|
24
|
-
query,
|
|
25
|
-
);
|
|
26
|
-
if (response.total != 0) {
|
|
27
|
-
return response;
|
|
28
|
-
} else {
|
|
29
|
-
return "No data found";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
format_query(patient_id: string): string {
|
|
34
|
-
let query = "Patient?"
|
|
35
|
-
if (patient_id) {
|
|
36
|
-
query += `_id=${patient_id}`
|
|
37
|
-
query += "&_revinclude=Observation:subject"
|
|
38
|
-
query += "&_revinclude=Condition:subject"
|
|
39
|
-
query += "&_revinclude=Procedure:subject"
|
|
40
|
-
query += "&_revinclude=MedicationRequest:subject"
|
|
41
|
-
}
|
|
42
|
-
return query
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/utils/hapi_server.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FhirServer } from "./fhir_server";
|
|
2
|
-
import { Logger } from "tslog";
|
|
3
|
-
|
|
4
|
-
const logger = new Logger({ name: "MedpromptLogger" });
|
|
5
|
-
|
|
6
|
-
export class HapiFhirServer extends FhirServer {
|
|
7
|
-
|
|
8
|
-
baseUrl: string = 'http://hapi.fhir.org/baseR4/';
|
|
9
|
-
|
|
10
|
-
async call_fhir_server(url: string, params: string) {
|
|
11
|
-
const _url_with_params = `${this.baseUrl}${url}${params}`
|
|
12
|
-
logger.info(`url_with_params: ${_url_with_params}`)
|
|
13
|
-
const response = await fetch(
|
|
14
|
-
_url_with_params,
|
|
15
|
-
);
|
|
16
|
-
const data = await response.json();
|
|
17
|
-
return data;
|
|
18
|
-
}
|
|
19
|
-
}
|