Skip to content

Commit

Permalink
Merge branch 'healthdataaiservices/stable' of https://github.com/alex…
Browse files Browse the repository at this point in the history
…athomases/azure-sdk-for-js into healthdataaiservices/stable
  • Loading branch information
Alexa Thomases committed Dec 7, 2024
2 parents 03bdd2e + 0c8658d commit 9b51092
Show file tree
Hide file tree
Showing 16 changed files with 408 additions and 362 deletions.
54 changes: 6 additions & 48 deletions sdk/healthdataaiservices/azure-health-deidentification/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Azure Deidentification REST client library for JavaScript

`@azure-rest/health-deidentification` is a managed service that enables users to tag, redact, or surrogate health data.
Health Deidentification Service

**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**

<!-- **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** -->
<!-- TODO Fix links once they are live use placeholden until then -->
Key links:

- [Package (NPM)](https://www.npmjs.com/package/@azure-rest/health-deidentification)
- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/health-deidentification?view=azure-node-preview)

## Getting started

Expand All @@ -32,57 +33,14 @@ To use an [Azure Active Directory (AAD) token credential](https://github.com/Azu
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)
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`

Pull `ServiceUrl` from your created Deidentification Service.

![Service Url Location](documentation/images/ServiceUrl_Location.png)

Basic code snippet to create your Deidentification Client and Deidentify a string.

```javascript
import createClient, {
DeidentificationContent,
isUnexpected,
} from "@azure-rest/health-deidentification";
import { DefaultAzureCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();

const credential = new DefaultAzureCredential();
const serviceEndpoint =
process.env["DEID_SERVICE_ENDPOINT"] || "https://example.api.cac001.deid.azure.com";
const client = createClient(serviceEndpoint, credential);

const content: DeidentificationContent = {
inputText: "Hello John!"
};

const response = await client.path("/deid").post({ body: content });

if (isUnexpected(response)) {
throw response.body.error;
}

console.log(response.body.outputText); // Hello, Tom!
```

## Key concept

Operation Modes:

- Tag: Will return a structure of offset and length with the PHI category of the related text spans.
- Redact: Will return output text with placeholder stubbed text. ex. `[name]`
- Surrogate: Will return output text with synthetic replacements.
- `My name is John Smith`
- `My name is Tom Jones`
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

## Troubleshooting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default azsdkEslint.config([
"@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",
"tsdoc/syntax": "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",
Expand Down
Loading

0 comments on commit 9b51092

Please sign in to comment.