Skip to content

Commit 5e318c6

Browse files
Merge pull request #49 from PhenoML/fern-bot/2026-01-29T02-36Z
feat: add citation support and rename text search method
2 parents ea5198f + 0e460d9 commit 5e318c6

File tree

15 files changed

+170
-35
lines changed

15 files changed

+170
-35
lines changed

changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 3.1.0 - 2026-01-29
2+
* feat: add citation support and rename text search method
3+
* Adds source text citation functionality to code extraction and renames the text search method for better clarity. Citations provide exact text spans with character offsets showing where each code was found in the source text, enabling precise traceability.
4+
* Key changes:
5+
* Add Citation interface with text spans and character offsets
6+
* Add include_citations option to ExtractRequestConfig for sentence-based chunking
7+
* Add is_ancestor and citations fields to ExtractedCodeResult
8+
* Rename textSearchKeywordBased to terminologyServerTextSearch for clarity
9+
* Add CPT usage disclaimers and paid plan requirements to documentation
10+
* Add BadGatewayError (502) error handling to FHIR client methods
11+
* 🌿 Generated with Fern
12+
113
## 3.0.0 - 2026-01-21
214
* feat: make provider parameter required for agent operations
315
* This change makes the provider parameter required for agent create and update operations,

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": "3.0.0",
3+
"version": "3.1.0",
44
"private": false,
55
"repository": "github:PhenoML/phenoml-ts-sdk",
66
"type": "commonjs",

