phenoml 0.0.17 → 0.0.19

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.
Files changed (64) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/construe/types/ExtractRequestConfig.d.ts +6 -1
  3. package/dist/cjs/api/resources/lang2Fhir/client/Client.d.ts +22 -3
  4. package/dist/cjs/api/resources/lang2Fhir/client/Client.js +78 -3
  5. package/dist/cjs/api/resources/lang2Fhir/client/requests/CreateMultiRequest.d.ts +14 -0
  6. package/dist/cjs/api/resources/lang2Fhir/client/requests/CreateMultiRequest.js +3 -0
  7. package/dist/cjs/api/resources/lang2Fhir/client/requests/ProfileUploadRequest.d.ts +3 -3
  8. package/dist/cjs/api/resources/lang2Fhir/client/requests/index.d.ts +1 -0
  9. package/dist/cjs/api/resources/lang2Fhir/types/CreateMultiResponse.d.ts +47 -0
  10. package/dist/cjs/api/resources/lang2Fhir/types/CreateMultiResponse.js +3 -0
  11. package/dist/cjs/api/resources/lang2Fhir/types/index.d.ts +1 -0
  12. package/dist/cjs/api/resources/lang2Fhir/types/index.js +1 -0
  13. package/dist/cjs/api/resources/summary/client/Client.d.ts +2 -1
  14. package/dist/cjs/api/resources/summary/client/Client.js +2 -1
  15. package/dist/cjs/api/resources/summary/client/requests/CreateSummaryRequest.d.ts +15 -2
  16. package/dist/cjs/api/resources/summary/client/requests/CreateSummaryRequest.js +2 -0
  17. package/dist/cjs/api/resources/summary/types/ErrorResponse.d.ts +5 -0
  18. package/dist/cjs/api/resources/summary/types/ErrorResponse.js +3 -0
  19. package/dist/cjs/api/resources/summary/types/index.d.ts +1 -0
  20. package/dist/cjs/api/resources/summary/types/index.js +1 -0
  21. package/dist/cjs/api/resources/tools/client/Client.d.ts +26 -0
  22. package/dist/cjs/api/resources/tools/client/Client.js +91 -0
  23. package/dist/cjs/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.d.ts +27 -0
  24. package/dist/cjs/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.js +3 -0
  25. package/dist/cjs/api/resources/tools/client/requests/index.d.ts +1 -0
  26. package/dist/cjs/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.d.ts +31 -0
  27. package/dist/cjs/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.js +3 -0
  28. package/dist/cjs/api/resources/tools/types/index.d.ts +1 -0
  29. package/dist/cjs/api/resources/tools/types/index.js +1 -0
  30. package/dist/cjs/version.d.ts +1 -1
  31. package/dist/cjs/version.js +1 -1
  32. package/dist/esm/Client.mjs +2 -2
  33. package/dist/esm/api/resources/construe/types/ExtractRequestConfig.d.mts +6 -1
  34. package/dist/esm/api/resources/lang2Fhir/client/Client.d.mts +22 -3
  35. package/dist/esm/api/resources/lang2Fhir/client/Client.mjs +78 -3
  36. package/dist/esm/api/resources/lang2Fhir/client/requests/CreateMultiRequest.d.mts +14 -0
  37. package/dist/esm/api/resources/lang2Fhir/client/requests/CreateMultiRequest.mjs +2 -0
  38. package/dist/esm/api/resources/lang2Fhir/client/requests/ProfileUploadRequest.d.mts +3 -3
  39. package/dist/esm/api/resources/lang2Fhir/client/requests/index.d.mts +1 -0
  40. package/dist/esm/api/resources/lang2Fhir/types/CreateMultiResponse.d.mts +47 -0
  41. package/dist/esm/api/resources/lang2Fhir/types/CreateMultiResponse.mjs +2 -0
  42. package/dist/esm/api/resources/lang2Fhir/types/index.d.mts +1 -0
  43. package/dist/esm/api/resources/lang2Fhir/types/index.mjs +1 -0
  44. package/dist/esm/api/resources/summary/client/Client.d.mts +2 -1
  45. package/dist/esm/api/resources/summary/client/Client.mjs +2 -1
  46. package/dist/esm/api/resources/summary/client/requests/CreateSummaryRequest.d.mts +15 -2
  47. package/dist/esm/api/resources/summary/client/requests/CreateSummaryRequest.mjs +2 -0
  48. package/dist/esm/api/resources/summary/types/ErrorResponse.d.mts +5 -0
  49. package/dist/esm/api/resources/summary/types/ErrorResponse.mjs +2 -0
  50. package/dist/esm/api/resources/summary/types/index.d.mts +1 -0
  51. package/dist/esm/api/resources/summary/types/index.mjs +1 -0
  52. package/dist/esm/api/resources/tools/client/Client.d.mts +26 -0
  53. package/dist/esm/api/resources/tools/client/Client.mjs +91 -0
  54. package/dist/esm/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.d.mts +27 -0
  55. package/dist/esm/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.mjs +2 -0
  56. package/dist/esm/api/resources/tools/client/requests/index.d.mts +1 -0
  57. package/dist/esm/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.d.mts +31 -0
  58. package/dist/esm/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.mjs +2 -0
  59. package/dist/esm/api/resources/tools/types/index.d.mts +1 -0
  60. package/dist/esm/api/resources/tools/types/index.mjs +1 -0
  61. package/dist/esm/version.d.mts +1 -1
  62. package/dist/esm/version.mjs +1 -1
  63. package/package.json +1 -1
  64. package/reference.md +144 -4
