Skip to content

Commit

Permalink
[Azure AI - Health Insights] - Typespec revision for Health Insights …
Browse files Browse the repository at this point in the history
…API V3 (Radiology Insights) (Azure#27614)

* V3 - remove OncoPhenotype, TrialMatcher, PatientTimeline interfaces

* update readme file

* remove client.tsp from all models except RadiologyInsights

* Revert "remove client.tsp from all models except RadiologyInsights"

This reverts commit b238f6f.

* revert and return client.tsp files

* remove version dependency, also remove all other models except RI

* Fix: request example

* prettier

* remove model RadiologyInsightsResult

* remove deprecated operation templates

* move imports to main.tsp

* add imports to rout.radiologyinsights

* revert - remove imports from rout file

* rename patientInfo

* add expand trait

* update example with details property

* add imports to rout.radiologyinsights

* fix: API Stewardship board review comments

* fix: tsv

* prettier

* communication.communicatedAt , recommendation.effectiveAt

* expand format csv

* comments

* fix: tsv

* remove unused client.tsp

* update spec

* python package version

* spread extensions

* remove retry-after from put operation

* Update specification/ai/data-plane/HealthInsights/readme.md

Co-authored-by: Praven Kuttappan <[email protected]>

* Update specification/ai/data-plane/HealthInsights/readme.md

Co-authored-by: Praven Kuttappan <[email protected]>

* Update specification/ai/data-plane/HealthInsights/readme.md

Co-authored-by: Praven Kuttappan <[email protected]>

* Update specification/ai/data-plane/HealthInsights/readme.md

Co-authored-by: Praven Kuttappan <[email protected]>

* update readme package version

* add x-ms-request-id to default error response

* fix: tsv

* use Azure.Core.ExpandQueryParameter

* fix: tsv

* order procedure spread extendible

* fix: tsv

* remove tspconfig files from Onco,PTL,CTM

* update openapi.json

* fix: PUT/GET same schema

* fix: PR comments

* alias retry after traits

* revert interface rout(radiology-insights)

---------

Co-authored-by: Praven Kuttappan <[email protected]>
  • Loading branch information
2 people authored and wiboris committed May 7, 2024
1 parent cf663cd commit 4ce9241
Show file tree
Hide file tree
Showing 25 changed files with 70,336 additions and 585 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ A given identifier for the patient. Has to be unique across all patients in a si
@doc("""
Patient structured information, including demographics and known structured clinical information.
""")
info?: PatientInfo;
details?: PatientDetails;

@doc("Patient encounters/visits.")
encounters?: Array<Encounter>;
encounters?: Array<PatientEncounter>;

@doc("Patient unstructured clinical data, given as documents.")
patientDocuments?: Array<PatientDocument>;
}

