The same document, as JSON
Set Decode's outputFormat to json to get the document in json (xml is then null). Encode accepts either form. It uses the same element names as the XML, so the XSD still describes it:
{ "ADT_A01_25": {
"MSH": {
"MSH_1_FieldSeparator": "|",
"MSH_2_EncodingCharacters": "^~\\&",
"MSH_3_SendingApplication": { "HD_0_NamespaceId": "HOSPITAL" },
…
"MSH_9_MessageType": { "CM_MSG_0_MessageType": "ADT", "CM_MSG_1_TriggerEvent": "A01", "CM_MSG_2_MessageStructure": "ADT_A01" },
"MSH_10_MessageControlId": "MSG00001",
…
},
"EVN_EventType": { … },
"PID_PatientIdentification": {
"PID_1_SetIdPid": "1",
"PID_3_PatientIdentifierList": [ { "CX_0_IdNumber": "123456" } ],
"PID_5_PatientName": [ { "XPN_0_FamilyName": { "XPN_0_0_Surname": "DOE" }, "XPN_1_GivenName": "JOHN" } ],
"PID_7_DateTimeOfBirth": { "TS_0_Time": "19800115" },
"PID_8_AdministrativeSex": "M"
},
"PV1_PatientVisit": { "PV1_1_SetIdPv1": "1", "PV1_2_PatientClass": "I" } } }- Elements with children are objects; elements without children are strings, never numbers, so
"01"keeps its zero. - Anything the schema lets repeat is always an array, even with one occurrence (
PID_3_PatientIdentifierList,PID_5_PatientName, repeating groups), so the shape doesn't depend on the message. Index with?[0]or usefirst(). - Out-of-order repeats (
PR1, ROL, PR1) are written as{ "$sequence": [ … ] }to keep the order. The encoder accepts this form anywhere. - No namespaces: the encoder takes them from the schema.
In expressions
@json(body('Decode_HL7')?['json'])?['ADT_A01_25']?['MSH']?['MSH_10_MessageControlId'] → "MSG00001"
@json(body('Decode_HL7')?['json'])?['ADT_A01_25']?['PID_PatientIdentification']?['PID_3_PatientIdentifierList']?[0]?['CX_0_IdNumber'] → "123456"
@first(json(body('Decode_HL7')?['json'])?['ADT_A01_25']?['PID_PatientIdentification']?['PID_5_PatientName'])?['XPN_0_FamilyName']?['XPN_0_0_Surname'] → "DOE"To encode, pass the JSON string (or an object, which @{...} turns into its JSON text) to Encode's message input.