@@ -426,10 +426,10 @@ catch (RequestFailedException exception)
426426### Recognize Healthcare Entities Asynchronously
427427Text Analytics for health 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 health records. For more information see [ How to: Use Text Analytics for health] [ healthcare ] .
428428
429- ``` C# Snippet:TextAnalyticsSampleHealthcareBatchAsync
430- string document1 = @" RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS |
431- Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE.
432- HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months.
429+ ``` C# Snippet:Sample7_AnalyzeHealthcareEntitiesBatchConvenience
430+ string document1 = @" RECORD #333582770390100 | MH | 85986313 | | 054351 | 2/14/2001 12:00:00 AM | CORONARY ARTERY DISEASE | Signed | DIS | \
431+ Admission Date: 5/22/2001 Report Status: Signed Discharge Date: 4/24/2001 ADMISSION DIAGNOSIS: CORONARY ARTERY DISEASE. \
432+ HISTORY OF PRESENT ILLNESS: The patient is a 54-year-old gentleman with a history of progressive angina over the past several months. \
433433 The patient had a cardiac catheterization in July of this year revealing total occlusion of the RCA and 50% left main disease ,\
434434 with a strong family history of coronary artery disease with a brother dying at the age of 52 from a myocardial infarction and \
435435 another brother who is status post coronary artery bypass grafting. The patient had a stress echocardiogram done on July , 2001 , \
@@ -443,52 +443,96 @@ Text Analytics for health is a containerized service that extracts and labels re
443443 {
444444 document1 ,
445445 document2 ,
446+ string .Empty
446447 };
448+ var options = new AnalyzeHealthcareEntitiesOptions { };
447449
448- AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions ()
449- {
450- IncludeStatistics = true
451- };
452-
453- AnalyzeHealthcareEntitiesOperation healthOperation = await client .StartAnalyzeHealthcareEntitiesAsync (batchInput , " en" , options );
450+ AnalyzeHealthcareEntitiesOperation healthOperation = client .StartAnalyzeHealthcareEntities (batchInput , " en" , options );
454451
455452 await healthOperation .WaitForCompletionAsync ();
456453
457- await foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation .Value )
454+ Console .WriteLine ($" AnalyzeHealthcareEntities operation was completed" );
455+
456+ Console .WriteLine ($" Created On : {healthOperation .CreatedOn }" );
457+ Console .WriteLine ($" Expires On : {healthOperation .ExpiresOn }" );
458+ Console .WriteLine ($" Status : {healthOperation .Status }" );
459+ Console .WriteLine ($" Last Modified: {healthOperation .LastModified }" );
460+
461+ foreach (AnalyzeHealthcareEntitiesResultCollection documentsInPage in healthOperation .GetValues ())
458462 {
459- Console .WriteLine ($" Results of Azure Text Analytics \" Healthcare Async \" Model, version: \" {documentsInPage .ModelVersion }\" " );
463+ Console .WriteLine ($" Results of Azure Text Analytics \" Healthcare\" Model, version: \" {documentsInPage .ModelVersion }\" " );
460464 Console .WriteLine (" " );
461465
462466 foreach (AnalyzeHealthcareEntitiesResult result in documentsInPage )
463467 {
464- Console .WriteLine ($" Recognized the following {result .Entities .Count } healthcare entities:" );
465-
466- foreach (HealthcareEntity entity in result .Entities )
468+ if (result .HasError )
467469 {
468- Console .WriteLine ($" Entity: {entity .Text }" );
469- Console .WriteLine ($" Category: {entity .Category }" );
470- Console .WriteLine ($" Offset: {entity .Offset }" );
471- Console .WriteLine ($" Length: {entity .Length }" );
472- Console .WriteLine ($" Links:" );
470+ Console .WriteLine (" Error!" );
471+ Console .WriteLine ($" Document error code: {result .Error .ErrorCode }." );
472+ Console .WriteLine ($" Message: {result .Error .Message }" );
473+ }
474+ else
475+ {
476+ Console .WriteLine ($" Recognized the following {result .Entities .Count } healthcare entities:" );
473477
474- foreach (EntityDataSource entityDataSource in entity . DataSources )
478+ foreach (HealthcareEntity entity in result . Entities )
475479 {
476- Console .WriteLine ($" Entity ID in Data Source: {entityDataSource .EntityId }" );
477- Console .WriteLine ($" DataSource: {entityDataSource .Name }" );
480+ Console .WriteLine ($" Entity: {entity .Text }" );
481+ Console .WriteLine ($" Category: {entity .Category }" );
482+ Console .WriteLine ($" Offset: {entity .Offset }" );
483+ Console .WriteLine ($" Length: {entity .Length }" );
484+ Console .WriteLine ($" NormalizedText: {entity .NormalizedText }" );
485+ Console .WriteLine ($" Links:" );
486+
487+ foreach (EntityDataSource entityDataSource in entity .DataSources )
488+ {
489+ Console .WriteLine ($" Entity ID in Data Source: {entityDataSource .EntityId }" );
490+ Console .WriteLine ($" DataSource: {entityDataSource .Name }" );
491+ }
492+
493+ if (entity .Assertion != null )
494+ {
495+ Console .WriteLine ($" Assertions:" );
496+
497+ if (entity .Assertion ? .Association != null )
498+ {
499+ Console .WriteLine ($" Association: {entity .Assertion ? .Association }" );
500+ }
501+
502+ if (entity .Assertion ? .Certainty != null )
503+ {
504+ Console .WriteLine ($" Certainty: {entity .Assertion ? .Certainty }" );
505+ }
506+ if (entity .Assertion ? .Conditionality != null )
507+ {
508+ Console .WriteLine ($" Conditionality: {entity .Assertion ? .Conditionality }" );
509+ }
510+ }
511+
512+ Console .WriteLine ($" We found {result .EntityRelations .Count } relations in the current document:" );
513+ Console .WriteLine (" " );
514+
515+ foreach (HealthcareEntityRelation relations in result .EntityRelations )
516+ {
517+ Console .WriteLine ($" Relation: {relations .RelationType }" );
518+ Console .WriteLine ($" For this relation there are {relations .Roles .Count } roles" );
519+
520+ foreach (HealthcareEntityRelationRole role in relations .Roles )
521+ {
522+ Console .WriteLine ($" Role Name: {role .Name }" );
523+
524+ Console .WriteLine ($" Associated Entity Text: {role .Entity .Text }" );
525+ Console .WriteLine ($" Associated Entity Category: {role .Entity .Category }" );
526+
527+ Console .WriteLine (" " );
528+ }
529+
530+ Console .WriteLine (" " );
531+ }
478532 }
533+ Console .WriteLine (" " );
479534 }
480-
481- Console .WriteLine ($" Document statistics:" );
482- Console .WriteLine ($" Character count (in Unicode graphemes): {result .Statistics .CharacterCount }" );
483- Console .WriteLine ($" Transaction count: {result .Statistics .TransactionCount }" );
484- Console .WriteLine (" " );
485535 }
486- Console .WriteLine ($" Request statistics:" );
487- Console .WriteLine ($" Document Count: {documentsInPage .Statistics .DocumentCount }" );
488- Console .WriteLine ($" Valid Document Count: {documentsInPage .Statistics .ValidDocumentCount }" );
489- Console .WriteLine ($" Transaction Count: {documentsInPage .Statistics .TransactionCount }" );
490- Console .WriteLine ($" Invalid Document Count: {documentsInPage .Statistics .InvalidDocumentCount }" );
491- Console .WriteLine (" " );
492536 }
493537}
494538```
0 commit comments