GetLastSegment
Positions and returns the first segment within the HL7 message structure.
Syntax
[ Segment = String] = object.GetLastSegment [ nMsgId = Integer]
The GetLastSegment method syntax has these parts:
| Part | Description |
| object | An object expression that evaluates to the HL7 control. |
| nMsgId | A integer expression that specifies the message Id. |
Returns
| Value | Description |
| Segment | A string expression that will contains the segment identifier. |
Remarks
GetLastSegment of an object is initiated at runtime. The GetLastSegment
is called to position and/or
extract the last segment within the HL7 Message.
Example
Private Sub ShowMessage()
Dim nSendMsgId As Integer
Dim nRecvMsgId As Integer
Dim sSeg As String
Dim nCount As Integer
Dim nFieldCount As Integer
Dim sMsg As String
Dim bSuccess As Boolean
Hl7cntl1.EnvelopSupport = False
nSendMsgId = Hl7cntl1.InitMessage
Hl7cntl1.SetSegment nSendMsgId, "MSH"
Hl7cntl1.SetField nSendMsgId, "|", 1
Hl7cntl1.SetField nSendMsgId, "^~\&", 2
Hl7cntl1.SetField nSendMsgId, "GPMS", 3
Hl7cntl1.SetField nSendMsgId, "DEMO", 4
Hl7cntl1.SetField nSendMsgId, "HL7DEMO", 6
Hl7cntl1.SetField nSendMsgId, "19911030140014865", 7
Hl7cntl1.SetField nSendMsgId, "ADT", 9
Hl7cntl1.SetFieldComponent nSendMsgId, "A28", 9, 0
Hl7cntl1.SetField nSendMsgId, "14001U090", 10
Hl7cntl1.SetField nSendMsgId, "D", 11
Hl7cntl1.SetField nSendMsgId, "2.2", 12
Hl7cntl1.SetSegment nSendMsgId, "EVN"
Hl7cntl1.SetField nSendMsgId, "A28", 1
Hl7cntl1.SetField nSendMsgId, "19911030140014865", 2
Hl7cntl1.SetSegment nSendMsgId, "PID"
Hl7cntl1.SetField nSendMsgId, "1", 1
Hl7cntl1.SetField nSendMsgId, "123", 3
Hl7cntl1.SetField nSendMsgId, "Bill" & "^"
& "Gates" & "^" & """", 5
Hl7cntl1.SetField nSendMsgId, "01/01/1956", 7
Hl7cntl1.SetField nSendMsgId, "M", 8
Hl7cntl1.SetField nSendMsgId, "100 Microsoft Rd" &
"^" & "Suite 100" & "^" & "Seattle"
& "^" & "WA" & "^" &
"10010", 11
Hl7cntl1.SetField nSendMsgId, "M", 16
Hl7cntl1.SetField nSendMsgId, "111-11-1111", 19
Hl7cntl1.SetSegment nSendMsgId, "PV1"
Hl7cntl1.SetField nSendMsgId, "1", 1
Hl7cntl1.SetField nSendMsgId, "PCP01", 7
Hl7cntl1.SetSegment nSendMsgId, "GT1"
sMsg = Hl7cntl1.GetMessage(nSendMsgId)
Hl7cntl1.DeInitMessage nSendMsgId
nRecvMsgId = Hl7cntl1.InitMessage
bSuccess = Hl7cntl1.SetMessage(nRecvMsgId, sMsg)
If bSuccess = True Then
sSeg = Hl7cntl1.GetLastSegment(nRecvMsgId)
MsgBox "The Last Segment Is " &
sSeg
sSeg = Hl7cntl1.GetNextSegment(nRecvMsgId)
While sSeg <> ""
MsgBox sSeg
nFieldCount =
Hl7cntl1.GetFieldCount(nRecvMsgId)
For nCount = 1 To
nFieldCount
MsgBox Hl7cntl1.GetField(nRecvMsgId, nCount)
Next nCount
sSeg =
Hl7cntl1.GetNextSegment(nRecvMsgId)
Wend
End If
Hl7cntl1.DeInitMessage nRecvMsgId
End Sub
.
..
...
This page, and all contents, are Copyright © 1998 by
Gary M. Gallagher.
Sparrow Technologies Incorporated - http://www.sparrow-technologies.com