Question
Murillo Braga · May 31, 2019

Conditions within ruleset

Hi guys

I have always struggled with this, tended to use workarounds but now decided to hear from more experienced people if this is something I am misunderstanding.

I need to basically add a "send" within the ruleset number 2, but without a need to associate a "when" node to it. Is this possible? What I basically need is to forward messages with status 160 to "ManageEDM" and also regardless of the status, it should get sent to "ManageRIS"

So what I need is the "send" to be present where the green arrow points, not where the red arrow points. If I click on rule number 2 and try to add the "send", it adds outside of the rule boundaries.

For instance, even by using a "when 1", it only gets executed if I move it above. If it is below, won't get hit.

Thanks in advance!

0
0 366
Discussion (7)1
Log in or sign up to continue

Hi Murillo.

You will need a when to specify when the action should be triggered, and using WHEN 1 is the easiest way of achieving what you need, however I think I see your problem with the ordering.

The reason why your rule only sends to ManageRIS when the ManageRIS item is above the OrderStatus check is because of the RETURN action.

What the RETURN does is stop any actions beyond that point from being processed if the conditions of the WHEN are met. So in your case: When Orderstatus =160, transform and send, and then do not process anything else and move on to the next message.

So what you will want to do is remove the RETURN block to allow the second WHEN in rule two to be run regardless of the outcome of the first WHEN.

Hi Julian,

Thanks for your time.

OK then, but removing the return doesn't affect anything at all. I actually put it there while testing to see if it would impact somehow.

The test that I've just did was getting rid of the return (keeping the order of the "whens") and the message only hit the 1 when target (in this case "ManageEDM". I then switched the order and it only hit the "ManageRIS". See below

Hi Alex,

Great, this seems a good solution for it! The "when" is basically holding everybody up within the same block, which is what I needed.

Many thanks for your answer :)

Can you show me the current set of rules from your latest test?

Hi Murillo.

From that screenshot - an ORU_R01 should go to ManageRIS every time, and go to ManageEDM as well if the OrderStatus is 160, so I'm at a loss as to why it isn't working as intended.

My next steps would be checking the general tab to be sure the rule type is set to "HL7 Message Routing Rule" or, if that fails, creating a new rule to make sure nothing has gone weird in the background for this specific rule.

Otherwise - if no one else is able to point you in the right direction here it might be worth raising with WRC as it could be a weird bug with the version of Ensemble.

Yes, it's possible to add the send where you want it.

You'll need to change your rule to look similar to this:

The problem with having two or more when blocks back-to-back is that they are bit misleading.   
You may assume that

when "condition 1"
    send
  when "condition 2"
    send

is the same as following pseudo code

if ("condition 1")
    send
  if ("condition 2")
    send 

when, in fact, it works at the following pseudo code

if ("condition 1")
    send
  else if ("condition 2")
    send

This means that when you have consecutive when blocks, one and only one when will be executed.
A workaround is to put each when block into its own rule.

P.S. I would split this routing rule in two separate routers and routing rules: one that sends messages only to EDM and one only to RIS. When you have a large environment, makes maintenance and a whole lot of other things easier in the future.