Calculated Fields

Calculated fields are virtual fields available for display on a (worklist) table, for use in filters and for use on XML templates including reports. The values are the result of operations performed on one or more actual database fields. For example, the turnaround time for a study can be calculated as the difference between the report date and the study date, and then used to set up a notification when it exceeds some defined period of time. Creating calculated fields requires administrator permissions.

To create a calculated field:

  1. Click the Admin/Server Settings tab
  2. Select System
  3. Click the Configure link in the Customize Labels section
  4. Select the table containing the information to use in the new field
  5. Click the New Calculated Field button at the bottom of the table
  6. Define the label and the expression.
  7. Use the Add Tag button to select the COLID of the field
    1. Only fields listed in the Add Tag list are available for the selected table
  8. Click Save

The system verifies the expression for correctness. If it is valid, a COLID is assigned and the field is stored on the server.  Field labels are regular language text strings used to identify the field in the selection list or in the worklist column header. Expressions consist of COLIDs, constants and methods tied together through operators.

For a detailed description of these components, see: Calculated Fields Rules

 To edit an existing calculated field:

  1. Follow directions 1-3 as described above
  2. Find the entry in the calculated field table at the bottom of the respective page
  3. Edit the string in the text field
  4. Click Save to have the syntax verified and the changes stored

To delete an existing calculated field:

  1. Follow directions 1-3 as described above
  2. Find the entry in the calculated field table at the bottom of the respective page
  3. click the delete button

Manual editing will need to be applied to all worklist filters, XML templates, validators and other places where this COLID existed. There is a limit of 100 calculated fields per database table. When a calculated value is a time interval, such as the turnaround time defined in the example above, the resulting value’s format is defined by the Time Interval Format defined in the Date Format section of the Settings page. To change the default format, select the option from the pull-down list and click the Format button.

Note: Calculated fields do not propagate between eRAD PACS servers. Calculated worklist fields are not available for all database tables. If the Calculate Fields button does not appear as described above, the tool is unavailable for the information on that table. At this time, the study and object database tables used by the PACS Worklist page are not available for use with this feature.

Calculated Fields Rules

Variables

 

A variable is a specific field within a referenced order or study. They are represented by column IDs, COLID. The list of COLIDs are displayed on the Customize Labels pages and in the Calculated Fields User Manual.

 

Variables types

 

Each Variable has a type depending on the information the field conveys. Some macros and operators work only if the arguments are of the required type. The table below lists the supported variable types.

 

Expression

Description

Boolean

A binary value in the form "yes" or "no" used by the boolean macros.

DateTime

All fields that contain a Date, Time or Date+Time value.

Interval

Expresses an interval of time between DateTime values. The display format of this type variable is defined in the Date Format section of the Settings page.

Number

Binary integer or floating point number fields.

String

All alphanumeric strings.

 

Constants

 

Constants are literal values entered in the calculated field rule. Their format is defined as follows:

 

Expression

Description

DateTime

Date and time expressed in the format YYYYMMDD_HHMMSS. To express time only, the format is 00000000_HHMMSS. Date-only constants are formatted YYYYMMDD_000000

Interval

Interval constants, expressed in seconds, using the format <number>S. For example, 1200S for 1,200 seconds. Used to add time to DateTime variables.

Number

Integer constants expressed as a string of numbers. Negative values must be expressed as an operation. For example, for -5, use 0-5.

State

Study state constants, expressed as the state label, without any quotes. For example, Ordered, Unviewed, and Final.

String

String constants wrapped on either end with double quotes.

 

Macros and Operations

 

Arithmetic macros and operations

 

Expression

Description

add(a,b[,c...])

Add the operands. If the Type of all operands is Number or Interval, the result is an arithmetic sum of the values. If the Type of all operands is String, the result is the concatenation of the strings. If the operands are a DateTime and one or more Interval variables, the Interval variables are added to the DateTime variables and the result is a DateTime variable. All other combinations of variable types is unsupported and returns NULL.

div(a,b)

Divide the operands. If the Type of all operands is Number of Interval, the result is the arithmetic dividend a/b. All other combinations of variable types is unsupported and returns NULL. Division by zero constants is checked, but zero-value variables may fail and product undefined results.

mul(a,b[,c...])

Multiple the operands. If the Type of all operands is Number or Interval, the result is the arithmetic product of the values. All other combinations of variable types is unsupported and returns NULL.

sub(a,b)

Subtract the operands. If the Type of all operands is Number, Interval or DateTime, the result is the arithmetic difference a-b. If operand a's Type is DateTime and b's Type is Interval, the result is a DateTime variable a-b. All other combinations of variable types is unsupported and returns NULL.

+

Same as add() with a limit of two operands, in the format a+b.

-

Same as sub() using the format a-b.

*

Same as mul(), with a limit of two operands, in the format a*b.

/

Same as div() using the format a/b.

 

Boolean macros and operations

 

Expression

Description

and (x,y)

