Exemple #1
0
        public async Task RecognizeHealthcareEntitiesTest()
        {
            TextAnalyticsClient client = GetClient();
            string document            = singleEnglish;

            HealthcareOperation operation = await client.StartHealthcareAsync(document);

            await operation.WaitForCompletionAsync();

            RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value;

            Assert.AreEqual(1, resultCollection.Count);

            DocumentHealthcareResult result = resultCollection.Single();

            var entitiesList = new List <string> {
                "100mg", "ibuprofen", "twice daily"
            };

            Assert.AreEqual(3, result.Entities.Count);
            Assert.IsNotNull(result.Id);
            Assert.AreEqual("0", result.Id);

            foreach (HealthcareEntity entity in result.Entities)
            {
                Assert.IsTrue(entitiesList.Contains(entity.Text));

                if (entity.Text == "ibuprofen")
                {
                    var linksList = new List <string> {
                        "UMLS", "AOD", "ATC", "CCPSS", "CHV", "CSP", "DRUGBANK", "GS", "LCH_NW", "LNC", "MEDCIN", "MMSL", "MSH", "MTHSPL", "NCI", "NCI_CTRP", "NCI_DCP", "NCI_DTP", "NCI_FDA", "NCI_NCI-GLOSS", "NDDF", "PDQ", "RCD", "RXNORM", "SNM", "SNMI", "SNOMEDCT_US", "USP", "USPMG", "VANDF"
                    };

                    foreach (HealthcareEntityLink link in entity.Links)
                    {
                        Assert.IsTrue(linksList.Contains(link.DataSource));
                    }
                }
            }

            foreach (HealthcareRelation relation in result.Relations)
            {
                if (relation.RelationType == "DosageOfMedication")
                {
                    Assert.AreEqual(relation.Source.Text, "100mg");
                    Assert.AreEqual(relation.Source.Category, "Dosage");
                    Assert.AreEqual(relation.Source.ConfidenceScore, 1);
                    Assert.AreEqual(relation.Source.Length, 5);
                    Assert.AreEqual(relation.Source.Offset, 18);


                    Assert.AreEqual(relation.Target.Text, "ibuprofen");
                    Assert.AreEqual(relation.Target.Category, "MedicationName");
                    Assert.AreEqual(relation.Target.ConfidenceScore, 1);
                    Assert.AreEqual(relation.Target.Length, 9);
                    Assert.AreEqual(relation.Target.Offset, 27);
                }
            }
        }
        public async Task HealthcareAsync_AutomaticPolling()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            #region Snippet:RecognizeHealthcareEntitiesAsyncAutomaticPolling
            string document = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
                                Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
                                HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
                                The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
                                with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
                                another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
                                which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
                                minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
                                increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";

            HealthcareOperation healthOperation = await client.StartHealthcareAsync(document);

            TimeSpan pollingInterval = new TimeSpan(1000);

            await healthOperation.WaitForCompletionAsync(pollingInterval);

            RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value;

            Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\"");
            Console.WriteLine("");

            foreach (DocumentHealthcareResult result in results)
            {
                Console.WriteLine($"    Recognized the following {result.Entities.Count} healthcare entities:");

                foreach (HealthcareEntity entity in result.Entities)
                {
                    Console.WriteLine($"    Entity: {entity.Text}");
                    Console.WriteLine($"    Category: {entity.Category}");
                    Console.WriteLine($"    Offset: {entity.Offset}");
                    Console.WriteLine($"    Length: {entity.Length}");
                    Console.WriteLine($"    IsNegated: {entity.IsNegated}");
                    Console.WriteLine($"    Links:");

                    foreach (HealthcareEntityLink healthcareEntityLink in entity.Links)
                    {
                        Console.WriteLine($"        ID: {healthcareEntityLink.Id}");
                        Console.WriteLine($"        DataSource: {healthcareEntityLink.DataSource}");
                    }
                }
                Console.WriteLine("");
            }
        }
        public async Task HealthcareAsyncCancellation()
        {
            string endpoint = TestEnvironment.Endpoint;
            string apiKey   = TestEnvironment.ApiKey;

            var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

            #region Snippet:TextAnalyticsSampleHealthcareAsyncCancellation
            string document = @"RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
                                Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
                                HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
                                The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
                                with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
                                another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
                                which showed no wall motion abnormalities , but this was a difficult study due to body habitus. The patient went for six minutes with \
                                minimal ST depressions in the anterior lateral leads , thought due to fatigue and wrist pain , his anginal equivalent. Due to the patient's \
                                increased symptoms and family history and history left main disease with total occasional of his RCA was referred for revascularization with open heart surgery.";

            HealthcareOperation healthOperation = await client.StartHealthcareAsync(document);

            await client.StartCancelHealthJobAsync(healthOperation);
        }