@@ -1,7 +1,12 @@
1
1
  export interface ExtractRequestConfig {
2
2
  /** Method for splitting input text into chunks before code extraction */
3
3
  chunking_method?: ExtractRequestConfig.ChunkingMethod;
4
- /** Maximum number of codes to extract per chunk */
4
+ /**
5
+ * Maximum number of codes to extract per chunk. If not specified, uses system-specific defaults:
6
+ * * SNOMED: 10
7
+ * * LOINC, HPO, RXNORM: 20
8
+ * * All other systems: 5
9
+ */
5
10
  max_codes_per_chunk?: number;
6
11
  /** Threshold for filtering similar codes (0.0-1.0) */
7
12
  code_similarity_filter?: number;
@@ -29,6 +29,25 @@ export declare class Lang2Fhir {
29
29
  */
30
30
  create(request: phenoml.lang2Fhir.CreateRequest, requestOptions?: Lang2Fhir.RequestOptions): core.HttpResponsePromise<phenoml.lang2Fhir.FhirResource>;
31
31
  private __create;
32
+ /**
33
+ * Analyzes natural language text and extracts multiple FHIR resources, returning them as a transaction Bundle.
34
+ * Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types from the text.
35
+ * Resources are linked with proper references (e.g., Conditions reference the Patient).
36
+ *
37
+ * @param {phenoml.lang2Fhir.CreateMultiRequest} request
38
+ * @param {Lang2Fhir.RequestOptions} requestOptions - Request-specific configuration.
39
+ *
40
+ * @throws {@link phenoml.lang2Fhir.BadRequestError}
41
+ * @throws {@link phenoml.lang2Fhir.UnauthorizedError}
42
+ * @throws {@link phenoml.lang2Fhir.InternalServerError}
43
+ *
44
+ * @example
45
+ * await client.lang2Fhir.createMulti({
46
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily."
47
+ * })
48
+ */
49
+ createMulti(request: phenoml.lang2Fhir.CreateMultiRequest, requestOptions?: Lang2Fhir.RequestOptions): core.HttpResponsePromise<phenoml.lang2Fhir.CreateMultiResponse>;
50
+ private __createMulti;
32
51
  /**
33
52
  * Converts natural language text into FHIR search parameters
34
53
  *
@@ -60,9 +79,9 @@ export declare class Lang2Fhir {
60
79
  *
61
80
  * @example
62
81
  * await client.lang2Fhir.uploadProfile({
63
- * version: "version",
64
- * resource: "custom-patient",
65
- * profile: "profile"
82
+ * version: "R4",
83
+ * resource: "condition-encounter-diagnosis",
84
+ * profile: "(base64 encoded JSON string of the FHIR profile)"
66
85
  * })
67
86
  */
68
87
  uploadProfile(request: phenoml.lang2Fhir.ProfileUploadRequest, requestOptions?: Lang2Fhir.RequestOptions): core.HttpResponsePromise<phenoml.lang2Fhir.Lang2FhirUploadProfileResponse>;
@@ -89,6 +89,81 @@ export class Lang2Fhir {
89
89
  }
90
90
  });
