Text Analytics for analyzing healthcare entities and multiple actions

Shawn

We’re pleased to announce that Text Analytics now supports healthcare analysis and multiple actions analysis in preview.

Healthcare Entities Analysis

Text Analytics for Healthcare is a containerized service that extracts and labels relevant medical information from unstructured texts such as doctor’s notes, discharge summaries, clinical documents, and electronic healthcare records.

Text Analytics for Healthcare is in preview. If you are interested in trying it out, please see how to use Text Analytics for Healthcare to request access. Note: Azure Active Directory (AAD) is not currently supported at this stage of the development

Text Analytics for Healthcare supports the following features:

  • Named entity recognition: Detects words and phrases mentioned in unstructured text as entities that can be associated with semantic types in the healthcare and biomedical domain, such as diagnosis, medication name, symptoms/signs, examinations, treatments, dosage, and route of administration. (For a full list of healthcare entity types and relationships, see the supported entity categories.)

  • Entity data source linking: Disambiguates distinct entities by associating named entities mentioned in text to concepts found in a predefined database of concepts including the Unified Medical Language System (UMLS). Medical concepts are also assigned preferred naming as an additional form of normalization.

  • Assertion detection: The meaning of medical content is highly affected by modifiers, such as negative or conditional assertions which can have critical implications if misrepresented. There are three categories of assertion detection we support for entities in the text:

    • Certainty – provides information regarding the presence (present vs. absent) of the concept and how certain the text is regarding its presence (definite vs. possible).
    • Conditional – provides information regarding whether the existence of a concept depends on certain conditions.
    • Association – describes whether the concept is associated with the subject of the text or someone else.

    For more information about the assertion output, view assertion output.

  • Entities relation extraction: Relation extraction identifies meaningful connections between concepts mentioned in text. For examples, a “time of condition” relation is found by associating a condition name with a time.

In this blog, we’ll use Java as the primary language to show the healthcare entities analysis feature. To see the complete sample, see Java sample. For more information about other languages, refer to .NET sample, JS sample, Python sample.

An example: Using Text Analytics for Healthcare in Java

To use Text Analytics for Healthcare, start with creating a Text Analytics client, and then use the client to make a request to the Text Analytics service on the healthcare documents input, which will return the analyzed output that includes the features described above.

Create a Text Analytics client

TextAnalyticsClient client = new TextAnalyticsClientBuilder()
                                 .credential(new AzureKeyCredential("{key}"))
                                 .endpoint("{endpoint}")
                                 .buildClient();

Please see how to authenticate the client for using the Text Analytics service.

Get documents

List<TextDocumentInput> documents = Arrays.asList(
    new TextDocumentInput("0",
        "Woman in NAD with a h/o CAD, DM2, asthma and HTN on ramipril for 8 years awoke from sleep around" 
            + " 2:30 am this morning of a sore throat and swelling of tongue. She came immediately to the ED" 
            + " b/c she was having difficulty swallowing."),
    new TextDocumentInput("1",
        "Patient's brother died at the age of 64 from lung cancer. She was admitted for likely gastroparesis"
            + " but remains unsure if she wants to start adjuvant hormonal therapy. Please hold lactulose "
            + "if diarrhea worsen."));                              

Begin a “healthcare entities analysis” long-running operation, it might take a few seconds to complete. You would be able to get the operation details in AnalyzeHealthcareEntitiesOperationDetail and the final operation result in AnalyzeHealthcareEntitiesResultCollection.

SyncPoller<AnalyzeHealthcareEntitiesOperationDetail, PagedIterable<AnalyzeHealthcareEntitiesResultCollection>>
    syncPoller = client.beginAnalyzeHealthcareEntities(documents, options, Context.NONE);

System.out.printf("Poller status: %s.%n", syncPoller.poll().getStatus());

syncPoller.waitForCompletion();

To view the operation details,

AnalyzeHealthcareEntitiesOperationDetail operationResult = syncPoller.poll().getValue();
System.out.printf("Operation created time: %s, expiration time: %s.%n", operationResult.getCreatedAt(),
    operationResult.getExpiresAt());
System.out.printf("Poller status: %s.%n", syncPoller.poll().getStatus());

To view the final result of the long-running operation.

