Skip to content

Commit 669e17c

Browse files
authored
Merge pull request #63 from PhenoML/fern-bot/2026-02-09T15-51Z
feat: add custom code system export endpoint
2 parents 7241357 + 7e4378b commit 669e17c

File tree

13 files changed

+406
-29
lines changed

13 files changed

+406
-29
lines changed

changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 5.3.0 - 2026-02-09
2+
* feat: add custom code system export endpoint
3+
* Add new exportCustomCodeSystem method to the construe client that allows exporting custom (non-builtin) code systems as JSON files. This feature enables users to backup and transfer code systems between instances.
4+
* Key changes:
5+
* Add exportCustomCodeSystem method to Construe client with GET endpoint
6+
* Create ExportCodeSystemResponse type definition for structured export data
7+
* Add GetConstrueCodesSystemsCodesystemExportRequest for version parameter
8+
* Include comprehensive test coverage for all HTTP response codes
9+
* Remove ForbiddenError from fhirProvider.get method and related tests
10+
* 🌿 Generated with Fern
11+
112
## 5.2.0 - 2026-02-08
213
* feat: refactor upload request structure with format-specific types
314
* Refactor the upload code system functionality to use a discriminated union approach with format-specific request types. This improves type safety and API clarity by separating CSV and JSON upload requirements.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "phenoml",
3-
"version": "5.2.0",
3+
"version": "5.3.0",
44
"private": false,
55
"repository": "github:PhenoML/phenoml-ts-sdk",
66
"type": "commonjs",

