getting exceptions when trying to parse hl7 messages containing large data in obx-5
getting the following exception when parsing files containing large embedded images:
Parse error in DoEDieIn: NHapi.Base.DataTypeException: Failed validation rule: Maxumim size <= 65536 characters at NHapi.Base.Model.Varies.fixOBX5(ISegment segment, IModelClassFactory factory) at NHapi.Base.Parser.PipeParser.Parse(ISegment destination, String segment, EncodingCharacters encodingChars) at NHapi.Base.Parser.PipeParser.DoParse(String message, String version) at NHapi.Base.Parser.ParserBase.Parse(String message, String version) at EPDHL7ListenerSvc2.EPDHL7ListenerSvc2.TryParseMessage(String HL7Message).
not sure if this limitation is to be expected or maybe it will be resolved in future versions
Regards, Alex
hi @AlexFJaxFL do you have any example code?
also @AlexFJaxFL might be worth checking #105 to see if this issue is similar or not?
hi @AlexFJaxFL do you have any example code?
Public Shared Function ParseHL7Messages(HL7Messages As String, FType As FeedType) As Boolean Dim MsgType As String = "" Dim SendingApp As String = "" Dim iEPDFacNo As Integer = 0
Try
FieldSeparator = HL7Messages(3)
ComponentSeparator = HL7Messages(4)
Dim HL7MessageName As String = ""
If Not HL7Messages.StartsWith("MSH") Then
If blnInService = True Then 'if running in the service
WriteEventLog("Error in ParseHL7Messages: does not start with MSH " & vbCrLf & HL7Messages, EventLogEntryType.Error)
Else
Dim ex As New Exception("Error in ParseHL7Messages: does not start with MSH " & vbCrLf & HL7Messages)
Throw ex
End If
End If
Dim prsr As New Parser.PipeParser()
Dim imsg As Model.IMessage = Nothing
Dim trsr As Util.Terser
Dim blnFilterOut As Boolean = False
For Each strMsg In HL7Messages.Split(New String() {"MSH|"}, StringSplitOptions.RemoveEmptyEntries)
strMsg = "MSH|" & strMsg 'add the split chars back on.
'If prsr.GetMessageStructure(strMsg) = "ORU_R01" Then
strMsg = SetOBX2DataType(strMsg) '
'End If
Try
imsg = prsr.Parse(strMsg)
Catch ex As Exception
Try
EPDnHapi.SetPtrnFindReplace(strMsg)
imsg = prsr.Parse(strMsg)
Catch ex1 As Exception
If strMsg.Contains("ORU^R01") OrElse strMsg.Contains("ORM^O01") Then ' for IB ORU/ORM clearing OBR-13 since not needed
EPDnHapi.ClearField(strMsg, "OBR|", 13) ' and causing problems for parser (AF)
Try
imsg = prsr.Parse(strMsg)
Catch ex2 As Exception
imsg = prsr.Parse(strMsg, "2.4")
End Try
End If
End Try
End Try
also @AlexFJaxFL might be worth checking #105 to see if this issue is similar or not?
i can see there is certain correlation between my issue and discussion that took place in #105, my data looks like this:
maybe this structure does not match what your engine parser is expecting ..
Hi @AlexFJaxFL we have some unit tests showing how it should look, https://github.com/nHapiNET/nHapi/blob/a9f42181815e035383120540160d470c03f60918/tests/NHapi.Benchmarks/LargeEmbeddedFileTest.cs#L23 There is also this blog which might help. http://healthbase.info/blog/?p=376
Ok, this information is very helpful indeed and will be used for .pdf related feeds which we have plenty. What approach should I use if incoming hl7 message contains .rtf content in obx-5 the way I demonstrated above ?
@AlexFJaxFL I think you can use a similar approach to the pdf for rtf files.
@AlexFJaxFL I think you can use a similar approach to the pdf for rtf files.
ok, data does not come in to us in the same format so i will have to do some custom programming to adjust accordingly and then will go from there
it appears other data types in OBX-2 (like ST, TX and ED which is used in your example above) work with nhapi parser just fine, however, in our case, we are getting type FT [formatted text] and for this type nhapi for me does not always work as expected.
data comes in like this: OBX|1|FT|^EDIE_VISIT_HISTORY||{\rtf1{\info{\
planning to override FT and make it ST or TX unless perhaps you might provide some other recommendations
@AlexFJaxFL do you have some sample code? I suspect it could be something to do with special character escaping etc
@AlexFJaxFL do you have some sample code? I suspect it could be something to do with special character escaping etc
Public Shared Function TryParseMessage(HL7Message As String) As String 'Steve K. - 20210503
Dim imsg As Model.IMessage = Nothing
Dim prsr As New Parser.PipeParser()
Dim ret As String = ""
Try
If Not HL7Message.StartsWith("MSH") Then
If blnInService = True Then 'if running in the service
WriteEventLog("Error in TryParseMessage: does not start with MSH " & vbCrLf & HL7Message, EventLogEntryType.Error)
Else
Dim ex As New Exception("Error in TryParseMessage: does not start with MSH " & vbCrLf & HL7Message)
Throw ex
End If
End If
Try
HL7Message = SetOBX2DataType(HL7Message) 'Steve K. - 20210504
imsg = prsr.Parse(HL7Message)
Catch ex As Exception
Try
EPDnHapi.SetPtrnFindReplace(HL7Message)
imsg = prsr.Parse(HL7Message)
Catch ex1 As Exception
If HL7Message.Contains("ORU^R01") OrElse HL7Message.Contains("ORM^O01") Then ' for IB ORU/ORM clearing OBR-13 since not needed
EPDnHapi.ClearField(HL7Message, "OBR|", 13) ' and causing problems for parser (AF)
Try
imsg = prsr.Parse(HL7Message)
Catch ex2 As Exception
imsg = prsr.Parse(HL7Message, "2.4")
End Try
End If
End Try
End Try
If imsg Is Nothing Then
ret = $"Can't parse HL7Message: {vbCrLf}{EPDnHapi.GetCleanHeaderString(HL7Message)}"
End If
Catch ex As Exception
imsg = Nothing
ret = ex.ToString 'If error return error messsage.
End Try
Return ret
End Function
client that had this issue decided to use another vendor next year so this issue does not seem as critical
@AlexFJaxFL do you have an example message?