Skip to main content

$v2json

$v2json(hl7MessageText) -> object

Source: FUME

Documentation

Parses a raw HL7 v2 ER7 message string into the normalized JSON object shape used by the engine.

This is the same parser the engine runs before evaluating HL7 v2 requests, but it is also useful mid-mapping when part of your input contains an embedded HL7 message string. The returned object is keyed by segment id and uses dictionary-backed field names where available. Message shape depends on the segments present in the input, and the parser supports the same unknown-field and line-numbering cases covered by the engine integration tests.

Examples

Parse an HL7 v2 message into normalized JSON

Input

This example uses the canonical hl7v2-adt-mini message as the raw input string passed to the function.

Example input

HL7 v2
MSH|^~\&|EXCARE|EXCARE-CLINIC|FUME|FUME|20260318091500||ADT^A01|msg-0001|P|2.5
EVN|A01|20260318091500
PID|1||rec-5001^^^EXCARE^MR||Reed^Avery||19900612|F
PV1|1|O|||||||||||||||||enc-1001^^^EXCARE^VN

Expression

$v2json($)

Result

{
"MSH": {
"SendingApplication": {
"NamespaceID": "EXCARE"
},
"MessageType": {
"MessageCode": "ADT",
"TriggerEvent": "A01"
}
},
"PID": [
{
"PatientIdentifierList": [
{
"IDNumber": "rec-5001"
}
],
"PatientName": [
{
"FamilyName": {
"Surname": "Reed"
},
"GivenName": "Avery"
}
]
}
],
"PV1": [
{
"VisitNumber": {
"IDNumber": "enc-1001"
}
}
]
}