Menu

#181 PipeParser should fail (or warn) on bad line endings

2.2
open
nobody
None
5
2013-07-11
2013-04-16
James Agnew
No

Per a message on the mailing list: PipeParser should give an error, or maybe even fail completely, or maybe be lenient if it detects a message that has the wrong line endings (\n instead of \r).

Currently it just puts everything in one giant MSH segment, which is about as unhelpful as it gets.

Discussion

  • James Agnew

    James Agnew - 2013-04-16

    Some sample code:
    String msg1 = "MSH|^~\&|SOARF|HMC|||201304110916||ADT^A02|4c73eeb1-85ee-439f-91d9-747cb20d82ed|P|2.5||2|||||||\n" +
    "EVN|A02|201304110916||XFR|B0QZ_LGILLE|201304110914|939\n" +
    "PID|1||4125315^^^900000^PN^^20130411~401768^^^14^MR^^20130411||Smith^Boy Gloria^^^^^L^^^20130411~Smith^Baby Gloria^^^^^L^^^20130411@20130411||201304110706|M||H|500 MARY SUE DR^^ATLANTA^GA^30721^USA^M^^White^^^20130411||^PRN^PH^^1^706^2295221||EN|S|NRL|1000038688^^^14^VCD^^20130411|||1000038533^^^14^VCD^^20130410~100039469^^^14^VN^^20130410~227922^^^900000^PN^^20021011~169813^^^14^MR^^20021011~255892163^^^900001^SS^^20130410|HIS||N|1|||||N|N||2013|||||\n" +
    "PD1||||||||N||||||^L|||||||\n" +
    "PV1|1|I|NCN^NCN IN53^IN5301^939|Newborn||NCN^NCN BEDS^NURS03^939|600458^Whitman^Jeffeory^H^^^^^11^L^^^PRN^^^^19560901~421805573^^^^^^^^900001^^^^HPSS~100^^^^^^^^900000^^^^DN~D41371^^^^^^^^900002^^^^UPIN~010588^^^^^^^^1788^^^^PRN~1720074198^^^^^^^^900004^^^^NPI~022667^^^^^^^^13^^^^LN~AW1082697^^^^^^^^900001^^^^DEA|||NUR|||N|Born in hospital||||IP|100039638^^^14^VN^^20130411|Mcaid|||||||||||||||||||939|||||201304110706|||||||V|\n" +
    "PV2|||^Newborn (Vaginal)||||~~~~false||||||||N||||||Y||Inpatient^L^17^^^900000^XX^^ ~^^1528056066^^^900004^NPI^^ |Checked in|Newborn||||||N|||||Y||||Nursery Newborn|||||||\n" +
    "ROL||UC|AT|600458^Whitman^Jeffeory^H^^^^^11 ^L^^^PRN^^^^19560901~421805573^^^^^^^^900001 ^^^^HPSS~100^^^^^^^^900000 ^^^^DN~D41371^^^^^^^^900002 ^^^^UPIN~010588^^^^^^^^1788 ^^^^PRN~1720074198^^^^^^^^900004 ^^^^NPI~022667^^^^^^^^13 ^^^^LN~AW1082697^^^^^^^^900001 ^^^^DEA|201304110706||||Phys|||^WPN^PH^^0^706^8762130^0~^ORN^FX^^0^706^8762168\n" +
    "OBX|1|NM|9272-6^Apgar 1^LN||0||||||||||||\n" +
    "OBX|2|NM|9274-2^Apgar 5^LN||0||||||||||||\n" +
    "PDA||||||N|||N\n" +
    "ZPV|||||||||||||||||||||||||||||||||||||||||||||||||\"\"||||||||||||^^mostCurrEncTypeCd^mostCurrEncTypeCd^IP||||||||100039638^^No SCD^14^ZAVN^^20130411||201304110706|\n";

         HapiContext context = new DefaultHapiContext();
         Parser p = context.getGenericParser();
         Message hl7msg;
    
         try {
    
             hl7msg = p.parse(msg1);
         } catch (EncodingNotSupportedException e) {
             e.printStackTrace();
             return;
         } catch (HL7Exception e) {
             e.printStackTrace();
             return;
         }
    
        //ORU_R01 adtMsg = (ORU_R01)hl7msg;
        ADT_A02 adtMsg = (ADT_A02)hl7msg;
        PID pid  = adtMsg.getPID();
        XPN [] names = adtMsg.getPID().getPatientName();
    
        System.out.println(adtMsg.printStructure());
    
        ca.uhn.hl7v2.model.v25.segment.MSH msh = adtMsg.getMSH();
        System.out.println("patientName length: " + pid.getPatientName().length);
    
        String msgTrigger = msh.getMessageType().getTriggerEvent().getValue();
        System.out.println("messageTrigger: " + msgTrigger);
    
     
  • Christian Ohr

    Christian Ohr - 2013-07-11

    Maybe add a ParserConfiguration item that forces a String.replace(\n,\r) before parsing starts?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.