2016-04-28 42 views
3
  1. 我希望得到一個特定的細分HL7,由段例如名稱, 我使用Pipeparser類,但我還是不知道如何通過結構每段名稱(MSH,PID,OBX,...)。獲得Java中的一個特定消息的段HL7

  2. 有時候我有像DG1或PV1或OBX(請參閱附加的行)重複段如何從Pentaho水壺中的每個行段獲取數據文件(我可以在水壺中使用java代碼,如果有這樣的解決方案, 請幫助)。

OBX|1|TX|PTH_SITE1^Site A|1|left||||||F||||||| 
OBX|2|TX|PTH_SPEC1^Specimen A||C-FNA^Fine Needle Aspiration||||||F||||||| 

DG1|1|I10C|G30.0|Alzheimer's disease with early onset|20160406|W||||||||| 
DG1|2|I10C|E87.70|Fluid overload, unspecified|20160406|W||||||||| 

回答

1

您應該使用HL7 Parser任何HL7消息格式正確/準確的分析。

隨着高致病性禽流感的幫助下,你可以分析你的消息流

// Open an InputStream to read from the file 
     File file = new File("hl7_messages.txt"); 
     InputStream is = new FileInputStream(file); 

     // It's generally a good idea to buffer file IO 
     is = new BufferedInputStream(is); 

     // The following class is a HAPI utility that will iterate over 
     // the messages which appear over an InputStream 
     Hl7InputStreamMessageIterator iter = new Hl7InputStreamMessageIterator(is); 

     while (iter.hasNext()) { 

      Message next = iter.next(); 

      // Do something with the message 

     } 

或者你可以把它讀作字符串

File file = new File("hl7_messages.txt"); 
     is = new FileInputStream(file); 
     is = new BufferedInputStream(is); 
     Hl7InputStreamMessageStringIterator iter2 = new Hl7InputStreamMessageStringIterator(is); 

     while (iter2.hasNext()) { 

      String next = iter2.next(); 

      // Do something with the message 

     } 

希望這可以幫助您在正確的方向。

+0

謝謝,據我所知,你的代碼可以在同一時間迭代多個消息HL7,但我的問題是在同一個消息中,我如何獲得每個段,以及如何處理重複段,如DG1 | 1 |和DG1 | 2 | –

+0

你可以看到這個[示例](http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/ExampleUseTerser.html)。你可以使用Terser解析和查找段落 – Sanjeev

+0

聽起來不錯,現在請如果你能看到第二個問題。 –