1

对于 HL7(健康级别 7),我使用的是Hapi

写操作:-

     ADT_A01 adt = new ADT_A01();
     adt.initQuickstart("ADT", "A01", "P");

      // Populate the MSH Segment
      MSH mshSegment = adt.getMSH();
      mshSegment.getSendingApplication().getNamespaceID().setValue("TestSendingSystem");
      mshSegment.getSequenceNumber().setValue("123");

      // Populate the PID Segment
      PID pid = adt.getPID(); 
      pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
      pid.getPatientName(0).getGivenName().setValue("John");
      pid.getPatientIdentifierList(0).getID().setValue("123456");

      pid.getAdministrativeSex().setValue("M");

      pid.getPhoneNumberHome(0).getPhoneNumber().setValue("90000000000");

      pid.getPatientAddress(0).getStreetAddress().getStreetName().setValue("B201, Abc street");
      pid.getPatientAddress(0).getCity().setValue("Noida");
      pid.getPatientAddress(0).getStateOrProvince().setValue("UP");
      pid.getPatientAddress(0).getCountry().setValue("India");

      // Now, let's encode the message and look at the output
      HapiContext context = new DefaultHapiContext();
      Parser parser = context.getPipeParser();
      String encodedMessage = parser.encode(adt);
      System.out.println("Printing ER7 Encoded Message:");
      System.out.println(encodedMessage);

输出:

打印 ER7 编码消息:MSH|^~\&|TestSendingSystem||||20170227154106.754+0530||ADT^A01^ADT_A01|1301|P|2.4|123 PID|||123456||Doe^John|||M| ||&B201, Abc 街^^诺伊达^UP^^印度||^^^^^^90000000000

读取操作:

       HapiContext context2 = new DefaultHapiContext();
       Parser p = context2.getGenericParser();
       Message hapiMsg;

        try {
          hapiMsg = p.parse(encodedMessage);
        } catch (EncodingNotSupportedException e) {
          return;
        } catch (HL7Exception e) {
          return;
        }

      ADT_A01 adtMsg = (ADT_A01)hapiMsg;
      MSH msh = adtMsg.getMSH();

     // Retrieve some data from the MSH segment
     String msgType = msh.getMessageType().getMessageType().getValue();
     String msgTrigger = msh.getMessageType().getTriggerEvent().getValue();

     System.out.println("Decode : ");
     System.out.println(msgType + " " + msgTrigger);

输出:

解码:ADT A01

我如何从此消息中获取患者信息。请建议我!谢谢

4

1 回答 1

1

我解决了!!!
这是我的解决方案:

     PID pid1 = adtMsg.getPID();
     String id = pid.getPatientIdentifierList(0).getID().getValue();
     System.out.println("PID : "+id);
     String last = pid1.getPatientName(0).getFamilyName().getSurname().getValue();
     String first = pid1.getPatientName(0).getGivenName().getValue();
     System.out.println("Patient Name : "+first+" "+last);

输出

Decode : 
------------------
Message Type : ADT
Message Trigger : A01
PID : 123456
Patient Name : John Doe
于 2017-02-27T13:40:00.457 回答