Class Name: |
HL7PlusSegment |
HL7+ Category: |
Restricted (Accessed through the HL7PlusMessage object) |
Description: |
Object representation of 1 segment in a HL7PlusMessage |
The HL7PlusSegment object is accessed through the HL7PlusMessage object through methods like AddEmptySegment(), GetSegment(), GetAllSegments() etc. Use the HL7PlusSegment object to get / set HL7PlusField and HL7PlusComponent values.
*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")
'---Now let's play and set some field values. oMSH.Field(7).ComponentValue(1) = MyController.HL7Now oMSH.Field(7).ComponentValue(2) = "S" oMSH.Field(9).ComponentValue(1) = "ADT" oMSH.Field(9).ComponentValue(2) = "A01"
|
|
|
A HL7PlusMessage object can contain only ONE MSH segment. And working with the HL7PlusSegment object which represents the MSH segment has some restrictions. The most important takeaway is:
Be careful when working with the MSH Segment!
*All example code is in Visual Basic.Net Consider the following example where oMsg is a HL7PlusMessage object:
Dim oMSH As HL7PlusSegment = oMSg.AddEmptySegment("MSH")
IF oMSG is NOT an EMPTY HL7PlusMessage an exception will occur and oMSH will be Nothing.
You cannot access Field(1) or Field(2) of an HL7PlusSegment object for the MSH segment. This is because field 1 of the MSH segment isn't really a field, it's the FieldDelimiter, and Field 2 also isn't really a field, it's the encoding characters.
You cannot rename the MSH segment. If you do your HL7PlusMessage will be corrupted.
If you use the .Value property to SET the Value of the MSH segment you can corrupt the message unless it is formatted correctly. This is true of all segments but is especially true of the MSH segment. So another important takeaway here is:
Be EXTREMELY careful when using the Value property to SET the value of a HL7PlusSegment Object!
|
This object class uses our standard HL7PlusException Class interface for error handling wherever possible.
See the HL7PlusException Implementation Reference
|