1.0.0-beta.1 • Published 4 days ago

@azure-rest/health-insights-cancerprofiling v1.0.0-beta.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 days ago

CancerProfiling REST client library for JavaScript

Health Insights is an Azure Applied AI Service built with the Azure Cognitive Services Framework, that leverages multiple Cognitive Services, Healthcare API services and other Azure resources. The Cancer Profiling model receives clinical records of oncology patients and outputs cancer staging, such as clinical stage TNM categories and pathologic stage TNM categories as well as tumor site, histology.

Please rely heavily on our REST client docs to use this library

Key links:

Getting started

Currently supported environments

  • LTS versions of Node.js

Prerequisites

  • LTS versions of Node.js
  • You must have an Azure subscription to use this package.
  • An existing Cognitive Services Health Insights instance.

Install the @azure-rest/health-insights-cancerprofiling package

Install the CancerProfiling REST client library for JavaScript with npm:

npm install @azure-rest/health-insights-cancerprofiling
SDK versionSupported API version of service
1.0.0-beta.12023-03-01-preview

Create and authenticate a CancerProfilingRestClient

To use an Azure Active Directory (AAD) token credential, provide an instance of the desired credential type obtained from the @azure/identity library.

To authenticate with AAD, you must first npm install @azure/identity

After setup, you can choose which type of credential from @azure/identity to use. As an example, DefaultAzureCredential can be used to authenticate the client.

Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

Key concepts

The Cancer Profiling model allows you to infer cancer attributes such as tumor site, histology, clinical stage TNM categories and pathologic stage TNM categories from unstructured clinical documents.

Examples

const apiKey = process.env["HEALTH_INSIGHTS_API_KEY"] || "";
const endpoint =
  process.env["HEALTH_INSIGHTS_ENDPOINT"] || "";
const credential = new AzureKeyCredential(apiKey);
const client = CancerProfilingRestClient(endpoint, credential);

// Define patient information and clinical documents for the request body
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 docContent = {
    sourceType: "INLINE",
    value: doc1
};

const patientDoc1 = {
    type: "NOTE",
    id: "doc1",
    content: docContent,
    clinicalType: "IMAGING",
    language: "en", 
    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. `;

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

    const patientDoc1 = {
        type: "NOTE",
        id: "doc1",
        content: docContent,
        clinicalType: "IMAGING",
        language: "en", 
        createdDateTime: new Date("2021-15-08T00: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 = {
    sourceType: "INLINE",
    value: doc2
};

const patientDoc2 = {
    type: "NOTE",
    id: "doc2",
    content: docContent3,
    clinicalType: "PATHOLOGY",
    language: "en", 
    createdDateTime: new Date("2022-01-01T00:00:00.000Z")
};

const patient1 = {
    id: "patient_id",
    info: patientInfo,
    data: [patientDoc1, patientDoc2]
};

const cancerProfilingData: OncoPhenotypeData = {
    patients: [patient1],
    configuration: {includeEvidence: true}
};

const parameters = {
    body: cancerProfilingData
};

// Initiate cancer profiling job and retrieve results
const initialResponse = await client.path("/oncophenotype/jobs").post(parameters);
if (isUnexpected(initialResponse)) {
    throw initialResponse;
}
const poller = await getLongRunningPoller(client, initialResponse);
const cancerProfilingResult = await poller.pollUntilDone();
if (isUnexpected(cancerProfilingResult)) {
    throw cancerProfilingResult;
}
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}`);
                    }
                }
            }
        }
    }
} else {
    const errors = cancerProfilingResult.errors;
    if (errors) {
      for (const error of errors) {
          console.log(error.code, ":", error.message);
      }
    }
}

Troubleshooting

Logging

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:

const { setLogLevel } = require("@azure/logger");

setLogLevel("info");

For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.

Next steps

This code sample show common scenario operation with the Azure Health Insights Cancer Profiling library. More samples can be found under the samples directory.

Additional documentation

For more extensive documentation on Azure Health Insights Cancer Profiling, see the Cancer Profiling documentation on docs.microsoft.com.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.