Online Help - Region 1: [CORE HL7 API Basic] |
Object: HL7Component
NOTE: No public entry point. Accessed only through a HL7Field object.

HL7 Component Object Hierarchy
Definition - Atomic Value
An object or base value which represents the smallest directly addressable item in an object hierarchy.
This certainly describes the HL7Component object. The only way to access a HL7Component object is through calling the GetFieldComponent() method of the HL7Field object. An important thing to remember is the way that all prior objects in the HL7Message tree have worked up to this point. A HL7Message is a collection of HL7Segments, and a HL7Segment is a collection of HL7Fields, and a HL7Field is a collection of HL7Components. And finally the HL7Component object itself is, at it's core, a collection of Sub Component Values. We don't have a HL7SubComponent object because one isn't needed, these Sub Component Values are just the base type string., so the HL7Component object is basically a collection of strings.
Property Name |
Data Type |
ExceptionHandling |
Uses the Standard Exceptions Interface |
NumberOfSubComponents |
int (read only) - The number of sub component values; 0 means the object is empty. |
FieldRepeats |
bool (read only)- Will indicate whether the field repeats (IE FieldInstances > 1) |
Index |
int (read only) - Will be the ordinal position (1 based) of the component within the ParentField. |
ParentField |
HL7Field Object (read only) - Reference to the Parent object that contains the Component. |
SubComponentDelimiter |
string (read only)- Will be the SubComponentDelimiter encoding character passed down from ParentField.ParentSegment.ParentMessage See Encoding Characters. |
Tag |
|
TrimEmptyInstances |
bool (Default = false) - If set to true BEFORE you access the Value property then empty trailing EMPTY repeat instances will be trimmed. Example1: Value if == false - "R1C1^R1C2~R2C1~R3C1^R3C2~~~~~" Example2: Value if == true - "R1C1^R1C2~R2C1~R3C1^R3C2" NOTE: This property is not inherited and must be set by you in code. |
Value |
string - Get returns the string value of the entire component. You can Set this value also by passing in a fully formed HL7 field string (Example: "2145551212&Home") |
Method |
Return Value |
ExceptionHandling |
Uses the Standard Exceptions Interface |
Clear() |
void - Clears the Value property (Same as setting Value = "") |
IsEmpty() |
bool Indicates whether the object has any value in any repeating instance. |
Getting and Setting Methods |
|
string GetSubComponentValue(int subIndex = 1) - Returns the string sub component value at position subIndex (1 based) or "" if empty or subIndex does not exist Example Code (C#):
//oSeg is a connected segment object representing a PID segment HL7Field oField = oSeg.GetField(14, true); //We will fill out the work phone number component the VERY old fashioned way HL7Component oComponent = oField.GetFieldComponent(1); oComponent.Value = "2145551212&54321&Work";
//NOW oComponent has 3 sub component values int a = oComponent.NumberOfSubComponents; // a == 3
string phonenum = oComponent.GetSubComponentValue(1); string extension = oComponent.GetSubComponentValue(2); string phoneType = oComponent.GetSubComponentValue(3);
Result:
phonenum = "2145551212" extension = "54321" phoneType = "Work" Value Property = "2145551212&54321&Work"
|
|
void SetSubComponentValue(string subValue, int subIndex = 1) sets the string sub component value at position subIndex to subValue. If subIndex < 1 OR subIndex > NumberOfComponents nothing happens. Example Code (C#):
//oSeg is a connected segment object representing a PID segment HL7Field oField = oSeg.GetField(14, true); //We will manually fill out each sub component value HL7Component oComponent = oField.GetFieldComponent(1);
int a = oComponent.NumberOfSubComponents; // a == 0
oComponent.SetSubComponentValue("2145551212", 1); oComponent.SetSubComponentValue("54321", 2); oComponent.SetSubComponentValue("Work", 3);
a = oComponent.NumberOfSubComponents; // a == 3
string phonenum = oComponent.GetSubComponentValue(1); string extension = oComponent.GetSubComponentValue(2); string phoneType = oComponent.GetSubComponentValue(3);
Result:
phonenum = "2145551212" extension = "54321" phoneType = "Work" Value Property = "2145551212&54321&Work"
|