Skip to content

Commit

Permalink
[healthinsights] Migrate healthinsights projects to use snippets extr…
Browse files Browse the repository at this point in the history
…action (Azure#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

- Azure#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)
  • Loading branch information
mpodwysocki authored Feb 24, 2025
1 parent 263d592 commit b995c60
Show file tree
Hide file tree
Showing 41 changed files with 1,703 additions and 824 deletions.
220 changes: 110 additions & 110 deletions sdk/healthinsights/health-insights-cancerprofiling-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,50 @@ The Cancer Profiling model allows you to infer cancer attributes such as tumor s

- [Infer Cancer Profiling](#cancer_profiling)

```typescript
const apiKey = process.env["HEALTH_INSIGHTS_API_KEY"] || "";
const endpoint = process.env["HEALTH_INSIGHTS_ENDPOINT"] || "";
```ts snippet:ReadmeSampleInferCanerProfiling
import { AzureKeyCredential } from "@azure/core-auth";
import CancerProfilingRestClient, {
OncoPhenotypeData,
isUnexpected,
getLongRunningPoller,
} from "@azure-rest/health-insights-cancerprofiling";

const endpoint = "https://<your-endpoint>";
const apiKey = "<your-api-key>";
const credential = new AzureKeyCredential(apiKey);
const client = CancerProfilingRestClient(endpoint, credential);

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

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

const docContent = {
sourceType: "INLINE",
value: doc1,
};

const patientDoc1 = {
type: "NOTE",
id: "doc1",
Expand All @@ -105,76 +111,77 @@ const patientDoc1 = {
createdDateTime: new Date("2021-15-08T00:00:00.000Z"),
};

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

const docContent = {
const docContent2 = {
sourceType: "INLINE",
value: doc1,
value: doc2,
};

const patientDoc1 = {
const patientDoc2 = {
type: "NOTE",
id: "doc1",
content: docContent,
clinicalType: "IMAGING",
id: "doc2",
content: docContent2,
clinicalType: "PATHOLOGY",
language: "en",
createdDateTime: new Date("2021-15-08T00:00:00.000Z"),
createdDateTime: new Date("2021-10-20T00:00:00.000Z"),
};

const doc2 = `Oncology Clinic
20.10.2021
Jane Doe 091175-8967
42-year-old healthy female who works as a nurse in the ER of this hospital.
First menstruation at 11 years old. First delivery- 27 years old. She has 3 children.
Didn’t breastfeed.
Contraception- Mirena.
Smoking- 10 pack years.
Mother- Belarusian. Father- Georgian.
About 3 months prior to admission, she stated she had SOB and was febrile.
She did a CXR as an outpatient which showed a finding in the base of the right lung-
possibly an infiltrate.
She was treated with antibiotics with partial response.
6 weeks later a repeat CXR was performed- a few solid dense findings in the right lung.
Therefore, she was referred for a PET-CT which demonstrated increased uptake in the right
breast, lymph nodes on the right a few areas in the lungs and liver.
On biopsy from the lesion in the right breast- triple negative adenocarcinoma. Genetic
testing has not been done thus far.
Genetic counseling- the patient denies a family history of breast, ovary, uterus,
and prostate cancer. Her mother has chronic lymphocytic leukemia (CLL).
She is planned to undergo genetic tests because the aggressive course of the disease,
and her young age.
Impression:
Stage 4 triple negative breast adenocarcinoma.
Could benefit from biological therapy.
Different treatment options were explained- the patient wants to get a second opinion.`;

const docContent2 = {
const doc3 = `PATHOLOGY REPORT
Clinical Information
Ultrasound-guided biopsy; A. 18 mm mass; most likely diagnosis based on imaging: IDC
Diagnosis
A. BREAST, LEFT AT 2:00 4 CM FN; ULTRASOUND-GUIDED NEEDLE CORE BIOPSIES:
- Invasive carcinoma of no special type (invasive ductal carcinoma), grade 1
Nottingham histologic grade: 1/3 (tubules 2; nuclear grade 2; mitotic rate 1;
total score; 5/9)
Fragments involved by invasive carcinoma: 2
Largest measurement of invasive carcinoma on a single fragment: 7 mm
Ductal carcinoma in situ (DCIS): Present
Architectural pattern: Cribriform
Nuclear grade: 2-
-intermediate
Necrosis: Not identified
Fragments involved by DCIS: 1
Largest measurement of DCIS on a single fragment: Span 2 mm
Microcalcifications: Present in benign breast tissue and invasive carcinoma
Blocks with invasive carcinoma: A1
Special studies: Pending`;

const docContent3 = {
sourceType: "INLINE",
value: doc2,
value: doc3,
};

const patientDoc2 = {
const patientDoc3 = {
type: "NOTE",
id: "doc2",
id: "doc3",
content: docContent3,
clinicalType: "PATHOLOGY",
language: "en",
Expand All @@ -184,7 +191,7 @@ const patientDoc2 = {
const patient1 = {
id: "patient_id",
info: patientInfo,
data: [patientDoc1, patientDoc2],
data: [patientDoc1, patientDoc2, patientDoc3],
};

const cancerProfilingData: OncoPhenotypeData = {
Expand All @@ -199,41 +206,34 @@ const parameters = {
// Initiate cancer profiling job and retrieve results
const initialResponse = await client.path("/oncophenotype/jobs").post(parameters);
if (isUnexpected(initialResponse)) {
throw initialResponse;
throw initialResponse.body.error;
}

const poller = await getLongRunningPoller(client, initialResponse);
const cancerProfilingResult = await poller.pollUntilDone();
if (isUnexpected(cancerProfilingResult)) {
throw cancerProfilingResult;
throw cancerProfilingResult.body.error;
}

const resultBody = cancerProfilingResult.body;
// Print the inference results for a patient's cancer attributes
if (cancerProfilingResult.status === "succeeded") {
const results = cancerProfilingResult.results;
if (results) {
for (const patientResult of results.patients) {
console.log(`Inferences of Patient ${patientResult.id}`);
for (const { type, value, confidenceScore, evidence } of patientResult.inferences) {
console.log(
`Clinical Type: ${String(type)} Value: ${value}, ConfidenceScore: ${confidenceScore}`,
);
for (const { patientDataEvidence } of evidence || []) {
if (patientDataEvidence) {
console.log(
`Evidence: ${patientDataEvidence.id} ${patientDataEvidence.offset} ${patientDataEvidence.length} ${patientDataEvidence.text}`,
);
}
const results = resultBody.results;
if (results) {
for (const patientResult of results.patients) {
console.log(`Inferences of Patient ${patientResult.id}`);
for (const { type, value, confidenceScore, evidence } of patientResult.inferences) {
console.log(
`Clinical Type: ${String(type)} Value: ${value}, ConfidenceScore: ${confidenceScore}`,
);
for (const { patientDataEvidence } of evidence || []) {
if (patientDataEvidence) {
console.log(
`Evidence: ${patientDataEvidence.id} ${patientDataEvidence.offset} ${patientDataEvidence.length} ${patientDataEvidence.text}`,
);
}
}
}
}
} else {
const errors = cancerProfilingResult.errors;
if (errors) {
for (const error of errors) {
console.log(error.code, ":", error.message);
}
}
}
```

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

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`:

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

setLogLevel("info");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped"
"update-snippets": "dev-tool run update-snippets"
},
"sideEffects": false,
"autoPublish": false,
Expand All @@ -62,7 +62,7 @@
"@azure/abort-controller": "^2.1.2",
"@azure/core-auth": "^1.9.0",
"@azure/core-lro": "^2.7.2",
"@azure/core-rest-pipeline": "^1.18.0",
"@azure/core-rest-pipeline": "^1.19.0",
"@azure/logger": "^1.1.4",
"tslib": "^2.8.1"
},
Expand All @@ -72,16 +72,16 @@
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.0.1",
"@azure/identity": "^4.7.0",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.6",
"@vitest/coverage-istanbul": "^3.0.6",
"autorest": "latest",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"playwright": "^1.49.0",
"playwright": "^1.50.1",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"vitest": "^3.0.6"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/healthinsights/health-insights-cancerprofiling-rest/README.md",
"//metadata": {
Expand All @@ -94,7 +94,7 @@
},
"browser": "./dist/browser/index.js",
"//sampleConfiguration": {
"productName": "HealthInsightsCancerprifiling",
"productName": "HealthInsightsCancerprofiling",
"productSlugs": [
"azure"
],
Expand All @@ -103,6 +103,7 @@
},
"type": "module",
"tshy": {
"project": "./tsconfig.src.json",
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
Expand All @@ -115,8 +116,7 @@
"browser",
"react-native"
],
"selfLink": false,
"project": "./tsconfig.src.json"
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
Expand All @@ -138,5 +138,6 @@
"default": "./dist/commonjs/index.js"
}
}
}
},
"react-native": "./dist/react-native/index.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@

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

import * as dotenv from "dotenv";
import "dotenv/config";
import CancerProfilingRestClient, {
CreateJobParameters,
getLongRunningPoller,
isUnexpected,
OncoPhenotypeData,
OncoPhenotypeResultOutput
} from "../src";

dotenv.config();

} from "../src/index.js";
// You will need to set this environment variables or edit the following values
const endpoint = process.env["HEALTH_INSIGHTS_ENDPOINT"] || "";
const apiKey = process.env["HEALTH_INSIGHTS_API_KEY"] || "";
Expand Down Expand Up @@ -188,7 +185,7 @@ function createRequestBody(): CreateJobParameters {
};

}
export async function main() {
export async function main(): Promise<void> {
const credential = new AzureKeyCredential(apiKey);
const client = CancerProfilingRestClient(endpoint, credential);
// Create body request for cancer profiling
Expand Down
Loading

0 comments on commit b995c60

Please sign in to comment.