Question
· Jun 30, 2023

Check repeating segments in a rule for value of "-"

I need to create a routing rule where I've got to check for the value of "-" in field 5 of a repeating RQD segment, if the "-" is found in any of the RQD-5 I want to send it to a transform, if the rule doesn't find a "-" in any of the RQD-5 I want to send it to another transform.

Unfortunately we are running an older version of Ensemble and the foreach function is not available. 

The other thing to add is the transforms are writing the output to a flat file so my business process is using the EnsLib.MsgRouter.RoutingEngine class.

Sample message:

ORC|NW|5139|||||||20230620161500|78068^TEST^TOM^^||43865^TEST^PHYSICIAN^^|1259^11800004
RQD|1|124128|0137^GUIDE CATH|0137^GUIDE CATH|-1||1259^CV CATH/EP||619^PERP|20230620
RQ1|40|SONIC AVE|LA7HS2SH||0137|
ORC|NW|5139|||||||20230620161500|78068^TEST^TOM^^||43865^TEST^PHYSICIAN^^|1259^11800004
RQD|2|138030|0537^COIL 400 COMPLEX STD|0537^COIL 400 COMPLEX STD|1||1259^CV CATH/EP||619^PERP|20230620
RQ1|2025|PUMA|4002C0610||0537|

Any help is greatly appreciated.

Product version: Ensemble 2018.1
$ZV: Cache for UNIX (IBM AIX for System Power System-64) 2018.1.4 (Build 505_1U) Thu May 28 2020 10:11:51 EDT [HealthShare Modules:Core:15.032.9035 + Linkage Engine:15.032.9035]
Discussion (4)1
Log in or sign up to continue

Hi Doug,

Have you considered creating a new Rule FunctionSet.

This would then appear in as a new available function in Rule Editor when compiled.

For example:

Class Test.Fun Extends Ens.Rule.FunctionSet
{
ClassMethod SegmentFieldContains(pDocument As EnsLib.HL7.Message, segmentName = "", fieldNumber = 0, value As %String = "")
{
  // validation
  quit:segmentName'?3AN 0
  quit:fieldNumber<1 0
  quit:value="" 0
  set isFound=0
  // get count of segments
  set segCount=pDocument.GetValueAt("*")
  // loop through all of the segments
  for i=1:1:segCount {
    set seg=pDocument.GetSegmentAt(i)
    continue:'$IsObject(seg)
    // skip wrong segment
    continue:seg.GetValueAt(0)'=segmentName
    // skip if field does not contain value
    continue:seg.GetValueAt(fieldNumber)'[value
    set isFound=1
    quit
  }
  quit isFound
}

}

If you were to use the Parenthesis () Syntax in your routing rule, you could simply make your rule something like:

The reason this works is that using the parenthesis syntax to access repeating values from a message will return all of the entries in the repeating segment as a *delimited string, and you can then check the string contains the - character using the contains function.

*Do make sure that the delimiter isn't the character you're looking for. Maybe throw in a trace when you first test this and check how it's returned.