Connectors
BaseConnector
Bases: Generic[T]
, ABC
Abstract base class for all connectors in the pipeline.
This class should be subclassed to create specific connectors. Subclasses must implement the input and output methods.
Source code in healthchain/io/base.py
input(data)
abstractmethod
Convert input data to the pipeline's internal format.
PARAMETER | DESCRIPTION |
---|---|
data
|
The input data to be converted.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataContainer[T]
|
DataContainer[T]: The converted data. |
Source code in healthchain/io/base.py
output(data)
abstractmethod
Convert pipeline's internal format to output data.
PARAMETER | DESCRIPTION |
---|---|
data
|
The data to be converted for output.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataContainer[T]
|
DataContainer[T]: The converted output data. |
Source code in healthchain/io/base.py
CdaConnector
Bases: BaseConnector
CDAConnector class for handling CDA (Clinical Document Architecture) documents.
This connector is responsible for parsing CDA documents, extracting relevant clinical data, and updating the document with new information. It serves as both an input and output connector in the pipeline.
The connector uses the InteropEngine to convert between CDA and FHIR formats, preserving the clinical content while allowing for manipulation of the data within the HealthChain pipeline.
ATTRIBUTE | DESCRIPTION |
---|---|
engine |
The interoperability engine for CDA conversions.
TYPE:
|
original_cda |
The original CDA document for use in output.
TYPE:
|
note_document_reference |
Reference to the note document extracted from the CDA.
TYPE:
|
METHOD | DESCRIPTION |
---|---|
input |
Parses the input CDA document and extracts clinical data. |
output |
Updates the CDA document with new data and returns the response. |
Source code in healthchain/io/cdaconnector.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
input(cda_request)
Parse the input CDA document and extract clinical data into a HealthChain Document object.
This method takes a CdaRequest object as input, parses it using the InteropEngine to convert CDA to FHIR resources, and creates a Document object with the extracted data. It creates a DocumentReference for the original CDA XML and extracts clinical data (problems, medications, allergies) into FHIR resources.
PARAMETER | DESCRIPTION |
---|---|
cda_request
|
Request object containing the CDA XML document to process.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Document
|
A Document object containing: - The extracted note text as the document data - FHIR resources organized into appropriate lists: - problem_list: List of Condition resources - medication_list: List of MedicationStatement resources - allergy_list: List of AllergyIntolerance resources - DocumentReference resources for the original CDA and extracted notes with a parent-child relationship
TYPE:
|
Note
If a DocumentReference resource is found in the converted FHIR resources, it is assumed to contain the note text and is stored for later use.
Source code in healthchain/io/cdaconnector.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
output(document)
Convert FHIR resources back to CDA format and return the response.
This method takes a Document object containing FHIR resources (problems, medications, allergies) and converts them back to CDA format using the InteropEngine. It combines all resources from the document's FHIR lists and includes the note document reference if available.
PARAMETER | DESCRIPTION |
---|---|
document
|
A Document object containing FHIR resources in problem_list, medication_list, and allergy_list.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CdaResponse
|
A response object containing the CDA document generated from the FHIR resources.
TYPE:
|
Source code in healthchain/io/cdaconnector.py
CdsFhirConnector
Bases: BaseConnector
CdsFhirConnector class for handling FHIR (Fast Healthcare Interoperability Resources) documents for CDS Hooks.
This connector facilitates the conversion between CDSRequest objects and Document objects, as well as the creation of CDSResponse objects from processed Documents.
ATTRIBUTE | DESCRIPTION |
---|---|
hook_name |
The name of the CDS Hook being used.
TYPE:
|
Source code in healthchain/io/cdsfhirconnector.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
input(cds_request, prefetch_document_key='document')
Converts a CDSRequest object into a Document object.
Takes a CDSRequest containing FHIR resources and extracts them into a Document object. The Document will contain all prefetched FHIR resources in its fhir.prefetch_resources. If a DocumentReference resource is provided via prefetch_document_key, its text content will be extracted into Document.data. For multiple attachments, the text content will be concatenated with newlines.
PARAMETER | DESCRIPTION |
---|---|
cds_request
|
The CDSRequest containing FHIR resources in its prefetch and/or a FHIR server URL.
TYPE:
|
prefetch_document_key
|
Key in the prefetch data containing a DocumentReference resource whose text content should be extracted. Defaults to "document".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Document
|
A Document object containing: - All prefetched FHIR resources in fhir.prefetch_resources - Any text content from the DocumentReference in data (empty string if none found) - For multiple attachments, text content is concatenated with newlines
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If neither prefetch nor fhirServer is provided in cds_request |
ValueError
|
If the prefetch data is invalid or cannot be processed |
NotImplementedError
|
If fhirServer is provided (FHIR server support not implemented) |
Source code in healthchain/io/cdsfhirconnector.py
output(document)
Convert Document to CDSResponse.
This method takes a Document object containing CDS cards and actions, and converts them into a CDSResponse object that follows the CDS Hooks specification.
PARAMETER | DESCRIPTION |
---|---|
document
|
The Document object containing CDS results.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CDSResponse
|
A response object containing CDS cards and optional system actions. If no cards are found in the Document, an empty list of cards is returned.
TYPE:
|