HL7 v2 & integration
Build a channel
The parts of an engine channel and how to build, deploy and test one, using the existing "ADT in" listener as the example.
A channel is one pipeline: a source that receives messages, optional filters and transformers, and one or more destinations that send them on.
The parts#
| Part | What it does | Example |
|---|---|---|
| Source connector | Receives messages | TCP Listener on port 6661 in MLLP mode |
| Source filter | Drops messages you don't want | Only accept ADT^A04 and ADT^A08 |
| Source transformer | Reshapes or enriches the message before routing | Pull out the MRN, normalise names |
| Destination connector | Sends somewhere | HTTP Sender to HAPI, File Writer, Database Writer, another channel |
| Destination transformer | Builds the outgoing payload | HL7 → FHIR Patient JSON |
| Response transformer | Inspects what the destination returned | Mark an error when HAPI returns 4xx |
Inside a transformer#
The engine parses v2 into XML. In JavaScript steps, msg is that XML (E4X), so you address fields by name:
var mrn = msg['PID']['PID.3'][0]['PID.3.1'].toString();
var family = msg['PID']['PID.5'][0]['PID.5.1'].toString();
var given = msg['PID']['PID.5'][0]['PID.5.2'].toString();
var dob = msg['PID']['PID.7']['PID.7.1'].toString(); // 19870314
var sex = msg['PID']['PID.8']['PID.8.1'].toString();
channelMap.put('mrn', mrn); // available later as ${mrn}A missing field gives an empty string, not an error, so check values before you use them.
| Map | Lives for | Use it for |
|---|---|---|
channelMap |
One message, all destinations | Values you work out once and use in each destination |
connectorMap |
One message, one connector | Values only one connector needs |
sourceMap |
One message, read-only | Info about the connection the message came in on (remote address and so on) |
globalChannelMap |
One channel, until redeploy | Counters, caches |
globalMap |
The whole server | Shared config |
configurationMap |
The whole server, set in Settings | Environment config such as the FHIR base URL |
Keep URLs in the configuration map
Put fhirBase = http://192.168.1.181:8080/fhir in Settings → Configuration Map and use ${fhirBase} in connectors. Then pointing a channel at another server is a single change.
The existing "ADT in" channel#
| Setting | Value |
|---|---|
| Source | TCP Listener, MLLP, port 6661 |
| Inbound data type | HL7 v2.x |
| Response | Auto-generate the ACK |
| Destinations | None yet (it receives and ACKs) |
Deploy, then test#
Save and deploy#
Changes do nothing until you Deploy Channel. Only a deployed channel opens its port.
Send a message#
~/fhir-lab/hl7/send-adtCheck the Dashboard#
Received, Filtered, Queued, Sent and Errored counts update live. Double-click the channel to open the Message Browser, then open a message and use the tabs: Raw, Transformed, Encoded, Sent, Response. They show the message at each stage.