Unit 8User Defined Arrays1

Just like sending a value to a variable you can send a value to an array that uses a subscript. For example if you were writing a report in ADM.PAT you might have the following variable:

You can add a subscript to this slash variable to make it an array.

Now this array will store the location for each acct.number. Since there can be many values in an array you need to make sure you use a “/” followed by three or more capital letters.

Use in Place of an IF Statement to Print Specific Values

In this example, we are writing a report in LAB.L.SPEC and printing the field patient’s.status. This
prints values such as ADM IN, DIS IN, DEP ER, etc. On the report, it is requested to print the letter I for any inpatient status, the letter E for any emergency status, and O for any out patient status.

An IF statement is possible such as:

IF{@patient's.status^STA="ADM IN" "I";
STA="DIS IN" "I";
STA="PRE IN" "I";
STA="SCH IN" "I";
STA="DEP ER" "E";
STA="PRE ER" "E";
STA="REG ER" "E";
STA="SCH ER" "E";
"O"}

A more EFFICIENT way to print this information will be to create a temporary array.

Step1:

Call a macro from AL START

Use in Place of an IF Statement to Print Specific Values (con’t)

Step 2:

Populate the array in the macro, sending the value that you expect to output for each the value of each status

This macro will populate the /STATUS temp array with the value of either “I” or “E”. It is assumed that any status NOT included in this macro is an outpatient status.

Step 3:

Create a computed field to output the value

The IF statement will first check for a value in the /STATUS temp array for an entry for the patient’s status. If that exists, the value is printed, ELSE the value of “O” prints.
Hard Coding a List in Selection

In this example we are writing a report in PHA.RX and hard coding a list of medications to select on. The report uses the detail segment of main.

Step1:

Call a macro from AL START

Hard Coding a List in Selection (con’t)

Step2:

Populate the array in the macro by sending 1 to the array/subscript

1^/LIST["INSHR"],

1^/LIST["WARF2T"],

1^/LIST["VANC500V"]

Hard Coding a List in Selection (con’t)

Step 3:

Select on the field using the LI operator and your array as the value.

Workshop - Part D

Access the report you created this morning.

Assignment

  1. Add a macro called from the AL START footnote.
  2. In the macro populate an array with the following order locations.
  • “NURHOME”
  • “LAB”
  • “ER”
  • “TELE”
  • “CICU”
  • “CCU”
  • “OLAB”
  1. Hard code this array into selection

Challenge: Add an additional array to your macro called from AL START. Populate the array with the following specific values based on the primary insurance for the patient. If the patient insurance is not included in this list, then print 99. The patient’s primary insurance mnemonic is currently printed in the computed field xx.ins1 on the report picture.

SP = 00
MCBR = 01
MCR = 01
HARVARD = 02
HARV BH = 02
EMP = 03
CIGNA = 04
BC = 05
BS = 05
AETNA = 06
AARP = 07

MEDITECH

Level Two - NPR Report Writer Workshop