Blogs Home
Friday, February 20, 2015 10:27 AM

NPR Tip: Every Module Can Have Room and Bed Index (MAGIC or Client/Server)

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

It is quite common to write reports for current inpatients, and a logical assumption by many NPR report writers is that such reports are best built in ADM, even when the data required is in some other application. A very typical approach is to build a “main report” in ADM and then use (shudder) fragments or programming in a macro to get the data from OE, PHA, LAB, NUR, etc.

A better technique is to write the report in the DPM with the data, and take advantage of the fact that most clinical modules keep a prefix or all prefixes “open to” ADM.

In MAGIC, EDM, OE, PHA, LAB, NUR, and SCH keep the * prefix open to the ADM data file, (ABS, BAR, RXM, and RADRW do not).

In C/S, EDM, OE, PHA,LAB, NUR, and SCH keep all prefixes open to ADM data, dictionaries, and programs, and it is easy to open ADM from any C/S report by calling:“”,”ADM.XYZ”) in a “start macro”.

This month, we will show how to effectively “give” EDM, OE, PHA, LAB, NUR, SCH a room and bed index. Our example will be a Pharmacy report for find all current inpatients on a particular medication. We will use the ADM room bed index to make a list of all current inpatients in slash, and use that list in a selection for speedy access to just those patients for our report.

The first step is to pick an index for your PHA.RX report that contains ADM.PAT.urn as far to the left in the subscripts as possible, ideally as the first subscript In EDM, OE, PHA, LAB, NUR and SCH this field is called “patient” (ABS and BAR are odd ducks with @adm.urn and @int.number just because).

In MAGIC, you have these indexes to choose from:

NPR Tip Image

In Client/Server the indexes are identical, you just don’t have to deal with the “customer name/programmer name” duality, as the C/S development team lacked a department of redundancy department.

NPR Tip Image
So our PHA report looks like this:

NPR Tip Image

The selections on the report are setup like this:

NPR Tip Image

Three points about the selections:
Selection #1
We are going to load a list of admission urns from the ADM room bed index in a “start” macro, the LI will use that list against the index file to efficiently get to all the medications of each current inpatient.

Selection #2
The index file we picked includes “status” (order status) as its second subscript. We can restrict the report to “AC” (active) orders to make it even more efficient by hardcoding that selection as #2

It is bad practice to write a PHA report looking for particular drug mnemonics. Nobody is going to check every formulary load to see if some new variations on a drug have appeared. Checking the med’ for “INSULIN” with a “CO (Contains) makes it less likely that new forms of that medication will be missed.

Now we need to use the ADM room and bed index to get our list of current inpatients (and outpatients in a bed if you use that MEDITECH feature).

The room and bed index looks like this:

@room.bed.index[facility,room.bed] = urn

To use it from a Pharmacy report we need to add the DPM so the translator can find it:[ADM.PAT.facility,,ADM.PAT.bed]

Since we want to loop through the whole thing, we can use “physical next (>) rather than nesting three DO loops with “logical next” (+ or @Next). It just amounts to a bit less typing:

Remember that (for MAGIC), only the * prefix is open to ADM in the PHA (and OE, NUR, and EDM applications). This means you have a problem using any field where the data definition expects to use a different prefix, such as :.

The way to tell which prefix will be used is either, stick the field or segment in a test macro and watch the translation or look at the data definition for ADM.PAT. If you look at the data definition you will see that data fields use the * prefix, but index segments translate with : instead.

NPR Tip Image

Fortunately, there is a “@Chg.prefix” translator macro you can include in your code to force the translator to use a substitute a different prefix for the one defined in the data definition:

The syntax is:
@Chg.prefix(DPM,regular prefix,prefix to use instead)
So if we do @Chg.prefix(ADM.PAT,:,*) the translator will use * instead of : for anything with a : in the data definition. Instead of :AARB the translator will do *AARB so your code will work.

PS – using one prefix for indexes and a different prefixes for data increases the chance that data fetched from the file will be in a memory based buffer and a report will run faster, with fewer trips to the disk for more data. This is the reason MEDITECH typically uses a different prefix for data than indexes, and opens multiple (two or more) prefixes to the application data file.

NPR Tip Image

After the start macro runs, there is a list in /PAT of all the patients currently in beds:

NPR Tip Image

This list in /PAT behaves like your own RBI index of patients for the report in PHA.

In C/S you do not need to use the @Chg.prefix, because the ADM prefixes are open in PHA exactly as the translator expects.

NPR Tip Image

Here is output from a MAGIC test system:

NPR Tip Image
Here is output from a C/S (actually 6.0) system:

NPR Tip Image

This sample PHA report in both C/S and MAGIC format: %PHA.RX.zcus.update.pha.rbi has been posted in our report library.

Visit our report library at

You can find additional Report Writing Tips on our website at, as well as information about our on-site Report Writer Training and Report Writing Services.

To subscribe for email notifications for new Report Writing classes, please follow this link:

For more information, please contact our NPR report writing team at