nHapiNET / nHapi

nHapi is the .Net port of the original Java project HAPI.
Mozilla Public License 2.0
275 stars 156 forks source link

Unescaped & or ^ in the OBX-5 #570

Closed samofwise closed 2 months ago

samofwise commented 2 months ago

I am receiving Unescaped & or ^ in the OBX-5 when a lab is sending Formatted Text (FT) such as links or html link tags (www.medical-website.com?param1=value1&param2=value2)

I know that the clinics should be escaping these characters with \T\ and \S\ but the labs are not doing this.

Is there any way to create a custom parser for OBX-5 that will skip the component and subcomponent delimiter parsing? (I would prefer to not have to pre-process the file with regex to escape those characters, as that solution seems very fragile)

Or are there any other solutions for this issue?

(I found someone else encounter this issue too: https://stackoverflow.com/questions/8935497/ampersand-character-in-obx-segment-causing-problems-hl7-formatting)

OBX Example

OBX|1|FT|HTML^Display format in HTML^AUSPDI|1|<HTML><P>This report has been forwarded to &quot;DOCTOR, Dr Demo&quot; from &quot;TEST&quot; with the following comments:<br />&quot;TESTING HTML URL&quot;<br /><br /></P><B><A HREF="http://www.healthlink.net">CLICK HERE TO VIEW THE IMAGES (2)</A></B><BR><BR><br><U><STRONG>CHEST X-RAY</STRONG></U><br><br><U><STRONG>HISTORY</STRONG></U><br>Left lateral chest wall pain.  Previous breast surgery and axillary lymph<br>node resection.  <br><br><U><STRONG>FINDINGS</STRONG></U><br>The prior left sided breast and axillary surgery is noted along with<br>insertion of bilateral breast prostheses.  There is also a surgical clip in<br>the left upper quadrant and there may have been a prior splenectomy. <br>Allowing for this, no pulmonary parenchymal mass is seen to suggest a<br>metastatic deposit.  There is minor tenting to the dome of the left<br>hemidiaphragm which would be compatible with postinflammatory scarring<br>(possibly related to prior the prior surgery and/or radiotherapy).  No<br>pleural fluid is seen.  The heart is not enlarged and the hilar complexes<br>have a normal configuration.  There is no apparent widening of the superior<br>mediastinum.  <br>No advanced bony destructive lesion is detected.  <br><br><U><STRONG>COMMENT</STRONG></U><br>No definite evidence of metastatic disease identified but if a skeletal<br>deposit is still clinically suspected then further assessment with an<br>isotope bone scan is suggested.  <br><br>Thank you for referring this patient.<br><br><U><STRONG>Mr Radiol Ogist</STRONG></U><br><br><br></HTML>||||||F

Specifically "forwarded to & quot;DOCTOR, Dr Demo & quot; from"

Issue on NHapiTools: https://github.com/dib0/NHapiTools/issues/29

jakubsuchybio commented 2 months ago

You can reconfigure your side to use different separators in the MSH and the other party should respect that. In that case you can use some other separator for the subcomponent separator instead of '&' Here is the spec of the MSH.2 https://hl7-definition.caristix.com/v2/HL7v2.5.1/Fields/MSH.2 Or better yet, try to tell the lab to change their separators as well.