Skip to content

Commit b995c60

Browse files
authored
[healthinsights] Migrate healthinsights projects to use snippets extraction (#33164)
### Packages impacted by this PR - @azure-rest/health-insights-cancerprofiling - @azure-rest/health-insights-clinicalmatching - @azure-rest/health-insights-radiologyinsights ### Issues associated with this PR - #32416 ### Describe the problem that is addressed by this PR Updates all projects under `healthinsights` to use snippets extraction. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 263d592 commit b995c60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1703
-824
lines changed

sdk/healthinsights/health-insights-cancerprofiling-rest/README.md

+110-110
Original file line numberDiff line numberDiff line change
@@ -58,44 +58,50 @@ The Cancer Profiling model allows you to infer cancer attributes such as tumor s
5858

5959
- [Infer Cancer Profiling](#cancer_profiling)
6060

61-
```typescript
62-
const apiKey = process.env["HEALTH_INSIGHTS_API_KEY"] || "";
63-
const endpoint = process.env["HEALTH_INSIGHTS_ENDPOINT"] || "";
61+
```ts snippet:ReadmeSampleInferCanerProfiling
62+
import { AzureKeyCredential } from "@azure/core-auth";
63+
import CancerProfilingRestClient, {
64+
OncoPhenotypeData,
65+
isUnexpected,
66+
getLongRunningPoller,
67+
} from "@azure-rest/health-insights-cancerprofiling";
68+
69+
const endpoint = "https://<your-endpoint>";
70+
const apiKey = "<your-api-key>";
6471
const credential = new AzureKeyCredential(apiKey);
6572
const client = CancerProfilingRestClient(endpoint, credential);
6673

67-
// Define patient information and clinical documents for the request body
74+
// Define patient information and clinical documents
6875
const patientInfo = {
6976
sex: "FEMALE",
7077
birthDate: new Date("1979-10-08T00:00:00.000Z"), // Note: Months are zero-based (11 represents December)
7178
};
7279

73-
const doc1 = "15.8.2021";
74-
("Jane Doe 091175-8967");
75-
("42 year old female, married with 3 children, works as a nurse. ");
76-
("Healthy, no medications taken on a regular basis.");
77-
("PMHx is significant for migraines with aura, uses Mirena for contraception.");
78-
("Smoking history of 10 pack years (has stopped and relapsed several times).");
79-
("She is in c/o 2 weeks of productive cough and shortness of breath.");
80-
("She has a fever of 37.8 and general weakness. ");
81-
("Denies night sweats and rash. She denies symptoms of rhinosinusitis, asthma, and heartburn. ");
82-
("On PE:");
83-
("GENERAL: mild pallor, no cyanosis. Regular breathing rate. ");
84-
("LUNGS: decreased breath sounds on the base of the right lung. Vesicular breathing.");
85-
(" No crackles, rales, and wheezes. Resonant percussion. ");
86-
("PLAN: ");
87-
("Will be referred for a chest x-ray. ");
88-
("======================================");
89-
("CXR showed mild nonspecific opacities in right lung base. ");
90-
("PLAN:");
91-
("Findings are suggestive of a working diagnosis of pneumonia. The patient is referred to a ");
92-
("follow-up CXR in 2 weeks. ");
80+
const doc1 = `15.8.2021
81+
Jane Doe 091175-8967
82+
42 year old female, married with 3 children, works as a nurse.
83+
Healthy, no medications taken on a regular basis.
84+
PMHx is significant for migraines with aura, uses Mirena for contraception.
85+
Smoking history of 10 pack years (has stopped and relapsed several times).
86+
She is in c/o 2 weeks of productive cough and shortness of breath.
87+
She has a fever of 37.8 and general weakness.
88+
Denies night sweats and rash. She denies symptoms of rhinosinusitis, asthma, and heartburn.
89+
On PE:
90+
GENERAL: mild pallor, no cyanosis. Regular breathing rate.
91+
LUNGS: decreased breath sounds on the base of the right lung. Vesicular breathing.
92+
No crackles, rales, and wheezes. Resonant percussion.
93+
PLAN:
94+
Will be referred for a chest x-ray.
95+
======================================
96+
CXR showed mild nonspecific opacities in right lung base.
97+
PLAN:
98+
Findings are suggestive of a working diagnosis of pneumonia. The patient is referred to a
99+
follow-up CXR in 2 weeks.`;
93100

94101
const docContent = {
95102
sourceType: "INLINE",
96103
value: doc1,
97104
};
98-
99105
const patientDoc1 = {
100106
type: "NOTE",
101107
id: "doc1",
@@ -105,76 +111,77 @@ const patientDoc1 = {
105111
createdDateTime: new Date("2021-15-08T00:00:00.000Z"),
106112
};
107113

108-
const doc1 = `15.8.2021
109-
Jane Doe 091175-8967
110-
42 year old female, married with 3 children, works as a nurse.
111-
Healthy, no medications taken on a regular basis.
112-
PMHx is significant for migraines with aura, uses Mirena for contraception.
113-
Smoking history of 10 pack years (has stopped and relapsed several times).
114-
She is in c/o 2 weeks of productive cough and shortness of breath.
115-
She has a fever of 37.8 and general weakness.
116-
Denies night sweats and rash. She denies symptoms of rhinosinusitis, asthma, and heartburn.
117-
On PE:
118-
GENERAL: mild pallor, no cyanosis. Regular breathing rate.
119-
LUNGS: decreased breath sounds on the base of the right lung. Vesicular breathing.
120-
No crackles, rales, and wheezes. Resonant percussion.
121-
PLAN:
122-
Will be referred for a chest x-ray.
123-
======================================
124-
CXR showed mild nonspecific opacities in right lung base.
125-
PLAN:
126-
Findings are suggestive of a working diagnosis of pneumonia. The patient is referred to a
127-
follow-up CXR in 2 weeks. `;
114+
// Define patientDoc2 and patientDoc3 similarly
115+
const doc2 = `Oncology Clinic
116+
20.10.2021
117+
Jane Doe 091175-8967
118+
42-year-old healthy female who works as a nurse in the ER of this hospital.
119+
First menstruation at 11 years old. First delivery- 27 years old. She has 3 children.
120+
Didn’t breastfeed.
121+
Contraception- Mirena.
122+
Smoking- 10 pack years.
123+
Mother- Belarusian. Father- Georgian.
124+
About 3 months prior to admission, she stated she had SOB and was febrile.
125+
She did a CXR as an outpatient which showed a finding in the base of the right lung-
126+
possibly an infiltrate.
127+
She was treated with antibiotics with partial response.
128+
6 weeks later a repeat CXR was performed- a few solid dense findings in the right lung.
129+
Therefore, she was referred for a PET-CT which demonstrated increased uptake in the right
130+
breast, lymph nodes on the right a few areas in the lungs and liver.
131+
On biopsy from the lesion in the right breast- triple negative adenocarcinoma. Genetic
132+
testing has not been done thus far.
133+
Genetic counseling- the patient denies a family history of breast, ovary, uterus,
134+
and prostate cancer. Her mother has chronic lymphocytic leukemia (CLL).
135+
She is planned to undergo genetic tests because the aggressive course of the disease,
136+
and her young age.
137+
Impression:
138+
Stage 4 triple negative breast adenocarcinoma.
139+
Could benefit from biological therapy.
140+
Different treatment options were explained- the patient wants to get a second opinion.`;
128141

129-
const docContent = {
142+
const docContent2 = {
130143
sourceType: "INLINE",
131-
value: doc1,
144+
value: doc2,
132145
};
133146

134-
const patientDoc1 = {
147+
const patientDoc2 = {
135148
type: "NOTE",
136-
id: "doc1",
137-
content: docContent,
138-
clinicalType: "IMAGING",
149+
id: "doc2",
150+
content: docContent2,
151+
clinicalType: "PATHOLOGY",
139152
language: "en",
140-
createdDateTime: new Date("2021-15-08T00:00:00.000Z"),
153+
createdDateTime: new Date("2021-10-20T00:00:00.000Z"),
141154
};
142155

143-
const doc2 = `Oncology Clinic
144-
20.10.2021
145-
Jane Doe 091175-8967
146-
42-year-old healthy female who works as a nurse in the ER of this hospital.
147-
First menstruation at 11 years old. First delivery- 27 years old. She has 3 children.
148-
Didn’t breastfeed.
149-
Contraception- Mirena.
150-
Smoking- 10 pack years.
151-
Mother- Belarusian. Father- Georgian.
152-
About 3 months prior to admission, she stated she had SOB and was febrile.
153-
She did a CXR as an outpatient which showed a finding in the base of the right lung-
154-
possibly an infiltrate.
155-
She was treated with antibiotics with partial response.
156-
6 weeks later a repeat CXR was performed- a few solid dense findings in the right lung.
157-
Therefore, she was referred for a PET-CT which demonstrated increased uptake in the right
158-
breast, lymph nodes on the right a few areas in the lungs and liver.
159-
On biopsy from the lesion in the right breast- triple negative adenocarcinoma. Genetic
160-
testing has not been done thus far.
161-
Genetic counseling- the patient denies a family history of breast, ovary, uterus,
162-
and prostate cancer. Her mother has chronic lymphocytic leukemia (CLL).
163-
She is planned to undergo genetic tests because the aggressive course of the disease,
164-
and her young age.
165-
Impression:
166-
Stage 4 triple negative breast adenocarcinoma.
167-
Could benefit from biological therapy.
168-
Different treatment options were explained- the patient wants to get a second opinion.`;
169-
170-
const docContent2 = {
156+
const doc3 = `PATHOLOGY REPORT
157+
Clinical Information
158+
Ultrasound-guided biopsy; A. 18 mm mass; most likely diagnosis based on imaging: IDC
159+
Diagnosis
160+
A. BREAST, LEFT AT 2:00 4 CM FN; ULTRASOUND-GUIDED NEEDLE CORE BIOPSIES:
161+
- Invasive carcinoma of no special type (invasive ductal carcinoma), grade 1
162+
Nottingham histologic grade: 1/3 (tubules 2; nuclear grade 2; mitotic rate 1;
163+
total score; 5/9)
164+
Fragments involved by invasive carcinoma: 2
165+
Largest measurement of invasive carcinoma on a single fragment: 7 mm
166+
Ductal carcinoma in situ (DCIS): Present
167+
Architectural pattern: Cribriform
168+
Nuclear grade: 2-
169+
-intermediate
170+
Necrosis: Not identified
171+
Fragments involved by DCIS: 1
172+
Largest measurement of DCIS on a single fragment: Span 2 mm
173+
Microcalcifications: Present in benign breast tissue and invasive carcinoma
174+
Blocks with invasive carcinoma: A1
175+
Special studies: Pending`;
176+
177+
const docContent3 = {
171178
sourceType: "INLINE",
172-
value: doc2,
179+
value: doc3,
173180
};
174181

175-
const patientDoc2 = {
182+
const patientDoc3 = {
176183
type: "NOTE",
177-
id: "doc2",
184+
id: "doc3",
178185
content: docContent3,
179186
clinicalType: "PATHOLOGY",
180187
language: "en",
@@ -184,7 +191,7 @@ const patientDoc2 = {
184191
const patient1 = {
185192
id: "patient_id",
186193
info: patientInfo,
187-
data: [patientDoc1, patientDoc2],
194+
data: [patientDoc1, patientDoc2, patientDoc3],
188195
};
189196

190197
const cancerProfilingData: OncoPhenotypeData = {
@@ -199,41 +206,34 @@ const parameters = {
199206
// Initiate cancer profiling job and retrieve results
200207
const initialResponse = await client.path("/oncophenotype/jobs").post(parameters);
201208
if (isUnexpected(initialResponse)) {
202-
throw initialResponse;
209+
throw initialResponse.body.error;
203210
}
211+
204212
const poller = await getLongRunningPoller(client, initialResponse);
205213
const cancerProfilingResult = await poller.pollUntilDone();
206214
if (isUnexpected(cancerProfilingResult)) {
207-
throw cancerProfilingResult;
215+
throw cancerProfilingResult.body.error;
208216
}
217+
209218
const resultBody = cancerProfilingResult.body;
210219
// Print the inference results for a patient's cancer attributes
211-
if (cancerProfilingResult.status === "succeeded") {
212-
const results = cancerProfilingResult.results;
213-
if (results) {
214-
for (const patientResult of results.patients) {
215-
console.log(`Inferences of Patient ${patientResult.id}`);
216-
for (const { type, value, confidenceScore, evidence } of patientResult.inferences) {
217-
console.log(
218-
`Clinical Type: ${String(type)} Value: ${value}, ConfidenceScore: ${confidenceScore}`,
219-
);
220-
for (const { patientDataEvidence } of evidence || []) {
221-
if (patientDataEvidence) {
222-
console.log(
223-
`Evidence: ${patientDataEvidence.id} ${patientDataEvidence.offset} ${patientDataEvidence.length} ${patientDataEvidence.text}`,
224-
);
225-
}
220+
const results = resultBody.results;
221+
if (results) {
222+
for (const patientResult of results.patients) {
223+
console.log(`Inferences of Patient ${patientResult.id}`);
224+
for (const { type, value, confidenceScore, evidence } of patientResult.inferences) {
225+
console.log(
226+
`Clinical Type: ${String(type)} Value: ${value}, ConfidenceScore: ${confidenceScore}`,
227+
);
228+
for (const { patientDataEvidence } of evidence || []) {
229+
if (patientDataEvidence) {
230+
console.log(
231+
`Evidence: ${patientDataEvidence.id} ${patientDataEvidence.offset} ${patientDataEvidence.length} ${patientDataEvidence.text}`,
232+
);
226233
}
227234
}
228235
}
229236
}
230-
} else {
231-
const errors = cancerProfilingResult.errors;
232-
if (errors) {
233-
for (const error of errors) {
234-
console.log(error.code, ":", error.message);
235-
}
236-
}
237237
}
238238
```
239239

@@ -243,8 +243,8 @@ if (cancerProfilingResult.status === "succeeded") {
243243

244244
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
245245

246-
```javascript
247-
const { setLogLevel } = require("@azure/logger");
246+
```ts snippet:SetLogLevel
247+
import { setLogLevel } from "@azure/logger";
248248

249249
setLogLevel("info");
250250
```

sdk/healthinsights/health-insights-cancerprofiling-rest/package.json

+12-11
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
5454
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
5555
"unit-test:node": "dev-tool run test:vitest",
56-
"update-snippets": "echo skipped"
56+
"update-snippets": "dev-tool run update-snippets"
5757
},
5858
"sideEffects": false,
5959
"autoPublish": false,
@@ -62,7 +62,7 @@
6262
"@azure/abort-controller": "^2.1.2",
6363
"@azure/core-auth": "^1.9.0",
6464
"@azure/core-lro": "^2.7.2",
65-
"@azure/core-rest-pipeline": "^1.18.0",
65+
"@azure/core-rest-pipeline": "^1.19.0",
6666
"@azure/logger": "^1.1.4",
6767
"tslib": "^2.8.1"
6868
},
@@ -72,16 +72,16 @@
7272
"@azure-tools/test-utils-vitest": "^1.0.0",
7373
"@azure/dev-tool": "^1.0.0",
7474
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
75-
"@azure/identity": "^4.0.1",
75+
"@azure/identity": "^4.7.0",
7676
"@types/node": "^18.0.0",
77-
"@vitest/browser": "^3.0.3",
78-
"@vitest/coverage-istanbul": "^3.0.3",
77+
"@vitest/browser": "^3.0.6",
78+
"@vitest/coverage-istanbul": "^3.0.6",
7979
"autorest": "latest",
8080
"dotenv": "^16.0.0",
8181
"eslint": "^9.9.0",
82-
"playwright": "^1.49.0",
82+
"playwright": "^1.50.1",
8383
"typescript": "~5.7.2",
84-
"vitest": "^3.0.3"
84+
"vitest": "^3.0.6"
8585
},
8686
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthinsights/health-insights-cancerprofiling-rest/README.md",
8787
"//metadata": {
@@ -94,7 +94,7 @@
9494
},
9595
"browser": "./dist/browser/index.js",
9696
"//sampleConfiguration": {
97-
"productName": "HealthInsightsCancerprifiling",
97+
"productName": "HealthInsightsCancerprofiling",
9898
"productSlugs": [
9999
"azure"
100100
],
@@ -103,6 +103,7 @@
103103
},
104104
"type": "module",
105105
"tshy": {
106+
"project": "./tsconfig.src.json",
106107
"exports": {
107108
"./package.json": "./package.json",
108109
".": "./src/index.ts"
@@ -115,8 +116,7 @@
115116
"browser",
116117
"react-native"
117118
],
118-
"selfLink": false,
119-
"project": "./tsconfig.src.json"
119+
"selfLink": false
120120
},
121121
"exports": {
122122
"./package.json": "./package.json",
@@ -138,5 +138,6 @@
138138
"default": "./dist/commonjs/index.js"
139139
}
140140
}
141-
}
141+
},
142+
"react-native": "./dist/react-native/index.js"
142143
}

sdk/healthinsights/health-insights-cancerprofiling-rest/samples/v1-beta/typescript/src/sample_infer_cancer_profiling.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@
1010

1111
import {AzureKeyCredential} from "@azure/core-auth";
1212

13-
import * as dotenv from "dotenv";
13+
import "dotenv/config";
1414
import CancerProfilingRestClient, {
1515
CreateJobParameters,
1616
getLongRunningPoller,
1717
isUnexpected,
1818
OncoPhenotypeData,
1919
OncoPhenotypeResultOutput
20-
} from "../src";
21-
22-
dotenv.config();
23-
20+
} from "../src/index.js";
2421
// You will need to set this environment variables or edit the following values
2522
const endpoint = process.env["HEALTH_INSIGHTS_ENDPOINT"] || "";
2623
const apiKey = process.env["HEALTH_INSIGHTS_API_KEY"] || "";
@@ -188,7 +185,7 @@ function createRequestBody(): CreateJobParameters {
188185
};
189186

190187
}
191-
export async function main() {
188+
export async function main(): Promise<void> {
192189
const credential = new AzureKeyCredential(apiKey);
193190
const client = CancerProfilingRestClient(endpoint, credential);
194191
// Create body request for cancer profiling

0 commit comments

Comments
 (0)