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
Copy file name to clipboardExpand all lines: README.md
+34-22Lines changed: 34 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ First time here? Check out our [Docs](https://dotimplement.github.io/HealthChain
21
21
22
22
## Features
23
23
-[x] 🛠️ Build custom pipelines or use [pre-built ones](https://dotimplement.github.io/HealthChain/reference/pipeline/pipeline/#prebuilt) for your healthcare NLP and ML tasks
24
-
-[x] 🏗️ Add built-in CDA and FHIR parsers to connect your pipeline to interoperability standards
24
+
-[x] 🏗️ Add built-in [CDA and FHIR parsers](https://dotimplement.github.io/HealthChain/reference/utilities/cda_parser/) to connect your pipeline to interoperability standards
25
25
-[x] 🧪 Test your pipelines in full healthcare-context aware [sandbox](https://dotimplement.github.io/HealthChain/reference/sandbox/sandbox/) environments
26
26
-[x] 🗃️ Generate [synthetic healthcare data](https://dotimplement.github.io/HealthChain/reference/utilities/data_generator/) for testing and development
27
27
-[x] 🚀 Deploy sandbox servers locally with [FastAPI](https://fastapi.tiangolo.com/)
@@ -33,7 +33,7 @@ First time here? Check out our [Docs](https://dotimplement.github.io/HealthChain
33
33
-**Built by health tech developers, for health tech developers** - HealthChain is tech stack agnostic, modular, and easily extensible.
34
34
35
35
## Pipeline
36
-
Pipelines provide a flexible way to build and manage processing pipelines for NLP and ML tasks that can easily interface with parsers and connectors to integrate with EHRs.
36
+
Pipelines provide a flexible way to build and manage processing pipelines for NLP and ML tasks that can easily integrate with complex healthcare systems.
37
37
38
38
### Building a pipeline
39
39
@@ -70,21 +70,39 @@ result = nlp(Document("Patient has a history of heart attack and high blood pres
70
70
71
71
print(f"Entities: {result.entities}")
72
72
```
73
+
74
+
#### Adding connectors
75
+
Connectors give your pipelines the ability to interface with EHRs.
76
+
77
+
```python
78
+
from healthchain.io import CdaConnector
79
+
from healthchain.models import CdaRequest
80
+
81
+
cda_connector = CdaConnector()
82
+
83
+
pipeline.add_input(cda_connector)
84
+
pipeline.add_output(cda_connector)
85
+
86
+
pipe = pipeline.build()
87
+
88
+
cda_data = CdaRequest(document="<CDA XML content>")
89
+
output = pipe(cda_data)
90
+
```
91
+
73
92
### Using pre-built pipelines
93
+
Pre-built pipelines are use case specific end-to-end workflows that already have connectors and models built-in.
74
94
75
95
```python
76
-
from healthchain.io.containers import Document
77
96
from healthchain.pipeline import MedicalCodingPipeline
The `CdaAnnotator` class is responsible for parsing and annotating CDA (Clinical Document Architecture) documents. It extracts information about problems, medications, allergies, and notes from the CDA document, and allows you to add new information to the CDA document.
4
+
5
+
The CDA parser is used in the [CDA Connector](../pipeline/connectors/cdaconnector.md) module, but can also be used independently.
6
+
7
+
Internally, `CdaAnnotator` parses CDA documents from XML strings to a dictionary-based representation using `xmltodict` and uses Pydantic for data validation. New problems are added to the CDA document using a template-based approach. It's currently not super configurable, but we're working on it.
8
+
9
+
Data interacts with the `CdaAnnotator` through `Concept` data models, which are designed to be an system-agnostic intermediary between FHIR and CDA data representations.
10
+
11
+
[(CdaAnnotator API Reference](../../api/cda_parser.md)[| Concept API Reference)](../../api/data_models.md#healthchain.models.data.concept)
12
+
13
+
## Usage
14
+
15
+
### Parsing CDA documents
16
+
17
+
Parse a CDA document from an XML string:
18
+
19
+
```python
20
+
from healthchain.cda_parser import CdaAnnotator
21
+
22
+
cda = CdaAnnotator.from_xml(cda_xml_string)
23
+
24
+
problems = cda.problem_list
25
+
medications = cda.medication_list
26
+
allergies = cda.allergy_list
27
+
note = cda.note
28
+
29
+
print([problem.name for problem in problems])
30
+
print([medication.name for medication in medications])
31
+
print([allergy.name for allergy in allergies])
32
+
print(note)
33
+
```
34
+
35
+
You can access data parsed from the CDA document in the `problem_list`, `medication_list`, `allergy_list`, and `note` attributes of the `CdaAnnotator` instance. They return a list of `Concept` data models.
36
+
37
+
### Adding new information to the CDA document
38
+
39
+
The methods currently available for adding new information to the CDA document are:
40
+
41
+
| Method | Description |
42
+
|--------|-------------|
43
+
|`.add_to_problem_list()`| Adds a list of [ProblemConcept](../../api/data_models.md#healthchain.models.data.concept.ProblemConcept)|
44
+
|`.add_to_medication_list()`| Adds a list of [MedicationConcept](../../api/data_models.md#healthchain.models.data.concept.MedicationConcept)|
45
+
|`.add_to_allergy_list()`| Adds a list of [AllergyConcept](../../api/data_models.md#healthchain.models.data.concept.AllergyConcept)|
46
+
47
+
The `overwrite` parameter in the `add_to_*_list()` methods is used to determine whether to overwrite the existing list or append to it. If `overwrite` is `True`, the existing list will be replaced with the new list. If `overwrite` is `False`, the new list will be appended to the existing list.
48
+
49
+
Depending on the use case, you don't always need to return the original list of information in the CDA document you receive, although this is mostly useful if you are just developing and don't want the eye-strain of a lengthy CDA document.
50
+
51
+
### Exporting the CDA document
52
+
53
+
```python
54
+
xml_string = cda.export(pretty_print=True)
55
+
```
56
+
57
+
The `pretty_print` parameter is optional and defaults to `True`. If `pretty_print` is `True`, the XML string will be formatted with newlines and indentation.
58
+
59
+
## Example
60
+
61
+
```python
62
+
from healthchain.cda_parser import CdaAnnotator
63
+
from healthchain.models import ProblemConcept, MedicationConcept, AllergyConcept
The CDA parser is a work in progress. I'm just gonna be real with you, CDAs are the bane of my existence. If you, for some reason, love working with XML-based documents, please get [in touch](https://discord.gg/UQC6uAepUz)! We have plans to implement more functionality in the future, including allowing configurable templates, more CDA section methods, and using LLMs as a fallback parsing method.
0 commit comments