{
  "id": 13126078,
  "title": "What a test HL7 v2 sender has to get right",
  "url": "https://urgent.news/2026/10/09/what-a-test-hl7-v2-sender-has-to-get-right",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-09T13:46:36.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/vijayamirtharajxavier/what-a-test-hl7-v2-sender-has-to-get-right-36fh"
  },
  "original_language": "en",
  "account": "Sending an HL7 v2 message involves a few key steps. First, establish a TCP socket connection and wrap the message in MLLP framing. Then, write the message and read the acknowledgment that comes back. The challenge lies in ensuring the message is delivered successfully, not just that it was received. To do this, test engineer learned that an ACK timeout needs to be a total deadline, not a read timeout. Set the socket timeout based on the remaining time, not a fixed value like 30 seconds. An ACK is only valid if the MSA-2 code matches the MSH-10 of the sent message. If it doesn't match, it belongs to a different message, which could lead to a message being lost. The test tool must handle ambiguous responses by closing the connection after a timeout or mismatch. HL7 v2 has two acknowledgment modes, and their codes look like pairs. However, the commit codes (CR and CE) have different implications. CR means the receiver won't take the message, while CE means there's a different issue that might be resolved with a retry. Enhanced mode requires two steps: a commit ACK on the same connection and an application ACK on a separate connection. If the sender marks the message as done on the CA, a later application error won't be recorded. A crash during the send process can result in message loss or reordering. To prevent this, HL7 Sender writes the state before performing network I/O, using SQLite with WAL mode and synchronous=FULL.",
  "summary": "Sending an HL7 v2 message is easy. Open a TCP socket, wrap the message in MLLP framing, write it, and read whatever comes back. You can do it in twenty lines of code, and there are plenty of tools that do. Knowing whether the message actually arrived, and what to do when it didn't, is the hard part. I found that out while building HL7 Sender ,an open-source desktop app and CLI for testing HL7 v2…",
  "key_points": [
    "Establish TCP socket connection and wrap message in MLLP framing",
    "Ensure ACK is valid by matching MSA-2 to MSH-10 code",
    "Handle ambiguous responses by closing connection after timeout or mismatch"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}