You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Regenerated for stable API version
* Custom methods
* Customization WIP
* Add client methods
* Overrides for async client
* Update tests for new API spec
* AttributeError: 'DeidentificationClient' object has no attribute 'begin_deidentify_documents'
* Internal operations!
* Still missing client method
* Update tests for job refactor
* Inheritance for customizations
* Model imports
* Add kwargs for maxpagesize
* Add @distributed_trace
* Fix pylint-next errors/warnings
* Update configuration files
* Changelog update
* Updating tests for new API version
* Pagination test, fixes for urls
* work in progress test sanitizing
* Regenerated for stable API version
* Custom methods
* Customization WIP
* Add client methods
* Overrides for async client
* Update tests for new API spec
* AttributeError: 'DeidentificationClient' object has no attribute 'begin_deidentify_documents'
* Internal operations!
* Still missing client method
* Update tests for job refactor
* Inheritance for customizations
* Model imports
* Add kwargs for maxpagesize
* Add @distributed_trace
* Fix pylint-next errors/warnings
* Update configuration files
* Changelog update
* Updating tests for new API version
* Pagination test, fixes for urls
* work in progress test sanitizing
* Tests running against latest TypeSpec
* Update TypeSpec before customizations
* Pull in SDK client name updates
* Update changelog and samples
* update changelog to unreleased
* remove unreleased beta version from changelog
* Updating version to 1.0.0
* Update README, samples
* Update spelling
* Separate samples for each operation
* adding black formatting
* update snippets after black formatting
* Update generated code
* Updating TypeSpec commit
---------
Co-authored-by: Alexa Thomases <athomases@microsoft.com>
Co-authored-by: Mike Soennichsen <msoennichsen@microsoft.com>
Co-authored-by: Josiah Vinson <jovinson@microsoft.com>
You can use [DefaultAzureCredential][default_azure_credential] to automatically find the best credential to use at runtime.
23
45
24
-
To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip]
46
+
You will need a **service URL** to instantiate a client object. You can find the service URL for a particular resource in the [Azure portal][azure_portal], or using the [Azure CLI][azure_cli]:
25
47
26
-
After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
27
-
As an example, [DefaultAzureCredential][default_azure_credential] can be used to authenticate the client:
48
+
```bash
49
+
# Get the service URL for the resource
50
+
az deidservice show --name "<resource-name>" --resource-group "<resource-group-name>" --query "properties.serviceUrl"
51
+
```
28
52
29
-
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
- Tag: Will return a structure of offset and length with the PHI category of the related text spans.
44
-
- Redact: Will return output text with placeholder stubbed text. ex. `[name]`
45
-
- Surrogate: Will return output text with synthetic replacements.
46
-
-`My name is John Smith`
47
-
-`My name is Tom Jones`
68
+
### De-identification operations:
69
+
Given an input text, the de-identification service can perform three main operations:
70
+
-`Tag` returns the category and location within the text of detected PHI entities.
71
+
-`Redact` returns output text where detected PHI entities are replaced with placeholder text. For example `John` replaced with `[name]`.
72
+
-`Surrogate` returns output text where detected PHI entities are replaced with realistic replacement values. For example, `My name is John Smith` could become `My name is Tom Jones`.
73
+
74
+
### Available endpoints
75
+
There are two ways to interact with the de-identification service. You can send text directly, or you can create jobs
76
+
to de-identify documents in Azure Storage.
77
+
78
+
You can de-identify text directly using the `DeidentificationClient`:
print(f'Surrogated Text: "{result.output_text}"') # Surrogated output: Hello, my name is <synthetic name>.
86
+
```
87
+
88
+
<!-- END SNIPPET -->
89
+
90
+
To de-identify documents in Azure Storage, see [Tutorial: Configure Azure Storage to de-identify documents][deid_configure_storage]
91
+
for prerequisites and configuration options.
92
+
93
+
To run the sample code below, populate the following environment variables:
94
+
-`AZURE_STORAGE_ACCOUNT_LOCATION`: an Azure Storage container endpoint, like `https://<storageaccount>.blob.core.windows.net/<container>`.
95
+
-`INPUT_PREFIX`: the prefix of the input document name(s) in the container. For example, providing `folder1` would create a job that would process documents like `https://<storageaccount>.blob.core.windows.net/<container>/folder1/document1.txt`
96
+
97
+
The client exposes a `begin_deidentify_documents` method that returns a [LROPoller](https://learn.microsoft.com/python/api/azure-core/azure.core.polling.lropoller) instance. You can get the result of the operation by calling `result()`, optionally passing in a `timeout` value in seconds:
print(f"File Count: {finished_job.summary.total_count if finished_job.summary isnotNoneelse0}")
125
+
```
126
+
127
+
<!-- END SNIPPET -->
56
128
57
129
## Examples
130
+
The following sections provide code samples covering some of the most common client use cases, including:
131
+
132
+
-[Discover PHI in unstructured text](#discover-phi-in-unstructured-text)
133
+
-[Replace PHI in unstructured text with placeholder values](#replace-phi-in-unstructured-text-with-placeholder-values)
134
+
-[Replace PHI in unstructured text with realistic surrogate values](#replace-phi-in-unstructured-text-with-realistic-surrogate-values)
135
+
136
+
See the [samples][samples] for code files illustrating common patterns, including creating and managing jobs to de-identify documents in Azure Storage.
137
+
138
+
### Discover PHI in unstructured text
139
+
When you specify the `TAG` operation, the service will return information about the PHI entities it detects. You can use this information to customize your de-identification workflow:
### Replace PHI in unstructured text with placeholder values
162
+
When you specify the `REDACT` operation, the service will replace the PHI entities it detects with placeholder values. You can learn more about [redaction customization][deid_redact].
163
+
<!-- SNIPPET: deidentify_text_redact.redact -->
69
164
165
+
```python
166
+
body = DeidentificationContent(
167
+
input_text="It's great to work at Contoso.", operation_type=DeidentificationOperationType.REDACT
print(f'Redacted Text: "{result.output_text}"') # Redacted output: "It's great to work at [organization]."
70
172
```
71
173
72
-
## Next steps
174
+
<!-- END SNIPPET -->
73
175
74
-
- Find a bug, or have feedback? Raise an issue with "Health Deidentification" Label.
176
+
### Replace PHI in unstructured text with realistic surrogate values
177
+
The default operation is the `SURROGATE` operation. Using this operation, the service will replace the PHI entities it detects with realistic surrogate values:
0 commit comments