Bugs5382 / node-hl7-client

A pure Node.js HL7 Client that allows for communication to a HL7 Broker/Server that can send properly formatted HL7 messages with ease.It can also parse and then you can extract message segments out.
MIT License
14 stars 4 forks source link

fix: MSH.9.3 in acknowledgment incorrectly formatted for hl7 spec 2.4+ #93

Closed jtarvainen closed 3 months ago

jtarvainen commented 3 months ago

For an acknowledgment message using the HL7 2.5.1 specification, the MSH.9.3 subfield is set to the values of MSH.9.1 and MSH.9.2, separated by an underscore:

https://github.com/Bugs5382/node-hl7-client/blob/eee724ed7d68d3f578a895a046e8302e96829ba4/src/specification/2.4.ts#L80

We have a device that uses HL7 2.5.1 but expects the MSH.9.3 subfield to contain only the MSH.9.1 value. For example, it expects the MSH.9 field to have the format "ACK^R22^ACK", but node-hl7-client sets the value to "ACK^R22^ACK_R22", which is not accepted.

Could you please check if the formulation of the MSH.9.3 subfield in node-hl7-client is correct? If it is, then there would need to be some way to bypass the default field value when constructing the acknowledgment message.

Thanks!

Bugs5382 commented 3 months ago

@jtarvainen I have been out for a while, but I will take a look at this week and have an answer for you.

Bugs5382 commented 3 months ago

@jtarvainen Ok... So this is what I used as my reference:

On this page MSH9.1 through MSH9.3 are all required. For MSH9.3 it says:

Specifies the abstract message structure code. Refer to HL7 Table 0354 - Message Structure in section 2.17.3 for valid values.

Table 0354 shows that everything is 9.1 + 9.2 with the underscore as the value. I can see that just plain ACK is valid.

image

ooops.

It looks like it only started being valid for 2.4 and beyond. Let me correct that. I will also have to update the node-hl7-server package. I saw your comment there.

Bugs5382 commented 3 months ago

@jtarvainen Please review the branch created:

https://github.com/Bugs5382/node-hl7-client/blob/7af097037e201b7fb63394ea757c2edf688a965c/src/specification/2.4.ts#L34-L37

Made it so now msh_9_3 can be set during the build. It is optional.

https://github.com/Bugs5382/node-hl7-client/blob/7af097037e201b7fb63394ea757c2edf688a965c/src/specification/2.4.ts#L85-L88

If msh_9_3 is not passed over, it will do as it's been doing. Otherwise...

https://github.com/Bugs5382/node-hl7-client/blob/7af097037e201b7fb63394ea757c2edf688a965c/__tests__/hl7.build.test.ts#L154-L168

It can be overridden. I know I am working on the riddle of my node-hl7-server package since I use 2.7 as the default. Please confirm if this is what you are looking for.

jtarvainen commented 3 months ago

@Bugs5382 Thanks, that seems to do what I need. But can you clarify how I would, as you say, set the field during the build? When I create a node-hl7-server Server instance like so:

new Server().createInbound({ port: 3000 }, async (req, res) => { ... })

then I currently have no control over how res (specifically, its private field _message) is constructed.

Bugs5382 commented 3 months ago

@jtarvainen Yep. Ok. Let me commit this here, so I can update the node-hl7-server package and update that documentation as well.

The node-hl7-server package uses this package to build it out.

Bugs5382 commented 3 months ago

Release in node-hl7-client@2.1.1-beta.1. I brought that over into the node-hl7-server to work on that issue.

Bugs5382 commented 3 months ago

@jtarvainen Check out https://github.com/Bugs5382/node-hl7-server/issues/76#issuecomment-2145819831

jtarvainen commented 3 months ago

Looks good to me!

Bugs5382 commented 3 months ago

@jtarvainen This package has been released! Be sure to leave me a star!