Search code examples
c#hl7hl7-v2nhapi

nHapi GT1 segment for DFT_P03 returning empty collection


I am stumped on the following

Sample message:

MSH|^~\&|CWM|MySender|UNKNOWN|UNKNOWN|20160711080000||DFT^P03|976503|P|2.5|
EVN|P03|20160711080000
PID||12345^^^RIS|||Test^Patient||192532325445|F|||27 Lotus street ^^Morningside^^2121|||m7715050|3|S|||23377|||||||||||N
PV1||I||||||999^Ref Doctor^||||||||N||A|160998675|||||||||||||||||||||||||20160701130000
GT1|1||EVERYMAN^ADAM^A||2222 HOME STREET^^ISHPEMING^MI^49849^""^|444-33 3333|555-555-2004||||SEL^SELF|444-33 3333||||AUTO CLINIC|2222 HOME STREET^^ISHPEMING^MI^49849^""|555-555-2004|
OBR|1||2015021000043|20310^CT of the soft tissues of the neck, with contrast^CT^4^CT Scan Machine|0|201502101124|201502101124|||||||||^MIKE^SMITH||||||||IMIL
FT1|1|E292252||201502101124||CG|00279519|F||1|||IMIL|PRIVATE^||||A1|||^MIKE^SMITH^^^||2015021000043^IMIL||20310^CT of the soft tissues of the neck, with contrast^CT^4^CT Scan Machine|CT
PR1|1|AQ|20310^CT of the soft tissues of the neck, with contrast^CT^4^CT Scan Machine||201502101124|D||||||||||CT|

I can parse the message, and I can work with the PID no problem, but the GT1 just does not get accepted. DFT does support the GT1 segment (optional) but it is just always returning an empty list

PipeParser parser = new PipeParser();
IMessage m = parser.Parse(msg);
DFT_P03 dft = m as DFT_P03;
GT1 gt1 = dft.GetGT1();
var memName = gt1.GetGuarantorName()[0];

then the final line blows up saying that my index is out of bounds, i.e. I have nothing in my gt1 collection.

Am I loading it in wrong?


Solution

  • The order of segments of your sample message is wrong. GT1-segment comes after the TransactionGroups and the ProcedureGroups.