@doc("Patient structured information, including demographics and known structured clinical information.")
model PatientInfo {
model PatientDetails {
@doc("The patient's sex.")
sex?: PatientInfoSex;
sex?: PatientSex;

@doc("The patient's date of birth.")
birthDate?: plainDate;
Expand All @@ -53,7 +53,7 @@ model PatientInfo {

#suppress "@azure-tools/typespec-azure-core/documentation-required" "MUST fix in next update"
@doc("The patient's sex.")
union PatientInfoSex {
union PatientSex {
string,
Female: "female",
Male: "male",
Expand Down Expand Up @@ -116,9 +116,10 @@ model PatientDocument {
language?: string;

@doc("The date and time when the document was created.")
createdDateTime?: utcDateTime;
createdAt?: utcDateTime;

@doc("Document author(s)")
@minItems(1)
authors?: Array<DocumentAuthor>;

@doc("specialty type the document")
Expand All @@ -142,8 +143,9 @@ model DocumentAdministrativeMetadata {
}

@doc("visit/encounter information")
model Encounter {
model PatientEncounter {
@doc("The id of the visit.")
@minLength(1)
id: string;

@doc("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,6 @@ using TypeSpec.Rest;

namespace AzureHealthInsights;

/**
* Provides status details for long running operations.
* @template TStatusResult The type of the operation status result.
* @template TStatusError The type of the operation status error. If not provided, the default error is used.
*/
@doc("Provides status details for long running operations.")
model HealthInsightsOperationStatus<
TStatusResult = never,
TStatusError = Foundations.Error
> {
@key("operationId")
@doc("The unique ID of the operation.")
@visibility("read")
id: Azure.Core.uuid;

@doc("The status of the operation")
@visibility("read")
@lroStatus
status: JobStatus;

@doc("The date and time when the processing job was created.")
@visibility("read")
createdDateTime?: utcDateTime;

@doc("The date and time when the processing job is set to expire.")
@visibility("read")
expirationDateTime?: utcDateTime;

@doc("The date and time when the processing job was last updated.")
@visibility("read")
lastUpdateDateTime?: utcDateTime;

@doc("Error object that describes the error when status is \"Failed\".")
error?: TStatusError;

@doc("The result of the operation.")
@lroResult
result?: TStatusResult;
}
////////////////// Inference //////////////////
@doc("An inference made by the model regarding a patient.")
model Inference {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
using TypeSpec.Http;
using TypeSpec.Rest;
using Azure.Core;

namespace AzureHealthInsights;

@doc("Provides status details for long running operations.")
model HealthInsightsJobBase {
@key("id")
@doc("The unique ID of the job.")
@visibility("read")
@maxLength(36)
@minLength(3)
@pattern("^[a-zA-Z0-9][a-zA-Z0-9-_]+[a-zA-Z0-9]$")
id: string;

@doc("The status of the job.")
@visibility("read")
@lroStatus
status: JobStatus;

@doc("The date and time when the processing job was created.")
@visibility("read")
createdAt?: utcDateTime;

@doc("The date and time when the processing job is set to expire.")
@visibility("read")
expiresAt?: utcDateTime;

@doc("The date and time when the processing job was last updated.")
@visibility("read")
updatedAt?: utcDateTime;

@doc("Error object that describes the error when status is \"Failed\".")
@visibility("read")
error?: Foundations.Error;
}

@doc("ConditionStage")
model ConditionStage {
@doc("""
Expand Down Expand Up @@ -143,32 +177,6 @@ union VerificationStatusType {
EnteredInError: "enteredInError",
}

// @doc("""
// ClinicalStatusType based on FHIR ValueSet condition-clinical.
// See: https://terminology.hl7.org/5.1.0/CodeSystem-condition-clinical.html
// """)
// union ClinicalStatusType {
// string,
//
// @doc("The subject is currently experiencing the condition or situation, there is evidence of the condition or situation, or considered to be a significant risk.")
// Active: "active";
// @doc("The subject is experiencing a reoccurrence or repeating of a previously resolved condition or situation, e.g. urinary tract infection, food insecurity.")
// Recurrence: "recurrence";
// @doc("The subject is experiencing a return of a condition or situation after a period of improvement or remission, e.g. relapse of cancer, alcoholism.")
// Relapse: "relapse";
// @doc("The subject is no longer experiencing the condition or situation and there is no longer evidence or appreciable risk of the condition or situation.")
// Inactive: "inactive";
// @doc("The subject is not presently experiencing the condition or situation, but there is a risk of the condition or situation returning.")
// Remission: "remission";
// @doc("The subject is not presently experiencing the condition or situation and there is a negligible perceived risk of the condition or situation returning.")
// Resolved: "resolved";
// @doc("""
// The authoring/source system does not know which of the status values currently applies for this condition.
// Note: This concept is not to be used for 'other' - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.
// """)
// Unknown: "unknown";
// }

@doc("""
A location given as a combination of city, state and country/region. It could specify a city, a state or a country/region.
In case a city is specified, either state +country/region or country/region (for countries/regions where there are no states) should be added.
Expand All @@ -195,12 +203,14 @@ model TimePeriod {
}

@doc("Procedure information")
model OrderedProcedure is Fhir.R4.Extendible {
model OrderedProcedure {
@doc("Procedure code")
code?: Fhir.R4.CodeableConcept;

@doc("Procedure description")
description?: string;

...Fhir.R4.Extendible;
}

@doc("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,39 @@ using Azure.Core.Traits;

namespace AzureHealthInsights;

#suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "This is a template"
@doc("Long running RPC operation template")
op HealthInsightsLongRunningRpcOperation<
TParams extends TypeSpec.Reflection.Model,
TResponse extends TypeSpec.Reflection.Model,
TModelResult extends TypeSpec.Reflection.Model,
Traits extends TypeSpec.Reflection.Model = {}
> is Azure.Core.RpcOperation<
TParams & RepeatabilityRequestHeaders,
Foundations.AcceptedResponse<HealthInsightsLongRunningStatusLocation<TResponse> &
Foundations.RetryAfterHeader> &
RepeatabilityResponseHeaders &
HealthInsightsOperationStatus<TModelResult>,
Traits
alias HealthInsightsRetryAfterTrait = ResponseHeadersTrait<
Foundations.RetryAfterHeader,
TraitContext.Read
>;

#suppress "@azure-tools/typespec-azure-core/long-running-polling-operation-required" "This is a template"
@doc("Long running Pool operation template")
op HealthInsightsLongRunningPollOperation<TResult extends TypeSpec.Reflection.Model> is Azure.Core.RpcOperation<
{
@doc("A processing job identifier.")
@path("id")
id: Azure.Core.uuid;
},
TResult,
HealthInsightsRetryAfterTrait
>;

/**
* Metadata for long running operation status monitor locations.
* @template TStatusResult The type of the operation status result.
*/
@doc("Metadata for long running operation status monitor locations")
model HealthInsightsLongRunningStatusLocation<TStatusResult = never> {
@pollingLocation
@doc("The location for monitoring the operation state.")
@TypeSpec.Http.header("Operation-Location")
operationLocation: HealthInsightsResourceLocation<HealthInsightsOperationStatus<TStatusResult>>;
// Note: I cannot use the following alias because of a bug in the compiler
// Using it return: "error intersect-duplicate-property: Intersection contains duplicate property definitions for responseHeaders"
// I can't use it like that: ResponseHeadersTrait<RequestIdResponseHeader & Foundations.RetryAfterHeader>;
// because then both traits will get the same context which is not the desired behavior.
// alias RequestIdResponseHeaderTrait = ResponseHeadersTrait<RequestIdResponseHeader>;
/////////////////////
@doc("Provides the 'x-ms-request-id' header to enable request correlation in responses.")
@trait("RequestIdResponseHeader")
model RequestIdResponseHeaderTrait {
@doc("An opaque, globally-unique, server-generated string identifier for the request.")
requestId: {
@traitLocation(TraitLocation.Response)
response: RequestIdResponseHeader;
};
}

/**
* A URL that points to a resource.
* @template TResource The type of resource that the URL points to.
*/
@doc("The location of an instance of {name}", TResource)
scalar HealthInsightsResourceLocation<TResource extends {}> extends url;
alias ServiceTraits = NoRepeatableRequests &
NoConditionalRequests &
NoClientRequestId &
HealthInsightsRetryAfterTrait &
RequestIdResponseHeaderTrait &
QueryParametersTrait<Azure.Core.ExpandQueryParameter>;

@trait("HealthInsightsRetryAfterTrait")
@doc("Health Insights retry after trait")
model HealthInsightsRetryAfterTrait {
@doc("The retry-after header.")
retryAfter: {
@traitLocation(TraitLocation.Response)
response: Foundations.RetryAfterHeader;
};
model HealthInsightsErrorResponse is Azure.Core.Foundations.ErrorResponse {
...RequestIdResponseHeaderTrait;
}

alias HealthInsightsOperations = ResourceOperations<
ServiceTraits,
HealthInsightsErrorResponse
>;

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using TypeSpec.Http;

namespace AzureHealthInsights;

@TypeSpec.Versioning.removed(AzureHealthInsights.ApiVersion.v2024_04_01)
interface OncoPhenotype {
#suppress "@azure-tools/typespec-azure-core/no-rpc-path-params" "Service uses a jobId in the path"
@summary("Get Onco Phenotype job details")
Expand Down
Loading

0 comments on commit 4ce9241

Please sign in to comment.