phenoml 0.0.18 → 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 (46) 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 +19 -0
  4. package/dist/cjs/api/resources/lang2Fhir/client/Client.js +75 -0
  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/index.d.ts +1 -0
  8. package/dist/cjs/api/resources/lang2Fhir/types/CreateMultiResponse.d.ts +47 -0
  9. package/dist/cjs/api/resources/lang2Fhir/types/CreateMultiResponse.js +3 -0
  10. package/dist/cjs/api/resources/lang2Fhir/types/index.d.ts +1 -0
  11. package/dist/cjs/api/resources/lang2Fhir/types/index.js +1 -0
  12. package/dist/cjs/api/resources/tools/client/Client.d.ts +26 -0
  13. package/dist/cjs/api/resources/tools/client/Client.js +91 -0
  14. package/dist/cjs/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.d.ts +27 -0
  15. package/dist/cjs/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.js +3 -0
  16. package/dist/cjs/api/resources/tools/client/requests/index.d.ts +1 -0
  17. package/dist/cjs/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.d.ts +31 -0
  18. package/dist/cjs/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.js +3 -0
  19. package/dist/cjs/api/resources/tools/types/index.d.ts +1 -0
  20. package/dist/cjs/api/resources/tools/types/index.js +1 -0
  21. package/dist/cjs/version.d.ts +1 -1
  22. package/dist/cjs/version.js +1 -1
  23. package/dist/esm/Client.mjs +2 -2
  24. package/dist/esm/api/resources/construe/types/ExtractRequestConfig.d.mts +6 -1
  25. package/dist/esm/api/resources/lang2Fhir/client/Client.d.mts +19 -0
  26. package/dist/esm/api/resources/lang2Fhir/client/Client.mjs +75 -0
  27. package/dist/esm/api/resources/lang2Fhir/client/requests/CreateMultiRequest.d.mts +14 -0
  28. package/dist/esm/api/resources/lang2Fhir/client/requests/CreateMultiRequest.mjs +2 -0
  29. package/dist/esm/api/resources/lang2Fhir/client/requests/index.d.mts +1 -0
  30. package/dist/esm/api/resources/lang2Fhir/types/CreateMultiResponse.d.mts +47 -0
  31. package/dist/esm/api/resources/lang2Fhir/types/CreateMultiResponse.mjs +2 -0
  32. package/dist/esm/api/resources/lang2Fhir/types/index.d.mts +1 -0
  33. package/dist/esm/api/resources/lang2Fhir/types/index.mjs +1 -0
  34. package/dist/esm/api/resources/tools/client/Client.d.mts +26 -0
  35. package/dist/esm/api/resources/tools/client/Client.mjs +91 -0
  36. package/dist/esm/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.d.mts +27 -0
  37. package/dist/esm/api/resources/tools/client/requests/Lang2FhirAndCreateMultiRequest.mjs +2 -0
  38. package/dist/esm/api/resources/tools/client/requests/index.d.mts +1 -0
  39. package/dist/esm/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.d.mts +31 -0
  40. package/dist/esm/api/resources/tools/types/Lang2FhirAndCreateMultiResponse.mjs +2 -0
  41. package/dist/esm/api/resources/tools/types/index.d.mts +1 -0
  42. package/dist/esm/api/resources/tools/types/index.mjs +1 -0
  43. package/dist/esm/version.d.mts +1 -1
  44. package/dist/esm/version.mjs +1 -1
  45. package/package.json +1 -1
  46. package/reference.md +139 -0
@@ -52,8 +52,8 @@ class phenomlClient {
52
52
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_js_1.mergeHeaders)({
53
53
  "X-Fern-Language": "JavaScript",
54
54
  "X-Fern-SDK-Name": "phenoml",
55
- "X-Fern-SDK-Version": "0.0.18",
56
- "User-Agent": "phenoml/0.0.18",
55
+ "X-Fern-SDK-Version": "0.0.19",
56
+ "User-Agent": "phenoml/0.0.19",
57
57
  "X-Fern-Runtime": core.RUNTIME.type,
58
58
  "X-Fern-Runtime-Version": core.RUNTIME.version,
59
59
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -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
  *
@@ -125,6 +125,81 @@ class Lang2Fhir {
125
125
  }
126
126
  });
127
127
  }
