phenoml 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/cjs/Client.js +2 -2
  2. package/dist/cjs/api/resources/construe/client/Client.d.ts +129 -0
  3. package/dist/cjs/api/resources/construe/client/Client.js +429 -0
  4. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemCodeIdRequest.d.ts +10 -0
  5. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemCodeIdRequest.js +3 -0
  6. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemRequest.d.ts +16 -0
  7. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemRequest.js +3 -0
  8. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchSemanticRequest.d.ts +16 -0
  9. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchSemanticRequest.js +3 -0
  10. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchTextRequest.d.ts +16 -0
  11. package/dist/cjs/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchTextRequest.js +3 -0
  12. package/dist/cjs/api/resources/construe/client/requests/index.d.ts +4 -0
  13. package/dist/cjs/api/resources/construe/errors/NotFoundError.d.ts +5 -0
  14. package/dist/cjs/api/resources/construe/errors/NotFoundError.js +50 -0
  15. package/dist/cjs/api/resources/construe/errors/NotImplementedError.d.ts +5 -0
  16. package/dist/cjs/api/resources/construe/errors/NotImplementedError.js +50 -0
  17. package/dist/cjs/api/resources/construe/errors/ServiceUnavailableError.d.ts +5 -0
  18. package/dist/cjs/api/resources/construe/errors/ServiceUnavailableError.js +50 -0
  19. package/dist/cjs/api/resources/construe/errors/index.d.ts +3 -0
  20. package/dist/cjs/api/resources/construe/errors/index.js +3 -0
  21. package/dist/cjs/api/resources/construe/types/CodeResponse.d.ts +8 -0
  22. package/dist/cjs/api/resources/construe/types/CodeResponse.js +3 -0
  23. package/dist/cjs/api/resources/construe/types/CodeSystemDetails.d.ts +10 -0
  24. package/dist/cjs/api/resources/construe/types/CodeSystemDetails.js +3 -0
  25. package/dist/cjs/api/resources/construe/types/CodeSystemInfo.d.ts +6 -0
  26. package/dist/cjs/api/resources/construe/types/CodeSystemInfo.js +3 -0
  27. package/dist/cjs/api/resources/construe/types/GetCodeResponse.d.ts +10 -0
  28. package/dist/cjs/api/resources/construe/types/GetCodeResponse.js +3 -0
  29. package/dist/cjs/api/resources/construe/types/ListCodeSystemsResponse.d.ts +4 -0
  30. package/dist/cjs/api/resources/construe/types/ListCodeSystemsResponse.js +3 -0
  31. package/dist/cjs/api/resources/construe/types/ListCodesResponse.d.ts +9 -0
  32. package/dist/cjs/api/resources/construe/types/ListCodesResponse.js +3 -0
  33. package/dist/cjs/api/resources/construe/types/SemanticSearchResponse.d.ts +6 -0
  34. package/dist/cjs/api/resources/construe/types/SemanticSearchResponse.js +3 -0
  35. package/dist/cjs/api/resources/construe/types/SemanticSearchResult.d.ts +4 -0
  36. package/dist/cjs/api/resources/construe/types/SemanticSearchResult.js +3 -0
  37. package/dist/cjs/api/resources/construe/types/TextSearchResponse.d.ts +8 -0
  38. package/dist/cjs/api/resources/construe/types/TextSearchResponse.js +3 -0
  39. package/dist/cjs/api/resources/construe/types/TextSearchResult.d.ts +4 -0
  40. package/dist/cjs/api/resources/construe/types/TextSearchResult.js +3 -0
  41. package/dist/cjs/api/resources/construe/types/index.d.ts +10 -0
  42. package/dist/cjs/api/resources/construe/types/index.js +10 -0
  43. package/dist/cjs/version.d.ts +1 -1
  44. package/dist/cjs/version.js +1 -1
  45. package/dist/esm/Client.mjs +2 -2
  46. package/dist/esm/api/resources/construe/client/Client.d.mts +129 -0
  47. package/dist/esm/api/resources/construe/client/Client.mjs +429 -0
  48. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemCodeIdRequest.d.mts +10 -0
  49. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemCodeIdRequest.mjs +2 -0
  50. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemRequest.d.mts +16 -0
  51. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemRequest.mjs +2 -0
  52. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchSemanticRequest.d.mts +16 -0
  53. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchSemanticRequest.mjs +2 -0
  54. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchTextRequest.d.mts +16 -0
  55. package/dist/esm/api/resources/construe/client/requests/GetConstrueCodesCodesystemSearchTextRequest.mjs +2 -0
  56. package/dist/esm/api/resources/construe/client/requests/index.d.mts +4 -0
  57. package/dist/esm/api/resources/construe/errors/NotFoundError.d.mts +5 -0
  58. package/dist/esm/api/resources/construe/errors/NotFoundError.mjs +13 -0
  59. package/dist/esm/api/resources/construe/errors/NotImplementedError.d.mts +5 -0
  60. package/dist/esm/api/resources/construe/errors/NotImplementedError.mjs +13 -0
  61. package/dist/esm/api/resources/construe/errors/ServiceUnavailableError.d.mts +5 -0
  62. package/dist/esm/api/resources/construe/errors/ServiceUnavailableError.mjs +13 -0
  63. package/dist/esm/api/resources/construe/errors/index.d.mts +3 -0
  64. package/dist/esm/api/resources/construe/errors/index.mjs +3 -0
  65. package/dist/esm/api/resources/construe/types/CodeResponse.d.mts +8 -0
  66. package/dist/esm/api/resources/construe/types/CodeResponse.mjs +2 -0
  67. package/dist/esm/api/resources/construe/types/CodeSystemDetails.d.mts +10 -0
  68. package/dist/esm/api/resources/construe/types/CodeSystemDetails.mjs +2 -0
  69. package/dist/esm/api/resources/construe/types/CodeSystemInfo.d.mts +6 -0
  70. package/dist/esm/api/resources/construe/types/CodeSystemInfo.mjs +2 -0
  71. package/dist/esm/api/resources/construe/types/GetCodeResponse.d.mts +10 -0
  72. package/dist/esm/api/resources/construe/types/GetCodeResponse.mjs +2 -0
  73. package/dist/esm/api/resources/construe/types/ListCodeSystemsResponse.d.mts +4 -0
  74. package/dist/esm/api/resources/construe/types/ListCodeSystemsResponse.mjs +2 -0
  75. package/dist/esm/api/resources/construe/types/ListCodesResponse.d.mts +9 -0
  76. package/dist/esm/api/resources/construe/types/ListCodesResponse.mjs +2 -0
  77. package/dist/esm/api/resources/construe/types/SemanticSearchResponse.d.mts +6 -0
  78. package/dist/esm/api/resources/construe/types/SemanticSearchResponse.mjs +2 -0
  79. package/dist/esm/api/resources/construe/types/SemanticSearchResult.d.mts +4 -0
  80. package/dist/esm/api/resources/construe/types/SemanticSearchResult.mjs +2 -0
  81. package/dist/esm/api/resources/construe/types/TextSearchResponse.d.mts +8 -0
  82. package/dist/esm/api/resources/construe/types/TextSearchResponse.mjs +2 -0
  83. package/dist/esm/api/resources/construe/types/TextSearchResult.d.mts +4 -0
  84. package/dist/esm/api/resources/construe/types/TextSearchResult.mjs +2 -0
  85. package/dist/esm/api/resources/construe/types/index.d.mts +10 -0
  86. package/dist/esm/api/resources/construe/types/index.mjs +10 -0
  87. package/dist/esm/version.d.mts +1 -1
  88. package/dist/esm/version.mjs +1 -1
  89. package/package.json +1 -1
  90. package/reference.md +392 -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": "1.0.1",
