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.
ATTRIBUTE | DESCRIPTION |
---|---|
overwrite |
Flag to determine if existing data should be overwritten when updating the CDA document.
TYPE:
|
cda_doc |
The parsed CDA document.
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
13 14 15 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 120 121 122 123 124 125 126 127 128 |
|
input(in_data)
Parse the input CDA document and extract clinical data.
This method takes a CdaRequest object containing the CDA document as input, parses it using the CdaAnnotator, and extracts relevant clinical data. The extracted data is then used to create a CcdData object and a healthchain Document object, which is returned.
PARAMETER | DESCRIPTION |
---|---|
in_data
|
The input request containing the CDA document.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Document
|
A Document object containing the extracted clinical data and the original note text.
TYPE:
|
Source code in healthchain/io/cdaconnector.py
output(out_data)
Update the CDA document with new data and return the response.
This method takes a Document object containing updated clinical data, updates the CDA document with this new information, and returns a CdaResponse object with the updated CDA document.
PARAMETER | DESCRIPTION |
---|---|
out_data
|
A Document object containing the updated clinical data (problems, allergies, medications).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CdaResponse
|
A response object containing the updated CDA document.
TYPE:
|
Note
The method updates the CDA document with new problems, allergies,
and medications if they are present in the input Document object.
The update behavior (overwrite or append) is determined by the
overwrite
attribute of the CdaConnector instance.
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
input(in_data)
Converts a CDSRequest object into a Document object containing FHIR resources.
This method takes a CDSRequest object as input, extracts the context and prefetch data, and creates a CdsFhirData object. It then returns a Document object containing the FHIR data and any extracted text content from DocumentReference resources.
PARAMETER | DESCRIPTION |
---|---|
in_data
|
The input CDSRequest object containing context and prefetch data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Document
|
A Document object with the following attributes: - data: Either a string representation of the prefetch data, or if a DocumentReference is present, the text content from that resource - hl7: Contains the CdsFhirData object with context and prefetch data
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If neither prefetch nor fhirServer is provided in the input data |
NotImplementedError
|
If fhirServer is provided (not yet implemented) |
ValueError
|
If the provided prefetch data is invalid |
Note
The method currently only supports prefetch data and does not handle FHIR server interactions. When a DocumentReference resource is present in the prefetch data, its text content will be extracted and stored as the Document's data field.
Source code in healthchain/io/cdsfhirconnector.py
output(out_data)
Generates a CDSResponse object from a processed Document object.
This method takes a Document object that has been processed and potentially contains CDS cards and system actions. It creates and returns a CDSResponse object based on the contents of the Document.
PARAMETER | DESCRIPTION |
---|---|
out_data
|
A Document object potentially containing CDS cards and system actions.
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:
|
Note
- If out_data.cds_cards is None, a warning is logged and an empty list of cards is returned.
- System actions (out_data.cds_actions) are included in the response if present.