91
91
  }
92
+ /**
93
+ * Analyzes natural language text and extracts multiple FHIR resources, returning them as a transaction Bundle.
94
+ * Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types from the text.
95
+ * Resources are linked with proper references (e.g., Conditions reference the Patient).
96
+ *
97
+ * @param {phenoml.lang2Fhir.CreateMultiRequest} request
98
+ * @param {Lang2Fhir.RequestOptions} requestOptions - Request-specific configuration.
99
+ *
100
+ * @throws {@link phenoml.lang2Fhir.BadRequestError}
101
+ * @throws {@link phenoml.lang2Fhir.UnauthorizedError}
102
+ * @throws {@link phenoml.lang2Fhir.InternalServerError}
103
+ *
104
+ * @example
105
+ * await client.lang2Fhir.createMulti({
106
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily."
107
+ * })
108
+ */
109
+ createMulti(request, requestOptions) {
110
+ return core.HttpResponsePromise.fromPromise(this.__createMulti(request, requestOptions));
111
+ }
112
+ __createMulti(request, requestOptions) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
115
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
116
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
117
+ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.phenomlEnvironment.Default, "lang2fhir/create/multi"),
118
+ method: "POST",
119
+ headers: _headers,
120
+ contentType: "application/json",
121
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
122
+ requestType: "json",
123
+ body: request,
124
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
125
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
126
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
127
+ });
128
+ if (_response.ok) {
129
+ return {
130
+ data: _response.body,
131
+ rawResponse: _response.rawResponse,
132
+ };
133
+ }
134
+ if (_response.error.reason === "status-code") {
135
+ switch (_response.error.statusCode) {
136
+ case 400:
137
+ throw new phenoml.lang2Fhir.BadRequestError(_response.error.body, _response.rawResponse);
138
+ case 401:
139
+ throw new phenoml.lang2Fhir.UnauthorizedError(_response.error.body, _response.rawResponse);
140
+ case 500:
141
+ throw new phenoml.lang2Fhir.InternalServerError(_response.error.body, _response.rawResponse);
142
+ default:
143
+ throw new errors.phenomlError({
144
+ statusCode: _response.error.statusCode,
145
+ body: _response.error.body,
146
+ rawResponse: _response.rawResponse,
147
+ });
148
+ }
149
+ }
150
+ switch (_response.error.reason) {
151
+ case "non-json":
152
+ throw new errors.phenomlError({
153
+ statusCode: _response.error.statusCode,
154
+ body: _response.error.rawBody,
155
+ rawResponse: _response.rawResponse,
156
+ });
157
+ case "timeout":
158
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling POST /lang2fhir/create/multi.");
159
+ case "unknown":
160
+ throw new errors.phenomlError({
161
+ message: _response.error.errorMessage,
162
+ rawResponse: _response.rawResponse,
163
+ });
164
+ }
165
+ });
166
+ }
92
167
  /**
93
168
  * Converts natural language text into FHIR search parameters
94
169
  *
@@ -175,9 +250,9 @@ export class Lang2Fhir {
175
250
  *
176
251
  * @example
177
252
  * await client.lang2Fhir.uploadProfile({
178
- * version: "version",
179
- * resource: "custom-patient",
180
- * profile: "profile"
253
+ * version: "R4",
254
+ * resource: "condition-encounter-diagnosis",
255
+ * profile: "(base64 encoded JSON string of the FHIR profile)"
181
256
  * })
182
257
  */
183
258
  uploadProfile(request, requestOptions) {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily."
5
+ * }
6
+ */
7
+ export interface CreateMultiRequest {
8
+ /** Natural language text containing multiple clinical concepts to extract */
9
+ text: string;
10
+ /** FHIR version to use */
11
+ version?: string;
12
+ /** Optional FHIR provider name for provider-specific profiles */
13
+ provider?: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @example
3
3
  * {
4
- * version: "version",
5
- * resource: "custom-patient",
6
- * profile: "profile"
4
+ * version: "R4",
5
+ * resource: "condition-encounter-diagnosis",
6
+ * profile: "(base64 encoded JSON string of the FHIR profile)"
7
7
  * }
8
8
  */
9
9
  export interface ProfileUploadRequest {
@@ -1,3 +1,4 @@
1
+ export type { CreateMultiRequest } from "./CreateMultiRequest.mjs";
1
2
  export type { CreateRequest } from "./CreateRequest.mjs";
2
3
  export type { DocumentRequest } from "./DocumentRequest.mjs";
3
4
  export type { ProfileUploadRequest } from "./ProfileUploadRequest.mjs";
@@ -0,0 +1,47 @@
1
+ export interface CreateMultiResponse {
2
+ /** Whether extraction was successful */
3
+ success?: boolean;
4
+ /** Status message */
5
+ message?: string;
6
+ /** FHIR transaction Bundle containing all extracted resources */
7
+ bundle?: CreateMultiResponse.Bundle;
8
+ /** Summary of extracted resources */
9
+ resources?: CreateMultiResponse.Resources.Item[];
10
+ }
11
+ export declare namespace CreateMultiResponse {
12
+ /**
13
+ * FHIR transaction Bundle containing all extracted resources
14
+ */
15
+ interface Bundle {
16
+ resourceType?: string;
17
+ type?: string;
18
+ entry?: Bundle.Entry.Item[];
19
+ }
20
+ namespace Bundle {
21
+ type Entry = Entry.Item[];
22
+ namespace Entry {
23
+ interface Item {
24
+ fullUrl?: string;
25
+ resource?: Record<string, unknown>;
26
+ request?: Item.Request;
27
+ }
28
+ namespace Item {
29
+ interface Request {
30
+ method?: string;
31
+ url?: string;
32
+ }
33
+ }
34
+ }
35
+ }
36
+ type Resources = Resources.Item[];
37
+ namespace Resources {
38
+ interface Item {
39
+ /** Temporary UUID for the resource */
40
+ tempId?: string;
41
+ /** FHIR resource type */
42
+ resourceType?: string;
43
+ /** Text excerpt this resource was extracted from */
44
+ description?: string;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,3 +1,4 @@
1
+ export * from "./CreateMultiResponse.mjs";
1
2
  export * from "./FhirResource.mjs";
2
3
  export * from "./Lang2FhirUploadProfileResponse.mjs";
3
4
  export * from "./SearchResponse.mjs";
@@ -1,3 +1,4 @@
1
+ export * from "./CreateMultiResponse.mjs";
1
2
  export * from "./FhirResource.mjs";
2
3
  export * from "./Lang2FhirUploadProfileResponse.mjs";
3
4
  export * from "./SearchResponse.mjs";
@@ -99,9 +99,10 @@ export declare class Summary {
99
99
  deleteTemplate(id: string, requestOptions?: Summary.RequestOptions): core.HttpResponsePromise<phenoml.summary.SummaryDeleteTemplateResponse>;
100
100
  private __deleteTemplate;
101
101
  /**
102
- * Creates a summary from FHIR resources using one of two modes:
102
+ * Creates a summary from FHIR resources using one of three modes:
103
103
  * - **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
104
104
  * - **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
105
+ * - **ips**: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs.
105
106
  *
106
107
  * @param {phenoml.summary.CreateSummaryRequest} request
107
108
  * @param {Summary.RequestOptions} requestOptions - Request-specific configuration.
@@ -383,9 +383,10 @@ export class Summary {
383
383
  });
384
384
  }
385
385
  /**
386
- * Creates a summary from FHIR resources using one of two modes:
386
+ * Creates a summary from FHIR resources using one of three modes:
387
387
  * - **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
388
388
  * - **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
389
+ * - **ips**: Generates an International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG. Requires a Bundle with exactly one Patient resource (returns 400 error if no Patient or multiple Patients are present). Automatically filters resources to those referencing the patient and generates sections for allergies, medications, problems, immunizations, procedures, and vital signs.
389
390
  *
390
391
  * @param {phenoml.summary.CreateSummaryRequest} request
391
392
  * @param {Summary.RequestOptions} requestOptions - Request-specific configuration.
@@ -12,11 +12,18 @@ export interface CreateSummaryRequest {
12
12
  * Summary generation mode:
13
13
  * - narrative: Substitute FHIR data into a template (requires template_id)
14
14
  * - flatten: Flatten FHIR resources for RAG/search (no template needed)
15
+ * - ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
15
16
  */
16
17
  mode?: CreateSummaryRequest.Mode;
17
18
  /** ID of the template to use (required for narrative mode) */
18
19
  template_id?: string;
19
- /** FHIR resources (single resource or Bundle) */
20
+ /**
21
+ * FHIR resources (single resource or Bundle).
22
+ * For IPS mode, must be a Bundle containing exactly one Patient resource with at least one
23
+ * identifier (id, fullUrl, or identifier field). Returns an error if no Patient is found,
24
+ * if multiple Patients are present, or if the Patient has no identifiers. Resources are
25
+ * automatically filtered to only include those referencing the patient.
26
+ */
20
27
  fhir_resources: CreateSummaryRequest.FhirResources;
21
28
  }
22
29
  export declare namespace CreateSummaryRequest {
@@ -24,14 +31,20 @@ export declare namespace CreateSummaryRequest {
24
31
  * Summary generation mode:
25
32
  * - narrative: Substitute FHIR data into a template (requires template_id)
26
33
  * - flatten: Flatten FHIR resources for RAG/search (no template needed)
34
+ * - ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
27
35
  */
28
36
  const Mode: {
29
37
  readonly Narrative: "narrative";
30
38
  readonly Flatten: "flatten";
39
+ readonly Ips: "ips";
31
40
  };
32
41
  type Mode = (typeof Mode)[keyof typeof Mode];
33
42
  /**
34
- * FHIR resources (single resource or Bundle)
43
+ * FHIR resources (single resource or Bundle).
44
+ * For IPS mode, must be a Bundle containing exactly one Patient resource with at least one
45
+ * identifier (id, fullUrl, or identifier field). Returns an error if no Patient is found,
46
+ * if multiple Patients are present, or if the Patient has no identifiers. Resources are
47
+ * automatically filtered to only include those referencing the patient.
35
48
  */
36
49
  type FhirResources = phenoml.summary.FhirResource | phenoml.summary.FhirBundle;
37
50
  }
@@ -5,9 +5,11 @@ export var CreateSummaryRequest;
5
5
  * Summary generation mode:
6
6
  * - narrative: Substitute FHIR data into a template (requires template_id)
7
7
  * - flatten: Flatten FHIR resources for RAG/search (no template needed)
8
+ * - ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
8
9
  */
9
10
  CreateSummaryRequest.Mode = {
10
11
  Narrative: "narrative",
11
12
  Flatten: "flatten",
13
+ Ips: "ips",
12
14
  };
13
15
  })(CreateSummaryRequest || (CreateSummaryRequest = {}));
@@ -0,0 +1,5 @@
1
+ export interface ErrorResponse {
2
+ success?: boolean;
3
+ /** Error message describing what went wrong */
4
+ error?: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,5 +1,6 @@
1
1
  export * from "./CreateSummaryResponse.mjs";
2
2
  export * from "./CreateSummaryTemplateResponse.mjs";
3
+ export * from "./ErrorResponse.mjs";
3
4
  export * from "./FhirBundle.mjs";
4
5
  export * from "./FhirResource.mjs";
5
6
  export * from "./SummaryDeleteTemplateResponse.mjs";
@@ -1,5 +1,6 @@
1
1
  export * from "./CreateSummaryResponse.mjs";
2
2
  export * from "./CreateSummaryTemplateResponse.mjs";
3
+ export * from "./ErrorResponse.mjs";
3
4
  export * from "./FhirBundle.mjs";
4
5
  export * from "./FhirResource.mjs";
5
6
  export * from "./SummaryDeleteTemplateResponse.mjs";
@@ -35,6 +35,32 @@ export declare class Tools {
35
35
  */
36
36
  createFhirResource(request: phenoml.tools.Lang2FhirAndCreateRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<phenoml.tools.Lang2FhirAndCreateResponse>;
37
37
  private __createFhirResource;
38
+ /**
39
+ * Extracts multiple FHIR resources from natural language text and stores them in a FHIR server.
40
+ * Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types.
41
+ * Resources are linked with proper references and submitted as a transaction bundle.
42
+ * For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically
43
+ * resolve them via PUT requests after the initial bundle creation.
44
+ *
45
+ * @param {phenoml.tools.Lang2FhirAndCreateMultiRequest} request
46
+ * @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
47
+ *
48
+ * @throws {@link phenoml.tools.BadRequestError}
49
+ * @throws {@link phenoml.tools.UnauthorizedError}
50
+ * @throws {@link phenoml.tools.ForbiddenError}
51
+ * @throws {@link phenoml.tools.FailedDependencyError}
52
+ * @throws {@link phenoml.tools.InternalServerError}
53
+ *
54
+ * @example
55
+ * await client.tools.createFhirResourcesMulti({
56
+ * "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
57
+ * "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
58
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
59
+ * provider: "medplum"
60
+ * })
61
+ */
62
+ createFhirResourcesMulti(request: phenoml.tools.Lang2FhirAndCreateMultiRequest, requestOptions?: Tools.RequestOptions): core.HttpResponsePromise<phenoml.tools.Lang2FhirAndCreateMultiResponse>;
63
+ private __createFhirResourcesMulti;
38
64
  /**
39
65
  * Converts natural language to FHIR search parameters and executes search in FHIR server
40
66
  *
@@ -120,6 +120,97 @@ export class Tools {
120
120
  }
121
121
  });
122
122
  }
123
+ /**
124
+ * Extracts multiple FHIR resources from natural language text and stores them in a FHIR server.
125
+ * Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types.
126
+ * Resources are linked with proper references and submitted as a transaction bundle.
127
+ * For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically
128
+ * resolve them via PUT requests after the initial bundle creation.
129
+ *
130
+ * @param {phenoml.tools.Lang2FhirAndCreateMultiRequest} request
131
+ * @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
132
+ *
133
+ * @throws {@link phenoml.tools.BadRequestError}
134
+ * @throws {@link phenoml.tools.UnauthorizedError}
135
+ * @throws {@link phenoml.tools.ForbiddenError}
136
+ * @throws {@link phenoml.tools.FailedDependencyError}
137
+ * @throws {@link phenoml.tools.InternalServerError}
138
+ *
139
+ * @example
140
+ * await client.tools.createFhirResourcesMulti({
141
+ * "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
142
+ * "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
143
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
144
+ * provider: "medplum"
145
+ * })
146
+ */
147
+ createFhirResourcesMulti(request, requestOptions) {
148
+ return core.HttpResponsePromise.fromPromise(this.__createFhirResourcesMulti(request, requestOptions));
149
+ }
150
+ __createFhirResourcesMulti(request, requestOptions) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
153
+ const { "X-Phenoml-On-Behalf-Of": phenomlOnBehalfOf, "X-Phenoml-Fhir-Provider": phenomlFhirProvider } = request, _body = __rest(request, ["X-Phenoml-On-Behalf-Of", "X-Phenoml-Fhir-Provider"]);
154
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({
155
+ Authorization: yield this._getAuthorizationHeader(),
156
+ "X-Phenoml-On-Behalf-Of": phenomlOnBehalfOf != null ? phenomlOnBehalfOf : undefined,
157
+ "X-Phenoml-Fhir-Provider": phenomlFhirProvider != null ? phenomlFhirProvider : undefined,
158
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
159
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
160
+ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.phenomlEnvironment.Default, "tools/lang2fhir-and-create-multi"),
161
+ method: "POST",
162
+ headers: _headers,
163
+ contentType: "application/json",
164
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
165
+ requestType: "json",
166
+ body: _body,
167
+ timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
168
+ maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
169
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
170
+ });
171
+ if (_response.ok) {
172
+ return {
173
+ data: _response.body,
174
+ rawResponse: _response.rawResponse,
175
+ };
176
+ }
177
+ if (_response.error.reason === "status-code") {
178
+ switch (_response.error.statusCode) {
179
+ case 400:
180
+ throw new phenoml.tools.BadRequestError(_response.error.body, _response.rawResponse);
181
+ case 401:
182
+ throw new phenoml.tools.UnauthorizedError(_response.error.body, _response.rawResponse);
183
+ case 403:
184
+ throw new phenoml.tools.ForbiddenError(_response.error.body, _response.rawResponse);
185
+ case 424:
186
+ throw new phenoml.tools.FailedDependencyError(_response.error.body, _response.rawResponse);
187
+ case 500:
188
+ throw new phenoml.tools.InternalServerError(_response.error.body, _response.rawResponse);
189
+ default:
190
+ throw new errors.phenomlError({
191
+ statusCode: _response.error.statusCode,
192
+ body: _response.error.body,
193
+ rawResponse: _response.rawResponse,
194
+ });
195
+ }
196
+ }
197
+ switch (_response.error.reason) {
198
+ case "non-json":
199
+ throw new errors.phenomlError({
200
+ statusCode: _response.error.statusCode,
201
+ body: _response.error.rawBody,
202
+ rawResponse: _response.rawResponse,
203
+ });
204
+ case "timeout":
205
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling POST /tools/lang2fhir-and-create-multi.");
206
+ case "unknown":
207
+ throw new errors.phenomlError({
208
+ message: _response.error.errorMessage,
209
+ rawResponse: _response.rawResponse,
210
+ });
211
+ }
212
+ });
213
+ }
123
214
  /**
124
215
  * Converts natural language to FHIR search parameters and executes search in FHIR server
125
216
  *
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
5
+ * "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
6
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
7
+ * provider: "medplum"
8
+ * }
9
+ */
10
+ export interface Lang2FhirAndCreateMultiRequest {
11
+ /**
12
+ * Optional header for on-behalf-of authentication. Used when making requests on behalf of another user or entity.
13
+ * Must be in the format: Patient/{uuid} or Practitioner/{uuid}
14
+ */
15
+ "X-Phenoml-On-Behalf-Of"?: string;
16
+ /**
17
+ * Optional header for FHIR provider authentication. Contains credentials in the format {fhir_provider_id}:{oauth2_token}.
18
+ * Multiple FHIR provider integrations can be provided as comma-separated values.
19
+ */
20
+ "X-Phenoml-Fhir-Provider"?: string;
21
+ /** Natural language text containing multiple clinical concepts to extract */
22
+ text: string;
23
+ /** FHIR version to use */
24
+ version?: string;
25
+ /** FHIR provider ID or name */
26
+ provider: string;
27
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,3 +1,4 @@
1
1
  export type { CohortRequest } from "./CohortRequest.mjs";
2
+ export type { Lang2FhirAndCreateMultiRequest } from "./Lang2FhirAndCreateMultiRequest.mjs";
2
3
  export type { Lang2FhirAndCreateRequest } from "./Lang2FhirAndCreateRequest.mjs";
3
4
  export type { Lang2FhirAndSearchRequest } from "./Lang2FhirAndSearchRequest.mjs";
@@ -0,0 +1,31 @@
1
+ export interface Lang2FhirAndCreateMultiResponse {
2
+ /** Whether the resources were created successfully */
3
+ success?: boolean;
4
+ /** Status message */
5
+ message?: string;
6
+ /** FHIR transaction-response Bundle from the server with resolved resource IDs */
7
+ response_bundle?: Lang2FhirAndCreateMultiResponse.ResponseBundle;
8
+ /** Metadata about created resources (temp IDs, types, descriptions) */
9
+ resource_info?: Lang2FhirAndCreateMultiResponse.ResourceInfo.Item[];
10
+ }
11
+ export declare namespace Lang2FhirAndCreateMultiResponse {
12
+ /**
13
+ * FHIR transaction-response Bundle from the server with resolved resource IDs
14
+ */
15
+ interface ResponseBundle {
16
+ resourceType?: string;
17
+ type?: string;
18
+ entry?: Record<string, unknown>[];
19
+ }
20
+ type ResourceInfo = ResourceInfo.Item[];
21
+ namespace ResourceInfo {
22
+ interface Item {
23
+ /** Original temporary UUID */
24
+ tempId?: string;
25
+ /** FHIR resource type */
26
+ resourceType?: string;
27
+ /** Text excerpt this resource was extracted from */
28
+ description?: string;
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from "./CohortResponse.mjs";
2
+ export * from "./Lang2FhirAndCreateMultiResponse.mjs";
2
3
  export * from "./Lang2FhirAndCreateResponse.mjs";
3
4
  export * from "./Lang2FhirAndSearchResponse.mjs";
4
5
  export * from "./McpServerResponse.mjs";
@@ -1,4 +1,5 @@
1
1
  export * from "./CohortResponse.mjs";
2
+ export * from "./Lang2FhirAndCreateMultiResponse.mjs";
2
3
  export * from "./Lang2FhirAndCreateResponse.mjs";
3
4
  export * from "./Lang2FhirAndSearchResponse.mjs";
4
5
  export * from "./McpServerResponse.mjs";
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.17";
1
+ export declare const SDK_VERSION = "0.0.19";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.0.17";
1
+ export const SDK_VERSION = "0.0.19";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phenoml",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "private": false,
5
5
  "repository": "github:PhenoML/phenoml-ts-sdk",
6
6
  "type": "commonjs",