Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to get number of segments in a hl7 message and then pull a field value from the last segment

Question
ED Coder · Aug 30, 2019

How to get number of segments in a hl7 message and then pull a field value from the last segment

Hi, Is there a way to count the number of segments in a HL7 Mesage? I tried the examples from the other answers but nothing works for me.

I am writing a function to get the last OBX segment field value 5. Below is a sample screenshot of what I want.

The number of obx segments can change, so I want to count the last obx segment and then get the field 5 value.

Would appreciate some guidance on this.

#Ensemble

Source URL:https://community.intersystems.com/post/how-get-number-segments-hl7-message-and-then-pull-field-value-last-segment