Blogs Home
Monday, April 23, 2012 12:52 PM

Save Valuable White Space on Your Reports (MAGIC, Client/Server or Report Designer)

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

When you use sort headers on an NPR or Report Designer report, you can print the sort values on a line above the detail items like so:

 

NPR Tip 1 image

Sometimes users object to the “stair step” look of this layout, and they want the key header information to print on the same line as the first detail record.

Rather than this (stair step output).........................They want this (key prints beside first record).

NPR Tip 2 imageNPR Tip 3 image

You could use some flags that are set in the HK region and cleared after the first detail record is printed to create fields that print one time only as the sort changes. There is an easier method which just sets up a set of computed fields that watch for a sort change as the report prints.

When your report translates, the translator tells you the sort fields of each sort key. You can make a set of computed fields that watch for a change in the sort value so that they will print once at the beginning of each set of records (in our example, each set of patients for a given attending doctor).

NPR Tip 4 image

As the report prints records, the value of the local variable attend.doctor (translates to ggg) will change from the first doctor, to the second, etc. If we create a set of header fields that watch for the value of the local variable attend.doctor to change, and print only as the value changes, we can have smart headers that print beside our first detail record in the section, but do not repeat down the page.

In the example, we have a computed field for the attending doctor mnemonic, and another computed field to the right which prints the attending doctor name.

In the left hand (mnemonic) field we check to see if the attending doctor sort value has changed by comparing to our own stored value in the variable “LAST”. In the right hand (name) field we do the same check, and also store the value of the current attend.doctor sort field in our variable LAST.

NPR Tip 5 image

NPR Tip 6 image

You might wonder why the field @MIS.DOC.DICT.name manages to print the name of the attending doctor. This is because the sort field attend.doctor translates to the same local variable which is the subscript of the records in MIS.DOC.DICT. In fact, just about every time you sort on a field that is a dictionary mnemonic, the sort subscript is identical to the subscript of the dictionary DPM and you can just use fields from the dictionary and they will work.

PS: You might not be used to using fields in a report without the “@” sign. The difference between using a field with the @ sign or without the @sign can either make no difference, or make a huge difference in the behavior of your report. This is how things work:

Some fields in the data definition are not stored data, but are subscripts. An example from ADM is the field @urn. Regardless of whether you use @urn or urn, the field translates to exactly the same thing: aa.

Other field are stored data, so if you use the “@” sign, you get a prefix/global/subscript combination like so:

@attend.doctor: *AA[aa]DR|1 (magic) or $(A)AA[aa]DR|1 (client server)

If you use the field without the @ sign: attend.doctor, you get ggg for either platform.

Final Tip:
If you are ever trying to figure out how a field translates and don’t want to slog thru the Data Definition or peer at your object code listed to Preview, you can stick the field in a macro and translate. For example to see the difference between @attend.doctor and attend.doctor, I can write a macro like this:

(I include strings in quotes so I will see them in the object code to make things clearer):

NPR Tip 7 image

The translator shows me what I will get with each field:

NPR Tip 8 image

Report Designer

The report designer approach is to create two computed fields and use a rule to set the value of the fields to the attending doctor mnemonic or name as the value of the sort changes.

Start on the Field page of Process Reports and create two computed fields, one for the attending provider mnemonic and one for the name. Both computed fields will need a rule associated to the Value Attribute.

NPR Tip 9 image

NPR Tip 10 image

On each of the two rules, created for the computed fields, add an External variable (same variable needs to be used in both rules) and a local variable on the main page of the Rule Dictionary. The default V0 external variable for RegAcct.OID is passed to the rule from the report.

NPR Tip 11 image

On the Fields page of the Rule Dictionary, for the mnemonic rule, add the RegAcct.AttendingProvider field. The V0 value will default in for the RegAcct.OID key.

NPR Tip 12 image

On the Rule page use the following steps to create the rule below.

Enter Line > Do/If /Then > If > Field > RegAcct.AttendingProvider(V0) > Operator > Is not equal to > Variable > e_att > End Line
Then > Expressions > Compute > Expression > Field > RegAcct.AttendingProvider(V0) > Save As > out > End Line > End If
Enter Line > Expression > Set Program Result > out

 

NPR Tip 13 image

On the next rule, for Attending Provider Name, add MisPerson.Name field and use the e_att attribute as the value for the MisPerson.OID key.
RegAcct.AttendingProvider will default in a value of V0 for the RegAcct.OID.

NPR Tip 14 image

On the Rule page use the following steps to create the rule below.

Enter Line > Do/If /Then > If > Field > RegAcct.AttendingProvider(V0) > Operator > Is not equal to > Variable > e_att > End Line
Then > Expressions > Compute > Expression > Field > RegAcct.AttendingProvider(V0) > Save As > out > End Line
Statement > Expressions > Compute > Expression > Field > MisPerson.Name(e_att) > Save As > out > End Line > End If 

Enter Line > Expression > Set Program Result > out

 

NPR Tip 15 image

After created the computed fields and rules go to Sorts page, of the Process Reports routine, add the sort field RegAcct.AttendingProvider and move it up to the first sort key position.

NPR Tip 16 image

In the Detail Region on the Layout Page add the 2 computed fields, the mnemonic field first and then the name field.

NPR Tip 17 image

NPR Tip 18 image