Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/healthinsights snippets #33164

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5fb7ab9
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 21, 2025
c961d2e
Migration: Update test config
mpodwysocki Feb 21, 2025
2387aaf
Migration: Clean up files
mpodwysocki Feb 21, 2025
3fc7e7f
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 21, 2025
3bafa17
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 21, 2025
cd08405
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 21, 2025
7528852
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 21, 2025
5ea9b54
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 21, 2025
85c509c
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 21, 2025
85adf73
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 21, 2025
eda506d
Migration: npm run format
mpodwysocki Feb 21, 2025
ceb4d52
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 21, 2025
7244217
Migration: Update test config
mpodwysocki Feb 21, 2025
73d6903
Migration: Clean up files
mpodwysocki Feb 21, 2025
a8fa354
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 21, 2025
331ade9
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 21, 2025
e4e6b23
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 21, 2025
cecb918
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 21, 2025
f2bc789
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 21, 2025
143c61b
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 21, 2025
9fd9800
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 21, 2025
8f13d85
Migration: npm run format
mpodwysocki Feb 21, 2025
4d2b576
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 21, 2025
3a8facb
Migration: Update test config
mpodwysocki Feb 21, 2025
82e5c00
Migration: Clean up files
mpodwysocki Feb 21, 2025
b9774f9
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 21, 2025
332c1b5
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 21, 2025
b4e4d76
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 21, 2025
068ea61
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 21, 2025
9cbf976
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 21, 2025
1aeec5f
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 21, 2025
d9211f5
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 21, 2025
b73bf3c
Migration: npm run format
mpodwysocki Feb 21, 2025
196d740
[healthinsights] Migrate healthinsights projects to use snippets extr…
mpodwysocki Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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