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

HL7 Field Object Hierarchy
Property Name |
Data Type |
ExceptionHandling |
Uses the Standard Exceptions Interface |
FieldInstances |
int (read only) - Will be the number times the field REPEATS (see Working With Repeating Fields below). |
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 field within the ParentSegment. |
ParentSegment |
HL7Segment Object (read only) - Reference to the Parent object that created the HL7Field. |
SubComponentDelimiter |
string (read only)- Will be the SubComponentDelimiter encoding character passed down from 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 field. You can Set this value also by passing in a fully formed HL7 field string (Example: "Smith^John^S") |
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. |
*See Below For Methods: •GetFieldComponent() •GetComponentValue() •SetComponentValue() •GetRepeatInstanceValue() •SetRepeatInstanceValue() |
HL7Component GetFieldComponent(int componentNumber = 1, int repeatInstance = 1, bool addIfNotPresent = false) Returns the HL7Component object at position componentNumber for instance repeatInstance of the segment. IF padIfNotPresent == true then components and/or instances are added to the object, otherwise it will return null if the componentNumber or repeatInstance does not exist. Example Code (C#):
//GetFieldComponent() Demo Simple Scenario HL7Segment oSeg = oMessage.AddSegment("PID|1|f2|f3|f4|Doe^John"); //oSeg is a connected segment object with 5 fields representing a PID segment HL7Field oField; oField = oSeg.GetField(5); //NOW oField will be the HL7Field object for field #5 of the PID segment //Now I want to change the first name using a HL7Component object HL7Component p2 = oField.GetFieldComponent(2, 1, true); p2.Value = "James";
|
string GetComponentValue(int componentNumber = 1, int repeatInstance = 1) Returns the string Value of the HL7Component object at position componentNumber for instance repeatInstance. Will be "" if either does not exist. Example Code (C#):
//GetComponentValue() Scenario HL7Segment oSeg = oMessage.AddSegment("PID|1|f2|f3|f4|Doe^John"); //oSeg is a connected segment object with 5 fields representing a PID segment HL7Field oField; oField = oSeg.GetField(5); //NOW oField will be the HL7Field object for field #5 of the PID segment string firstName, middleName; firstName = oField.GetComponentValue(2); //is the exact same as calling firstName = oField.GetComponentValue(2, 1); //firstName == "John" middleName = oField.GetComponentValue(3); //middleName == "" because field #5 does not have a component #3.
|
void SetComponentValue(string value, int componentNumber = 1, int repeatInstance = 1, bool addIfNotPresent = true) Will set the Value of the HL7Component object at position componentNumber for instance repeatInstance. If addIfNotPresent == false will do nothing if either does not exist. Example Code (C#):
//SetComponentValue() Scenario HL7Segment oSeg = oMessage.AddSegment("PID|1|f2|f3|f4|Doe^John"); //oSeg is a connected segment object with 5 fields representing a PID segment HL7Field oField; oField = oSeg.GetField(5); //NOW oField will be the HL7Field object for field #5 of the PID segment string firstName, middleName;
//Now Set Component values oField.SetComponentValue("James", 2); //Is the exact same as calling oField.SetComponentValue("James", 2, 1, true); firstName = oField.GetComponentValue(2); //firstName == "James" //now set the middle name which does NOT exist yet oField.SetComponentValue("M", 3, 1, false); middleName = oField.GetComponentValue(3); //MiddleName == "" //by using false in parameter 4 I am effectively saying //IF there is a middle name, change it to "M" //Now set Middle Name no matter what oField.SetComponentValue("M", 3); middleName = oField.GetComponentValue(3); //MiddleName == "M" //Parameters 3 and 4 are defaulted to 1 and true respectively
|
|
string GetRepeatInstanceValue(int repeatInstance = 1) Returns the FULL field value of INSTANCE #repeatInstance of the HL7Field object. Will be "" if repeatInstance does not exist. Example Code (C#):
//GetRepeatInstanceValue() Demo HL7Segment oSeg = oMessage.AddSegment("PID|1|"); //oSeg is a connected segment object with 5 fields representing a PID segment HL7Field oField = oSeg.GetField(2, true); //oField is now empty oField.Value = "f2ID1^ValA^333~f2ID2~f2ID3^AA~f2ID4^ValD^999"; //Field # 2 has been completely populated int a = oField.FieldInstances; //a = 4. The field repeats 4 times string tst = oField.GetRepeatInstanceValue(3); //tst == "f2ID3^AA"
|
void SetRepeatInstanceValue(string value, int repeatInstance, bool addIfNotPresent = true) Will set the FULL field value of the HL7Field object of INSTANCE #repeatInstance. If addIfNotPresent == true and repeatInstance < FieldInstances new instances will be added.If addIfNotPresent == false and repeatInstance < FieldInstances nothing will happen. Example Code (C#):
//SetRepeatInstanceValue() Demo HL7Segment oSeg = oMessage.AddSegment("PID|1|"); //oSeg is a connected segment object with 5 fields representing a PID segment HL7Field oField = oSeg.GetField(2, true); //oField is now an empty field #2 oField.SetRepeatInstanceValue("Instance3^C2^C3", 3, true); string tst = oField.Value; //tst == "~~Instance3^C2^C3" //Field # 2 has been completely populated ONLY with a 3rd instance. int a = oField.FieldInstances; //a = 3. The field repeats 3 times oField.SetRepeatInstanceValue("Instance2", 2, true); tst = oField.Value; //tst == "~Instance2~Instance3^C2^C3" oField.SetRepeatInstanceValue("Instance1^id1", 1, true); tst = oField.Value; //tst == "Instance1^id1~Instance2~Instance3^C2^C3" oField.SetRepeatInstanceValue("Instance4", 4, true); tst = oField.Value; //tst == "Instance1^id1~Instance2~Instance3^C2^C3~Instance4" a = oField.FieldInstances; //a = 4. The field repeats 4 times //Get Component #2 of Instance #3 tst = oField.GetComponentValue(2, 3); //tst == "C2"
|
Under Construction
Enter topic text here.