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.
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:
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
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:
The “OPEN.LAB” code for MAGIC:
The “OPEN.LAB” code for Client/Server is much easier
The @PROCESS macro is identical across platforms, to count COMP drug tests:
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.
The “CLOSE.LAB” for C/S calls the Z.link.db 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 Z.rw.close.up code take care of closing things up at the end instead.
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):
Example reports with this code for both C/S and MAGIC have been uploaded to our report library as OE.ORD.zcus.is.ord.rule.example.