reference.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ await client.cohort.analyze({
11531153
<dl>
11541154
<dd>
11551155

1156-
Upload a custom medical code system with codes and descriptions for use in code extraction.
1156+
Upload a custom medical code system with codes and descriptions for use in code extraction. Requires a paid plan.
11571157
Upon upload, construe generates embeddings for all of the codes in the code system and stores them in the vector database so you can
11581158
subsequently use the code system for construe/extract and lang2fhir/create (coming soon!)
11591159
</dd>
@@ -1223,7 +1223,9 @@ await client.construe.uploadCodeSystem({
12231223
<dl>
12241224
<dd>
12251225

1226-
Converts natural language text into structured medical codes
1226+
Converts natural language text into structured medical codes.
1227+
1228+
Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
12271229
</dd>
12281230
</dl>
12291231
</dd>
@@ -1288,7 +1290,7 @@ await client.construe.extractCodes({
12881290
<dl>
12891291
<dd>
12901292

1291-
Returns metadata about all available code systems including built-in and custom systems.
1293+
Returns the terminology server's catalog of available code systems, including both built-in standard terminologies and custom uploaded systems.
12921294
</dd>
12931295
</dl>
12941296
</dd>
@@ -1343,7 +1345,9 @@ await client.construe.listAvailableCodeSystems();
13431345
<dl>
13441346
<dd>
13451347

1346-
Returns a paginated list of all codes in the specified code system.
1348+
Returns a paginated list of all codes in the specified code system from the terminology server.
1349+
1350+
Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
13471351
</dd>
13481352
</dl>
13491353
</dd>
@@ -1418,7 +1422,9 @@ await client.construe.listCodesInACodeSystem("ICD-10-CM", {
14181422
<dl>
14191423
<dd>
14201424

1421-
Returns details for a specific code within a code system.
1425+
Looks up a specific code in the terminology server and returns its details.
1426+
1427+
Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
14221428
</dd>
14231429
</dl>
14241430
</dd>
@@ -1514,6 +1520,8 @@ not just keywords.
15141520
conceptually similar results that keyword search would miss.
15151521

15161522
See also: `/search/text` for faster keyword-based lookup with typo tolerance.
1523+
1524+
Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
15171525
</dd>
15181526
</dl>
15191527
</dd>
@@ -1576,7 +1584,7 @@ await client.construe.semanticSearchEmbeddingBased("ICD-10-CM", {
15761584
</dl>
15771585
</details>
15781586

1579-
<details><summary><code>client.construe.<a href="/src/api/resources/construe/client/Client.ts">textSearchKeywordBased</a>(codesystem, { ...params }) -> phenoml.TextSearchResponse</code></summary>
1587+
<details><summary><code>client.construe.<a href="/src/api/resources/construe/client/Client.ts">terminologyServerTextSearch</a>(codesystem, { ...params }) -> phenoml.TextSearchResponse</code></summary>
15801588
<dl>
15811589
<dd>
15821590

@@ -1606,6 +1614,8 @@ the code ID or specific keywords. Fast response times suitable for typeahead int
16061614
Won't find conceptually related codes with different terminology.
16071615

16081616
See also: `/search/semantic` for finding conceptually similar codes.
1617+
1618+
Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
16091619
</dd>
16101620
</dl>
16111621
</dd>
@@ -1620,7 +1630,7 @@ See also: `/search/semantic` for finding conceptually similar codes.
16201630
<dd>
16211631

16221632
```typescript
1623-
await client.construe.textSearchKeywordBased("ICD-10-CM", {
1633+
await client.construe.terminologyServerTextSearch("ICD-10-CM", {
16241634
q: "E11.65",
16251635
version: "version",
16261636
limit: 1

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": "3.0.0",
44-
"User-Agent": "phenoml/3.0.0",
43+
"X-Fern-SDK-Version": "3.1.0",
44+
"User-Agent": "phenoml/3.1.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: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class Construe {
2121
}
2222

2323
/**
24-
* Upload a custom medical code system with codes and descriptions for use in code extraction.
24+
* Upload a custom medical code system with codes and descriptions for use in code extraction. Requires a paid plan.
2525
* Upon upload, construe generates embeddings for all of the codes in the code system and stores them in the vector database so you can
2626
* subsequently use the code system for construe/extract and lang2fhir/create (coming soon!)
2727
*
@@ -130,7 +130,9 @@ export class Construe {
130130
}
131131

132132
/**
133-
* Converts natural language text into structured medical codes
133+
* Converts natural language text into structured medical codes.
134+
*
135+
* Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
134136
*
135137
* @param {phenoml.construe.ExtractRequest} request
136138
* @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
@@ -228,7 +230,7 @@ export class Construe {
228230
}
229231

230232
/**
231-
* Returns metadata about all available code systems including built-in and custom systems.
233+
* Returns the terminology server's catalog of available code systems, including both built-in standard terminologies and custom uploaded systems.
232234
*
233235
* @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
234236
*
@@ -312,7 +314,9 @@ export class Construe {
312314
}
313315

314316
/**
315-
* Returns a paginated list of all codes in the specified code system.
317+
* Returns a paginated list of all codes in the specified code system from the terminology server.
318+
*
319+
* Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
316320
*
317321
* @param {string} codesystem - Code system name (e.g., "ICD-10-CM", "SNOMED_CT_US_LITE")
318322
* @param {phenoml.construe.GetConstrueCodesCodesystemRequest} request
@@ -423,7 +427,9 @@ export class Construe {
423427
}
424428

425429
/**
426-
* Returns details for a specific code within a code system.
430+
* Looks up a specific code in the terminology server and returns its details.
431+
*
432+
* Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
427433
*
428434
* @param {string} codesystem - Code system name
429435
* @param {string} codeId - The code identifier
@@ -547,6 +553,8 @@ export class Construe {
547553
*
548554
* See also: `/search/text` for faster keyword-based lookup with typo tolerance.
549555
*
556+
* Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
557+
*
550558
* @param {string} codesystem - Code system name
551559
* @param {phenoml.construe.GetConstrueCodesCodesystemSearchSemanticRequest} request
552560
* @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
@@ -679,6 +687,8 @@ export class Construe {
679687
*
680688
* See also: `/search/semantic` for finding conceptually similar codes.
681689
*
690+
* Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
691+
*
682692
* @param {string} codesystem - Code system name
683693
* @param {phenoml.construe.GetConstrueCodesCodesystemSearchTextRequest} request
684694
* @param {Construe.RequestOptions} requestOptions - Request-specific configuration.
@@ -691,21 +701,23 @@ export class Construe {
691701
* @throws {@link phenoml.construe.ServiceUnavailableError}
692702
*
693703
* @example
694-
* await client.construe.textSearchKeywordBased("ICD-10-CM", {
704+
* await client.construe.terminologyServerTextSearch("ICD-10-CM", {
695705
* q: "E11.65",
696706
* version: "version",
697707
* limit: 1
698708
* })
699709
*/
700-
public textSearchKeywordBased(
710+
public terminologyServerTextSearch(
701711
codesystem: string,
702712
request: phenoml.construe.GetConstrueCodesCodesystemSearchTextRequest,
703713
requestOptions?: Construe.RequestOptions,
704714
): core.HttpResponsePromise<phenoml.construe.TextSearchResponse> {
705-
return core.HttpResponsePromise.fromPromise(this.__textSearchKeywordBased(codesystem, request, requestOptions));
715+
return core.HttpResponsePromise.fromPromise(
716+
this.__terminologyServerTextSearch(codesystem, request, requestOptions),
717+
);
706718
}
707719

708-
private async __textSearchKeywordBased(
720+
private async __terminologyServerTextSearch(
709721
codesystem: string,
710722
request: phenoml.construe.GetConstrueCodesCodesystemSearchTextRequest,
711723
requestOptions?: Construe.RequestOptions,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This file was auto-generated by Fern from our API Definition.
2+
3+
/**
4+
* A reference to source text that led to a code extraction
5+
*/
6+
export interface Citation {
7+
/** The exact text span containing evidence for the code */
8+
text: string;
9+
/** Starting byte offset in the original input text (0-indexed) */
10+
begin_offset: number;
11+
/** Ending byte offset (exclusive), such that input[begin_offset:end_offset] == text */
12+
end_offset: number;
13+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ export interface ExtractRequestConfig {
2525
include_ancestors?: boolean;
2626
/** Whether to include codes that failed validation in the results */
2727
include_invalid?: boolean;
28+
/**
29+
* Whether to include source text citations for each extracted code.
30+
* Citations show the exact text spans (with character offsets) that led to each code.
31+
* Only available when using chunking_method: "sentences".
32+
* The "none" method returns full text as one chunk (not useful for citations).
33+
* LLM-based chunking (paragraphs, topics) does not support citations.
34+
*/
35+
include_citations?: boolean;
2836
}
2937

3038
export namespace ExtractRequestConfig {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export interface ExtractRequestSystem {
1414
* * CPT - version 2025
1515
*
1616
* Custom systems:
17-
* * Any valid system name configured in your environment. Must have self-hosted construe module.
17+
* * Any valid system name uploaded via /construe/upload. Requires a paid plan.
18+
*
19+
* Usage of CPT is subject to AMA requirements: see PhenoML Terms of Service.
1820
*/
1921
name?: string;
2022
/** Code system version. Must match the version available in your environment. */

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// This file was auto-generated by Fern from our API Definition.
22

3+
import type * as phenoml from "../../../index.js";
4+
35
export interface ExtractedCodeResult {
46
/** The extracted code */
57
code: string;
@@ -11,4 +13,15 @@ export interface ExtractedCodeResult {
1113
longDescription?: string;
1214
/** Explanation for why this code was extracted (if include_rationale is true) */
1315
rationale?: string;
16+
/**
17+
* Whether this code is an ancestor (parent) of an extracted code rather than directly extracted.
18+
* Only present when include_ancestors is true.
19+
*/
20+
is_ancestor?: boolean;
21+
/**
22+
* Source text references showing where this code was found in the input.
23+
* Only present when include_citations is true and chunking method supports it.
24+
* Ancestor codes do not receive citations.
25+
*/
26+
citations?: phenoml.construe.Citation[];
1427
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./Citation.js";
12
export * from "./CodeResponse.js";
23
export * from "./CodeSystemDetails.js";
34
export * from "./CodeSystemInfo.js";

0 commit comments

Comments
 (0)