Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TA] Healthcare Design update #18200

Merged
merged 12 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions sdk/textanalytics/Azure.AI.TextAnalytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,12 @@ Text Analytics for health is a containerized service that extracts and labels re

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:");

Expand All @@ -441,13 +441,12 @@ 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($" ID: {entityDataSource.EntityId}");
Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
}
Console.WriteLine("");
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ To recognize healthcare entities in a document, use the `StarthealthcareAsyc` me

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:");

Expand All @@ -47,13 +47,12 @@ To recognize healthcare entities in a document, use the `StarthealthcareAsyc` me
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($" ID: {entityDataSource.EntityId}");
Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
}
Console.WriteLine("");
Expand Down Expand Up @@ -85,12 +84,12 @@ To recognize healthcare entities in multiple documents, call `StartHealthcareBat

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:");

Expand All @@ -100,13 +99,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($" ID: {entityDataSource.EntityId}");
Console.WriteLine($" DataSource: {entityDataSource.Name}");
}
}
Console.WriteLine("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Azure.AI.TextAnalytics
{
/// <summary> The AnalyzeHealthcareEntitiesOperation class for LRO. </summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you thinking on having a separate PR to improve the docstrings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what should be the docstrings, are there any guidelines around it? can you provide some example doc strings?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly I don't think there are any guidelines for it, but think of it as the way to explain to a user what each class, property, method is about.
You could use the docstring in other endpoints or libraries as guidance

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. is a user reads The AnalyzeHealthcareEntitiesOperation class for LRO. it actually doesn't mean anything for them. What is LRO? and what is the purpose of this class?
something like
Tracks the status of a long-running operation that analyze the healthcare entities from the given documents. or something along those lines

public class AnalyzeHealthcareEntitiesOperation : Operation<RecognizeHealthcareEntitiesResultCollection>
public class AnalyzeHealthcareEntitiesOperation : Operation<AnalyzeHealthcareEntitiesResultCollection>
{
/// <summary>Provides communication with the Text Analytics Azure Cognitive Service through its REST API.</summary>
private readonly TextAnalyticsRestClient _serviceClient;
Expand All @@ -35,6 +35,21 @@ public class AnalyzeHealthcareEntitiesOperation : Operation<RecognizeHealthcareE
/// </summary>
public override string Id { get; }

/// <summary>
/// CreatedOn
/// </summary>
public DateTimeOffset CreatedOn { get; }

/// <summary>
/// ExpiresOn
/// </summary>
public DateTimeOffset ExpiresOn { get; }

/// <summary>
/// LastModified
/// </summary>
public DateTimeOffset LastModified { get; }

/// <summary>
/// Gets the status of the operation.
/// </summary>
Expand All @@ -51,7 +66,7 @@ public class AnalyzeHealthcareEntitiesOperation : Operation<RecognizeHealthcareE
/// <remarks>
/// This property can be accessed only after the operation completes successfully (HasValue is true).
/// </remarks>
public override RecognizeHealthcareEntitiesResultCollection Value
public override AnalyzeHealthcareEntitiesResultCollection Value
{
get
{
Expand Down Expand Up @@ -80,7 +95,7 @@ public override RecognizeHealthcareEntitiesResultCollection Value
private Response _response;

/// <summary>The result of the long-running operation. <c>null</c> until result is received on status update.</summary>
private RecognizeHealthcareEntitiesResultCollection _value;
private AnalyzeHealthcareEntitiesResultCollection _value;

private int? _top { get; }
private int? _skip { get; }
Expand Down Expand Up @@ -169,7 +184,7 @@ public override async ValueTask<Response> UpdateStatusAsync(CancellationToken ca
/// <remarks>
/// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation.
/// </remarks>
public override ValueTask<Response<RecognizeHealthcareEntitiesResultCollection>> WaitForCompletionAsync(CancellationToken cancellationToken = default) =>
public override ValueTask<Response<AnalyzeHealthcareEntitiesResultCollection>> WaitForCompletionAsync(CancellationToken cancellationToken = default) =>
this.DefaultWaitForCompletionAsync(cancellationToken);

/// <summary>
Expand All @@ -185,7 +200,7 @@ public override ValueTask<Response<RecognizeHealthcareEntitiesResultCollection>>
/// <remarks>
/// This method will periodically call UpdateStatusAsync till HasCompleted is true, then return the final result of the operation.
/// </remarks>
public override ValueTask<Response<RecognizeHealthcareEntitiesResultCollection>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) =>
public override ValueTask<Response<AnalyzeHealthcareEntitiesResultCollection>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) =>
this.DefaultWaitForCompletionAsync(pollingInterval, cancellationToken);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public class HealthcareOptions : TextAnalyticsRequestOptions
public class AnalyzeHealthcareEntitiesOptions : TextAnalyticsRequestOptions
{
/// <summary>
/// Initializes a new instance of the <see cref="HealthcareOptions"/>
/// Initializes a new instance of the <see cref="AnalyzeHealthcareEntitiesOptions"/>
/// class.
/// </summary>
public HealthcareOptions()
public AnalyzeHealthcareEntitiesOptions()
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using Azure.AI.TextAnalytics.Models;

namespace Azure.AI.TextAnalytics
{
/// <summary>
/// DocumentHealthcareEntities.
/// </summary>
public partial class AnalyzeHealthcareEntitiesResult : TextAnalyticsResult
{
internal AnalyzeHealthcareEntitiesResult(string id, TextDocumentStatistics statistics,
IReadOnlyList<HealthcareEntityInternal> healthcareEntities,
IReadOnlyList<HealthcareRelationInternal> healthcareRelations,
IReadOnlyList<TextAnalyticsWarningInternal> warnings)
: base(id, statistics)
{
Entities = Transforms.ConvertToHealthcareEntityCollection(healthcareEntities, healthcareRelations);
Warnings = Transforms.ConvertToWarnings(warnings);
}

internal AnalyzeHealthcareEntitiesResult(string id, TextAnalyticsError error) : base(id, error) { }

/// <summary> Healthcare entities. </summary>
public IReadOnlyCollection<HealthcareEntity> Entities { get; }

/// <summary> Warnings encountered while processing document. </summary>
public IReadOnlyList<TextAnalyticsWarning> Warnings { get; } = new List<TextAnalyticsWarning>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@

using System.Collections.Generic;
using System.Collections.ObjectModel;
using Azure.AI.TextAnalytics.Models;

namespace Azure.AI.TextAnalytics
{
/// <summary>
/// Collection of <see cref="DocumentHealthcareResult"/> objects corresponding
/// Collection of <see cref="AnalyzeHealthcareEntitiesResult"/> objects corresponding
/// to a batch of documents, and information about the batch operation.
/// </summary>
public class RecognizeHealthcareEntitiesResultCollection : ReadOnlyCollection<DocumentHealthcareResult>
public class AnalyzeHealthcareEntitiesResultCollection : ReadOnlyCollection<AnalyzeHealthcareEntitiesResult>
{
/// <summary>
/// </summary>
/// <param name="list"></param>
/// <param name="statistics"></param>
/// <param name="modelVersion"></param>
internal RecognizeHealthcareEntitiesResultCollection(IList<DocumentHealthcareResult> list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list)
internal AnalyzeHealthcareEntitiesResultCollection(IList<AnalyzeHealthcareEntitiesResult> list, TextDocumentBatchStatistics statistics, string modelVersion) : base(list)
{
Statistics = statistics;
ModelVersion = modelVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal partial class DocumentHealthcareEntitiesInternal
/// <summary> Unique, non-empty document identifier. </summary>
public string Id { get; }
/// <summary> Healthcare entities. </summary>
public IReadOnlyList<HealthcareEntity> Entities { get; }
public IReadOnlyList<HealthcareEntityInternal> Entities { get; }
/// <summary> Healthcare entity relations. </summary>
public IReadOnlyList<HealthcareRelationInternal> Relations { get; }
/// <summary> Warnings encountered while processing document. </summary>
Expand Down

This file was deleted.

22 changes: 22 additions & 0 deletions sdk/textanalytics/Azure.AI.TextAnalytics/src/EntityDataSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Azure.Core;

namespace Azure.AI.TextAnalytics
{
/// <summary>
/// HealthcareEntityLink.
/// </summary>
[CodeGenModel("HealthcareEntityLink")]
public partial class EntityDataSource
{
/// <summary> Entity id in the given source catalog. </summary>
[CodeGenMember("Id")]
public string EntityId { get; }

/// <summary> Entity Catalog. Examples include: UMLS, CHV, MSH, etc. </summary>
[CodeGenMember("DataSource")]
public string Name { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading