|
10 | 10 |
|
11 | 11 | </div>
|
12 | 12 |
|
13 |
| -Build simple, portable, and scalable AI and NLP applications in a healthcare context π« π₯. |
| 13 | +Connect your AI models to any healthcare system with a few lines of Python π« π₯. |
| 14 | + |
| 15 | +Integrating AI with electronic health records (EHRs) is complex, manual, and time-consuming. Let's try to change that. |
14 | 16 |
|
15 |
| -Integrating electronic health record systems (EHRs) data is complex, and so is designing reliable, reactive algorithms involving unstructured healthcare data. Let's try to change that. |
16 | 17 |
|
17 | 18 | ```bash
|
18 | 19 | pip install healthchain
|
19 | 20 | ```
|
20 | 21 | First time here? Check out our [Docs](https://dotimplement.github.io/HealthChain/) page!
|
21 | 22 |
|
22 |
| -Came here from NHS RPySOC 2024 β¨? |
23 |
| -[CDS sandbox walkthrough](https://dotimplement.github.io/HealthChain/cookbook/cds_sandbox/) |
24 |
| -[Slides](https://speakerdeck.com/jenniferjiangkells/building-healthcare-context-aware-applications-with-healthchain) |
25 | 23 |
|
26 | 24 | ## Features
|
27 |
| -- [x] π₯ Build FHIR-native pipelines or use [pre-built ones](https://dotimplement.github.io/HealthChain/reference/pipeline/pipeline/#prebuilt) for your healthcare NLP and ML tasks |
28 |
| -- [x] π Connect pipelines to any EHR system with built-in [CDA and FHIR Connectors](https://dotimplement.github.io/HealthChain/reference/pipeline/connectors/connectors/) |
29 |
| -- [x] π Convert between FHIR, CDA, and HL7v2 with the [InteropEngine](https://dotimplement.github.io/HealthChain/reference/interop/interop/) |
30 |
| -- [x] π§ͺ Test your pipelines in full healthcare-context aware [sandbox](https://dotimplement.github.io/HealthChain/reference/sandbox/sandbox/) environments |
31 |
| -- [x] ποΈ Generate [synthetic healthcare data](https://dotimplement.github.io/HealthChain/reference/utilities/data_generator/) for testing and development |
32 |
| -- [x] π Deploy sandbox servers locally with [FastAPI](https://fastapi.tiangolo.com/) |
| 25 | +- [x] π **Gateway**: Connect to multiple EHR systems with [unified API](https://dotimplement.github.io/HealthChain/reference/gateway/gateway/) supporting FHIR, CDS Hooks, and SOAP/CDA protocols |
| 26 | +- [x] π₯ **Pipelines**: Build FHIR-native ML workflows or use [pre-built ones](https://dotimplement.github.io/HealthChain/reference/pipeline/pipeline/#prebuilt) for your healthcare NLP and AI tasks |
| 27 | +- [x] π **InteropEngine**: Convert between FHIR, CDA, and HL7v2 with a [template-based engine](https://dotimplement.github.io/HealthChain/reference/interop/interop/) |
| 28 | +- [x] π Type-safe healthcare data with full type hints and Pydantic validation for [FHIR resources](https://dotimplement.github.io/HealthChain/reference/utilities/fhir_helpers/) |
| 29 | +- [x] β‘ Event-driven architecture with real-time event handling and [audit trails](https://dotimplement.github.io/HealthChain/reference/gateway/events/) built-in |
| 30 | +- [x] π Deploy production-ready applications with [HealthChainAPI](https://dotimplement.github.io/HealthChain/reference/gateway/api/) and FastAPI integration |
| 31 | +- [x] π§ͺ Generate [synthetic healthcare data](https://dotimplement.github.io/HealthChain/reference/utilities/data_generator/) and [sandbox testing](https://dotimplement.github.io/HealthChain/reference/sandbox/sandbox/) utilities |
33 | 32 |
|
34 | 33 | ## Why use HealthChain?
|
35 |
| -- **EHR integrations are manual and time-consuming** - HealthChain abstracts away complexities so you can focus on AI development, not EHR configurations. |
36 |
| -- **It's difficult to track and evaluate multiple integration instances** - HealthChain provides a framework to test the real-world resilience of your whole system, not just your models. |
37 |
| -- [**Most healthcare data is unstructured**](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6372467/) - HealthChain is optimized for real-time AI and NLP applications that deal with realistic healthcare data. |
38 |
| -- **Built by health tech developers, for health tech developers** - HealthChain is tech stack agnostic, modular, and easily extensible. |
| 34 | +- **EHR integrations are manual and time-consuming** - **HealthChainAPI** abstracts away complexities so you can focus on AI development, not learning FHIR APIs, CDS Hooks, and authentication schemes. |
| 35 | +- **Healthcare data is fragmented and complex** - **InteropEngine** handles the conversion between FHIR, CDA, and HL7v2 so you don't have to become an expert in healthcare data standards. |
| 36 | +- [**Most healthcare data is unstructured**](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6372467/) - HealthChain **Pipelines** are optimized for real-time AI and NLP applications that deal with realistic healthcare data. |
| 37 | +- **Built by health tech developers, for health tech developers** - HealthChain is tech stack agnostic, modular, and easily extensible with built-in compliance and audit features. |
| 38 | + |
| 39 | +## HealthChainAPI |
| 40 | + |
| 41 | +The HealthChainAPI provides a secure, asynchronous integration layer that coordinates multiple healthcare systems in a single application. |
| 42 | + |
| 43 | +### Multi-Protocol Support |
| 44 | + |
| 45 | +Connect to multiple healthcare data sources and protocols: |
| 46 | + |
| 47 | +```python |
| 48 | +from healthchain.gateway import ( |
| 49 | + HealthChainAPI, FHIRGateway, |
| 50 | + CDSHooksService, NoteReaderService |
| 51 | +) |
| 52 | + |
| 53 | +# Create your healthcare application |
| 54 | +app = HealthChainAPI( |
| 55 | + title="My Healthcare AI App", |
| 56 | + description="AI-powered patient care platform" |
| 57 | +) |
| 58 | + |
| 59 | +# FHIR for patient data from multiple EHRs |
| 60 | +fhir = FHIRGateway() |
| 61 | +fhir.add_source("epic", "fhir://fhir.epic.com/r4?client_id=...") |
| 62 | +fhir.add_source("medplum", "fhir://api.medplum.com/fhir/R4/?client_id=...") |
| 63 | + |
| 64 | +# CDS Hooks for real-time clinical decision support |
| 65 | +cds = CDSHooksService() |
| 66 | + |
| 67 | +@cds.hook("patient-view", id="allergy-alerts") |
| 68 | +def check_allergies(request): |
| 69 | + # Your AI logic here |
| 70 | + return {"cards": [...]} |
| 71 | + |
| 72 | +# SOAP for clinical document processing |
| 73 | +notes = NoteReaderService() |
| 74 | + |
| 75 | +@notes.method("ProcessDocument") |
| 76 | +def process_note(request): |
| 77 | + # Your NLP pipeline here |
| 78 | + return processed_document |
| 79 | + |
| 80 | +# Register everything |
| 81 | +app.register_gateway(fhir) |
| 82 | +app.register_service(cds) |
| 83 | +app.register_service(notes) |
| 84 | + |
| 85 | +# Your API now handles: |
| 86 | +# /fhir/* - Patient data, observations, etc. |
| 87 | +# /cds/* - Real-time clinical alerts |
| 88 | +# /soap/* - Clinical document processing |
| 89 | +``` |
| 90 | + |
| 91 | +### FHIR Operations with AI Enhancement |
| 92 | + |
| 93 | +```python |
| 94 | +from healthchain.gateway import FHIRGateway |
| 95 | +from fhir.resources.patient import Patient |
| 96 | + |
| 97 | +gateway = FHIRGateway() |
| 98 | +gateway.add_source("epic", "fhir://fhir.epic.com/r4?...") |
| 99 | + |
| 100 | +# Add AI transformations to FHIR data |
| 101 | +@gateway.transform(Patient) |
| 102 | +async def enhance_patient(id: str, source: str = None) -> Patient: |
| 103 | + async with gateway.modify(Patient, id, source) as patient: |
| 104 | + # Get lab results and process with AI |
| 105 | + lab_results = await gateway.search( |
| 106 | + Observation, |
| 107 | + {"patient": id, "category": "laboratory"}, |
| 108 | + source |
| 109 | + ) |
| 110 | + insights = nlp_pipeline.process(patient, lab_results) |
| 111 | + |
| 112 | + # Add AI summary to patient record |
| 113 | + patient.extension = patient.extension or [] |
| 114 | + patient.extension.append({ |
| 115 | + "url": "http://healthchain.org/fhir/summary", |
| 116 | + "valueString": insights.summary |
| 117 | + }) |
| 118 | + return patient |
| 119 | + |
| 120 | +# Automatically available at: GET /fhir/transform/Patient/123?source=epic |
| 121 | +``` |
39 | 122 |
|
40 | 123 | ## Pipeline
|
41 | 124 | Pipelines provide a flexible way to build and manage processing pipelines for NLP and ML tasks that can easily integrate with complex healthcare systems.
|
@@ -139,116 +222,40 @@ cda_data = engine.from_fhir(fhir_resources, dest_format=FormatType.CDA)
|
139 | 222 |
|
140 | 223 | ## Sandbox
|
141 | 224 |
|
142 |
| -Sandboxes provide a staging environment for testing and validating your pipeline in a realistic healthcare context. |
143 |
| - |
144 |
| -### Clinical Decision Support (CDS) |
145 |
| -[CDS Hooks](https://cds-hooks.org/) is an [HL7](https://cds-hooks.hl7.org) published specification for clinical decision support. |
146 |
| - |
147 |
| -**When is this used?** CDS hooks are triggered at certain events during a clinician's workflow in an electronic health record (EHR), e.g. when a patient record is opened, when an order is elected. |
148 |
| - |
149 |
| -**What information is sent**: the context of the event and [FHIR](https://hl7.org/fhir/) resources that are requested by your service, for example, the patient ID and information on the encounter and conditions they are being seen for. |
150 |
| - |
151 |
| -**What information is returned**: βcardsβ displaying text, actionable suggestions, or links to launch a [SMART](https://smarthealthit.org/) app from within the workflow. |
152 |
| - |
| 225 | +Test your AI applications in realistic healthcare contexts with [CDS Hooks](https://cds-hooks.org/) sandbox environments. |
153 | 226 |
|
154 | 227 | ```python
|
155 | 228 | import healthchain as hc
|
156 |
| - |
157 |
| -from healthchain.pipeline import SummarizationPipeline |
158 | 229 | from healthchain.sandbox.use_cases import ClinicalDecisionSupport
|
159 |
| -from healthchain.models import Card, Prefetch, CDSRequest |
160 |
| -from healthchain.data_generator import CdsDataGenerator |
161 |
| -from typing import List |
162 | 230 |
|
163 | 231 | @hc.sandbox
|
164 | 232 | class MyCDS(ClinicalDecisionSupport):
|
165 |
| - def __init__(self) -> None: |
166 |
| - self.pipeline = SummarizationPipeline.from_model_id( |
167 |
| - "facebook/bart-large-cnn", source="huggingface" |
168 |
| - ) |
169 |
| - self.data_generator = CdsDataGenerator() |
| 233 | + def __init__(self): |
| 234 | + self.pipeline = SummarizationPipeline.from_model_id("facebook/bart-large-cnn") |
170 | 235 |
|
171 |
| - # Sets up an instance of a mock EHR client of the specified workflow |
172 | 236 | @hc.ehr(workflow="encounter-discharge")
|
173 |
| - def ehr_database_client(self) -> Prefetch: |
| 237 | + def ehr_database_client(self): |
174 | 238 | return self.data_generator.generate_prefetch()
|
175 | 239 |
|
176 |
| - # Define your application logic here |
177 |
| - @hc.api |
178 |
| - def my_service(self, data: CDSRequest) -> CDSRequest: |
179 |
| - result = self.pipeline(data) |
180 |
| - return result |
181 |
| -``` |
182 |
| - |
183 |
| -### Clinical Documentation |
184 |
| - |
185 |
| -The `ClinicalDocumentation` use case implements a real-time Clinical Documentation Improvement (CDI) service. It helps convert free-text medical documentation into coded information that can be used for billing, quality reporting, and clinical decision support. |
186 |
| - |
187 |
| -**When is this used?** Triggered when a clinician opts in to a CDI functionality (e.g. Epic NoteReader) and signs or pends a note after writing it. |
188 |
| - |
189 |
| -**What information is sent**: A [CDA (Clinical Document Architecture)](https://www.hl7.org.uk/standards/hl7-standards/cda-clinical-document-architecture/) document which contains continuity of care data and free-text data, e.g. a patient's problem list and the progress note that the clinician has entered in the EHR. |
190 |
| - |
191 |
| -```python |
192 |
| -import healthchain as hc |
193 |
| - |
194 |
| -from healthchain.pipeline import MedicalCodingPipeline |
195 |
| -from healthchain.sandbox.use_cases import ClinicalDocumentation |
196 |
| -from healthchain.models import CdaRequest, CdaResponse |
197 |
| -from fhir.resources.documentreference import DocumentReference |
198 |
| - |
199 |
| -@hc.sandbox |
200 |
| -class NotereaderSandbox(ClinicalDocumentation): |
201 |
| - def __init__(self): |
202 |
| - self.pipeline = MedicalCodingPipeline.from_model_id( |
203 |
| - "en_core_sci_md", source="spacy" |
204 |
| - ) |
205 |
| - |
206 |
| - # Load an existing CDA file |
207 |
| - @hc.ehr(workflow="sign-note-inpatient") |
208 |
| - def load_data_in_client(self) -> DocumentReference: |
209 |
| - with open("/path/to/cda/data.xml", "r") as file: |
210 |
| - xml_string = file.read() |
211 |
| - |
212 |
| - cda_document_reference = create_document_reference( |
213 |
| - data=xml_string, |
214 |
| - content_type="text/xml", |
215 |
| - description="Original CDA Document loaded from my sandbox", |
216 |
| - ) |
217 |
| - return cda_document_reference |
218 |
| - |
219 |
| - @hc.api |
220 |
| - def my_service(self, data: CdaRequest) -> CdaResponse: |
221 |
| - annotated_ccd = self.pipeline(data) |
222 |
| - return annotated_ccd |
223 |
| -``` |
224 |
| -### Running a sandbox |
225 |
| - |
226 |
| -Ensure you run the following commands in your `mycds.py` file: |
227 |
| - |
228 |
| -```python |
229 | 240 | cds = MyCDS()
|
230 | 241 | cds.start_sandbox()
|
231 |
| -``` |
232 |
| -This will populate your EHR client with the data generation method you have defined, send requests to your server for processing, and save the data in the `./output` directory. |
233 | 242 |
|
234 |
| -Then run: |
235 |
| -```bash |
236 |
| -healthchain run mycds.py |
| 243 | +# Run with: healthchain run mycds.py |
237 | 244 | ```
|
238 |
| -By default, the server runs at `http://127.0.0.1:8000`, and you can interact with the exposed endpoints at `/docs`. |
239 | 245 |
|
240 | 246 | ## Road Map
|
241 |
| -- [x] π Transform and validate healthcare HL7v2, CDA to FHIR with template-based interop engine |
242 |
| -- [ ] π₯ Runtime connection health and EHR integration management - connect to FHIR APIs and legacy systems |
| 247 | +- [ ] π Built-in HIPAA compliance validation and PHI detection |
243 | 248 | - [ ] π Track configurations, data provenance, and monitor model performance with MLFlow integration
|
244 | 249 | - [ ] π Compliance monitoring, auditing at deployment as a sidecar service
|
245 |
| -- [ ] π Built-in HIPAA compliance validation and PHI detection |
246 |
| -- [ ] π§ Multi-modal pipelines that that have built-in NLP to utilize unstructured data |
| 250 | +- [ ] π HL7v2 parsing and FHIR profile conversion support |
| 251 | +- [ ] π§ Multi-modal pipelines |
| 252 | + |
247 | 253 |
|
248 | 254 | ## Contribute
|
249 | 255 | We are always eager to hear feedback and suggestions, especially if you are a developer or researcher working with healthcare systems!
|
250 | 256 | - π‘ Let's chat! [Discord](https://discord.gg/UQC6uAepUz)
|
251 | 257 | - π οΈ [Contribution Guidelines](CONTRIBUTING.md)
|
252 | 258 |
|
253 |
| -## Acknowledgement |
254 |
| -This repository makes use of [fhir.resources](https://github.com/nazrulworld/fhir.resources), and [CDS Hooks](https://cds-hooks.org/) developed by [HL7](https://www.hl7.org/) and [Boston Childrenβs Hospital](https://www.childrenshospital.org/). |
| 259 | + |
| 260 | +## Acknowledgements π€ |
| 261 | +This project builds on [fhir.resources](https://github.com/nazrulworld/fhir.resources) and [CDS Hooks](https://cds-hooks.org/) standards developed by [HL7](https://www.hl7.org/) and [Boston Children's Hospital](https://www.childrenshospital.org/). |
0 commit comments