From: William T H. <han...@mc...> - 2004-04-16 20:02:35
|
Hi all, I'm having newbie problems getting PipeParser to behave the way I think it should. If I build up a basic ORU_R01 message (code that does the work is down below), and ask PipeParser to write it out, I get the following output. Note that all the lines are the same length - it seems like it's not flushing a string buffer between segments. The same message works fine written out through the XML parser (which, unfortunately, doesn't help me much). Any ideas? Am I doing something wrong here?? Thanks all -Bill Hansley PS - Thanks, Bryan, for coordinating such a great and useful product/project!! PipeParser produced this: MSH|^~\&|ORVIEW||DHTS||200304051447||ORU_R01|1234456789|P PID|||W01950||Hansley^Bill||19670107|M||CR01|1234456789|P OBR|||314159|BOB Report|||||||||||||||||||||F1234456789|P XMLParser produced this: <?xml version="1.0"?> <ORU_R01> <MSH> <MSH.1>|</MSH.1> <MSH.2>^~\&</MSH.2> <MSH.3>ORVIEW</MSH.3> <MSH.5>DHTS</MSH.5> <MSH.7>200304051447</MSH.7> <MSH.9> <CM_MSG.1>ORU_R01</CM_MSG.1> </MSH.9> <MSH.10>1234456789</MSH.10> <MSH.11>P</MSH.11> </MSH> <ORU_R01.PIDNTEPV1ORCOBRNTEOBXNTE> <ORU_R01.PIDNTEPV1> <PID> <PID.3> <CM_PAT_ID.1>W01950</CM_PAT_ID.1> </PID.3> <PID.5> <PN.1>Hansley</PN.1> <PN.2>Bill</PN.2> </PID.5> <PID.7>19670107</PID.7> <PID.8>M</PID.8> <PID.10>C</PID.10> </PID> </ORU_R01.PIDNTEPV1> <ORU_R01.ORCOBRNTEOBXNTE> <OBR> <OBR.3> <CM_FILLER.1>314159</CM_FILLER.1> </OBR.3> <OBR.4> <CE.1>BOB Report</CE.1> </OBR.4> <OBR.25>F</OBR.25> </OBR> </ORU_R01.ORCOBRNTEOBXNTE> </ORU_R01.PIDNTEPV1ORCOBRNTEOBXNTE> </ORU_R01> The Code: //instantiate a PipeParser, which handles the "traditional encoding" PipeParser pipeParser = new PipeParser(); try { ca.uhn.hl7v2.model.v22.message.ORU_R01 oru = new ca.uhn.hl7v2.model.v22.message.ORU_R01(); //ca.uhn.hl7v2.model.v22.segment.MSH msh = oru.getMSH(); oru.getMSH().getFieldSeparator().setValue("|"); oru.getMSH().getEncodingCharacters().setValue("^~\\&"); oru.getMSH().getSendingApplication().setValue("ORVIEW"); oru.getMSH().getReceivingApplication().setValue("DHTS"); //msh.getDateTimeOfMessage().setValue(ValidTS.toHL7TSFormat(System.currentTimeMillis())); oru.getMSH().getDateTimeOfMessage().setValue("200304051447"); oru.getMSH().getMessageType().getMessageType().setValue("ORU_R01"); oru.getMSH().getMessageControlID().setValue("1234456789"); oru.getMSH().getProcessingID().setValue("P"); System.out.println(pipeParser.encode(oru)); //ca.uhn.hl7v2.model.v22.segment.PID pid = oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID(); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().getPatientIDInternalID(0).getPatientID().setValue("W01950"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().getPatientName().getFamilyName().setValue("Hansley"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().getPatientName().getGivenName().setValue("Bill"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().getDateOfBirth().setValue("19670107"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().getSex().setValue("M"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().getRace().setValue("C"); System.out.println(pipeParser.encode(oru)); //ca.uhn.hl7v2.model.v22.segment.OBR obr = oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOBR(); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOBR().getFillerOrderNumber().getUniqueFillerId().setValue("314159"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOBR().getUniversalServiceID().getIdentifier().setValue("BOB Report"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOBR().getResultStatus().setValue("F"); System.out.println(pipeParser.encode(oru)); //instantiate an XML parser XMLParser xmlParser = new DefaultXMLParser(); //encode message in XML String ackMessageInXML = xmlParser.encode(oru); //print XML-encoded message to standard out System.out.println(ackMessageInXML); |