Skip to content

Commit c06979d

Browse files
Add sync clients (#133)
* WIP * Refactor of gateway module * Update gateway tests * Fix use_events toggle * Add execute_with_client to sync gateway * Update docs * Typo * Enhance metadata endpoints * Add set problem list to update method * Fix connection status * Tidy tests * Docs edit * Gateway docs adjustment
1 parent 64a4361 commit c06979d

Some content is hidden

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

69 files changed

+5054
-2309
lines changed

README.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ First time here? Check out our [Docs](https://dotimplement.github.io/HealthChain
2222

2323

2424
## Features
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
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 (sync / async support)
2626
- [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
2727
- [x] 🔄 **InteropEngine**: Convert between FHIR, CDA, and HL7v2 with a [template-based engine](https://dotimplement.github.io/HealthChain/reference/interop/interop/)
2828
- [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
29+
- [x]Built-in event-driven logging and operation tracking for [audit trails](https://dotimplement.github.io/HealthChain/reference/gateway/events/)
3030
- [x] 🚀 Deploy production-ready applications with [HealthChainAPI](https://dotimplement.github.io/HealthChain/reference/gateway/api/) and FastAPI integration
3131
- [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
32+
- [x] 🖥️ Bootstrap configurations with CLI tools
3233

3334
## Why use HealthChain?
3435
- **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.
@@ -86,6 +87,11 @@ app.register_service(notes)
8687
# /fhir/* - Patient data, observations, etc.
8788
# /cds/* - Real-time clinical alerts
8889
# /soap/* - Clinical document processing
90+
91+
# Deploy with uvicorn
92+
if __name__ == "__main__":
93+
import uvicorn
94+
uvicorn.run(app, port=8888)
8995
```
9096

9197
### FHIR Operations with AI Enhancement
@@ -99,23 +105,27 @@ gateway.add_source("epic", "fhir://fhir.epic.com/r4?...")
99105

100106
# Add AI transformations to FHIR data
101107
@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
108+
def enhance_patient(id: str, source: str = None) -> Patient:
109+
patient = gateway.read(Patient, id, source)
110+
111+
# Get lab results and process with AI
112+
lab_results = gateway.search(
113+
Observation,
114+
{"patient": id, "category": "laboratory"},
115+
source
116+
)
117+
insights = nlp_pipeline.process(patient, lab_results)
118+
119+
# Add AI summary to patient record
120+
patient.extension = patient.extension or []
121+
patient.extension.append({
122+
"url": "http://healthchain.org/fhir/summary",
123+
"valueString": insights.summary
124+
})
125+
126+
# Update the patient record
127+
gateway.update(patient, source)
128+
return patient
119129

120130
# Automatically available at: GET /fhir/transform/Patient/123?source=epic
121131
```

docs/quickstart.md

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ HealthChain provides three core tools for healthcare AI integration: **Gateway**
88

99
### HealthChainAPI Gateway 🔌
1010

11-
The HealthChainAPI provides a unified interface for connecting your AI models to multiple healthcare systems through a single API. Handle FHIR, CDS Hooks, and SOAP/CDA protocols with OAuth2 authentication and connection pooling.
11+
The HealthChainAPI provides a unified interface for connecting your AI models to multiple healthcare systems through a single API. Handle FHIR, CDS Hooks, and SOAP/CDA protocols with OAuth2 authentication.
1212

1313
[(Full Documentation on Gateway)](./reference/gateway/gateway.md)
1414

1515
```python
1616
from healthchain.gateway import HealthChainAPI, FHIRGateway
17+
from fhir.resources.patient import Patient
1718

1819
# Create your healthcare application
1920
app = HealthChainAPI(title="My Healthcare AI App")
@@ -25,11 +26,12 @@ fhir.add_source("medplum", "fhir://api.medplum.com/fhir/R4/?client_id=...")
2526

2627
# Add AI transformations to FHIR data
2728
@fhir.transform(Patient)
28-
async def enhance_patient(id: str, source: str = None) -> Patient:
29-
async with fhir.modify(Patient, id, source) as patient:
30-
# Your AI logic here
31-
patient.active = True
32-
return patient
29+
def enhance_patient(id: str, source: str = None) -> Patient:
30+
patient = fhir.read(Patient, id, source)
31+
# Your AI logic here
32+
patient.active = True
33+
fhir.update(patient, source)
34+
return patient
3335

3436
# Register and run
3537
app.register_gateway(fhir)
@@ -154,10 +156,6 @@ The HealthChain Interoperability module provides tools for converting between di
154156

155157
[(Full Documentation on Interoperability Engine)](./reference/interop/interop.md)
156158

157-
158-
**Choose your setup based on your needs:**
159-
160-
**Default configs** - For basic testing and prototyping only:
161159
```python
162160
from healthchain.interop import create_interop, FormatType
163161

@@ -175,32 +173,6 @@ fhir_resources = engine.to_fhir(cda_xml, src_format=FormatType.CDA)
175173
cda_document = engine.from_fhir(fhir_resources, dest_format=FormatType.CDA)
176174
```
177175

178-
> ⚠️ **Default configs are limited** - Only supports problems, medications, and notes. No allergies, custom mappings, or organization-specific templates.
179-
180-
🛠️ **Custom configs** - **Required for real-world use**:
181-
```bash
182-
# Create editable configuration templates
183-
healthchain init-configs ./my_configs
184-
```
185-
186-
```python
187-
# Use your customized configs
188-
engine = create_interop(config_dir="./my_configs")
189-
190-
# Now you can customize:
191-
# • Add experimental features (allergies, procedures)
192-
# • Modify terminology mappings (SNOMED, LOINC codes)
193-
# • Customize templates for your organization's CDA format
194-
# • Configure validation rules and environments
195-
```
196-
197-
**When you need custom configs:**
198-
- 🏥 **Production healthcare applications**
199-
- 🔧 **Organization-specific CDA templates**
200-
- 🧪 **Experimental features** (allergies, procedures)
201-
- 🗺️ **Custom terminology mappings**
202-
- 🛡️ **Specific validation requirements**
203-
204176

205177
## Utilities ⚙️
206178

0 commit comments

Comments
 (0)