Blogs Home
Monday, October 22, 2012 12:02 PM

Smarter OE/POM rules Part 2 (Client/Server or MAGIC)

Written by Joe Cocuzzo, Senior VP of Report Writing Services - iatricSystems

Last month we showed how to create a rule for OE/POM that calls a report macro written as a program, in a way that allows you to easily restore that program call if the rule is refilled or rebuilt.

As promised, this month we will show how to write a macro that checks the patient’s primary insurance and lab history across visits to alert you if the patient has a particular insurance and 3 or more drug screens in the past 365 days.

We are looking for all ordered tests for DAU7 (which were completed) for the past 365 days, provided the patient has a primary insurance of CIGNA.

Across visits for the patient, we want to count the number of these tests and alert the user if the patient has had three or more already.

Because the MAGIC version of the code opens prefixes with programming, you might want to test your version in your test directory before running in LIVE.

Here is a test patient we have set up, notice that the tests span two different accounts.

NPR Image 1

Our order rule macro will run from OE, so we will do the following in our macro:

Check to see if the current visit has a CIGNA primary insurance, if so:

Open Lab
Check all prior lab work for accounts where CIGNA was the primary insurance and count the number of DAU7 ordered tests for the past 365 days.
Display warning message if 3 or more are found
Close Lab

The “open lab” and “close lab” code is different in Client/Server and MAGIC, but otherwise our two macros can be identical.

Here is the macro code we need:

NPR Image 2

The “OPEN.LAB” code for MAGIC:

NPR Image 3

The “OPEN.LAB” code for Client/Server is much easier

NPR Image 4

The @PROCESS macro is identical across platforms, to count COMP drug tests:

NPR Image 5

The “CLOSE.LAB” for MAGIC will unstack all the prefixes so things are back the way we started. Even though we use the “C” (Close) command, because we “unstack” the prefixes are actually opened “back” to the way they were when we stacked them. This is crucial in MAGIC, as the report is expecting to be “open” to the OE database and dictionary, not to LAB.

NPR Image 6

The “CLOSE.LAB” for C/S calls the to close the LAB database, but since each database in C/S has unique prefixes, it would not hurt to leave the prefixes open and let the code take care of closing things up at the end instead.

NPR Image 7

When we order in OE on a patient with three or more drug screens in the past 365 days (where CIGNA is the primary insurance):

NPR Image 8

Example reports with this code for both C/S and MAGIC have been uploaded to our report library as