56
- "User-Agent": "phenoml/1.0.1",
55
+ "X-Fern-SDK-Version": "1.1.0",
56
+ "User-Agent": "phenoml/1.1.0",
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) });
@@ -52,5 +52,134 @@ export declare class Construe {
52
52
  */
53
53
  extractCodes(request: phenoml.construe.ExtractRequest, requestOptions?: Construe.RequestOptions): core.HttpResponsePromise<phenoml.construe.ExtractCodesResult>;
54
54
  private __extractCodes;
55
+ /**
56
+ * Returns metadata about all available code systems including built-in and custom systems.
57
+ *
58
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
59
+ *
60
+ * @throws {@link phenoml.construe.UnauthorizedError}
61
+ * @throws {@link phenoml.construe.InternalServerError}
62
+ *
63
+ * @example
64
+ * await client.construe.listAvailableCodeSystems()
65
+ */
66
+ listAvailableCodeSystems(requestOptions?: Construe.RequestOptions): core.HttpResponsePromise<phenoml.construe.ListCodeSystemsResponse>;
67
+ private __listAvailableCodeSystems;
68
+ /**
69
+ * Returns a paginated list of all codes in the specified code system.
70
+ *
71
+ * @param {string} codesystem - Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE")
72
+ * @param {phenoml.construe.GetConstrueCodesCodesystemRequest} request
73
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
74
+ *
75
+ * @throws {@link phenoml.construe.BadRequestError}
76
+ * @throws {@link phenoml.construe.UnauthorizedError}
77
+ * @throws {@link phenoml.construe.NotFoundError}
78
+ * @throws {@link phenoml.construe.InternalServerError}
79
+ *
80
+ * @example
81
+ * await client.construe.listCodesInACodeSystem("ICD-10-CM", {
82
+ * version: "2025",
83
+ * cursor: "cursor",
84
+ * limit: 1
85
+ * })
86
+ */
87
+ listCodesInACodeSystem(codesystem: string, request?: phenoml.construe.GetConstrueCodesCodesystemRequest, requestOptions?: Construe.RequestOptions): core.HttpResponsePromise<phenoml.construe.ListCodesResponse>;
88
+ private __listCodesInACodeSystem;
89
+ /**
90
+ * Returns details for a specific code within a code system.
91
+ *
92
+ * @param {string} codesystem - Code system name
93
+ * @param {string} codeId - The code identifier
94
+ * @param {phenoml.construe.GetConstrueCodesCodesystemCodeIdRequest} request
95
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
96
+ *
97
+ * @throws {@link phenoml.construe.BadRequestError}
98
+ * @throws {@link phenoml.construe.UnauthorizedError}
99
+ * @throws {@link phenoml.construe.NotFoundError}
100
+ * @throws {@link phenoml.construe.InternalServerError}
101
+ *
102
+ * @example
103
+ * await client.construe.getASpecificCode("ICD-10-CM", "E11.65", {
104
+ * version: "version"
105
+ * })
106
+ */
107
+ getASpecificCode(codesystem: string, codeId: string, request?: phenoml.construe.GetConstrueCodesCodesystemCodeIdRequest, requestOptions?: Construe.RequestOptions): core.HttpResponsePromise<phenoml.construe.GetCodeResponse>;
108
+ private __getASpecificCode;
109
+ /**
110
+ * Performs semantic similarity search using vector embeddings.
111
+ *
112
+ * **When to use**: Best for natural language queries where you want to find conceptually
113
+ * related codes, even when different terminology is used. The search understands meaning,
114
+ * not just keywords.
115
+ *
116
+ * **Examples**:
117
+ * - Query "trouble breathing at night" finds codes like "Sleep apnea", "Orthopnea",
118
+ * "Nocturnal dyspnea" — semantically related but no exact keyword matches
119
+ * - Query "heart problems" finds "Myocardial infarction", "Cardiac arrest", "Arrhythmia"
120
+ *
121
+ * **Trade-offs**: Slower than text search (requires embedding generation), but finds
122
+ * conceptually similar results that keyword search would miss.
123
+ *
124
+ * See also: `/search/text` for faster keyword-based lookup with typo tolerance.
125
+ *
126
+ * @param {string} codesystem - Code system name
127
+ * @param {phenoml.construe.GetConstrueCodesCodesystemSearchSemanticRequest} request
128
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
129
+ *
130
+ * @throws {@link phenoml.construe.BadRequestError}
131
+ * @throws {@link phenoml.construe.UnauthorizedError}
132
+ * @throws {@link phenoml.construe.NotFoundError}
133
+ * @throws {@link phenoml.construe.InternalServerError}
134
+ *
135
+ * @example
136
+ * await client.construe.semanticSearchEmbeddingBased("ICD-10-CM", {
137
+ * text: "patient has trouble breathing at night and wakes up gasping",
138
+ * version: "version",
139
+ * limit: 1
140
+ * })
141
+ */
142
+ semanticSearchEmbeddingBased(codesystem: string, request: phenoml.construe.GetConstrueCodesCodesystemSearchSemanticRequest, requestOptions?: Construe.RequestOptions): core.HttpResponsePromise<phenoml.construe.SemanticSearchResponse>;
143
+ private __semanticSearchEmbeddingBased;
144
+ /**
145
+ * Performs fast full-text search over code IDs and descriptions.
146
+ *
147
+ * **When to use**: Best for autocomplete UIs, code lookup, or when users know part of
148
+ * the code ID or specific keywords. Fast response times suitable for typeahead interfaces.
149
+ *
150
+ * **Features**:
151
+ * - Substring matching on code IDs (e.g., "11.65" finds "E11.65")
152
+ * - Typo tolerance on descriptions (not on code IDs)
153
+ * - Fast response times (~10-50ms)
154
+ *
155
+ * **Examples**:
156
+ * - Query "E11" finds all codes starting with E11 (diabetes codes)
157
+ * - Query "diabtes" (typo) still finds "diabetes" codes
158
+ *
159
+ * **Trade-offs**: Faster than semantic search, but only matches keywords/substrings.
160
+ * Won't find conceptually related codes with different terminology.
161
+ *
162
+ * See also: `/search/semantic` for finding conceptually similar codes.
163
+ *
164
+ * @param {string} codesystem - Code system name
165
+ * @param {phenoml.construe.GetConstrueCodesCodesystemSearchTextRequest} request
166
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
167
+ *
168
+ * @throws {@link phenoml.construe.BadRequestError}
169
+ * @throws {@link phenoml.construe.UnauthorizedError}
170
+ * @throws {@link phenoml.construe.NotFoundError}
171
+ * @throws {@link phenoml.construe.InternalServerError}
172
+ * @throws {@link phenoml.construe.NotImplementedError}
173
+ * @throws {@link phenoml.construe.ServiceUnavailableError}
174
+ *
175
+ * @example
176
+ * await client.construe.textSearchKeywordBased("ICD-10-CM", {
177
+ * q: "E11.65",
178
+ * version: "version",
179
+ * limit: 1
180
+ * })
181
+ */
182
+ textSearchKeywordBased(codesystem: string, request: phenoml.construe.GetConstrueCodesCodesystemSearchTextRequest, requestOptions?: Construe.RequestOptions): core.HttpResponsePromise<phenoml.construe.TextSearchResponse>;
183
+ private __textSearchKeywordBased;
55
184
  protected _getAuthorizationHeader(): Promise<string>;
56
185
  }
