Skip to content

Commit a750b58

Browse files
SDK implementation for Radiology Insights (in public preview) (#34317)
* init * Create async_sample.py * Create sample_critical_result_inference_async.py adding sample * Delete async_sample.py removed old async sample * Adding tests folder with samples and update README * cleanup of README links, adding changelog and add ci.yml entry * Code cleanup based on Black * Create sdk_packaging.toml * Update cspell.json * Update README.md * Update _models.py * pylint fixes adding pylint exclusions * addition of testing rewrote testclass & added playback functionality through assets repo * updating assets.json with new recordings and adressing review comments updating assets.json with new recordings and adressing review comments * adding sync tests and samples * adressing reviewer comments adressing reviewer comments * test fixes fix test issues in playback mode * remove dependency remove pytz dependency * add ignore for non-radiology insights projects & fix non-existing module * ignore pyright in non RI packages ignoring pyright errors in non radiology insights packages * fixing some additional reviewer comments * SDK generated with latest typespec * fix ci issues * clean up samples clean up samples --------- Co-authored-by: Asaf Levi <[email protected]>
1 parent 472f0e4 commit a750b58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+12770
-1
lines changed

.vscode/cspell.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@
451451
"aiter",
452452
"solft",
453453
"amltmp",
454-
"amltemp"
454+
"amltemp",
455+
"deserializers",
456+
"dicom",
455457
],
456458
"overrides": [
457459
{
@@ -1706,6 +1708,17 @@
17061708
"ctxt",
17071709
"wday"
17081710
]
1711+
},
1712+
{
1713+
"filename": "sdk/healthinsights/azure-healthinsights-radiologyinsights/**",
1714+
"words": [
1715+
"ctxt",
1716+
"mros",
1717+
"Nify",
1718+
"loinc",
1719+
"wday",
1720+
"SNOMED"
1721+
]
17091722
}
17101723
],
17111724
"allowCompoundWords": true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.azure-sdk-build]
2+
pylint = false
3+
pyright = false
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.azure-sdk-build]
2+
pylint = false
3+
pyright = false
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0b1 (2024-02-23)
4+
5+
- Initial version
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include *.md
2+
include LICENSE
3+
include azure/healthinsights/radiologyinsights/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
7+
include azure/healthinsights/__init__.py
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Azure Cognitive Services Health Insights Radiology Insights client library for Python
2+
[Health Insights][health_insights] is an Azure Applied AI Service built with the Azure Cognitive Services Framework, that leverages multiple Cognitive Services, Healthcare API services and other Azure resources.
3+
4+
[Radiology Insights][radiology_insights_docs] is a model that aims to provide quality checks as feedback on errors and inconsistencies (mismatches) and ensures critical findings are identified and communicated using the full context of the report. Follow-up recommendations and clinical findings with measurements (sizes) documented by the radiologist are also identified.
5+
6+
## Getting started
7+
8+
### Prequisites
9+
10+
- Python 3.8 or later is required to use this package.
11+
- You need an [Azure subscription][azure_sub] to use this package.
12+
- An existing Cognitive Services Health Insights instance.
13+
14+
For more information about creating the resource or how to get the location and sku information see [here][cognitive_resource_cli].
15+
16+
### Installing the module
17+
18+
```bash
19+
python -m pip install azure-healthinsights-radiologyinsights
20+
```
21+
This table shows the relationship between SDK versions and supported API versions of the service:
22+
23+
| SDK version | Supported API version of service |
24+
|-------------|----------------------------------|
25+
| 1.0.0b1 | 2023-09-01-preview |
26+
27+
28+
### Authenticate the client
29+
30+
#### Get the endpoint
31+
32+
You can find the endpoint for your Health Insights service resource using the [Azure Portal][azure_portal] or [Azure CLI][azure_cli]
33+
34+
35+
```bash
36+
# Get the endpoint for the Health Insights service resource
37+
az cognitiveservices account show --name "resource-name" --resource-group "resource-group-name" --query "properties.endpoint"
38+
```
39+
40+
#### Get the API Key
41+
42+
You can get the **API Key** from the Health Insights service resource in the Azure Portal.
43+
Alternatively, you can use **Azure CLI** snippet below to get the API key of your resource.
44+
45+
```PowerShell
46+
az cognitiveservices account keys list --resource-group <your-resource-group-name> --name <your-resource-name>
47+
```
48+
49+
#### Create a RadiologyInsightsClient with an API Key Credential
50+
51+
Once you have the value for the API key, you can pass it as a string into an instance of **AzureKeyCredential**. Use the key as the credential parameter to authenticate the client:
52+
53+
<!-- SNIPPET:sample_critical_result_inference_async.create_radiology_insights_client-->
54+
```python
55+
import os
56+
from azure.core.credentials import AzureKeyCredential
57+
from azure.healthinsights.radiologyinsights import RadiologyInsightsClient
58+
59+
KEY = os.environ["AZURE_HEALTH_INSIGHTS_API_KEY"]
60+
ENDPOINT = os.environ["AZURE_HEALTH_INSIGHTS_ENDPOINT"]
61+
62+
radiology_insights_client = RadiologyInsightsClient(endpoint=ENDPOINT, credential=AzureKeyCredential(KEY))
63+
```
64+
<!-- SNIPPET:sample_critical_result_inference_async.create_radiology_insights_client-->
65+
66+
### Long-Running Operations
67+
68+
Long-running operations are operations which consist of an initial request sent to the service to start an operation,
69+
followed by polling the service at intervals to determine whether the operation has completed or failed, and if it has
70+
succeeded, to get the result.
71+
72+
Methods that support healthcare analysis, custom text analysis, or multiple analyses are modeled as long-running operations.
73+
The client exposes a `begin_<method-name>` method that returns a poller object. Callers should wait
74+
for the operation to complete by calling `result()` on the poller object returned from the `begin_<method-name>` method.
75+
Sample code snippets are provided to illustrate using long-running operations [below](#examples "Examples").
76+
77+
## Key concepts
78+
79+
Radiology Insights currently supports one document from one patient. Please take a look [here][inferences] for more detailed information about the inferences this service produces.
80+
81+
## Examples
82+
83+
### Create a RadiologyInsights request and get the result using an asynchronous client
84+
85+
For an example how to create a client, a request and get the result see the example in the sample folder.
86+
87+
### Get Critical Result Inference information
88+
89+
<!-- SNIPPET:sample_critical_result_inference_async.display_critical_results-->
90+
```python
91+
for patient_result in radiology_insights_result.patient_results:
92+
for ri_inference in patient_result.inferences:
93+
if (
94+
ri_inference.kind
95+
== models.RadiologyInsightsInferenceType.CRITICAL_RESULT
96+
):
97+
critical_result = ri_inference.result
98+
print(
99+
f"Critical Result Inference found: {critical_result.description}"
100+
)
101+
```
102+
<!-- SNIPPET:sample_critical_result_inference_async.display_critical_results-->
103+
104+
For detailed conceptual information of this and other inferences please read more [here][inferences].
105+
106+
## Troubleshooting
107+
108+
### General
109+
110+
Health Insights Radiology Insights client library will raise exceptions defined in [Azure Core][azure_core].
111+
112+
### Logging
113+
114+
This library uses the standard [logging](https://docs.python.org/3/library/logging.html) library for logging.
115+
116+
Basic information about HTTP sessions (URLs, headers, etc.) is logged at `INFO` level.
117+
118+
Detailed `DEBUG` level logging, including request/response bodies and **unredacted**
119+
headers, can be enabled on the client or per-operation with the `logging_enable` keyword argument.
120+
121+
See full SDK logging documentation with examples [here](https://learn.microsoft.com/azure/developer/python/sdk/azure-sdk-logging).
122+
123+
## Next steps
124+
125+
## Contributing
126+
127+
This project welcomes contributions and suggestions. Most contributions require
128+
you to agree to a Contributor License Agreement (CLA) declaring that you have
129+
the right to, and actually do, grant us the rights to use your contribution.
130+
For details, visit https://cla.microsoft.com.
131+
132+
When you submit a pull request, a CLA-bot will automatically determine whether
133+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
134+
comment). Simply follow the instructions provided by the bot. You will only
135+
need to do this once across all repos using our CLA.
136+
137+
This project has adopted the
138+
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
139+
see the Code of Conduct FAQ or contact <[email protected]> with any
140+
additional questions or comments.
141+
142+
<!-- LINKS -->
143+
[health_insights]: https://learn.microsoft.com/azure/azure-health-insights/overview
144+
[radiology_insights_docs]: https://learn.microsoft.com/azure/azure-health-insights/radiology-insights/
145+
[azure_sub]: https://azure.microsoft.com/free/
146+
[cognitive_resource_cli]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli
147+
[azure_portal]: https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesHealthInsights
148+
[azure_cli]: https://learn.microsoft.com/cli/azure/
149+
[inferences]: https://learn.microsoft.com/azure/azure-health-insights/radiology-insights/inferences
150+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "python",
4+
"TagPrefix": "python/healthinsights/azure-healthinsights-radiologyinsights",
5+
"Tag": "python/healthinsights/azure-healthinsights-radiologyinsights_69d7fab8d7"
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

0 commit comments

Comments
 (0)