Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Xusifob
Copy link
Contributor

@Xusifob Xusifob commented Apr 3, 2025

When passing a multi level array such as this one inside the PID 2.3 :

array:2 [
  0 => array:5 [
    0 => "181015456787531"
    1 => ""
    2 => ""
    3 => array:3 [
      0 => "ASIP-SANTE-INS-NIR"
      1 => "1.2.250.1.213.1.4.8"
      2 => "ISO"
    ]
    4 => "INS"
  ]
  1 => array:5 [
    0 => 30174
    1 => ""
    2 => ""
    3 => "INSTAMED"
    4 => "PI"
  ]
]

It returned an error Array to string conversion

This also fixes a bug in the separator for repeater fields :

Tried with the file :

MSH|^~\&|INSTAMED||||20250403123507||SIU^S12|2025040312350786994||2.5.1|
PID|1||181015456787531^^^ASIP-SANTE-INS-NIR&1.2.250.1.213.1.4.8&ISO^INS~30174^^^INSTAMED^PI||ALERTE^Paul^^^M.^^B~D'USAGE^Paul^^^M.^^D||19810101000000|F|||||||fr|||30644^^^INSTAMED^PI|1 81 01 54 567 875 31|
PV1|1||||||MARTIN^Lucio^^^Dr|||||||||||||||||||||||||||||||||||||20210610180005|
SCH||23909^INSTAMED||||Consultation|||30|m|30^20250403104500^20250403111500|||||31427^MARTIN^Lucio|||||||||Booked|
RGS|1|A|
AIG|1|A|31427^Lucio MARTIN|
AIL|1|A|1eee125c-174f-683e-bafa-0d671a0f999f^Clinique Ambroise Paré|||20250403104500|||30|m^Minutes||Booked|
AIP|1|A|31427^MARTIN^Lucio^^^Dr|||20250403104500|||30|m^Minutes||Booked|

@Xusifob Xusifob marked this pull request as draft April 3, 2025 11:03
@Xusifob
Copy link
Contributor Author

Xusifob commented Apr 3, 2025

I need to add a new test and fix the existing test

@Xusifob Xusifob force-pushed the bugfix/multi-level-generation branch from 22e4a1f to d02387d Compare April 8, 2025 11:22
@Xusifob Xusifob marked this pull request as ready for review April 8, 2025 11:22
@Xusifob
Copy link
Contributor Author

Xusifob commented Apr 8, 2025

I've added a bunch of new elements :

  • An array repeaterFields in segment which contains the list of repeatable fields inside the object
  • A flag $extractRepeatableFieldAsMultiDimArray that can be enabled on the create Message level, which will export a field repeted into a multi dimentional array even if there is only 1 value in it. I've set it to false to avoid breaking changes

This allows to regenerate the same HL7 file in output that I had in input when there are single and multiple repeated fields

@senaranya
Copy link
Owner

Thanks for the PR. Since it touches core parts of the library, I need to look for any regression. It may take me a while before I can do the thorough checks.

Meanwhile, are you certain the existing configurations can't be used to achieve what you're looking for? I didn't get a chance to go through the entire set of changes in the PR, but since it looks to be related to array/subarrays, may be this from the readme could be of some help?

// Segment with separator character (~) creates sub-arrays containing each sub-segment
$message = new Message("MSH|^~\&|||||||ADT^A01||P|2.3.1|\nPID|||3^0~4^1"); // Creates [[3,0], [4,1]]

// To create a single array instead, pass 'true' as 6th argument. This may be used to retain behavior from previous releases
// Notice: Since this leads to a non-standard behavior, it may be removed in future
$message = new Message("MSH|^~\&|||||||ADT^A01||P|2.3.1|\nPID|||3^0~4^1", null, false, false, true, true); // Creates ['3', '0~4', '1']
// or
$message = new Message("MSH|^~\&|||||||ADT^A01||P|2.3.1|\nPID|||3^0~4^1", doNotSplitRepetition: true); // Creates ['3', '0~4', '1']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants