diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md index 64616c98b9636..31e9ab56c8eff 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md @@ -2,6 +2,18 @@ ## 5.1.0-beta.4 (Unreleased) +### Breaking changes +- Renamed `RecognizeHealthcareEntitiesResultCollection` to `AnalyzeHealthcareEntitiesResultCollection`. +- Renamed `DocumentHealthcareResult` to `AnalyzeHealthcareEntitiesResult`. +- Removed `StartHealthcare` and `StartHealthcareAsync` methods. +- Renamed `StartHealthcareBatch` and `StartHealthcareBatchAsync` to `StartAnalyzeHealthcareEntities` and `StartAnalyzeHealthcareEntitiesAsync` respectively. +- Renamed `HealthcareOperation` to `AnalyzeHealthcareEntitiesOperation`. +- Renamed `HealthcareOptions` to `AnalyzeHealthcareEntitiesOptions`. +- Moved `Cancel` and `CancelAsync` for Healthcare from `TextAnalyticsClient` to `AnalyzeHealthcareEntitiesOperation`. +- Renamed `JobStatus` to `TextAnalyticsOperationStatus`. +- Renamed `HealthcareEntityLink` to `EntityDataSource` with `DataSource` to `EntityDataSource` and `Id` to `Name`. +- Removed `HealthcareRelation` and added `HealthcareRelationType`. + ## 5.1.0-beta.3 (2020-11-19) ### New Features diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/README.md b/sdk/textanalytics/Azure.AI.TextAnalytics/README.md index f4894d809a88a..f67b99c0d5999 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/README.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/README.md @@ -411,7 +411,7 @@ catch (RequestFailedException exception) ### Recognize Healthcare Entities Asynchronously Text 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]. -```C# Snippet:RecognizeHealthcareEntitiesAsync +```C# Snippet:TextAnalyticsSampleHealthcareBatchAsync 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. \ @@ -422,16 +422,29 @@ Text Analytics for health is a containerized service that extracts and labels re 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."; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareAsync(document); + List batchInput = new List() + { + document, + document, + }; + + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() + { + Top = 1, + Skip = 0, + IncludeStatistics = true + }; + + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en", options); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -441,17 +454,26 @@ Text Analytics for health is a containerized service that extracts and labels re 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } + + Console.WriteLine($" Document statistics:"); + Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}"); + Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}"); Console.WriteLine(""); } + Console.WriteLine($"Request statistics:"); + Console.WriteLine($" Document Count: {results.Statistics.DocumentCount}"); + Console.WriteLine($" Valid Document Count: {results.Statistics.ValidDocumentCount}"); + Console.WriteLine($" Transaction Count: {results.Statistics.TransactionCount}"); + Console.WriteLine($" Invalid Document Count: {results.Statistics.InvalidDocumentCount}"); + Console.WriteLine(""); } ``` diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs index 0d57718dad294..ccfd4ab92555c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs @@ -1,20 +1,41 @@ namespace Azure.AI.TextAnalytics { - public partial class AnalyzeHealthcareEntitiesOperation : Azure.Operation + public partial class AnalyzeHealthcareEntitiesOperation : Azure.Operation { public AnalyzeHealthcareEntitiesOperation(string operationId, Azure.AI.TextAnalytics.TextAnalyticsClient client) { } + public System.DateTimeOffset CreatedOn { get { throw null; } } + public System.DateTimeOffset ExpiresOn { get { throw null; } } public override bool HasCompleted { get { throw null; } } public override bool HasValue { get { throw null; } } public override string Id { get { throw null; } } + public System.DateTimeOffset LastModified { get { throw null; } } public Azure.AI.TextAnalytics.TextAnalyticsOperationStatus Status { get { throw null; } } - public override Azure.AI.TextAnalytics.RecognizeHealthcareEntitiesResultCollection Value { get { throw null; } } + public override Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesResultCollection Value { get { throw null; } } public virtual void Cancel(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } public virtual System.Threading.Tasks.Task CancelAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public override Azure.Response GetRawResponse() { throw null; } public override Azure.Response UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public override System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public override System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public override System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class AnalyzeHealthcareEntitiesOptions : Azure.AI.TextAnalytics.TextAnalyticsRequestOptions + { + public AnalyzeHealthcareEntitiesOptions() { } + public int? Skip { get { throw null; } set { } } + public int? Top { get { throw null; } set { } } + } + public partial class AnalyzeHealthcareEntitiesResult : Azure.AI.TextAnalytics.TextAnalyticsResult + { + internal AnalyzeHealthcareEntitiesResult() { } + public System.Collections.Generic.IReadOnlyCollection Entities { get { throw null; } } + public System.Collections.Generic.IReadOnlyCollection Warnings { get { throw null; } } + } + public partial class AnalyzeHealthcareEntitiesResultCollection : System.Collections.ObjectModel.ReadOnlyCollection + { + internal AnalyzeHealthcareEntitiesResultCollection() : base (default(System.Collections.Generic.IList)) { } + public string ModelVersion { get { throw null; } } + public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } } public partial class AnalyzeOperation : Azure.Operation { @@ -127,16 +148,6 @@ internal DetectLanguageResultCollection() : base (default(System.Collections.Gen public string ModelVersion { get { throw null; } } public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } } - public partial class DocumentHealthcareResult - { - internal DocumentHealthcareResult() { } - public System.Collections.Generic.IReadOnlyList Entities { get { throw null; } } - public string Id { get { throw null; } } - public System.Collections.Generic.IReadOnlyList Relations { get { throw null; } } - public Azure.AI.TextAnalytics.TextDocumentStatistics? Statistics { get { throw null; } } - public Azure.AI.TextAnalytics.TextAnalyticsError TextAnalyticsError { get { throw null; } } - public System.Collections.Generic.IReadOnlyList Warnings { get { throw null; } } - } public partial class DocumentSentiment { internal DocumentSentiment() { } @@ -196,6 +207,12 @@ internal Entity() { } public static bool operator !=(Azure.AI.TextAnalytics.EntityCategory left, Azure.AI.TextAnalytics.EntityCategory right) { throw null; } public override string ToString() { throw null; } } + public partial class EntityDataSource + { + internal EntityDataSource() { } + public string EntityId { get { throw null; } } + public string Name { get { throw null; } } + } public partial class EntityRecognitionPiiTasksItem : Azure.AI.TextAnalytics.TaskState { internal EntityRecognitionPiiTasksItem() { } @@ -217,31 +234,35 @@ internal ExtractKeyPhrasesResultCollection() : base (default(System.Collections. public string ModelVersion { get { throw null; } } public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } } - public partial class HealthcareEntity : Azure.AI.TextAnalytics.Entity + public partial class HealthcareEntity { internal HealthcareEntity() { } - public bool IsNegated { get { throw null; } } - public System.Collections.Generic.IReadOnlyList Links { get { throw null; } } - } - public partial class HealthcareEntityLink - { - internal HealthcareEntityLink() { } - public string DataSource { get { throw null; } } - public string Id { get { throw null; } } - } - public partial class HealthcareOptions : Azure.AI.TextAnalytics.TextAnalyticsRequestOptions - { - public HealthcareOptions() { } - public int? Skip { get { throw null; } set { } } - public int? Top { get { throw null; } set { } } + public string Category { get { throw null; } } + public double ConfidenceScore { get { throw null; } } + public System.Collections.Generic.IReadOnlyCollection DataSources { get { throw null; } } + public int Length { get { throw null; } } + public int Offset { get { throw null; } } + public System.Collections.Generic.Dictionary RelatedEntities { get { throw null; } } + public string SubCategory { get { throw null; } } + public string Text { get { throw null; } } } - public partial class HealthcareRelation + public partial class HealthcareEntityRelationType : System.IEquatable { - internal HealthcareRelation() { } - public bool Bidirectional { get { throw null; } } - public string RelationType { get { throw null; } } - public Azure.AI.TextAnalytics.HealthcareEntity Source { get { throw null; } } - public Azure.AI.TextAnalytics.HealthcareEntity Target { get { throw null; } } + internal HealthcareEntityRelationType() { } + public static readonly Azure.AI.TextAnalytics.HealthcareEntityRelationType DirectionOfBodyStructure; + public static readonly Azure.AI.TextAnalytics.HealthcareEntityRelationType DirectionOfExamination; + public static readonly Azure.AI.TextAnalytics.HealthcareEntityRelationType RelationOfExamination; + public static readonly Azure.AI.TextAnalytics.HealthcareEntityRelationType TimeOfExamination; + public bool Equals(Azure.AI.TextAnalytics.HealthcareEntityRelationType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.TextAnalytics.HealthcareEntityRelationType left, Azure.AI.TextAnalytics.HealthcareEntityRelationType right) { throw null; } + public static explicit operator string (Azure.AI.TextAnalytics.HealthcareEntityRelationType relationtype) { throw null; } + public static implicit operator Azure.AI.TextAnalytics.HealthcareEntityRelationType (string relationtype) { throw null; } + public static bool operator !=(Azure.AI.TextAnalytics.HealthcareEntityRelationType left, Azure.AI.TextAnalytics.HealthcareEntityRelationType right) { throw null; } + public override string ToString() { throw null; } } public partial class JobManifestTasks { @@ -378,12 +399,6 @@ internal RecognizeEntitiesResultCollection() : base (default(System.Collections. public string ModelVersion { get { throw null; } } public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } } - public partial class RecognizeHealthcareEntitiesResultCollection : System.Collections.ObjectModel.ReadOnlyCollection - { - internal RecognizeHealthcareEntitiesResultCollection() : base (default(System.Collections.Generic.IList)) { } - public string ModelVersion { get { throw null; } } - public Azure.AI.TextAnalytics.TextDocumentBatchStatistics Statistics { get { throw null; } } - } public partial class RecognizeLinkedEntitiesResult : Azure.AI.TextAnalytics.TextAnalyticsResult { internal RecognizeLinkedEntitiesResult() { } @@ -500,7 +515,7 @@ public TextAnalyticsClient(System.Uri endpoint, Azure.Core.TokenCredential crede public virtual System.Threading.Tasks.Task> ExtractKeyPhrasesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override int GetHashCode() { throw null; } - public virtual Azure.AsyncPageable GetHealthcareEntities(Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation operation, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AsyncPageable GetHealthcareEntities(Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation operation, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response RecognizeEntities(string document, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RecognizeEntitiesAsync(string document, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response RecognizeEntitiesBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -519,16 +534,14 @@ public TextAnalyticsClient(System.Uri endpoint, Azure.Core.TokenCredential crede public virtual Azure.Response RecognizePiiEntitiesBatch(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> RecognizePiiEntitiesBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartAnalyzeHealthcareEntitiesAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task StartAnalyzeHealthcareEntitiesAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AI.TextAnalytics.AnalyzeOperation StartAnalyzeOperationBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.AnalyzeOperationOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.AI.TextAnalytics.AnalyzeOperation StartAnalyzeOperationBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.AnalyzeOperationOptions options, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StartAnalyzeOperationBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.AnalyzeOperationOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task StartAnalyzeOperationBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.AnalyzeOperationOptions options, string language = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation StartHealthcare(string document, string language = null, Azure.AI.TextAnalytics.HealthcareOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task StartHealthcareAsync(string document, string language = null, Azure.AI.TextAnalytics.HealthcareOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.HealthcareOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual Azure.AI.TextAnalytics.AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.HealthcareOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task StartHealthcareBatchAsync(System.Collections.Generic.IEnumerable documents, Azure.AI.TextAnalytics.HealthcareOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task StartHealthcareBatchAsync(System.Collections.Generic.IEnumerable documents, string language = null, Azure.AI.TextAnalytics.HealthcareOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md index e0f608e2d69e6..a26e0362be63f 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/samples/Sample_RecognizeHealthcareEntities.md @@ -17,7 +17,7 @@ var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(a To recognize healthcare entities in a document, use the `StarthealthcareAsyc` method. The returned type is a Long Running operation of type `HealthcareOperation` which polls for the results from the API. -```C# Snippet:RecognizeHealthcareEntities +```C# Snippet:TextAnalyticsSampleHealthcareBatchAsync 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. \ @@ -28,36 +28,58 @@ To recognize healthcare entities in a document, use the `StarthealthcareAsyc` me 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."; - AnalyzeHealthcareEntitiesOperation healthOperation = client.StartHealthcare(document); + List batchInput = new List() + { + document, + document, + }; + + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() + { + Top = 1, + Skip = 0, + IncludeStatistics = true + }; + + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en", options); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; - Console.WriteLine($"Results of Azure Text Analytics \"Healthcare\" Model, version: \"{results.ModelVersion}\""); + Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { - Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); + Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); - foreach (HealthcareEntity entity in result.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($" Links:"); + + foreach (EntityDataSource entityDataSource in entity.DataSources) { - 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($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } - Console.WriteLine(""); + } + + Console.WriteLine($" Document statistics:"); + Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}"); + Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}"); + Console.WriteLine(""); } + Console.WriteLine($"Request statistics:"); + Console.WriteLine($" Document Count: {results.Statistics.DocumentCount}"); + Console.WriteLine($" Valid Document Count: {results.Statistics.ValidDocumentCount}"); + Console.WriteLine($" Transaction Count: {results.Statistics.TransactionCount}"); + Console.WriteLine($" Invalid Document Count: {results.Statistics.InvalidDocumentCount}"); + Console.WriteLine(""); } ``` @@ -81,16 +103,16 @@ To recognize healthcare entities in multiple documents, call `StartHealthcareBat document, }; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareBatchAsync(batchInput, "en"); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en"); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -100,13 +122,12 @@ To recognize healthcare entities in multiple documents, call `StartHealthcareBat 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine(""); @@ -116,8 +137,6 @@ To recognize healthcare entities in multiple documents, call `StartHealthcareBat To see the full example source files, see: -* [Synchronously RecognizeHealthcare ](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare.cs) -* [Asynchronously RecognizeHealthcare ](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync.cs) * [Synchronously RecognizeHealthcareBatch](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatch.cs) * [Asynchronously RecognizeHealthcareBatch](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchAsync.cs) * [Synchronously RecognizeHealthcare Cancellation](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare_Cancellation.cs) diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOperation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOperation.cs index cdd25e7c6dc03..d165498005342 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOperation.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOperation.cs @@ -14,7 +14,7 @@ namespace Azure.AI.TextAnalytics { /// The AnalyzeHealthcareEntitiesOperation class for LRO. - public class AnalyzeHealthcareEntitiesOperation : Operation + public class AnalyzeHealthcareEntitiesOperation : Operation { /// Provides communication with the Text Analytics Azure Cognitive Service through its REST API. private readonly TextAnalyticsRestClient _serviceClient; @@ -35,6 +35,21 @@ public class AnalyzeHealthcareEntitiesOperation : Operation public override string Id { get; } + /// + /// CreatedOn + /// + public DateTimeOffset CreatedOn { get; } + + /// + /// ExpiresOn + /// + public DateTimeOffset ExpiresOn { get; } + + /// + /// LastModified + /// + public DateTimeOffset LastModified { get; } + /// /// Gets the status of the operation. /// @@ -51,7 +66,7 @@ public class AnalyzeHealthcareEntitiesOperation : Operation /// This property can be accessed only after the operation completes successfully (HasValue is true). /// - public override RecognizeHealthcareEntitiesResultCollection Value + public override AnalyzeHealthcareEntitiesResultCollection Value { get { @@ -80,7 +95,7 @@ public override RecognizeHealthcareEntitiesResultCollection Value private Response _response; /// The result of the long-running operation. null until result is received on status update. - private RecognizeHealthcareEntitiesResultCollection _value; + private AnalyzeHealthcareEntitiesResultCollection _value; private int? _top { get; } private int? _skip { get; } @@ -169,7 +184,7 @@ public override async ValueTask UpdateStatusAsync(CancellationToken ca /// /// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation. /// - public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => this.DefaultWaitForCompletionAsync(cancellationToken); /// @@ -185,7 +200,7 @@ public override ValueTask> /// /// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation. /// - public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => this.DefaultWaitForCompletionAsync(pollingInterval, cancellationToken); /// diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareOptions.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOptions.cs similarity index 76% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareOptions.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOptions.cs index 92e32144b0c9d..8631d868a3746 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareOptions.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesOptions.cs @@ -7,13 +7,13 @@ namespace Azure.AI.TextAnalytics /// Options that allow callers to specify details about how the operation /// is run and what information is returned from it by the service. /// - public class HealthcareOptions : TextAnalyticsRequestOptions + public class AnalyzeHealthcareEntitiesOptions : TextAnalyticsRequestOptions { /// - /// Initializes a new instance of the + /// Initializes a new instance of the /// class. /// - public HealthcareOptions() + public AnalyzeHealthcareEntitiesOptions() { } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesResult.cs new file mode 100644 index 0000000000000..4ed1938a77264 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesResult.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Azure.AI.TextAnalytics +{ + /// + /// AnalyzeHealthcareEntitiesResult. + /// + public partial class AnalyzeHealthcareEntitiesResult : TextAnalyticsResult + { + private readonly IReadOnlyCollection _entities; + + internal AnalyzeHealthcareEntitiesResult(string id, TextDocumentStatistics statistics, + IList healthcareEntities, + IList warnings) + : base(id, statistics) + { + _entities = new ReadOnlyCollection(healthcareEntities); + Warnings = new ReadOnlyCollection(warnings); + } + + internal AnalyzeHealthcareEntitiesResult(string id, TextAnalyticsError error) : base(id, error) { } + + /// Warnings encountered while processing document. + public IReadOnlyCollection Warnings { get; } = new List(); + + /// + /// Gets the collection of healthcare entities in the document. + /// + public IReadOnlyCollection Entities + { + get + { + if (HasError) + { +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations + throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.ErrorCode}: {Error.Message}"); +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations + } + return _entities; + } + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeHealthcareEntitiesResultCollection.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesResultCollection.cs similarity index 73% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeHealthcareEntitiesResultCollection.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesResultCollection.cs index bf6e7f7631cc6..bea8b389222d1 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeHealthcareEntitiesResultCollection.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeHealthcareEntitiesResultCollection.cs @@ -3,22 +3,21 @@ using System.Collections.Generic; using System.Collections.ObjectModel; -using Azure.AI.TextAnalytics.Models; namespace Azure.AI.TextAnalytics { /// - /// Collection of objects corresponding + /// Collection of objects corresponding /// to a batch of documents, and information about the batch operation. /// - public class RecognizeHealthcareEntitiesResultCollection : ReadOnlyCollection + public class AnalyzeHealthcareEntitiesResultCollection : ReadOnlyCollection { /// /// /// /// /// - internal RecognizeHealthcareEntitiesResultCollection(IList list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list) + internal AnalyzeHealthcareEntitiesResultCollection(IList list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list) { Statistics = statistics; ModelVersion = modelVersion; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntitiesInternal.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntitiesInternal.cs index 0071611303222..eaab321612763 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntitiesInternal.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareEntitiesInternal.cs @@ -18,7 +18,7 @@ internal partial class DocumentHealthcareEntitiesInternal /// Unique, non-empty document identifier. public string Id { get; } /// Healthcare entities. - public IReadOnlyList Entities { get; } + public IReadOnlyList Entities { get; } /// Healthcare entity relations. public IReadOnlyList Relations { get; } /// Warnings encountered while processing document. diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareResult.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareResult.cs deleted file mode 100644 index 274dd0cb1e20c..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/DocumentHealthcareResult.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text.RegularExpressions; -using Azure.AI.TextAnalytics.Models; - -namespace Azure.AI.TextAnalytics -{ - /// - /// DocumentHealthcareEntities. - /// - public partial class DocumentHealthcareResult - { - internal DocumentHealthcareResult(DocumentHealthcareEntitiesInternal documentHealthcareEntities) - { - Entities = documentHealthcareEntities.Entities; - Relations = ResolveHealthcareRelations(documentHealthcareEntities.Entities, documentHealthcareEntities.Relations); - Id = documentHealthcareEntities.Id; - Warnings = Transforms.ConvertToWarnings(documentHealthcareEntities.Warnings); - Statistics = documentHealthcareEntities.Statistics; - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - internal DocumentHealthcareResult(string id, TextAnalyticsError textAnalyticsError) - { - Id = id; - TextAnalyticsError = textAnalyticsError; - } - - internal static IReadOnlyList ResolveHealthcareRelations(IEnumerable entities, IEnumerable relations) - { - List list = new List(); - - if (relations == null) - { - return list; - } - - foreach (HealthcareRelationInternal relation in relations) - { - list.Add(new HealthcareRelation(relation.RelationType, - relation.Bidirectional, - ResolveHealthcareEntity(entities, relation.Source), - ResolveHealthcareEntity(entities, relation.Target))); - } - - return list; - } - - /// Unique, non-empty document identifier. - public string Id { get; } - /// Healthcare entities. - public IReadOnlyList Entities { get; } - /// Healthcare entity relations. - public IReadOnlyList Relations { get; } = new List(); - /// Warnings encountered while processing document. - public IReadOnlyList Warnings { get; } = new List(); - /// if IncludeStatistics=true was specified in the request this field will contain information about the document payload. - public TextDocumentStatistics? Statistics { get; } - - /// TextAnalyticsError. - public TextAnalyticsError TextAnalyticsError { get; } - - private static Regex _healthcareEntityRegex = new Regex(@"\#/results/documents\/(?\d*)\/entities\/(?\d*)$", RegexOptions.Compiled, TimeSpan.FromSeconds(2)); - - internal static HealthcareEntity ResolveHealthcareEntity(IEnumerable entities, string reference) - { - var healthcareEntityMatch = _healthcareEntityRegex.Match(reference); - if (healthcareEntityMatch.Success) - { - int entityIndex = int.Parse(healthcareEntityMatch.Groups["entityIndex"].Value, CultureInfo.InvariantCulture); - - if (entityIndex < entities.Count()) - { - return entities.ElementAt(entityIndex); - } - } - - throw new InvalidOperationException($"Failed to parse element reference: {reference}"); - } - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityDataSource.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityDataSource.cs new file mode 100644 index 0000000000000..9abc15b2ff980 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityDataSource.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.AI.TextAnalytics +{ + /// + /// EntityDataSource. + /// + [CodeGenModel("HealthcareEntityLink")] + public partial class EntityDataSource + { + /// Entity id in the given source catalog. + [CodeGenMember("Id")] + public string EntityId { get; } + + /// Entity Catalog. Examples include: UMLS, CHV, MSH, etc. + [CodeGenMember("DataSource")] + public string Name { get; } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.Serialization.cs index 2cc5178a37712..b1df5a366305c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.Serialization.cs @@ -17,7 +17,7 @@ internal partial class DocumentHealthcareEntitiesInternal internal static DocumentHealthcareEntitiesInternal DeserializeDocumentHealthcareEntitiesInternal(JsonElement element) { string id = default; - IReadOnlyList entities = default; + IReadOnlyList entities = default; IReadOnlyList relations = default; IReadOnlyList warnings = default; Optional statistics = default; @@ -30,10 +30,10 @@ internal static DocumentHealthcareEntitiesInternal DeserializeDocumentHealthcare } if (property.NameEquals("entities")) { - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(HealthcareEntity.DeserializeHealthcareEntity(item)); + array.Add(HealthcareEntityInternal.DeserializeHealthcareEntityInternal(item)); } entities = array; continue; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.cs index 8edffa1c4a9d0..b1ab8a18b1aea 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/DocumentHealthcareEntitiesInternal.cs @@ -21,7 +21,7 @@ internal partial class DocumentHealthcareEntitiesInternal /// Healthcare entity relations. /// Warnings encountered while processing document. /// , , , or is null. - internal DocumentHealthcareEntitiesInternal(string id, IEnumerable entities, IEnumerable relations, IEnumerable warnings) + internal DocumentHealthcareEntitiesInternal(string id, IEnumerable entities, IEnumerable relations, IEnumerable warnings) { if (id == null) { @@ -52,7 +52,7 @@ internal DocumentHealthcareEntitiesInternal(string id, IEnumerable Healthcare entity relations. /// Warnings encountered while processing document. /// if showStats=true was specified in the request this field will contain information about the document payload. - internal DocumentHealthcareEntitiesInternal(string id, IReadOnlyList entities, IReadOnlyList relations, IReadOnlyList warnings, TextDocumentStatistics? statistics) + internal DocumentHealthcareEntitiesInternal(string id, IReadOnlyList entities, IReadOnlyList relations, IReadOnlyList warnings, TextDocumentStatistics? statistics) { Id = id; Entities = entities; diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityDataSource.Serialization.cs similarity index 78% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.Serialization.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityDataSource.Serialization.cs index 41bcc3c65d054..52977f39108c3 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityDataSource.Serialization.cs @@ -10,9 +10,9 @@ namespace Azure.AI.TextAnalytics { - public partial class HealthcareEntityLink + public partial class EntityDataSource { - internal static HealthcareEntityLink DeserializeHealthcareEntityLink(JsonElement element) + internal static EntityDataSource DeserializeEntityDataSource(JsonElement element) { string dataSource = default; string id = default; @@ -29,7 +29,7 @@ internal static HealthcareEntityLink DeserializeHealthcareEntityLink(JsonElement continue; } } - return new HealthcareEntityLink(dataSource, id); + return new EntityDataSource(dataSource, id); } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityDataSource.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityDataSource.cs new file mode 100644 index 0000000000000..75be70d61febc --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/EntityDataSource.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.AI.TextAnalytics +{ + /// The HealthcareEntityLink. + public partial class EntityDataSource + { + /// Initializes a new instance of EntityDataSource. + /// Entity Catalog. Examples include: UMLS, CHV, MSH, etc. + /// Entity id in the given source catalog. + /// or is null. + internal EntityDataSource(string name, string entityId) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + if (entityId == null) + { + throw new ArgumentNullException(nameof(entityId)); + } + + Name = name; + EntityId = entityId; + } + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.Serialization.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityInternal.Serialization.cs similarity index 81% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.Serialization.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityInternal.Serialization.cs index d2a73b85b5048..8de37665e765b 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.Serialization.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityInternal.Serialization.cs @@ -11,12 +11,12 @@ namespace Azure.AI.TextAnalytics { - public partial class HealthcareEntity + internal partial class HealthcareEntityInternal { - internal static HealthcareEntity DeserializeHealthcareEntity(JsonElement element) + internal static HealthcareEntityInternal DeserializeHealthcareEntityInternal(JsonElement element) { bool isNegated = default; - Optional> links = default; + Optional> links = default; string text = default; string category = default; Optional subcategory = default; @@ -37,10 +37,10 @@ internal static HealthcareEntity DeserializeHealthcareEntity(JsonElement element property.ThrowNonNullablePropertyIsNull(); continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(HealthcareEntityLink.DeserializeHealthcareEntityLink(item)); + array.Add(EntityDataSource.DeserializeEntityDataSource(item)); } links = array; continue; @@ -76,7 +76,7 @@ internal static HealthcareEntity DeserializeHealthcareEntity(JsonElement element continue; } } - return new HealthcareEntity(text, category, subcategory.Value, offset, length, confidenceScore, isNegated, Optional.ToList(links)); + return new HealthcareEntityInternal(text, category, subcategory.Value, offset, length, confidenceScore, isNegated, Optional.ToList(links)); } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityInternal.cs similarity index 76% rename from sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.cs rename to sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityInternal.cs index 2d817694fa049..8254438133d97 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntity.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityInternal.cs @@ -12,9 +12,9 @@ namespace Azure.AI.TextAnalytics { /// The HealthcareEntity. - public partial class HealthcareEntity : Entity + internal partial class HealthcareEntityInternal : Entity { - /// Initializes a new instance of HealthcareEntity. + /// Initializes a new instance of HealthcareEntityInternal. /// Entity text as appears in the request. /// Entity type. /// Start position for the entity text. Use of different 'stringIndexType' values can affect the offset returned. @@ -22,7 +22,7 @@ public partial class HealthcareEntity : Entity /// Confidence score between 0 and 1 of the extracted entity. /// . /// or is null. - internal HealthcareEntity(string text, string category, int offset, int length, double confidenceScore, bool isNegated) : base(text, category, offset, length, confidenceScore) + internal HealthcareEntityInternal(string text, string category, int offset, int length, double confidenceScore, bool isNegated) : base(text, category, offset, length, confidenceScore) { if (text == null) { @@ -34,10 +34,10 @@ internal HealthcareEntity(string text, string category, int offset, int length, } IsNegated = isNegated; - Links = new ChangeTrackingList(); + Links = new ChangeTrackingList(); } - /// Initializes a new instance of HealthcareEntity. + /// Initializes a new instance of HealthcareEntityInternal. /// Entity text as appears in the request. /// Entity type. /// (Optional) Entity sub type. @@ -46,12 +46,14 @@ internal HealthcareEntity(string text, string category, int offset, int length, /// Confidence score between 0 and 1 of the extracted entity. /// . /// Entity references in known data sources. - internal HealthcareEntity(string text, string category, string subcategory, int offset, int length, double confidenceScore, bool isNegated, IReadOnlyList links) : base(text, category, subcategory, offset, length, confidenceScore) + internal HealthcareEntityInternal(string text, string category, string subcategory, int offset, int length, double confidenceScore, bool isNegated, IReadOnlyList links) : base(text, category, subcategory, offset, length, confidenceScore) { IsNegated = isNegated; Links = links; } + + public bool IsNegated { get; } /// Entity references in known data sources. - public IReadOnlyList Links { get; } + public IReadOnlyList Links { get; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.cs deleted file mode 100644 index 6ad7ef0d584c2..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Generated/Models/HealthcareEntityLink.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; - -namespace Azure.AI.TextAnalytics -{ - /// The HealthcareEntityLink. - public partial class HealthcareEntityLink - { - /// Initializes a new instance of HealthcareEntityLink. - /// Entity Catalog. Examples include: UMLS, CHV, MSH, etc. - /// Entity id in the given source catalog. - /// or is null. - internal HealthcareEntityLink(string dataSource, string id) - { - if (dataSource == null) - { - throw new ArgumentNullException(nameof(dataSource)); - } - if (id == null) - { - throw new ArgumentNullException(nameof(id)); - } - - DataSource = dataSource; - Id = id; - } - - /// Entity Catalog. Examples include: UMLS, CHV, MSH, etc. - public string DataSource { get; } - /// Entity id in the given source catalog. - public string Id { get; } - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs index 267414b85b745..b437e21f47e2c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntity.cs @@ -2,19 +2,70 @@ // Licensed under the MIT License. using System.Collections.Generic; -using Azure.Core; namespace Azure.AI.TextAnalytics { /// - /// HealthcareEntity. + /// . /// - [CodeGenModel("HealthcareEntity")] - public partial class HealthcareEntity + public class HealthcareEntity { + internal HealthcareEntity(HealthcareEntityInternal entity) + { + Category = entity.Category; + Text = entity.Text; + SubCategory = entity.Subcategory; + ConfidenceScore = entity.ConfidenceScore; + Offset = entity.Offset; + DataSources = entity.Links; + RelatedEntities = new Dictionary(entity.RelatedEntities); + } /// - /// IsNegated + /// Gets the entity text as it appears in the input document. /// - public bool IsNegated { get; } + public string Text { get; } + + /// + /// Gets the entity category inferred by the Text Analytics service's + /// healthcare model. The list of available categories is + /// described at + /// . + /// + public string Category { get; } + + /// + /// Gets the sub category of the entity inferred by the Text Analytics service's + /// healthcare model. This property may not have a value if + /// a sub category doesn't exist for this entity. The list of available categories and + /// subcategories is described at + /// . + /// + public string SubCategory { get; } + + /// + /// Gets a score between 0 and 1, indicating the confidence that the + /// text substring matches this inferred entity. + /// + public double ConfidenceScore { get; } + + /// + /// Gets the starting position (in UTF-16 code units) for the matching text in the input document. + /// + public int Offset { get; } + + /// + /// Gets the length for the matching entity in the input document. + /// + public int Length { get; } + + /// + /// Get the list of data sources for the entity. + /// + public IReadOnlyCollection DataSources { get; } + + /// + /// Gets the entities and the relationship between the entities. + /// + public Dictionary RelatedEntities { get; } } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityInternal.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityInternal.cs new file mode 100644 index 0000000000000..4dd61d8319e7b --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityInternal.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.TextAnalytics +{ + /// + /// HealthcareEntity. + /// + [CodeGenModel("HealthcareEntity")] + internal partial class HealthcareEntityInternal + { + /// + /// Gets the dictionary for related entity with mapped relation type for each. + /// + internal Dictionary RelatedEntities { get; } = new Dictionary(); + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityLink.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityLink.cs deleted file mode 100644 index 3fd0acbd6de39..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityLink.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using Azure.Core; - -namespace Azure.AI.TextAnalytics -{ - /// - /// HealthcareEntityLink. - /// - [CodeGenModel("HealthcareEntityLink")] - public partial class HealthcareEntityLink - { - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityRelationType.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityRelationType.cs new file mode 100644 index 0000000000000..1cc17f53f7379 --- /dev/null +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareEntityRelationType.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ComponentModel; +using Azure.Core; + +namespace Azure.AI.TextAnalytics +{ + /// + /// HealthcareEntityRelationType + /// + public class HealthcareEntityRelationType : IEquatable + { + /// + /// Specifies the relation type DirectionOfBodyStructure. + /// + public static readonly HealthcareEntityRelationType DirectionOfBodyStructure = new HealthcareEntityRelationType("DirectionOfBodyStructure"); + + /// + /// Specifies the relation type DirectionOfExamination. + /// + public static readonly HealthcareEntityRelationType DirectionOfExamination = new HealthcareEntityRelationType("DirectionOfExamination"); + + /// + /// Specifies the relation type RelationOfExamination. + /// + public static readonly HealthcareEntityRelationType RelationOfExamination = new HealthcareEntityRelationType("RelationOfExamination"); + + /// + /// Specifies the relation type TimeOfExamination. + /// + public static readonly HealthcareEntityRelationType TimeOfExamination = new HealthcareEntityRelationType("TimeOfExamination"); + + private readonly string _value; + + private HealthcareEntityRelationType(string relationtype) + { + Argument.AssertNotNull(relationtype, nameof(relationtype)); + _value = relationtype; + } + + /// + /// Defines implicit conversion from string to HealthcareEntityRelationType. + /// + /// string to convert. + /// The string as an HealthcareEntityRelationType. + public static implicit operator HealthcareEntityRelationType(string relationtype) => new HealthcareEntityRelationType(relationtype); + + /// + /// Defines explicit conversion from HealthcareEntityRelationType to string. + /// + /// HealthcareEntityRelationType to convert. + /// The HealthcareEntityRelationType as a string. + public static explicit operator string(HealthcareEntityRelationType relationtype) => relationtype._value; + + /// + /// Compares two HealthcareEntityRelationType values for equality. + /// + /// The first HealthcareEntityRelationType to compare. + /// The second HealthcareEntityRelationType to compare. + /// true if the HealthcareEntityRelationType objects are equal or are both null; false otherwise. + public static bool operator ==(HealthcareEntityRelationType left, HealthcareEntityRelationType right) => Equals(left, right); + + /// + /// Compares two HealthcareEntityRelationType values for inequality. + /// + /// The first HealthcareEntityRelationType to compare. + /// The second HealthcareEntityRelationType to compare. + /// true if the HealthcareEntityRelationType objects are not equal; false otherwise. + public static bool operator !=(HealthcareEntityRelationType left, HealthcareEntityRelationType right) => !Equals(left, right); + + /// + /// Compares the HealthcareEntityRelationType for equality with another HealthcareEntityRelationType. + /// + /// The HealthcareEntityRelationType with which to compare. + /// true if the HealthcareEntityRelationType objects are equal; otherwise, false. + public bool Equals(HealthcareEntityRelationType other) => _value == other._value; + + /// + /// Determines whether the specified object is equal to the current object. + /// + /// The object to compare with the current object. + /// true if the specified object is equal to the current object; otherwise, false. + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is HealthcareEntityRelationType relationtype && Equals(relationtype); + + /// + /// Serves as the default hash function. + /// + /// A hash code for the current object. + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value.GetHashCode(); + + /// + /// Returns a string representation of the HealthcareEntityRelationType. + /// + /// The HealthcareEntityRelationType as a string. + public override string ToString() => _value; + } +} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareRelation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareRelation.cs deleted file mode 100644 index 49bd433d7dde1..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/HealthcareRelation.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; - -namespace Azure.AI.TextAnalytics -{ - /// - /// HealthcareRelation class. - /// - public partial class HealthcareRelation - { - /// Initializes a new instance of HealthcareRelation. - /// Type of relation. Examples include: `DosageOfMedication` or `FrequencyOfMedication`, etc. - /// If true the relation between the entities is bidirectional, otherwise directionality is source to target. - /// Reference link to the source entity. - /// Reference link to the target entity. - /// , , or is null. - internal HealthcareRelation(string relationType, bool bidirectional, HealthcareEntity source, HealthcareEntity target) - { - if (relationType == null) - { - throw new ArgumentNullException(nameof(relationType)); - } - if (source == null) - { - throw new ArgumentNullException(nameof(source)); - } - if (target == null) - { - throw new ArgumentNullException(nameof(target)); - } - - RelationType = relationType; - Bidirectional = bidirectional; - Source = source; - Target = target; - } - - /// - /// Source Entity - /// - public HealthcareEntity Source { get; } - - /// - /// Target Entity - /// - public HealthcareEntity Target { get; } - - /// Type of relation. Examples include: `DosageOfMedication` or `FrequencyOfMedication`, etc. - public string RelationType { get; } - /// If true the relation between the entities is bidirectional, otherwise directionality is source to target. - public bool Bidirectional { get; } - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs index 3c90fcad0aaea..83a939d3d3283 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/TextAnalyticsClient.cs @@ -2065,104 +2065,6 @@ private Response RecognizeLinkedEntitie #region Healthcare - /// - /// Runs a predictive model to identify a collection of healthcare entities - /// found in the passed-in document, and include information linking the - /// entities to their corresponding entries in a well-known knowledge base. - /// For a list of languages supported by this operation, see - /// . - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// Note: In order to use this functionality, request to access public preview is required. - /// Azure Active Directory (AAD) is not currently supported. For more information see - /// . - /// - /// - /// The document to analyze. - /// The language that the document is written in. - /// The additional configurable - /// A - /// controlling the request lifetime. - /// Service returned a non-success - /// status code. - public virtual async Task StartHealthcareAsync(string document, string language = default, HealthcareOptions options = default, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(document, nameof(document)); - options ??= new HealthcareOptions(); - - var documents = new List() { document }; - - MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents, language); - - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartHealthcare)}"); - scope.Start(); - - try - { - ResponseWithHeaders response = await _serviceRestClient.HealthAsync(documentInputs, options.ModelVersion, options.StringIndexType, cancellationToken).ConfigureAwait(false); - string location = response.Headers.OperationLocation; - - IDictionary idToIndexMap = CreateIdToIndexMap(documentInputs.Documents); - - return new AnalyzeHealthcareEntitiesOperation(_serviceRestClient, _clientDiagnostics, location, idToIndexMap, options.Top, options.Skip, options.IncludeStatistics); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// Runs a predictive model to identify a collection of healthcare entities - /// found in the passed-in document, and include information linking the - /// entities to their corresponding entries in a well-known knowledge base. - /// For a list of languages supported by this operation, see - /// . - /// For document length limits, maximum batch size, and supported text encoding, see - /// . - /// - /// Note: In order to use this functionality, request to access public preview is required. - /// Azure Active Directory (AAD) is not currently supported. For more information see - /// . - /// - /// - /// The document to analyze. - /// The language that the document is written in. - /// The additional configurable - /// A - /// controlling the request lifetime. - /// Service returned a non-success - /// status code. - public virtual AnalyzeHealthcareEntitiesOperation StartHealthcare(string document, string language = default, HealthcareOptions options = default, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(document, nameof(document)); - options ??= new HealthcareOptions(); - - var documents = new List() { document }; - - MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents, language); - - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartHealthcare)}"); - scope.Start(); - - try - { - ResponseWithHeaders response = _serviceRestClient.Health(documentInputs, options.ModelVersion, options.StringIndexType, cancellationToken); - string location = response.Headers.OperationLocation; - - IDictionary idToIndexMap = CreateIdToIndexMap(documentInputs.Documents); - - return new AnalyzeHealthcareEntitiesOperation(_serviceRestClient, _clientDiagnostics, location, idToIndexMap, options.Top, options.Skip, options.IncludeStatistics); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - /// /// Runs a predictive model to identify a collection of healthcare entities /// found in the passed-in document, and include information linking the @@ -2179,18 +2081,18 @@ public virtual AnalyzeHealthcareEntitiesOperation StartHealthcare(string documen /// /// The documents to analyze. /// The language that the document is written in. - /// The additional configurable + /// The additional configurable /// A /// controlling the request lifetime. /// Service returned a non-success /// status code. - public virtual async Task StartHealthcareBatchAsync(IEnumerable documents, string language = default, HealthcareOptions options = default, CancellationToken cancellationToken = default) + public virtual async Task StartAnalyzeHealthcareEntitiesAsync(IEnumerable documents, string language = default, AnalyzeHealthcareEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); - options ??= new HealthcareOptions(); + options ??= new AnalyzeHealthcareEntitiesOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents, language); - return await StartHealthcareBatchAsync(documentInputs, options, cancellationToken).ConfigureAwait(false); + return await StartAnalyzeHealthcareEntitiesAsync(documentInputs, options, cancellationToken).ConfigureAwait(false); } /// @@ -2213,7 +2115,7 @@ public virtual async Task StartHealthcareBat /// in the request sent to the /// service. If set to an empty string, the service will apply a model /// where the language is explicitly set to "None". - /// The additional configurable options + /// The additional configurable options /// A /// controlling the request lifetime. /// A result containing the collection of entities identified @@ -2221,13 +2123,13 @@ public virtual async Task StartHealthcareBat /// that a given entity correctly matches the identified substring. /// Service returned a non-success /// status code. - public virtual AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(IEnumerable documents, string language = default, HealthcareOptions options = default, CancellationToken cancellationToken = default) + public virtual AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(IEnumerable documents, string language = default, AnalyzeHealthcareEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(documents, nameof(documents)); - options ??= new HealthcareOptions(); + options ??= new AnalyzeHealthcareEntitiesOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents, language); - return StartHealthcareBatch(documentInputs, options, cancellationToken); + return StartAnalyzeHealthcareEntities(documentInputs, options, cancellationToken); } /// @@ -2245,19 +2147,19 @@ public virtual AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(IEnumerab /// /// /// The documents to analyze. - /// The additional configurable options + /// The additional configurable options /// A controlling the request lifetime. /// A to wait on this long-running operation. Its upon successful /// completion will contain layout elements extracted from the form. - public virtual AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(IEnumerable documents, HealthcareOptions options, CancellationToken cancellationToken = default) + public virtual AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(IEnumerable documents, AnalyzeHealthcareEntitiesOptions options, CancellationToken cancellationToken = default) { Argument.AssertNotNull(documents, nameof(documents)); - options ??= new HealthcareOptions(); + options ??= new AnalyzeHealthcareEntitiesOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); - return StartHealthcareBatch(documentInputs, options, cancellationToken); + return StartAnalyzeHealthcareEntities(documentInputs, options, cancellationToken); } /// @@ -2275,26 +2177,26 @@ public virtual AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(IEnumerab /// /// /// The documents to analyze. - /// The additional configurable options + /// The additional configurable options /// A controlling the request lifetime. /// A to wait on this long-running operation. Its upon successful /// completion will contain layout elements extracted from the form. - public virtual async Task StartHealthcareBatchAsync(IEnumerable documents, HealthcareOptions options = default, CancellationToken cancellationToken = default) + public virtual async Task StartAnalyzeHealthcareEntitiesAsync(IEnumerable documents, AnalyzeHealthcareEntitiesOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(documents, nameof(documents)); - options ??= new HealthcareOptions(); + options ??= new AnalyzeHealthcareEntitiesOptions(); MultiLanguageBatchInput documentInputs = ConvertToMultiLanguageInputs(documents); - return await StartHealthcareBatchAsync(documentInputs, options, cancellationToken).ConfigureAwait(false); + return await StartAnalyzeHealthcareEntitiesAsync(documentInputs, options, cancellationToken).ConfigureAwait(false); } - private AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(MultiLanguageBatchInput batchInput, HealthcareOptions options, CancellationToken cancellationToken = default) + private AnalyzeHealthcareEntitiesOperation StartAnalyzeHealthcareEntities(MultiLanguageBatchInput batchInput, AnalyzeHealthcareEntitiesOptions options, CancellationToken cancellationToken = default) { - options ??= new HealthcareOptions(); + options ??= new AnalyzeHealthcareEntitiesOptions(); - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartHealthcareBatch)}"); + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartAnalyzeHealthcareEntities)}"); scope.Start(); try @@ -2313,11 +2215,11 @@ private AnalyzeHealthcareEntitiesOperation StartHealthcareBatch(MultiLanguageBat } } - private async Task StartHealthcareBatchAsync(MultiLanguageBatchInput batchInput, HealthcareOptions options, CancellationToken cancellationToken = default) + private async Task StartAnalyzeHealthcareEntitiesAsync(MultiLanguageBatchInput batchInput, AnalyzeHealthcareEntitiesOptions options, CancellationToken cancellationToken = default) { - options ??= new HealthcareOptions(); + options ??= new AnalyzeHealthcareEntitiesOptions(); - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartHealthcareBatch)}"); + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(StartAnalyzeHealthcareEntities)}"); scope.Start(); try @@ -2341,19 +2243,19 @@ private async Task StartHealthcareBatchAsync /// /// Healthcare operation class object which is returned when operation is started. /// A controlling the request lifetime. - /// A collection of items. - public virtual AsyncPageable GetHealthcareEntities(AnalyzeHealthcareEntitiesOperation operation, CancellationToken cancellationToken = default) + /// A collection of items. + public virtual AsyncPageable GetHealthcareEntities(AnalyzeHealthcareEntitiesOperation operation, CancellationToken cancellationToken = default) { - async Task> FirstPageFunc(int? pageSizeHint) + async Task> FirstPageFunc(int? pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(GetHealthcareEntities)}"); scope.Start(); try { - Response response = await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + Response response = await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); - RecognizeHealthcareEntitiesResultCollection result = operation.Value; + AnalyzeHealthcareEntitiesResultCollection result = operation.Value; return Page.FromValues(result.AsEnumerable(), operation.NextLink, response.GetRawResponse()); } catch (Exception e) @@ -2362,7 +2264,7 @@ async Task> FirstPageFunc(int? pageSizeHint) throw; } } - async Task> NextPageFunc(string nextLink, int? pageSizeHint) + async Task> NextPageFunc(string nextLink, int? pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(TextAnalyticsClient)}.{nameof(GetHealthcareEntities)}"); scope.Start(); @@ -2417,7 +2319,7 @@ async Task> NextPageFunc(string nextLink, int? pa Response jobState = await _serviceRestClient.HealthStatusAsync(new Guid(jobId), top, skip, showStats, cancellationToken).ConfigureAwait(false); - RecognizeHealthcareEntitiesResultCollection result = Transforms.ConvertToRecognizeHealthcareEntitiesResultCollection(jobState.Value.Results, operation._idToIndexMap); + AnalyzeHealthcareEntitiesResultCollection result = Transforms.ConvertToRecognizeHealthcareEntitiesResultCollection(jobState.Value.Results, operation._idToIndexMap); return Page.FromValues(result.AsEnumerable(), jobState.Value.NextLink, jobState.GetRawResponse()); } catch (Exception e) diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs index 38f191a08eeb6..bec0c1aeb7101 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs @@ -3,7 +3,9 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; +using System.Text.RegularExpressions; using Azure.AI.TextAnalytics.Models; namespace Azure.AI.TextAnalytics @@ -245,27 +247,62 @@ internal static RecognizeLinkedEntitiesResultCollection ConvertToRecognizeLinked #region Healthcare - internal static RecognizeHealthcareEntitiesResultCollection ConvertToRecognizeHealthcareEntitiesResultCollection(HealthcareResult results, IDictionary idToIndexMap) + internal static List ConvertToHealthcareEntityCollection(IEnumerable healthcareEntities, IEnumerable healthcareRelations) { - var healthcareEntititesResults = new List(); + var entities = healthcareEntities.Select((entity) => new HealthcareEntity(entity)).ToList(); + foreach (HealthcareRelationInternal relation in healthcareRelations) { + string relationType = relation.RelationType; + int sourceIndex = ParseHealthcareEntityIndex(relation.Source); + int targetIndex = ParseHealthcareEntityIndex(relation.Target); + HealthcareEntity sourceEntity = entities[sourceIndex]; + HealthcareEntity targetEntity = entities[targetIndex]; + sourceEntity.RelatedEntities.Add(targetEntity, relationType); + if (relation.Bidirectional) + { + targetEntity.RelatedEntities.Add(sourceEntity, relationType); + } + } + return entities; + } + + internal static AnalyzeHealthcareEntitiesResultCollection ConvertToRecognizeHealthcareEntitiesResultCollection(HealthcareResult results, IDictionary idToIndexMap) + { + var healthcareEntititesResults = new List(); //Read errors foreach (DocumentError error in results.Errors) { - healthcareEntititesResults.Add(new DocumentHealthcareResult(error.Id, ConvertToError(error.Error))); + healthcareEntititesResults.Add(new AnalyzeHealthcareEntitiesResult(error.Id, ConvertToError(error.Error))); } //Read entities foreach (DocumentHealthcareEntitiesInternal documentHealthcareEntities in results.Documents) { - healthcareEntititesResults.Add(new DocumentHealthcareResult(documentHealthcareEntities)); + healthcareEntititesResults.Add(new AnalyzeHealthcareEntitiesResult( + documentHealthcareEntities.Id, + documentHealthcareEntities.Statistics ?? default, + ConvertToHealthcareEntityCollection(documentHealthcareEntities.Entities, documentHealthcareEntities.Relations), + ConvertToWarnings(documentHealthcareEntities.Warnings))); } healthcareEntititesResults = healthcareEntititesResults.OrderBy(result => idToIndexMap[result.Id]).ToList(); - return new RecognizeHealthcareEntitiesResultCollection(healthcareEntititesResults, results.Statistics, results.ModelVersion); + return new AnalyzeHealthcareEntitiesResultCollection(healthcareEntititesResults, results.Statistics, results.ModelVersion); } + private static int ParseHealthcareEntityIndex(string reference) + { + Match healthcareEntityMatch = _healthcareEntityRegex.Match(reference); + if (healthcareEntityMatch.Success) + { + return int.Parse(healthcareEntityMatch.Groups["entityIndex"].Value, CultureInfo.InvariantCulture); + } + + throw new InvalidOperationException($"Failed to parse element reference: {reference}"); + } + + private static Regex _healthcareEntityRegex = new Regex(@"\#/results/documents\/(?\d*)\/entities\/(?\d*)$", RegexOptions.Compiled, TimeSpan.FromSeconds(2)); + #endregion #region Analyze Operation diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/RecognizeHealthcareEntitiesTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/RecognizeHealthcareEntitiesTests.cs index c91d6ae24bbb5..1bceb4cf2daa8 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/RecognizeHealthcareEntitiesTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/RecognizeHealthcareEntitiesTests.cs @@ -36,23 +36,22 @@ public RecognizeHealthcareEntitiesTests(bool isAsync) : base(isAsync) { } public async Task RecognizeHealthcareEntitiesTest() { TextAnalyticsClient client = GetClient(); - string document = singleEnglish; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareAsync(document); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(batchDocuments); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; - Assert.AreEqual(1, resultCollection.Count); + Assert.AreEqual(2, resultCollection.Count); - DocumentHealthcareResult result = resultCollection.Single(); + AnalyzeHealthcareEntitiesResult result = resultCollection[0]; var entitiesList = new List { "100mg", "ibuprofen", "twice daily" }; Assert.AreEqual(3, result.Entities.Count); Assert.IsNotNull(result.Id); - Assert.AreEqual("0", result.Id); + Assert.AreEqual("1", result.Id); foreach (HealthcareEntity entity in result.Entities) { @@ -62,26 +61,24 @@ public async Task RecognizeHealthcareEntitiesTest() { var linksList = new List { "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 (EntityDataSource entityDataSource in entity.DataSources) + Assert.IsTrue(linksList.Contains(entityDataSource.Name)); } - } - foreach (HealthcareRelation relation in result.Relations) - { - if (relation.RelationType == "DosageOfMedication") + if (entity.Text == "100mg") { - 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); + Assert.IsTrue(entity.RelatedEntities.Count == 1); + + var relatedEntity = entity.RelatedEntities.FirstOrDefault().Key; + + Assert.AreEqual("ibuprofen", relatedEntity.Text); + Assert.AreEqual("MedicationName", relatedEntity.Category); + Assert.AreEqual(0, relatedEntity.Length); + Assert.AreEqual(27, relatedEntity.Offset); + Assert.AreEqual(1.0, relatedEntity.ConfidenceScore); + + // TODO - DosageOfMedication is not in relation types and is returned from the service. Need to add to swagger. + //Assert.AreEqual(HealthcareEntityRelationType.DosageOfMedication, entity.RelatedEntities.ElementAt(0).Value); } } } @@ -92,13 +89,13 @@ public async Task RecognizeHealthcareEntitiesWithLanguageTest() TextAnalyticsClient client = GetClient(); string document = singleEnglish; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(new List() { document }, "en"); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(new List() { document }, "en"); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; - foreach (DocumentHealthcareResult result in resultCollection) + foreach (AnalyzeHealthcareEntitiesResult result in resultCollection) { Assert.AreEqual(3, result.Entities.Count); Assert.IsNotNull(result.Id); @@ -110,16 +107,16 @@ public async Task RecognizeHealthcareEntitiesWithTopParameter() { TextAnalyticsClient client = GetClient(); - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { Top = 1 }; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(batchDocuments, options); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(batchDocuments, options); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; Assert.AreEqual(1, resultCollection.Count); Assert.AreEqual(3, resultCollection[0].Entities.Count); @@ -134,18 +131,18 @@ public async Task RecognizeHealthcareEntitiesWithSkipParameter() { TextAnalyticsClient client = GetClient(); - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { Skip = 1 }; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(batchDocuments, options); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(batchDocuments, options); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; - Assert.IsNotNull(resultCollection[0].TextAnalyticsError); + Assert.IsFalse(resultCollection[0].HasError); Assert.IsNotNull(resultCollection[0].Warnings); Assert.AreEqual(1, resultCollection.Count); Assert.AreEqual(6, resultCollection[0].Entities.Count); @@ -166,16 +163,16 @@ public async Task RecognizeHealthcareEntitiesBatchWithErrorTest() "", }; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(documents); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(documents); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; Assert.IsNotNull(resultCollection[2].Id); - Assert.IsNotNull(resultCollection[2].TextAnalyticsError); - Assert.AreEqual("Document text is empty.", resultCollection[2].TextAnalyticsError.Message); - Assert.AreEqual(TextAnalyticsErrorCode.InvalidDocument, resultCollection[2].TextAnalyticsError.ErrorCode.ToString()); + + Assert.IsTrue(resultCollection[2].HasError); + Assert.AreEqual(TextAnalyticsErrorCode.InvalidDocument, resultCollection[2].Error.ErrorCode.ToString()); } [Test] @@ -184,11 +181,11 @@ public async Task RecognizeHealthcareEntitiesBatchConvenienceTest() TextAnalyticsClient client = GetClient(); var documents = batchConvenienceDocuments; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(documents); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(documents); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; Assert.AreEqual(2, resultCollection.Count); } @@ -199,21 +196,21 @@ public async Task RecognizeHealthcareEntitiesBatchConvenienceWithStatisticsTest( TextAnalyticsClient client = GetClient(); var documents = batchConvenienceDocuments; - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { IncludeStatistics = true }; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(documents, "en", options); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(documents, "en", options); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; Assert.AreEqual(documents.Count, resultCollection.Statistics.DocumentCount); - Assert.AreEqual(48, resultCollection[0].Statistics.Value.CharacterCount); - Assert.AreEqual(1, resultCollection[0].Statistics.Value.TransactionCount); + Assert.AreEqual(48, resultCollection[0].Statistics.CharacterCount); + Assert.AreEqual(1, resultCollection[0].Statistics.TransactionCount); Assert.Greater(resultCollection.Statistics.DocumentCount, 0); Assert.AreEqual(2, resultCollection.Statistics.DocumentCount); @@ -228,11 +225,11 @@ public async Task RecognizeHealthcareEntitiesBatchTest() TextAnalyticsClient client = GetClient(); List documents = batchDocuments; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(documents); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(documents); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; Assert.AreEqual(2, resultCollection.Count); } @@ -243,16 +240,16 @@ public async Task RecognizeHealthcareEntitiesBatchWithStatisticsTest() TextAnalyticsClient client = GetClient(); var documents = batchDocuments; - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { IncludeStatistics = true }; - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(documents, options); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(documents, options); await operation.WaitForCompletionAsync(PollingInterval); - RecognizeHealthcareEntitiesResultCollection resultCollection = operation.Value; + AnalyzeHealthcareEntitiesResultCollection resultCollection = operation.Value; Assert.AreEqual(2, resultCollection.Count); @@ -274,7 +271,7 @@ public async Task RecognizeHealthcareEntitiesBatchWithCancellation() batchDocuments.Add(document); } - AnalyzeHealthcareEntitiesOperation operation = await client.StartHealthcareBatchAsync(batchDocuments, "en"); + AnalyzeHealthcareEntitiesOperation operation = await client.StartAnalyzeHealthcareEntitiesAsync(batchDocuments, "en"); await operation.CancelAsync(); @@ -309,17 +306,17 @@ public async Task RecognizeHealthcareEntitiesBatchWithPagination() list.Add(document); }; - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { Top = 2 }; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareBatchAsync(list, "en", options); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(list, "en", options); - AsyncPageable results = client.GetHealthcareEntities(healthOperation); + AsyncPageable results = client.GetHealthcareEntities(healthOperation); int resultCount = 0; - await foreach (DocumentHealthcareResult result in results) + await foreach (AnalyzeHealthcareEntitiesResult result in results) { resultCount += 1; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTest.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTest.json index 92fe79ec6adc5..e390bbbaaa871 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTest.json +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTest.json @@ -1,119 +1,106 @@ { "Entries": [ { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs?stringIndexType=Utf16CodeUnit", + "RequestUri": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs?stringIndexType=Utf16CodeUnit", "RequestMethod": "POST", "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], - "Content-Length": "100", + "Accept": "application/json, text/json", + "Content-Length": "223", "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": "Sanitized", - "traceparent": "00-7d83b3ff7afff74d8646a40f3a9773bb-75577e8f2adc544c-00", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], + "traceparent": "00-36f6c39da44b2546bad6c9a423bf90c6-96b8683de0ee4542-00", + "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210201.1 (.NET Framework 4.8.4250.0; Microsoft Windows 10.0.19042 )", "x-ms-client-request-id": "e51cbf87a321df02032925de5e6708b4", "x-ms-return-client-request-id": "true" }, "RequestBody": { "documents": [ { - "id": "0", + "id": "1", "text": "Subject is taking 100mg of ibuprofen twice daily", "language": "en" + }, + { + "id": "2", + "text": "Can cause rapid or irregular heartbeat, delirium, panic, psychosis, and heart failure.", + "language": "en" } ] }, "StatusCode": 202, "ResponseHeaders": { - "apim-request-id": "3ebc853f-1e23-4fac-9805-ab8f7ece142b", - "Date": "Tue, 17 Nov 2020 20:17:35 GMT", - "operation-location": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/970738c7-50b4-4b04-806a-5e05c01ba70f", + "apim-request-id": "e8773249-c01a-4a99-b340-7b9288cbfd28", + "Date": "Mon, 01 Feb 2021 22:39:56 GMT", + "operation-location": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/abf7284a-a7ce-45b8-8e97-928f6d9f9d06", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "69" + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "303" }, "ResponseBody": [] }, { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/970738c7-50b4-4b04-806a-5e05c01ba70f?showStats=false", + "RequestUri": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/abf7284a-a7ce-45b8-8e97-928f6d9f9d06?showStats=false", "RequestMethod": "GET", "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], + "Accept": "application/json, text/json", "Ocp-Apim-Subscription-Key": "Sanitized", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], + "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210201.1 (.NET Framework 4.8.4250.0; Microsoft Windows 10.0.19042 )", "x-ms-client-request-id": "2cdb69530701f208f175aa6a97e2593b", "x-ms-return-client-request-id": "true" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { - "apim-request-id": "4b91b2da-980d-48ba-b3fd-680b8e10d8f7", + "apim-request-id": "2211dd68-5bcb-4ce4-8f36-0cf5b87073ff", "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 17 Nov 2020 20:17:35 GMT", + "Date": "Mon, 01 Feb 2021 22:39:57 GMT", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "8" + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "1143" }, "ResponseBody": { - "jobId": "970738c7-50b4-4b04-806a-5e05c01ba70f", - "lastUpdateDateTime": "2020-11-17T20:17:36Z", - "createdDateTime": "2020-11-17T20:17:36Z", - "expirationDateTime": "2020-11-18T20:17:36Z", + "jobId": "abf7284a-a7ce-45b8-8e97-928f6d9f9d06", + "lastUpdateDateTime": "2021-02-01T22:39:57Z", + "createdDateTime": "2021-02-01T22:39:56Z", + "expirationDateTime": "2021-02-02T22:39:56Z", "status": "notStarted", "errors": [] } }, { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/970738c7-50b4-4b04-806a-5e05c01ba70f?showStats=false", + "RequestUri": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/abf7284a-a7ce-45b8-8e97-928f6d9f9d06?showStats=false", "RequestMethod": "GET", "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], + "Accept": "application/json, text/json", "Ocp-Apim-Subscription-Key": "Sanitized", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], + "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210201.1 (.NET Framework 4.8.4250.0; Microsoft Windows 10.0.19042 )", "x-ms-client-request-id": "a701cb20bb11a529608aebe12f36a48e", "x-ms-return-client-request-id": "true" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { - "apim-request-id": "496f7a26-757f-4d47-96c9-b39dd77dfc28", + "apim-request-id": "8b838e7d-c660-4b9c-a2f2-adb50d7daf8d", "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 17 Nov 2020 20:17:36 GMT", + "Date": "Mon, 01 Feb 2021 22:40:00 GMT", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "42" + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "1501" }, "ResponseBody": { - "jobId": "970738c7-50b4-4b04-806a-5e05c01ba70f", - "lastUpdateDateTime": "2020-11-17T20:17:37Z", - "createdDateTime": "2020-11-17T20:17:36Z", - "expirationDateTime": "2020-11-18T20:17:36Z", + "jobId": "abf7284a-a7ce-45b8-8e97-928f6d9f9d06", + "lastUpdateDateTime": "2021-02-01T22:40:00Z", + "createdDateTime": "2021-02-01T22:39:56Z", + "expirationDateTime": "2021-02-02T22:39:56Z", "status": "succeeded", "errors": [], "results": { "documents": [ { - "id": "0", + "id": "1", "entities": [ { "offset": 18, @@ -277,6 +264,789 @@ } ], "warnings": [] + }, + { + "id": "2", + "entities": [ + { + "offset": 10, + "length": 5, + "text": "rapid", + "category": "SymptomOrSign", + "confidenceScore": 0.98, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0456962" + }, + { + "dataSource": "AOD", + "id": "0000002744" + }, + { + "dataSource": "CHV", + "id": "0000034666" + }, + { + "dataSource": "LNC", + "id": "LA24868-4" + }, + { + "dataSource": "NCI", + "id": "C65069" + }, + { + "dataSource": "RCD", + "id": "X78xZ" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "255358001" + } + ] + }, + { + "offset": 19, + "length": 19, + "text": "irregular heartbeat", + "category": "SymptomOrSign", + "confidenceScore": 1.0, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0003811" + }, + { + "dataSource": "AOD", + "id": "0000005346" + }, + { + "dataSource": "BI", + "id": "BI00057" + }, + { + "dataSource": "CCPSS", + "id": "1017785" + }, + { + "dataSource": "CCS", + "id": "7.2.9" + }, + { + "dataSource": "CCSR_10", + "id": "CIR017" + }, + { + "dataSource": "CHV", + "id": "0000001440" + }, + { + "dataSource": "COSTAR", + "id": "153" + }, + { + "dataSource": "CSP", + "id": "1393-3277" + }, + { + "dataSource": "CST", + "id": "ARRHYTHMIA" + }, + { + "dataSource": "HPO", + "id": "HP:0011675" + }, + { + "dataSource": "ICD10", + "id": "I49.9" + }, + { + "dataSource": "ICD10AM", + "id": "I49.9" + }, + { + "dataSource": "ICD10CM", + "id": "I49.9" + }, + { + "dataSource": "ICD9CM", + "id": "427.9" + }, + { + "dataSource": "ICPC", + "id": "K80" + }, + { + "dataSource": "ICPC2EENG", + "id": "K80" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU033639" + }, + { + "dataSource": "ICPC2P", + "id": "K80012" + }, + { + "dataSource": "LCH", + "id": "U000359" + }, + { + "dataSource": "LCH_NW", + "id": "sh85007430" + }, + { + "dataSource": "LNC", + "id": "LA15419-7" + }, + { + "dataSource": "MDR", + "id": "10003119" + }, + { + "dataSource": "MEDCIN", + "id": "35851" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "147" + }, + { + "dataSource": "MSH", + "id": "D001145" + }, + { + "dataSource": "MTH", + "id": "153" + }, + { + "dataSource": "MTHICD9", + "id": "427.9" + }, + { + "dataSource": "NANDA-I", + "id": "00126" + }, + { + "dataSource": "NCI", + "id": "C2881" + }, + { + "dataSource": "NCI_FDA", + "id": "1721" + }, + { + "dataSource": "NCI_NICHD", + "id": "C2881" + }, + { + "dataSource": "NOC", + "id": "040520" + }, + { + "dataSource": "OMIM", + "id": "115000" + }, + { + "dataSource": "PSY", + "id": "03790" + }, + { + "dataSource": "RCD", + "id": "X77BB" + }, + { + "dataSource": "SNM", + "id": "F-73102" + }, + { + "dataSource": "SNMI", + "id": "D3-30010" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "698247007" + }, + { + "dataSource": "WHO", + "id": "0433" + } + ] + }, + { + "offset": 40, + "length": 8, + "text": "delirium", + "category": "Diagnosis", + "confidenceScore": 0.99, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0011206" + }, + { + "dataSource": "AOD", + "id": "0000004328" + }, + { + "dataSource": "CCPSS", + "id": "1017884" + }, + { + "dataSource": "CHV", + "id": "0000003670" + }, + { + "dataSource": "COSTAR", + "id": "U000178" + }, + { + "dataSource": "CSP", + "id": "5003-0016" + }, + { + "dataSource": "CST", + "id": "DELIRIUM" + }, + { + "dataSource": "DSM-5", + "id": "780.09" + }, + { + "dataSource": "DXP", + "id": "U000937" + }, + { + "dataSource": "HPO", + "id": "HP:0031258" + }, + { + "dataSource": "ICD10", + "id": "F05.9" + }, + { + "dataSource": "ICD10AM", + "id": "F05.9" + }, + { + "dataSource": "ICD10CM", + "id": "R41.0" + }, + { + "dataSource": "ICNP", + "id": "10022091" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU022150" + }, + { + "dataSource": "LCH", + "id": "U001289" + }, + { + "dataSource": "LCH_NW", + "id": "sh85036579" + }, + { + "dataSource": "LNC", + "id": "LP89856-6" + }, + { + "dataSource": "MDR", + "id": "10012218" + }, + { + "dataSource": "MEDCIN", + "id": "677" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "5562" + }, + { + "dataSource": "MSH", + "id": "D003693" + }, + { + "dataSource": "NANDA-I", + "id": "02157" + }, + { + "dataSource": "NCI", + "id": "C2981" + }, + { + "dataSource": "NCI_CTCAE", + "id": "E12898" + }, + { + "dataSource": "NCI_CTRP", + "id": "C2981" + }, + { + "dataSource": "NCI_NCI-GLOSS", + "id": "CDR0000450100" + }, + { + "dataSource": "NCI_NICHD", + "id": "C2981" + }, + { + "dataSource": "NOC", + "id": "091213" + }, + { + "dataSource": "OMIM", + "id": "MTHU035152" + }, + { + "dataSource": "PDQ", + "id": "CDR0000042226" + }, + { + "dataSource": "PSY", + "id": "13360" + }, + { + "dataSource": "QMR", + "id": "Q0200089" + }, + { + "dataSource": "RCD", + "id": "XE1Xv" + }, + { + "dataSource": "SNM", + "id": "F-85720" + }, + { + "dataSource": "SNMI", + "id": "D9-20100" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "2776000" + }, + { + "dataSource": "WHO", + "id": "0099" + } + ] + }, + { + "offset": 50, + "length": 5, + "text": "panic", + "category": "Diagnosis", + "confidenceScore": 0.89, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0030318" + }, + { + "dataSource": "AOD", + "id": "0000023911" + }, + { + "dataSource": "CHV", + "id": "0000009234" + }, + { + "dataSource": "CST", + "id": "AGITATION" + }, + { + "dataSource": "ICD10CM", + "id": "F41.0" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU057222" + }, + { + "dataSource": "LCH", + "id": "U003458" + }, + { + "dataSource": "LCH_NW", + "id": "sh85097438" + }, + { + "dataSource": "MDR", + "id": "10033670" + }, + { + "dataSource": "MSH", + "id": "D010200" + }, + { + "dataSource": "MTH", + "id": "551" + }, + { + "dataSource": "MTHICD9", + "id": "300.01" + }, + { + "dataSource": "NCI", + "id": "C94438" + }, + { + "dataSource": "NCI_NCI-GLOSS", + "id": "CDR0000454704" + }, + { + "dataSource": "NOC", + "id": "121346" + }, + { + "dataSource": "PSY", + "id": "36260" + }, + { + "dataSource": "RCD", + "id": "Xa3Vj" + }, + { + "dataSource": "SNM", + "id": "F-90880" + }, + { + "dataSource": "SNMI", + "id": "F-92560" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "79823003" + }, + { + "dataSource": "WHO", + "id": "0163" + } + ] + }, + { + "offset": 57, + "length": 9, + "text": "psychosis", + "category": "Diagnosis", + "confidenceScore": 1.0, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0033975" + }, + { + "dataSource": "AIR", + "id": "PSYCH" + }, + { + "dataSource": "AOD", + "id": "0000004324" + }, + { + "dataSource": "BI", + "id": "BI00688" + }, + { + "dataSource": "CCPSS", + "id": "1018204" + }, + { + "dataSource": "CHV", + "id": "0000010350" + }, + { + "dataSource": "COSTAR", + "id": "089" + }, + { + "dataSource": "CSP", + "id": "2484-8182" + }, + { + "dataSource": "CST", + "id": "PSYCHOSIS" + }, + { + "dataSource": "DXP", + "id": "U003257" + }, + { + "dataSource": "HPO", + "id": "HP:0000709" + }, + { + "dataSource": "ICD9CM", + "id": "298.9" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU070382" + }, + { + "dataSource": "ICPC2P", + "id": "P98004" + }, + { + "dataSource": "LCH_NW", + "id": "sh85108502" + }, + { + "dataSource": "LNC", + "id": "LA7534-6" + }, + { + "dataSource": "MDR", + "id": "10061920" + }, + { + "dataSource": "MEDCIN", + "id": "364298" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "4180" + }, + { + "dataSource": "MSH", + "id": "D011618" + }, + { + "dataSource": "MTH", + "id": "089" + }, + { + "dataSource": "MTHICD9", + "id": "298.9" + }, + { + "dataSource": "NANDA-I", + "id": "03128" + }, + { + "dataSource": "NCI", + "id": "C78576" + }, + { + "dataSource": "NCI_CTCAE", + "id": "E12954" + }, + { + "dataSource": "NCI_NCI-GLOSS", + "id": "CDR0000450115" + }, + { + "dataSource": "NCI_NICHD", + "id": "C78576" + }, + { + "dataSource": "NOC", + "id": "061619" + }, + { + "dataSource": "OMIM", + "id": "MTHU002910" + }, + { + "dataSource": "PSY", + "id": "41910" + }, + { + "dataSource": "QMR", + "id": "Q0200208" + }, + { + "dataSource": "RCD", + "id": "X00S6" + }, + { + "dataSource": "SNM", + "id": "D-9200" + }, + { + "dataSource": "SNMI", + "id": "D9-72000" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "69322001" + }, + { + "dataSource": "WHO", + "id": "0193" + } + ] + }, + { + "offset": 72, + "length": 13, + "text": "heart failure", + "category": "Diagnosis", + "confidenceScore": 0.99, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0018801" + }, + { + "dataSource": "AOD", + "id": "0000005308" + }, + { + "dataSource": "BI", + "id": "BI00019" + }, + { + "dataSource": "CCPSS", + "id": "0017571" + }, + { + "dataSource": "CCS", + "id": "7.2.11.2" + }, + { + "dataSource": "CCSR_10", + "id": "CIR019" + }, + { + "dataSource": "CHV", + "id": "0000005877" + }, + { + "dataSource": "COSTAR", + "id": "U000338" + }, + { + "dataSource": "CSP", + "id": "1393-3587" + }, + { + "dataSource": "CST", + "id": "HEART FAIL" + }, + { + "dataSource": "HPO", + "id": "HP:0001635" + }, + { + "dataSource": "ICD10", + "id": "I50.9" + }, + { + "dataSource": "ICD10AM", + "id": "I50.9" + }, + { + "dataSource": "ICD10CM", + "id": "I50.9" + }, + { + "dataSource": "ICD9CM", + "id": "428.9" + }, + { + "dataSource": "ICPC", + "id": "K77" + }, + { + "dataSource": "ICPC2EENG", + "id": "K77" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU027668" + }, + { + "dataSource": "ICPC2P", + "id": "K77011" + }, + { + "dataSource": "LCH", + "id": "U005616" + }, + { + "dataSource": "LCH_NW", + "id": "sh85059745" + }, + { + "dataSource": "LNC", + "id": "LP269421-6" + }, + { + "dataSource": "MDR", + "id": "10007554" + }, + { + "dataSource": "MEDCIN", + "id": "95724" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "199" + }, + { + "dataSource": "MSH", + "id": "D006333" + }, + { + "dataSource": "MTHICD9", + "id": "428.9" + }, + { + "dataSource": "NCI", + "id": "C50577" + }, + { + "dataSource": "NCI_CTCAE", + "id": "E10124" + }, + { + "dataSource": "NCI_FDA", + "id": "2206" + }, + { + "dataSource": "NCI_NICHD", + "id": "C50577" + }, + { + "dataSource": "OMIM", + "id": "MTHU009472" + }, + { + "dataSource": "RCD", + "id": "G58.." + }, + { + "dataSource": "SNM", + "id": "D-7050" + }, + { + "dataSource": "SNMI", + "id": "D3-16000" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "84114007" + }, + { + "dataSource": "WHO", + "id": "0496" + } + ] + } + ], + "relations": [], + "warnings": [] } ], "errors": [], @@ -288,6 +1058,6 @@ "Variables": { "RandomSeed": "1686725774", "TEXT_ANALYTICS_API_KEY": "Sanitized", - "TEXT_ANALYTICS_ENDPOINT": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com" + "TEXT_ANALYTICS_ENDPOINT": "https://ta-s-westeurope.cognitiveservices.azure.com" } } \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTestAsync.json b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTestAsync.json index f456d4b3de42c..9d25996316703 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTestAsync.json +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/SessionRecords/RecognizeHealthcareEntitiesTests/RecognizeHealthcareEntitiesTestAsync.json @@ -1,155 +1,106 @@ { "Entries": [ { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs?stringIndexType=Utf16CodeUnit", + "RequestUri": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs?stringIndexType=Utf16CodeUnit", "RequestMethod": "POST", "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], - "Content-Length": "100", + "Accept": "application/json, text/json", + "Content-Length": "223", "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": "Sanitized", - "traceparent": "00-e5a4811315d9ac458320de27ff359ca5-038f3624c8c5b245-00", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], + "traceparent": "00-0731d84338b4a34597da1454795cff6f-32e439059e32dc4e-00", + "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210201.1 (.NET Framework 4.8.4250.0; Microsoft Windows 10.0.19042 )", "x-ms-client-request-id": "acdb13842ca5b9295fa84adf0c4870a8", "x-ms-return-client-request-id": "true" }, "RequestBody": { "documents": [ { - "id": "0", + "id": "1", "text": "Subject is taking 100mg of ibuprofen twice daily", "language": "en" + }, + { + "id": "2", + "text": "Can cause rapid or irregular heartbeat, delirium, panic, psychosis, and heart failure.", + "language": "en" } ] }, "StatusCode": 202, "ResponseHeaders": { - "apim-request-id": "12c1243f-92ad-4c7f-b481-1a74aa2310a5", - "Date": "Tue, 17 Nov 2020 20:17:58 GMT", - "operation-location": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/438b8056-a2b2-4122-b554-92ddd20bf4cd", + "apim-request-id": "a8d93197-4ccc-44e0-9e54-09b4c1701fa5", + "Date": "Mon, 01 Feb 2021 22:40:01 GMT", + "operation-location": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/e16734bd-a6bc-4401-a89e-88c6f216a900", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "77" + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "681" }, "ResponseBody": [] }, { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/438b8056-a2b2-4122-b554-92ddd20bf4cd?showStats=false", + "RequestUri": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/e16734bd-a6bc-4401-a89e-88c6f216a900?showStats=false", "RequestMethod": "GET", "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], + "Accept": "application/json, text/json", "Ocp-Apim-Subscription-Key": "Sanitized", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], + "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210201.1 (.NET Framework 4.8.4250.0; Microsoft Windows 10.0.19042 )", "x-ms-client-request-id": "1181511460ff1ed085a4ba80632c2cfd", "x-ms-return-client-request-id": "true" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { - "apim-request-id": "baf7113b-79a6-429c-9229-820419698c27", + "apim-request-id": "e3452241-630f-4efb-86ea-df96ed527dbc", "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 17 Nov 2020 20:17:58 GMT", + "Date": "Mon, 01 Feb 2021 22:40:01 GMT", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "8" + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "122" }, "ResponseBody": { - "jobId": "438b8056-a2b2-4122-b554-92ddd20bf4cd", - "lastUpdateDateTime": "2020-11-17T20:17:58Z", - "createdDateTime": "2020-11-17T20:17:58Z", - "expirationDateTime": "2020-11-18T20:17:58Z", + "jobId": "e16734bd-a6bc-4401-a89e-88c6f216a900", + "lastUpdateDateTime": "2021-02-01T22:40:02Z", + "createdDateTime": "2021-02-01T22:40:01Z", + "expirationDateTime": "2021-02-02T22:40:01Z", "status": "notStarted", "errors": [] } }, { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/438b8056-a2b2-4122-b554-92ddd20bf4cd?showStats=false", + "RequestUri": "https://ta-s-westeurope.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/e16734bd-a6bc-4401-a89e-88c6f216a900?showStats=false", "RequestMethod": "GET", "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], + "Accept": "application/json, text/json", "Ocp-Apim-Subscription-Key": "Sanitized", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], + "User-Agent": "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20210201.1 (.NET Framework 4.8.4250.0; Microsoft Windows 10.0.19042 )", "x-ms-client-request-id": "d0605b7dc709a544ca5e0c1b0401dc1e", "x-ms-return-client-request-id": "true" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { - "apim-request-id": "d027eaed-0b6c-4468-8fbf-3ff4d24be74f", + "apim-request-id": "5a409b75-0291-4bb3-99f8-50b010d94834", "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 17 Nov 2020 20:17:59 GMT", + "Date": "Mon, 01 Feb 2021 22:40:05 GMT", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "10" + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "2378" }, "ResponseBody": { - "jobId": "438b8056-a2b2-4122-b554-92ddd20bf4cd", - "lastUpdateDateTime": "2020-11-17T20:18:00Z", - "createdDateTime": "2020-11-17T20:17:58Z", - "expirationDateTime": "2020-11-18T20:17:58Z", - "status": "running", - "errors": [] - } - }, - { - "RequestUri": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com/text/analytics/v3.1-preview.3/entities/health/jobs/438b8056-a2b2-4122-b554-92ddd20bf4cd?showStats=false", - "RequestMethod": "GET", - "RequestHeaders": { - "Accept": [ - "application/json", - "text/json" - ], - "Ocp-Apim-Subscription-Key": "Sanitized", - "User-Agent": [ - "azsdk-net-AI.TextAnalytics/5.1.0-alpha.20201116.1", - "(.NET Core 4.6.29321.03; Microsoft Windows 10.0.19042 )" - ], - "x-ms-client-request-id": "b5e59345e53b24c743bd270071a85633", - "x-ms-return-client-request-id": "true" - }, - "RequestBody": null, - "StatusCode": 200, - "ResponseHeaders": { - "apim-request-id": "d2e9e5f5-5a76-4f03-aad3-aed1c8c851b2", - "Content-Type": "application/json; charset=utf-8", - "Date": "Tue, 17 Nov 2020 20:18:00 GMT", - "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload", - "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-envoy-upstream-service-time": "32" - }, - "ResponseBody": { - "jobId": "438b8056-a2b2-4122-b554-92ddd20bf4cd", - "lastUpdateDateTime": "2020-11-17T20:18:00Z", - "createdDateTime": "2020-11-17T20:17:58Z", - "expirationDateTime": "2020-11-18T20:17:58Z", + "jobId": "e16734bd-a6bc-4401-a89e-88c6f216a900", + "lastUpdateDateTime": "2021-02-01T22:40:03Z", + "createdDateTime": "2021-02-01T22:40:01Z", + "expirationDateTime": "2021-02-02T22:40:01Z", "status": "succeeded", "errors": [], "results": { "documents": [ { - "id": "0", + "id": "1", "entities": [ { "offset": 18, @@ -313,6 +264,789 @@ } ], "warnings": [] + }, + { + "id": "2", + "entities": [ + { + "offset": 10, + "length": 5, + "text": "rapid", + "category": "SymptomOrSign", + "confidenceScore": 0.98, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0456962" + }, + { + "dataSource": "AOD", + "id": "0000002744" + }, + { + "dataSource": "CHV", + "id": "0000034666" + }, + { + "dataSource": "LNC", + "id": "LA24868-4" + }, + { + "dataSource": "NCI", + "id": "C65069" + }, + { + "dataSource": "RCD", + "id": "X78xZ" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "255358001" + } + ] + }, + { + "offset": 19, + "length": 19, + "text": "irregular heartbeat", + "category": "SymptomOrSign", + "confidenceScore": 1.0, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0003811" + }, + { + "dataSource": "AOD", + "id": "0000005346" + }, + { + "dataSource": "BI", + "id": "BI00057" + }, + { + "dataSource": "CCPSS", + "id": "1017785" + }, + { + "dataSource": "CCS", + "id": "7.2.9" + }, + { + "dataSource": "CCSR_10", + "id": "CIR017" + }, + { + "dataSource": "CHV", + "id": "0000001440" + }, + { + "dataSource": "COSTAR", + "id": "153" + }, + { + "dataSource": "CSP", + "id": "1393-3277" + }, + { + "dataSource": "CST", + "id": "ARRHYTHMIA" + }, + { + "dataSource": "HPO", + "id": "HP:0011675" + }, + { + "dataSource": "ICD10", + "id": "I49.9" + }, + { + "dataSource": "ICD10AM", + "id": "I49.9" + }, + { + "dataSource": "ICD10CM", + "id": "I49.9" + }, + { + "dataSource": "ICD9CM", + "id": "427.9" + }, + { + "dataSource": "ICPC", + "id": "K80" + }, + { + "dataSource": "ICPC2EENG", + "id": "K80" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU033639" + }, + { + "dataSource": "ICPC2P", + "id": "K80012" + }, + { + "dataSource": "LCH", + "id": "U000359" + }, + { + "dataSource": "LCH_NW", + "id": "sh85007430" + }, + { + "dataSource": "LNC", + "id": "LA15419-7" + }, + { + "dataSource": "MDR", + "id": "10003119" + }, + { + "dataSource": "MEDCIN", + "id": "35851" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "147" + }, + { + "dataSource": "MSH", + "id": "D001145" + }, + { + "dataSource": "MTH", + "id": "153" + }, + { + "dataSource": "MTHICD9", + "id": "427.9" + }, + { + "dataSource": "NANDA-I", + "id": "00126" + }, + { + "dataSource": "NCI", + "id": "C2881" + }, + { + "dataSource": "NCI_FDA", + "id": "1721" + }, + { + "dataSource": "NCI_NICHD", + "id": "C2881" + }, + { + "dataSource": "NOC", + "id": "040520" + }, + { + "dataSource": "OMIM", + "id": "115000" + }, + { + "dataSource": "PSY", + "id": "03790" + }, + { + "dataSource": "RCD", + "id": "X77BB" + }, + { + "dataSource": "SNM", + "id": "F-73102" + }, + { + "dataSource": "SNMI", + "id": "D3-30010" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "698247007" + }, + { + "dataSource": "WHO", + "id": "0433" + } + ] + }, + { + "offset": 40, + "length": 8, + "text": "delirium", + "category": "Diagnosis", + "confidenceScore": 0.99, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0011206" + }, + { + "dataSource": "AOD", + "id": "0000004328" + }, + { + "dataSource": "CCPSS", + "id": "1017884" + }, + { + "dataSource": "CHV", + "id": "0000003670" + }, + { + "dataSource": "COSTAR", + "id": "U000178" + }, + { + "dataSource": "CSP", + "id": "5003-0016" + }, + { + "dataSource": "CST", + "id": "DELIRIUM" + }, + { + "dataSource": "DSM-5", + "id": "780.09" + }, + { + "dataSource": "DXP", + "id": "U000937" + }, + { + "dataSource": "HPO", + "id": "HP:0031258" + }, + { + "dataSource": "ICD10", + "id": "F05.9" + }, + { + "dataSource": "ICD10AM", + "id": "F05.9" + }, + { + "dataSource": "ICD10CM", + "id": "R41.0" + }, + { + "dataSource": "ICNP", + "id": "10022091" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU022150" + }, + { + "dataSource": "LCH", + "id": "U001289" + }, + { + "dataSource": "LCH_NW", + "id": "sh85036579" + }, + { + "dataSource": "LNC", + "id": "LP89856-6" + }, + { + "dataSource": "MDR", + "id": "10012218" + }, + { + "dataSource": "MEDCIN", + "id": "677" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "5562" + }, + { + "dataSource": "MSH", + "id": "D003693" + }, + { + "dataSource": "NANDA-I", + "id": "02157" + }, + { + "dataSource": "NCI", + "id": "C2981" + }, + { + "dataSource": "NCI_CTCAE", + "id": "E12898" + }, + { + "dataSource": "NCI_CTRP", + "id": "C2981" + }, + { + "dataSource": "NCI_NCI-GLOSS", + "id": "CDR0000450100" + }, + { + "dataSource": "NCI_NICHD", + "id": "C2981" + }, + { + "dataSource": "NOC", + "id": "091213" + }, + { + "dataSource": "OMIM", + "id": "MTHU035152" + }, + { + "dataSource": "PDQ", + "id": "CDR0000042226" + }, + { + "dataSource": "PSY", + "id": "13360" + }, + { + "dataSource": "QMR", + "id": "Q0200089" + }, + { + "dataSource": "RCD", + "id": "XE1Xv" + }, + { + "dataSource": "SNM", + "id": "F-85720" + }, + { + "dataSource": "SNMI", + "id": "D9-20100" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "2776000" + }, + { + "dataSource": "WHO", + "id": "0099" + } + ] + }, + { + "offset": 50, + "length": 5, + "text": "panic", + "category": "Diagnosis", + "confidenceScore": 0.89, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0030318" + }, + { + "dataSource": "AOD", + "id": "0000023911" + }, + { + "dataSource": "CHV", + "id": "0000009234" + }, + { + "dataSource": "CST", + "id": "AGITATION" + }, + { + "dataSource": "ICD10CM", + "id": "F41.0" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU057222" + }, + { + "dataSource": "LCH", + "id": "U003458" + }, + { + "dataSource": "LCH_NW", + "id": "sh85097438" + }, + { + "dataSource": "MDR", + "id": "10033670" + }, + { + "dataSource": "MSH", + "id": "D010200" + }, + { + "dataSource": "MTH", + "id": "551" + }, + { + "dataSource": "MTHICD9", + "id": "300.01" + }, + { + "dataSource": "NCI", + "id": "C94438" + }, + { + "dataSource": "NCI_NCI-GLOSS", + "id": "CDR0000454704" + }, + { + "dataSource": "NOC", + "id": "121346" + }, + { + "dataSource": "PSY", + "id": "36260" + }, + { + "dataSource": "RCD", + "id": "Xa3Vj" + }, + { + "dataSource": "SNM", + "id": "F-90880" + }, + { + "dataSource": "SNMI", + "id": "F-92560" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "79823003" + }, + { + "dataSource": "WHO", + "id": "0163" + } + ] + }, + { + "offset": 57, + "length": 9, + "text": "psychosis", + "category": "Diagnosis", + "confidenceScore": 1.0, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0033975" + }, + { + "dataSource": "AIR", + "id": "PSYCH" + }, + { + "dataSource": "AOD", + "id": "0000004324" + }, + { + "dataSource": "BI", + "id": "BI00688" + }, + { + "dataSource": "CCPSS", + "id": "1018204" + }, + { + "dataSource": "CHV", + "id": "0000010350" + }, + { + "dataSource": "COSTAR", + "id": "089" + }, + { + "dataSource": "CSP", + "id": "2484-8182" + }, + { + "dataSource": "CST", + "id": "PSYCHOSIS" + }, + { + "dataSource": "DXP", + "id": "U003257" + }, + { + "dataSource": "HPO", + "id": "HP:0000709" + }, + { + "dataSource": "ICD9CM", + "id": "298.9" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU070382" + }, + { + "dataSource": "ICPC2P", + "id": "P98004" + }, + { + "dataSource": "LCH_NW", + "id": "sh85108502" + }, + { + "dataSource": "LNC", + "id": "LA7534-6" + }, + { + "dataSource": "MDR", + "id": "10061920" + }, + { + "dataSource": "MEDCIN", + "id": "364298" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "4180" + }, + { + "dataSource": "MSH", + "id": "D011618" + }, + { + "dataSource": "MTH", + "id": "089" + }, + { + "dataSource": "MTHICD9", + "id": "298.9" + }, + { + "dataSource": "NANDA-I", + "id": "03128" + }, + { + "dataSource": "NCI", + "id": "C78576" + }, + { + "dataSource": "NCI_CTCAE", + "id": "E12954" + }, + { + "dataSource": "NCI_NCI-GLOSS", + "id": "CDR0000450115" + }, + { + "dataSource": "NCI_NICHD", + "id": "C78576" + }, + { + "dataSource": "NOC", + "id": "061619" + }, + { + "dataSource": "OMIM", + "id": "MTHU002910" + }, + { + "dataSource": "PSY", + "id": "41910" + }, + { + "dataSource": "QMR", + "id": "Q0200208" + }, + { + "dataSource": "RCD", + "id": "X00S6" + }, + { + "dataSource": "SNM", + "id": "D-9200" + }, + { + "dataSource": "SNMI", + "id": "D9-72000" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "69322001" + }, + { + "dataSource": "WHO", + "id": "0193" + } + ] + }, + { + "offset": 72, + "length": 13, + "text": "heart failure", + "category": "Diagnosis", + "confidenceScore": 0.99, + "isNegated": false, + "links": [ + { + "dataSource": "UMLS", + "id": "C0018801" + }, + { + "dataSource": "AOD", + "id": "0000005308" + }, + { + "dataSource": "BI", + "id": "BI00019" + }, + { + "dataSource": "CCPSS", + "id": "0017571" + }, + { + "dataSource": "CCS", + "id": "7.2.11.2" + }, + { + "dataSource": "CCSR_10", + "id": "CIR019" + }, + { + "dataSource": "CHV", + "id": "0000005877" + }, + { + "dataSource": "COSTAR", + "id": "U000338" + }, + { + "dataSource": "CSP", + "id": "1393-3587" + }, + { + "dataSource": "CST", + "id": "HEART FAIL" + }, + { + "dataSource": "HPO", + "id": "HP:0001635" + }, + { + "dataSource": "ICD10", + "id": "I50.9" + }, + { + "dataSource": "ICD10AM", + "id": "I50.9" + }, + { + "dataSource": "ICD10CM", + "id": "I50.9" + }, + { + "dataSource": "ICD9CM", + "id": "428.9" + }, + { + "dataSource": "ICPC", + "id": "K77" + }, + { + "dataSource": "ICPC2EENG", + "id": "K77" + }, + { + "dataSource": "ICPC2ICD10ENG", + "id": "MTHU027668" + }, + { + "dataSource": "ICPC2P", + "id": "K77011" + }, + { + "dataSource": "LCH", + "id": "U005616" + }, + { + "dataSource": "LCH_NW", + "id": "sh85059745" + }, + { + "dataSource": "LNC", + "id": "LP269421-6" + }, + { + "dataSource": "MDR", + "id": "10007554" + }, + { + "dataSource": "MEDCIN", + "id": "95724" + }, + { + "dataSource": "MEDLINEPLUS", + "id": "199" + }, + { + "dataSource": "MSH", + "id": "D006333" + }, + { + "dataSource": "MTHICD9", + "id": "428.9" + }, + { + "dataSource": "NCI", + "id": "C50577" + }, + { + "dataSource": "NCI_CTCAE", + "id": "E10124" + }, + { + "dataSource": "NCI_FDA", + "id": "2206" + }, + { + "dataSource": "NCI_NICHD", + "id": "C50577" + }, + { + "dataSource": "OMIM", + "id": "MTHU009472" + }, + { + "dataSource": "RCD", + "id": "G58.." + }, + { + "dataSource": "SNM", + "id": "D-7050" + }, + { + "dataSource": "SNMI", + "id": "D3-16000" + }, + { + "dataSource": "SNOMEDCT_US", + "id": "84114007" + }, + { + "dataSource": "WHO", + "id": "0496" + } + ] + } + ], + "relations": [], + "warnings": [] } ], "errors": [], @@ -324,6 +1058,6 @@ "Variables": { "RandomSeed": "1184190609", "TEXT_ANALYTICS_API_KEY": "Sanitized", - "TEXT_ANALYTICS_ENDPOINT": "https://textanalytics-westeurope.ppe.cognitiveservices.azure.com" + "TEXT_ANALYTICS_ENDPOINT": "https://ta-s-westeurope.cognitiveservices.azure.com" } } \ No newline at end of file diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare.cs deleted file mode 100644 index d52bf20d34aa9..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; -using Azure.AI.TextAnalytics.Tests; -using Azure.Core.TestFramework; -using NUnit.Framework; - -namespace Azure.AI.TextAnalytics.Samples -{ - [LiveOnly] - public partial class TextAnalyticsSamples: SamplesBase - { - [Test] - public async Task Healthcare() - { - string endpoint = TestEnvironment.Endpoint; - string apiKey = TestEnvironment.ApiKey; - - var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); - - #region Snippet:RecognizeHealthcareEntities - 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."; - - AnalyzeHealthcareEntitiesOperation healthOperation = client.StartHealthcare(document); - - await healthOperation.WaitForCompletionAsync(); - - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; - - Console.WriteLine($"Results of Azure Text Analytics \"Healthcare\" 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(""); - } - } - - #endregion - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync.cs deleted file mode 100644 index 9b7da1b4a2d26..0000000000000 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; -using Azure.AI.TextAnalytics.Tests; -using Azure.Core.TestFramework; -using NUnit.Framework; - -namespace Azure.AI.TextAnalytics.Samples -{ - [LiveOnly] - public partial class TextAnalyticsSamples: SamplesBase - { - [Test] - public async Task HealthcareAsync() - { - string endpoint = TestEnvironment.Endpoint; - string apiKey = TestEnvironment.ApiKey; - - var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); - - #region Snippet:RecognizeHealthcareEntitiesAsync - 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."; - - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareAsync(document); - - await healthOperation.WaitForCompletionAsync(); - - 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(""); - } - } - - #endregion - } -} diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_AutomaticPolling.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_AutomaticPolling.cs index 7d345b2f8a6ec..3c475e4066903 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_AutomaticPolling.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_AutomaticPolling.cs @@ -2,9 +2,8 @@ // Licensed under the MIT License. using System; -using System.Linq; +using System.Collections.Generic; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -33,18 +32,18 @@ with a strong family history of coronary artery disease with a brother dying at 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."; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareAsync(document); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(new List() { document }); TimeSpan pollingInterval = new TimeSpan(1000); await healthOperation.WaitForCompletionAsync(pollingInterval); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -54,13 +53,12 @@ with a strong family history of coronary artery disease with a brother dying at 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine(""); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Cancellation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Cancellation.cs index f85701d6245d1..aaeef88e5aeaa 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Cancellation.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Cancellation.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -40,7 +39,7 @@ with a strong family history of coronary artery disease with a brother dying at batchDocument.Add(document); } - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareBatchAsync(batchDocument, "en"); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchDocument, "en"); await healthOperation.CancelAsync(); } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_ManualPolling.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_ManualPolling.cs index 9f748aae4eb39..39ffbe0763021 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_ManualPolling.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_ManualPolling.cs @@ -2,9 +2,8 @@ // Licensed under the MIT License. using System; -using System.Linq; +using System.Collections.Generic; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -33,7 +32,7 @@ with a strong family history of coronary artery disease with a brother dying at 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."; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareAsync(document); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(new List() { document }); TimeSpan pollingInterval = new TimeSpan(1000); @@ -48,12 +47,12 @@ with a strong family history of coronary artery disease with a brother dying at await Task.Delay(pollingInterval); } - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -63,13 +62,12 @@ with a strong family history of coronary artery disease with a brother dying at 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine(""); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Pagination.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Pagination.cs index 5187c3992c194..39ca46ec5fefa 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Pagination.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareAsync_Pagination.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Threading.Tasks; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; @@ -32,20 +31,20 @@ public async Task HealthcareAsyncPagination() list.Add(document); }; - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { Top = 2 }; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareBatchAsync(list, "en", options); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(list, "en", options); - AsyncPageable results = client.GetHealthcareEntities(healthOperation); + AsyncPageable results = client.GetHealthcareEntities(healthOperation); Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\""); Console.WriteLine(""); int resultCount = 0; - await foreach (DocumentHealthcareResult result in results) + await foreach (AnalyzeHealthcareEntitiesResult result in results) { resultCount += 1; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatch.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatch.cs index 2f524b2e8894d..1b69c8304bf1f 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatch.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatch.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -39,21 +38,21 @@ with a strong family history of coronary artery disease with a brother dying at document, }; - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { IncludeStatistics = true }; - AnalyzeHealthcareEntitiesOperation healthOperation = client.StartHealthcareBatch(batchInput, "en", options); + AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput, "en", options); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -63,19 +62,18 @@ with a strong family history of coronary artery disease with a brother dying at 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine($" Document statistics:"); - Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.Value.CharacterCount}"); - Console.WriteLine($" Transaction count: {result.Statistics.Value.TransactionCount}"); + Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}"); + Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}"); Console.WriteLine(""); } Console.WriteLine($"Request statistics:"); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchAsync.cs index 8cedfdf3b33b4..21ac7d445a528 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchAsync.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchAsync.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -40,23 +38,23 @@ with a strong family history of coronary artery disease with a brother dying at document, }; - HealthcareOptions options = new HealthcareOptions() + AnalyzeHealthcareEntitiesOptions options = new AnalyzeHealthcareEntitiesOptions() { Top = 1, Skip = 0, IncludeStatistics = true }; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareBatchAsync(batchInput, "en", options); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en", options); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -66,19 +64,18 @@ with a strong family history of coronary artery disease with a brother dying at 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine($" Document statistics:"); - Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.Value.CharacterCount}"); - Console.WriteLine($" Transaction count: {result.Statistics.Value.TransactionCount}"); + Console.WriteLine($" Character count (in Unicode graphemes): {result.Statistics.CharacterCount}"); + Console.WriteLine($" Transaction count: {result.Statistics.TransactionCount}"); Console.WriteLine(""); } Console.WriteLine($"Request statistics:"); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenience.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenience.cs index a1b437e93cf57..7a2fc45695f53 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenience.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenience.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -38,16 +37,16 @@ with a strong family history of coronary artery disease with a brother dying at document, }; - AnalyzeHealthcareEntitiesOperation healthOperation = client.StartHealthcareBatch(batchInput, "en"); + AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchInput, "en"); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -57,13 +56,12 @@ with a strong family history of coronary artery disease with a brother dying at 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine(""); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenienceAsync.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenienceAsync.cs index e5485636334f1..d30999df06e3a 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenienceAsync.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_HealthcareBatchConvenienceAsync.cs @@ -3,9 +3,7 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -39,16 +37,16 @@ with a strong family history of coronary artery disease with a brother dying at document, }; - AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartHealthcareBatchAsync(batchInput, "en"); + AnalyzeHealthcareEntitiesOperation healthOperation = await client.StartAnalyzeHealthcareEntitiesAsync(batchInput, "en"); await healthOperation.WaitForCompletionAsync(); - RecognizeHealthcareEntitiesResultCollection results = healthOperation.Value; + AnalyzeHealthcareEntitiesResultCollection results = healthOperation.Value; Console.WriteLine($"Results of Azure Text Analytics \"Healthcare Async\" Model, version: \"{results.ModelVersion}\""); Console.WriteLine(""); - foreach (DocumentHealthcareResult result in results) + foreach (AnalyzeHealthcareEntitiesResult result in results) { Console.WriteLine($" Recognized the following {result.Entities.Count} healthcare entities:"); @@ -58,13 +56,12 @@ with a strong family history of coronary artery disease with a brother dying at 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) + foreach (EntityDataSource entityDataSource in entity.DataSources) { - Console.WriteLine($" ID: {healthcareEntityLink.Id}"); - Console.WriteLine($" DataSource: {healthcareEntityLink.DataSource}"); + Console.WriteLine($" Entity ID in Data Source: {entityDataSource.EntityId}"); + Console.WriteLine($" DataSource: {entityDataSource.Name}"); } } Console.WriteLine(""); diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare_Cancellation.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare_Cancellation.cs index 74fd7b24d198f..137c6133ffd16 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare_Cancellation.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/samples/Sample_Healthcare_Cancellation.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; -using System.Threading.Tasks; -using Azure.AI.TextAnalytics.Models; using Azure.AI.TextAnalytics.Tests; using Azure.Core.TestFramework; using NUnit.Framework; @@ -40,7 +38,7 @@ with a strong family history of coronary artery disease with a brother dying at batchDocument.Add(document); } - AnalyzeHealthcareEntitiesOperation healthOperation = client.StartHealthcareBatch(batchDocument, "en"); + AnalyzeHealthcareEntitiesOperation healthOperation = client.StartAnalyzeHealthcareEntities(batchDocument, "en"); healthOperation.Cancel(); }