reference.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,81 @@ await client.construe.deleteCustomCodeSystem("CUSTOM_CODES", {
14781478
</dl>
14791479

14801480

1481+
</dd>
1482+
</dl>
1483+
</details>
1484+
1485+
<details><summary><code>client.construe.<a href="/src/api/resources/construe/client/Client.ts">exportCustomCodeSystem</a>(codesystem, { ...params }) -> phenoml.ExportCodeSystemResponse</code></summary>
1486+
<dl>
1487+
<dd>
1488+
1489+
#### 📝 Description
1490+
1491+
<dl>
1492+
<dd>
1493+
1494+
<dl>
1495+
<dd>
1496+
1497+
Exports a custom (non-builtin) code system as a JSON file compatible with the upload format.
1498+
The exported file can be re-uploaded directly via POST /construe/upload with format "json".
1499+
Only available on dedicated instances. Builtin systems cannot be exported.
1500+
</dd>
1501+
</dl>
1502+
</dd>
1503+
</dl>
1504+
1505+
#### 🔌 Usage
1506+
1507+
<dl>
1508+
<dd>
1509+
1510+
<dl>
1511+
<dd>
1512+
1513+
```typescript
1514+
await client.construe.exportCustomCodeSystem("CUSTOM_CODES", {
1515+
version: "version"
1516+
});
1517+
1518+
```
1519+
</dd>
1520+
</dl>
1521+
</dd>
1522+
</dl>
1523+
1524+
#### ⚙️ Parameters
1525+
1526+
<dl>
1527+
<dd>
1528+
1529+
<dl>
1530+
<dd>
1531+
1532+
**codesystem:** `string` — Code system name
1533+
1534+
</dd>
1535+
</dl>
1536+
1537+
<dl>
1538+
<dd>
1539+
1540+
**request:** `phenoml.construe.GetConstrueCodesSystemsCodesystemExportRequest`
1541+
1542+
</dd>
1543+
</dl>
1544+
1545+
<dl>
1546+
<dd>
1547+
1548+
**requestOptions:** `Construe.RequestOptions`
1549+
1550+
</dd>
1551+
</dl>
1552+
</dd>
1553+
</dl>
1554+
1555+
14811556
</dd>
14821557
</dl>
14831558
</details>

src/Client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export class phenomlClient {
4040
{
4141
"X-Fern-Language": "JavaScript",
4242
"X-Fern-SDK-Name": "phenoml",
43-
"X-Fern-SDK-Version": "5.2.0",
44-
"User-Agent": "phenoml/5.2.0",
43+
"X-Fern-SDK-Version": "5.3.0",
44+
"User-Agent": "phenoml/5.3.0",
4545
"X-Fern-Runtime": core.RUNTIME.type,
4646
"X-Fern-Runtime-Version": core.RUNTIME.version,
4747
},

src/api/resources/construe/client/Client.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,126 @@ export class Construe {
534534
}
535535
}
536536

537+
/**
538+
* Exports a custom (non-builtin) code system as a JSON file compatible with the upload format.
539+
* The exported file can be re-uploaded directly via POST /construe/upload with format "json".
540+
* Only available on dedicated instances. Builtin systems cannot be exported.
541+
*
542+
* @param {string} codesystem - Code system name
543+
* @param {phenoml.construe.GetConstrueCodesSystemsCodesystemExportRequest} request
544+
* @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
545+
*
546+
* @throws {@link phenoml.construe.BadRequestError}
547+
* @throws {@link phenoml.construe.UnauthorizedError}
548+
* @throws {@link phenoml.construe.ForbiddenError}
549+
* @throws {@link phenoml.construe.NotFoundError}
550+
* @throws {@link phenoml.construe.ConflictError}
551+
* @throws {@link phenoml.construe.FailedDependencyError}
552+
* @throws {@link phenoml.construe.InternalServerError}
553+
*
554+
* @example
555+
* await client.construe.exportCustomCodeSystem("CUSTOM_CODES", {
556+
* version: "version"
557+
* })
558+
*/
559+
public exportCustomCodeSystem(
560+
codesystem: string,
561+
request: phenoml.construe.GetConstrueCodesSystemsCodesystemExportRequest = {},
562+
requestOptions?: Construe.RequestOptions,
563+
): core.HttpResponsePromise<phenoml.construe.ExportCodeSystemResponse> {
564+
return core.HttpResponsePromise.fromPromise(this.__exportCustomCodeSystem(codesystem, request, requestOptions));
565+
}
566+
567+
private async __exportCustomCodeSystem(
568+
codesystem: string,
569+
request: phenoml.construe.GetConstrueCodesSystemsCodesystemExportRequest = {},
570+
requestOptions?: Construe.RequestOptions,
571+
): Promise<core.WithRawResponse<phenoml.construe.ExportCodeSystemResponse>> {
572+
const { version } = request;
573+
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
574+
if (version != null) {
575+
_queryParams.version = version;
576+
}
577+
578+
const _headers: core.Fetcher.Args["headers"] = mergeHeaders(
579+
this._options?.headers,
580+
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
581+
requestOptions?.headers,
582+
);
583+
const _response = await (this._options.fetcher ?? core.fetcher)({
584+
url: core.url.join(
585+
(await core.Supplier.get(this._options.baseUrl)) ??
586+
(await core.Supplier.get(this._options.environment)) ??
587+
environments.phenomlEnvironment.Default,
588+
`construe/codes/systems/${core.url.encodePathParam(codesystem)}/export`,
589+
),
590+
method: "GET",
591+
headers: _headers,
592+
queryParameters: { ..._queryParams, ...requestOptions?.queryParams },
593+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
594+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
595+
abortSignal: requestOptions?.abortSignal,
596+
});
597+
if (_response.ok) {
598+
return {
599+
data: _response.body as phenoml.construe.ExportCodeSystemResponse,
600+
rawResponse: _response.rawResponse,
601+
};
602+
}
603+
604+
if (_response.error.reason === "status-code") {
605+
switch (_response.error.statusCode) {
606+
case 400:
607+
throw new phenoml.construe.BadRequestError(_response.error.body as unknown, _response.rawResponse);
608+
case 401:
609+
throw new phenoml.construe.UnauthorizedError(
610+
_response.error.body as unknown,
611+
_response.rawResponse,
612+
);
613+
case 403:
614+
throw new phenoml.construe.ForbiddenError(_response.error.body as unknown, _response.rawResponse);
615+
case 404:
616+
throw new phenoml.construe.NotFoundError(_response.error.body as unknown, _response.rawResponse);
617+
case 409:
618+
throw new phenoml.construe.ConflictError(_response.error.body as unknown, _response.rawResponse);
619+
case 424:
620+
throw new phenoml.construe.FailedDependencyError(
621+
_response.error.body as unknown,
622+
_response.rawResponse,
623+
);
624+
case 500:
625+
throw new phenoml.construe.InternalServerError(
626+
_response.error.body as unknown,
627+
_response.rawResponse,
628+
);
629+
default:
630+
throw new errors.phenomlError({
631+
statusCode: _response.error.statusCode,
632+
body: _response.error.body,
633+
rawResponse: _response.rawResponse,
634+
});
635+
}
636+
}
637+
638+
switch (_response.error.reason) {
639+
case "non-json":
640+
throw new errors.phenomlError({
641+
statusCode: _response.error.statusCode,
642+
body: _response.error.rawBody,
643+
rawResponse: _response.rawResponse,
644+
});
645+
case "timeout":
646+
throw new errors.phenomlTimeoutError(
647+
"Timeout exceeded when calling GET /construe/codes/systems/{codesystem}/export.",
648+
);
649+
case "unknown":
650+
throw new errors.phenomlError({
651+
message: _response.error.errorMessage,
652+
rawResponse: _response.rawResponse,
653+
});
654+
}
655+
}
656+
537657
/**
538658
* Returns a paginated list of all codes in the specified code system from the terminology server.
539659
*
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
/**
4+
* @example
5+
* {
6+
* version: "version"
7+
* }
8+
*/
9+
export interface GetConstrueCodesSystemsCodesystemExportRequest {
10+
/** Specific version of the code system. Required if multiple versions exist. */
11+
version?: string;
12+
}

src/api/resources/construe/client/requests/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export type { GetConstrueCodesCodesystemCodeIdRequest } from "./GetConstrueCodes
44
export type { GetConstrueCodesCodesystemRequest } from "./GetConstrueCodesCodesystemRequest.js";
55
export type { GetConstrueCodesCodesystemSearchSemanticRequest } from "./GetConstrueCodesCodesystemSearchSemanticRequest.js";
66
export type { GetConstrueCodesCodesystemSearchTextRequest } from "./GetConstrueCodesCodesystemSearchTextRequest.js";
7+
export type { GetConstrueCodesSystemsCodesystemExportRequest } from "./GetConstrueCodesSystemsCodesystemExportRequest.js";
78
export type { GetConstrueCodesSystemsCodesystemRequest } from "./GetConstrueCodesSystemsCodesystemRequest.js";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
import type * as phenoml from "../../../index.js";
4+
5+
export interface ExportCodeSystemResponse {
6+
/** Code system name */
7+
name: string;
8+
/** Code system version */
9+
version: string;
10+
/** Upload format (always "json") */
11+
format: "json";
12+
/** All codes in the system */
13+
codes: phenoml.construe.CodeResponse[];
14+
}

src/api/resources/construe/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from "./CodeSystemDetails.js";
44
export * from "./CodeSystemInfo.js";
55
export * from "./ConstrueUploadCodeSystemResponse.js";
66
export * from "./DeleteCodeSystemResponse.js";
7+
export * from "./ExportCodeSystemResponse.js";
78
export * from "./ExtractCodesResult.js";
89
export * from "./ExtractedCodeResult.js";
910
export * from "./ExtractRequestConfig.js";

src/api/resources/fhirProvider/client/Client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ export class FhirProvider {
226226
* @param {FhirProvider.RequestOptions} requestOptions - Request-specific configuration.
227227
*
228228
* @throws {@link phenoml.fhirProvider.UnauthorizedError}
229-
* @throws {@link phenoml.fhirProvider.ForbiddenError}
230229
* @throws {@link phenoml.fhirProvider.NotFoundError}
231230
* @throws {@link phenoml.fhirProvider.InternalServerError}
232231
*
@@ -277,11 +276,6 @@ export class FhirProvider {
277276
_response.error.body as unknown,
278277
_response.rawResponse,
279278
);
280-
case 403:
281-
throw new phenoml.fhirProvider.ForbiddenError(
282-
_response.error.body as unknown,
283-
_response.rawResponse,
284-
);
285279
case 404:
286280
throw new phenoml.fhirProvider.NotFoundError(
287281
_response.error.body as unknown,

0 commit comments

Comments
 (0)