Ship + get hired
Week 6 · ~10 h
Hospitals run 24/7, so how you change things matters as much as what you change. An ADT interface that stops at 2 a.m. means the night's admissions never reach the lab, pharmacy or bed board, and nurses find out when an order can't be placed for a patient the system has never heard of. A change that quietly alters what an acknowledgment means can lose messages for days. Most of the work on an integration team is keeping existing interfaces running while you change them.
This week makes the project something an employer can run, read and trust. We put HAPI FHIR, the week 3 bridge and Open Integration Engine (OIE) into one Docker Compose file, deploy an OIE channel through its REST API, keep the channel's XML in git so every change is a reviewable diff, replay a whole day of traffic to prove it creates no duplicate patients, stop the bridge and watch the engine hold the messages in a queue while our on-call script raises an alert (“pages” someone), and roll a change back. Then we write the documents that turn a lab into a portfolio piece: an interface spec, a runbook and a README.
Words you need this week. Feed: the stream of messages one system sends to another. On-call: the person who must respond when something breaks, day or night. Page: to alert that person. Interface spec: the written contract between the team that sends a feed and the team that receives it. Runbook: the step-by-step operations guide for whoever is on call.
Done when
This week you build a Compose file, a runbook, an interface spec and a README. You are done when:
- A reviewer has it running in 10 minutes (exercise 4).
- A replayed day creates no duplicates.
- Spec, channel exports and code agree.
One command to a running lab
The first thing a reviewer does with your project is try to run it, and the commonest way that fails is a README that only works on your machine. Your machine has the right Java, an image you pulled months ago, a port you opened once. A reviewer's has none of that. So describe the whole lab in one file Docker can run anywhere. Messages flow from the sender to OIE on port 6661, from OIE to the bridge on 2575, and from the bridge to HAPI over HTTP:
# Week 6 lab: sender -> OIE (6661) -> bridge (2575) -> HAPI
# Images are pinned by digest: "latest" moves, a digest
# doesn't. These are HAPI FHIR 8.12.0, OIE 4.5.2 and
# Python 3.12-slim as tested on 31 Oct 2026.
services:
hapi:
image: hapiproject/hapi@sha256:0ff86aac4c7bd13a1ee226444a70263bb46ed1c28ef543c30a44f865b80ca04e
ports: ["8080:8080"]
bridge:
image: python@sha256:d75c4b6cdd039ae966a34cd3ccab9e0e5f7299280ad76fe1744882d86eedce0b
working_dir: /app
volumes: ["./bridge.py:/app/bridge.py:ro"]
environment:
FHIR_BASE: http://hapi:8080/fhir
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_ROOT_USER_ACTION: ignore
command: sh -c "pip install -q hl7==0.4.5 && python bridge.py"
ports: ["2575:2575"]
depends_on: [hapi]
healthcheck:
# healthy = listening on 2575 AND HAPI answers
test: ["CMD", "python", "-c", "import socket, urllib.request as u;
socket.create_connection(('localhost', 2575));
u.urlopen('http://hapi:8080/fhir/metadata')"]
interval: 5s
retries: 40
start_period: 180s
oie:
image: openintegrationengine/engine@sha256:d48bf93e933f85180f0ae4a94c13f4e5d38bac3ea53468fbb9ee03bbc0d94b14
ports: ["8443:8443", "6661:6661"]
depends_on: [bridge]
healthcheck:
test: ["CMD", "curl", "-skf", "-o", "/dev/null",
"-u", "admin:admin", "-H", "X-Requested-With: OpenAPI",
"https://localhost:8443/api/server/version"]
interval: 5s
retries: 40
start_period: 120s
The images are pinned by digest, not by tag. A tag like
latest moves whenever the publisher pushes; a digest names exactly
one image, so the reviewer runs what you tested, and an upgrade becomes a
reviewed commit.
The bridge is week 3's bridge.py with one change: instead of
hard-coding http://localhost:8080/fhir, which is wrong inside a
container, it reads FHIR_BASE from the environment and falls back
to the old value. It installs python-hl7 at start-up; a real deployment would
build an image so start-up doesn't depend on a package index.
Health checks matter because “the container started” is not “the service is
ready”. The HAPI image has no shell or curl to check itself, so the
bridge's check tests both its own MLLP port and HAPI's metadata endpoint: the
bridge is healthy only when the path to the FHIR server works.
docker compose up --wait returns when every checked service is
healthy, and --wait-timeout makes it fail instead of hanging. Here
is the reviewer's first minute, from a fresh clone:
$ ls
adt.hl7
adt-prod.hl7
bridge.py
channels
compose.yaml
day.py
interface-spec.md
oie.curl
oncall.sh
README.md
RUNBOOK.md
snapshot.sh
$ git log --oneline
c40b1f2 Lab: compose, bridge, OIE channel, docs
$ time docker compose up -d --wait --wait-timeout 120
Network hims-lab_default Creating
Network hims-lab_default Creating
Network hims-lab_default Created
Network hims-lab_default Created
Container hims-lab-hapi-1 Creating
Container hims-lab-hapi-1 Created
Container hims-lab-bridge-1 Creating
Container hims-lab-bridge-1 Created
Container hims-lab-oie-1 Creating
Container hims-lab-oie-1 Created
Container hims-lab-hapi-1 Starting
Container hims-lab-hapi-1 Started
Container hims-lab-bridge-1 Starting
Container hims-lab-bridge-1 Started
Container hims-lab-oie-1 Starting
Container hims-lab-oie-1 Started
Container hims-lab-oie-1 Waiting
Container hims-lab-hapi-1 Waiting
Container hims-lab-bridge-1 Waiting
Container hims-lab-hapi-1 Healthy
Container hims-lab-oie-1 Healthy
Container hims-lab-bridge-1 Healthy
real 0m21.821s
user 0m0.111s
sys 0m0.047s
$ docker compose ps --format 'table {{.Service}}\t{{.Status}}'
SERVICE STATUS
bridge Up 21 seconds (healthy)
hapi Up 21 seconds
oie Up 21 seconds (healthy)
The real line is the number for your README, measured with the
images already present; a first pull adds download time. Then check that you
run what you think you run:
$ curl -s localhost:8080/fhir/metadata |
jq -r '.software | "\(.name) \(.version)"'
HAPI FHIR Server 8.12.0
$ curl -K oie.curl https://localhost:8443/api/server/version; echo
4.5.2
$ docker compose exec bridge python --version
Python 3.12.12
$ docker compose exec bridge pip show hl7 | head -2
Name: hl7
Version: 0.4.5
Tested: OIE 4.5.2, the week 3 bridge and HAPI FHIR 8.12.0 ran together from one compose file. A message sent to OIE on port 6661 reached HAPI through the bridge, and the sender received the bridge's AA (sessions below). OIE reaches HAPI only through the bridge here; we did not try OIE's own HTTP sender straight to HAPI.
Deploying an OIE channel
In week 3 we wrote the listener ourselves. In an integration engine the same job is a channel: a source connector that receives messages, optional filters and transformers, and destination connectors that send them on. OIE stores each channel as an XML document, and its REST API accepts and returns that XML, so a channel is a file you keep in git like any other code.
Ours is as small as we could make it: a TCP listener in MLLP mode on port 6661,
and one TCP sender in MLLP mode to bridge:2575. No transformer: the
bridge already does the mapping, and one place for it means the spec has one
piece of code to agree with. Most of the file is default data-type settings;
these are the lines that matter:
<properties class="com.mirth.connect.connectors.tcp.TcpReceiverProperties" version="4.5.2">
<pluginProperties/>
<listenerConnectorProperties version="4.5.2">
<host>0.0.0.0</host>
<port>6661</port>
</listenerConnectorProperties>
<sourceConnectorProperties version="4.5.2">
<responseVariable>d1</responseVariable>
<!-- ... -->
<properties class="com.mirth.connect.connectors.tcp.TcpDispatcherProperties" version="4.5.2">
<pluginProperties/>
<destinationConnectorProperties version="4.5.2">
<queueEnabled>false</queueEnabled>
<sendFirst>false</sendFirst>
<retryIntervalMillis>10000</retryIntervalMillis>
<!-- ... -->
<validateResponse>true</validateResponse>
<!-- ... -->
<serverMode>false</serverMode>
<remoteAddress>bridge</remoteAddress>
<remotePort>2575</remotePort>
<!-- ... -->
<responseTimeout>15000</responseTimeout>
Read responseVariable twice: it decides what the sender gets
back. d1 means “the response from destination 1”, so the sender
receives the bridge's own ACK, and AA still means what week 3 promised: the
patient is stored. OIE could instead generate its own ACK on arrival, which is
faster, but then AA means only “the engine has it” and OIE's queue is what
someone must watch. validateResponse makes OIE read the bridge's
ACK, so an AE or AR counts as an error in OIE's statistics.
Writing channel XML from nothing is the hard part, and we didn't: we took a small HL7 test channel from OIE's source repository and swapped in the TCP connectors, using the field names from OIE's connector classes. The usual route is to build the channel in the Administrator GUI and export it. Either way, the file in git should be what the server exports, which we check below.
The REST API wants basic authentication and an X-Requested-With
header on every call. Any value will do, but without the header the server
answers 400; OIE's source calls this check
RequestedWithFilter. The four calls we need:
# OIE 4.5.2 REST API: basic auth plus
# header X-Requested-With: OpenAPI
POST /api/channels # channel XML
POST /api/channels/<id>/_deploy # -> 204
GET /api/channels/<id>/status # -> STARTED
GET /api/channels/<id>/statistics
We keep those options in a curl config file, oie.curl, passed
with -K. Create the channel, deploy it, and ask for its state and
counters:
$ cat oie.curl
# curl -K oie.curl URL: what OIE 4.5.2's REST API needs.
# Lab only: self-signed certificate and default password.
insecure
silent
user = "admin:admin"
header = "X-Requested-With: OpenAPI"
$ grep -m1 '<id>' channels/adt-to-bridge.xml
<id>6e0d3c1a-7b2f-4c55-9e1a-0a5d2f3b6c01</id>
$ export OIE=https://localhost:8443/api
$ export CH=6e0d3c1a-7b2f-4c55-9e1a-0a5d2f3b6c01
$ curl -K oie.curl -H 'Content-Type: application/xml' \
--data-binary @channels/adt-to-bridge.xml $OIE/channels; echo
{"boolean":true}
$ curl -K oie.curl -X POST -w '%{http_code}\n' $OIE/channels/$CH/_deploy
204
$ curl -K oie.curl -H 'Accept: application/json' \
$OIE/channels/$CH/status | jq -r .dashboardStatus.state
STARTED
$ curl -K oie.curl -H 'Accept: application/json' \
$OIE/channels/$CH/statistics |
jq -c '.channelStatistics | del(.serverId, .channelId)'
{"received":0,"sent":0,"error":0,"filtered":0,"queued":0}
Later sessions use the same $OIE and $CH. Creating
stores the channel; deploying starts the listener. Now send week 3's admission
through the engine:
$ mllp_send --loose -f adt.hl7 -p 6661 localhost | tr '\r' '\n'
MSH|^~\&|BRIDGE|LAB|REGADT|GENHOSP|20261031221512||ACK^A01^ACK|63042215126766400I1E|T|2.5.1
MSA|AA|MSG00001
$ ./snapshot.sh
1 patients, 1 versions, sha256 6a37a2ca824f531a
$ docker compose logs --no-log-prefix bridge
listening for MLLP on port 2575
MSG00001 AA after HTTP 201 http://hapi:8080/fhir/Patient/1000/_history/1
The ACK came from the bridge (sending application BRIDGE) through
OIE, after HAPI answered 201 Created. snapshot.sh,
shown below, counts patients and versions and fingerprints what they say.
TEST vs PROD feeds (MSH-11)
Every interface exists at least twice: a TEST feed for trying changes, training staff and loading made-up patients, and a PROD feed carrying real patients into real charts. Mixing them up hurts both ways. Test messages in production put fictional results into the record of a real person whose MRN happens to match. Production messages in a test system copy real health information to a place with weaker access controls, which is a privacy breach in itself.
The first defence is separate hosts, ports and credentials. The second is in
the message: MSH-11, the processing ID. Our bridge is a test
listener and accepts only T. adt-prod.hl7 is the same
admission marked P:
$ tr '\r' '\n' < adt-prod.hl7 | head -1 | cut -d'|' -f9-12
ADT^A01^ADT_A01|MSG00004|P|2.5.1
$ mllp_send --loose -f adt-prod.hl7 -p 6661 localhost | tr '\r' '\n'
MSH|^~\&|BRIDGE|LAB|REGADT|GENHOSP|20261031221512||ACK^A01^ACK|6304221512888967CY6K|P|2.5.1
MSA|AR|MSG00004
ERR||MSH^1^11|202^Unsupported processing id^HL70357|E
$ curl -K oie.curl -H 'Accept: application/json' \
$OIE/channels/$CH/statistics |
jq -c '.channelStatistics | del(.serverId, .channelId)'
{"received":2,"sent":1,"error":1,"filtered":0,"queued":0}
The bridge answered AR with ERR code 202, unsupported processing
ID, and wrote nothing. Because the channel validates responses, OIE counted the
AR as an error: one sent, one error. The on-call check reads that counter
later. A production receiver should refuse T just as firmly, with
the allowed value set per environment, never a default that accepts
anything.
| MSH-11 | Meaning (HL7 table 0103) | Our TEST feed |
|---|---|---|
T | Training (test) | processed; AA after the write |
P | Production | AR, ERR 202, nothing written |
D | Debugging | AR, ERR 202, nothing written |
Canada: the same practice. Connections to provincial systems, such as client registries and drug or lab repositories, typically start in a test or conformance environment, and getting access to it can take longer than building the interface. Ask early which environment you will be given.
Replaying a day of traffic safely
Sooner or later you will be asked to send a lot of messages again: the bridge was down overnight and the sender gave up, a database was restored from last night's backup, or a new downstream system needs yesterday's admissions. Engines and senders keep message archives for this, and replay is routine, as long as the receiver can take it.
Week 3 made the receiver idempotent: the bridge writes with a FHIR
conditional update
keyed on the MRN, so the same message twice leaves the same state as once.
Replay tests that at the scale of a day. day.py writes a synthetic
day for 100 made-up patients: an admission each, a demographics update for some,
a discharge for others, in time order:
$ python3 day.py > day.hl7
$ grep -c '^MSH' day.hl7
207
$ cut -d'|' -f9 day.hl7 | sort | uniq -c
100 ADT^A01^ADT_A01
63 ADT^A03^ADT_A03
44 ADT^A08^ADT_A01
$ head -2 day.hl7 | tr '\r' '\n'
MSH|^~\&|REGADT|GENHOSP|BRIDGE|LAB|20261030000500||ADT^A01^ADT_A01|DAY00001|T|2.5.1
EVN|A01|20261030000500
PID|1||300041^^^GENHOSP^MR||GARCIA^TAYLOR||19530319|F
PV1|1|I|4W^401^A
MSH|^~\&|REGADT|GENHOSP|BRIDGE|LAB|20261030001300||ADT^A01^ADT_A01|DAY00002|T|2.5.1
EVN|A01|20261030001300
PID|1||300080^^^GENHOSP^MR||ROY^ALEX||19420926|F
PV1|1|I|4W^402^A
To prove nothing changed we need a fingerprint that ignores what should change, such as server ids, versions and timestamps:
#!/usr/bin/env bash
# What the FHIR server says about patients: how many, how many
# versions, and a fingerprint of identity fields (not ids/versions).
# Same fingerprint before and after a replay = nothing changed.
# shortcut: reads one page (_count=500); page through
# Bundle.link "next" for bigger servers.
set -euo pipefail
FHIR=${FHIR:-http://localhost:8080/fhir}
# no-cache: HAPI otherwise reuses recent search results
get() { curl -sf -H 'Cache-Control: no-cache' "$FHIR/$1"; }
all=$(get 'Patient?_count=500' | jq -c '[.entry[]?.resource |
[.identifier[0].value, .name, .gender, .birthDate]] | sort')
versions=$(get 'Patient/_history?_summary=count' | jq .total)
echo "$(jq length <<<"$all") patients, $versions versions," \
"sha256 $(sha256sum <<<"$all" | cut -c1-16)"
Send the day, then send the whole day again:
$ ./snapshot.sh
1 patients, 1 versions, sha256 6a37a2ca824f531a
$ mllp_send --loose -f day.hl7 -p 6661 localhost | grep -c 'MSA|AA'
207
$ ./snapshot.sh
101 patients, 134 versions, sha256 52b3bb252a6ac2db
$ mllp_send --loose -f day.hl7 -p 6661 localhost | grep -c 'MSA|AA'
207
$ ./snapshot.sh
101 patients, 200 versions, sha256 52b3bb252a6ac2db
$ docker compose logs bridge | grep -o 'HTTP 20[01]' | sort | uniq -c
314 HTTP 200
101 HTTP 201
All 207 messages got AA both times. After each pass there were 101 patients (Jane Doe plus the day's 100) with the same fingerprint, and the bridge's log shows 101 creates; every other write was an update. A replayed day creates no duplicates.
Look at the versions, though: 134 after the first pass, 200 after the second. Idempotent doesn't mean “nothing happens”. Replaying a patient's A01 put back the name from before their A08, and HAPI stored a version; the replayed A08 then restored the corrected name and HAPI stored another. Each of the 33 patients whose A08 changed something gained two versions. For a moment a clinician, or a system subscribed to Patient changes, could have seen the old name. So replay in the original order, and from the point of failure to the end, never an old slice: an old A01 on its own leaves the patient rewound.
Tested: in a rehearsal run, a plain
Patient?_summary=countstill said 1 just after the day's 100 patients were created: HAPI reuses recent search results for a short time.snapshot.shsendsCache-Control: no-cacheto get fresh results.
Note that the key is the MRN, not MSH-10: our replay reused the
archive's control IDs, but a sender that regenerates messages would give the
same facts new ones. Identity decides what to write; control IDs only trace.
Change windows, review and rollback
Every change to a production interface is a risk to every patient whose messages flow through it, and hospitals manage that risk with process. Changes are requested in a ticket, reviewed, approved (often by a change advisory board when clinical systems are involved) and scheduled into a change window: an agreed time, usually when volume is low, when the affected teams expect trouble and someone is watching. Each request says how the change will be tested afterwards and how it will be undone.
A reviewer needs something to review, and an engine's GUI doesn't produce diffs. So the channel lives in git, and the file in git must be what the engine runs. Export it and compare:
$ curl -K oie.curl $OIE/channels/$CH -o channels/adt-to-bridge.xml
$ git status --short
$ git diff --exit-code && echo 'engine and git agree'
engine and git agree
The export matches the committed file byte for byte: channel exports and code agree. Run this before every change, in case someone edited the channel in the GUI since the last export.
Now a real change. Today, if the bridge is down, the sender gets no AA and the messages pile up in the sender's queue, where we can't see them. Turning on OIE's destination queue in “on failure” mode makes OIE try the bridge first and, if that fails, keep the message and retry itself. In the GUI it is a drop-down; in git it is two lines:
$ sed -i -e 's|<queueEnabled>false|<queueEnabled>true|' \
-e 's|<sendFirst>false|<sendFirst>true|' channels/adt-to-bridge.xml
$ git diff
diff --git a/channels/adt-to-bridge.xml b/channels/adt-to-bridge.xml
index 7a4c617..9daaf34 100644
--- a/channels/adt-to-bridge.xml
+++ b/channels/adt-to-bridge.xml
@@ -149,8 +149,8 @@
<properties class="com.mirth.connect.connectors.tcp.TcpDispatcherProperties" version="4.5.2">
<pluginProperties/>
<destinationConnectorProperties version="4.5.2">
- <queueEnabled>false</queueEnabled>
- <sendFirst>false</sendFirst>
+ <queueEnabled>true</queueEnabled>
+ <sendFirst>true</sendFirst>
<retryIntervalMillis>10000</retryIntervalMillis>
<regenerateTemplate>false</regenerateTemplate>
<retryCount>0</retryCount>
$ git commit -qam 'bridge destination: queue on failure'
A good reviewer asks what the diff doesn't say: when OIE queues a message,
what does the sender get back, given that the source still answers with
d1? We'll find out. Deploy with PUT, which replaces the
stored channel, then export again:
$ curl -K oie.curl -X PUT -H 'Content-Type: application/xml' \
--data-binary @channels/adt-to-bridge.xml \
"$OIE/channels/$CH?override=true"; echo
{"boolean":true}
$ curl -K oie.curl -X POST -w '%{http_code}\n' $OIE/channels/$CH/_deploy
204
$ curl -K oie.curl $OIE/channels/$CH -o channels/adt-to-bridge.xml
$ git diff -U0 | grep '^[-+] '
- <revision>1</revision>
+ <revision>2</revision>
$ git commit -qam 'Export after deploy'
$ git log --oneline
09af831 Export after deploy
19508dd bridge destination: queue on failure
c40b1f2 Lab: compose, bridge, OIE channel, docs
The server's export differs from our commit only in the revision number, which it bumps on every save. Committing the export keeps git and the engine in step and records the deploy.
When the bridge goes down
Stop the bridge and send the day's last five messages, as a sender would after a short outage:
$ docker compose stop bridge
Container hims-lab-bridge-1 Stopping
Container hims-lab-bridge-1 Stopped
$ tail -5 day.hl7 > burst.hl7
$ mllp_send --loose -f burst.hl7 -p 6661 localhost | od -An -c
\v 034 \r \n \v 034 \r \n \v 034 \r \n \v 034 \r \n
\v 034 \r \n
$ ./oncall.sh $CH; echo "exit $?"
received=421 error=1 (0%) queued=5
PAGE: interface needs a human
exit 2
There is the reviewer's answer. For each queued message OIE sent back an
empty MLLP frame: \v (0x0B) and then 034 \r
(0x1C 0x0D) with no ACK inside; the \n is
mllp_send's own line break. That's not AA, so a careful sender
resends, which is safe only because the receiver is idempotent. The behaviour
belongs in the interface spec, and the change shouldn't be approved without
it.
Tested: with the destination queued on failure and the source responding with
d1, OIE 4.5.2 answered each message sent while the bridge was stopped with an empty MLLP frame (0b 1c 0d), and counted it as queued, not as an error.
The rest of the output is our on-call script raising an alert. An interface that pages on every error trains people to ignore pages: one malformed message is a ticket for the morning, and the sender already knows because it got an AE. What needs a human now is a sign that many patients are affected: messages piling up behind a broken downstream system, or a whole class of messages failing. So alert on queue depth and error rates, not on every error:
#!/usr/bin/env bash
# Page a human on queue depth or error rate, not on every error.
# Usage: ./oncall.sh <channel-id> (cron it every minute)
set -euo pipefail
OIE=${OIE:-https://localhost:8443/api}
MAX_QUEUED=${MAX_QUEUED:-3} # messages waiting downstream
MAX_ERR_PCT=${MAX_ERR_PCT:-5} # errors per 100 received
stats=$(curl -sfk -u admin:admin -H 'X-Requested-With: OpenAPI' \
-H 'Accept: application/json' "$OIE/channels/$1/statistics")
read -r rcv err q < <(jq -r '.channelStatistics |
"\(.received) \(.error) \(.queued)"' <<<"$stats")
pct=$(( rcv ? 100 * err / rcv : 0 ))
echo "received=$rcv error=$err (${pct}%) queued=$q"
if (( q > MAX_QUEUED || pct > MAX_ERR_PCT )); then
echo "PAGE: interface needs a human"; exit 2
fi
echo "OK"
| Signal | Why | Action |
|---|---|---|
| Queue depth above a threshold | messages are not reaching the chart | page now |
| Error rate above a threshold | a whole class of messages is failing | page now |
| No messages for longer than usual | the sender or the network is down | page in the daytime, check at night |
| A single AE or AR | one bad message; the sender knows | next-day error review |
Our check found 421 received, 1 error (the PROD message, well under 5%) and 5 queued, over the threshold of 3, so it paged and exited with status 2, which is what cron or a monitoring agent acts on. Set real thresholds from the feed's normal volume. We didn't build the missing-traffic check: an ADT feed that goes silent at 10 a.m. on a weekday is broken even if every counter looks fine.
Start the bridge again and give OIE one retry interval (10 seconds in our channel) to drain:
$ docker compose start --wait --wait-timeout 120 bridge
Container hims-lab-bridge-1 Starting
Container hims-lab-bridge-1 Started
Container hims-lab-bridge-1 Waiting
Container hims-lab-hapi-1 Waiting
Container hims-lab-hapi-1 Healthy
Container hims-lab-bridge-1 Healthy
$ sleep 15
$ ./oncall.sh $CH; echo "exit $?"
received=421 error=1 (0%) queued=0
OK
exit 0
$ docker compose logs --no-log-prefix bridge | tail -6
listening for MLLP on port 2575
DAY00203 AA after HTTP 200 http://hapi:8080/fhir/Patient/1094/_history/1
DAY00204 AA after HTTP 200 http://hapi:8080/fhir/Patient/1095/_history/1
DAY00205 AA after HTTP 200 http://hapi:8080/fhir/Patient/1096/_history/4
DAY00206 AA after HTTP 200 http://hapi:8080/fhir/Patient/1097/_history/1
DAY00207 AA after HTTP 200 http://hapi:8080/fhir/Patient/1100/_history/1
$ ./snapshot.sh
101 patients, 200 versions, sha256 52b3bb252a6ac2db
The queue is empty, the check is quiet, the bridge's log shows the five queued messages, and the fingerprint is unchanged, because these were the day's latest messages. OIE's lifetime counters only grow, so a real check compares with its previous run and computes a rate; that's an exercise.
A rollback you have actually run
The other classic failure is a rollback plan nobody has run. Change requests always have a rollback section, often one line written by someone who never tried it. Find out before the window whether the previous version can be restored, how long it takes, and how you will know it worked. With the channel in git, rollback is just another deploy of a reviewed commit:
$ git revert --no-edit HEAD~1
Auto-merging channels/adt-to-bridge.xml
[main 9733c98] Revert "bridge destination: queue on failure"
Date: Sat Oct 31 22:16:08 2026 +0000
1 file changed, 2 insertions(+), 2 deletions(-)
$ grep -o '<queueEnabled>[a-z]*' channels/adt-to-bridge.xml
<queueEnabled>false
$ curl -K oie.curl -X PUT -H 'Content-Type: application/xml' \
--data-binary @channels/adt-to-bridge.xml \
"$OIE/channels/$CH?override=true"; echo
{"boolean":true}
$ curl -K oie.curl -X POST -w '%{http_code}\n' $OIE/channels/$CH/_deploy
204
$ curl -K oie.curl -H 'Accept: application/json' \
$OIE/channels/$CH/status | jq -r .dashboardStatus.state
STARTED
$ curl -K oie.curl $OIE/channels/$CH | grep -o '<queueEnabled>[a-z]*'
<queueEnabled>false
$ mllp_send --loose -f adt.hl7 -p 6661 localhost | tr '\r' '\n' | grep MSA
MSA|AA|MSG00001
$ git log --oneline
9733c98 Revert "bridge destination: queue on failure"
09af831 Export after deploy
19508dd bridge destination: queue on failure
c40b1f2 Lab: compose, bridge, OIE channel, docs
Git reverted the queue change, the engine took the reverted file, the deployed
channel reads queueEnabled false, and a test message gets AA end to
end. The history tells the story of the change window. Time a rehearsal like
this and put the number in the change request.
Not everything rolls back this neatly. If a bad mapping wrote wrong birth dates for an hour, reverting the channel stops the damage but doesn't repair it: you find the affected patients and correct or replay them. Another reason to keep the archive and make replay safe.
Downtime procedures
Systems go down on purpose (upgrades, migrations) and by accident, and the hospital keeps working on downtime procedures: paper forms, read-only copies of key reports, phone calls instead of electronic orders. ONC's SAFER Guides include one on contingency planning for planned and unplanned EHR unavailability; read it before your first scheduled downtime.
For an interface team a downtime has three parts. Before: announce start and end times, and confirm senders will queue rather than give up after a retry limit. During: watch the queues grow at the expected rate. After: drain the queues, replay from the archive whatever was dropped, send a test message, check the queue is at zero, and tell the units. Then everything done on paper gets entered, and those registrations arrive hours late and out of order: week 3's A08-before-A01 case, at volume.
Finally, the stop step from the runbook:
$ docker compose down
Container hims-lab-oie-1 Stopping
Container hims-lab-oie-1 Stopped
Container hims-lab-oie-1 Removing
Container hims-lab-oie-1 Removed
Container hims-lab-bridge-1 Stopping
Container hims-lab-bridge-1 Stopped
Container hims-lab-bridge-1 Removing
Container hims-lab-bridge-1 Removed
Container hims-lab-hapi-1 Stopping
Container hims-lab-hapi-1 Stopped
Container hims-lab-hapi-1 Removing
Container hims-lab-hapi-1 Removed
Network hims-lab_default Removing
Network hims-lab_default Removed
$ docker compose ps -a
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
The containers and network are gone, and so is every patient: this HAPI image keeps its database inside the container, as week 3 found. Fine for a lab you rebuild in under a minute, and the runbook warns about it; a production FHIR server keeps its data in a database that outlives containers.
Writing it down: interface spec and runbook
An interface spec is the contract between sending and receiving teams; when a
message is rejected at 3 a.m., it decides whose problem it is. Ours covers the
connection (transport, ports, network path, HL7 version, processing ID, ACK
mode), the trigger events and what each does, segments used and ignored,
field-by-field mappings from PID to FHIR, the ACK rules, duplicate
and replay handling, and monitoring. Its ACK rules:
## ACK rules
| Situation | ACK | ERR |
|-----------|-----|-----|
| Patient written (HTTP 200 or 201) | AA | |
| MSH-11 is not `T` | AR | MSH^1^11, 202 |
| PID-3 missing | AE | PID^1^3, 101 |
| Unknown assigning authority | AE | PID^1^3, 103 |
| Bad birth date | AE | PID^1^7, 102 |
| MRN already on several patients (HTTP 412) | AE | PID^1^3, 205 |
| Other HTTP 4xx | AE | PID, 207 |
| FHIR server down or 5xx | none: connection closed, sender retries | |
AA is sent only after the FHIR write has committed.
Every row is a branch in bridge.py, so you check that spec and
code agree by reading them side by side and keeping a test message per row, as
week 3's broken message set did. Writing the spec also finds gaps: ours lists
A40 as an open item, because the bridge doesn't check
MSH-9 yet and would treat a merge as an ordinary update.
The runbook is for the person on call who didn't build the interface, which in six months includes you. Ours covers start, stop, health check, change, roll back, bridge or FHIR server down, replay and planned downtime, as commands and expected results copied from the sessions on this page. A step nobody has run doesn't belong in a runbook unless it is marked untested.
AI this week: let it draft the runbook and spec; run every step by hand.
Download the lab files:
compose.yaml,
bridge.py,
adt-to-bridge.xml (the
channel; keep it in channels/),
oie.curl,
day.py,
snapshot.sh,
oncall.sh,
adt.hl7,
adt-prod.hl7,
interface-spec.md,
RUNBOOK.md and
README.md.
What employers run
You won't find OIE everywhere, and the ideas transfer. Integration job ads name engines such as Rhapsody, Cloverleaf, Epic Bridges and Mirth (Mirth Connect, which OIE forked). Each has this week's parts under other names: inbound and outbound connections, routes or channels, transformers, queues, ACK settings, alerting and configuration export. Epic Bridges is the interface module inside Epic, so its builders work for or alongside an Epic customer.
At the ends of the feed are the clinical systems: Epic, Oracle Health, MEDITECH, TELUS Health. You don't need to have used them; you need to know what they send and expect. Employers test the skills in this course: find the field that broke a v2 message, explain what an ACK promises, map to FHIR without losing meaning, and change a running interface safely. When an ad names an engine you haven't used, map the concepts of the one you have.
Canada: expect the same engines. You are likely to meet MEDITECH in hospitals and TELUS Health in community clinics, alongside Epic and Oracle Health, with provincial registries and health card numbers as extra integration points.
The portfolio README and getting hired
Your repo is the interview before the interview, and the README decides how a hiring manager spends their ten minutes. Ours opens with what the project does for a hospital, then a diagram of the flow, the exact commands with expected output, where to look, what was tested, and the limits. Limits are a strength: “default admin password, self-signed certificate, no TLS on MLLP, data lost on restart” shows you know a lab from production.
Before you share the link, clone the repo into an empty directory on another machine, follow the README literally, and time it. Every step it was missing goes into it. Only claim “runs in 10 minutes” after you have watched someone else do it.
Then prepare to talk about decisions, not features: why AA only after the
write, why key on the MRN and not MSH-10, why page on queue depth,
what happens when the FHIR server is down. Each answer here comes with commands
you ran. Interview prep lists questions to
practise, with the week that prepared you for each;
On the job lists what the course leaves for
your employer to teach.
Exercises
- How does replaying a day of messages stay duplicate-free? Replay
day.hl7backwards (tac day.hl7) after a normal pass and comparesnapshot.sh. Which patients would a clinician now see wrongly named? - What should an on-call alert fire on? Make
oncall.shcompute the error rate over the last five minutes instead of lifetime counters, and add a missing-traffic check. - What belongs in an interface spec? Write one for a results feed
(
ORU^R01) into the same FHIR server. - The ten-minute test: give your repo and README to someone else. Time them, note every question, and fix the README until the next person needs no help.
- Close the spec's open item: answer AR with
ERRcode 200 (unsupported message type) for events the spec doesn't list, and add a test message for it. - Rehearse a failed change: deploy a channel pointing at the wrong bridge port, detect it, and roll back from git. How long from deploy to AA?
- Switch the source response from
d1to an ACK OIE generates itself and repeat the outage. What does the sender get, what does AA mean, and which spec line changes? - Make the lab survive a restart: add Postgres to the compose file (without
publishing port 5432), point HAPI at it, and prove it with
down,upandsnapshot.sh. - Make the accepted processing ID a bridge setting (
Tin test,Pin production). What should happen when it is missing? - Write your portfolio README and a two-minute spoken summary of one design decision in it.
For more drill on this week's skills, work through the week 6 practice problems.
Read
- OIE
- HAPI FHIR server
- OIE Docker image: the source of the image we ran
docker compose upreference (--wait)- FHIR R4: conditional update
- python-hl7:
mllp_send - ONC SAFER Guides, including Contingency Planning (EHR downtime)
- Interview prep
- On the job
Tested with
Every command on this page was run on 31 Oct 2026 against the course lab: HAPI FHIR 8.12.0, OIE 4.5.2 and the week 3 bridge on Python 3.12 with python-hl7 0.4.5, started by Docker Compose v5.4.0. The outputs are copied from one run. Yours will differ in timestamps, control IDs, commit hashes and server ids.
Course content © 2026 HeyItWorked. All rights reserved.
Site design adapted from The Missing Semester of Your CS Education under CC BY-NC-SA 4.0. See copyright and license.