@@ -58,44 +58,50 @@ The Cancer Profiling model allows you to infer cancer attributes such as tumor s
58
58
59
59
- [ Infer Cancer Profiling] ( #cancer_profiling )
60
60
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>" ;
64
71
const credential = new AzureKeyCredential (apiKey );
65
72
const client = CancerProfilingRestClient (endpoint , credential );
66
73
67
- // Define patient information and clinical documents for the request body
74
+ // Define patient information and clinical documents
68
75
const patientInfo = {
69
76
sex: " FEMALE" ,
70
77
birthDate: new Date (" 1979-10-08T00:00:00.000Z" ), // Note: Months are zero-based (11 represents December)
71
78
};
72
79
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. ` ;
93
100
94
101
const docContent = {
95
102
sourceType: " INLINE" ,
96
103
value: doc1 ,
97
104
};
98
-
99
105
const patientDoc1 = {
100
106
type: " NOTE" ,
101
107
id: " doc1" ,
@@ -105,76 +111,77 @@ const patientDoc1 = {
105
111
createdDateTime: new Date (" 2021-15-08T00:00:00.000Z" ),
106
112
};
107
113
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. ` ;
128
141
129
- const docContent = {
142
+ const docContent2 = {
130
143
sourceType: " INLINE" ,
131
- value: doc1 ,
144
+ value: doc2 ,
132
145
};
133
146
134
- const patientDoc1 = {
147
+ const patientDoc2 = {
135
148
type: " NOTE" ,
136
- id: " doc1 " ,
137
- content: docContent ,
138
- clinicalType: " IMAGING " ,
149
+ id: " doc2 " ,
150
+ content: docContent2 ,
151
+ clinicalType: " PATHOLOGY " ,
139
152
language: " en" ,
140
- createdDateTime: new Date (" 2021-15-08T00 :00:00.000Z" ),
153
+ createdDateTime: new Date (" 2021-10-20T00 :00:00.000Z" ),
141
154
};
142
155
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 = {
171
178
sourceType: " INLINE" ,
172
- value: doc2 ,
179
+ value: doc3 ,
173
180
};
174
181
175
- const patientDoc2 = {
182
+ const patientDoc3 = {
176
183
type: " NOTE" ,
177
- id: " doc2 " ,
184
+ id: " doc3 " ,
178
185
content: docContent3 ,
179
186
clinicalType: " PATHOLOGY" ,
180
187
language: " en" ,
@@ -184,7 +191,7 @@ const patientDoc2 = {
184
191
const patient1 = {
185
192
id: " patient_id" ,
186
193
info: patientInfo ,
187
- data: [patientDoc1 , patientDoc2 ],
194
+ data: [patientDoc1 , patientDoc2 , patientDoc3 ],
188
195
};
189
196
190
197
const cancerProfilingData: OncoPhenotypeData = {
@@ -199,41 +206,34 @@ const parameters = {
199
206
// Initiate cancer profiling job and retrieve results
200
207
const initialResponse = await client .path (" /oncophenotype/jobs" ).post (parameters );
201
208
if (isUnexpected (initialResponse )) {
202
- throw initialResponse ;
209
+ throw initialResponse . body . error ;
203
210
}
211
+
204
212
const poller = await getLongRunningPoller (client , initialResponse );
205
213
const cancerProfilingResult = await poller .pollUntilDone ();
206
214
if (isUnexpected (cancerProfilingResult )) {
207
- throw cancerProfilingResult ;
215
+ throw cancerProfilingResult . body . error ;
208
216
}
217
+
209
218
const resultBody = cancerProfilingResult .body ;
210
219
// 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
+ );
226
233
}
227
234
}
228
235
}
229
236
}
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
- }
237
237
}
238
238
```
239
239
@@ -243,8 +243,8 @@ if (cancerProfilingResult.status === "succeeded") {
243
243
244
244
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 ` :
245
245
246
- ``` javascript
247
- const { setLogLevel } = require ( " @azure/logger" ) ;
246
+ ``` ts snippet:SetLogLevel
247
+ import { setLogLevel } from " @azure/logger" ;
248
248
249
249
setLogLevel (" info" );
250
250
```
0 commit comments