Hospital Chile
Platform that ingests radiology reports from Chilean hospitals over HL7, structures them, corrects them with an AI agent and triggers escalated alerts on critical findings.
CLIENTE
Hospital Chile
SECTOR
Health & nutrition
§ 01Challenge
The client provides radiology report processing for a network of Chilean hospitals and clinics that emit HL7 messages across multiple hospital institutions.
Ingestion and processing had three serious friction points:
-
Brittle HL7 parsing. v2.5 messages arrived with inconsistent separators (
\n,\r,\r\nmixed within the same message), multi-line OBX segments and embedded HTML (<p>,<strong>,<br />, entities such as®, ). The initial parser broke OBX segments 2–4 in complex reports. -
No automated clinical correction. Anatomical/gender mismatches (e.g. "prostate" described in a female patient), spelling errors, laterality contradictions and duplicated sections passed through to the final report unreviewed.
-
Manual handling of critical findings. When an institution reported a critical pathology, coordination happened over manual email. There was no automatic escalation if the contact failed to respond, nor any traceability of confirmation.
§ 02Decision
Architecture built around n8n as the orchestrator. Key justifications:
- n8n instead of a custom-coded service. Integration logic varies hospital by hospital and must be modifiable without a redeploy. Sub-workflows are tweaked live.
- Classification by OBX segment position instead of content analysis. More robust against wording variations across hospitals.
- AI agent with a specialised clinical prompt. Detects anatomical/gender mismatches, spelling, laterality and consistency between sections. Returns structured JSON; original fields are preserved and only the corrected ones are overwritten.
- Alert system with time-based escalation. Tables
avisos+contactos_emergencia+log_avisos, with retries at 0h, 2h, 6h, 12h, 24h and 48h, cut off as soon as receipt is confirmed. - Field
tipo_informeextracted from OBX-11 (F = final, I = preliminary) so the downstream pipeline can distinguish definitive reports from preliminary ones.
§ 03Process
Phase 1. Robust HL7 ingestion. Built an HL7 parser tolerant to mixed separators and multi-line OBX. Cleaned embedded HTML and entities. Mapped to a canonical structure. Validated with real messages from multiple hospitals and modalities.
Phase 2. AI-powered clinical correction. Integrated an AI agent with a specialised prompt to validate anatomical/gender coherence, spelling, laterality and internal consistency of the report.
Phase 3. Critical findings. Designed and implemented the alert system: immediate phone call, WhatsApp cascade with scheduled retries and automatic cut-off on confirmation.
§ 04Outcome
10+ Chilean hospitals integrated over HL7 with a single pipeline.
AI clinical correction applied to every report before persistence, with clear separation between original text and detected errors (no in-line marks polluting the clinical report).
Critical-alert system with five escalated retries and full traceability in log_avisos (what was sent, when, on which channel, and who/when it was confirmed).
Modular n8n architecture: ingestion, cleansing, AI correction and alerts are independent sub-workflows that can be modified in isolation.
§ AGENDA
Something similar in your operation?
30-minute intro session, no strings attached. We talk through the process, see if it fits — and if it doesn't, you save yourself the build.