MEDITECH Reporting: Changing Business Rules Quickly

MEDITECH reports often contain business rules for your organization.  When changes are requested, they are usually needed right away. To implement changes, report writers have to understand what a report does.


Business rules are typically expressed in code, known as NPR macros.  Macros are used to break up code into logical groups.  Common practice has been to implement code as inline macros often using the @Macro syntax or a footnote.

Business rules while often straightforward to implement, can be challenging to understand once converted to code.  Understanding existing business logic is required before you can make changes; it follows that organized, de-duplicated code is faster to read, understand and therefore to change.

When you implement an inline macro, your ability to reuse code is limited.  Macros implemented as programs differ from inline macros in 3 ways, they: 1) accept parameters (a,b,c), 2) end in a semi-colon <;>, and 3) code is not compiled into the report.

Parameters facilitate fewer lines of code by making it easy to organize and reuse groups of subroutines, also referred to as blocks of code.  Code reuse equals less code.  Less code means fewer lines of code to understand, before adding or changing report functionality.

@Macro provides a way to separate code in a report without an update to macro calls when the report’s name changes.  One downside to this approach is that you have to Translate the report, each time a change is made to a macro.  If the macro or report is a lengthy one, report translation can take a long time.

Instead of for example, @Macro(detail), you can implement your detail macro as a program and call it dynamically.  To implement an inline macro as a program:

1) identify and define your parameters in the macro A^urn for example

2) terminate the macro with a semi-colon <;>

3) call the macro as a program, only dynamically like this:

Use the dynamic macro technique and your reports will be better organized, clear and adaptable to changing business rules.

NOTE: for those using CS 5.6 and greater, the variable may not be available.  Please try this approach instead.



Leave a Reply

Your email address will not be published. Required fields are marked *