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
@@ -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.17",
56
- "User-Agent": "phenoml/0.0.17",
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
  *
@@ -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>;
@@ -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
  *
@@ -211,9 +286,9 @@ class Lang2Fhir {
211
286
  *
212
287
  * @example
213
288
  * await client.lang2Fhir.uploadProfile({
214
- * version: "version",
215
- * resource: "custom-patient",
216
- * profile: "profile"
289
+ * version: "R4",
290
+ * resource: "condition-encounter-diagnosis",
291
+ * profile: "(base64 encoded JSON string of the FHIR profile)"
217
292
  * })
218
293
  */
219
294
  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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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.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);
@@ -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.
@@ -419,9 +419,10 @@ class Summary {
419
419
  });
420
420
  }
421
421
  /**
422
- * Creates a summary from FHIR resources using one of two modes:
422
+ * Creates a summary from FHIR resources using one of three modes:
423
423
  * - **narrative**: Uses a template to substitute FHIR data into placeholders (requires template_id)
424
424
  * - **flatten**: Flattens FHIR resources into a searchable format for RAG/search (no template needed)
425
+ * - **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.
425
426
  *
426
427
  * @param {phenoml.summary.CreateSummaryRequest} request
427
428
  * @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
  }
@@ -8,9 +8,11 @@ var CreateSummaryRequest;
8
8
  * Summary generation mode:
9
9
  * - narrative: Substitute FHIR data into a template (requires template_id)
10
10
  * - flatten: Flatten FHIR resources for RAG/search (no template needed)
11
+ * - ips: Generate International Patient Summary (IPS) narrative per ISO 27269/HL7 FHIR IPS IG
11
12
  */
12
13
  CreateSummaryRequest.Mode = {
13
14
  Narrative: "narrative",
14
15
  Flatten: "flatten",
16
+ Ips: "ips",
15
17
  };
16
18
  })(CreateSummaryRequest || (exports.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,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
1
  export * from "./CreateSummaryResponse.js";
2
2
  export * from "./CreateSummaryTemplateResponse.js";
3
+ export * from "./ErrorResponse.js";
3
4
  export * from "./FhirBundle.js";
4
5
  export * from "./FhirResource.js";
5
6
  export * from "./SummaryDeleteTemplateResponse.js";
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./CreateSummaryResponse.js"), exports);
18
18
  __exportStar(require("./CreateSummaryTemplateResponse.js"), exports);
19
+ __exportStar(require("./ErrorResponse.js"), exports);
19
20
  __exportStar(require("./FhirBundle.js"), exports);
20
21
  __exportStar(require("./FhirResource.js"), exports);
21
22
  __exportStar(require("./SummaryDeleteTemplateResponse.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.17";
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.17";
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.17",
20
- "User-Agent": "phenoml/0.0.17",
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) });