QRF-5 ExtraComponents #471
-
I have the QRF that needs to be transformed. How can this be done? I can get the Data below but I could not find a way to change the data on the fourth component.
Original Transformed |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
Hi @alberk8 Can you provide some additional data, what version of nHapi? what version of dotnet? Also I'm not 100% certain on your desired outcome. |
Beta Was this translation helpful? Give feedback.
-
Hi, I can extract the data from the code above but I want to transform the the QRF segment. I can't find a way to rebuild or change the field no 5.
|
Beta Was this translation helpful? Give feedback.
-
@alberk8 thanks for the extra info, I'll take a look in the coming week. |
Beta Was this translation helpful? Give feedback.
-
@milkshakeuk I have tried a few combinations. Is there a way to add non standard segment without the Terser?.
|
Beta Was this translation helpful? Give feedback.
-
@alberk8 to add the non-standard segment using System;
using NHapi.Base.Parser;
using NHapi.Model.V26.Message;
using NHapi.Model.V26.Segment;
var er7 = """
MSH|^~\&||KC1234F3|||20230810160302+0800||QRY^R02|202308101603020042|P|2.6
QRD|20230810160302+0800|R|I|Q101||||TXE107200400230|RES
QRF|MON||||168430091&5^5^1^0^2005&2005&2005&2005&2005
""".ReplaceLineEndings("\r");
var pipeParser = new PipeParser();
var qryR02 = (QRY_R02)pipeParser.Parse(er7);
// Standard segments for QRY_R02 (v2.6)
// index: Name
// 0: MSH (Message Header)
// 1: SFT (Software Segment) optional repeating
// 2: UAC (User Authentication Credential Segment) optional
// 3: QRD (Original-Style Query Definition)
// 4: QRF (Original style query filter)
// Insert non-standard PID at index 4 (takes standard segment indexes into account)
// pushes QRF to index position 5
_ = qryR02.AddNonstandardSegment("PID", 4);
var pid = qryR02.GetStructure("PID") as PID;
pid.GetPatientIdentifierList(0).IDNumber.Value = "1234";
pid.GetPatientName(0).GivenName.Value = "John";
pid.DateTimeOfBirth.Value = "1970-01-10";
pid.AdministrativeSex.Value = "M";
var encoded = pipeParser.Encode(qryR02);
Console.WriteLine(encoded); outputs the following:
|
Beta Was this translation helpful? Give feedback.
-
@alberk8 here is how you could customise using System;
using NHapi.Base.Parser;
using NHapi.Base.Model;
using NHapi.Model.V26.Message;
using NHapi.Model.V26.Datatype;
var er7 = """
MSH|^~\&||KC1234F3|||20230810160302+0800||QRY^R02|202308101603020042|P|2.6
QRD|20230810160302+0800|R|I|Q101||||TXE107200400230|RES
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);
// getting non-existent component at index 4 component will create it
var newComponent = part5.ExtraComponents.GetComponent(4);
((GenericPrimitive)newComponent.Data).Value = "test";
// getting non-existent sub component at index 0 will create it
var newSubComponent = newComponent.ExtraComponents.GetComponent(0);
((GenericPrimitive)newSubComponent.Data).Value = "subcomponent";
Console.WriteLine(PipeParser.Encode(qryR02.QRF, EncodingCharacters.FromMessage(qryR02))); outputs the following:
|
Beta Was this translation helpful? Give feedback.
-
@alberk8 can you let me know if these solve your issues? |
Beta Was this translation helpful? Give feedback.
-
@milkshakeuk , Thank you. It worked like a charm. I think this needs to go into an example. Thank you again. |
Beta Was this translation helpful? Give feedback.
-
@alberk8 I have converted this to a discussion rather than an issue, could you mark the relevant suggestions as answers please :) |
Beta Was this translation helpful? Give feedback.
@alberk8 here is how you could customise
QRF-5
: