Class Name: |
HL7PlusField |
HL7+ Category: |
Restricted (Accessed through the HL7PlusSegment object) |
Description: |
Object representation of 1 Field in a HL7PlusSegment |
The HL7PlusField object is accessed through the HL7PlusSegment object through the Field property as well as other properties.
*All example code is in Visual Basic.Net
'Where MyController is a HL7PlusController object Dim oMSg As HL7PlusMessage = MyController.NewHL7PlusMessage() If IsNothing(oMSg) Then MessageBox.Show("An Error Occurred: " & MyController.LastError, "Error") Return End If 'oMsg is now an EMPTY HL7 message. 'From this point on we don't have to worry about HL7PlusController Errors 'In an EMPTY message I MUST add the MSH segment first Dim oMSH As HL7PlusSegment = oMSg.AddEmptySegment("MSH") '--------------------------------- '--------------------------------- '--------------------------------- 'The following 3 snippets do EXACTLY the same thing '-----------#1--------------- oMSH.Field(9).ComponentValue(1) = "ADT" oMSH.Field(9).ComponentValue(2) = "A01" '-----------#2--------------- Dim oFld9 As HL7PlusField = oMSH.Field(9) With oFld9 .ComponentValue(2) = "A01" .ComponentValue(1) = "ADT" End With '-----------#3--------------- 'I can also just set the VALUE property with the raw 'value for the entire field. Useful for fields with only 1 'component, but can be used for compound fields as well. 'This only works if ComponentDelimiter is ^ oFld9.Value = "ADT^A01" MessageBox.Show(oMSH.Field(9).Value, "Field 9 of the MSH Segment")
|
|
|
This object class uses our standard HL7PlusException Class interface for error handling wherever possible.
See the HL7PlusException Implementation Reference
|
*All example code is in Visual Basic.Net
'Where MyController is a HL7PlusController object Dim oMSg As HL7PlusMessage = MyController.NewHL7PlusMessage() If IsNothing(oMSg) Then MessageBox.Show("An Error Occurred: " & MyController.LastError, "Error") Return End If 'oMsg is now an EMPTY HL7 message. 'From this point on we don't have to worry about HL7PlusController Errors 'In an EMPTY message I MUST add the MSH segment first Dim oMSH As HL7PlusSegment = oMSg.AddEmptySegment("MSH") '--------------------------------- '--------------------------------- '--------------------------------- 'The following 3 snippets do EXACTLY the same thing '-----------#1--------------- oMSH.Field(9).ComponentValue(1) = "ADT" oMSH.Field(9).ComponentValue(2) = "A01" '-----------#2--------------- Dim oFld9 As HL7PlusField = oMSH.Field(9) With oFld9 .ComponentValue(2) = "A01" .ComponentValue(1) = "ADT" End With '-----------#3--------------- 'I can also just set the VALUE property with the raw 'value for the entire field. Useful for fields with only 1 'component, but can be used for compound fields as well. 'This only works if ComponentDelimiter is ^ oFld9.Value = "ADT^A01" MessageBox.Show(oMSH.Field(9).Value, "Field 9 of the MSH Segment")
|
*All example code is in Visual Basic.Net 'Where MyController is a HL7PlusController object Dim oMsg As HL7PlusMessage = MyController.NewHL7PlusMessage(MyController.ExampleHL7MessageString) If IsNothing(oMsg) Then MessageBox.Show("An Error Occurred: " & MyController.LastError, "Error") Return End If 'oMsg is now and EMPTY message Dim oMSH As HL7PlusSegment = oMsg.AddEmptySegment("MSH") '...Code... '...Code... '...Code... Dim oEVN As HL7PlusSegment = oMsg.AddEmptySegment("EVN") '...Code... '...Code... '...Code... '------------- 'Make the PID segment Dim oPID As HL7PlusSegment = oMsg.AddEmptySegment("PID") '...Code... '...Code... 'WAIT! We now have to do a repeating field for example 'PID field 9, the Patient Alias. 'Our HL7 message is for Billy The Kid. Dim oFld9 As HL7PlusField = oPID.Field(9) 'Our Name Values First Alias Dim oLst1 As New List(Of String) oLst1.Add("Bonney") '--Last Name oLst1.Add("William") '--First oLst1.Add("H") '--Middle 'Second Alias Name Dim oLst2 As New List(Of String) oLst2.Add("Kid") '--Last Name oLst2.Add("Billy") '--First oLst2.Add("The") '--Middle With oFld9 '-------Method 1--------- 'We can just set the first instance like this .ComponentValue(1) = oLst1(0) .ComponentValue(2) = oLst1(1) .ComponentValue(3) = oLst1(2) '--OR LIKE THIS .ComponentValue(1, 1) = oLst1(0) .ComponentValue(2, 1) = oLst1(1) .ComponentValue(3, 1) = oLst1(2) 'NOW set the repeating instance like so .Component(1, 2).Value = oLst2(0) .Component(2, 2).Value = oLst2(1) .Component(3, 2).Value = oLst2(2) '--OR LIKE THIS .ComponentValue(1, 2) = oLst2(0) .ComponentValue(2, 2) = oLst2(1) .ComponentValue(3, 2) = oLst2(2) MessageBox.Show(.Value, "Field 9 Value") .Clear() ' Start over '-------Method 2--Using Lists (of String)------- .SetFieldValue(oLst1, 1) .SetFieldValue(oLst2, 2) MessageBox.Show(.Value, "Field 9 Value Set with 2 lists") .Clear() ' Start over '-------Method 3--Using A List (Of List(of String))------- Dim oLst3 As New List(Of List(Of String)) oLst3.Add(oLst1) oLst3.Add(oLst2) .SetFieldValue(oLst3) MessageBox.Show(.Value, "Field 9 Value Set with List(of List)") .Clear() ' Start over 'Finally, If you're really good you can set the whole 'field with pre-formatted HL7 values 'This ONLY works if ComponentDelimiter is ^ 'AND RepeatDelimiter is ~ Dim strFld9 As String = "Bonney^William^H~Kid^Billy^The" oFld9.Value = strFld9 MessageBox.Show(.Value, "Field 9 Value Set Directly") End With
|