Tired of Creating the Same Report… over and over again?

It is that time again… time for Techie Tuesday! And Tuesday would not be complete without some new NPR tips and tricks!!! For the NPR Report Writers out there, have you ever created a report that one department loves and then you discover that another department wants something very similar but yet completely different? Many times this can result in creating the same report repeatedly but with some differences to meet the needs of the different users and departments. Today we will provide some tips on how you can create one report that can work for the many!

To demonstrate how you can add additional flexibility to a report, we will show you how you can create a single report that allows the user to change the sort and specify the desired sections to print. Let’s start by looking at a report that allows users to select from a list of available fields to sort by. The report will print all patients currently in-house sorted either by:

  • Patient Status
  • Location
  • Financial Class

In order to accomplish this, we will utilize computed fields. What are computed fields? The NPR Report writer provides the capability of adding your own custom fields where you can use Magic syntax to apply logic to any report. There are a few rules to remember though when taking advantage of calculated fields:

  • The field name must be prefixed with a lowercase xx
  • The only punctuation allowed is a period (no spaces). Numerics are allowed as well.
  • You must define the following attributes for calculated fields: DAT (data type), LEN (length of the field), VAL (value of the field)
  • The logic defined for the VAL attribute cannot exceed 255 translatable characters

Now that we have covered a few basics, let us really get started! We will start by creating a report that pulls all in-house patients. To do this we will take advantage of the room.bed.index, which is used to find all inpatients currently in the hospital.

Flexible Sorting

Step 1: Create a report where the detail segment is set to main and the index is set to room.bed.index.


Step 2: We will add a computed field called xx.sort to the Sort Field section. The goal of the computed field is to return the value to sort by based on what the user selects as the desired sort field when prompted upon running the report.


Step 3: We will add a computed field to the Select Field/Prompt section called xx.sort.choice; this field is used to prompt the user for the desired sort field and store the result.


Step 4: Next add the xx.sort and xx.sort.choice computed fields to the list of Field Names. Additionally, add the xx.sort field to the picture of the report along with the other desired fields to display.


After adding the computed fields to the field list, you must set the required attributes for each:

  • xx.sort.choice: For this one we can simply set the VAL attribute to the value that is returned when the user selects the desired sort field from the prompt screen.


  • xx.sort: This computed field should return the appropriate value from the patient file based on which sort field the user selects when prompted. For example, if the user selects to sort by location, then the computed field should return the location field from the patient file.


Step 5: Wouldn’t it be great to provide the user with a lookup of choices that the report can be sorted by upon running the report? Users can accomplish this by taking advantage of the Edit Elements feature that is available for each report. Using this feature, we can defined additional attributes for any field that is displayed on the prompt screen. To access this feature, select the Edit Elements option from the starting page of the report.


Select to edit the attributes of the c.xx.sort.choice field and add the following attributes:

  • CH – set this to a comma delimited list of choices that should be presented in the lookup
  • DAT – set this to CHOICE
  • LEN – specify a maximum length
  • REQ – set this attribute to 1 to indicate that the user must specify the desired field to sort the report by before running the report


Upon execution of the report, users will now be prompted with a question asking how the user would like to sort the information displayed on the report. Press F9 to access a lookup of available choices:


Flexible Display of Information

Let’s take it one step further!! Now let us allow the user to identify whether the patient details should print, totals by the selected sort field should print, or both. Again, we will utilize computed fields for this functionality. We will also utilize the LC line attribute in order to determine whether a line should print or not.

Now you might ask yourself what is the LC attribute? The LC attribute allows you to execute a line check. Depending on whether the value returns true or false determines whether the line where the attribute resides should print. The syntax to use when applying a line check attribute is LC=magic expression. Below are a few examples:

  • LC=@age>17
  • LC=@insurance=”MCA”!(@insurance=”MBC”)

There are a few things to consider when using the LC attribute:

  • LC is used to conditionally print a line based on an expression. If the expression is true, then the line will print. If false, then the line will be suppressed when printed.
  • Data fields in the expression must begin with the @ sign
  • Computed fields are not recognized within line checks
  • If the expression will not fit on one line, then you can continue to the next line but the line must begin with ‘LC=’. The length of the expression cannot exceed 255 translated characters.
  • Computed fields on a line will not be computed if the line check evaluates to false

Additionally, LCR, which stands for line check range, is available. LCR is used to conditionally print a range of lines based on any expression. If the expression is true, then the lines will print. If false, then the lines will be suppressed when printed.

  • Use LCR=END to end the line check range
  • Nested line checks are not allowed
  • A line check range can span regions (start on HK1 and end on D)
  • The line which ends the line check is included in the range

Let us now continue with the report that we started earlier and enhance it further to prompt the user for whether the report should display details only, display totals only, or display both.

Step 1: Add two computed fields to the Select Field/Prompt section called xx.show.detail and xx.show.totals. One of the computed fields will prompt the user for whether the detail section should print and one will prompt the user for whether the totals should print.


Step 2: Modify the report picture to include lines in the TK2 region for totals as well as a new page header for the totals.


Step 3: Add the two computed fields (xx.show.details) and (xx.show.totals) to the Field list and set the attributes for each. Since both of these will be used for prompting the user and storing the response, set the VAL attribute to the value returned from the prompt.



Step 4: Now it is time to add the LC attribute to the report picture to define when a line should print or not print. If the user answers yes to the xx.show.detail prompt then the detail lines should print. If the user answers yes to the xx.show.totals prompt then the total lines should print.



And that’s all there is to it!! We just created one report that is flexible enough to allow the user to select how the report needs to be sorted as well as allow the user to identify whether it should display patient details only, totals only, or both. By utilizing the many available attributes and by taking advantage of computed fields, you can make reports extremely flexible so that one report can meet the needs of the many users. Imagine… no more creating the same report multiple times!!!

I hope you have enjoyed this blog and please stay tuned to the IPeople blogs for more techie tricks and tips to get your flying through your work.

Jenny Blue

Jenny Blue

CEO at IPeople
Jenny Blue is co-founder and CEO of Interface People, LP and Consultant People, LP, which operate in a total of 48 US States, England, Ireland, Canada, and South Africa. In her role, Mrs. Blue provides leadership and vision to the company with the ultimate goal of improving patient care through technology. With over 16 years of experience in the programming and healthcare industries, her strong background provides solid direction to all departments, and sets the pace for outstanding innovation as IPeople continues to address the growing challenges and objectives in healthcare.
Jenny Blue

Latest posts by Jenny Blue (see all)

Be First to Comment

Leave a Reply

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