Write requirements that clinicians and testers can both read
Ambiguous clinical requirements are the root of many expensive defects. "Display recent vitals" leaves open which vitals, how recent, whether manually entered and device-captured readings are mixed, and how to show a value that was later entered in error.
Pair each workflow requirement with concrete examples using fictional patients. Example: "Patient Ada Testcase, admitted 08:10, has a heart rate of 112 recorded at 09:00 and corrected to 102 at 09:05. The summary card shows 102 with a correction indicator." Examples like this become acceptance tests directly.
- Name the timestamp that defines ordering: observation time, result time, or entry time.
- Specify behavior for corrected, cancelled, and entered-in-error records.
- State units and conversions explicitly.
- Record who on the clinical side approved each workflow decision.
Build interfaces that tolerate reality
Healthcare interfaces deliver duplicates, out-of-order events, and messages that violate their own specification. Defensive design is not pessimism; it is accuracy.
| Pattern | Example | Practice |
|---|---|---|
| Duplicate delivery | Sender retries after a lost ACK | Idempotent processing keyed on message control ID plus source |
| Out-of-order events | A08 update arrives before A01 admit | Upsert semantics; hold-and-retry for dependent events |
| Spec drift | New Z-segment appears after an EHR upgrade | Tolerant parsing; alert on unknown segments rather than failing silently |
| Field overflow | OBX-5 longer than target column | Validate lengths; reject loudly or store full value |
| Silent stop | Feed stops after a network change | Throughput baselines with alerting on unexpected silence |
| Patient merges | A40 merge after duplicate registration | Propagate merges to all stores; keep audit of prior identifiers |
Protect data integrity above convenience
Data integrity in healthcare means a value shown to a clinician is the value the source system recorded, linked to the right patient, with its history intact. Optimizations that compromise that — caching without invalidation, lossy transformations, overwriting instead of versioning — are false economies.
Checklist
- Patient matching rules are explicit, documented, and tested; ambiguous matches go to a work queue, not an automatic merge.
- Clinical records are versioned; updates create new versions instead of overwriting.
- Every stored fact carries provenance back to its source message or resource.
- Code-system mappings (local codes to LOINC, SNOMED CT, RxNorm) are versioned and reviewed.
- Reconciliation jobs compare counts between source and destination daily.
Test with synthetic patients and recorded traffic
Testing in healthcare should lean on two kinds of data: synthetic patient records generated by tools such as Synthea, and recorded message traffic with identifiers replaced. Real PHI should not appear in development or test environments.
Build a library of clinical scenarios — a newborn registered under a temporary name, a patient transferred between facilities, a lab result corrected after release, an order cancelled after collection. Run them end to end through interfaces and the user interface on every release candidate. These scenarios catch the defects unit tests cannot.
Layers worth automating
- Unit tests for parsing, mapping, and business rules.
- Contract tests against recorded HL7 v2 messages and FHIR resources per counterparty.
- FHIR profile validation against US Core using the HL7 validator.
- Authorization tests that attempt cross-patient and cross-tenant access.
- End-to-end clinical scenario tests in a production-like environment.
Release like clinicians are watching — because they are
Clinicians notice changes immediately and have no time to relearn a screen mid-shift. Releases that alter workflows need advance notice, training material, and, ideally, a toggle so customers can enable changes on their schedule.
- Ship behind feature flags and enable per tenant.
- Publish release notes before deployment, flagging workflow-affecting changes.
- Coordinate interface-affecting changes with customer IT change windows.
- Keep rollback tested and fast; database migrations must be backward compatible for at least one release.
- Avoid deployments during known high-acuity periods agreed with customers.
Observe business signals, not just infrastructure
CPU graphs will not tell you that the ORU feed from a reference lab has delivered nothing since 06:00. Instrument the flows that matter clinically: messages received and processed per interface, end-to-end latency from source event to display, error and dead-letter rates, and FHIR Subscription delivery confirmations.
Set alerts on deviation from expected patterns. A feed that normally carries hundreds of messages per hour on weekday mornings and carries none is an incident even if every health check is green. Make sure logs and traces exclude PHI, or route them only to systems covered by a BAA.
Document decisions, interfaces, and runbooks
Healthcare teams carry a lot of tribal knowledge about specific customers: which hospital sends patient class codes in PV1-2 and which uses PV1-18, who to call when a feed stops, which interface is allowed to restart during the day. When that knowledge lives in one engineer's head, every vacation is a risk.
- Architecture decision records for consequential choices.
- Per-counterparty interface specifications with sample messages and mapping tables in version control.
- Runbooks for each alert: what it means, how to diagnose, how to recover, whom to notify.
- Customer contact and escalation matrices kept current.
Team habits that compound
Hold blameless post-incident reviews and turn findings into tests or alerts. Rotate engineers through integration support so knowledge spreads. Invite clinical users to sprint reviews. Review access to production quarterly. Treat dependency updates as routine maintenance rather than emergencies.
None of these practices is novel. What matters is consistency: a team that does them every week builds a system hospitals trust, and that trust shortens every future sales cycle and security review.
References
- HL7 FHIR: Validation
- HL7 Version 2 Product Suite
- ONC: Health IT Safety
- NIST Secure Software Development Framework
This guide is educational and is not legal or regulatory advice.
Frequently asked questions
What are the most important healthcare software engineering best practices?
Write clinical requirements with concrete fictional-patient examples, build idempotent and order-tolerant interfaces, protect data integrity with versioning and provenance, test with synthetic patients and recorded traffic rather than PHI, release behind feature flags with advance notice, monitor business signals such as message throughput, and document interfaces and runbooks so knowledge does not live in one person.
Should we use real patient data for testing?
Avoid it. Use synthetic patient data from tools like Synthea and recorded messages with identifiers replaced. If a test genuinely requires realistic data that synthetic generation cannot reproduce, use a documented de-identification method, restrict access, and treat the dataset as sensitive. Copying production PHI into test environments expands breach risk and audit scope.
How do we handle out-of-order HL7 messages?
Design consumers to tolerate them. Use upsert semantics so an update can create a record if the original event has not arrived, hold dependent events briefly and retry, and key processing on message control IDs to discard duplicates. Log ordering anomalies for review, and reconcile counts against the source system daily to catch anything missed.
What should we monitor in a healthcare integration?
Monitor message throughput per interface against expected baselines, end-to-end latency, error and dead-letter queue growth, acknowledgment failures, certificate expiry dates, and delivery confirmations for FHIR Subscriptions or webhooks. Alert on unexpected silence as well as on errors, since a stopped feed often produces no error at all.