我正在构建一个与系统交互的应用程序,该系统发送的ZPM消息类型仅用于库存类型的交易。它还发送DFT ^ P03类型的计费交易,我的系统非常乐意处理这些交易。但是,当它收到ZPM消息时,默认管道解析器绝对爆炸并引发以下异常:
ca.uhn.hl7v2.HL7Exception: Can't determine message structure from MSH-9: ZPM HINT: there are only 1 of 3 components present
at ca.uhn.hl7v2.parser.PipeParser.getStructure(PipeParser.java:186)
at ca.uhn.hl7v2.parser.PipeParser.doParse(PipeParser.java:223)
at ca.uhn.hl7v2.parser.GenericParser.doParse(GenericParser.java:245)
at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:212)
at ca.uhn.hl7v2.parser.GenericParser.parse(GenericParser.java:253)
at ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl.processMessage(ApplicationRouterImpl.java:138)
at ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl.processMessage(ApplicationRouterImpl.java:105)
at ca.uhn.hl7v2.app.Responder.processMessage(Responder.java:91)
at ca.uhn.hl7v2.app.Receiver$Grunt.run(Receiver.java:127)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
我能够通过将ZPM消息自定义映射到DFT_P03来解决此问题,但这是我要消除的部署步骤。此外,库存消息不是金融交易,因此这非常骇客。这就是我初始化HAPI上下文的方式:
ModelClassFactory cmf = new
CustomModelClassFactory("com.something.some_lib.hl7.custommodel");
MinLowerLayerProtocol mllp = new MinLowerLayerProtocol();
mllp.setCharset(StandardCharsets.ISO_8859_1.name());
hapiContext = new DefaultHapiContext();
hapiContext.setValidationContext(ValidationContextFactory.noValidation());
hapiContext.getPipeParser()
.getParserConfiguration()
.setUnexpectedSegmentBehaviour(
UnexpectedSegmentBehaviourEnum.ADD_INLINE);
hapiContext.setModelClassFactory(cmf);
hapiContext.setLowerLayerProtocol(mllp);
有没有办法允许这些消息通过?