2017-02-27 63 views
1

對於HL7(健康等級7)我使用Hapi從HL7標準信息讀取病人信息

寫操作: -

 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.7 54 + 0530 || ADT^A01^ADT_A01 | 1301 | P | 2.4 | 123 PID ||| 123456 || Doe^John ||| M ||| & B201,美國廣播公司街^^諾伊達^ UP ^^ ||印度^^^^^^ 900億

讀操作:

 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

我如何獲得患者信息來自此消息的信息。 請建議我! 謝謝

+0

我不熟悉哈啤,但我想嘗試'adtMsg.getPID()getPatientName(0).getFamilyName(。 ).getSurname()。getValue()' – xmojmr

+0

謝謝@xmojmr !!我知道了 –

回答

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