senaranya/HL7

Collect the third level

GELELOIC opened this issue · 2 comments

Hello,

Can we easily get the third level of an object?

Example :
$orc->getEnteringOrganization()->getAlternateIdentifier() ?

Because I feel like it's not possible.

^^^123456

So how to recover ORC17.4 because $orc->getEnteringOrganization() returns a string.

Thanks you!

That's right, it won't return an object. If there are more than one non-null subfields in a field, it'll return an array, else it'll return a string.

However, you can pass true as third argument to Message() constructor when you're parsing, so it honors the position of the sub-field.

That is,

$msg = new Message($hl7String, null, true); // Or, with PHP-8: new Message($hl7String, keepEmptySubFields: true);
$orc = $msg->getFirstSegmentInstance('ORC');
$orc->getEnteringOrganization(); // This will now return ['', '', '', '123456'] for the ORC.17 field `^^^123456`

Great

Thank you for your help.

Good day