-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segment separators are not correct #22
Comments
You can override the segment separator while creating Message object:
|
Also see here: https://healthstandards.com/blog/2007/09/24/hl7-separator-characters/
And for my particular use case I do not create a new message. The fragment is as follows:
|
Please use I know \n is non-standard, but a lot orgs have configured their RIS to accept it. Making a core change in the default such as this is going to break a lot of systems that are using this library. |
I understand the problem. But how to fix the behaviour for |
You can pass a Message object to the constructor of ACK: $msg = new Message(<HL7 string>, ['SEGMENT_SEPARATOR' => <separator character>]);
$response = new ACK($msg); |
Did the above work for you? |
No, the ACK still contains "\n" (backslash followed by "n" (ASCII 92, ASCII 100)) and not CR (ASCII 13) as segment separator. Edit: the code fragment I tried: $request = new Message($message, ['SEGMENT_SEPARATOR' => "\015"]);
$response = new ACK($request);
$responseData = $response->toString(); |
I think the problem is, that the constructor of Maybe it would be better to just have one instance of So this could be used then like this: $hl7 = new HL7(['SEGMENT_SEPARATOR' => "\015"]);
$request = $hl7->createMessage($message);
$response = $hl7->createACK($request);
$responseData = $response->toString(); |
I just updated my pull request with the proposed changes. |
Thanks for the pull request. We shouldn't use the HL7 class though, it is not tested and not used anywhere. I've kept it thinking someday it'd be a front facade for creating HL7 messages, but Message class is working pretty well for everyone so far. So I might remove HL7 class for good. So please replace
Thank you for the pull request, appreciate your contribution. We'll need to make a few changes though:
|
I'm sorry... but Also see here: $message .= $pretty
? str_replace(['\r', '\n'], ["\r", "\n"], $this->segmentSeparator)
: $this->segmentSeparator; Please note: inside single quotes PHP does not expand https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single |
Maybe it would be a good idea, to expand the constructor of |
Thanks for the update in pull request. I'll merge it once tests and readme are added. If you'd want me to do it, I can do over the weekend. |
Thank you. It's not that urgent - just take your time. For now I have a local workaround which will do until there is an official update of your component. Thanks for your work! |
In certain places the segment separators are defined as following:
$this->hl7Globals['SEGMENT_SEPARATOR'] = '\n';
However - this is not correct:
'\n'
will translate to two characters and not to a newline."\015"
(ASCII 13, CR) and not just a newline.The text was updated successfully, but these errors were encountered: