GetFieldDefaultValue()

Top  Previous  Next

Object: EHL7.EHL7Message

FileName: EHL7.dll

 

METHOD

 

Name: GetFieldValue()

Parameters:

1) oSegment (Segment Object)

2) nFieldNumber (Long) index of the data field element in the segment (1-xxx) to get value from

3) nFieldComponent (Optional Long) default = 0, which component of the field element to get default value from

       

Returns: String

Description: Returns the value from a field element of a segment.  If an error occurs IsError is set to true

 

Programming Note: Passing 0 (the default) in nFieldComponent will return the default value for the element in a string delimited by the Component delimiter in the EncodingChars property of the vendor object, otherwise returns just the default value for the component specified.

 

See Also: GetFieldValue(), SetFieldValue(), Extended Element Properties

 

Example:

Private Sub MessageTest()

Dim myVendorObj As New EHL7.HL7Vendors

Dim myMsg As New EHL7.EHL7Message

Dim strVendorID As String

Dim oSegment As Object

Dim oMSH As Object

Dim i As Long

myVendorObj.VendorPath = "C:\EasyHL7"

strVendorID = myVendorObj.GetVendorID("Default","2.3")

If strVendorID = "" Then

    MsgBox myVendorObj.LastError

    Set myVendorObj = Nothing

    Exit Sub

End If

If Not MyVendorObj.OpenVendor(strVendorID) Then

    MsgBox myVendorObj.LastError

    Set myVendorObj = Nothing

    Exit Sub

End If

With myMsg

   Set oMSH = .CreateMessage(myVendorObj)

   'Do some processing of the MSH Segment

   If .IsError Then

     MsgBox .LastError

     .ClearErrors

     Exit Sub

   End If

   'Add a patient identifier segment

   Set oSegment = .AddSegment("PID")

   If .IsError Then

     MsgBox .LastError

     .ClearErrors

     Exit Sub

   End If

  'Show the Default Value (if configured for the patient name field)

   Msgbox .GetFieldDefaultValue(oSegment,5)

   'Show the Default Value (if configured) for component 4 of the patient name field

   Msgbox .GetFieldDefaultValue(oSegment,5,4)

   'Add the patient's name

   .SetFieldValue "Smith", oSegment, 5, 1

   .SetFieldValue "John", oSegment, 5, 2

   .SetFieldValue "J", oSegment, 5, 3

   .SetFieldValue "Jr", oSegment, 5, 4

   .SetFieldValue "Mr", oSegment, 5, 5

   'Another way to Set a field value is to pass 0 in nComponent and a delimited string

    .SetFieldValue "Smith^John^J^Jr^Mr", oSegment, 5, 0

   'Add the Patient's Sex only 1 component for field 8 so I can

   'ignore the 4th parameter

   .SetFieldValue "M", oSegment, 8

   'Now get the values back out.

   'Show the first name

   MsgBox "The first name is: " & .GetFieldValue(oSegment,5,2)

   'Show everything

   MsgBox "Patient name field = " & .GetFieldValue(oSegment,5,0)

End With

End Sub