Unit 12 - Creating Computed Fields 1

Computed Fields:

Each standard field is defined within the data definition and is comprised of field attributes that define the length, justification, data type and value of the field. Computed fields allow you to create your own data fields by defining these attributes.

What makes the computed field a powerful reporting tool is the fact that its value can be defined using programming expressions, operators, control structures, and program calls which can be used when creating a computed field.

Creating a computed field

Access the field section of the report and create a computed field by defining a fieldname, which is prefaced with xx.

Once you define the field name, the <Enter> key will invoke the field attribute editor.

To define a computed field, access the Picture tab and place the cursor on an empty line in the Fields section and type the name of the field as: xx.field.name. The xx. is required syntax which is recognized by the Report Writer as the prefix for a computed field. The field.name is the user-defined name of the field.

Required Field Attributes

w  All computed field attributes are user defined

w  Field Attributes have the form: ATT=value

w  The following attributes are required:

•  DAT= Data Type (format) of output

•  LEN= Length of output

•  VAL= Value of output

The above attributes are required, and must have a value in order to exit the field attribute editor

Note: Use the arrow keys to move around within this editor. The <Enter> key will cause blank lines to be inserted between the attributes. These blank lines must be removed in order to exit the field attribute editor.

The Data Type attribute

The DAT attribute defines the data type of the field. MEDITECH has defined many data types for use within the NPR applications. If the computed field output value consists of a standard data field, it is recommended to use the data type of the standard field (which can be found on the data definition listing).

w  A <Lookup> at the DAT attribute prompt will provide a lookup of data types

w  The data type will format the output of the VAL attribute.

Some common data types are:

FREE - for all text output DEC2 - decimal to two places

INT or PINT - for integer values MONEY - Money values

DATE - for date values HHMM - for time values

CODE.128 – code 128 barcodes BAR.CODE - Code 39 barcode

The Length Attribute

The LEN attribute defines the length of your output. Again, we suggest using the length associated with a standard field if this field is the output value.

The length will display as the amount of characters which the field marker occupies on the picture.

The VAL Attribute

The VAL attribute generates the output value of a computed field.

w  The VAL attribute allows you to use operators and control structures to create an

expression which manipulates standard data field values.

w  The VAL attribute can encompass more than one line within the attribute editor.

w  Each line must begin with VAL=

w  There is a 255 translatable character limit in the VAL statement of the computed field.

The VAL attribute is where you enter the actual output value of the computed field. You can use many programming operators, control structures and programs.

Note: VAL attributes may encompass more than one line within the field attribute editor. Each line of the value must begin with the VAL= attribute and will translate into one line of object code.

Referencing Values

You can reference a Data Field, Literal, Constant Values, and expressions in a computed field.

Data Field

The @ symbol is used as a prefix to reference the value of a data field within a computed field VAL attribute. A <Lookup> is available while the cursor is at the VAL=.

1.   The <Lookup> keystroke will display a data field lookup box.

2.   A partial field name can be entered if you know the name of the field you are looking for or you can leave this box blank. Hit <Lookup> to get a list of standard data fields.

3.   The lookup will provide a complete alphabetic listing of standard data fields within the report’s DPM and requires you to be familiar with the data definition to determine which fields can actually be accessed within the report. The detail segment and index file subscripts determine which fields are in the path of the report. There are methods of accessing fields outside of the path which is why all fields are listed and not just the fields fully accessible to the report.


Once a field is chosen from the lookup, the field will be placed at the cursor position within the VAL attribute. The @ symbol will be automatically added if a field is chosen from the lookup. If you choose to type the fields without using the lookup, you must remember to prefix the field name with the @ symbol.

Literal Values

To reference a literal, enter the string within a set of quotes.

Numeric Constants

Numeric constants do not require quotation marks though they can be used for

constants if you choose.

Note: The constant value 133.51 is equivalent to the literal value "133.51".

Expressions

Expressions can be a combination of Standard field name, constants, and variable.

An expression can use numeric operators and would be contained in parentheses.

Additional attributes

There are additional non-required attributes, which you can use within a computed field.

JFY

The JFY attribute can change the default justification of a field. The default is determined by the data type. Numeric data types are right justified and alpha data types are left justified. The justification of any field can be changed as desired. The justifications are L, R and C (for center). Center will center the value within the length of the field.

DEC

The DEC attribute defines the number of decimal places of the output. This attribute will round the value to a number of decimal places. Some data types have a default number of decimal places which can be overridden by this value. This attribute accepts an integer value.

COMMA

The COMMA attribute is used with data fields which return a numeric value (have a numeric data type). This attribute accepts a Y response and will print the output with commas delimiting the thousands places. Example: The number 5210 will print as 5,210 if COMMA=Y is used.

SIZE

The SIZE attribute will increase/decrease the font size. This attribute accepts S, L, V, X to produce small, large, very large and extra large. A numeric value is also a valid response for this attribute. If a numeric value is used, this value is divided into the report CPI to produce the font size of the field. Example: SIZE=3 would produce 4 characters per inch if the report CPI was 12.

FONT

The FONT attribute allows you to define b(old), i(talic) or r(everse) video.

Workshop - Part E:

·  Steps to be performed within the report:

1.  Create a computed field xx.location.

2.  Define the three required attributes to print free text “Location:”.

3.  Remove the current field id for location and replace with the computed field from step 1.

4.  Add an attribute to print the field in bold and underline.

5.  File and translate the report.

MEDITECH

Level One - NPR Report Writer Workshop