Question
· Feb 8, 2019

How to get the length of A Segment In HL7

I am trying to get the values of a PID:3 segment to an  array but I will need to know the length of the segment to process .

set o = ##class(EnsLib.HL7.Message).%OpenId(458)

w o.GetValueAt("PID:3")

w o.GetValueAt("PID:3").SegCount  This throws an error any help appreciated

Discussion (4)3
Log in or sign up to continue

Hi Thembalani,

The property SegCount will only show you on the message level how many "lines" the message has. Ex (MSH,PID,PV1) = 3

If you want the individual pieces in the message you will have to first get to the segment correctly, this is dependent on the version of HL7 you're using. My exampe is from 2.6

>w o.GetValueAt("PIDgrpgrp(1).PIDgrp.PID:PatientIdentifierList()")
6107145310089^^^^NNZAF
 

You can then piece it out on "^"

>w $L(o.GetValueAt("PIDgrpgrp(1).PIDgrp.PID:PatientIdentifierList()"),"^")
5
 

Hope this helps