Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4008604
Interop engine WIP
jenniferjiangkells Mar 6, 2025
34d5476
FHIR -> CDA wip
jenniferjiangkells Mar 7, 2025
61c8a0a
Organize configs and refactor
jenniferjiangkells Mar 11, 2025
15e4f3a
stuff happened and i think it's more modular now or something
jenniferjiangkells Mar 12, 2025
cfcad89
Tidy
jenniferjiangkells Mar 14, 2025
cbfbb43
Refactoring to make core interop logic clearer
jenniferjiangkells Mar 17, 2025
3a1a0d7
config tidy
jenniferjiangkells Mar 17, 2025
7ffba04
Move configs to project-level
jenniferjiangkells Mar 18, 2025
3e2e866
configure document type
jenniferjiangkells Mar 18, 2025
b7d4bdc
Add Cda validation and medication entry templates
jenniferjiangkells Mar 19, 2025
f67b308
AllergyIntolerance template
jenniferjiangkells Mar 24, 2025
5c38c76
allergy entry template
jenniferjiangkells Mar 24, 2025
f49b3fe
Clean up configs
jenniferjiangkells Mar 25, 2025
05b9fe7
Added config pydantic validation
jenniferjiangkells Mar 25, 2025
723f24c
Refactor ConfigManager
jenniferjiangkells Mar 28, 2025
ec37607
Unify validation behaviour and added tests
jenniferjiangkells Mar 29, 2025
fa479ce
Clean up default config behaviour
jenniferjiangkells Mar 31, 2025
3c680f9
Fixed some templates
jenniferjiangkells Apr 3, 2025
b4004be
Tidied, refactored, and added tests
jenniferjiangkells Apr 3, 2025
488f429
Lil test fix
jenniferjiangkells Apr 3, 2025
18710ea
Merge branch 'main' of https://github.com/dotimplement/HealthChain in…
jenniferjiangkells Apr 4, 2025
dfafbd3
Added docs and some changes to config structure and base class interf…
jenniferjiangkells Apr 11, 2025
45cc826
Added notes <-> DocumentReference
jenniferjiangkells Apr 14, 2025
2c1803b
Update the new InteropEngine usage in CdaConnector and update tests
jenniferjiangkells Apr 15, 2025
db4a930
Remove legacy CcdAnnotator and update docs
jenniferjiangkells Apr 15, 2025
5b5df8c
Removed unfinished hl7v2 implementations and fixed tests
jenniferjiangkells Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Came here from NHS RPySOC 2024 ✨?
## Features
- [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
- [x] 🔌 Connect pipelines to any EHR system with built-in [CDA and FHIR Connectors](https://dotimplement.github.io/HealthChain/reference/pipeline/connectors/connectors/)
- [x] 🔄 Convert between FHIR, CDA, and HL7v2 with the [InteropEngine](https://dotimplement.github.io/HealthChain/reference/interop/interop/)
- [x] 🧪 Test your pipelines in full healthcare-context aware [sandbox](https://dotimplement.github.io/HealthChain/reference/sandbox/sandbox/) environments
- [x] 🗃️ Generate [synthetic healthcare data](https://dotimplement.github.io/HealthChain/reference/utilities/data_generator/) for testing and development
- [x] 🚀 Deploy sandbox servers locally with [FastAPI](https://fastapi.tiangolo.com/)
Expand Down Expand Up @@ -117,6 +118,24 @@ cda_data = CdaRequest(document="<CDA XML content>")
output = pipeline(cda_data)
```

## Interoperability

The InteropEngine is a template-based system that allows you to convert between FHIR, CDA, and HL7v2.

```python
from healthchain.interop import create_engine, FormatType

engine = create_engine()

with open("tests/data/test_cda.xml", "r") as f:
cda_data = f.read()

# Convert CDA to FHIR
fhir_resources = engine.to_fhir(cda_data, src_format=FormatType.CDA)

# Convert FHIR to CDA
cda_data = engine.from_fhir(fhir_resources, dest_format=FormatType.CDA)
```

## Sandbox

Expand Down Expand Up @@ -219,7 +238,7 @@ healthchain run mycds.py
By default, the server runs at `http://127.0.0.1:8000`, and you can interact with the exposed endpoints at `/docs`.

## Road Map
- [ ] 🔄 Transform and validate healthcare HL7v2, CDA to FHIR with template-based interop engine
- [x] 🔄 Transform and validate healthcare HL7v2, CDA to FHIR with template-based interop engine
- [ ] 🏥 Runtime connection health and EHR integration management - connect to FHIR APIs and legacy systems
- [ ] 📊 Track configurations, data provenance, and monitor model performance with MLFlow integration
- [ ] 🚀 Compliance monitoring, auditing at deployment as a sidecar service
Expand Down
59 changes: 59 additions & 0 deletions configs/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# HealthChain Interoperability Engine Default Configuration
# This file contains default values used throughout the engine

defaults:
# Common defaults for all resources
common:
id_prefix: "hc-"
timestamp: "%Y%m%d"
reference_name: "#{uuid}name"
subject:
reference: "Patient/example"

# Mapping directory configuration
mappings_dir: "cda_default"

# Resource-specific defaults
resources:
Condition:
clinicalStatus:
coding:
- system: "http://terminology.hl7.org/CodeSystem/condition-clinical"
code: "unknown"
display: "Unknown"
MedicationStatement:
status: "unknown"
medication:
concept:
coding:
- system: "http://terminology.hl7.org/CodeSystem/v3-NullFlavor"
code: "UNK"
display: "Unknown"

# TODO: More control over settings
# # Validation settings
# validation:
# strict_mode: true
# warn_on_missing: true
# ignore_unknown_fields: true

# # Parser settings
# parser:
# max_entries: 1000
# skip_empty_sections: true

# # Logging settings
# logging:
# level: "INFO"
# include_timestamps: true

# # Error handling
# errors:
# retry_count: 3
# fail_on_critical: true

# # Performance settings
# performance:
# cache_templates: true
# cache_mappings: true
# batch_size: 100
33 changes: 33 additions & 0 deletions configs/environments/development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Development Environment Configuration
# This file contains settings specific to the development environment
# TODO: Implement

# Logging settings for development
logging:
level: "DEBUG"
include_timestamps: true
console_output: true
file_output: false

# Error handling for development
errors:
retry_count: 1
fail_on_critical: true
verbose_errors: true

# Performance settings for development
performance:
cache_templates: false # Disable caching for easier template development
cache_mappings: false # Disable caching for easier mapping development
batch_size: 10 # Smaller batch size for easier debugging

# Default resource fields for development
defaults:
common:
id_prefix: "dev-" # Development-specific ID prefix
subject:
reference: "Patient/Foo"

# Template settings for development
templates:
reload_on_change: true # Automatically reload templates when they change
37 changes: 37 additions & 0 deletions configs/environments/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Production Environment Configuration
# This file contains settings specific to the production environment
# TODO: Implement

# Logging settings for production
logging:
level: "WARNING"
include_timestamps: true
console_output: false
file_output: true
file_path: "/var/log/healthchain/interop.log"
rotate_logs: true
max_log_size_mb: 10
backup_count: 5

# Error handling for production
errors:
retry_count: 3
fail_on_critical: true
verbose_errors: false

# Performance settings for production
performance:
cache_templates: true # Enable caching for better performance
cache_mappings: true # Enable caching for better performance
batch_size: 100 # Larger batch size for better throughput

# Default resource fields for production
defaults:
common:
id_prefix: "hc-" # Production ID prefix
subject:
reference: "Patient/example"

# Template settings for production
templates:
reload_on_change: false # Don't reload templates in production
39 changes: 39 additions & 0 deletions configs/environments/testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Testing Environment Configuration
# This file contains settings specific to the testing environment
# TODO: Implement
# Logging settings for testing
logging:
level: "INFO"
include_timestamps: true
console_output: true
file_output: true
file_path: "./logs/test-interop.log"

# Error handling for testing
errors:
retry_count: 2
fail_on_critical: true
verbose_errors: true

# Performance settings for testing
performance:
cache_templates: true # Enable caching for realistic testing
cache_mappings: true # Enable caching for realistic testing
batch_size: 50 # Medium batch size for testing

# Default resource fields for testing
defaults:
common:
id_prefix: "test-" # Testing-specific ID prefix
subject:
reference: "Patient/test-example"

# Template settings for testing
templates:
reload_on_change: false # Don't reload templates in testing

# Validation settings for testing
validation:
strict_mode: true
warn_on_missing: true
ignore_unknown_fields: false # Stricter validation for testing
55 changes: 55 additions & 0 deletions configs/interop/cda/document/ccd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CCD Document Configuration
# This file contains configuration for CCD documents

# Document templates (required)
templates:
document: "fhir_cda/document"
section: "fhir_cda/section"

# Basic document information
code:
code: "34133-9"
code_system: "2.16.840.1.113883.6.1"
code_system_name: "LOINC"
display: "Summarization of Episode Note"
confidentiality_code:
code: "N"
code_system: "2.16.840.1.113883.5.25"
language_code: "en-US"
realm_code: "GB"
type_id:
extension: "POCD_HD000040"
root: "2.16.840.1.113883.1.3"
template_id:
root: "1.2.840.114350.1.72.1.51693"

# Document structure
structure:
# Header configuration
header:
include_patient: false
include_author: false
include_custodian: false
include_legal_authenticator: false

# Body configuration
body:
structured_body: true
non_xml_body: false
include_sections:
- "allergies"
- "medications"
- "problems"
- "notes"

# Rendering configuration
rendering:
# XML formatting
xml:
pretty_print: true
encoding: "UTF-8"

# Narrative generation
narrative:
include: true
generate_if_missing: true
88 changes: 88 additions & 0 deletions configs/interop/cda/sections/allergies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Allergies Section Configuration
# ========================

# Metadata for both extraction and rendering processes
resource: "AllergyIntolerance"
resource_template: "cda_fhir/allergy_intolerance"
entry_template: "fhir_cda/allergy_entry"

# Section identifiers (used for extraction)
identifiers:
template_id: "2.16.840.1.113883.10.20.1.2"
code: "48765-2"
code_system: "2.16.840.1.113883.6.1"
code_system_name: "LOINC"
display: "Allergies"
reaction:
template_id: "1.3.6.1.4.1.19376.1.5.3.1.4.5"
severity:
template_id: "1.3.6.1.4.1.19376.1.5.3.1.4.1"

# Template configuration (used for rendering/generation)
template:
# Act element configuration
act:
template_id:
- "1.3.6.1.4.1.19376.1.5.3.1.4.5.1"
- "1.3.6.1.4.1.19376.1.5.3.1.4.5.3"
- "2.16.840.1.113883.3.88.11.32.6"
- "2.16.840.1.113883.3.88.11.83.6"
status_code: "active"

# Allergy observation configuration
allergy_obs:
type_code: "SUBJ"
inversion_ind: false
template_id:
- "1.3.6.1.4.1.19376.1.5.3.1.4.5"
- "1.3.6.1.4.1.19376.1.5.3.1.4.6"
- "2.16.840.1.113883.10.20.1.18"
- "1.3.6.1.4.1.19376.1.5.3.1"
- "2.16.840.1.113883.10.20.1.28"
code: "420134006"
code_system: "2.16.840.1.113883.6.96"
code_system_name: "SNOMED CT"
display_name: "Propensity to adverse reactions"
status_code: "completed"

# Reaction observation configuration
reaction_obs:
template_id:
- "2.16.840.1.113883.10.20.1.54"
- "1.3.6.1.4.1.19376.1.5.3.1.4.5"
code: "RXNASSESS"
status_code: "completed"

# Severity observation configuration
severity_obs:
template_id:
- "2.16.840.1.113883.10.20.1.55"
- "1.3.6.1.4.1.19376.1.5.3.1.4.1"
code: "SEV"
code_system: "2.16.840.1.113883.5.4"
code_system_name: "ActCode"
display_name: "Severity"
status_code: "completed"
value:
code_system: "2.16.840.1.113883.5.1063"
code_system_name: "SeverityObservation"

# Clinical status observation configuration
clinical_status_obs:
template_id: "2.16.840.1.113883.10.20.1.39"
code: "33999-4"
code_system: "2.16.840.1.113883.6.1"
code_system_name: "LOINC"
display_name: "Status"
status_code: "completed"

# Rendering configuration (not used)
rendering:
narrative:
include: true
template: "narratives/allergy_narrative"
entry:
include_status: true
include_reaction: true
include_severity: true
include_dates: true
Loading