From d59a1999f2d1a05070d68317d6ceb99f1f14590a Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 27 Sep 2024 03:33:25 +0000 Subject: [PATCH] CodeGen from PR 30768 in Azure/azure-rest-api-specs Merge f857628ff2d7bfaaefb117ed52ddcd5f082fdad0 into 139840784c38414085b3d799cee5545f9b6e8dec --- .../LICENSE | 21 + .../README.md | 57 + .../api-extractor.json | 31 + .../eslint.config.mjs | 17 + .../package.json | 111 ++ .../src/azureHealthInsightsClient.ts | 76 ++ .../src/clientDefinitions.ts | 34 + .../src/index.ts | 16 + .../src/isUnexpected.ts | 118 ++ .../src/logger.ts | 5 + .../src/models.ts | 1016 ++++++++++++++++ .../src/outputModels.ts | 1045 +++++++++++++++++ .../src/parameters.ts | 34 + .../src/pollingHelper.ts | 221 ++++ .../src/responses.ts | 83 ++ .../src/serializeHelper.ts | 16 + .../test/public/sampleTest.spec.ts | 21 + .../test/public/utils/recordedClient.ts | 29 + .../tsconfig.browser.config.json | 10 + .../tsconfig.json | 16 + .../tsp-location.yaml | 6 + .../vitest.browser.config.ts | 37 + .../vitest.config.ts | 33 + 23 files changed, 3053 insertions(+) create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/LICENSE create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/README.md create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/api-extractor.json create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/eslint.config.mjs create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/package.json create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/azureHealthInsightsClient.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/clientDefinitions.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/index.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/isUnexpected.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/logger.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/models.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/outputModels.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/parameters.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/pollingHelper.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/responses.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/serializeHelper.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/sampleTest.spec.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/utils/recordedClient.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.browser.config.json create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.json create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsp-location.yaml create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.browser.config.ts create mode 100644 sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.config.ts diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/LICENSE b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/LICENSE new file mode 100644 index 000000000000..7d5934740965 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/README.md b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/README.md new file mode 100644 index 000000000000..c211bccae03b --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/README.md @@ -0,0 +1,57 @@ +# AzureHealthInsights REST client library for JavaScript + +Azure AI Health Insights provides an API that serves insight models, specific for Health & Life Sciences, that perform analysis and provide inferences to be used by a human. + +**Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library** + +Key links: + +- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/health-insights-radiologyinsights) +- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/health-insights-radiologyinsights?view=azure-node-preview) + +## Getting started + +### Currently supported environments + +- LTS versions of Node.js + +### Prerequisites + +- You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package. + +### Install the `@azure-rest/health-insights-radiologyinsights` package + +Install the AzureHealthInsights REST client REST client library for JavaScript with `npm`: + +```bash +npm install @azure-rest/health-insights-radiologyinsights +``` + +### Create and authenticate a `AzureHealthInsightsClient` + +To use an [Azure Active Directory (AAD) token credential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token), +provide an instance of the desired credential type obtained from the +[@azure/identity](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) library. + +To authenticate with AAD, you must first `npm` install [`@azure/identity`](https://www.npmjs.com/package/@azure/identity) + +After setup, you can choose which type of [credential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials) from `@azure/identity` to use. +As an example, [DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) +can be used to authenticate the client. + +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: +AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET + +## Troubleshooting + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`: + +```javascript +const { setLogLevel } = require("@azure/logger"); + +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/api-extractor.json b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/api-extractor.json new file mode 100644 index 000000000000..31b2add8f571 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "mainEntryPointFilePath": "./dist/esm/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, + "dtsRollup": { + "enabled": true, + "untrimmedFilePath": "", + "publicTrimmedFilePath": "./types/health-insights-radiologyinsights.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} \ No newline at end of file diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/eslint.config.mjs b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/eslint.config.mjs new file mode 100644 index 000000000000..113bdc3eaf5f --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/eslint.config.mjs @@ -0,0 +1,17 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default [ + ...azsdkEslint.configs.recommended, + { + rules: { + "@azure/azure-sdk/ts-modules-only-named": "warn", + "@azure/azure-sdk/ts-apiextractor-json-types": "warn", + "@azure/azure-sdk/ts-package-json-types": "warn", + "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", + "@azure/azure-sdk/ts-package-json-module": "off", + "@azure/azure-sdk/ts-package-json-files-required": "off", + "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", + "tsdoc/syntax": "warn" + } + } +]; diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/package.json b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/package.json new file mode 100644 index 000000000000..fb4813d5f223 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/package.json @@ -0,0 +1,111 @@ +{ + "name": "@azure-rest/health-insights-radiologyinsights", + "version": "1.0.0-beta.1", + "description": "A generated SDK for AzureHealthInsightsClient.", + "engines": { + "node": ">=18.0.0" + }, + "sideEffects": false, + "autoPublish": false, + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false + }, + "type": "module", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "files": [ + "dist", + "README.md", + "LICENSE", + "review/*", + "CHANGELOG.md" + ], + "sdk-type": "client", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "//metadata": { + "constantPaths": [ + { + "path": "src/azureHealthInsightsClient.ts", + "prefix": "userAgentInfo" + } + ] + }, + "dependencies": { + "@azure-rest/core-client": "^2.1.0", + "@azure/core-auth": "^1.6.0", + "@azure/core-rest-pipeline": "^1.5.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.6.2", + "@azure/core-lro": "^3.0.0", + "@azure/abort-controller": "^2.1.2" + }, + "devDependencies": { + "dotenv": "^16.0.0", + "@microsoft/api-extractor": "^7.40.3", + "@types/node": "^18.0.0", + "eslint": "^8.55.0", + "prettier": "^3.2.5", + "rimraf": "^5.0.5", + "mkdirp": "^3.0.1", + "typescript": "~5.5.3", + "tshy": "^1.11.1", + "@azure/identity": "^4.2.1", + "@vitest/browser": "^2.0.5", + "@vitest/coverage-istanbul": "^2.0.5", + "playwright": "^1.41.2", + "vitest": "^2.0.5", + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.0.0", + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0" + }, + "scripts": { + "clean": "rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "extract-api": "rimraf review && mkdirp ./review && dev-tool run extract-api", + "pack": "npm pack 2>&1", + "lint": "eslint package.json api-extractor.json src test", + "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", + "unit-test:node": "dev-tool run test:vitest", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:samples": "echo skipped", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", + "execute:samples": "echo skipped", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", + "generate:client": "echo skipped", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", + "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", + "build:test": "npm run clean && tshy && dev-tool run build-test", + "build": "npm run clean && tshy && mkdirp ./review && dev-tool run extract-api", + "test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node", + "test": "npm run clean && tshy && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test" + } +} \ No newline at end of file diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/azureHealthInsightsClient.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/azureHealthInsightsClient.ts new file mode 100644 index 000000000000..bde66ed42d92 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/azureHealthInsightsClient.ts @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { getClient, ClientOptions } from "@azure-rest/core-client"; +import { logger } from "./logger.js"; +import { TokenCredential, KeyCredential } from "@azure/core-auth"; +import { AzureHealthInsightsClient } from "./clientDefinitions.js"; + +/** The optional parameters for the client */ +export interface AzureHealthInsightsClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} + +/** + * Initialize a new instance of `AzureHealthInsightsClient` + * @param endpointParam - Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export default function createClient( + endpointParam: string, + credentials: TokenCredential | KeyCredential, + { + apiVersion = "2024-04-01", + ...options + }: AzureHealthInsightsClientOptions = {}, +): AzureHealthInsightsClient { + const endpointUrl = + options.endpoint ?? options.baseUrl ?? `${endpointParam}/health-insights`; + const userAgentInfo = `azsdk-js-health-insights-radiologyinsights-rest/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; + options = { + ...options, + userAgentOptions: { + userAgentPrefix, + }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, + credentials: { + scopes: options.credentials?.scopes ?? [ + "https://cognitiveservices.azure.com/.default", + ], + apiKeyHeaderName: + options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key", + }, + }; + const client = getClient( + endpointUrl, + credentials, + options, + ) as AzureHealthInsightsClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + + return client; +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/clientDefinitions.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/clientDefinitions.ts new file mode 100644 index 000000000000..18f89514a7d6 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/clientDefinitions.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { GetJobParameters, CreateJobParameters } from "./parameters.js"; +import { + GetJob200Response, + GetJobDefaultResponse, + CreateJob200Response, + CreateJob201Response, + CreateJobDefaultResponse, +} from "./responses.js"; +import { Client, StreamableMethod } from "@azure-rest/core-client"; + +export interface GetJob { + /** Gets the status and details of the Radiology Insights job. */ + get( + options?: GetJobParameters, + ): StreamableMethod; + /** Creates a Radiology Insights job with the given request body. */ + put( + options: CreateJobParameters, + ): StreamableMethod< + CreateJob200Response | CreateJob201Response | CreateJobDefaultResponse + >; +} + +export interface Routes { + /** Resource for '/radiology-insights/jobs/\{id\}' has methods for the following verbs: get, put */ + (path: "/radiology-insights/jobs/{id}", id: string): GetJob; +} + +export type AzureHealthInsightsClient = Client & { + path: Routes; +}; diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/index.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/index.ts new file mode 100644 index 000000000000..d1325c813534 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/index.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import AzureHealthInsightsClient from "./azureHealthInsightsClient.js"; + +export * from "./azureHealthInsightsClient.js"; +export * from "./parameters.js"; +export * from "./responses.js"; +export * from "./clientDefinitions.js"; +export * from "./isUnexpected.js"; +export * from "./models.js"; +export * from "./outputModels.js"; +export * from "./pollingHelper.js"; +export * from "./serializeHelper.js"; + +export default AzureHealthInsightsClient; diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/isUnexpected.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/isUnexpected.ts new file mode 100644 index 000000000000..d597c4547a3b --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/isUnexpected.ts @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + GetJob200Response, + GetJobDefaultResponse, + CreateJob200Response, + CreateJob201Response, + CreateJobLogicalResponse, + CreateJobDefaultResponse, +} from "./responses.js"; + +const responseMap: Record = { + "GET /radiology-insights/jobs/{id}": ["200"], + "PUT /radiology-insights/jobs/{id}": ["200", "201"], +}; + +export function isUnexpected( + response: GetJob200Response | GetJobDefaultResponse, +): response is GetJobDefaultResponse; +export function isUnexpected( + response: + | CreateJob200Response + | CreateJob201Response + | CreateJobLogicalResponse + | CreateJobDefaultResponse, +): response is CreateJobDefaultResponse; +export function isUnexpected( + response: + | GetJob200Response + | GetJobDefaultResponse + | CreateJob200Response + | CreateJob201Response + | CreateJobLogicalResponse + | CreateJobDefaultResponse, +): response is GetJobDefaultResponse | CreateJobDefaultResponse { + const lroOriginal = response.headers["x-ms-original-url"]; + const url = new URL(lroOriginal ?? response.request.url); + const method = response.request.method; + let pathDetails = responseMap[`${method} ${url.pathname}`]; + if (!pathDetails) { + pathDetails = getParametrizedPathSuccess(method, url.pathname); + } + return !pathDetails.includes(response.status); +} + +function getParametrizedPathSuccess(method: string, path: string): string[] { + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(responseMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/logger.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/logger.ts new file mode 100644 index 000000000000..8ea654a5fde2 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("health-insights-radiologyinsights"); diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/models.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/models.ts new file mode 100644 index 000000000000..6d969e1f7fa5 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/models.ts @@ -0,0 +1,1016 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Contains the list of patients, and configuration data. */ +export interface RadiologyInsightsData { + /** The list of patients, including their clinical information and data. */ + patients: Array; + /** Configuration affecting the Radiology Insights model's inference. */ + configuration?: RadiologyInsightsModelConfiguration; +} + +/** A patient record, including their clinical information and data. */ +export interface PatientRecord { + /** A given identifier for the patient. Has to be unique across all patients in a single request. */ + id: string; + /** Patient structured information, including demographics and known structured clinical information. */ + details?: PatientDetails; + /** Patient encounters/visits. */ + encounters?: Array; + /** Patient unstructured clinical data, given as documents. */ + patientDocuments?: Array; +} + +/** Patient structured information, including demographics and known structured clinical information. */ +export interface PatientDetails { + /** + * The patient's sex. + * + * Possible values: "female", "male", "unspecified" + */ + sex?: PatientSex; + /** The patient's date of birth. */ + birthDate?: string; + /** Known clinical information for the patient, structured. */ + clinicalInfo?: Array; +} + +/** + * Resource is the ancestor of DomainResource from which most resources are derived. Bundle, Parameters, and Binary extend Resource directly. + * Based on [FHIR Resource](https://www.hl7.org/fhir/r4/resource.html + */ +export interface Resource extends Record { + /** The type of resource */ + resourceType: string; + /** Resource Id */ + id?: string; + /** Metadata about the resource */ + meta?: Meta; + /** A set of rules under which this content was created */ + implicitRules?: string; + /** Language of the resource content */ + language?: string; +} + +/** + * Metadata about a resource + * Based on [FHIR Meta](https://www.hl7.org/fhir/R4/resource.html#Meta) + */ +export interface Meta { + /** The version specific identifier, as it appears in the version portion of the URL. This value changes when the resource is created, updated, or deleted. */ + versionId?: string; + /** When the resource last changed - e.g. when the version changed. */ + lastUpdated?: string; + /** A uri that identifies the source system of the resource. This provides a minimal amount of Provenance information that can be used to track or differentiate the source of information in the resource. The source may identify another FHIR server, document, message, database, etc. */ + source?: string; + /** A list of profiles (references to [StructureDefinition](https://www.hl7.org/fhir/structuredefinition.html) resources) that this resource claims to conform to. The URL is a reference to [StructureDefinition.url](https://www.hl7.org/fhir/structuredefinition-definitions.html#StructureDefinition.url). */ + profile?: string[]; + /** Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure. */ + security?: Array; + /** Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource. */ + tag?: Array; +} + +/** + * A Coding is a representation of a defined concept using a symbol from a defined "code system". + * Based on [FHIR Coding](https://www.hl7.org/fhir/R4/datatypes.html#Coding) + */ +export interface Coding extends Element { + /** Identity of the terminology system */ + system?: string; + /** Version of the system - if relevant */ + version?: string; + /** Symbol in syntax defined by the system */ + code?: string; + /** Representation defined by the system */ + display?: string; +} + +/** + * The base definition for all elements contained inside a resource. + * Based on [FHIR Element](https://www.hl7.org/fhir/R4/element.html) + */ +export interface Element { + /** Unique id for inter-element referencing */ + id?: string; + /** Additional Content defined by implementations */ + extension?: Array; +} + +/** + * Base for all elements + * Based on [FHIR Element](https://www.hl7.org/fhir/R4/element.html) + */ +export interface Extension extends Element { + /** Source of the definition for the extension code - a logical name or a URL. */ + url: string; + /** Value as Quantity */ + valueQuantity?: Quantity; + /** Value as CodeableConcept */ + valueCodeableConcept?: CodeableConcept; + /** Value as string */ + valueString?: string; + /** Value as boolean */ + valueBoolean?: boolean; + /** Value as integer */ + valueInteger?: number; + /** Value as Range. */ + valueRange?: Range; + /** Value as Ratio. */ + valueRatio?: Ratio; + /** Value as SampledData. */ + valueSampledData?: SampledData; + /** Value as time (hh:mm:ss) */ + valueTime?: string; + /** Value as dateTime. */ + valueDateTime?: string; + /** Value as Period. */ + valuePeriod?: Period; + /** Value as reference. */ + valueReference?: Reference; +} + +/** + * A measured or measurable amount + * Based on [FHIR Quantity](https://www.hl7.org/fhir/R4/datatypes.html#Quantity) + */ +export interface Quantity extends Element { + /** Numerical value (with implicit precision) */ + value?: number; + /** < | <= | >= | > - how to understand the value */ + comparator?: string; + /** Unit representation */ + unit?: string; + /** System that defines coded unit form */ + system?: string; + /** Coded form of the unit */ + code?: string; +} + +/** + * Concept - reference to a terminology or just text + * Based on [FHIR CodeableConcept](https://www.hl7.org/fhir/R4/datatypes.html#CodeableConcept) + */ +export interface CodeableConcept extends Element { + /** Code defined by a terminology system */ + coding?: Array; + /** Plain text representation of the concept */ + text?: string; +} + +/** + * A set of ordered Quantities defined by a low and high limit + * Based on [FHIR Range](https://www.hl7.org/fhir/R4/datatypes.html#Range) + */ +export interface Range extends Element { + /** Low limit */ + low?: Quantity; + /** High limit */ + high?: Quantity; +} + +/** + * A ratio of two Quantity values - a numerator and a denominator + * Based on [FHIR Ratio](https://www.hl7.org/fhir/R4/datatypes.html#Ratio) + */ +export interface Ratio extends Element { + /** Numerator value */ + numerator?: Quantity; + /** Denominator value */ + denominator?: Quantity; +} + +/** + * A series of measurements taken by a device + * Based on [FHIR SampledData](https://www.hl7.org/fhir/R4/datatypes.html#SampledData) + */ +export interface SampledData extends Element { + /** Zero value and units */ + origin: Quantity; + /** Number of milliseconds between samples */ + period: number; + /** Multiply data by this before adding to origin */ + factor?: number; + /** Lower limit of detection */ + lowerLimit?: number; + /** Upper limit of detection */ + upperLimit?: number; + /** Number of sample points at each time point */ + dimensions: number; + /** Decimal values with spaces, or "E" | "U" | "L" */ + data?: string; +} + +/** + * A time period defined by a start and end date and optionally time + * Based on [FHIR Period](https://www.hl7.org/fhir/R4/datatypes.html#Period) + */ +export interface Period extends Element { + /** Starting time with inclusive boundary */ + start?: string; + /** End time with inclusive boundary, if not ongoing */ + end?: string; +} + +/** + * A reference from one resource to another + * Based on [FHIR Reference](https://www.hl7.org/fhir/R4/references.html) + */ +export interface Reference extends Element { + /** Literal reference, Relative, internal or absolute URL */ + reference?: string; + /** Type the reference refers to (e.g. "Patient") */ + type?: string; + /** Logical reference, when literal reference is not known */ + identifier?: Identifier; + /** Text alternative for the resource */ + display?: string; +} + +/** + * An identifier intended for computation + * Based on [FHIR Identifier](https://www.hl7.org/fhir/R4/identifier.html) + */ +export interface Identifier extends Element { + /** usual | official | temp | secondary | old (If known) */ + use?: string; + /** Description of identifier */ + type?: CodeableConcept; + /** The namespace for the identifier value */ + system?: string; + /** The value that is unique */ + value?: string; + /** Time period when id is/was valid for use */ + period?: Period; + /** Organization that issued id (may be just text) */ + assigner?: Reference; +} + +/** + * Any resource that is a [DomainResource](https://www.hl7.org/fhir/domainresource.html) may include a human-readable narrative that contains a summary of the resource and may be used to represent the content of the resource to a human. + * Based on [FHIR Narrative](https://www.hl7.org/fhir/R4/narrative.html#Narrative) + */ +export interface Narrative extends Element { + /** generated, extensions, additional, empty */ + status: string; + /** xhtml */ + div: string; +} + +/** + * A text note which also contains information about who made the statement and when + * Based on [FHIR Annotation](https://www.hl7.org/fhir/R4/datatypes.html#Annotation) + */ +export interface Annotation extends Element { + /** Individual responsible for the annotation */ + authorString?: string; + /** When the annotation was made */ + time?: string; + /** The annotation - text content (as markdown) */ + text: string; +} + +/** + * Component results + * Based on [FHIR Observation.component](https://www.hl7.org/fhir/R4/observation.html) + */ +export interface ObservationComponent extends Element { + /** Type of component observation (code / type) */ + code: CodeableConcept; + /** Value as Quantity */ + valueQuantity?: Quantity; + /** Value as CodeableConcept */ + valueCodeableConcept?: CodeableConcept; + /** Value as string */ + valueString?: string; + /** Value as boolean */ + valueBoolean?: boolean; + /** Value as integer */ + valueInteger?: number; + /** Value as Range. */ + valueRange?: Range; + /** Value as Ratio. */ + valueRatio?: Ratio; + /** Value as SampledData. */ + valueSampledData?: SampledData; + /** Value as time (hh:mm:ss) */ + valueTime?: string; + /** Value as dateTime. */ + valueDateTime?: string; + /** Value as Period. */ + valuePeriod?: Period; + /** Value as reference. */ + valueReference?: Reference; + /** Why the component result is missing */ + dataAbsentReason?: CodeableConcept; + /** High, low, normal, etc. */ + interpretation?: Array; + /** Provides guide for interpretation of component result */ + referenceRange?: Array; +} + +/** + * Provides guide for interpretation of component result + * Based on [FHIR Observation.referenceRange](https://www.hl7.org/fhir/R4/observation.html) + */ +export interface ObservationReferenceRange { + /** Low Range, if relevant */ + low?: Quantity; + /** High Range, if relevant */ + high?: Quantity; + /** Reference range qualifier */ + type?: CodeableConcept; + /** Reference range population */ + appliesTo?: Array; + /** Applicable age range, if relevant */ + age?: Range; + /** Text based reference range in an observation */ + text?: string; +} + +/** Contact details (See: https://www.hl7.org/fhir/R4/metadatatypes.html#ContactDetail) */ +export interface ContactDetail extends Element { + /** Name of an individual to contact */ + name?: string; + /** Contact details for individual or organization */ + telecom?: Array; +} + +/** + * Details for all kinds of technology mediated contact points for a person or organization, including telephone, email, etc. + * See https://www.hl7.org/fhir/R4/datatypes.html#ContactPoint + */ +export interface ContactPoint { + /** + * phone | fax | email | pager | url | sms | other + * + * Possible values: "phone", "fax", "email", "pager", "url", "sms", "other" + */ + system?: ContactPointSystem; + /** The actual contact point details */ + value?: string; + /** + * home | work | temp | old | mobile - purpose of this contact point + * + * Possible values: "home", "work", "temp", "old", "mobile" + */ + use?: ContactPointUse; + /** Specify preferred order of use (1 = highest) */ + rank?: number; + /** Time period when the contact point was/is in use */ + period?: Period; +} + +/** + * A resource with narrative, extensions, and contained resources + * Based on [FHIR DomainResource](https://www.hl7.org/fhir/domainresource.html) + */ +export interface DomainResourceParent extends Resource { + /** Text summary of the resource, for human interpretation */ + text?: Narrative; + /** Contained, inline Resources */ + contained?: Array; + /** Additional Content defined by implementations */ + extension?: Array; + /** Extensions that cannot be ignored */ + modifierExtension?: Array; + resourceType: string; +} + +/** + * Detailed information about observations + * Based on [FHIR Observation](https://www.hl7.org/fhir/R4/observation.html) + */ +export interface Observation extends DomainResourceParent { + /** resourceType */ + resourceType: "Observation"; + /** Business Identifier for observation */ + identifier?: Array; + /** + * registered | preliminary | final | amended + + * + * Possible values: "registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown" + */ + status: ObservationStatusCodeType; + /** Classification of type of observation */ + category?: Array; + /** Type of observation (code / type) */ + code: CodeableConcept; + /** Who and/or what the observation is about */ + subject?: Reference; + /** Healthcare event during which this observation is made */ + encounter?: Reference; + /** Clinically relevant time/time-period for observation */ + effectiveDateTime?: string; + /** Clinically relevant time/time-period for observation */ + effectivePeriod?: Period; + /** Clinically relevant time/time-period for observation */ + effectiveInstant?: string; + /** Date/Time this version was made available */ + issued?: string; + /** Actual result */ + valueQuantity?: Quantity; + /** Actual result */ + valueCodeableConcept?: CodeableConcept; + /** Actual result */ + valueString?: string; + /** Actual result */ + valueBoolean?: boolean; + /** Actual result */ + valueInteger?: number; + /** Actual result */ + valueRange?: Range; + /** Actual result */ + valueRatio?: Ratio; + /** Actual result */ + valueSampledData?: SampledData; + /** Actual result */ + valueTime?: string; + /** Actual result */ + valueDateTime?: string; + /** Actual result */ + valuePeriod?: Period; + /** Why the result is missing */ + dataAbsentReason?: CodeableConcept; + /** High, low, normal, etc. */ + interpretation?: Array; + /** Comments about the observation */ + note?: Array; + /** Observed body part */ + bodySite?: CodeableConcept; + /** How it was done */ + method?: CodeableConcept; + /** Provides guide for interpretation */ + referenceRange?: Array; + /** Related resource that belongs to the Observation group */ + hasMember?: Array; + /** Related measurements the observation is made from */ + derivedFrom?: Array; + /** Component results */ + component?: Array; +} + +/** + * Detailed information about conditions, problems or diagnoses + * Based on [FHIR Condition](https://www.hl7.org/fhir/R4/condition.html) + */ +export interface Condition extends DomainResourceParent { + /** resourceType */ + resourceType: "Condition"; + /** External Ids for this condition */ + identifier?: Array; + /** active | recurrence | relapse | inactive | remission | resolved */ + clinicalStatus?: CodeableConcept; + /** unconfirmed | provisional | differential | confirmed | refuted | entered-in-error */ + verificationStatus?: CodeableConcept; + /** problem-list-item | encounter-diagnosis */ + category?: Array; + /** Subjective severity of condition */ + severity?: CodeableConcept; + /** Identification of the condition, problem or diagnosis */ + code?: CodeableConcept; + /** Anatomical location, if relevant */ + bodySite?: Array; + /** Encounter created as part of */ + encounter?: Reference; + /** Estimated or actual date, date-time, or age */ + onsetDateTime?: string; + /** Estimated or actual date, date-time, or age */ + onsetAge?: Quantity; + /** Estimated or actual date, date-time, or age */ + onsetPeriod?: Period; + /** Estimated or actual date, date-time, or age */ + onsetRange?: Range; + /** Estimated or actual date, date-time, or age */ + onsetString?: string; + /** When in resolution/remission */ + abatementDateTime?: string; + /** When in resolution/remission */ + abatementAge?: Quantity; + /** When in resolution/remission */ + abatementPeriod?: Period; + /** When in resolution/remission */ + abatementRange?: Range; + /** When in resolution/remission */ + abatementString?: string; + /** Date record was first recorded */ + recordedDate?: string; + /** stge/grade, usually assessed formally */ + stage?: Array; + /** Additional information about the Condition */ + note?: Array; +} + +/** + * Stage/grade, usually assessed formally + * Based on [FHIR Condition.Stage](https://www.hl7.org/fhir/R4/condition.html) + */ +export interface ConditionStage { + /** Simple summary (disease specific) */ + summary?: CodeableConcept; + /** Kind of staging */ + type?: CodeableConcept; +} + +/** + * Detailed information about Research Study + * Based on [FHIR ResearchStudy](https://www.hl7.org/fhir/R4/researchstudy.html) + */ +export interface ResearchStudy extends DomainResourceParent { + /** resourceType */ + resourceType: "ResearchStudy"; + /** Business Identifier for study */ + identifier?: Array; + /** Name for this study */ + title?: string; + /** Steps followed in executing study */ + protocol?: Array; + /** Part of larger study */ + partOf?: Array; + /** + * active | administratively-completed | approved | closed-to-accrual | closed-to-accrual-and-intervention | completed | disapproved | in-review | temporarily-closed-to-accrual | temporarily-closed-to-accrual-and-intervention | withdrawn + * + * Possible values: "active", "administratively-completed", "approved", "closed-to-accrual", "closed-to-accrual-and-intervention", "completed", "disapproved", "in-review", "temporarily-closed-to-accrual", "temporarily-closed-to-accrual-and-intervention", "withdrawn" + */ + status: ResearchStudyStatusCodeType; + /** treatment | prevention | diagnostic | supportive-care | screening | health-services-research | basic-science | device-feasibility */ + primaryPurposeType?: CodeableConcept; + /** n-a | early-phase-1 | phase-1 | phase-1-phase-2 | phase-2 | phase-2-phase-3 | phase-3 | phase-4 */ + phase?: CodeableConcept; + /** Classifications for the study */ + category?: Array; + /** Drugs, devices, etc. under study */ + focus?: Array; + /** Condition being studied */ + condition?: Array; + /** Contact details for the study */ + contact?: Array; + /** Used to search for the study */ + keyword?: Array; + /** Geographic region(s) for study */ + location?: Array; + /** What this is study doing */ + description?: string; + /** Inclusion & exclusion criteria */ + enrollment?: Array; + /** When the study began and ended */ + period?: Period; + /** Organization that initiates and is legally responsible for the study */ + sponsor?: Reference; + /** Researcher who oversees multiple aspects of the study */ + principalInvestigator?: Reference; + /** Facility where study activities are conducted */ + site?: Array; + /** accrual-goal-met | closed-due-to-toxicity | closed-due-to-lack-of-study-progress | temporarily-closed-per-study-design */ + reasonStopped?: CodeableConcept; + /** Comments made about the study */ + note?: Array; + /** Defined path through the study for a subject */ + arm?: { name: string; type?: CodeableConcept; description?: string }[]; + /** A goal for the study */ + objective?: { name: string; type?: CodeableConcept }[]; +} + +/** visit/encounter information */ +export interface PatientEncounter { + /** The id of the visit. */ + id: string; + /** + * Time period of the visit. + * In case of admission, use timePeriod.start to indicate the admission time and timePeriod.end to indicate the discharge time. + */ + period?: TimePeriod; + /** + * The class of the encounter. + * + * Possible values: "inpatient", "ambulatory", "observation", "emergency", "virtual", "healthHome" + */ + class?: EncounterClass; +} + +/** A duration of time during which an event is happening */ +export interface TimePeriod { + /** Starting time with inclusive boundary */ + start?: Date | string; + /** End time with inclusive boundary, if not ongoing */ + end?: Date | string; +} + +/** A clinical document related to a patient. Document here is in the wide sense - not just a text document (note). */ +export interface PatientDocument { + /** + * The type of the patient document, such as 'note' (text document) or 'fhirBundle' (FHIR JSON document). + * + * Possible values: "note", "fhirBundle", "dicom", "genomicSequencing" + */ + type: DocumentType; + /** + * The type of the clinical document. + * + * Possible values: "consultation", "dischargeSummary", "historyAndPhysical", "radiologyReport", "procedure", "progress", "laboratory", "pathologyReport" + */ + clinicalType?: ClinicalDocumentType; + /** A given identifier for the document. Has to be unique across all documents for a single patient. */ + id: string; + /** A 2 letter ISO 639-1 representation of the language of the document. */ + language?: string; + /** The date and time when the document was created. */ + createdAt?: Date | string; + /** Document author(s) */ + authors?: Array; + /** + * specialty type the document + * + * Possible values: "pathology", "radiology" + */ + specialtyType?: SpecialtyType; + /** Administrative metadata for the document. */ + administrativeMetadata?: DocumentAdministrativeMetadata; + /** The content of the patient document. */ + content: DocumentContent; +} + +/** Document author */ +export interface DocumentAuthor { + /** author id */ + id?: string; + /** Text representation of the full name */ + fullName?: string; +} + +/** Document administrative metadata */ +export interface DocumentAdministrativeMetadata { + /** List of procedure information associated with the document. */ + orderedProcedures?: Array; + /** Reference to the encounter associated with the document. */ + encounterId?: string; +} + +/** Procedure information */ +export interface OrderedProcedure { + /** Procedure code */ + code?: CodeableConcept; + /** Procedure description */ + description?: string; + /** Additional Content defined by implementations */ + extension?: Array; +} + +/** The content of the patient document. */ +export interface DocumentContent { + /** + * The type of the content's source. + * In case the source type is 'inline', the content is given as a string (for instance, text). + * In case the source type is 'reference', the content is given as a URI. + * + * Possible values: "inline", "reference" + */ + sourceType: DocumentContentSourceType; + /** The content of the document, given either inline (as a string) or as a reference (URI). */ + value: string; +} + +/** Configuration affecting the Radiology Insights model's inference. */ +export interface RadiologyInsightsModelConfiguration { + /** An indication whether the model should produce verbose output. */ + verbose?: boolean; + /** An indication whether the model's output should include evidence for the inferences. */ + includeEvidence?: boolean; + /** This is a list of inference types to be inferred for the current request. It could be used if only part of the Radiology Insights inferences are required. If this list is omitted or empty, the model will return all the inference types. */ + inferenceTypes?: RadiologyInsightsInferenceType[]; + /** Options regarding follow up recommendation inferences and finding inferences. */ + inferenceOptions?: RadiologyInsightsInferenceOptions; + /** Local for the model to use. If not specified, the model will use the default locale. */ + locale?: string; +} + +/** Options regarding follow up recommendation inferences and finding inferences. */ +export interface RadiologyInsightsInferenceOptions { + /** Follow-up recommendation options. */ + followupRecommendationOptions?: FollowupRecommendationOptions; + /** Finding options. */ + findingOptions?: FindingOptions; +} + +/** Follow-up recommendation options. */ +export interface FollowupRecommendationOptions { + /** Include/Exclude follow-up recommendations without a specific radiology procedure. Default is false. */ + includeRecommendationsWithNoSpecifiedModality?: boolean; + /** Include/Exclude follow-up recommendations in references to a guideline or article. Default is false. */ + includeRecommendationsInReferences?: boolean; + /** If this is true, provide one or more sentences as evidence for the recommendation, next to the token evidence. The start and end positions of these sentences will be put in an extension with url 'modality_sentences'. Default is false. */ + provideFocusedSentenceEvidence?: boolean; +} + +/** Finding options. */ +export interface FindingOptions { + /** If this is true, provide the sentence that contains the first token of the finding's clinical indicator (i.e. the medical problem), if there is one. This sentence is provided as an extension with url 'ci_sentence', next to the token evidence. Default is false. */ + provideFocusedSentenceEvidence?: boolean; +} + +/** The inference results for the Radiology Insights request. If field 'status' has value 'succeeded', then field 'result' will contain an instance of RadiologyInsightsInferenceResult. */ +export interface RadiologyInsightsInferenceResult { + /** Results for the patients given in the request. */ + patientResults: Array; + /** The version of the model used for inference, expressed as the model date. */ + modelVersion: string; +} + +/** Results of the model's work for a single patient. */ +export interface RadiologyInsightsPatientResult { + /** Identifier given for the patient in the request. */ + patientId: string; + /** The model's inferences for the given patient. */ + inferences: Array; +} + +/** + * An inference made by the Radiology Insights model regarding a patient. + * - AgeMismatch + * - SexMismatch + * - LateralityDiscrepancy + * - CompleteOrderDiscrepancy + * - LimitedOrderDiscrepancy + * - Finding + * - CriticalResult + * - FollowupRecommendation + * - RadiologyProcedure + * - FollowupCommunication + */ +export interface RadiologyInsightsInferenceParent { + /** Additional Content defined by implementations */ + extension?: Array; + kind: string; +} + +/** A notification for age mismatch is displayed when the age mentioned in a document for a specific patient does not match the age specified in the patient information. */ +export interface AgeMismatchInference extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "ageMismatch"; +} + +/** A notification for a sex mismatch is displayed when the gender, personal pronouns, gender-related body parts, or gender-related procedures mentioned in a patient's clinical document are either inconsistent or do not match the gender specified in the patient information. */ +export interface SexMismatchInference extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "sexMismatch"; + /** Sex indication : SNOMED CT code for gender finding. */ + sexIndication: CodeableConcept; +} + +/** A laterality mismatch occurs when there is a discrepancy between the clinical documentation and the ordered procedure (orderLateralityMismatch), a contradiction within the clinical document (textLateralityContradiction), or when no laterality is mentioned (textLateralityMissing). */ +export interface LateralityDiscrepancyInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "lateralityDiscrepancy"; + /** Laterality indication : SNOMED CT code for laterality qualifier value. */ + lateralityIndication?: CodeableConcept; + /** + * Mismatch type : orderLateralityMismatch, textLateralityContradiction, textLateralityMissing. + * + * Possible values: "orderLateralityMismatch", "textLateralityContradiction", "textLateralityMissing" + */ + discrepancyType: LateralityDiscrepancyType; +} + +/** A complete order discrepancy is shown when one or more body parts and/or measurements that should be in the document (because there is a complete order) are not present. */ +export interface CompleteOrderDiscrepancyInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "completeOrderDiscrepancy"; + /** Order type : CPT ultrasound complete code for abdomen, retroperitoneal, pelvis or breast. */ + orderType: CodeableConcept; + /** List of missing body parts required by a complete order : SNOMED CT codes. */ + missingBodyParts?: Array; + /** List of missing body parts that require measurement by a complete order : SNOMED CT codes. */ + missingBodyPartMeasurements?: Array; +} + +/** A limited order discrepancy occurs when there is a limited order, but all body parts and measurements that are needed for a complete order are present in the document. */ +export interface LimitedOrderDiscrepancyInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "limitedOrderDiscrepancy"; + /** Order type : CPT ultrasound complete code for abdomen, retroperitoneal, pelvis or breast. */ + orderType: CodeableConcept; + /** List of body parts found in the document : SNOMED CT codes. */ + presentBodyParts?: Array; + /** List of body parts that are measured according to the document : SNOMED CT codes. */ + presentBodyPartMeasurements?: Array; +} + +/** Findings in a radiology report typically describe abnormalities, lesions, or other notable observations related to the anatomy or pathology of the imaged area. */ +export interface FindingInference extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "finding"; + /** Finding data : contains extensions, fields and components linked with the finding. */ + finding: Observation; +} + +/** Critical results refer to findings of utmost importance that may require timely attention due to their potential impact on patient care. */ +export interface CriticalResultInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "criticalResult"; + /** The complete Critical Result, as outlined below, will be reused for the recommendation. */ + result: CriticalResult; +} + +/** Critical Result consists of two properties. */ +export interface CriticalResult { + /** Description : medical problem. */ + description: string; + /** Finding linked to the critical result. */ + finding?: Observation; +} + +/** Radiology procedures are the specific imaging studies or examinations ordered for the patient, extracted from the document information and text. */ +export interface RadiologyProcedureInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "radiologyProcedure"; + /** LOINC codes for the procedure. */ + procedureCodes?: Array; + /** Imaging procedures. */ + imagingProcedures: Array; + /** Ordered procedure information from the document information or text. */ + orderedProcedure: OrderedProcedure; +} + +/** Imaging procedure. */ +export interface ImagingProcedure { + /** Modality : SNOMED CT code. */ + modality: CodeableConcept; + /** Anatomy : SNOMED CT code. */ + anatomy: CodeableConcept; + /** Laterality : SNOMED CT code. */ + laterality?: CodeableConcept; + /** Contrast : see RadiologyCodeWithTypes (below). */ + contrast?: RadiologyCodeWithTypes; + /** View : see RadiologyCodeWithTypes (below). */ + view?: RadiologyCodeWithTypes; +} + +/** Radiology code with types : used in imaging procedure recommendation for contrast and view. */ +export interface RadiologyCodeWithTypes { + /** The SNOMED CT code indicates whether imaging was conducted with or without contrast in the case of contrast, and in the case of views, it denotes the number of views. */ + code: CodeableConcept; + /** The collection of types will indicate the contrast substance used in the case of contrast and, in the case of views, it will specify the types of views, such as lateral and frontal, etc. */ + types: Array; +} + +/** Follow-up recommendations offer guidance to healthcare providers on managing and monitoring patients based on the findings of imaging studies. */ +export interface FollowupRecommendationInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "followupRecommendation"; + /** Date and time are displayed when the procedure is recommended to be done at a specific point in time. */ + effectiveAt?: string; + /** The period is shown if a specific period is mentioned, with a start and end date-time. */ + effectivePeriod?: Period; + /** Findings related to the recommendation. */ + findings?: Array; + /** The conditional value indicates whether or not the sentence containing the recommendation includes a conditional statement. Keywords for conditional statements include 'if', 'when', 'unless', and so on. */ + isConditional: boolean; + /** The option value indicates whether or not the sentence containing the recommendation includes an optional statement. Keywords for optional statements include 'recommend', 'consider', and so on. */ + isOption: boolean; + /** The guideline value indicates whether or not the recommendation is part of a guideline section that compiles all recommendations applicable to various findings. */ + isGuideline: boolean; + /** Hedging refers to ambiguous, vague or imprecise language within the sentence of the recommendation. Keywords for hedging are 'can be','may be',and so on. */ + isHedging: boolean; + /** The procedure recommendation can be a generic procedure or an imaging procedure. */ + recommendedProcedure: ProcedureRecommendation; +} + +/** Finding reference for recommendation. */ +export interface RecommendationFinding { + /** Finding linked to a recommendation. */ + finding?: Observation; + /** Critical result linked to a recommendation. */ + criticalFinding?: CriticalResult; + /** + * Recommendation finding status. + * + * Possible values: "present", "differential", "ruleOut", "conditional" + */ + recommendationFindingStatus: RecommendationFindingStatusType; + /** Additional Content defined by implementations */ + extension?: Array; +} + +/** The procedure recommendation can be a generic procedure or an imaging procedure. */ +export interface ProcedureRecommendationParent { + /** Additional Content defined by implementations */ + extension?: Array; + kind: string; +} + +/** Generic procedure information. */ +export interface GenericProcedureRecommendation + extends ProcedureRecommendationParent { + /** Procedure type : generic. */ + kind: "genericProcedureRecommendation"; + /** Procedure modality : SNOMED CT code. */ + code: CodeableConcept; + /** Procedure description : MANAGEMENT PROCEDURE (PROCEDURE) or CONSULTATION (PROCEDURE) based on SNOMED CT. */ + description?: string; +} + +/** Imaging procedures. */ +export interface ImagingProcedureRecommendation + extends ProcedureRecommendationParent { + /** Procedure type : imaging. */ + kind: "imagingProcedureRecommendation"; + /** LOINC codes for the procedure. */ + procedureCodes?: Array; + /** Imaging procedures. */ + imagingProcedures: Array; +} + +/** Follow-up communication involves the exchange of important information, recommendations, or updates between radiologists and other healthcare professionals involved in a patient's care. */ +export interface FollowupCommunicationInference + extends RadiologyInsightsInferenceParent { + /** Inference type. */ + kind: "followupCommunication"; + /** Communication date and time. */ + communicatedAt?: Date[] | string[]; + /** Recipient of the communication. */ + recipient?: MedicalProfessionalType[]; + /** Communication was acknowledged. */ + wasAcknowledged: boolean; +} + +/** Response for the Radiology Insights request. */ +export interface RadiologyInsightsJob { + /** The request data for the operation. */ + jobData?: RadiologyInsightsData; +} + +/** + * A resource with narrative, extensions, and contained resources + * Based on [FHIR DomainResource](https://www.hl7.org/fhir/domainresource.html) + */ +export type DomainResource = + | DomainResourceParent + | Observation + | Condition + | ResearchStudy; +/** + * An inference made by the Radiology Insights model regarding a patient. + * - AgeMismatch + * - SexMismatch + * - LateralityDiscrepancy + * - CompleteOrderDiscrepancy + * - LimitedOrderDiscrepancy + * - Finding + * - CriticalResult + * - FollowupRecommendation + * - RadiologyProcedure + * - FollowupCommunication + */ +export type RadiologyInsightsInference = + | RadiologyInsightsInferenceParent + | AgeMismatchInference + | SexMismatchInference + | LateralityDiscrepancyInference + | CompleteOrderDiscrepancyInference + | LimitedOrderDiscrepancyInference + | FindingInference + | CriticalResultInference + | RadiologyProcedureInference + | FollowupRecommendationInference + | FollowupCommunicationInference; +/** The procedure recommendation can be a generic procedure or an imaging procedure. */ +export type ProcedureRecommendation = + | ProcedureRecommendationParent + | GenericProcedureRecommendation + | ImagingProcedureRecommendation; +/** Alias for PatientSex */ +export type PatientSex = string; +/** Alias for ContactPointSystem */ +export type ContactPointSystem = string; +/** Alias for ContactPointUse */ +export type ContactPointUse = string; +/** Alias for ObservationStatusCodeType */ +export type ObservationStatusCodeType = string; +/** Alias for ResearchStudyStatusCodeType */ +export type ResearchStudyStatusCodeType = string; +/** Alias for EncounterClass */ +export type EncounterClass = string; +/** Alias for DocumentType */ +export type DocumentType = string; +/** Alias for ClinicalDocumentType */ +export type ClinicalDocumentType = string; +/** Alias for SpecialtyType */ +export type SpecialtyType = string; +/** Alias for DocumentContentSourceType */ +export type DocumentContentSourceType = string; +/** Alias for RadiologyInsightsInferenceType */ +export type RadiologyInsightsInferenceType = string; +/** Alias for LateralityDiscrepancyType */ +export type LateralityDiscrepancyType = string; +/** Alias for RecommendationFindingStatusType */ +export type RecommendationFindingStatusType = string; +/** Alias for MedicalProfessionalType */ +export type MedicalProfessionalType = string; +/** Alias for JobStatus */ +export type JobStatus = string; diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/outputModels.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/outputModels.ts new file mode 100644 index 000000000000..151e1700b948 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/outputModels.ts @@ -0,0 +1,1045 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ErrorModel } from "@azure-rest/core-client"; + +/** Response for the Radiology Insights request. */ +export interface RadiologyInsightsJobOutput { + /** The request data for the operation. */ + jobData?: RadiologyInsightsDataOutput; + /** The result of the operation. */ + readonly result?: RadiologyInsightsInferenceResultOutput; + /** The unique ID of the job. */ + readonly id: string; + /** + * The status of the job. + * + * Possible values: "notStarted", "running", "succeeded", "failed", "canceled" + */ + readonly status: JobStatusOutput; + /** The date and time when the processing job was created. */ + readonly createdAt?: string; + /** The date and time when the processing job is set to expire. */ + readonly expiresAt?: string; + /** The date and time when the processing job was last updated. */ + readonly updatedAt?: string; + /** Error object that describes the error when status is "Failed". */ + readonly error?: ErrorModel; +} + +/** Contains the list of patients, and configuration data. */ +export interface RadiologyInsightsDataOutput { + /** The list of patients, including their clinical information and data. */ + patients: Array; + /** Configuration affecting the Radiology Insights model's inference. */ + configuration?: RadiologyInsightsModelConfigurationOutput; +} + +/** A patient record, including their clinical information and data. */ +export interface PatientRecordOutput { + /** A given identifier for the patient. Has to be unique across all patients in a single request. */ + id: string; + /** Patient structured information, including demographics and known structured clinical information. */ + details?: PatientDetailsOutput; + /** Patient encounters/visits. */ + encounters?: Array; + /** Patient unstructured clinical data, given as documents. */ + patientDocuments?: Array; +} + +/** Patient structured information, including demographics and known structured clinical information. */ +export interface PatientDetailsOutput { + /** + * The patient's sex. + * + * Possible values: "female", "male", "unspecified" + */ + sex?: PatientSexOutput; + /** The patient's date of birth. */ + birthDate?: string; + /** Known clinical information for the patient, structured. */ + clinicalInfo?: Array; +} + +/** + * Resource is the ancestor of DomainResource from which most resources are derived. Bundle, Parameters, and Binary extend Resource directly. + * Based on [FHIR Resource](https://www.hl7.org/fhir/r4/resource.html + */ +export interface ResourceOutput extends Record { + /** The type of resource */ + resourceType: string; + /** Resource Id */ + id?: string; + /** Metadata about the resource */ + meta?: MetaOutput; + /** A set of rules under which this content was created */ + implicitRules?: string; + /** Language of the resource content */ + language?: string; +} + +/** + * Metadata about a resource + * Based on [FHIR Meta](https://www.hl7.org/fhir/R4/resource.html#Meta) + */ +export interface MetaOutput { + /** The version specific identifier, as it appears in the version portion of the URL. This value changes when the resource is created, updated, or deleted. */ + versionId?: string; + /** When the resource last changed - e.g. when the version changed. */ + lastUpdated?: string; + /** A uri that identifies the source system of the resource. This provides a minimal amount of Provenance information that can be used to track or differentiate the source of information in the resource. The source may identify another FHIR server, document, message, database, etc. */ + source?: string; + /** A list of profiles (references to [StructureDefinition](https://www.hl7.org/fhir/structuredefinition.html) resources) that this resource claims to conform to. The URL is a reference to [StructureDefinition.url](https://www.hl7.org/fhir/structuredefinition-definitions.html#StructureDefinition.url). */ + profile?: string[]; + /** Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure. */ + security?: Array; + /** Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource. */ + tag?: Array; +} + +/** + * A Coding is a representation of a defined concept using a symbol from a defined "code system". + * Based on [FHIR Coding](https://www.hl7.org/fhir/R4/datatypes.html#Coding) + */ +export interface CodingOutput extends ElementOutput { + /** Identity of the terminology system */ + system?: string; + /** Version of the system - if relevant */ + version?: string; + /** Symbol in syntax defined by the system */ + code?: string; + /** Representation defined by the system */ + display?: string; +} + +/** + * The base definition for all elements contained inside a resource. + * Based on [FHIR Element](https://www.hl7.org/fhir/R4/element.html) + */ +export interface ElementOutput { + /** Unique id for inter-element referencing */ + id?: string; + /** Additional Content defined by implementations */ + extension?: Array; +} + +/** + * Base for all elements + * Based on [FHIR Element](https://www.hl7.org/fhir/R4/element.html) + */ +export interface ExtensionOutput extends ElementOutput { + /** Source of the definition for the extension code - a logical name or a URL. */ + url: string; + /** Value as Quantity */ + valueQuantity?: QuantityOutput; + /** Value as CodeableConcept */ + valueCodeableConcept?: CodeableConceptOutput; + /** Value as string */ + valueString?: string; + /** Value as boolean */ + valueBoolean?: boolean; + /** Value as integer */ + valueInteger?: number; + /** Value as Range. */ + valueRange?: RangeOutput; + /** Value as Ratio. */ + valueRatio?: RatioOutput; + /** Value as SampledData. */ + valueSampledData?: SampledDataOutput; + /** Value as time (hh:mm:ss) */ + valueTime?: string; + /** Value as dateTime. */ + valueDateTime?: string; + /** Value as Period. */ + valuePeriod?: PeriodOutput; + /** Value as reference. */ + valueReference?: ReferenceOutput; +} + +/** + * A measured or measurable amount + * Based on [FHIR Quantity](https://www.hl7.org/fhir/R4/datatypes.html#Quantity) + */ +export interface QuantityOutput extends ElementOutput { + /** Numerical value (with implicit precision) */ + value?: number; + /** < | <= | >= | > - how to understand the value */ + comparator?: string; + /** Unit representation */ + unit?: string; + /** System that defines coded unit form */ + system?: string; + /** Coded form of the unit */ + code?: string; +} + +/** + * Concept - reference to a terminology or just text + * Based on [FHIR CodeableConcept](https://www.hl7.org/fhir/R4/datatypes.html#CodeableConcept) + */ +export interface CodeableConceptOutput extends ElementOutput { + /** Code defined by a terminology system */ + coding?: Array; + /** Plain text representation of the concept */ + text?: string; +} + +/** + * A set of ordered Quantities defined by a low and high limit + * Based on [FHIR Range](https://www.hl7.org/fhir/R4/datatypes.html#Range) + */ +export interface RangeOutput extends ElementOutput { + /** Low limit */ + low?: QuantityOutput; + /** High limit */ + high?: QuantityOutput; +} + +/** + * A ratio of two Quantity values - a numerator and a denominator + * Based on [FHIR Ratio](https://www.hl7.org/fhir/R4/datatypes.html#Ratio) + */ +export interface RatioOutput extends ElementOutput { + /** Numerator value */ + numerator?: QuantityOutput; + /** Denominator value */ + denominator?: QuantityOutput; +} + +/** + * A series of measurements taken by a device + * Based on [FHIR SampledData](https://www.hl7.org/fhir/R4/datatypes.html#SampledData) + */ +export interface SampledDataOutput extends ElementOutput { + /** Zero value and units */ + origin: QuantityOutput; + /** Number of milliseconds between samples */ + period: number; + /** Multiply data by this before adding to origin */ + factor?: number; + /** Lower limit of detection */ + lowerLimit?: number; + /** Upper limit of detection */ + upperLimit?: number; + /** Number of sample points at each time point */ + dimensions: number; + /** Decimal values with spaces, or "E" | "U" | "L" */ + data?: string; +} + +/** + * A time period defined by a start and end date and optionally time + * Based on [FHIR Period](https://www.hl7.org/fhir/R4/datatypes.html#Period) + */ +export interface PeriodOutput extends ElementOutput { + /** Starting time with inclusive boundary */ + start?: string; + /** End time with inclusive boundary, if not ongoing */ + end?: string; +} + +/** + * A reference from one resource to another + * Based on [FHIR Reference](https://www.hl7.org/fhir/R4/references.html) + */ +export interface ReferenceOutput extends ElementOutput { + /** Literal reference, Relative, internal or absolute URL */ + reference?: string; + /** Type the reference refers to (e.g. "Patient") */ + type?: string; + /** Logical reference, when literal reference is not known */ + identifier?: IdentifierOutput; + /** Text alternative for the resource */ + display?: string; +} + +/** + * An identifier intended for computation + * Based on [FHIR Identifier](https://www.hl7.org/fhir/R4/identifier.html) + */ +export interface IdentifierOutput extends ElementOutput { + /** usual | official | temp | secondary | old (If known) */ + use?: string; + /** Description of identifier */ + type?: CodeableConceptOutput; + /** The namespace for the identifier value */ + system?: string; + /** The value that is unique */ + value?: string; + /** Time period when id is/was valid for use */ + period?: PeriodOutput; + /** Organization that issued id (may be just text) */ + assigner?: ReferenceOutput; +} + +/** + * Any resource that is a [DomainResource](https://www.hl7.org/fhir/domainresource.html) may include a human-readable narrative that contains a summary of the resource and may be used to represent the content of the resource to a human. + * Based on [FHIR Narrative](https://www.hl7.org/fhir/R4/narrative.html#Narrative) + */ +export interface NarrativeOutput extends ElementOutput { + /** generated, extensions, additional, empty */ + status: string; + /** xhtml */ + div: string; +} + +/** + * A text note which also contains information about who made the statement and when + * Based on [FHIR Annotation](https://www.hl7.org/fhir/R4/datatypes.html#Annotation) + */ +export interface AnnotationOutput extends ElementOutput { + /** Individual responsible for the annotation */ + authorString?: string; + /** When the annotation was made */ + time?: string; + /** The annotation - text content (as markdown) */ + text: string; +} + +/** + * Component results + * Based on [FHIR Observation.component](https://www.hl7.org/fhir/R4/observation.html) + */ +export interface ObservationComponentOutput extends ElementOutput { + /** Type of component observation (code / type) */ + code: CodeableConceptOutput; + /** Value as Quantity */ + valueQuantity?: QuantityOutput; + /** Value as CodeableConcept */ + valueCodeableConcept?: CodeableConceptOutput; + /** Value as string */ + valueString?: string; + /** Value as boolean */ + valueBoolean?: boolean; + /** Value as integer */ + valueInteger?: number; + /** Value as Range. */ + valueRange?: RangeOutput; + /** Value as Ratio. */ + valueRatio?: RatioOutput; + /** Value as SampledData. */ + valueSampledData?: SampledDataOutput; + /** Value as time (hh:mm:ss) */ + valueTime?: string; + /** Value as dateTime. */ + valueDateTime?: string; + /** Value as Period. */ + valuePeriod?: PeriodOutput; + /** Value as reference. */ + valueReference?: ReferenceOutput; + /** Why the component result is missing */ + dataAbsentReason?: CodeableConceptOutput; + /** High, low, normal, etc. */ + interpretation?: Array; + /** Provides guide for interpretation of component result */ + referenceRange?: Array; +} + +/** + * Provides guide for interpretation of component result + * Based on [FHIR Observation.referenceRange](https://www.hl7.org/fhir/R4/observation.html) + */ +export interface ObservationReferenceRangeOutput { + /** Low Range, if relevant */ + low?: QuantityOutput; + /** High Range, if relevant */ + high?: QuantityOutput; + /** Reference range qualifier */ + type?: CodeableConceptOutput; + /** Reference range population */ + appliesTo?: Array; + /** Applicable age range, if relevant */ + age?: RangeOutput; + /** Text based reference range in an observation */ + text?: string; +} + +/** Contact details (See: https://www.hl7.org/fhir/R4/metadatatypes.html#ContactDetail) */ +export interface ContactDetailOutput extends ElementOutput { + /** Name of an individual to contact */ + name?: string; + /** Contact details for individual or organization */ + telecom?: Array; +} + +/** + * Details for all kinds of technology mediated contact points for a person or organization, including telephone, email, etc. + * See https://www.hl7.org/fhir/R4/datatypes.html#ContactPoint + */ +export interface ContactPointOutput { + /** + * phone | fax | email | pager | url | sms | other + * + * Possible values: "phone", "fax", "email", "pager", "url", "sms", "other" + */ + system?: ContactPointSystemOutput; + /** The actual contact point details */ + value?: string; + /** + * home | work | temp | old | mobile - purpose of this contact point + * + * Possible values: "home", "work", "temp", "old", "mobile" + */ + use?: ContactPointUseOutput; + /** Specify preferred order of use (1 = highest) */ + rank?: number; + /** Time period when the contact point was/is in use */ + period?: PeriodOutput; +} + +/** + * A resource with narrative, extensions, and contained resources + * Based on [FHIR DomainResource](https://www.hl7.org/fhir/domainresource.html) + */ +export interface DomainResourceOutputParent extends ResourceOutput { + /** Text summary of the resource, for human interpretation */ + text?: NarrativeOutput; + /** Contained, inline Resources */ + contained?: Array; + /** Additional Content defined by implementations */ + extension?: Array; + /** Extensions that cannot be ignored */ + modifierExtension?: Array; + resourceType: string; +} + +/** + * Detailed information about observations + * Based on [FHIR Observation](https://www.hl7.org/fhir/R4/observation.html) + */ +export interface ObservationOutput extends DomainResourceOutputParent { + /** resourceType */ + resourceType: "Observation"; + /** Business Identifier for observation */ + identifier?: Array; + /** + * registered | preliminary | final | amended + + * + * Possible values: "registered", "preliminary", "final", "amended", "corrected", "cancelled", "entered-in-error", "unknown" + */ + status: ObservationStatusCodeTypeOutput; + /** Classification of type of observation */ + category?: Array; + /** Type of observation (code / type) */ + code: CodeableConceptOutput; + /** Who and/or what the observation is about */ + subject?: ReferenceOutput; + /** Healthcare event during which this observation is made */ + encounter?: ReferenceOutput; + /** Clinically relevant time/time-period for observation */ + effectiveDateTime?: string; + /** Clinically relevant time/time-period for observation */ + effectivePeriod?: PeriodOutput; + /** Clinically relevant time/time-period for observation */ + effectiveInstant?: string; + /** Date/Time this version was made available */ + issued?: string; + /** Actual result */ + valueQuantity?: QuantityOutput; + /** Actual result */ + valueCodeableConcept?: CodeableConceptOutput; + /** Actual result */ + valueString?: string; + /** Actual result */ + valueBoolean?: boolean; + /** Actual result */ + valueInteger?: number; + /** Actual result */ + valueRange?: RangeOutput; + /** Actual result */ + valueRatio?: RatioOutput; + /** Actual result */ + valueSampledData?: SampledDataOutput; + /** Actual result */ + valueTime?: string; + /** Actual result */ + valueDateTime?: string; + /** Actual result */ + valuePeriod?: PeriodOutput; + /** Why the result is missing */ + dataAbsentReason?: CodeableConceptOutput; + /** High, low, normal, etc. */ + interpretation?: Array; + /** Comments about the observation */ + note?: Array; + /** Observed body part */ + bodySite?: CodeableConceptOutput; + /** How it was done */ + method?: CodeableConceptOutput; + /** Provides guide for interpretation */ + referenceRange?: Array; + /** Related resource that belongs to the Observation group */ + hasMember?: Array; + /** Related measurements the observation is made from */ + derivedFrom?: Array; + /** Component results */ + component?: Array; +} + +/** + * Detailed information about conditions, problems or diagnoses + * Based on [FHIR Condition](https://www.hl7.org/fhir/R4/condition.html) + */ +export interface ConditionOutput extends DomainResourceOutputParent { + /** resourceType */ + resourceType: "Condition"; + /** External Ids for this condition */ + identifier?: Array; + /** active | recurrence | relapse | inactive | remission | resolved */ + clinicalStatus?: CodeableConceptOutput; + /** unconfirmed | provisional | differential | confirmed | refuted | entered-in-error */ + verificationStatus?: CodeableConceptOutput; + /** problem-list-item | encounter-diagnosis */ + category?: Array; + /** Subjective severity of condition */ + severity?: CodeableConceptOutput; + /** Identification of the condition, problem or diagnosis */ + code?: CodeableConceptOutput; + /** Anatomical location, if relevant */ + bodySite?: Array; + /** Encounter created as part of */ + encounter?: ReferenceOutput; + /** Estimated or actual date, date-time, or age */ + onsetDateTime?: string; + /** Estimated or actual date, date-time, or age */ + onsetAge?: QuantityOutput; + /** Estimated or actual date, date-time, or age */ + onsetPeriod?: PeriodOutput; + /** Estimated or actual date, date-time, or age */ + onsetRange?: RangeOutput; + /** Estimated or actual date, date-time, or age */ + onsetString?: string; + /** When in resolution/remission */ + abatementDateTime?: string; + /** When in resolution/remission */ + abatementAge?: QuantityOutput; + /** When in resolution/remission */ + abatementPeriod?: PeriodOutput; + /** When in resolution/remission */ + abatementRange?: RangeOutput; + /** When in resolution/remission */ + abatementString?: string; + /** Date record was first recorded */ + recordedDate?: string; + /** stge/grade, usually assessed formally */ + stage?: Array; + /** Additional information about the Condition */ + note?: Array; +} + +/** + * Stage/grade, usually assessed formally + * Based on [FHIR Condition.Stage](https://www.hl7.org/fhir/R4/condition.html) + */ +export interface ConditionStageOutput { + /** Simple summary (disease specific) */ + summary?: CodeableConceptOutput; + /** Kind of staging */ + type?: CodeableConceptOutput; +} + +/** + * Detailed information about Research Study + * Based on [FHIR ResearchStudy](https://www.hl7.org/fhir/R4/researchstudy.html) + */ +export interface ResearchStudyOutput extends DomainResourceOutputParent { + /** resourceType */ + resourceType: "ResearchStudy"; + /** Business Identifier for study */ + identifier?: Array; + /** Name for this study */ + title?: string; + /** Steps followed in executing study */ + protocol?: Array; + /** Part of larger study */ + partOf?: Array; + /** + * active | administratively-completed | approved | closed-to-accrual | closed-to-accrual-and-intervention | completed | disapproved | in-review | temporarily-closed-to-accrual | temporarily-closed-to-accrual-and-intervention | withdrawn + * + * Possible values: "active", "administratively-completed", "approved", "closed-to-accrual", "closed-to-accrual-and-intervention", "completed", "disapproved", "in-review", "temporarily-closed-to-accrual", "temporarily-closed-to-accrual-and-intervention", "withdrawn" + */ + status: ResearchStudyStatusCodeTypeOutput; + /** treatment | prevention | diagnostic | supportive-care | screening | health-services-research | basic-science | device-feasibility */ + primaryPurposeType?: CodeableConceptOutput; + /** n-a | early-phase-1 | phase-1 | phase-1-phase-2 | phase-2 | phase-2-phase-3 | phase-3 | phase-4 */ + phase?: CodeableConceptOutput; + /** Classifications for the study */ + category?: Array; + /** Drugs, devices, etc. under study */ + focus?: Array; + /** Condition being studied */ + condition?: Array; + /** Contact details for the study */ + contact?: Array; + /** Used to search for the study */ + keyword?: Array; + /** Geographic region(s) for study */ + location?: Array; + /** What this is study doing */ + description?: string; + /** Inclusion & exclusion criteria */ + enrollment?: Array; + /** When the study began and ended */ + period?: PeriodOutput; + /** Organization that initiates and is legally responsible for the study */ + sponsor?: ReferenceOutput; + /** Researcher who oversees multiple aspects of the study */ + principalInvestigator?: ReferenceOutput; + /** Facility where study activities are conducted */ + site?: Array; + /** accrual-goal-met | closed-due-to-toxicity | closed-due-to-lack-of-study-progress | temporarily-closed-per-study-design */ + reasonStopped?: CodeableConceptOutput; + /** Comments made about the study */ + note?: Array; + /** Defined path through the study for a subject */ + arm?: { name: string; type?: CodeableConceptOutput; description?: string }[]; + /** A goal for the study */ + objective?: { name: string; type?: CodeableConceptOutput }[]; +} + +/** visit/encounter information */ +export interface PatientEncounterOutput { + /** The id of the visit. */ + id: string; + /** + * Time period of the visit. + * In case of admission, use timePeriod.start to indicate the admission time and timePeriod.end to indicate the discharge time. + */ + period?: TimePeriodOutput; + /** + * The class of the encounter. + * + * Possible values: "inpatient", "ambulatory", "observation", "emergency", "virtual", "healthHome" + */ + class?: EncounterClassOutput; +} + +/** A duration of time during which an event is happening */ +export interface TimePeriodOutput { + /** Starting time with inclusive boundary */ + start?: string; + /** End time with inclusive boundary, if not ongoing */ + end?: string; +} + +/** A clinical document related to a patient. Document here is in the wide sense - not just a text document (note). */ +export interface PatientDocumentOutput { + /** + * The type of the patient document, such as 'note' (text document) or 'fhirBundle' (FHIR JSON document). + * + * Possible values: "note", "fhirBundle", "dicom", "genomicSequencing" + */ + type: DocumentTypeOutput; + /** + * The type of the clinical document. + * + * Possible values: "consultation", "dischargeSummary", "historyAndPhysical", "radiologyReport", "procedure", "progress", "laboratory", "pathologyReport" + */ + clinicalType?: ClinicalDocumentTypeOutput; + /** A given identifier for the document. Has to be unique across all documents for a single patient. */ + id: string; + /** A 2 letter ISO 639-1 representation of the language of the document. */ + language?: string; + /** The date and time when the document was created. */ + createdAt?: string; + /** Document author(s) */ + authors?: Array; + /** + * specialty type the document + * + * Possible values: "pathology", "radiology" + */ + specialtyType?: SpecialtyTypeOutput; + /** Administrative metadata for the document. */ + administrativeMetadata?: DocumentAdministrativeMetadataOutput; + /** The content of the patient document. */ + content: DocumentContentOutput; +} + +/** Document author */ +export interface DocumentAuthorOutput { + /** author id */ + id?: string; + /** Text representation of the full name */ + fullName?: string; +} + +/** Document administrative metadata */ +export interface DocumentAdministrativeMetadataOutput { + /** List of procedure information associated with the document. */ + orderedProcedures?: Array; + /** Reference to the encounter associated with the document. */ + encounterId?: string; +} + +/** Procedure information */ +export interface OrderedProcedureOutput { + /** Procedure code */ + code?: CodeableConceptOutput; + /** Procedure description */ + description?: string; + /** Additional Content defined by implementations */ + extension?: Array; +} + +/** The content of the patient document. */ +export interface DocumentContentOutput { + /** + * The type of the content's source. + * In case the source type is 'inline', the content is given as a string (for instance, text). + * In case the source type is 'reference', the content is given as a URI. + * + * Possible values: "inline", "reference" + */ + sourceType: DocumentContentSourceTypeOutput; + /** The content of the document, given either inline (as a string) or as a reference (URI). */ + value: string; +} + +/** Configuration affecting the Radiology Insights model's inference. */ +export interface RadiologyInsightsModelConfigurationOutput { + /** An indication whether the model should produce verbose output. */ + verbose?: boolean; + /** An indication whether the model's output should include evidence for the inferences. */ + includeEvidence?: boolean; + /** This is a list of inference types to be inferred for the current request. It could be used if only part of the Radiology Insights inferences are required. If this list is omitted or empty, the model will return all the inference types. */ + inferenceTypes?: RadiologyInsightsInferenceTypeOutput[]; + /** Options regarding follow up recommendation inferences and finding inferences. */ + inferenceOptions?: RadiologyInsightsInferenceOptionsOutput; + /** Local for the model to use. If not specified, the model will use the default locale. */ + locale?: string; +} + +/** Options regarding follow up recommendation inferences and finding inferences. */ +export interface RadiologyInsightsInferenceOptionsOutput { + /** Follow-up recommendation options. */ + followupRecommendationOptions?: FollowupRecommendationOptionsOutput; + /** Finding options. */ + findingOptions?: FindingOptionsOutput; +} + +/** Follow-up recommendation options. */ +export interface FollowupRecommendationOptionsOutput { + /** Include/Exclude follow-up recommendations without a specific radiology procedure. Default is false. */ + includeRecommendationsWithNoSpecifiedModality?: boolean; + /** Include/Exclude follow-up recommendations in references to a guideline or article. Default is false. */ + includeRecommendationsInReferences?: boolean; + /** If this is true, provide one or more sentences as evidence for the recommendation, next to the token evidence. The start and end positions of these sentences will be put in an extension with url 'modality_sentences'. Default is false. */ + provideFocusedSentenceEvidence?: boolean; +} + +/** Finding options. */ +export interface FindingOptionsOutput { + /** If this is true, provide the sentence that contains the first token of the finding's clinical indicator (i.e. the medical problem), if there is one. This sentence is provided as an extension with url 'ci_sentence', next to the token evidence. Default is false. */ + provideFocusedSentenceEvidence?: boolean; +} + +/** The inference results for the Radiology Insights request. If field 'status' has value 'succeeded', then field 'result' will contain an instance of RadiologyInsightsInferenceResult. */ +export interface RadiologyInsightsInferenceResultOutput { + /** Results for the patients given in the request. */ + patientResults: Array; + /** The version of the model used for inference, expressed as the model date. */ + modelVersion: string; +} + +/** Results of the model's work for a single patient. */ +export interface RadiologyInsightsPatientResultOutput { + /** Identifier given for the patient in the request. */ + patientId: string; + /** The model's inferences for the given patient. */ + inferences: Array; +} + +/** + * An inference made by the Radiology Insights model regarding a patient. + * - AgeMismatch + * - SexMismatch + * - LateralityDiscrepancy + * - CompleteOrderDiscrepancy + * - LimitedOrderDiscrepancy + * - Finding + * - CriticalResult + * - FollowupRecommendation + * - RadiologyProcedure + * - FollowupCommunication + */ +export interface RadiologyInsightsInferenceOutputParent { + /** Additional Content defined by implementations */ + extension?: Array; + kind: string; +} + +/** A notification for age mismatch is displayed when the age mentioned in a document for a specific patient does not match the age specified in the patient information. */ +export interface AgeMismatchInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "ageMismatch"; +} + +/** A notification for a sex mismatch is displayed when the gender, personal pronouns, gender-related body parts, or gender-related procedures mentioned in a patient's clinical document are either inconsistent or do not match the gender specified in the patient information. */ +export interface SexMismatchInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "sexMismatch"; + /** Sex indication : SNOMED CT code for gender finding. */ + sexIndication: CodeableConceptOutput; +} + +/** A laterality mismatch occurs when there is a discrepancy between the clinical documentation and the ordered procedure (orderLateralityMismatch), a contradiction within the clinical document (textLateralityContradiction), or when no laterality is mentioned (textLateralityMissing). */ +export interface LateralityDiscrepancyInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "lateralityDiscrepancy"; + /** Laterality indication : SNOMED CT code for laterality qualifier value. */ + lateralityIndication?: CodeableConceptOutput; + /** + * Mismatch type : orderLateralityMismatch, textLateralityContradiction, textLateralityMissing. + * + * Possible values: "orderLateralityMismatch", "textLateralityContradiction", "textLateralityMissing" + */ + discrepancyType: LateralityDiscrepancyTypeOutput; +} + +/** A complete order discrepancy is shown when one or more body parts and/or measurements that should be in the document (because there is a complete order) are not present. */ +export interface CompleteOrderDiscrepancyInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "completeOrderDiscrepancy"; + /** Order type : CPT ultrasound complete code for abdomen, retroperitoneal, pelvis or breast. */ + orderType: CodeableConceptOutput; + /** List of missing body parts required by a complete order : SNOMED CT codes. */ + missingBodyParts?: Array; + /** List of missing body parts that require measurement by a complete order : SNOMED CT codes. */ + missingBodyPartMeasurements?: Array; +} + +/** A limited order discrepancy occurs when there is a limited order, but all body parts and measurements that are needed for a complete order are present in the document. */ +export interface LimitedOrderDiscrepancyInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "limitedOrderDiscrepancy"; + /** Order type : CPT ultrasound complete code for abdomen, retroperitoneal, pelvis or breast. */ + orderType: CodeableConceptOutput; + /** List of body parts found in the document : SNOMED CT codes. */ + presentBodyParts?: Array; + /** List of body parts that are measured according to the document : SNOMED CT codes. */ + presentBodyPartMeasurements?: Array; +} + +/** Findings in a radiology report typically describe abnormalities, lesions, or other notable observations related to the anatomy or pathology of the imaged area. */ +export interface FindingInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "finding"; + /** Finding data : contains extensions, fields and components linked with the finding. */ + finding: ObservationOutput; +} + +/** Critical results refer to findings of utmost importance that may require timely attention due to their potential impact on patient care. */ +export interface CriticalResultInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "criticalResult"; + /** The complete Critical Result, as outlined below, will be reused for the recommendation. */ + result: CriticalResultOutput; +} + +/** Critical Result consists of two properties. */ +export interface CriticalResultOutput { + /** Description : medical problem. */ + description: string; + /** Finding linked to the critical result. */ + finding?: ObservationOutput; +} + +/** Radiology procedures are the specific imaging studies or examinations ordered for the patient, extracted from the document information and text. */ +export interface RadiologyProcedureInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "radiologyProcedure"; + /** LOINC codes for the procedure. */ + procedureCodes?: Array; + /** Imaging procedures. */ + imagingProcedures: Array; + /** Ordered procedure information from the document information or text. */ + orderedProcedure: OrderedProcedureOutput; +} + +/** Imaging procedure. */ +export interface ImagingProcedureOutput { + /** Modality : SNOMED CT code. */ + modality: CodeableConceptOutput; + /** Anatomy : SNOMED CT code. */ + anatomy: CodeableConceptOutput; + /** Laterality : SNOMED CT code. */ + laterality?: CodeableConceptOutput; + /** Contrast : see RadiologyCodeWithTypes (below). */ + contrast?: RadiologyCodeWithTypesOutput; + /** View : see RadiologyCodeWithTypes (below). */ + view?: RadiologyCodeWithTypesOutput; +} + +/** Radiology code with types : used in imaging procedure recommendation for contrast and view. */ +export interface RadiologyCodeWithTypesOutput { + /** The SNOMED CT code indicates whether imaging was conducted with or without contrast in the case of contrast, and in the case of views, it denotes the number of views. */ + code: CodeableConceptOutput; + /** The collection of types will indicate the contrast substance used in the case of contrast and, in the case of views, it will specify the types of views, such as lateral and frontal, etc. */ + types: Array; +} + +/** Follow-up recommendations offer guidance to healthcare providers on managing and monitoring patients based on the findings of imaging studies. */ +export interface FollowupRecommendationInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "followupRecommendation"; + /** Date and time are displayed when the procedure is recommended to be done at a specific point in time. */ + effectiveAt?: string; + /** The period is shown if a specific period is mentioned, with a start and end date-time. */ + effectivePeriod?: PeriodOutput; + /** Findings related to the recommendation. */ + findings?: Array; + /** The conditional value indicates whether or not the sentence containing the recommendation includes a conditional statement. Keywords for conditional statements include 'if', 'when', 'unless', and so on. */ + isConditional: boolean; + /** The option value indicates whether or not the sentence containing the recommendation includes an optional statement. Keywords for optional statements include 'recommend', 'consider', and so on. */ + isOption: boolean; + /** The guideline value indicates whether or not the recommendation is part of a guideline section that compiles all recommendations applicable to various findings. */ + isGuideline: boolean; + /** Hedging refers to ambiguous, vague or imprecise language within the sentence of the recommendation. Keywords for hedging are 'can be','may be',and so on. */ + isHedging: boolean; + /** The procedure recommendation can be a generic procedure or an imaging procedure. */ + recommendedProcedure: ProcedureRecommendationOutput; +} + +/** Finding reference for recommendation. */ +export interface RecommendationFindingOutput { + /** Finding linked to a recommendation. */ + finding?: ObservationOutput; + /** Critical result linked to a recommendation. */ + criticalFinding?: CriticalResultOutput; + /** + * Recommendation finding status. + * + * Possible values: "present", "differential", "ruleOut", "conditional" + */ + recommendationFindingStatus: RecommendationFindingStatusTypeOutput; + /** Additional Content defined by implementations */ + extension?: Array; +} + +/** The procedure recommendation can be a generic procedure or an imaging procedure. */ +export interface ProcedureRecommendationOutputParent { + /** Additional Content defined by implementations */ + extension?: Array; + kind: string; +} + +/** Generic procedure information. */ +export interface GenericProcedureRecommendationOutput + extends ProcedureRecommendationOutputParent { + /** Procedure type : generic. */ + kind: "genericProcedureRecommendation"; + /** Procedure modality : SNOMED CT code. */ + code: CodeableConceptOutput; + /** Procedure description : MANAGEMENT PROCEDURE (PROCEDURE) or CONSULTATION (PROCEDURE) based on SNOMED CT. */ + description?: string; +} + +/** Imaging procedures. */ +export interface ImagingProcedureRecommendationOutput + extends ProcedureRecommendationOutputParent { + /** Procedure type : imaging. */ + kind: "imagingProcedureRecommendation"; + /** LOINC codes for the procedure. */ + procedureCodes?: Array; + /** Imaging procedures. */ + imagingProcedures: Array; +} + +/** Follow-up communication involves the exchange of important information, recommendations, or updates between radiologists and other healthcare professionals involved in a patient's care. */ +export interface FollowupCommunicationInferenceOutput + extends RadiologyInsightsInferenceOutputParent { + /** Inference type. */ + kind: "followupCommunication"; + /** Communication date and time. */ + communicatedAt?: string[]; + /** Recipient of the communication. */ + recipient?: MedicalProfessionalTypeOutput[]; + /** Communication was acknowledged. */ + wasAcknowledged: boolean; +} + +/** A response containing error details. */ +export interface HealthInsightsErrorResponseOutput { + /** The error object. */ + error: ErrorModel; +} + +/** + * A resource with narrative, extensions, and contained resources + * Based on [FHIR DomainResource](https://www.hl7.org/fhir/domainresource.html) + */ +export type DomainResourceOutput = + | DomainResourceOutputParent + | ObservationOutput + | ConditionOutput + | ResearchStudyOutput; +/** + * An inference made by the Radiology Insights model regarding a patient. + * - AgeMismatch + * - SexMismatch + * - LateralityDiscrepancy + * - CompleteOrderDiscrepancy + * - LimitedOrderDiscrepancy + * - Finding + * - CriticalResult + * - FollowupRecommendation + * - RadiologyProcedure + * - FollowupCommunication + */ +export type RadiologyInsightsInferenceOutput = + | RadiologyInsightsInferenceOutputParent + | AgeMismatchInferenceOutput + | SexMismatchInferenceOutput + | LateralityDiscrepancyInferenceOutput + | CompleteOrderDiscrepancyInferenceOutput + | LimitedOrderDiscrepancyInferenceOutput + | FindingInferenceOutput + | CriticalResultInferenceOutput + | RadiologyProcedureInferenceOutput + | FollowupRecommendationInferenceOutput + | FollowupCommunicationInferenceOutput; +/** The procedure recommendation can be a generic procedure or an imaging procedure. */ +export type ProcedureRecommendationOutput = + | ProcedureRecommendationOutputParent + | GenericProcedureRecommendationOutput + | ImagingProcedureRecommendationOutput; +/** Alias for PatientSexOutput */ +export type PatientSexOutput = string; +/** Alias for ContactPointSystemOutput */ +export type ContactPointSystemOutput = string; +/** Alias for ContactPointUseOutput */ +export type ContactPointUseOutput = string; +/** Alias for ObservationStatusCodeTypeOutput */ +export type ObservationStatusCodeTypeOutput = string; +/** Alias for ResearchStudyStatusCodeTypeOutput */ +export type ResearchStudyStatusCodeTypeOutput = string; +/** Alias for EncounterClassOutput */ +export type EncounterClassOutput = string; +/** Alias for DocumentTypeOutput */ +export type DocumentTypeOutput = string; +/** Alias for ClinicalDocumentTypeOutput */ +export type ClinicalDocumentTypeOutput = string; +/** Alias for SpecialtyTypeOutput */ +export type SpecialtyTypeOutput = string; +/** Alias for DocumentContentSourceTypeOutput */ +export type DocumentContentSourceTypeOutput = string; +/** Alias for RadiologyInsightsInferenceTypeOutput */ +export type RadiologyInsightsInferenceTypeOutput = string; +/** Alias for LateralityDiscrepancyTypeOutput */ +export type LateralityDiscrepancyTypeOutput = string; +/** Alias for RecommendationFindingStatusTypeOutput */ +export type RecommendationFindingStatusTypeOutput = string; +/** Alias for MedicalProfessionalTypeOutput */ +export type MedicalProfessionalTypeOutput = string; +/** Alias for JobStatusOutput */ +export type JobStatusOutput = string; diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/parameters.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/parameters.ts new file mode 100644 index 000000000000..ee448414b4ce --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/parameters.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { RequestParameters } from "@azure-rest/core-client"; +import { RadiologyInsightsJob } from "./models.js"; + +export interface GetJobQueryParamProperties { + /** Expand the indicated resources into the response. This parameter needs to be formatted as multi collection, we provide buildMultiCollection from serializeHelper.ts to help, you will probably need to set skipUrlEncoding as true when sending the request */ + expand?: string; +} + +export interface GetJobQueryParam { + queryParameters?: GetJobQueryParamProperties; +} + +export type GetJobParameters = GetJobQueryParam & RequestParameters; + +export interface CreateJobBodyParam { + /** The resource instance. */ + body: RadiologyInsightsJob; +} + +export interface CreateJobQueryParamProperties { + /** Expand the indicated resources into the response. This parameter needs to be formatted as multi collection, we provide buildMultiCollection from serializeHelper.ts to help, you will probably need to set skipUrlEncoding as true when sending the request */ + expand?: string; +} + +export interface CreateJobQueryParam { + queryParameters?: CreateJobQueryParamProperties; +} + +export type CreateJobParameters = CreateJobQueryParam & + CreateJobBodyParam & + RequestParameters; diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/pollingHelper.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/pollingHelper.ts new file mode 100644 index 000000000000..986993876973 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/pollingHelper.ts @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Client, HttpResponse } from "@azure-rest/core-client"; +import { AbortSignalLike } from "@azure/abort-controller"; +import { + CancelOnProgress, + CreateHttpPollerOptions, + RunningOperation, + OperationResponse, + OperationState, + createHttpPoller, +} from "@azure/core-lro"; +import { + CreateJob200Response, + CreateJob201Response, + CreateJobDefaultResponse, + CreateJobLogicalResponse, +} from "./responses.js"; + +/** + * A simple poller that can be used to poll a long running operation. + */ +export interface SimplePollerLike< + TState extends OperationState, + TResult, +> { + /** + * Returns true if the poller has finished polling. + */ + isDone(): boolean; + /** + * Returns the state of the operation. + */ + getOperationState(): TState; + /** + * Returns the result value of the operation, + * regardless of the state of the poller. + * It can return undefined or an incomplete form of the final TResult value + * depending on the implementation. + */ + getResult(): TResult | undefined; + /** + * Returns a promise that will resolve once a single polling request finishes. + * It does this by calling the update method of the Poller's operation. + */ + poll(options?: { abortSignal?: AbortSignalLike }): Promise; + /** + * Returns a promise that will resolve once the underlying operation is completed. + */ + pollUntilDone(pollOptions?: { + abortSignal?: AbortSignalLike; + }): Promise; + /** + * Invokes the provided callback after each polling is completed, + * sending the current state of the poller's operation. + * + * It returns a method that can be used to stop receiving updates on the given callback function. + */ + onProgress(callback: (state: TState) => void): CancelOnProgress; + + /** + * Returns a promise that could be used for serialized version of the poller's operation + * by invoking the operation's serialize method. + */ + serialize(): Promise; + + /** + * Wait the poller to be submitted. + */ + submitted(): Promise; + + /** + * Returns a string representation of the poller's operation. Similar to serialize but returns a string. + * @deprecated Use serialize() instead. + */ + toString(): string; + + /** + * Stops the poller from continuing to poll. Please note this will only stop the client-side polling + * @deprecated Use abortSignal to stop polling instead. + */ + stopPolling(): void; + + /** + * Returns true if the poller is stopped. + * @deprecated Use abortSignal status to track this instead. + */ + isStopped(): boolean; +} + +/** + * Helper function that builds a Poller object to help polling a long running operation. + * @param client - Client to use for sending the request to get additional pages. + * @param initialResponse - The initial response. + * @param options - Options to set a resume state or custom polling interval. + * @returns - A poller object to poll for operation state updates and eventually get the final response. + */ +export async function getLongRunningPoller< + TResult extends CreateJobLogicalResponse | CreateJobDefaultResponse, +>( + client: Client, + initialResponse: + | CreateJob200Response + | CreateJob201Response + | CreateJobDefaultResponse, + options?: CreateHttpPollerOptions>, +): Promise, TResult>>; +export async function getLongRunningPoller( + client: Client, + initialResponse: TResult, + options: CreateHttpPollerOptions> = {}, +): Promise, TResult>> { + const abortController = new AbortController(); + const poller: RunningOperation = { + sendInitialRequest: async () => { + // In the case of Rest Clients we are building the LRO poller object from a response that's the reason + // we are not triggering the initial request here, just extracting the information from the + // response we were provided. + return getLroResponse(initialResponse); + }, + sendPollRequest: async ( + path: string, + pollOptions?: { abortSignal?: AbortSignalLike }, + ) => { + // This is the callback that is going to be called to poll the service + // to get the latest status. We use the client provided and the polling path + // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location + // depending on the lro pattern that the service implements. If non is provided we default to the initial path. + function abortListener(): void { + abortController.abort(); + } + const inputAbortSignal = pollOptions?.abortSignal; + const abortSignal = abortController.signal; + if (inputAbortSignal?.aborted) { + abortController.abort(); + } else if (!abortSignal.aborted) { + inputAbortSignal?.addEventListener("abort", abortListener, { + once: true, + }); + } + let response; + try { + response = await client + .pathUnchecked(path ?? initialResponse.request.url) + .get({ abortSignal }); + } finally { + inputAbortSignal?.removeEventListener("abort", abortListener); + } + const lroResponse = getLroResponse(response as TResult); + lroResponse.rawResponse.headers["x-ms-original-url"] = + initialResponse.request.url; + return lroResponse; + }, + }; + + options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; + const httpPoller = createHttpPoller(poller, options); + const simplePoller: SimplePollerLike, TResult> = { + isDone() { + return httpPoller.isDone; + }, + isStopped() { + return abortController.signal.aborted; + }, + getOperationState() { + if (!httpPoller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return httpPoller.operationState; + }, + getResult() { + return httpPoller.result; + }, + toString() { + if (!httpPoller.operationState) { + throw new Error( + "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().", + ); + } + return JSON.stringify({ + state: httpPoller.operationState, + }); + }, + stopPolling() { + abortController.abort(); + }, + onProgress: httpPoller.onProgress, + poll: httpPoller.poll, + pollUntilDone: httpPoller.pollUntilDone, + serialize: httpPoller.serialize, + submitted: httpPoller.submitted, + }; + return simplePoller; +} + +/** + * Converts a Rest Client response to a response that the LRO implementation understands + * @param response - a rest client http response + * @returns - An LRO response that the LRO implementation understands + */ +function getLroResponse( + response: TResult, +): OperationResponse { + if (Number.isNaN(response.status)) { + throw new TypeError( + `Status code of the response is not a number. Value: ${response.status}`, + ); + } + + return { + flatResponse: response, + rawResponse: { + ...response, + statusCode: Number.parseInt(response.status), + body: response.body, + }, + }; +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/responses.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/responses.ts new file mode 100644 index 000000000000..bf22042efff7 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/responses.ts @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { RawHttpHeaders } from "@azure/core-rest-pipeline"; +import { HttpResponse } from "@azure-rest/core-client"; +import { + RadiologyInsightsJobOutput, + HealthInsightsErrorResponseOutput, +} from "./outputModels.js"; + +export interface GetJob200Headers { + /** The Retry-After header can indicate how long the client should wait before polling the operation status. */ + "retry-after"?: number; + /** An opaque, globally-unique, server-generated string identifier for the request. */ + "x-ms-request-id"?: string; +} + +/** The request has succeeded. */ +export interface GetJob200Response extends HttpResponse { + status: "200"; + body: RadiologyInsightsJobOutput; + headers: RawHttpHeaders & GetJob200Headers; +} + +export interface GetJobDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; + /** An opaque, globally-unique, server-generated string identifier for the request. */ + "x-ms-request-id"?: string; +} + +export interface GetJobDefaultResponse extends HttpResponse { + status: string; + body: HealthInsightsErrorResponseOutput; + headers: RawHttpHeaders & GetJobDefaultHeaders; +} + +export interface CreateJob200Headers { + /** An opaque, globally-unique, server-generated string identifier for the request. */ + "x-ms-request-id"?: string; + /** The location for monitoring the operation state. */ + "operation-location": string; +} + +/** The request has succeeded. */ +export interface CreateJob200Response extends HttpResponse { + status: "200"; + body: RadiologyInsightsJobOutput; + headers: RawHttpHeaders & CreateJob200Headers; +} + +export interface CreateJob201Headers { + /** An opaque, globally-unique, server-generated string identifier for the request. */ + "x-ms-request-id"?: string; + /** The location for monitoring the operation state. */ + "operation-location": string; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface CreateJob201Response extends HttpResponse { + status: "201"; + body: RadiologyInsightsJobOutput; + headers: RawHttpHeaders & CreateJob201Headers; +} + +export interface CreateJobDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; + /** An opaque, globally-unique, server-generated string identifier for the request. */ + "x-ms-request-id"?: string; +} + +export interface CreateJobDefaultResponse extends HttpResponse { + status: string; + body: HealthInsightsErrorResponseOutput; + headers: RawHttpHeaders & CreateJobDefaultHeaders; +} + +/** The final response for long-running createJob operation */ +export interface CreateJobLogicalResponse extends HttpResponse { + status: "200"; + body: RadiologyInsightsJobOutput; +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/serializeHelper.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/serializeHelper.ts new file mode 100644 index 000000000000..a19f11ca222a --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/src/serializeHelper.ts @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export function buildMultiCollection( + items: string[], + parameterName: string, +): string { + return items + .map((item, index) => { + if (index === 0) { + return item; + } + return `${parameterName}=${item}`; + }) + .join("&"); +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/sampleTest.spec.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..d4919ac91ac5 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/sampleTest.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createRecorder } from "./utils/recordedClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async function () { + // recorder = await createRecorder(this); + }); + + afterEach(async function () { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/utils/recordedClient.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6e425fdcfdf9 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Recorder, + RecorderStartOptions, + VitestTestContext, +} from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder( + context: VitestTestContext, +): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.browser.config.json b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.browser.config.json new file mode 100644 index 000000000000..1b37aebc5457 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.browser.config.json @@ -0,0 +1,10 @@ +{ + "extends": "./.tshy/build.json", + "include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts"], + "exclude": ["./test/**/node/**/*.ts"], + "compilerOptions": { + "outDir": "./dist-test/browser", + "rootDir": ".", + "skipLibCheck": true + } +} diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.json b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.json new file mode 100644 index 000000000000..a6575847a41e --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "rootDir": ".", + "skipLibCheck": true + }, + "include": [ + "./src/**/*.ts", + "./src/**/*.mts", + "./src/**/*.cts", + "test/**/*.ts", + "./test/**/*.ts" + ] +} \ No newline at end of file diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsp-location.yaml b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsp-location.yaml new file mode 100644 index 000000000000..b911fe10d8d9 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/tsp-location.yaml @@ -0,0 +1,6 @@ +directory: specification/ai/HealthInsights/HealthInsights.RadiologyInsights +commit: 65171caa921a67914855465095f912fb17445d7e +repo: /mnt/vss/_work/1/s/azure-rest-api-specs +additionalDirectories: +- specification/ai/HealthInsights/HealthInsights.Common +- specification/ai/HealthInsights/HealthInsights.OpenAPI diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.browser.config.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.browser.config.ts new file mode 100644 index 000000000000..5e0dc418cfa2 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.browser.config.ts @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; + +process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); + +export default defineConfig({ + define: { + "process.env": process.env, + }, + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.browser.xml", + }, + browser: { + enabled: true, + headless: true, + name: "chromium", + provider: "playwright", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["dist-test/browser/**/*.spec.js"], + coverage: { + include: ["dist-test/browser/**/*.spec.js"], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage-browser", + }, + testTimeout: 1200000, + }, +}); diff --git a/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.config.ts b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.config.ts new file mode 100644 index 000000000000..f8ab2a758bf9 --- /dev/null +++ b/sdk/healthinsights/azurehealthinsightsradiologyinsights-rest/vitest.config.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig } from "vitest/config"; +import { relativeRecordingsPath } from "@azure-tools/test-recorder"; + +export default defineConfig({ + test: { + reporters: ["basic", "junit"], + outputFile: { + junit: "test-results.browser.xml", + }, + fakeTimers: { + toFake: ["setTimeout", "Date"], + }, + watch: false, + include: ["test/**/*.spec.ts"], + exclude: ["test/**/browser/*.spec.ts"], + coverage: { + include: ["src/**/*.ts"], + exclude: [ + "src/**/*-browser.mts", + "src/**/*-react-native.mts", + "vitest*.config.ts", + "samples-dev/**/*.ts", + ], + provider: "istanbul", + reporter: ["text", "json", "html"], + reportsDirectory: "coverage", + }, + testTimeout: 1200000, + }, +});