简体   繁体   English

在 Java 中创建包含 RXO 段的正确 HL7 消息

[英]Create correct HL7 message containing RXO segment in Java

I am trying to create an HL7 message in Java and then print the resulting message.我正在尝试用 Java 创建一个 HL7 消息,然后打印生成的消息。 I am faking basic patient information and then adding the Drug Prescription information.我正在伪造基本的患者信息,然后添加药物处方信息。 Then, I want to print the complete message but I wasn't able to use the API correctly.然后,我想打印完整的消息,但我无法正确使用 API。 I am new at using HL7, so I know I'm probably missing some required segments and even using the wrong ones, can you please help?我是使用 HL7 的新手,所以我知道我可能遗漏了一些必需的段,甚至使用了错误的段,你能帮忙吗? This is my current code:这是我当前的代码:

    public RXO runDrugPrescriptionEvent(CMSGeneric cmsgen) {

         CMSDrugPrescriptionEvent cmsic = (CMSDrugPrescriptionEvent) cmsgen;

         ADT_A28 adt23 = new ADT_A28();

         try {
             adt23.initQuickstart("ADT", "A08", cmsic.getPDE_EVENT_ID());

             // We set the sex identity (male or female)
             if (cmsic.getBENE_SEX_IDENT_CD() == 1) {
                 adt23.getPID().getSex().setValue("Male");
             }
             else {
                 adt23.getPID().getSex().setValue("Female");
             }

             // We set a fake name and family name
             adt23.getPID().insertPatientName(0).getGivenName().setValue("CMS Name " + MainTest.NEXT_PATIENT_ID);
             adt23.getPID().insertPatientName(0).getFamilyName().setValue("CMS Family name " + MainTest.NEXT_PATIENT_ID);
             MainTest.NEXT_PATIENT_ID++;

             RXO rxo = new RXO(adt23, new DefaultModelClassFactory());
             rxo.getRxo1_RequestedGiveCode().getCe1_Identifier().setValue("" + cmsic.getPDE_DRUG_CD());
             rxo.getRxo18_RequestedGiveStrength().setValue("" + cmsic.getPDE_DRUG_STR_CD());
             rxo.getRxo19_RequestedGiveStrengthUnits().getCe1_Identifier().setValue("" + cmsic.getPDE_DRUG_STR_UNITS());
             rxo.getRxo5_RequestedDosageForm().getCe1_Identifier().setValue("" + cmsic.getPDE_DRUG_DOSE_CD());

             rxo.getRxo11_RequestedDispenseAmount().setValue("" + cmsic.getPDE_DRUG_QTY_DIS());

             HapiContext context = new DefaultHapiContext();
             Parser parser = context.getPipeParser();
             String encodedMessage =  adt23.getParser().encode(rxo.getMessage());

             logger.debug("Printing Message:");
             logger.debug(encodedMessage);

             return rxo;
        } catch (IOException e) {
             System.out.println("IOException creating HL7 message. " + e.getMessage());
             e.printStackTrace();
         } catch (HL7Exception e) {
             System.out.println("HL7Exception creating HL7 message. " + e.getMessage());
             e.printStackTrace();
         } 

         return null;
     }     

With this code, the logger prints the following message:使用此代码,记录器打印以下消息:

MSH|^~\\&|||||20160331101349.8+0100||ADT^A08|110001|PDE-00001E6FADAD3F57|2.3 PID|||||CMS Family name 100~^CMS Name 100|||Female MSH|^~\\&|||||20160331101349.8+0100||ADT^A08|110001|PDE-00001E6FADAD3F57|2.3 PID||||CMS 家族名称100~^CMS 名称100|||女性

But I was expecting to see the RXO segment as well.但我也期待看到 RXO 部分。 How can I achieve that?我怎样才能做到这一点?

I found that changing the message type from ADT_A28 to ORP_O10 would let me have all the fields I need, as ADT_A28 wasn't the appropriate message for the kind of information I needed.我发现将消息类型从 ADT_A28 更改为 ORP_O10 可以让我拥有我需要的所有字段,因为 ADT_A28 不是适合我需要的信息类型的消息。 There's a complete example on how to set a great amount of segments in this type of message here .有一个关于如何设置这种类型的消息段的大量完整的例子在这里 Then, I was able to print the complete message using the PipeParser:然后,我能够使用 PipeParser 打印完整的消息:

        HapiContext context = new DefaultHapiContext();
        Parser parser = context.getPipeParser();
        String encodedMessage =  parser.encode(msg);
        logger.debug("Printing EREncoded Message:");
        logger.debug(encodedMessage);

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

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