using NHapi.Model.V26.Message;
using NHapi.Model.V26.Datatype;
MSH|^~\&||KC1234F3|||20230810160302+0800||QRY^R02|202308101603020042|P|2.6
QRD|20230810160302+0800|R|I|Q101||||TXE107200400230|RES
PID|||107200400230||Surname^Lastname|||M||||||||||107200400230
QRF|MON||||168430091&5^5^1^0^2005&2005&2005&2005&2005
""".ReplaceLineEndings("\r");
var pipeParser = new PipeParser();
var qryR02 = pipeParser.Parse(er7) as QRY_R02;
ST part5 = qryR02.QRF.GetOtherQRYSubjectFilter(0);
var newComponent = part5.ExtraComponents.GetComponent(4);
((GenericPrimitive)newComponent.Data).Value = "test";
var newSubComponent = newComponent.ExtraComponents.GetComponent(0);
((GenericPrimitive)newSubComponent.Data).Value = "subcomponent";
Console.WriteLine(PipeParser.Encode(qryR02.QRF, EncodingCharacters.FromMessage(qryR02)));