senaranya/HL7

inconsistent data position when parsing information

Florian-Rowehy opened this issue · 0 comments

I am working with HL7v2.5.1 and new to HL7.
It might be intended for the format but the data index is inconsistent depending on message data.

When receiving an ADT^A04 event for example, the patient firstname, email and phone number are optional.
I might receive:
PID|||25577203^^^App^PI||LASTNAME^^^^^^L|||U|MaidenName^^^^^^M||||
PID|||25577202^^^App^PI||LASTNAME^FirstName^^^^^L||19890220|M|Maiden_name^^^^^^M||||^^^patient@email.com
PID|||25577185^^^App^PI||LASTNAME^FirstName^^^^^L|||F|||||~+33320459845
PID|||25576798^^^App^PI||LASTNAME^FirstName^^^^^L||19890101|M|Maiden_name^^^^^^M||street name^^City^^00000||^^^patient@email.com~+33212358226
PID|||25577698^^^App^PI||LASTNAME^FirstName^^^^^L||19890101|M|Maiden_name^^^^^^M||||+33607252627^^^patient@email.com~+33405263633

When parsing the data using the Message constructor, pid->getField(5) //getPatientName will return an array
with [0=>LASTNAME, 1=>L] or [0=>LASTNAME, 1=>FirstName, 3=>L]

It is worse for the phone number & email.
$pid->get(13) can return a simple string like the email or phone number, an array
[
0 => "patient@email.com"
1 => "+33212358226"
]
or
[
0 => "+33320459845"
]
or even an array of array and string
[
0 => array:2 [
0 => "+33607252627"
1 => "patient@email.com"
]
1 => "+33405263633"
]

When I look at the HL7v2.5.1 PID13 definition

PID.13.1 - Telephone Number
PID.13.2 - Telecommunication Use Code
PID.13.3 - Telecommunication Equipment Type
PID.13.4 - Email Address
PID.13.5 - Country Code
PID.13.6 - Area/City Code

I would expect an array [
0 => "phoneNumber",
1=>"",
...
3=>"email"
...;
]

Same for the name:
[
0 => "LASTNAME",
1=>"FirstName",
...
6=>"NameTypeCode"
...;
]

Am I not using the correct settings or misunderstanding the library usage?