HAPI 2 v2.3 - setValidating (false) не влияет на XMLParser - PullRequest
0 голосов
/ 15 октября 2018

с последней версией HAPI 2 v2.3, отключить проверку работает только для pipedParser, XMLParser не оказывает влияния.

примеры кода ниже работают отлично с предыдущей версией (HAPI 2 v2.2), но в HAPI v2.3 выдается исключение:

  • Проверка не удалась: примитив 'THIS-IS-NOT-DATE-VALUE' должен бытьпустая или строка даты и времени HL7

    import ca.uhn.hl7v2.DefaultHapiContext;
    import ca.uhn.hl7v2.HL7Exception;
    import ca.uhn.hl7v2.HapiContext;
    import ca.uhn.hl7v2.model.Message;
    import ca.uhn.hl7v2.parser.PipeParser;
    import ca.uhn.hl7v2.parser.XMLParser;
    
    public class TestXMLParser {    
       public static void main(String[] args) throws HL7Exception {
              // TODO Auto-generated method stub
              String invalidMessage = "MSH|^~\\&|MedSeries|CAISI_1-2|PLS|3910|200903230934||ADT^A31^ADT_A05|75535037-1237815294895|P^T|2.4\r"
                           + "EVN|A31|THIS-IS-NOT-DATE-VALUE\r"
                           + "PID|1||29^^CAISI_1-2^PI~\"\"||Test300^Leticia^^^^^L||19770202|M||||||||||||||||||||||";
    
              HapiContext context = new DefaultHapiContext();
              // turn off the validation <<<<<<<<<<<<<<=================
              context.getParserConfiguration().setValidating(false);
    
              Message hapiMsg = null;
              String xmlDoc = null;
    
              // get an instance of the PipeParser
              PipeParser parser = context.getPipeParser();
              hapiMsg = parser.parse(invalidMessage); // this works fine
              System.out.println("Successfully parsed the message");
    
              // get an instance of XMLParser
              XMLParser xmlParser = context.getXMLParser();
    
              // encode the piped formatted message to xml format
              xmlDoc = xmlParser.encode(hapiMsg);
    
              // try to parse the xml string into Hapi message objects
              Message xmlMessage = xmlParser.parse(xmlDoc);// with HAPI 2 v2.3 an exception is thrown.
    
              // encode the xml formatted message to pipe-format
              String er7 = parser.encode(xmlMessage);
              System.out.println("er7:\n" + er7);
       }
    

    }

Интересно, есть ли у вас какие-либо предложения / обходные пути.Спасибо.

...