How to check repeating segment value in business rule?
Hi,
In the business rule I want to send a message to the business operation if any of OBX:8 (Abnormal Flag) is set.
I tried foreach but could not found desire results. Below is the sample message:
.png)
Thanks
Comments
Are you correctly specifying the propertypath for the Document Type of the message? This works as expected for me, where the DocType is 2.5:ORU_R01:
.png)
Thanks Jeffrey Drumm
I was missing (1) in PIDgrpgrp and in ORCgrp
Hi Jeff
I would set up Business Rule to check fields and assign values for HL7 ORU_R01 by using Intersystems IRIS for Health. Your posting above is just what I wanted. Please help me how to go there. What Type and Context Class should be in the following Wizard: .png)
Hi William,
This is what you need:
.png)
I will add that I am very grateful to ISC for finally adding this foreach feature to the routing rule functionality (it appears to have become available with 2020.4). I have one quibble, though ... it would be wonderful to be able to exit the loop without returning from the ruleset (i.e. "break"). The current mechanism forces you to loop through all repetitions regardless of the desired condition being met before the final loop iteration is reached.
A design pattern where I might wish to assign a value to a variable and exit the loop when the condition is met (rather than executing a send) is something I can envision doing regularly.
Agreed
Hi Jeffrey,
I'm having trouble with the following routing rule using foreach and assign operations. I don't really understand how to use assign. Any suggestions?
.png)
.png)
In a routing rule, temporary variables must be declared in the rule's general tab:
![]()
And in the rule proper, they must be prefixed with an "@" symbol wherever they're referenced:
.png)
The foreach as you've designed it will only set the values for tSendAbnormal and tSendNormal based on the contents of the last OBX segment in the message, since it keeps looping until it either hits the last segment or you've triggered a return based on a condition.
What, exactly, are your criteria for sending a message to the "Normal" transformation vs. the "Abnormal?" In a result message, some observations (OBX segments) may have abnormal flags while others won't. Would such a message qualify for both transformations?
There are 3 possible scenarios that require sending a message to only 1 or both transformations.
1) The ORU contains only Abnormal OBXs - Send only to Abnormal transformation
2) The ORU contains only Normal OBXs - Send only to Normal transformation
3) The ORU contains both Normal and Abnormal OBXs - Send to both transformations
Thanks, Jeffrey
I made the following changes to use the temp variables, and it seems to work as expected. It had to separate the two whens into separate subrules to get them to execute.
Yes, this would be much easier if we had a break operation
.png)
.png)
Great! I was a bit off on my comment regarding how the expressions in the foreach would be evaluated. Your rule should work as expected.
I will mention that having the "= 1" as part of the when evaluation is superfluous. 1 is true in the rule editor so these work just fine:
.png)
.png)
With some help we created a function to loop through a repeating field and verify values against a single string, and a variation against a Lookup Table...
ClassMethod DoesSingleValueExistRepeatingSegmentFields(pHL7Msg As EnsLib.HL7.Message, pSegment As%String, pField As%String, pSubField As%String, pInputValue As%String) As%Boolean
{
#dim tSeg as EnsLib.HL7.Segment
set tSegCount = pHL7Msg.SegCountGet()
set i = 1setj = 1Set tFound = 0//get new valuesset tval=""while ((i <= tSegCount) && (tval="")) {
set tSeg = pHL7Msg.GetSegmentAt(i)
if (tSeg.Name = pSegment) {
set pField2 = pField_"(*)"set tRepCount = tSeg.GetValueAt(pField2)
while ((j <= tRepCount) && (tval="")) {
set tID = tSeg.GetValueAt(pField_"("_j_")"_"."_pSubField)
if (pInputValue = tID) {
set tval = 1
}
setj = j + 1
}
}
set i = i + 1
}
if (tval '= "")
{
Q1
}
quit0
}