View Categories

CCL in an EKM / Discern Expert Rule

4 min read

The purpose of the Discern rule explained in this article is to be an example of how a Discern rule can use CCL to evaluate a condition. When a template does not exist to assess a specific condition, you can combine two logic templates to get this functionality. This example shows how to do it. First we will describe what the rule does and then we will dive into how the rule is structured. Finally, we will review how to trigger the rule.

What the Discern Expert Rule does #

This Discern rule prevents users from being able to place a duplicate Nuclear Medicine order for a patient. The rule is triggered when the user tries to place a Nuclear Medicine order (by adding the order to the scratchpad). The rule identifies the orderable the user is attempting to place and then checks if the patient already has an active order of the same catalog_cd. If the rule finds an existing order, the rule shows a warning to the end user and prevents the user from proceeding.

The Duplicate Checking Parameters for orders in DCPTools can provide a very similar functionality to what the rule is providing:

The following logic template is also helpful for finding existing orders for the patient:

Even though both previous methods can provide similar functionality to the CCL templates from this example, we intend to give an example of how CCL can be used in logic templates to solve a problem that is easy to understand.

Structure of the Discern Expert rule #

We need the Discern rule to trigger when the user selects the order from the catalog and before the order is signed. To accomplish this, we use the ADDTOSCRATCHPAD event:

We use the EKS_ORDER_DETAIL_E template to make the rule trigger for orderables of the Activity Sub Type of Nuclear Medicine.

We also use the EKS_DEBUGEKM_E to maximize the debug level while we develop. This template should not be used in PROD (or it should only be used temporarily).

In the Logic Section, we evaluate again the order being added to the scratchpad with the template EKS_ORDER_INCOMING_DETAIL. The following two templates are the interesting ones for this example.

Template EKS_CALC_SAVE_L runs a CCL query. The query assigns a value to a Millennium-defined variable called log_misc1. The template reads the value stored in the log_misc1 variable and assigns it to the custom variable cont. The name of the variable cont is arbitrary. We could have used a different name, but the query must assign the result to the variable log_misc1.

The value of variable cont is now available in template EKS_EVAL_L. This template evaluates the value of cont:

Following is the CCL query from template EKS_CALC_SAVE_L:

SELECT
	O.ORDER_ID
FROM
	ORDERS   O
	, ORDER_CATALOG_SYNONYM   OC
	, DUMMYT D
PLAN O WHERE O.PERSON_ID = trigger_personid
JOIN OC WHERE OC.SYNONYM_ID = O.SYNONYM_ID
JOIN D WHERE OC.MNEMONIC_KEY_CAP = CNVTUPPER('@SYNONYM:1')
DETAIL
	log_misc1 = '2'
with nocounter go

We include the DUMMYT table to compare the synonym mnemonic of the order. This strategy is necessary if the synonym mnemonic of the order being placed or values in OC.MNEMONIC_KEY could contain special characters like, for example, MNU Gammagrafía. For catalogs in English, including the DUMMYT table is probably unnecessary for this comparison as mnemonics in English don’t usually include special characters.

In the action section, we use the template EKS_ALERT_FLEX_A to launch the alert to the user. Please note that the value OPT_CANCEL_LABEL is selected in the OPT_DEFAULT_LABEL parameter. Additionally, no value is set for the parameter OPT_CANCEL_LABEL. These two conditions prevent the user from ending up placing the order.

Following is the content of the message being displayed to the user:

You are trying to place order ‘@SYNONYM:1’. The patient already has an active order of this type.

The message includes the mnemonic of the order the user is trying to place with the help of the substitution variable SYNONYM:1 (where 1 identifies the logic template 1).

How to trigger the Discern Expert rule #

Choose a Nuclear Medicine orderable for which the patient does not currently have an active order. Place the order. The rule should trigger, but it should allow you to sign it and it should not show any alerts. You would only see that the rule was triggered by checking EKM Monitor. Now, try to place the order again. This time, you should not be able to sign it. A pop-up message like this one should display:

You can find the rule attached to this article.

Powered by BetterDocs

This site uses cookies to function and analyze usage. By accepting, you consent to their use and data processing.    Know More
Privacidad