c# - nHapi Patient Referral Message (REF_I12) PID Segment not being parsed -
i have issue nhapi pipeparser not appear parsing pid segment of ref_i12 (patient referral) message. if use exact same pid segment in different message (adt_a01), pid segment parsed. i'm using hl7 version 2.5
the following working code illustrates issue:
using nhapi.base.parser; using nhapi.model.v25.message; using system; public class messagetester { public static void test() { var parser = new pipeparser(); var adtmsg = new nhapi.model.v25.message.adt_a01(); adtmsg.msh.messagetype.messagecode.value = "adt"; adtmsg.msh.messagetype.triggerevent.value = "a01"; adtmsg.msh.messagetype.messagestructure.value = "adt_a01"; adtmsg.msh.fieldseparator.value = "|"; adtmsg.msh.encodingcharacters.value = @"^~\&"; adtmsg.msh.versionid.versionid.value = "2.5"; adtmsg.pid.setidpid.value = "1"; adtmsg.pid.countycode.value = "zar"; var name = adtmsg.pid.getpatientname(0); name.prefixegdr.value = "mr"; name.familyname.surname.value = "lastname"; name.givenname.value = "firstname"; name.nametypecode.value = "l"; adtmsg.pid.administrativesex.value = "m"; // following returns value of "zar", expected. console.writeline("pre-encoded adt_a01 countrycode: {0}", adtmsg.pid.countycode.value); // following returns value of 1, expected. console.writeline("pre-encoded adt_a01 patientnamerepititionsused: {0}", adtmsg.pid.patientnamerepetitionsused); var encodedadt_a01 = parser.encode(adtmsg); var parsedadt_a01 = parser.parse(encodedadt_a01) adt_a01; // after parsing encoded message following returns value of "zar", expected. console.writeline("parsed adt_a01 countrycode: {0}", parsedadt_a01.pid.countycode.value); // after parsing encoded message following returns value of 1, expected. console.writeline("parsed adt_a01 patientnamerepititionsused: {0}", parsedadt_a01.pid.patientnamerepetitionsused); console.writeline("----------------------------------------------------------------"); var refmsg = new nhapi.model.v25.message.ref_i12(); refmsg.msh.messagetype.messagecode.value = "ref"; refmsg.msh.messagetype.triggerevent.value = "i12"; refmsg.msh.messagetype.messagestructure.value = "ref_i12"; refmsg.msh.fieldseparator.value = "|"; refmsg.msh.encodingcharacters.value = @"^~\&"; refmsg.msh.versionid.versionid.value = "2.5"; refmsg.pid.setidpid.value = "1"; refmsg.pid.countycode.value = "zar"; name = refmsg.pid.getpatientname(0); name.prefixegdr.value = "mr"; name.familyname.surname.value = "lastname"; name.givenname.value = "firstname"; name.nametypecode.value = "l"; refmsg.pid.administrativesex.value = "m"; // following returns value of "zar", expected. console.writeline("pre-encoded ref_i12 countrycode: {0}", refmsg.pid.countycode.value); // following returns value of 1, expected. console.writeline("pre-encoded ref_i12 patientnamerepititionsused: {0}", refmsg.pid.patientnamerepetitionsused); var encodedref_i12 = parser.encode(refmsg); var parsedref_i12 = parser.parse(encodedref_i12) ref_i12; // after parsing encoded message following returns nothing, "zar" expected. console.writeline("parsed ref_i12 countrycode: {0}", parsedref_i12.pid.countycode.value); // after parsing encoded message following returns value of 0, 1 expected. console.writeline("parsed ref_i12 patientnamerepititionsused: {0}", parsedref_i12.pid.patientnamerepetitionsused); } }
any appreciated. thank you
i've found source of issue.
after checking hapi api docs, realised not populating required segment of ref_i12 message, namely ref_i12_provider_contact segment. adding segment message while building it, using following line of code, resulted in successful parsing of message:
refmsg.getprovider_contact(0).prd.getprovidername(0).familyname.surname.value = "dummyproviderlastname";
here full original source code issue fixed:
using nhapi.base.parser; using nhapi.model.v25.message; using system; public class messagetester { public static void test() { var parser = new pipeparser(); var adtmsg = new nhapi.model.v25.message.adt_a01(); adtmsg.msh.messagetype.messagecode.value = "adt"; adtmsg.msh.messagetype.triggerevent.value = "a01"; adtmsg.msh.messagetype.messagestructure.value = "adt_a01"; adtmsg.msh.fieldseparator.value = "|"; adtmsg.msh.encodingcharacters.value = @"^~\&"; adtmsg.msh.versionid.versionid.value = "2.5"; adtmsg.pid.setidpid.value = "1"; adtmsg.pid.countycode.value = "zar"; var name = adtmsg.pid.getpatientname(0); name.prefixegdr.value = "mr"; name.familyname.surname.value = "lastname"; name.givenname.value = "firstname"; name.nametypecode.value = "l"; adtmsg.pid.administrativesex.value = "m"; // following returns value of "zar", expected. console.writeline("pre-encoded adt_a01 countrycode: {0}", adtmsg.pid.countycode.value); // following returns value of 1, expected. console.writeline("pre-encoded adt_a01 patientnamerepititionsused: {0}", adtmsg.pid.patientnamerepetitionsused); var encodedadt_a01 = parser.encode(adtmsg); var parsedadt_a01 = parser.parse(encodedadt_a01) adt_a01; // after parsing encoded message following returns value of "zar", expected. console.writeline("parsed adt_a01 countrycode: {0}", parsedadt_a01.pid.countycode.value); // after parsing encoded message following returns value of 1, expected. console.writeline("parsed adt_a01 patientnamerepititionsused: {0}", parsedadt_a01.pid.patientnamerepetitionsused); console.writeline("----------------------------------------------------------------"); var refmsg = new nhapi.model.v25.message.ref_i12(); refmsg.msh.messagetype.messagecode.value = "ref"; refmsg.msh.messagetype.triggerevent.value = "i12"; refmsg.msh.messagetype.messagestructure.value = "ref_i12"; refmsg.msh.fieldseparator.value = "|"; refmsg.msh.encodingcharacters.value = @"^~\&"; refmsg.msh.versionid.versionid.value = "2.5"; // line of code fixed issue refmsg.getprovider_contact(0).prd.getprovidername(0).familyname.surname.value = "dummyproviderlastname"; refmsg.pid.setidpid.value = "1"; refmsg.pid.countycode.value = "zar"; name = refmsg.pid.getpatientname(0); name.prefixegdr.value = "mr"; name.familyname.surname.value = "lastname"; name.givenname.value = "firstname"; name.nametypecode.value = "l"; refmsg.pid.administrativesex.value = "m"; // following returns value of "zar", expected. console.writeline("pre-encoded ref_i12 countrycode: {0}", refmsg.pid.countycode.value); // following returns value of 1, expected. console.writeline("pre-encoded ref_i12 patientnamerepititionsused: {0}", refmsg.pid.patientnamerepetitionsused); var encodedref_i12 = parser.encode(refmsg); var parsedref_i12 = parser.parse(encodedref_i12) ref_i12; // fixed: after parsing encoded message following returns "zar" expected. console.writeline("parsed ref_i12 countrycode: {0}", parsedref_i12.pid.countycode.value); // fixed: after parsing encoded message following returns value of 1 expected. console.writeline("parsed ref_i12 patientnamerepititionsused: {0}", parsedref_i12.pid.patientnamerepetitionsused); } }
lesson learned: check hapi api docs required segments if message not parsing expected.
thank you