@@ -210,6 +210,435 @@ class Construe {
210
210
  }
211
211
  });
212
212
  }
213
+ /**
214
+ * Returns metadata about all available code systems including built-in and custom systems.
215
+ *
216
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
217
+ *
218
+ * @throws {@link phenoml.construe.UnauthorizedError}
219
+ * @throws {@link phenoml.construe.InternalServerError}
220
+ *
221
+ * @example
222
+ * await client.construe.listAvailableCodeSystems()
223
+ */
224
+ listAvailableCodeSystems(requestOptions) {
225
+ return core.HttpResponsePromise.fromPromise(this.__listAvailableCodeSystems(requestOptions));
226
+ }
227
+ __listAvailableCodeSystems(requestOptions) {
228
+ return __awaiter(this, void 0, void 0, function* () {
229
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
230
+ 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);
231
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
232
+ 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, "construe/codes/systems"),
233
+ method: "GET",
234
+ headers: _headers,
235
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
236
+ 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,
237
+ 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,
238
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
239
+ });
240
+ if (_response.ok) {
241
+ return {
242
+ data: _response.body,
243
+ rawResponse: _response.rawResponse,
244
+ };
245
+ }
246
+ if (_response.error.reason === "status-code") {
247
+ switch (_response.error.statusCode) {
248
+ case 401:
249
+ throw new phenoml.construe.UnauthorizedError(_response.error.body, _response.rawResponse);
250
+ case 500:
251
+ throw new phenoml.construe.InternalServerError(_response.error.body, _response.rawResponse);
252
+ default:
253
+ throw new errors.phenomlError({
254
+ statusCode: _response.error.statusCode,
255
+ body: _response.error.body,
256
+ rawResponse: _response.rawResponse,
257
+ });
258
+ }
259
+ }
260
+ switch (_response.error.reason) {
261
+ case "non-json":
262
+ throw new errors.phenomlError({
263
+ statusCode: _response.error.statusCode,
264
+ body: _response.error.rawBody,
265
+ rawResponse: _response.rawResponse,
266
+ });
267
+ case "timeout":
268
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling GET /construe/codes/systems.");
269
+ case "unknown":
270
+ throw new errors.phenomlError({
271
+ message: _response.error.errorMessage,
272
+ rawResponse: _response.rawResponse,
273
+ });
274
+ }
275
+ });
276
+ }
277
+ /**
278
+ * Returns a paginated list of all codes in the specified code system.
279
+ *
280
+ * @param {string} codesystem - Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE")
281
+ * @param {phenoml.construe.GetConstrueCodesCodesystemRequest} request
282
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
283
+ *
284
+ * @throws {@link phenoml.construe.BadRequestError}
285
+ * @throws {@link phenoml.construe.UnauthorizedError}
286
+ * @throws {@link phenoml.construe.NotFoundError}
287
+ * @throws {@link phenoml.construe.InternalServerError}
288
+ *
289
+ * @example
290
+ * await client.construe.listCodesInACodeSystem("ICD-10-CM", {
291
+ * version: "2025",
292
+ * cursor: "cursor",
293
+ * limit: 1
294
+ * })
295
+ */
296
+ listCodesInACodeSystem(codesystem, request = {}, requestOptions) {
297
+ return core.HttpResponsePromise.fromPromise(this.__listCodesInACodeSystem(codesystem, request, requestOptions));
298
+ }
299
+ __listCodesInACodeSystem(codesystem_1) {
300
+ return __awaiter(this, arguments, void 0, function* (codesystem, request = {}, requestOptions) {
301
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
302
+ const { version, cursor, limit } = request;
303
+ const _queryParams = {};
304
+ if (version != null) {
305
+ _queryParams.version = version;
306
+ }
307
+ if (cursor != null) {
308
+ _queryParams.cursor = cursor;
309
+ }
310
+ if (limit != null) {
311
+ _queryParams.limit = limit.toString();
312
+ }
313
+ 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);
314
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
315
+ 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, `construe/codes/${core.url.encodePathParam(codesystem)}`),
316
+ method: "GET",
317
+ headers: _headers,
318
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
319
+ 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,
320
+ 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,
321
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
322
+ });
323
+ if (_response.ok) {
324
+ return { data: _response.body, rawResponse: _response.rawResponse };
325
+ }
326
+ if (_response.error.reason === "status-code") {
327
+ switch (_response.error.statusCode) {
328
+ case 400:
329
+ throw new phenoml.construe.BadRequestError(_response.error.body, _response.rawResponse);
330
+ case 401:
331
+ throw new phenoml.construe.UnauthorizedError(_response.error.body, _response.rawResponse);
332
+ case 404:
333
+ throw new phenoml.construe.NotFoundError(_response.error.body, _response.rawResponse);
334
+ case 500:
335
+ throw new phenoml.construe.InternalServerError(_response.error.body, _response.rawResponse);
336
+ default:
337
+ throw new errors.phenomlError({
338
+ statusCode: _response.error.statusCode,
339
+ body: _response.error.body,
340
+ rawResponse: _response.rawResponse,
341
+ });
342
+ }
343
+ }
344
+ switch (_response.error.reason) {
345
+ case "non-json":
346
+ throw new errors.phenomlError({
347
+ statusCode: _response.error.statusCode,
348
+ body: _response.error.rawBody,
349
+ rawResponse: _response.rawResponse,
350
+ });
351
+ case "timeout":
352
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling GET /construe/codes/{codesystem}.");
353
+ case "unknown":
354
+ throw new errors.phenomlError({
355
+ message: _response.error.errorMessage,
356
+ rawResponse: _response.rawResponse,
357
+ });
358
+ }
359
+ });
360
+ }
361
+ /**
362
+ * Returns details for a specific code within a code system.
363
+ *
364
+ * @param {string} codesystem - Code system name
365
+ * @param {string} codeId - The code identifier
366
+ * @param {phenoml.construe.GetConstrueCodesCodesystemCodeIdRequest} request
367
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
368
+ *
369
+ * @throws {@link phenoml.construe.BadRequestError}
370
+ * @throws {@link phenoml.construe.UnauthorizedError}
371
+ * @throws {@link phenoml.construe.NotFoundError}
372
+ * @throws {@link phenoml.construe.InternalServerError}
373
+ *
374
+ * @example
375
+ * await client.construe.getASpecificCode("ICD-10-CM", "E11.65", {
376
+ * version: "version"
377
+ * })
378
+ */
379
+ getASpecificCode(codesystem, codeId, request = {}, requestOptions) {
380
+ return core.HttpResponsePromise.fromPromise(this.__getASpecificCode(codesystem, codeId, request, requestOptions));
381
+ }
382
+ __getASpecificCode(codesystem_1, codeId_1) {
383
+ return __awaiter(this, arguments, void 0, function* (codesystem, codeId, request = {}, requestOptions) {
384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
385
+ const { version } = request;
386
+ const _queryParams = {};
387
+ if (version != null) {
388
+ _queryParams.version = version;
389
+ }
390
+ 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);
391
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
392
+ 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, `construe/codes/${core.url.encodePathParam(codesystem)}/${core.url.encodePathParam(codeId)}`),
393
+ method: "GET",
394
+ headers: _headers,
395
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
396
+ 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,
397
+ 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,
398
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
399
+ });
400
+ if (_response.ok) {
401
+ return { data: _response.body, rawResponse: _response.rawResponse };
402
+ }
403
+ if (_response.error.reason === "status-code") {
404
+ switch (_response.error.statusCode) {
405
+ case 400:
406
+ throw new phenoml.construe.BadRequestError(_response.error.body, _response.rawResponse);
407
+ case 401:
408
+ throw new phenoml.construe.UnauthorizedError(_response.error.body, _response.rawResponse);
409
+ case 404:
410
+ throw new phenoml.construe.NotFoundError(_response.error.body, _response.rawResponse);
411
+ case 500:
412
+ throw new phenoml.construe.InternalServerError(_response.error.body, _response.rawResponse);
413
+ default:
414
+ throw new errors.phenomlError({
415
+ statusCode: _response.error.statusCode,
416
+ body: _response.error.body,
417
+ rawResponse: _response.rawResponse,
418
+ });
419
+ }
420
+ }
421
+ switch (_response.error.reason) {
422
+ case "non-json":
423
+ throw new errors.phenomlError({
424
+ statusCode: _response.error.statusCode,
425
+ body: _response.error.rawBody,
426
+ rawResponse: _response.rawResponse,
427
+ });
428
+ case "timeout":
429
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling GET /construe/codes/{codesystem}/{codeID}.");
430
+ case "unknown":
431
+ throw new errors.phenomlError({
432
+ message: _response.error.errorMessage,
433
+ rawResponse: _response.rawResponse,
434
+ });
435
+ }
436
+ });
437
+ }
438
+ /**
439
+ * Performs semantic similarity search using vector embeddings.
440
+ *
441
+ * **When to use**: Best for natural language queries where you want to find conceptually
442
+ * related codes, even when different terminology is used. The search understands meaning,
443
+ * not just keywords.
444
+ *
445
+ * **Examples**:
446
+ * - Query "trouble breathing at night" finds codes like "Sleep apnea", "Orthopnea",
447
+ * "Nocturnal dyspnea" — semantically related but no exact keyword matches
448
+ * - Query "heart problems" finds "Myocardial infarction", "Cardiac arrest", "Arrhythmia"
449
+ *
450
+ * **Trade-offs**: Slower than text search (requires embedding generation), but finds
451
+ * conceptually similar results that keyword search would miss.
452
+ *
453
+ * See also: `/search/text` for faster keyword-based lookup with typo tolerance.
454
+ *
455
+ * @param {string} codesystem - Code system name
456
+ * @param {phenoml.construe.GetConstrueCodesCodesystemSearchSemanticRequest} request
457
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
458
+ *
459
+ * @throws {@link phenoml.construe.BadRequestError}
460
+ * @throws {@link phenoml.construe.UnauthorizedError}
461
+ * @throws {@link phenoml.construe.NotFoundError}
462
+ * @throws {@link phenoml.construe.InternalServerError}
463
+ *
464
+ * @example
465
+ * await client.construe.semanticSearchEmbeddingBased("ICD-10-CM", {
466
+ * text: "patient has trouble breathing at night and wakes up gasping",
467
+ * version: "version",
468
+ * limit: 1
469
+ * })
470
+ */
471
+ semanticSearchEmbeddingBased(codesystem, request, requestOptions) {
472
+ return core.HttpResponsePromise.fromPromise(this.__semanticSearchEmbeddingBased(codesystem, request, requestOptions));
473
+ }
474
+ __semanticSearchEmbeddingBased(codesystem, request, requestOptions) {
475
+ return __awaiter(this, void 0, void 0, function* () {
476
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
477
+ const { text, version, limit } = request;
478
+ const _queryParams = {};
479
+ _queryParams.text = text;
480
+ if (version != null) {
481
+ _queryParams.version = version;
482
+ }
483
+ if (limit != null) {
484
+ _queryParams.limit = limit.toString();
485
+ }
486
+ 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);
487
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
488
+ 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, `construe/codes/${core.url.encodePathParam(codesystem)}/search/semantic`),
489
+ method: "GET",
490
+ headers: _headers,
491
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
492
+ 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,
493
+ 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,
494
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
495
+ });
496
+ if (_response.ok) {
497
+ return {
498
+ data: _response.body,
499
+ rawResponse: _response.rawResponse,
500
+ };
501
+ }
502
+ if (_response.error.reason === "status-code") {
503
+ switch (_response.error.statusCode) {
504
+ case 400:
505
+ throw new phenoml.construe.BadRequestError(_response.error.body, _response.rawResponse);
506
+ case 401:
507
+ throw new phenoml.construe.UnauthorizedError(_response.error.body, _response.rawResponse);
508
+ case 404:
509
+ throw new phenoml.construe.NotFoundError(_response.error.body, _response.rawResponse);
510
+ case 500:
511
+ throw new phenoml.construe.InternalServerError(_response.error.body, _response.rawResponse);
512
+ default:
513
+ throw new errors.phenomlError({
514
+ statusCode: _response.error.statusCode,
515
+ body: _response.error.body,
516
+ rawResponse: _response.rawResponse,
517
+ });
518
+ }
519
+ }
520
+ switch (_response.error.reason) {
521
+ case "non-json":
522
+ throw new errors.phenomlError({
523
+ statusCode: _response.error.statusCode,
524
+ body: _response.error.rawBody,
525
+ rawResponse: _response.rawResponse,
526
+ });
527
+ case "timeout":
528
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling GET /construe/codes/{codesystem}/search/semantic.");
529
+ case "unknown":
530
+ throw new errors.phenomlError({
531
+ message: _response.error.errorMessage,
532
+ rawResponse: _response.rawResponse,
533
+ });
534
+ }
535
+ });
536
+ }
537
+ /**
538
+ * Performs fast full-text search over code IDs and descriptions.
539
+ *
540
+ * **When to use**: Best for autocomplete UIs, code lookup, or when users know part of
541
+ * the code ID or specific keywords. Fast response times suitable for typeahead interfaces.
542
+ *
543
+ * **Features**:
544
+ * - Substring matching on code IDs (e.g., "11.65" finds "E11.65")
545
+ * - Typo tolerance on descriptions (not on code IDs)
546
+ * - Fast response times (~10-50ms)
547
+ *
548
+ * **Examples**:
549
+ * - Query "E11" finds all codes starting with E11 (diabetes codes)
550
+ * - Query "diabtes" (typo) still finds "diabetes" codes
551
+ *
552
+ * **Trade-offs**: Faster than semantic search, but only matches keywords/substrings.
553
+ * Won't find conceptually related codes with different terminology.
554
+ *
555
+ * See also: `/search/semantic` for finding conceptually similar codes.
556
+ *
557
+ * @param {string} codesystem - Code system name
558
+ * @param {phenoml.construe.GetConstrueCodesCodesystemSearchTextRequest} request
559
+ * @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
560
+ *
561
+ * @throws {@link phenoml.construe.BadRequestError}
562
+ * @throws {@link phenoml.construe.UnauthorizedError}
563
+ * @throws {@link phenoml.construe.NotFoundError}
564
+ * @throws {@link phenoml.construe.InternalServerError}
565
+ * @throws {@link phenoml.construe.NotImplementedError}
566
+ * @throws {@link phenoml.construe.ServiceUnavailableError}
567
+ *
568
+ * @example
569
+ * await client.construe.textSearchKeywordBased("ICD-10-CM", {
570
+ * q: "E11.65",
571
+ * version: "version",
572
+ * limit: 1
573
+ * })
574
+ */
575
+ textSearchKeywordBased(codesystem, request, requestOptions) {
576
+ return core.HttpResponsePromise.fromPromise(this.__textSearchKeywordBased(codesystem, request, requestOptions));
577
+ }
578
+ __textSearchKeywordBased(codesystem, request, requestOptions) {
579
+ return __awaiter(this, void 0, void 0, function* () {
580
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
581
+ const { q, version, limit } = request;
582
+ const _queryParams = {};
583
+ _queryParams.q = q;
584
+ if (version != null) {
585
+ _queryParams.version = version;
586
+ }
587
+ if (limit != null) {
588
+ _queryParams.limit = limit.toString();
589
+ }
590
+ 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);
591
+ const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
592
+ 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, `construe/codes/${core.url.encodePathParam(codesystem)}/search/text`),
593
+ method: "GET",
594
+ headers: _headers,
595
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
596
+ 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,
597
+ 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,
598
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
599
+ });
600
+ if (_response.ok) {
601
+ return { data: _response.body, rawResponse: _response.rawResponse };
602
+ }
603
+ if (_response.error.reason === "status-code") {
604
+ switch (_response.error.statusCode) {
605
+ case 400:
606
+ throw new phenoml.construe.BadRequestError(_response.error.body, _response.rawResponse);
607
+ case 401:
608
+ throw new phenoml.construe.UnauthorizedError(_response.error.body, _response.rawResponse);
609
+ case 404:
610
+ throw new phenoml.construe.NotFoundError(_response.error.body, _response.rawResponse);
611
+ case 500:
612
+ throw new phenoml.construe.InternalServerError(_response.error.body, _response.rawResponse);
613
+ case 501:
614
+ throw new phenoml.construe.NotImplementedError(_response.error.body, _response.rawResponse);
615
+ case 503:
616
+ throw new phenoml.construe.ServiceUnavailableError(_response.error.body, _response.rawResponse);
617
+ default:
618
+ throw new errors.phenomlError({
619
+ statusCode: _response.error.statusCode,
620
+ body: _response.error.body,
621
+ rawResponse: _response.rawResponse,
622
+ });
623
+ }
624
+ }
625
+ switch (_response.error.reason) {
626
+ case "non-json":
627
+ throw new errors.phenomlError({
628
+ statusCode: _response.error.statusCode,
629
+ body: _response.error.rawBody,
630
+ rawResponse: _response.rawResponse,
631
+ });
632
+ case "timeout":
633
+ throw new errors.phenomlTimeoutError("Timeout exceeded when calling GET /construe/codes/{codesystem}/search/text.");
634
+ case "unknown":
635
+ throw new errors.phenomlError({
636
+ message: _response.error.errorMessage,
637
+ rawResponse: _response.rawResponse,
638
+ });
639
+ }
640
+ });
641
+ }
213
642
  _getAuthorizationHeader() {
214
643
  return __awaiter(this, void 0, void 0, function* () {
215
644
  return `Bearer ${yield core.Supplier.get(this._options.token)}`;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * version: "version"
5
+ * }
6
+ */
7
+ export interface GetConstrueCodesCodesystemCodeIdRequest {
8
+ /** Specific version of the code system */
9
+ version?: string;
10
+ }
@@ -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 });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * version: "2025",
5
+ * cursor: "cursor",
6
+ * limit: 1
7
+ * }
8
+ */
9
+ export interface GetConstrueCodesCodesystemRequest {
10
+ /** Specific version of the code system. Required if multiple versions exist. */
11
+ version?: string;
12
+ /** Pagination cursor from previous response */
13
+ cursor?: string;
14
+ /** Maximum number of codes to return (default 20) */
15
+ limit?: number;
16
+ }
@@ -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 });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * text: "patient has trouble breathing at night and wakes up gasping",
5
+ * version: "version",
6
+ * limit: 1
7
+ * }
8
+ */
9
+ export interface GetConstrueCodesCodesystemSearchSemanticRequest {
10
+ /** Natural language text to find semantically similar codes for */
11
+ text: string;
12
+ /** Specific version of the code system */
13
+ version?: string;
14
+ /** Maximum number of results (default 10, max 50) */
15
+ limit?: number;
16
+ }
@@ -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 });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * q: "E11.65",
5
+ * version: "version",
6
+ * limit: 1
7
+ * }
8
+ */
9
+ export interface GetConstrueCodesCodesystemSearchTextRequest {
10
+ /** Search query (searches code IDs and descriptions) */
11
+ q: string;
12
+ /** Specific version of the code system */
13
+ version?: string;
14
+ /** Maximum number of results (default 20, max 100) */
15
+ limit?: number;
16
+ }