for (AnalyzeHealthcareEntitiesResultCollection healthcareEntitiesResultCollection : syncPoller.getFinalResult()) {
    // documents result
    for (AnalyzeHealthcareEntitiesResult healthcareEntitiesResult : healthcareEntitiesResultCollection) {
        System.out.println("Document entities: ");
        // Recognized healthcare entities
        for (HealthcareEntity entity : healthcareEntitiesResult.getEntities()) {
            System.out.printf("\tText: %s, normalized name: %s, category: %s, confidence score: %f.%n",
                entity.getText(), entity.getNormalizedText(), entity.getCategory(), entity.getConfidenceScore());
            // Assertion detection
            HealthcareEntityAssertion assertion = entity.getAssertion();
            if (assertion != null) {
                System.out.printf("\t\tEntity assertion: association=%s, certainty=%s, conditionality=%s.%n",
                    assertion.getAssociation(), assertion.getCertainty(), assertion.getConditionality());
            }
            // Entity data source linking
            for (EntityDataSource dataSource : entity.getDataSources()) {
                System.out.printf("\t\tEntity ID in data source: %s, data source: %s.%n",
                    dataSource.getEntityId(), dataSource.getName());
            }
        }
        // Relation extraction
        for (HealthcareEntityRelation entityRelation : healthcareEntitiesResult.getEntityRelations()) {
            System.out.printf("Relation type: %s.%n", entityRelation.getRelationType());
            for (HealthcareEntityRelationRole role : entityRelation.getRoles()) {
                HealthcareEntity entity = role.getEntity();
                System.out.printf("\tEntity text: %s, category: %s, role: %s.%n",
                    entity.getText(), entity.getCategory(), role.getName());
            }
        }
    }
}

Multiple Actions Analysis

One action represents one single operation that Text Analytics supports, such as the Key Phrase Extraction operation would be considered as one action. Text Analytics now provides a way to run multiple actions in one or more documents as a single long-running operation. Currently, Text Analytics for the multiple actions analytics only supports:

We’ll now use Java as the primary language to show the multiple actions analysis feature. To see the full complete sample, see Java sample. For more information about other languages, refer to .NET sample, JS sample, Python sample.

An example: Using Text Analytics for Multiple Actions in Java

We can use the same Text Analytics client we created above in the healthcare to analyze the documents input. The output will include all action results.

Begin a long-running multiple actions analysis operation.

SyncPoller<AnalyzeBatchActionsOperationDetail, PagedIterable<AnalyzeBatchActionsResult>> syncPoller =
    client.beginAnalyzeBatchActions(documents,
        new TextAnalyticsActions().setDisplayName("{tasks_display_name}")
            .setRecognizeEntitiesOptions(new RecognizeEntitiesOptions())
            .setExtractKeyPhrasesOptions(new ExtractKeyPhrasesOptions()),
        new AnalyzeBatchActionsOptions().setIncludeStatistics(false),
        Context.NONE);

syncPoller.waitForCompletion();

To view the final result of long-running operation. An action result could either be an action error or a successful result. That pattern applies to each document result as well.

for (AnalyzeBatchActionsResult actionsResult : syncPoller.getFinalResult()) {
    System.out.println("Entities recognition action results:");
    for (RecognizeEntitiesActionResult actionResult : actionsResult.getRecognizeEntitiesActionResults()) {
        if (!actionResult.isError()) {
            for (RecognizeEntitiesResult documentResult : actionResult.getResult()) {
                if (!documentResult.isError()) {
                    for (CategorizedEntity entity : documentResult.getEntities()) {
                        System.out.printf("Recognized entity: %s, entity category: %s, confidence score: %f.%n",
                            entity.getText(), entity.getCategory(), entity.getConfidenceScore());
                    }
                } else {
                    System.out.printf("Cannot recognize entities. Error: %s%n",
                        documentResult.getError().getMessage());
                }
            }
        } else {
            System.out.printf("Cannot execute Entities Recognition action. Error: %s%n",
                actionResult.getError().getMessage());
        }
    }

    System.out.println("Key phrases extraction action results:");
    for (ExtractKeyPhrasesActionResult actionResult : actionsResult.getExtractKeyPhrasesActionResults()) {
        if (!actionResult.isError()) {
            for (ExtractKeyPhraseResult documentResult : actionResult.getResult()) {
                if (!documentResult.isError()) {
                    System.out.println("Extracted phrases:");
                    for (String keyPhrases : documentResult.getKeyPhrases()) {
                        System.out.printf("\t%s.%n", keyPhrases);
                    }
                } else {
                    System.out.printf("Cannot extract key phrases. Error: %s%n", 
                        documentResult.getError().getMessage());
                }
            }
        } else {
            System.out.printf("Cannot execute Key Phrases Extraction action. Error: %s%n",
                actionResult.getError().getMessage());
        }
    }
}

Summary

This article introduced the new Text Analytics library features for healthcare entities analysis and multiple actions analysis.

For more information about the features in this article in other programming languages, see the following:

Azure SDK Blog Contributions

Thank you for reading this Azure SDK blog post! We hope that you learned something new and welcome you to share this post. We are open to Azure SDK blog contributions. Please contact us at azsdkblog@microsoft.com with your topic and we’ll get you set up as a guest blogger.

0 comments

Comments are closed. Login to edit/delete your existing comments