Blogs Home
Tuesday, August 26, 2014 8:44 AM

NPR Tip (MAGIC only) - Printing Radiology ($T RAD) Text and how to use ECB/ECE loop in a report

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

In October 2002, we published a tip on how to print Radiology report text in an NPR report. At the time, there was no field or utility to do this (or possibly I just liked to do things the hard way), so our code showed how to open to the "saf" (sequential access file) or "raf" (random access file) containing the report text and send the text out to the printer or output file.

There is a utility program that will print the entire report body for you, and you can just put a program call in an LC or ECB and call this:,

Or for Addenda


There can be a problem however, if you need to send the lines of text out with some data at the beginning of each line, or without the CR/LF at the end. It turns out if you pass a "B" argument to either of these utilities, they build the report text in /RPT.TEXT[report]T[n] = line of text and the addenda text in /ADD.TEXT[addendum]T[n] = line of addendum text.

So if we call,1) the utility creates /RPT.TEXT[report]T[1] = first line of text
/RPT.TEXT[report]T[2] = second line of text

This month I will show you a report that selects reports and addenda for a signed date range, and then prints out the report and addenda text with some leading data (we will show line #) at the start of each line of text. We will use the two utilities to create the temp structures holding the report and addendum text and an ECB/ECE loop to print out the lines with a line counter at the beginning of each line.

The report example is a bit more complex because it also allows you to export a report if it was signed during the selected date range, or if one of its addenda was signed during the date range. This is useful for a billing service export because they typically want to get a report "again" if an addenda is attached and signed.

Step 1 is to build a report in RADRW.REPORT so it loops through the "" segment. Note that we do not use an index. Because we loop on the indexes in our own "start" macro (called at the beginning of the report) and make a list of the report urns in a slash structure, when we do an LI selection, the report goes directly to the list of reports we want and an index would only make the report slower (much slower).

NPR Image

Then on page two we prompt for a date range with an "IG" (ignore) operator and do an LI selection on /RPT. That is a structure we will build in a "start" macro to make a list of all the reports signed in the date range and all the reports which had an addenda signed in the date range.

NPR Image

NPR Image

Next we call the two utilities in a "detail" macro (per each report and exam) to build /RPT.TEXT and /ADD.TEXT

NPR Image

Then in the picture, we "wrap a loop" around a line with an ECB and ECE and loop thru /RPT.TEXT, get the line of text out into the variable "DATA" and then put a line counter at the beginning of each line in five spaces left justified.

A computed field prints the line. We set TRUNC =NO so that even if the line exceeds the width we have defined, the entire value prints.

NPR Image

The output of the report is shown below:

NPR Image

A copy of the report has been loaded to our MAGIC report library.

Visit our report library at to look them up.

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

This article originally appeared in the August 2014 issue of Iatric Systems Updates! newsletter.