The result is “yes” if Boolean expression x and y are both “yes”. If either Boolean expression is “no", the result is “no”.

not(x)

The result is “yes” if the Boolean expression x is “no”. Otherwise, the result is “yes”.

or(x,y)

The result is “yes” if Boolean expression x or y is “yes”. If neither Boolean expression is “yes”, the result is “no”.

xor(x,y)

The result is “yes” if either Boolean expression x or y is “yes”. If both Boolean expressions are “no” or if both are “yes”, the result is “no”.

&

Same as and(), in the format x&y.

|

Same as or(), in the format x|y.

^

Same as xor(), in the format x^y.

 

Calendar macros and operations

 

Expression Description
createdate(y,m,d[,h[,min[,s]]]) Returns a datetime value constructed from the numbers specifying the year (y), month (m) and day (d). Includes the hour (h), minutes (min) and seconds (s), if specified. Otherwise, hours, minutes and seconds are returned as 000000. If any value exceeds the applicable values, such as a day=32, the operation will fail and return an empty string.
day(dt) Returns the day part of datetime, dt, as a number 0 through 31.
hour(dt) Returns the hour part of the datetime, dt, as a number 0 through 23.
minute(dt) Returns the minute part of the datetime, dt, as a number 0 through 59.
month(dt) Returns the month part of datetime, dt, as a number 0 through 12.
sec(dt) Returns the seconds part of datetime, dt, as a number 0 through 59.
year(dt) Return the month part of datetime, dt, as a number.

 

 

Conditional macros and operations

 

Expression

Description

equals(x,y)

The result is ‘yes’ if the two values are the same. Otherwise, the result is ‘no’. Both x and y must be the same type: string, number or interval.

greater(x,y)

The result is ‘yes’ if x is greater than y. Otherwise, the result is ‘no’. Both x and y must be the same type: number or interval.

if(test,x,y)

Returns x if the Boolean expression test evaluates to true. Otherwise, the result is y.

less(x,y)

The result is ‘yes’ if x is less than y. Otherwise, the result is ‘no’. Both x and y must be the same type: number or interval.

=

Same as equals(), in the format x=y.

>

Same as greater(), in the format x>y

<

Same as less(), in the format x<y

 

Date macros and operations

 

Expression

Description

age(d1,d2)

Returns the difference d1-d2 in calendar years.

atleaststatemintime(s)

Returns the earliest date and time the order or study existed in state s or any later state. The result is in DateTime format. Available for the Study Information and Scheduler Order tables only.

atmoststatemaxtime(s)

Returns the most recent date and time the order or study was in state s or any earlier state. The result is in DateTime format. Available for the Study Information and Scheduler Order tables only.

curdatetime()

Returns the current date and time in DateTime format.

minstatetime(s)

Returns the earliest date and time the order or study existed in state, s. The result is in DateTime format.

maxstatetime(s)

Returns the most recent date and time the order or study existed in state, s. The result is in DateTime format.

 

 

Multi-value macros and operations

 

Expression

Description

avg(id)

Returns the mathematical average of the values in the multi-valued field, id, such as an object-level field in the study table. Number and Interval Type variables only.

count(id)

Returns the number of entries in the multi-valued field, id, such as an object-level field in the study table.

countif(id,s)

Returns the number of entries in the multi-valued field, id, whose value is s. Number, Interval and String Type variables only. The result is in Number format.

hasvalue(id)

Checks the specified field value for NULL or an empty string. Returns “no” if no value is present. Otherwise, it returns “yes”.

max(id)

Returns the greatest value in the multi-valued field, id, such as an object-level field in the study table. The comparison is numeric for Number and Interval Types, lexicographic for String and DateTime Types.

min(id)

Returns the lowest value in the multi-valued field, id, such as an object-level field in the study table. The comparison is numeric for Number and Interval Types, lexicographic for String and DateTime Types.

sum(id)

Returns the mathematical sum of the values in the multi-valued field, id, such as an object-level field in the study-table. Number and Interval Type variables only.



String macros and operations

Expression Description

concat(s1,s2[,s3...])

Concatenates the values s1 and s2 (and s3, etc.) NULL values are treated as an empty string, "".

indexof(s,p)

Returns the starting position of pattern p in string s. The first position in string s is 0. Returns -1 if p is not found in s. Returns NULL if s or p is NULL. Matching is case-sensitive.

strlen(s)

Returns the number of characters in string s.

substr(s,from[,len])

Returns the len characters in string s, starting at position from. The first position is '0'. If from extends past the end of the string, an empty string is returned. If len is omitted, the remaining string is returned.

 

Type conversion macros and operations

Expression Description
floor(n) Returns the truncated integer part of the number, n.
interval(n) Convert the number, n, to an interval.
number(s) If the argument s is a string, convert the first non-numeric or decimal characters to a floating point number. If s is an interval, convert it to a number representing the number of seconds in the interval.
string(n) Convert the number, n, to a string.