Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

Global map tables can now be created and referenced by many devices.

We recommend using a full database for very large map table lookups. Performance within Connexion starts to degrade after approximately 100,000 rows.

Using an HL7 Transform (v2) device, open the map table dialog and create a new map table:

...

In custom code, the underlying data table object is now exposed. This allows you to perform your own complex queries:

Code Block
languagec#
using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.Generic;
using Connexion.Core;
using Connexion.Core.HL7;
using Connexion.Share;

namespace Connexion.Device
{ 
  // ** This is pseudo-code **
  [ClientRunnable(true)]
  public partial class CustomFunctions : BaseHL7CustomFunctions
  {   
    public void TableLookup(IMessageContext context)
    {
      MapTable mt;
      if(!MapTablesByName.TryGetValue("New MapTable", out mt))
        throw new Exception("Maptable 'New MapTable' not found");
     
      var message = context.GetAsHL7Message();
      
      // put the values to search for in a dictionary where the key is
      // the column name and the value is the value to search for.
      // In production, cache the dictionary and just change the values.
      var lookup = new Dictionary<string, string>();
      lookup.Add("Modality", message["MSH-9"]);
      lookup.Add("Body Part", message["MSH-10"]);
      
      // set the value of MSH-11 to whatever the map table lookup returned
      message["MSH-11"] = mt.Lookup(lookup, "Loinc Part Code");
    }
    
    public void DatatableLookup(IMessageContext context)
    {
      MapTable mt;
      if(!MapTablesByName.TryGetValue("New MapTable", out mt))
        throw new Exception("Maptable 'New MapTable' not found");
      
      var message = context.GetAsHL7Message();
      
      // SQL syntax - careful this can be slow
      // https://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx
      var datatable = mt.DataTable;
      var result = datatable.Select($"Modality = '{message["MSH-9"]}' AND [Body Part] Like '{message["MSH-10"]}%'");
      var row = result.FirstOrDefault();
      if(row == null)
      {
        message["MSH-11"] = "Not Matched";
      }
      else
      {
        message["MSH-11"] = row["LOINC Part Code"].ToString();
      }
    }

  }
}

...