简体   繁体   中英

Iterate over repeated specific HL7 segment in Pentaho Data Integration KETTLE

I want to get a specific segment hl7, by name of segment for example,

  1. I am using Pipeparser class but i still don't know how to get each segment by structure name ( MSH,PID,OBX,... ).

  2. Sometimes I have a repeated segments like DG1 or PV1 or OBX(see attached lines) how can I get data fileds from each row segment in Pentaho kettle (do i need java code in kettle, if there is such solution, help please).

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

or

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

You should use HL7 Parser for proper/accurate parsing of any HL7 formatted message.

With the help of HAPI you can either parse your message as Stream

// 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

        }

Or you can read it as String

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

        }

Hope this helps you in right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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