I need to set a 2nd field of a repeated field. For example, how do I set the second identifier for a patient in the PID-3 field?
There are many ways to handle values in a repeated field. The following sets of code all set the 2 patient identifier to “12345^^^ALT”.
// set using named fields
CX cx = pid.PatientIdentifierList_03[2];
cx.IDNumber_01.Value = "12345";
cx.AssigningAuthority_04.NamespaceID_01.Value = "ALT";
// set using the segment
pid[3,2,1] = "12345";
pid[3,2,4] = "ALT";
// set using the message and a fully qualified Path
message["PID-3[2].1"] = "12345";
message["PID-3[2].4"] = "ALT";
// set using the message with explicit SEG, FIELD, REPEAT, COMPONENT, SUBCOMPONENT
message["PID", 1, 3, 2, 1] = "12345";
message["PID", 1, 3, 2, 4] = "ALT";