简体   繁体   English

HAPI:Hl7解析器不分隔Hl7消息的段

[英]HAPI: Hl7 Parser do not separate the segment of the Hl7 message

I'm getting started to Hl7 using HAPI API. 我正在使用HAPI API进入Hl7。 I have an Hl7 test message (picked up from a real case) and I want to read the field of the various segment (MSH, PID, PV1, etc.) The problem is that the Parser do not split the message in segments, but put all the message in the MSH segment. 我有一条Hl7测试消息(从实际情况中挑选),并且我想读取各个段(MSH,PID,PV1等)的字段。问题是解析器不会将消息拆分为多个段,而是将所有邮件放在MSH段中。 I tried both the PipeParser and the GenericParser. 我尝试了PipeParser和GenericParser。 The message is an ORU_R01 message, version 2.3.1 (I used the debug and the getVersion() method to get those information) 该消息是2.3.1版的ORU_R01消息(我使用debug和getVersion()方法获取这些信息)

Here is the test class 这是测试课

    import java.io.IOException;

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.model.v231.group.ORU_R01_PIDPD1NK1NTEPV1PV2;
import ca.uhn.hl7v2.model.v231.group.ORU_R01_PIDPD1NK1NTEPV1PV2ORCOBRNTEOBXNTECTI;
import ca.uhn.hl7v2.model.v231.message.ORU_R01;
import ca.uhn.hl7v2.model.v231.segment.MSH;
import ca.uhn.hl7v2.model.v231.segment.PID;
import ca.uhn.hl7v2.parser.Parser;

public class Hl7EncodeTester 
{
    public static void main (String[] args) throws HL7Exception, IOException
    {
        String msg = "MSH|^~\\&|REPO|BCS|THE|Theorema|201412170140||ORU^R01|20140012620415|P|2.3.1||||||||PID|||711697^^^^PI^PRIAMO~RSSMHL69B15B081W^^^^NN||ROSSINI^MICHELE||19690215|F|||VIA^POMPEI^6^ASSO^CO^22063||031700239|||M||RSSMHL69B15B081W|300CP102||||ASSO|||100|||||PV1|||265^INRCA Ospedale^^959^^^0310^^||||||||||||||||||||||||||||||||||||||||||||||||||OBR|1||2014047190|69^RADIOLOGIA||||201412162247||||||||||||0310692014047190||201412162247|||||||||||||||OBX|1|FT|20140001988995||REFERTO FORMATO P7M BASE64 ||||||F|||20141216||CFmedicorefertante^CognomeMedicoRefertante^NomeMedicoRefertante||||TXA|1||multipart|||20141216|||||CFmedicorefertante^^^^^^^^^^^^COMPILATORE||||2014047190||AU|||||||NTE|1|O||";
        HapiContext context = new DefaultHapiContext();
//      Parser p = context.getPipeParser();
        Parser p = context.getGenericParser();
        Message adt = p.parse(msg);
        ORU_R01 oruMsg = (ORU_R01) adt;
        System.out.println("ORU_RO1 message = " + oruMsg.encode());
        MSH msh = oruMsg.getMSH();
        System.out.println("MSH segment = " + msh.encode());
        ORU_R01_PIDPD1NK1NTEPV1PV2ORCOBRNTEOBXNTECTI segment1 = 
                            oruMsg.getPIDPD1NK1NTEPV1PV2ORCOBRNTEOBXNTECTI();
        ORU_R01_PIDPD1NK1NTEPV1PV2 segment2= segment1.getPIDPD1NK1NTEPV1PV2();
        PID pid = segment2.getPID();
        System.out.println("Patient Name = " + pid.getPatientName(0).getXpn2_GivenName().getValue());
    }
}

This is the console output: 这是控制台输出:

ORU_RO1 message = MSH|^~\&|REPO|BCS|THE|Theorema|201412170140||ORU^R01|20140012620415|P|2.3.1||||||||PID|||711697^^^^PI^PRIAMO~RSSMHL69B15B081W^^^^NN||ROSSINI^MICHELE||19690215|F|||VIA^POMPEI^6^ASSO^CO^22063||031700239|||M||RSSMHL69B15B081W|300CP102||||ASSO|||100|||||PV1|||265^INRCA Ospedale^^959^^^0310||||||||||||||||||||||||||||||||||||||||||||||||||OBR|1||2014047190|69^RADIOLOGIA||||201412162247||||||||||||0310692014047190||201412162247|||||||||||||||OBX|1|FT|20140001988995||REFERTO FORMATO P7M BASE64 ||||||F|||20141216||CFmedicorefertante^CognomeMedicoRefertante^NomeMedicoRefertante||||TXA|1||multipart|||20141216|||||CFmedicorefertante^^^^^^^^^^^^COMPILATORE||||2014047190||AU|||||||NTE|1|O

MSH segment = MSH|^~\&|REPO|BCS|THE|Theorema|201412170140||ORU^R01|20140012620415|P|2.3.1||||||||PID|||711697^^^^PI^PRIAMO~RSSMHL69B15B081W^^^^NN||ROSSINI^MICHELE||19690215|F|||VIA^POMPEI^6^ASSO^CO^22063||031700239|||M||RSSMHL69B15B081W|300CP102||||ASSO|||100|||||PV1|||265^INRCA Ospedale^^959^^^0310||||||||||||||||||||||||||||||||||||||||||||||||||OBR|1||2014047190|69^RADIOLOGIA||||201412162247||||||||||||0310692014047190||201412162247|||||||||||||||OBX|1|FT|20140001988995||REFERTO FORMATO P7M BASE64 ||||||F|||20141216||CFmedicorefertante^CognomeMedicoRefertante^NomeMedicoRefertante||||TXA|1||multipart|||20141216|||||CFmedicorefertante^^^^^^^^^^^^COMPILATORE||||2014047190||AU|||||||NTE|1|O
Patient Name = null

The whole message and the MSH segment I obtained are the same, I cannot split the message in segments (there are supposed to be: MSH, PID, PV1, OBR, OBX, TXA and NTE) Someone knows a solution to my problem? 整个消息和我获得的MSH段是相同的,我无法将消息拆分为段(应该是:MSH,PID,PV1,OBR,OBX,TXA和NTE)有人知道我的问题的解决方案吗?

There's no segment terminator in your message. 您的消息中没有句段终止符 So the parser can't find it. 因此,解析器找不到它。 Note that this terminator is binary and hard-coded in the standard 请注意,此终结器是二进制的,并且在标准中进行了硬编码

HL7 Messaging Standard Version 2.5 → Control → Message Framework → 2.5.4 Message delimiters HL7 Messaging Standard版本2.5→控制→消息框架→ 2.5.4消息定界符

...The segment terminator is always a carriage return (in ASCII , a hex 0D ). ...段终止符始终是回车符(以ASCII ,十六进制0D )。 The other delimiters are defined in the MSH segment, with the field delimiter in the 4th character position... 其他定界符在MSH段中定义,字段定界符在第4个字符位置...

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM