/// <summary> /// Decode the segment. The HL7 message delimiters has been set to the correct value before calling this method. /// </summary> /// <param name="segmentString">Encoded segment string.</param> /// <param name="messageDelimiters">HL7 message delimiters to use to encode the message.</param> public void Decode(System.String segmentString, Hl7MessageDelimiters messageDelimiters) { int index = 0; System.String val = System.String.Empty; int i = 0; bool isVal = false; while (i < segmentString.Length) { if (segmentString.Substring(i, 1) == messageDelimiters.FieldDelimiter) { _values.Insert(index, val); index++; if ((index == 1) && ((System.String)_values[0] == "MSH")) { // special insert for the field delimiter itself. _values.Insert(index, messageDelimiters.FieldDelimiter); index++; } val = System.String.Empty; isVal = false; } else { val += segmentString[i]; isVal = true; } i++; } if (isVal == true) { _values.Insert(index, val); } if (_values.Count > 0) { // use segment index 0 here - the correct value will be determined when the segment is added to the message _segmentId = new Hl7SegmentId(SegmentNames.NameEnum((System.String)_values[0]), 0); } }
/// <summary> /// Class constructor /// </summary> /// <param name="sequenceNumber">Segment Sequence Number in HL7 message.</param> /// <param name="setId">Set ID</param> public Hl7Segment(int sequenceNumber, System.String setId) : this(sequenceNumber, SegmentNames.NameEnum(setId)) { }