Skip to content

Commit

Permalink
Add Health Deidentification SDK client library for java (#40725)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielszaniszlo authored Jul 22, 2024
1 parent 4e150dd commit b714f86
Show file tree
Hide file tree
Showing 61 changed files with 10,873 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@
"databind",
"databricks",
"DAZURE",
"deidentification",
"deidentificationclient",
"deidentified",
"deid",
"deidservices",
"deidentify",
"ddos",
"dcis",
"deallocate",
Expand All @@ -301,6 +307,7 @@
"Entra",
"Esto",
"etag",
"euap",
"eventhub",
"eventhubs",
"failondeprecatedstatus",
Expand All @@ -316,10 +323,12 @@
"hanaonazure",
"hdfs",
"hdinsight",
"healthdataaiservices",
"hudha",
"hvac",
"hybridkubernetes",
"hyunwoongko",
"idnum",
"insights",
"intellij",
"Intellij",
Expand Down
1 change: 1 addition & 0 deletions eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ com.azure:azure-developer-devcenter;1.0.1;1.1.0-beta.1
com.azure:azure-developer-loadtesting;1.0.14;1.1.0-beta.1
com.azure:azure-digitaltwins-core;1.3.21;1.4.0-beta.1
com.azure:azure-e2e;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-health-deidentification;1.0.0;1.0.0-beta.1
com.azure:azure-health-insights-clinicalmatching;1.0.0-beta.1;1.0.0-beta.2
com.azure:azure-health-insights-cancerprofiling;1.0.0-beta.1;1.0.0-beta.2
com.azure:azure-health-insights-radiologyinsights;1.0.0-beta.1;1.0.0-beta.2
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<module>sdk/hdinsight</module>
<module>sdk/healthbot</module>
<module>sdk/healthcareapis</module>
<module>sdk/healthdataaiservices</module>
<module>sdk/healthinsights</module>
<module>sdk/hybridcompute</module>
<module>sdk/hybridconnectivity</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

- Azure Deidentification client library for Java. This package contains Microsoft Azure Deidentification client library.

### Features Added

### Breaking Changes

### Bugs Fixed

### Other Changes
161 changes: 161 additions & 0 deletions sdk/healthdataaiservices/azure-health-deidentification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Azure Deidentification client library for Java

Azure Deidentification client library for Java.

This package contains Microsoft Azure Deidentification client library which is a managed service that enables users to tag, redact, or surrogate health data.

## Documentation

Various documentation is available to help you get started

- [API reference documentation][docs]
- [Product documentation][product_documentation]

## Getting started

### Prerequisites

- [Java Development Kit (JDK)][jdk] with version 8 or above
- [Azure Subscription][azure_subscription]

### Adding the package to your product

[//]: # ({x-version-update-start;com.azure:azure-health-deidentification;current})
```xml
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-health-deidentification</artifactId>
<version>1.0.0-beta.1</version>
</dependency>
```
[//]: # ({x-version-update-end})

### Authentication

[Azure Identity][azure_identity] package provides the default implementation for authenticating the client.

## Key concepts
### 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`

## Examples

The following sections provide several code snippets covering some of the most common Azure Deidentification client use cases, including:

- [Create a `DeidentificationClient`](#create-a-deidentificationclient)
- [Calling deidentification endpoint](#calling-deidentification-endpoint)
- [Creating deidentification Job](#creating-deidentification-job)
- [Process deidentification Job](#process-deidentification-job)
- [List deidentification Jobs](#list-deidentification-jobs)
- [List completed files](#list-completed-files)

### Create a `DeidentificationClient`

Create a `DeidentificationClient` using the `DEID_SERVICE_ENDPOINT` environment variable.

```java com.azure.health.deidentification.readme
DeidentificationClientBuilder deidentificationClientbuilder = new DeidentificationClientBuilder()
.endpoint(Configuration.getGlobalConfiguration().get("DEID_SERVICE_ENDPOINT", "endpoint"))
.httpClient(HttpClient.createDefault())
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC));

DeidentificationClient deidentificationClient = deidentificationClientbuilder.buildClient();
```

### Calling `Deidentification` endpoint

Calling the realtime endpoint with an input.

```java com.azure.health.deidentification.sync.helloworld
String inputText = "Hello, my name is John Smith.";

DeidentificationContent content = new DeidentificationContent(inputText);

DeidentificationResult result = deidentificationClient.deidentify(content);

System.out.println("Deidentified output: " + result.getOutputText());
// Deidentified output: Hello, my name is Harley Billiard.
```
### Creating Deidentification Job

Creating a Deidentification Job using `STORAGE_ACCOUNT_NAME` and `STORAGE_CONTAINER_NAME` environment variables.

```java com.azure.health.deidentification.sync.createjob.create
String storageLocation = "https://" + Configuration.getGlobalConfiguration().get("STORAGE_ACCOUNT_NAME") + ".blob.core.windows.net/" + Configuration.getGlobalConfiguration().get("STORAGE_CONTAINER_NAME");
String jobName = "MyJob-" + Instant.now().toEpochMilli();
String outputFolder = "_output";
String inputPrefix = "example_patient_1";
SourceStorageLocation sourceStorageLocation = new SourceStorageLocation(storageLocation, inputPrefix);

DeidentificationJob job = new DeidentificationJob(sourceStorageLocation, new TargetStorageLocation(storageLocation, outputFolder));
job.setOperation(OperationType.SURROGATE);
job.setDataType(DocumentDataType.PLAINTEXT);

```
### Process Deidentification Job

Create and poll job until it is completed.

```java com.azure.health.deidentification.sync.createjob.process
DeidentificationJob result = deidentificationClient.beginCreateJob(jobName, job)
.waitForCompletion()
.getValue();
System.out.println(jobName + " - " + result.getStatus());
// MyJob-1719953889301 - Succeeded
```

### List Deidentification Jobs

List and process deidentification jobs

```java com.azure.health.deidentification.sync.listjobs
PagedIterable<DeidentificationJob> jobs = deidentificationClient.listJobs();
for (DeidentificationJob currentJob : jobs) {
System.out.println(currentJob.getName() + " - " + currentJob.getStatus());
// MyJob-1719953889301 - Succeeded
}
```

### List completed files

List the files which are completed by a job.

```java com.azure.health.deidentification.sync.listcompletedfiles
PagedIterable<DocumentDetails> reports = deidentificationClient.listJobDocuments(jobName);

for (DocumentDetails currentFile : reports) {
System.out.println(currentFile.getId() + " - " + currentFile.getOutput().getPath());
// c45dcd5e-e3ce-4ff2-80b6-a8bbeb47f878 - _output/MyJob-1719954393623/example_patient_1/visit_summary.txt
// e55a1aa2-8eba-4515-b070-1fd3d005008b - _output/MyJob-1719954393623/example_patient_1/doctor_dictation.txt
}
```



## Troubleshooting

## Next steps

## Contributing

For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md).

1. Fork it
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
1. Create new Pull Request

<!-- LINKS -->
[product_documentation]: https://azure.microsoft.com/services/
[docs]: https://azure.github.io/azure-sdk-for-java/
[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/
[azure_subscription]: https://azure.microsoft.com/free/
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fhealthdataaiservices%2Fazure-health-deidentification%2FREADME.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/healthdataaiservices/azure-health-deidentification",
"Tag": "java/healthdataaiservices/azure-health-deidentification_aca7da2fcc"
}
96 changes: 96 additions & 0 deletions sdk/healthdataaiservices/azure-health-deidentification/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!--
~ Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
Code generated by Microsoft (R) TypeSpec Code Generator.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.azure</groupId>
<artifactId>azure-client-sdk-parent</artifactId>
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
</parent>

<groupId>com.azure</groupId>
<artifactId>azure-health-deidentification</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-health-deidentification;current} -->
<packaging>jar</packaging>

<name>Microsoft Azure SDK for Deidentification</name>
<description>This package contains Microsoft Azure Deidentification client library.</description>
<url>https://github.com/Azure/azure-sdk-for-java</url>

<licenses>
<license>
<name>The MIT License (MIT)</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/Azure/azure-sdk-for-java</url>
<connection>scm:git:git@github.com:Azure/azure-sdk-for-java.git</connection>
<developerConnection>scm:git:git@github.com:Azure/azure-sdk-for-java.git</developerConnection>
<tag>HEAD</tag>
</scm>
<developers>
<developer>
<id>microsoft</id>
<name>Microsoft</name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-json</artifactId>
<version>1.1.0</version> <!-- {x-version-update;com.azure:azure-json;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-xml</artifactId>
<version>1.0.0</version> <!-- {x-version-update;com.azure:azure-xml;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.50.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
<version>1.15.2</version> <!-- {x-version-update;com.azure:azure-core-http-netty;dependency} -->
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-api;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.26.1</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.13.1</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version> <!-- {x-version-update;org.slf4j:slf4j-simple;external_dependency} -->
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.health.deidentification;

import com.azure.core.util.ServiceVersion;

/**
* Service version of DeidServicesClient.
*/
public enum DeidServicesServiceVersion implements ServiceVersion {
/**
* Enum value 2024-07-12-preview.
*/
V2024_07_12_PREVIEW("2024-07-12-preview");

private final String version;

DeidServicesServiceVersion(String version) {
this.version = version;
}

/**
* {@inheritDoc}
*/
@Override
public String getVersion() {
return this.version;
}

/**
* Gets the latest service version supported by this client library.
*
* @return The latest {@link DeidServicesServiceVersion}.
*/
public static DeidServicesServiceVersion getLatest() {
return V2024_07_12_PREVIEW;
}
}
Loading

0 comments on commit b714f86

Please sign in to comment.