Announcement

Collapse
No announcement yet.

Processing DFTs with multiple FT1s

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

  • Processing DFTs with multiple FT1s

    I have DFTs with one or more FT1s. I'm trying to get them into SQL Server 2008. I'm using Mirth 2.1.0.5389. Since I don't know how many FT1s I have, I can't use a transformer to pull out the fields I want and send them to a stored procedure. I could concatenate the strings together and deal with it in SQL Server but that isn't my preferred method.

    Sample input:
    MSH|^~\&|MTAB|MM|MODULEMD|MODULEMD|20150223093543| |DFT^P03|201502230935431000|P|2.3
    EVN|P03|20150223093543|||
    PID|1|22818|32396|22818|PtLastname^PTFirstname^||1 9380303|M||WHITE|8359 Office Park Dr^^Grand Blanc^MI^48439||248-434-0444^^^|||||22818|123456789|||NON - HISPANIC/LATINO||||||||
    PV1|1|O|^^^PMC|R|||^DrLastName^DrFirstName|H83114^ Dr2LastName^Dr2FirstName||||||||N||P|||||||||||||| ||||||||||||||||||||
    FT1|1|212887|1|20150223||CM|93000^ECG ROUTINE ECG W/AT LEAST 12 LEADS; W/I&R|||1.00||||||PMC|||427.9~272.9~786.05~272.0|A73 292^DrLastName^DrFirstName|A73292^DrLastName^DrFir stName|H83114^Dr2LastName^Dr2FirstName|||93000^ECG ROUTINE ECG W/AT LEAST 12 LEADS; W/I&R
    FT1|2|212887|2|20150223||CG|99214^OFC/OUTPT VISIT E&M EST MOD-HI SEVERITY 25 MIN|||1.00||||||PMC|||427.9~272.4~424.2~496|A73292 ^DrLastName^DrFirstName|A73292^DrLastName^DrFirstN ame|H83114^Dr2LastName^Dr2FirstName|||99214^OFC/OUTPT VISIT E&M EST MOD-HI SEVERITY 25 MIN

    I found a post about writing each FT1(+ MSH, PID, etc.) into a new message.
    http://www.mirthcorp.com/community/f...&highlight=ft1
    "multiple messages from one".

    I imported the channel. I only get one message and the result is "FT1|undefined". The MSH, PID, etc. are ok.

    Here is my channel transformer code:
    var suppress = "";
    var tmp = msg;

    for each (seg in msg..MSH)
    {
    tmp['MSH'] = msg['MSH'];
    }

    for each (seg in msg..EVN)
    {
    tmp['EVN'] = msg['EVN'];
    }

    for each (seg in msg..PID)
    {
    tmp['PID'] = msg['PID'];
    }

    for each (seg in msg..PV1)
    {
    tmp['PV1'] = msg['PV1'];
    }

    try{
    if (msg['FT1'][0]['FT1.1']['FT1.1.1'] != ""){
    //continue
    }
    }
    catch(e){
    suppress = "yes";

    channelMap.put('check', e);
    }


    var test = "";
    var count = 0;
    for each (seg in msg..FT1)
    {
    tmp['FT1'] = msg['FT1'][count];
    var test = test + tmp;
    count++;
    }

    channelMap.put('test', test);
    channelMap.put('suppress', suppress);

  • #2
    There are probably lots of ways to do this.. I would attempt it this way..

    In your transformer
    Code:
    var dbArrayList = new XMLList();
    
    for each (ft1 in msg['FT1']) {
       var row = <row/>;
       
       var sqlStr = '';
    
       /* some logic to build sqlStr goes here 
           to access FT1 you can do this..
           var id = ft1['FT1.1']['FT1.1.1'].toString();
    
       */
       row['sql'] = sqlStr;
       dbArrayList += row;
    
    }
    
    // lastly submit arrays that contain sql statements to the channel	
    dbArrayList = '<rows>' + dbArrayList + '</rows>'
    connectorMap.put('dbArrayList',dbArrayList);
    then in the javascript database writer..
    Code:
    var dbList = new XMLList($('dbArrayList'));
    
    // setup your database connection here
    
    for each (var row in dbList.row)
    {
        var sql = row.sql.toString();
        // run your database transactions here
    
    }
    Last edited by glenn71; 03-03-2015, 05:17 PM.

    Comment


    • #3
      I tried this in my transformer:
      var dbArrayList = new XMLList();

      for each (ft1 in msg['FT1']) {
      var row = <row/>;

      var sqlStr = '';

      sqlStr = ft1['FT1.1'].toString();

      row['sql'] = sqlStr;
      dbArrayList += row;

      }

      // lastly submit arrays that contain sql statements to the channel
      dbArrayList = '<rows>' + dbArrayList + '</rows>'
      connectorMap.put('dbArrayList',dbArrayList);

      And this in my javascript:
      var dbList = new XMLList($('dbArrayList'));

      for each (var row in dbList.row)
      {
      var FT1 = row.sql.toString();
      // run your database transactions here

      sql = 'EXEC [dbo].[%hl7_edi_financial_transaction_info_sp_create2] ' +
      ' @p_msg_id = 58 ' +
      ',@p_FT1 = ' + FT1
      }

      I turned my SQL Profiler on. I never saw ].[%hl7_edi_financial_transaction_info_sp_create2 get called.

      Not sure if the array didn't get built in the transformer or it didn't get passed well to javascript.

      Comment


      • #4
        I ended up with
        var rpt = '';
        var i = 0;
        for each (ft1 in msg['FT1']) {
        var ln = msg['FT1'][i++].toString();
        rpt = rpt + ln + '<br>';
        }
        in my transformer.

        And this in my JavaScript:

        This in the parameter section:
        var sql = 'EXEC [dbo].[edi_sp_dft_info_hl7_import2] ' +
        ' @p_msg_id = ? ' +
        ...
        ',@p_FT1 = ? '
        var params = new Packages.java.util.ArrayList();
        params.add($('MessageId'));
        ...
        params.add($('FT1'));


        This was the key to getting both FT1 segments:
        for each (ft1 in msg['FT1']) {

        I had:
        for each (itm in msg..FT1) {
        and I only got one FT1

        Thank you!

        Comment

        Working...
        X