From: Tripp, B. <Bry...@uh...> - 2004-04-19 19:03:50
|
For the list, the explanation is as follows ... This code prints the message to the console after each segment is added. There are no line feeds at the ends of HL7 segments, and Bill was using the XP console, so the results of each println statement go on a single line, with each segment overwriting the last. So the first line is the MSH, the second line is the MSH with the PID overwriting part of it, and the third is the MSH overwritten by the PID overwritten by the OBR. Everything looks sensible when the output is written somewhere that sees \r as a line break (e.g. the Eclipse console or a file). Bryan -----Original Message----- From: William T Hansley [mailto:han...@mc...] Sent: April 16, 2004 4:02 PM To: hl7...@li... Subject: [HAPI-devel] Problems with PipeParser 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.currentTi meMillis())); 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().ge tPatientIDInternalID(0).getPatientID().setValue("W01950"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().ge tPatientName().getFamilyName().setValue("Hansley"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().ge tPatientName().getGivenName().setValue("Bill"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().ge tDateOfBirth().setValue("19670107"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().ge tSex().setValue("M"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_PIDNTEPV1().getPID().ge tRace().setValue("C"); System.out.println(pipeParser.encode(oru)); //ca.uhn.hl7v2.model.v22.segment.OBR obr = oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOB R(); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOB R().getFillerOrderNumber().getUniqueFillerId().setValue("314159"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOB R().getUniversalServiceID().getIdentifier().setValue("BOB Report"); oru.getORU_R01_PIDNTEPV1ORCOBRNTEOBXNTE().getORU_R01_ORCOBRNTEOBXNTE().getOB R().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); This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient. Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. If you have received this e-mail in error, please contact the sender and delete all copies. Opinions, conclusions or other information contained in this e-mail may not be that of the organization. |