Question
· Jan 18, 2018

Using StartsWith with a data lookup table

I have an interface that does not send me specific ID's, so I am scanning the AIL3.2 (Text) field for certain characters. The Routing rule is getting pretty big with all the OR statements. Is there a way that I can define what I am searching for in the data lookup table, and not have to scan the whole field that it does by default? Is there a way that I can simplify this?

 <rule name="Provation" disabled="false">
<constraint name="source" value="CaseSched949502Normalization"></constraint>
<constraint name="docCategory" value="SIUOSU"></constraint>
<constraint name="docName" value="SIU_S12,SIU_S15,SIU_S26"></constraint>
<when condition="(HL7.{MSH:MessageType.TriggerEvent}!=&quot;S14&quot;)&amp;&amp;(HL7.{MSH:SendingFacility.NamespaceID} CONTAINS &quot;CASE&quot;)&amp;&amp;((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS &quot;OSU UH ENDO&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS &quot;OSU UH BRONC&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS &quot;OSU UHE ENDO&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS &quot;OSU UHE BRONC&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS &quot;OSU STONERIDGE ENDO&quot;)||((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;MER&quot;)&amp;&amp;GroupIDExists(HL7,&quot;AIS&quot;,&quot;3.1&quot;,&quot;GIProvationMERProcedures&quot;))||(((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;ONT ENDO&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;GAL OR&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;GAL ENDO&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;BUC OR&quot;))&amp;&amp;GroupIDExists(HL7,&quot;AIS&quot;,&quot;3.1&quot;,&quot;GIProvationAVIProcedures&quot;))||(((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;HOC OR&quot;)||(HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith &quot;HOC ENDO&quot;))&amp;&amp;GroupIDExists(HL7,&quot;AIS&quot;,&quot;3.1&quot;,&quot;GIProvationHOCProcedures&quot;)))">
<send transform="osuwmc.CaseSchedtoProvationDTL" target="GIProvationADTSCHED"></send>
</when>
</rule>

Thanks

Scott Roth

The Ohio State University Wexner Medical Center

Discussion (3)2
Log in or sign up to continue

just for better readability of the audience I transformed your WHEN condition that dictates speed.

(HL7.{MSH:MessageType.TriggerEvent}!="S14")
&&
(HL7.{MSH:SendingFacility.NamespaceID} CONTAINS "CASE")
&&
(
 (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS "OSU UH ENDO")
 ||
 (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS "OSU UH BRONC")
 ||
 (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS "OSU UHE ENDO")
 ||
 (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS "OSU UHE BRONC")
 ||
 (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} CONTAINS "OSU STONERIDGE ENDO")
 ||
 (
  (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "MER")
  &&
  GroupIDExists(HL7,"AIS","3.1","GIProvationMERProcedures")
 )
 ||
 (
  (
   (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "ONT ENDO")
   ||
   (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "GAL OR")
   ||
   (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "GAL ENDO")
   ||
   (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "BUC OR")
  )
  &&
  GroupIDExists(HL7,"AIS","3.1","GIProvationAVIProcedures")
 )
 ||
 (
  ((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "HOC OR")
  ||
  (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room} StartsWith "HOC ENDO")
  )
  &&
  GroupIDExists(HL7,"AIS","3.1","GIProvationHOCProcedures")
 )

It shows me that you basically check on  (HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room}
I see not much opportunity for optimization of CONTAINS
But for your StartsWith you may try this construct:

  In(SubString((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room},1,6),"HOC OR","HOC EN")
or
 In(SubString((HL7.{RGSgrp(1).AIL:LocationResourceID(1).Room},1,6),"ONT EN","GAL OR","GAL EN",BUC OR")

An HealthShare expert might be able to answer if it is possible to have an index on the fields of your WHEN condition.

A different approach could be to handle the whole WHEN in a Custom Utility Function

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=...

You can treat a lookup table (Ens.Util.LookupTable) like any SQL table, using the LIKE operator to perform either "contains" ('%strval%') or "StartsWith" ('%strval') searches, but I don't think that's what you're really looking for. I'm thinking that, based on the logic you supplied, you're looking for two tables: One containing keys that you will use as "StartsWith" strings, and the other as "Contains" strings. You'd like to iterate through one table for your "Contains" comparisons, checking each AIL:3.2 against each key. And for your "StartsWith" comparisons, the other table. This would keep it maintainable in the Ensemble section of the Management Console, but you'd only really be populating the KeyName field. Wrapped in a couple of FunctionSet methods, this would simplify your rule considerably.

But here are some examples of "Contains" vs. "StartsWith" queries against Ens.Util.LookupTable, just in case:

ISYSDEV>>select KeyName from Ens_Util.LookupTable where TableName = 'ALLERGY_CODES' and KeyName LIKE '%mon%'
12.     select KeyName from Ens_Util.LookupTable where TableName = 'ALLERGY_CODES' and KeyName LIKE '%mon%'
KeyName
Almonds
almonds
cinnamon
lemons
4 Rows(s) Affected
statement prepare time: 0.1417s, elapsed execute time: 0.0011s.
---------------------------------------------------------------------------

 

ISYSDEV>>select KeyName from Ens_Util.LookupTable where TableName = 'ALLERGY_CODES' and KeyName LIKE 'cin%'
13.     select KeyName from Ens_Util.LookupTable where TableName = 'ALLERGY_CODES' and KeyName LIKE 'cin%'
KeyName
cinnamon
1 Rows(s) Affected
statement prepare time: 0.0006s, elapsed execute time: 0.0003s.
---------------------------------------------------------------------------