Skip to content
LambogeniusDocs

HL7 v2 Codec for Azure Logic Apps

Decode HL7 message

Inputs, outputs, ACK codes and error details of the decode action.

Service provider/serviceProviders/lamboHl7CodecLicensed together with the HL7 MLLP Connector. One token covers both.

Inputs

The designer shows the main inputs (output format, validate, generate ACK, ACK mode); the rest are under Advanced parameters.

InputDefaultMeaning
message(required)ER7 payload: a single message, several messages, or an FHS/BHS batch. MLLP framing and CR, LF or CRLF are accepted.
validateXmltrueValidate the XML against the XSD (errors → AE).
generateAcktrueBuild the ACK/NAK.
ackModeAutoAuto (enhanced CA/CE/CR when MSH-15/16 are present, honouring AL/NE/ER/SU), Original, Enhanced.
outputFormatxmljson returns the same document as JSON (JSON instead of XML).
schemaNameemptyEmpty = automatic (how schemas are chosen). Otherwise a root name, file.xsd or file.xsd#ROOT.
allowSchemalessfalseNo schema found → generic XML (PID_3, PID_3_3 names, no groups) instead of AR / 200.
allowUndefinedZSegmentstrueKeep Z-segments the XSD doesn't define (warning; left out of validation). false = error.
allowUndefinedContenttrueKeep HL7 extensions (see behaviour). false = errors (AE).
supportedVersionsemptyFor example 2.5.1,2.4: other MSH-12 versions → AR / 203.
ackSendingApplication, ackSendingFacilityMSH-5, MSH-6MSH-3 / MSH-4 of the ACK.
wrapAckInMllpfalseAdd MLLP framing to the ACK.
indentfalsePretty-print the XML or JSON.
schemaFolderconnection, else Artifacts/SchemasFolder with the XSDs.

Output

Outputs are in the action's body, in camelCase. body('Decode_HL7') is this object (run history shows it under body, next to statusCode):

body('Decode_HL7')
├─ success        true when every message decoded without errors (warnings allowed)
├─ isBatch, messageCount
├─ ackCode        the FIRST message's
├─ xml            the FIRST message's document, as a string (outputFormat xml)
├─ json           the same document as JSON text (outputFormat json); the other one is null
├─ outputFormat   "xml" or "json"
├─ ack            the FIRST message's ACK (ER7)
├─ batchAck       FHS/BHS … BTS/FTS around every message's ACK, for a batch
├─ messages[]     one entry per message, in input order:
│    success, ackCode, messageType, triggerEvent, messageStructure, version, controlId,
│    sendingApplication, sendingFacility, receivingApplication, receivingFacility, processingId,
│    schema, xml, json, ack, errors[]
└─ errors[]       every message's errors: code, codeText, severity, message, location, controlId
  • xml and json are strings, not objects. Read them with xml(body('Decode_HL7')?['xml']) and xpath(), or with json(body('Decode_HL7')?['json']). See Maps and XPath.
  • MSH is in the document, and its main values are also copied into each messages[i]. body('Decode_HL7')?['messages']?[0]?['controlId'] is MSH-10 without any XPath.
  • The top-level xml, json, ack and ackCode are the first message's. For a batch or several messages, loop over messages. Each entry has its own document, ACK and errors. success covers all of them.
  • The input isn't repeated in the outputs. It is in the action's inputs in run history.

A message whose PID-8 is X, a value the schema's table doesn't allow:

{
  "success": false,
  "isBatch": false,
  "messageCount": 1,
  "ackCode": "AE",
  "xml": "<ns0:ADT_A01_25 xmlns:ns0=\"http://lambogenius.com/HealthCare/HL7/2X\"><MSH>…</ns0:ADT_A01_25>",
  "json": null,
  "outputFormat": "xml",
  "ack": "MSH|^~\\&|TARGET|FACILITY|HOSPITAL|FACILITY|20261021182459-0400||ACK^A01^ACK|20261021222459365359|T|2.5\rMSA|AE|MSG00003|XSD validation: …\rERR||PID^3^8^1|102^Data type error^HL70357|E||||XSD validation: …\r",
  "batchAck": null,
  "messages": [ {
    "success": false, "ackCode": "AE",
    "messageType": "ADT", "triggerEvent": "A01", "messageStructure": "ADT_A01", "version": "2.5", "controlId": "MSG00003",
    "sendingApplication": "HOSPITAL", "sendingFacility": "FACILITY", "receivingApplication": "TARGET", "receivingFacility": "FACILITY",
    "processingId": "T", "schema": "ADT_A01_25.xsd#ADT_A01_25",
    "xml": "<ns0:ADT_A01_25 …", "json": null, "ack": "MSH|^~\\&|TARGET|…", "errors": [ … ]
  } ],
  "errors": [ {
    "code": "102", "codeText": "Data type error", "severity": "Error",
    "message": "XSD validation: The 'PID_8_AdministrativeSex' element is invalid - The value 'X' is invalid according to its datatype … - The Enumeration constraint failed.",
    "location": "PID[3].8(1)", "controlId": "MSG00003"
  } ]
}
  • errors[] carry the HL7 table 0357 code, codeText, severity (Error or Warning), message, controlId and a location.
  • Locations read SEGMENT[n].field(repetition).component.subcomponent, where n is the segment's position in the message: PID[3].8(1) is the third segment (the PID), field 8, first repetition.
  • The document is still returned when validation fails, so you can log or inspect it.

ACK codes, and when the action fails

ResultMeaning
AAAccepted.
AEStructure or validation errors. ERR segments describe them (v2.5+ layout with ERL location, table 0357 code, severity and ERR-8 text; ERR-1 for v2.4 and earlier).
ARCannot process: no MSH, no schema, or an unsupported version.
Action fails (400 / 500)Only a missing message (400) or an unexpected error (500). License problems fail with 403.
HL7 problems never fail the action

Check success or ackCode, route the errors, and return ack to the sender. That way a bad message gets a proper AE or AR instead of a failed run.