Announcement

Collapse
No announcement yet.

Using Data From Repeating HL7 Segs in Template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Data From Repeating HL7 Segs in Template

    Hi All!

    I?ve been playing around with javascript transformers in Mirth 1.4 and trying to figure out how to extract data from a single field in repeating segments in the incoming message (e.g., DG1, IN1, etc.) and place said fields into the outgoing message. I got the javascript to work (cool!) insofar as it can iterate through the repeating segments and extract the selected fields but I?m stumped on how to get those fields into a variable I can use in the template for the outbound message. Please note that I?m NOT talking about repeating values in a single field (i.e., data delimited by ?~?) but regular fields that occur in each of the repeating segments (in this case DG1.1).

    What I want to do (and this is just for playing around mind you) is take field DG1.1 from each of the DG1 segments in an incoming ADT message and concatenate those fields into a field in the outgoing message?s PID segment. So if there are, say, 3 DG1 segments in the incoming message I simply want to extract the data from DG1.1 in each of those segments and place all of the data into, say, PID-20 of the outgoing message. I thought that once I figured out how to do this then I?d have a simple example I could use as a model for doing real, more complicated stuff.

    Here?s the HL7 message (please note that our admitting system uses non-standard default delimiters but Mirth handles them fine if I turn off strict parsing. Please also note that since one of these delimiters is a colon the Mirth message board seems to replace selected ones with emoticons. Can emoticons be turned off selectively????):

    Code:
    MSH:;~\\&:HBOC:A:NONPCM:A:200704101456::ADT;A08;42:19377332:«»D:2.2:19377332::AL::
    EVN:A08:200704101456::
    PID::00691759:00753542;;;A:32000;A115520:THORPE;TEST;;::19121212:M::1:3372 GILBRALTER HTS #C11;;TOLEDO;OH;43614;US;C;LUCAS~;;TOLEDO;OH;43614;US;P;LUCAS:LUCAS:«»(444)111-2222~(222)111-2222::ENGLISH;4;:M:BUD;;:0704700003;;;A:333-22-2222:
    NK1:1:TEST;OTHER:H;;:300 TEST;;TOLEDO;OH;43614;US:«»(444)111-2222
    PV1::I:3AB;3108;01;A;;;3:3:::111111;BUTTHEAD;MEANSHERYL;;;;MD:55555;NO;PHYSICIAN:"":CC::::1:::111111;BUTTHEAD;MEANSHERYL;;;;MD:IA;;A:0704700003;;;A:«»PM:::::::::::::::::::A:OCC;OCCUPIED::::200702161057:::::
    AL1:::;:::
    DG1:First:I9::TEST::ADMITTING::::::::
    DG1:«»Second:I9::TEST::WORKING::::::::
    GT1:1:32000:THORPE;TEST;;::3372 GILBRALTER HTS #C11;;TOLEDO;OH;43614;US;C;LUCAS~;;TOLEDO;OH;43614;US;P;LUCAS:«»(444)111-2222~(222)111-2222::19121212:M::«»S:333-22-2222:::1:UNKNOWN EMPLOYER;UNK::::4
    IN1:1:001:851:«»PARAMOUNT:«»PO BOX 928;;TOLEDO;OH;436970928;US;C;:«»PARAMOUNT:«»(419)887-2525:88:::UNKNOWN EMPLOYER;UNK;A:::;;&&:N;;:THORPE;TEST;::19121212::::::::::::;;::::::33322222201::::::4:M:;;;;;:
    IN2::333-22-2222::::::::::::::::::::;;::::::::
    ACC:""::
    ZCA:::;;;
    ZCM:N::5:::::::4:::::::::::G::55555;NO;PHYSICIAN::
    ZCV:3::GB7342::::ER:0
    Here?s my javascript:

    Code:
    var testResult = "X";
    var count = 0;
    for each (dg in msg..DG1)
    {
        logger.info('dg.1: ' + msg['DG1']['DG1.1']['DG1.1.1'][count].toString());
        testResult = msg['DG1']['DG1.1']['DG1.1.1'][count].toString();
        count++;
    }
    logger.info('Count is: ' + count);
    logger.info('Result is: ' + testResult);
    connectorMap.put('testResult', testResult);
    connectorMap.put('count', count);
    Here?s my outbound message template:

    Code:
    MSH|^~\\&|PCM|A|XYZ|A|${msh7}|OkToBundle|${msh9}|${msh10}|P|2.2|||AL|NE${cr}PID|1||${pid3}||${pid5}||${pid7}|${pid8}||||||||||${pid19}|${pid19}|TR ${testResult}|CNT ${count}
    After running a transaction the mirth.log shows:

    Code:
    INFO  2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: dg.1: First
    INFO  2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: dg.1: Second
    INFO  2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: Count is: 2
    INFO  2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: Result is: Second
    In the Mirth Channel Messages Mappings (Admin Console) the variable testResult shows ?Second?. The count variable is 2.0.

    So ? I can see in mirth.log that the javascript has obtained each of the DG1.1 values but I?m stumped as to how to get all of them (i.e., both ?First? and ?Second? into the outbound message variables so it can be used in the outbound template. Ideally I?d like to know if there is some way to also have access to each of the repeating values individually ? so if I only wanted to use DG1.1 from the second DG1 segment I?d be able to do that as well. Please also note that I also may be overthinking this.

    Thanks in advance!!!!!!

    Bob D.
    Toledo Ohio

    Post edited by: bdilworth, at: 05/03/2007 07:34

    Post edited by: chrisl, at: 05/03/2007 16:25
    Bob Dilworth
    University of Toledo Medical Center
    Toledo, Ohio

  • #2
    Re:Using Data From Repeating HL7 Segs in Template

    I am planning on doing something similar - I was simply going to store the values in an array - not sure if that solution is sufficient for you - Ooops I see you want to use them in the outbound.....I think I am going to create custom xml, so I'll simply append everything I need, which is not sufficient for your purposes, apologies

    Post edited by: cord73, at: 05/03/2007 09:27

    Comment


    • #3
      Re:Using Data From Repeating HL7 Segs in Template

      I thought of declaring an array in my javascript, filling it with the values from the repeating DG1 segment, and then doing a connectorMap.put of the array so that the outbound's template would have access to it. The one thing I can't see how to do is access the individual elements of the array from within the outbound's template.

      How would one do that?
      Bob Dilworth
      University of Toledo Medical Center
      Toledo, Ohio

      Comment


      • #4
        Re:Using Data From Repeating HL7 Segs in Template

        Added code tags around your HL7 and JS to prevent the emoticons and fix the forum wrapping the text.
        Chris Lang

        Comment


        • #5
          Re:Using Data From Repeating HL7 Segs in Template

          chrisl wrote:
          Added code tags around your HL7 and JS to prevent the emoticons and fix the forum wrapping the text.
          Cool! Thanks Chris. I guess I never noticed we could do that.

          Does anyone have any thoughts on my original question? Bottom line I need to know how to extract things from incoming HL7 repeating segments and place a subset of those things into repeating segments in the outbound HL7 message.

          Can data extracted from the incoming message via javascript be inserted directly into the outgoing message without resorting to the use of variables in the outgoing message template??? If so does anyone have any working examples they'd be willing to share?

          Post edited by: bdilworth, at: 05/04/2007 06:31
          Bob Dilworth
          University of Toledo Medical Center
          Toledo, Ohio

          Comment


          • #6
            Re:Using Data From Repeating HL7 Segs in Template

            Looking into this, will reply asap.
            Chris Lang

            Comment


            • #7
              Re:Using Data From Repeating HL7 Segs in Template

              What if you just put all dg1 fields to one single var and use that variable in a mapping ? (testResult in your case)

              Code:
              var testResult = "";
              var count = 0;
              for each (dg in msg..DG1)
              {
                  logger.info('dg.1: ' + msg['DG1']['DG1.1']['DG1.1.1'][count].toString());
                  testResult += msg['DG1']['DG1.1']['DG1.1.1'][count].toString() + " ";
                  count++;
              }
              logger.info('Count is: ' + count);
              logger.info('Result is: ' + testResult);
              connectorMap.put('testResult', testResult);
              connectorMap.put('count', count);
              svart
              OL/Germany

              Comment

              Working...
              X