APPENDIX II

Expressions

Our challenge is to find a way to allow users to define and build complex expressions out of flexible building blocks of compiled code. Once a user defines an expression, it will be stored in two formats. One format would be fairly textual and descriptive, but still show parenthesis for grouping, and all operators with their standard symbols. A second format would be much more cryptic, and would be designed for rapid and efficient evaluation by an expression evaluator which we would have to write.

One approach that we will be exploring regarding how best to write an expression evaluator uses the following logic. If the expression evaluator has to parse out the logic embedded in the textual description each time it evaluates, it will be very inefficient. We would want to pass it a string of PseudoCode which would allow it to run much more efficiently, and also which might be suitable for compiling. Operators and operand types would all be assigned Tokens, which would be interspersed with codes and constants.

OperatorsAssigned Token
Algebraic:(+)00
(-)01
(*)02
(/)03
Relational:(=)10
(>)11
(>=)12
(<)13
(<=)14
(!=)15
Bitwise:(not)20
(and)21
(or)22
Stack:Push30
Pop31
OperandsAssigned Token
ConstantsNumeric40
Date41
Logical42
String43
System Function44
Data Field45
Expression46
Expression Parameter47

Lets take the following example.

Five days after a referral to a specialist for Physical Therapy we want to confirm that we have received a report from the therapist.

One approach would be to write a routine which scans the table that stores referral information to see if a response has been received and recorded, on all referrals more than five days old. This routine would work only for this one expression.

A second approach would be to create a routine that returns the date of a referral (for our example let's assume this is a field in a table that we have defined in a data dictionary with a unique identifier #001627), and another routine to indicate whether a report for the referral has been received ( another table field defined in a data dictionary under #001629). If the user wants to get a list of all referrals, he could create a new expression that relates these other two expressions in the following manner:

(Current Date - Referral Date) > 5 ) AND (NOT Referral Received )

The current date would be a system function, let's say in our list of system functions it is assigned the identifier # 00005. So using the tokens listed above we might be able to store something much more cryptic, but much faster for the computer to evaluate.
44System Function
00005Current Date system function
01Subtraction Operator
45Data Field Evaluator
001627ID of data dictionary entry with type and full field information
11> Operator
40Numeric Constant
5Value of Numeric Constant
21AND Operator
20NOT Operator
45Data Field Evaluator
001629ID of report received field.

By storing a sequence such as "44|00005|01|45|001627|11|40|5|21|20|45|001629|" we have something that an expression evaluator could decode and evaluate repetitively, at a much higher rate of speed then if it had to parse the textual string. This example is probably overly simplified. We would also have to deal with parsing parenthesis, and stack considerations. But through the use of tokens such as these we should be able to greatly increase the efficiency of processing events that users are able to define. Such rapid expression evaluation may be needed when we are receiving messages from live active applications which need rapid comparison with a large list of triggers in order to determine if the data that they contain constitutes a triggering event.

In situations where we will be scanning data in SQL databases in a passive or background mode, a more viable and efficient option may be to create an embedded SQL expression which the system can use to find all matching records, or provide help lists and hints which will allow the user to see and edit an SQL expression directly. Another option that we will be exploring is the creation of embedded SQL statements based on variables and constants that a user selects.




Home ck_MedRules ck_CompCare ck_Medical Grants The Company Employment Request Info Links

Copyright 1997 CK Software, Inc., 210 N. Higgins, Suite 334, Missoula, MT 59802
Phone: (406) 721-2606 Fax: 721-4225