Last month we showed how to cross applications without using fragments in a Client/Server (C/S ) NPR report. This month it is MAGIC’s turn.
The “official” technique for crossing applications in an NPR report is to write another report as a fragment and call it via the utility program %Z.rw.fragment. The fragment then takes over and
prints, or puts some data in /R.FRAG.VAL, which you use in some computed fields or an “MV” array back in the main report to print the data from the other application.
Fragments allow you to cross applications without needing to write any loops, but they carry a sizable performance penalty. Also, it is more difficult to maintain a main report and one or more fragment
reports, especially as the fragment calls tend to be hidden in line checks, ECB attributes, or computed fields.
This month we will show a MAGIC version of a patient export from Abstracting with patient address information from MRI.DRC.
Last month we showed how to avoid fragments in C/S by using the %Z.rw.fragment program with no “A” argument (that is, no report name) or the %Z.link.db program to open the MRI database. In MAGIC we cannot use Z.rw.fragment in this way, and the Z.link.db program does not exist. Instead, we can use the %Z.link program to open the prefix we need.
NOTE: If you are unfamiliar with opening and managing prefixes, you should develop your report in the TEST environment and make sure it performs properly before running it in LIVE. If you want
to learn more about the MAGIC programming language generally, MEDITECH has an “Introduction to MAGIC” and a “MAGIC Reference Manual” that you might be able to request.
We use @mri.urn as the HK1 sort, so the local variable mri.urn (ea) contains the patient’s medical records urn. This means that if we open the MRI database, fields stored by the patient’s medical records urn will be available. Notice that ? is the prefix the translator will use for the MRI.DRC fields we want to retrieve.
We use a sort in our report on the mri.urn of the patient, which means we will have one HK1 region on our report per patient, and we will suppress the detail section of the report. In a macro called
before the printing of the HK1 region we will open ? to the MRI datafile and get the patient’s address fields and put them in local variables.
MEDITECH has a utility program that you can use to open any prefix to an application data or dictionary file. The arguments are in the source code at the top of the program, so you can use the F4 key (get) and put \Z.link in the lookup box and see them:
The first thing we do is “close and stack” the ? prefix. This will allow us to re-open it back to the Abstracting data file once we have retrieved the address information from MRI.
Then we call the %Z.link program, passing the prefix in quotes (“?”), the application (“MRI”), the data file (“%.MRI.data”) and the database (“MRI.”_(@.db# “1.”)). We build the database name out of the
1th dot piece of the current database concatenated with “MRI.” So if the abstracting database is “ABS.STL” we would pass “MRI.STL”. If you have an Abstracting or MRI database that does not correspond in this way, you will need to adjust the code accordingly.
After we have ? “open to MRI”, we can get the address fields and put them in variables. We also check to see if the patient is expired, so we can set a flag to use in a LC to suppress such patients.
Finally we “close and unstack” the ? prefix, with the command C(?U). Although this is a “close” command, the ? prefix is re-opened to Abstracting when this is executed. The reason is that the “unstack” command “restores the prefix to its previous state.” That means that C(?U) and O(?U) do exactly the same thing. C(?U) has the advantage that it is not blocked by the NPR customer RW syntax checker.
How much faster is the “nofrag” approach to a report using a fragment?
At one MAGIC site, selecting a year’s worth of IN visits, the non-fragment report took 94 seconds to retrieve 5761 records:
A fragment version of the same report, run for the same set of records, takes five times longer:
These example reports have been posted to our MAGIC report library: ABS.PAT.zcus.is.nofrag. ABS.PAT.zcus.is.frag (and MRI.DRC.zcus.is.frag)
Upcoming NPR Training Opportunities:
We are pleased to offer NPR Report Writer training sessions at host sites. Details and a course description are available on our website at http://www.iatric.com/Information/Classes.aspx.
|Greater Baltimore Medical Center Baltimore, MD||Beginner / Intermediate||Jim Fahnestock||September 13-15, 2011||$750|
|Greater Baltimore Medical Center Baltimore, MD||Intermediate / Advanced||Philip Sherry||October 10-12, 2011||$750|
To subscribe for email notifications for new classes, please follow this link:
For more information or to reserve a seat, please contact Karen Roemer at 978-805-3142 or email firstname.lastname@example.org.