我有一个SIU S12 message不包含PV2段。但是,当我从NHAPI获得解析的消息时,PV2的父组SIU_S12_PATIENT组返回1,表示存在PV2,即currentReps ("PV2")。如何通过NHAPI知道段是否实际存在于HL7消息中?
var parser = new NHapi.Base.Parser.PipeParser();
var parsedMessage = parser.Parse(message) as NHapi.Model.V231.Message.SIU_S12;
var patientGroup=parsedMessage.GetPATIENT(0);
// This call should not create the segment if it does not exist
int pv2Count=patientGroup.currentReps("PV2");
//pv2Count is 1 here despite no PV2 segment exists in the message
//also Both GetAll("PV2") and SegmentFinder say the PV2 segment is present
//DG1RepetitionsUsed is also 1 despite no DG1 segment is present in the message
我试图避免编写代码来评估段中的每个字段。 PV2仅仅是一个例子 - 消息源中可能会丢失更多的段。
我使用NHAPI v 2.4,最新版本。
更新:下面泰森的建议,我想出这个方法,
var parser = new NHapi.Base.Parser.PipeParser();
var parsedMessage = parser.Parse(message) as NHapi.Model.V231.Message.SIU_S12;
var encodingChars = new NHapi.Base.Parser.EncodingCharacters('|', null);
var patientGroup = parsedMessage.GetPATIENT(0);
var dg1 = (NHapi.Model.V231.Segment.DG1) (patientGroup.GetStructure("DG1"));
string encodedDg1 = NHapi.Base.Parser.PipeParser.Encode(dg1, encodingChars);
bool dg1Exists = string.Compare(encodedDg1,
"DG1", StringComparison.InvariantCultureIgnoreCase)==0;
PiperParser不返回空字符串,但返回段名称。但是,仍然可以用来检查段是否为空,谢谢。 – 2013-07-12 22:18:35