128
+ /**
129
+ * Analyzes natural language text and extracts multiple FHIR resources, returning them as a transaction Bundle.
130
+ * Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types from the text.
131
+ * Resources are linked with proper references (e.g., Conditions reference the Patient).
132
+ *
133
+ * @param {phenoml.lang2Fhir.CreateMultiRequest} request
134
+ * @param {Lang2Fhir.RequestOptions} requestOptions - Request-specific configuration.
135
+ *
136
+ * @throws {@link phenoml.lang2Fhir.BadRequestError}
137
+ * @throws {@link phenoml.lang2Fhir.UnauthorizedError}
138
+ * @throws {@link phenoml.lang2Fhir.InternalServerError}
139
+ *
140
+ * @example
141
+ * await client.lang2Fhir.createMulti({
142
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily."
143
+ * })
144
+ */
145
+ createMulti(request, requestOptions) {
146
+ return core.HttpResponsePromise.fromPromise(this.__createMulti(request, requestOptions));
147
+ }
148
+ __createMulti(request, requestOptions) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
151
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
152
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
153
+ 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"),
154
+ method: "POST",
155
+ headers: _headers,
156
+ contentType: "application/json",
157
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
158
+ requestType: "json",
159
+ body: request,
160
+ 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,
161
+ 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,
162
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
163
+ });
164
+ if (_response.ok) {
165
+ return {
166
+ data: _response.body,
167
+ rawResponse: _response.rawResponse,
168
+ };
169
+ }
170
+ if (_response.error.reason === "status-code") {
171
+ switch (_response.error.statusCode) {
172
+ case 400:
173
+ throw new phenoml.lang2Fhir.BadRequestError(_response.error.body, _response.rawResponse);
174
+ case 401:
175
+ throw new phenoml.lang2Fhir.UnauthorizedError(_response.error.body, _response.rawResponse);
176
+ case 500:
177
+ throw new phenoml.lang2Fhir.InternalServerError(_response.error.body, _response.rawResponse);
178
+ default:
179
+ throw new errors.phenomlError({
180
+ statusCode: _response.error.statusCode,
181
+ body: _response.error.body,
182
+ rawResponse: _response.rawResponse,
183
+ });
184
+ }
185
+ }
186
+ switch (_response.error.reason) {
187
+ case "non-json":
188
+ throw new errors.phenomlError({
189
+ statusCode: _response.error.statusCode,
190
+ body: _response.error.rawBody,
191
+ rawResponse: _response.rawResponse,
192
+ });
193
+ case "timeout":
194
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling POST /lang2fhir/create/multi.");
195
+ case "unknown":
196
+ throw new errors.phenomlError({
197
+ message: _response.error.errorMessage,
198
+ rawResponse: _response.rawResponse,
199
+ });
200
+ }
201
+ });
202
+ }
128
203
  /**
129
204
  * Converts natural language text into FHIR search parameters
130
205
  *
@@ -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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ export type { CreateMultiRequest } from "./CreateMultiRequest.js";
1
2
  export type { CreateRequest } from "./CreateRequest.js";
2
3
  export type { DocumentRequest } from "./DocumentRequest.js";
3
4
  export type { ProfileUploadRequest } from "./ProfileUploadRequest.js";
@@ -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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ export * from "./CreateMultiResponse.js";
1
2
  export * from "./FhirResource.js";
2
3
  export * from "./Lang2FhirUploadProfileResponse.js";
3
4
  export * from "./SearchResponse.js";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CreateMultiResponse.js"), exports);
17
18
  __exportStar(require("./FhirResource.js"), exports);
18
19
  __exportStar(require("./Lang2FhirUploadProfileResponse.js"), exports);
19
20
  __exportStar(require("./SearchResponse.js"), exports);
@@ -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
  *
@@ -156,6 +156,97 @@ class Tools {
156
156
  }
157
157
  });
158
158
  }
159
+ /**
160
+ * Extracts multiple FHIR resources from natural language text and stores them in a FHIR server.
161
+ * Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types.
162
+ * Resources are linked with proper references and submitted as a transaction bundle.
163
+ * For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically
164
+ * resolve them via PUT requests after the initial bundle creation.
165
+ *
166
+ * @param {phenoml.tools.Lang2FhirAndCreateMultiRequest} request
167
+ * @param {Tools.RequestOptions} requestOptions - Request-specific configuration.
168
+ *
169
+ * @throws {@link phenoml.tools.BadRequestError}
170
+ * @throws {@link phenoml.tools.UnauthorizedError}
171
+ * @throws {@link phenoml.tools.ForbiddenError}
172
+ * @throws {@link phenoml.tools.FailedDependencyError}
173
+ * @throws {@link phenoml.tools.InternalServerError}
174
+ *
175
+ * @example
176
+ * await client.tools.createFhirResourcesMulti({
177
+ * "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
178
+ * "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
179
+ * text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
180
+ * provider: "medplum"
181
+ * })
182
+ */
183
+ createFhirResourcesMulti(request, requestOptions) {
184
+ return core.HttpResponsePromise.fromPromise(this.__createFhirResourcesMulti(request, requestOptions));
185
+ }
186
+ __createFhirResourcesMulti(request, requestOptions) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
189
+ 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"]);
190
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
191
+ Authorization: yield this._getAuthorizationHeader(),
192
+ "X-Phenoml-On-Behalf-Of": phenomlOnBehalfOf != null ? phenomlOnBehalfOf : undefined,
193
+ "X-Phenoml-Fhir-Provider": phenomlFhirProvider != null ? phenomlFhirProvider : undefined,
194
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
195
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
196
+ 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"),
197
+ method: "POST",
198
+ headers: _headers,
199
+ contentType: "application/json",
200
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
201
+ requestType: "json",
202
+ body: _body,
203
+ 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,
204
+ 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,
205
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
206
+ });
207
+ if (_response.ok) {
208
+ return {
209
+ data: _response.body,
210
+ rawResponse: _response.rawResponse,
211
+ };
212
+ }
213
+ if (_response.error.reason === "status-code") {
214
+ switch (_response.error.statusCode) {
215
+ case 400:
216
+ throw new phenoml.tools.BadRequestError(_response.error.body, _response.rawResponse);
217
+ case 401:
218
+ throw new phenoml.tools.UnauthorizedError(_response.error.body, _response.rawResponse);
219
+ case 403:
220
+ throw new phenoml.tools.ForbiddenError(_response.error.body, _response.rawResponse);
221
+ case 424:
222
+ throw new phenoml.tools.FailedDependencyError(_response.error.body, _response.rawResponse);
223
+ case 500:
224
+ throw new phenoml.tools.InternalServerError(_response.error.body, _response.rawResponse);
225
+ default:
226
+ throw new errors.phenomlError({
227
+ statusCode: _response.error.statusCode,
228
+ body: _response.error.body,
229
+ rawResponse: _response.rawResponse,
230
+ });
231
+ }
232
+ }
233
+ switch (_response.error.reason) {
234
+ case "non-json":
235
+ throw new errors.phenomlError({
236
+ statusCode: _response.error.statusCode,
237
+ body: _response.error.rawBody,
238
+ rawResponse: _response.rawResponse,
239
+ });
240
+ case "timeout":
241
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling POST /tools/lang2fhir-and-create-multi.");
242
+ case "unknown":
243
+ throw new errors.phenomlError({
244
+ message: _response.error.errorMessage,
245
+ rawResponse: _response.rawResponse,
246
+ });
247
+ }
248
+ });
249
+ }
159
250
  /**
160
251
  * Converts natural language to FHIR search parameters and executes search in FHIR server
161
252
  *
@@ -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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
1
  export type { CohortRequest } from "./CohortRequest.js";
2
+ export type { Lang2FhirAndCreateMultiRequest } from "./Lang2FhirAndCreateMultiRequest.js";
2
3
  export type { Lang2FhirAndCreateRequest } from "./Lang2FhirAndCreateRequest.js";
3
4
  export type { Lang2FhirAndSearchRequest } from "./Lang2FhirAndSearchRequest.js";
@@ -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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  export * from "./CohortResponse.js";
2
+ export * from "./Lang2FhirAndCreateMultiResponse.js";
2
3
  export * from "./Lang2FhirAndCreateResponse.js";
3
4
  export * from "./Lang2FhirAndSearchResponse.js";
4
5
  export * from "./McpServerResponse.js";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./CohortResponse.js"), exports);
18
+ __exportStar(require("./Lang2FhirAndCreateMultiResponse.js"), exports);
18
19
  __exportStar(require("./Lang2FhirAndCreateResponse.js"), exports);
19
20
  __exportStar(require("./Lang2FhirAndSearchResponse.js"), exports);
20
21
  __exportStar(require("./McpServerResponse.js"), exports);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.0.18";
1
+ export declare const SDK_VERSION = "0.0.19";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.0.18";
4
+ exports.SDK_VERSION = "0.0.19";
@@ -16,8 +16,8 @@ export class phenomlClient {
16
16
  this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
17
17
  "X-Fern-Language": "JavaScript",
18
18
  "X-Fern-SDK-Name": "phenoml",
19
- "X-Fern-SDK-Version": "0.0.18",
20
- "User-Agent": "phenoml/0.0.18",
19
+ "X-Fern-SDK-Version": "0.0.19",
20
+ "User-Agent": "phenoml/0.0.19",
21
21
  "X-Fern-Runtime": core.RUNTIME.type,
22
22
  "X-Fern-Runtime-Version": core.RUNTIME.version,
23
23
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
@@ -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
  *
@@ -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
  *
@@ -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,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";
@@ -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.18";
1
+ export declare const SDK_VERSION = "0.0.19";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.0.18";
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.18",
3
+ "version": "0.0.19",
4
4
  "private": false,
5
5
  "repository": "github:PhenoML/phenoml-ts-sdk",
6
6
  "type": "commonjs",
package/reference.md CHANGED
@@ -2434,6 +2434,73 @@ await client.lang2Fhir.create({
2434
2434
  </dl>
2435
2435
 
2436
2436
 
2437
+ </dd>
2438
+ </dl>
2439
+ </details>
2440
+
2441
+ <details><summary><code>client.lang2Fhir.<a href="/src/api/resources/lang2Fhir/client/Client.ts">createMulti</a>({ ...params }) -> phenoml.CreateMultiResponse</code></summary>
2442
+ <dl>
2443
+ <dd>
2444
+
2445
+ #### 📝 Description
2446
+
2447
+ <dl>
2448
+ <dd>
2449
+
2450
+ <dl>
2451
+ <dd>
2452
+
2453
+ Analyzes natural language text and extracts multiple FHIR resources, returning them as a transaction Bundle.
2454
+ Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types from the text.
2455
+ Resources are linked with proper references (e.g., Conditions reference the Patient).
2456
+ </dd>
2457
+ </dl>
2458
+ </dd>
2459
+ </dl>
2460
+
2461
+ #### 🔌 Usage
2462
+
2463
+ <dl>
2464
+ <dd>
2465
+
2466
+ <dl>
2467
+ <dd>
2468
+
2469
+ ```typescript
2470
+ await client.lang2Fhir.createMulti({
2471
+ text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily."
2472
+ });
2473
+
2474
+ ```
2475
+ </dd>
2476
+ </dl>
2477
+ </dd>
2478
+ </dl>
2479
+
2480
+ #### ⚙️ Parameters
2481
+
2482
+ <dl>
2483
+ <dd>
2484
+
2485
+ <dl>
2486
+ <dd>
2487
+
2488
+ **request:** `phenoml.lang2Fhir.CreateMultiRequest`
2489
+
2490
+ </dd>
2491
+ </dl>
2492
+
2493
+ <dl>
2494
+ <dd>
2495
+
2496
+ **requestOptions:** `Lang2Fhir.RequestOptions`
2497
+
2498
+ </dd>
2499
+ </dl>
2500
+ </dd>
2501
+ </dl>
2502
+
2503
+
2437
2504
  </dd>
2438
2505
  </dl>
2439
2506
  </details>
@@ -3099,6 +3166,78 @@ await client.tools.createFhirResource({
3099
3166
  </dl>
3100
3167
 
3101
3168
 
3169
+ </dd>
3170
+ </dl>
3171
+ </details>
3172
+
3173
+ <details><summary><code>client.tools.<a href="/src/api/resources/tools/client/Client.ts">createFhirResourcesMulti</a>({ ...params }) -> phenoml.Lang2FhirAndCreateMultiResponse</code></summary>
3174
+ <dl>
3175
+ <dd>
3176
+
3177
+ #### 📝 Description
3178
+
3179
+ <dl>
3180
+ <dd>
3181
+
3182
+ <dl>
3183
+ <dd>
3184
+
3185
+ Extracts multiple FHIR resources from natural language text and stores them in a FHIR server.
3186
+ Automatically detects Patient, Condition, MedicationRequest, Observation, and other resource types.
3187
+ Resources are linked with proper references and submitted as a transaction bundle.
3188
+ For FHIR servers that don't auto-resolve urn:uuid references, this endpoint will automatically
3189
+ resolve them via PUT requests after the initial bundle creation.
3190
+ </dd>
3191
+ </dl>
3192
+ </dd>
3193
+ </dl>
3194
+
3195
+ #### 🔌 Usage
3196
+
3197
+ <dl>
3198
+ <dd>
3199
+
3200
+ <dl>
3201
+ <dd>
3202
+
3203
+ ```typescript
3204
+ await client.tools.createFhirResourcesMulti({
3205
+ "X-Phenoml-On-Behalf-Of": "Patient/550e8400-e29b-41d4-a716-446655440000",
3206
+ "X-Phenoml-Fhir-Provider": "550e8400-e29b-41d4-a716-446655440000:eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c...",
3207
+ text: "John Smith, 45-year-old male, diagnosed with Type 2 Diabetes. Prescribed Metformin 500mg twice daily.",
3208
+ provider: "medplum"
3209
+ });
3210
+
3211
+ ```
3212
+ </dd>
3213
+ </dl>
3214
+ </dd>
3215
+ </dl>
3216
+
3217
+ #### ⚙️ Parameters
3218
+
3219
+ <dl>
3220
+ <dd>
3221
+
3222
+ <dl>
3223
+ <dd>
3224
+
3225
+ **request:** `phenoml.tools.Lang2FhirAndCreateMultiRequest`
3226
+
3227
+ </dd>
3228
+ </dl>
3229
+
3230
+ <dl>
3231
+ <dd>
3232
+
3233
+ **requestOptions:** `Tools.RequestOptions`
3234
+
3235
+ </dd>
3236
+ </dl>
3237
+ </dd>
3238
+ </dl>
3239
+
3240
+
3102
3241
  </dd>
3103
3242
  </dl>
3104
3243
  </details>