Class Name: |
HL7PlusStringAnalyzer |
HL7+ Category: |
|
Description: |
HL7+ utility class for parsing String values which contain (or might contain) multiple HL7 messages. |
If you have a STRING value which contains a fully formed HL7 message you can use the HL7PlusMessage object and set the Value property to populate the object. However, what do you do if you have a STRING value which contains multiple fully formed HL7 messages?
That's where the HL7PlusStringAnalyzer object class comes in. If you have a .Net String which contains multiple fully formed HL7 messages you can use this object to parse that value into individual HL7PlusMessage objects.
IMPORTANT Conditions and Restrictions: In order for this object to work properly your String value must contain HL7 messages which all use the same Encoding Characters. The Segment Delimiter is used in the parsing operation and this value is inherited from the SegmentDelimiter property of the HL7PlusController object which creates it. Your String of HL7 messages must use the same segment delimiter as the HL7PlusController object which is used to create the HL7PlusStringAnalyzer (see Implementation below).
*All example code is in Visual Basic.Net
Dim strMessages As String = "" Dim i As Integer Dim MyAnalyzer As HL7PlusStringAnalyzer 'Where MyController is a HL7PlusController object With MyController MyAnalyzer = .NewHL7PlusStringAnalyzer() If IsNothing(MyAnalyzer) Then 'An error occurred. Most likely .IsRunnable = False MessageBox.Show(.LastError, "Error") Return End If 'Make a string with more than 1 message strMessages = .ExampleHL7MessageString & .ExampleHL7MessageString & .ExampleHL7MessageString 'NOTE: If you pass your string when you create the 'object it will automatically set the Value property 'AND call AnalyzeValue like so 'EXAMPLE: MyAnalyzer = .NewHL7PlusStringAnalyzer(strMessages) End With With MyAnalyzer 'Set the Value Property .Value = strMessages 'Now Analyze the Value If Not .AnalyzeValue() Then MessageBox.Show(.LastError, "Analyzer Error") Return End If If .Count = 0 Then MessageBox.Show("String contains no HL7 messages") Return Else MessageBox.Show("String Contains " & .Count.ToString & " messages") End If If .InvalidMessageCount > 0 Then MessageBox.Show("Warning. There are" & .InvalidMessageCount.ToString & " invalid messages") End If Dim oMsgs As List(Of HL7PlusMessage) = .HL7MessageList Dim oVals As List(Of String) = .HL7ValuesList Dim sMsg As String = "" For i = 0 To oMsgs.Count - 1 If IsNothing(oMsgs(i)) Then 'This is one of the invalid messages sMsg = "Message #" & i.ToString & " did not parse correctly. " & Environment.NewLine & "Value=" & Environment.NewLine & oVals(i) MessageBox.Show(sMsg, "Parse Error") Else With oMsgs(i) '..Code..... '..Code..... '..Code..... End With End If Next End With
|
|
|
|
This object class uses our standard HL7PlusException Class interface for error handling wherever possible.
See the HL7PlusException Implementation Reference
|