You can get my hl7 parser utility here:
https://usspvlclovertch2.infor.com/viewtopic.php?p=19423#19423
Reposting from a previous thread:
Attached are two procs that we’ve created for doing what you want.
We use them all the time. They cut development time down to ‘next to nothing’.
Charlie probably won’t agree with this method but it works very well for us.
Usage is:
vm_getHL7
and
vm_setHL7
The only caveat is when dealing with the MSH segment. Adjust the field count by -1 due to the field separator counting as a field.
Examples:
set event [vm_getHL7 $msg MSH 0 8 0 1] ;(Looking for MSH-9.1, see caveat)
set MRN [vm_getHL7 $msg PID 0 3] ;(get MRN)
set MRN2 [vm_getHL7 $msg PID 1 3] ;(get MRN from 2nd instance of PID (usually A17 messages))
set OBX5 [vm_getHL7 $msg OBX $count 5] ;(part of a foreach that increments $count)
and
set msg [vm_setHL7 $msg [vm_getHL7 $msg PV1 0 19] PID 0 18] ;(copies value in PV1-19 to PID-1Cool
set msg [vm_setHL7 $msg {} PV1 0 19] ;(blank out PV1-19)
set msg [vm_setHL7 $msg VMMC MSH 0 3] ;(hard code VMMC in MSH-4, see caveat about MSH)
set msg [vm_setHL7 $msg 03 PV1 0 3 0 2] ;(hard code bed value to 03)
For additional info you can email me at michael.hertel@vmmc.org