WRITING ARDEN SYNTAX MEDICAL LOGIC MODULES GEORGE HRIPCSAK Center for Medical Informatics, Columbia-PresbyterianMedical Center, 161 Fort Washington Avenue, AP-1310, New York, NY 10032, U.S.A. (Received 3 June 1994; received for publication 21 July 1994)
Abstract-The Arden Syntax for Medical Logic Modules is a language for encoding medical knowledge bases that consist of independent modules. The Arden Syntax has been used to generate clinical alerts, diagnostic interpretations, management messages, and screening for research studies and quality assurance. An Arden Syntax knowledge base consists of rules called Medical Logic Modules (MLMs), which are stored as simple ASCII files that can be written on any text editor. An MLM is made of slots grouped into three categories: maintenance information, library information, and the actual medical knowledge. Most MLMs are triggered by clinical events, evaluate medical criteria, and, if appropriate, perform an action such as sending a message to a health care provider. This paper provides a detailed tutorial on how to write MLMs. Arden Syntax Standards
Medical logic modules Automated decision-support
MLM Knowledge representation Expert systems
1. INTRODUCTION The Arden
Syntax for medical logic modules (MLMs) is a language for representing medical knowledge. It was born out of a desire to share knowledge across institutions (medical centers, hospitals, office practices, health departments, etc.). The original draft standard was prepared in 1989 for a retreat held at the Arden Homestead in Harriman, New York [l]; the goal of the retreat was to investigate and encourage knowledge base sharing. The Arden Syntax was later adopted by the ASTM, a consensus standards organization, and the official standard was published in 1992 [2]. While the official standard has been available for some time, it is a technical specification document that does not serve novice users well. This paper is a tutorial for the novice user. It is organized to bring the user through the syntax in a logical manner with many examples. This tutorial does not replace the standard, but should be used in conjunction with it. Details that have been left out of this tutorial due to space are contained in the standard. A third document, which describes the rationale behind the Arden Syntax [3], will be helpful to Arden Syntax users. It explains in detail why the standard was created and how it got to look as it does today. It specifically addresses the issues of sharing MLMs, and it covers the advantages and disadvantages of using the Arden Syntax. Knowledge of a computer programming language like Pascal will also be helpful. If the reader has little experience with computers, then an introductory text on Pascal or BASIC is recommended. 2. OVERALL
APPROACH
An Arden Syntax knowledge base consists of a set of rules called Medial Logic Modules (MLMs), each of which contains sufficient logic for a single medical decision. Most MLMs produce narrative or coded messages that are relayed to the appropriate health-care provider. MLMs have been used for many purposes. An alert is a message 331
G. HRIPCSAK
332
that warns a provider of some clinically important situation, such as a medication interaction or a dangerous laboratory result. An interpretation is a non-emergent message intended to supply the provider with supportive information, such as an interpretation of liver function tests. It includes diagnosis support. A screen is a message sent to a clinical researcher or a quality assurance officer that indicates that a patient fulfills a set of criteria, either for a clinical trial, or for some quality assurance concern. Management messages are used for institutional administration, such as managing bed assignments, carrying out regulations, and automating ancillary department procedures. Sets of MLMs have been used to implement practice guidelines and care plans. Functionally, an MLM consists of four major components: evoking event, logic, action, and data mapping. Most MLMs are evoked (triggered) by some clinically relevant event, such as the admission of a patient or the storage of medical data. Thus, the evoking event sets the context in which the MLM is pertinent. When an MLM is evoked, the logic portion is evaluated. It generally consists of medical criteria and algorithms. The result of the evaluation is to conclude true or false. If true, the action is executed. Storing a message in the patient record and sending electronic mail to the health-care provider are typical actions. To define the evoking event, logic, and action, an MLM must use data mappings to convert from institution-specific entities (database entries, electronic mail addresses, etc.) to terms actually used in the MLM. The four functional components are defined in the MLM, along with many others related to maintenance and outside knowledge sources. 3.
A SIMPLE
MLM
EXAMPLE
Before embarking upon the details of the Arden Syntax, it is illustrative to look at a simple MLM that includes only the common, required elements. The MLM in Fig. 1 is typical. Its goal is to alert health-care providers of new or worsening anemia, as indicated by a blood test called the hematocrit. Whenever a hematocrit is recorded, it is compared to a threshold and to a previous value. If the hematocrit fulfils certain criteria indicative of anemia, a message is sent to the provider. As seen in Fig. 1 the MLM consists of a set of slots organized into three categories: maintenance, library, and knowledge. The first slot of the maintenance category is the title, which is a brief description of what the MLM does. The filename serves as a unique identifier that one can use to specify the MLM. The version keeps track of updates to MLMs. The institution specifies where an MLM was written, and the author is the person(s) who wrote it. The specialist slot (empty here) is reserved for future approvals of this MLM for clinical use. The date the MLM was last updated is shown. The validation level indicates that this MLM is only used for testing at present. The library category follows. The purpose slot describes what this MLM is used for. The explanation slot describes how the MLM works. The keywords slot supplies terms that can be used to search through a knowledge base of MLMs. The knowledge category contains the functional components of the MLM. The Arden Syntax type slot always says data-driven at present. The data slot maps terms used locally in the MLM to entities in the patient database. In this example, blood_count storage* is defined as an event in which a complete blood count test is stored. Hematocrz is defined as the last blood hematocrit result in the patient database, and previous hct is defined as the one before it. The evoke slot specifies that this MLM is triggered when a blood_count_storage event occurs. The logic slot contains a set of criteria. This MLM first checks to see whether the hematocrit result is a number. If it is not a number (e.g. “clotted”), then an error occurred when the blood test was performed, and the MLM terminates without sending a message (conclude false). If it is a number, then the MLM checks whether the current hematocrit is 5 units less than the previous one, or less than 30 units in total. If so, the MLM concludes true, which means that the action *The
monospaced
bold font of blood_count_storage
actually occurs within an MLM.
is used throughout
this paper
to indicate
text that
Writing Arden Syntax MLMs
333
maintenance: title: Alert on low hematocrit;; filename: low_heamtocrit;; veraion: 1.00;; institution: CPMC;; author: George Hriposak, M.D. (hripcsalcucis.columbia.edu):: specialist: :; date: 1993-10-31;; validation: testing:: library: purpose: Warn provider of new or worsenmg anema.:; explanation: Whenever a . blood count result is obtained, the . . _ . nematocr;t zs cnecxea to see whether it is below 30 or at least 5 points below the previous value.;: keywords: anemia; hematocrit:; knowledge:
type: data-driven;: data: blood count storage := event T'comaprete blood count'); hematocrit := read last ('hematocrit'j: previous_hct := read last ( ('hematocrit') where it occurred before the time of hematocrft);; evoke: blood_count_storage;; logic: if hematocrit is not n&et then coxlude false: elsaif hesmtoerit <= previous_hct - 5 or hematocrit < 30 then conclude true: endif:: action: write "The patient's hematocrit ("I I hematocrit low or falling rapidly.";:
I I”) is
end: Fig. 1. A simple MLM.
slot is evaluated. In this MLM the write phrase sends a message to the health-care provider, indicating that there is new or worsening anemia. This MLM is simpler than a real MLM would be. For example, one might not want to send an “anemia” alert for a hematocrit that dropped from 52 (above normal) to 47 (normal). Many contingencies must be covered in a real MLM. 4. CATEGORIES
AND
SLOTS
4.1, General rules An MLM is an ASCII file that can be created by using any word processor. comprised of slots grouped into categories as follows:
It is
name > : name > : < slot body > ;; : < slot body > ;; 1..
A sample MLM that has all possible Arden Syntax slots is shown in Fig. 2. It begins with the word maintenance followed immediately by a colon (:). This marks the beginning of the maintenance category, and it is followed by a series of slots. Each slot has a name with a colon (title:), followed by the slot’s value (Screen for hypokalemia with digoxin therapy), and terminated with a double semicolon (;;). MLMs follow several genera1 rules. The allowable characters are printable ASCII (33 to 126), space (32), carriage return (13), linefeed (lo), and horizontal tab (9). The Arden Syntax is not case sensitive (except when quoted within character strings). The double
334
G. HRIPCSAK maintenance: title: Screen for hypokalemia with digoxin therapy:: filename: hypokalemia-and_digorin;; version: 1.06;; institution: Columbia-Presbyterian Medical Center;; author: George Hripcsak, M.D. ([email protected]);; specialist: George Eripcsak, M.D.;; data: 1993-09-17;; validation: production;; library: purpoas: Warn the health oare provider of hypokalemia in the setting of digoxin therapy.;; explanation: Whenever a serum or whole blood potassium value ia stored, it is checked for hypokalemia (less than 3.3). If hypokalemia ia present, then if tha patient has a non-zero aerum digoxin level within the ... ;: keywords: hypokalemia; digoxin; arrhythmia;; citations: 1. International Committee of Medical Journal Editors. Uniform Requiraments for Manuscripts Submitted to Biomedical Journals. NSJM 1991:324:424-S.;; links: CTIM-1.14.5;; knowledge
typm:
:
data-driven;;
d&a: K storage := avent (result, intravaxular potassium); It-:= read last (intravaaoular potaesium) where it occurred within the past 3 days: diaoxin :- read last (intravascular diaoxin level) where it occurrd within 1 week bhore tiniif K;; priority: 50;; evoke : X-storage;; logic: if K < 3.3 and digoxin > 0 then /* send an alert l/ conclude true; endif: action: write "This patient has hypokalemia (" II X 1) "1 in tha settina of diaoxin theraw. This can pbtentiate card& arrhithmias." ::' urgency: 50;; end: Fig.
2. An MLM with all optional
slots.
semicolon (;;) is special because it marks the end of a slot; it cannot appear in the body of a slot. Categories and slots must appear in the order that they are listed here. There are three categories. The maintenance category contains slots for knowledge base maintenance and change control. The library category explanatory information, keywords, and links to other knowledge sources. The knowledge category contains the actual medical logic encoded in the MLM. The phrase end: marks the end of the MLM; syntactically it appears like a category, but is has no slots. 4.2. Maintenance category The maintenance category has the following slots (see Fig. 2). The title is a brief statement of what the MLM does. It is treated as free text (that is, it is not structured in any particular way), and it often contains an institution-specific name. Thefilename is the MLM’s unique identifier. It is composed of a letter; then letters, digits, underscores (J. It can be 1 to 80 characters in length. When one is referring to an MLM, the filename rather than the title is used. Note that an MLM’s “filename” need not be the same as the name of the computer file that the MLM is stored in. For example, more than one MLM can be placed in a single computer file. The oersion contains a revision number that is incremented each time the MLM is changed. It begins with 1.00,and it always has two digits to the right of the decimal point. Minor changes to MLMs should result in an increment of 0.01, and major changes should result in an increment of 1. The imtitution names the origin of the MLM. At present, institutions are represented with free text rather than coded names. The combination of the institution with the
Writing
Arden
Syntax
MLMs
335
filename should make an MLM unique across all institutions. The artthor is the person or persons who wrote the MLM. The format is first name, middle name or initial, and last name, followed by optional suffixes separated by commas. An optional electronic mail address may follow in parentheses. Internet addresses should be used directly; bitnet addresses should be suftixcd by .bitnet. and UUCP addresses should be suftixed by .uucp. If thcrc arc several authors. then their names arc separated by semicolons. The ,spccirrlist is the person who approved the MLM in the institution using the MLM, which may bc different from the institution that authored the MLM. It has the same format as the author slot. It is always blank when an MLM is shared, because each institution must approve MLMs for its own use. The clatc slot shows the date of last change. Most often, it contains a simple date (YYYY-MM-DD), but it can also include time of day according to the IS0 8601 standard [4] (e.g. 1993-OI-3OT33: 12:34.5). The r~ufidation indicates for what the MLM has been approved in the institution. There are now four valid entries: production--approved for clinical care research-approved for clinical research testing-only for debugging, sharing expired-no longer in use 4.3.
Lihrury
category
The library category follows. The purpose slot describes the motivation for using the MLM. It contains free text, and it is generally one or two sentences. The explanation slot details how the MLM works. It is also free text, but it usually contains a whole paragraph. It can be displayed to the clinical users when they are reviewing MLM messages. The keywords are descriptive terms for indexing an MLM knowledge base. The list is delimited by semicolons. UMLS [5] terms are preferred. The citutions slot contains references to literature that supports the MLM’s medical behavior. References should follow “Vancouver style” [6]. The citations slot is optional. The links slot contains institution-specific links to other sources of information, such as electronic textbooks and education modules. The links slot is also optional. 4.4.
Knowledge
category
The knowledge category contains the MLM’s medical knowledge. The type slot is intended to allow future slot variations within the knowledge category. At present. the type is always data-driven. (This does not mean, however, that the MLM must necessarily be triggered by the storage of data; it could be triggered by any event or called by another MLM.) The dutu slot maps terms used in the MLM to the institution’s database and environment. Terms may refer to clinical data, clinical events, electronic mail addresses, etc. The purpose of the data slot is to separate those parts of the MLM that are specific to an institution from the more generic parts of the MLM (e.g. the logic). It is considered a “structured slot”, which means it follows a special syntax that is described below. The priority indicates the order in which MLMs should be invoked. It can be a number from 1 (last) to 99 (first). It is an optional slot, and it is rarely used. The erloke slot specifies how the MLM should be triggered. An MLM can be triggered by an event, by the expiration of a time interval after an event, or by a direct call from an MLM or an application program. The logic slot contains medical criteria or an algorithm. It uses terms defined in the data slot and decides whether to perform the MLM’s action. The uction slot usually generates a message that is routed to a health-care provider, but it can perform a number of other actions. Like the data slot, the evoke, logic, and action slots are structured slots, and they are described in more detail below. The urgency indicates importance of MLM’s message or action. It is a number from 1 (low) to 99 (high). It is an optional slot, and it has not been used often. The MLM ends with its end: marker. If there is more than one MLM in file, then the next one simply begins with its maintenance category.
G. HKIITMK
33h 5.
SYNTAX
OF
THE
STRUCTURED
SLOTS
The structured slots share II common syntax. although each has its own slot-specific constructs. The syntax for these slots is similar to programming languages like Pascal. It it is derived from these is also similar to the syntaxes of HELP [7] and RMRS [Xl, since . systems. A slot is composed of sfutetnettts. each of which performs some function or defines some mapping. Statements. in turn, contain expressiotts. which are detined in the next section. This part of the tutorial begins by describing simple expressions, such as those that consist of numbers. More complex expressions are defined later in the tutorial.
5.2. Expressims An expressiott is irn Arden
Syntax phrase consisting of numbers,
strings, variables,
operators. etc. When expressions are evaluated, they return a result. For example, 2+2 returns a result of 4. Two expressions are said to be equioalenr if they return the same result. A typical expression might be
vat-l + 4.67 - COS(6). Numbers follow ASTM El238 format [9]. A number contains digits, an optional decimal point, and optional digits to the right of the decimal point. A number between zero and one may drop the zero before the decimal point. Scientific notation is permitted using E. There is no distinction between integer and real data types. The following expressions contain valid numbers: 3+0.1 3.00+0.100 3.+.1
3EO+ lE-I The Boolean
values are true and false.
true OR false Variables are made of a letter; then letters, digits, underscores (3. There are no variable type declarations. One simply uses a variable in the MLM. A variable can accept multiple data types within one MLM. For example, a variable can be assigned a number, then later be assigned a Boolean value. Remember that the syntax is case insensitive,
so these two variables are the same:
abcd_e3 aBcD_E3 Comments
follow the same syntax as C:
/* this is a comment, Arden
Syntax operators
much like C */ are similar
to those of other languages.
Or, and, and not
provide logical disjunction, conjunction, and negation. The operators =, <>, >, C, >=, and <= perform familiar comparisons, and +, -, *, and / provide plus, minus, times, and divide. The ** performs exponentiation (3**2 equals 9). There are several numeric functions. The following trigonometric functions are supported: arccos, arcsin, arctan, cosine, sine, and tangent. All angles are expressed as radians. The other numeric functions are defined as follows. exp-raise e to power log-natural logarithm IoglO-logarithm in base IO int-truncate to next smaller integer
Writing
abs--absolute sqrt-square
A&n
Syntax MLMs
value;
root.
For example, exp 1 equals” 2.71828... log 10 eclucrls 2.3025... log10 10 equds I int 3.4 equals 3 int -3.4 equuls -4 abs 3.4 eqds 3.4 abs -3.4 equals 3.4 sqrt 9 e~~ff~s 3
The Arden Syntax supports several lexical variants to improve readability and familiarity. The and of are formatting tokens. The is treated as white space. Of can appear after a numeric function. Several of the numeric functions have short forms: cos (cosine), sin (sine), and tan (tangent). Thus these expressions are the same: cos 3 cosine of 3 the cosine of 3 cos of (3)
Comparison =
EQ
<> > < > = < =
NE GT LT GE LE
operators is is is is is is
also have variants:
equal not equal greater than less than greater than or equal less than or equal
The word is has the following synonyms: are, was, and were. Is can be followed by not, which reverses the logic of the clause. For example, these two expressions are the same: 2<=3 2 was not greater than 3 Operator precedence is similar to other programming higher precedence than + :
languages. For example, * has
3 + 4*6 equals 3 + (4*6) One can use parentheses to override defaults. The common operators here in order of decreasing precedence:
are arranged
1. arccos arcsin arctan cosine sine tangent exp log log10 int abs sqrt 2. ** 3. +I 4. + 5. =<>><>=<= 6. not 7. and 8. or
The following groups of expressions serve as examples. Expressions within groups are equivalent. ” In these cxprcssion
CBM 24:5-8
cxamplcs and all that l’ollow. ~U~I/S is not part ol’ the Ardcn
to the Icl’t of qrtds
is cquiwlcnt
to the cxprcssion
Syntax.
fnstcad,
to the right oC c~qtrols.
it mc;ma that the
33x
3~4 OR 26 OR false (3>4) OR (2~5) OR (false) false OR true OR false true sine 0+2 (sine 0) + 2 0+2 log(l)+2 (log (I,)+2 0+2 3>4 + 7 or not S/4 - 9
7)))
Stutements
A structured slot is made of statements, which are built from the expressions defined above. The ussignment statement is the most basic. A variable holds (stores) a value for later use in the MLM. The value is set using an assignment statement. Assignment is indicated by : = or let-be: a:= 3. let a bd3; One could then use the variable
a as follows:
b : = a; /* b is assigned 3 (equals a) */ Now the following
expressions
are equivalent:
a + 1 equals 4 b + 1 equals 4 Notice that : = (assignment) and = (test for equality) are different. Also notice that all statements end with a semicolon. An if-then statement tests whether a criterion (a Boolean expression) is true. and then evaluates a block of statements based on the result. For example, if vat-1 > 5 then varl := 5; endif;
/*nowvarl<=
591
The general form of the if-then statement allows several tests. Only associated with the first test that is true is executed. If none is true, associated with else part are executed. IF a= 1 THEN b:= 1; ELSEIF a=2 THEN b := 2; ELSEIF a = 3 THEN b:= 3; ELSE b:= 0; ENDIF; /* if a is 1, 2, or 3, then b is a; otherwise b is 0 */ 5.4.
Character strings
Character
strings are values just like numbers:
“this is a character
string”
the statements the statements
Writing Arden Syntax MLMs
339
To a user, this string would appear like this: this is a character string To place a quotation mark within a string, use ““. “this contains ,,,’one quote mark” would appear like this: this contains IIone quote mark Character strings may cross a line. A single carriage return is translated into a space. Two or more carriage returns are translated into one carriage return. The expression “the first half the second half” would appear like this: the first half the second half One can concatenate This expression
strings together using 11.It does not add intervening spaces itself.
“first half” 11“second half” would print like this: first halfsecond half When non-strings are concatenated,
they are converted to strings. For example,
“result = ” IJ3 would print like this: result = 3 5.5. Lists The Arden Syntax supports lists, A list is an ordered set of values. One can create a list using ,. Lists can be heterogeneous (e.g. strings and numbers in the same list). Character strings are not considered lists of characters. These are valid lists: 3,475 3, true, “asdf”, 7 Because , has the lowest precedence, parentheses:
list expressions
are usually surrounded
with
(3,495) Two special lists are supported. An empty list is created using 0. The , operator is used to make a single value into a list of length 1. 0 ,I Except for 0, parentheses do item surrounded by redundant Lists can then be used must list, the function is applied to
not create a list. Therefore, (1) is not a list; it is a single parentheses. like single values. When a numeric function is applied to a each element:
int(3.4, 4.5, 5.6) equals (3, 4, 5) Operators that accept two or more arguments, such as addition, apply their operation pair-wise if the lists are the same length: (.l, .2, -3) + (1, 2, 3) equals (1.1, 2.2, 3.3)
G. HKIPCSAK
340
If one argument is a single value and the other is a list, then the single value is applied to each element of the list: 2 + (.l, .2, .3) equals (2.1, 2.2, 2.3) One should not use two lists of different length (the result would be null, which is explained below). List membership is supported using the is in operator: 3 is in (3, 4, 5) equals true 5 is in 5 equals true The result of is in is a list if the left argument is a list: (2, 3) are in (3, 4, 5) equals (false, true) (Note the use of the lexical variant are.) Lists can be aggregated using aggregation operators. They accept a list as input, they return a single value or another list, and their usage is the same as numeric functions. For example, count(1, 2, 3) equals 3 average(1, 2, 3) equals 2 minimum(1, 2, 3) equals 1 When an aggregation operator is applied to a single value, it treats the value like a list of length one: count(78) equals 1 Aggregation
operators can also be applied to empty lists:
count0 equals 0 To be used properly, aggregation operators usually require parentheses because of the high precedence of the aggregation operators. For example, the following is syntactically valid but usually undesired: count 1, 2, 3 equals (count l), 2, 3 Instead, use this: count(1,
2, 3)
The basic aggregation operators
are
count-number of elements exist-true if there is at least one element last-value at the end of a list first-value at the beginning of a list These aggregation operators
are used for numeric lists only:
average(avg) median sum
stddev-standard deviation variance-statistical variance These aggregation operators minimum(min)-smallest maximum(max)-largest
are used for numbers and strings:
value value
The Boolean aggregation operators any-true
are
if any element in the list is true
Writing Arden Syntax MLMs
all-true no-true
341
if all elements are true if none of the elements are true
For example, any(true, equals al&true, equals no(true, equals
When used on empty lists, the Boolean aggregation operators work as follows: any0 equals false allo equals true no() equals true
It is important to use aggregation with if-then statements. The if part of an if-then statement expects a single Boolean value; it does not know how to interpret multiple values. Therefore regardless of value of elements, a list is always counted as false. One should always use any, all, or no with lists so that they reduce the list to a single value: if (true, false, true) then a:= 3; /* NOT performed */ endif; if any(true, false, true) then a:= 3; /* IS performed */ endif;
The following aggregation operators
return list results:
minimum
from return smallest elements in C list > maximum from return < number > largest elements in C list > first from return first elements from last from return last elements from (In this example and others that follow, the phrase “” means any valid number, including a variable that has been assigned a number and an expression that results in a number. Similarly, “” means any list.) These aggregation operators return the number of elements requested, or only what is available if too many are requested. For example, first 2 from (1, 2,3) equals (1, 2) maximum 2 from (6, 4, 5) equals (6, 5) first 7 from (1, 2, 3) equals (1, 2,3) The following aggregation operators compare elements within a list. increase
< list > return difference between successive items decrease < list > additive inverse of increase % increase percent difference between successive items % decrease additive inverse of % increase
G. HKIPCSAK
342
For example, decrease(7, 3, 6) equals (4, -3) % increase(4, 5, 8) equals (25, 60) 5.6. Null
In the Arden Syntax, a rrull value symbolizes uncertainty or an error. A null value can result in several ways. The keyword null itself can be used. A null value can be returned from a database query. An error in execution will result in null, including the invalid use of an aggregation operator. All of the following expressions result in null. null 3/o log 0 true + 3 last0 sum(“asdf”,
2)
Note that these two are not the same: min 1 from () equals () /* a valid list */ min() equals null I* no way to pick one value *I Null can be an element in a list: (1, “asdf”, null, 4, null)
In general, any operation with null results in null. 3 + null equals null 3 >= null equals null 3 + (1, null) equals (4, null) (3 = null) equals null (null = null) equals null
To test for null, use is null, or its synonym is not present. (3, null) is null equals (false, true) (3, null) is present equals (true, false)
The Arden Syntax uses three-state logic, where null means “unknown”. tables for the three Boolean operators are as follows: OR
TRUE
FALSE
Null
TRUE FALSE NULL
true true true
true false null
true null null
AND
TRUE
FALSE
NULL
TRUE FALSE NULL
true false null
false false false
null false null
NOT
TRUE
FALSE
NULL
false
true
null
The truth
Writing Arden Syntax MLMs
343
For example, (true or null) equals true (false or null) equals null (null and null) equals null
In an if-then statement, the Boolean expression must be true to execute the statements associated with then. Thus, null is treated the same as false, and the statements (if any) associated with else are executed instead. Non-Booleans are treated like null. if null then a:= 3.,
else a : = 0; /* this is chosen */ endif;
To separate the three logical states, check for null (existence) first, then check the truth value. if a is nuil then b : = “a is nuII”; eiseif a then b : = “a is true@; else b : = “a is false”; endif;
5.7. Time and duration An Arden Syntax time is a specific instant, which consists of a date and a time of day. It is known as a “timestamp” in some other languages. The format follows the IS0 8601 standard 141, where seconds and microseconds are optional. The general format is YYYY-MM-DDThh:mm:ss.mmmmmm where “YYYY” is year, “MM” is month, “DD” is day, “hh” is hour, “mm” is minutes, “ss” is seconds, and “mmmmmm” is microseconds. The T between the day and hour is required. For example, 1954-02-28Tl2:21 1993.Ol-02T14:30:34 1987-ll-12T02:00:21.123456 An Arden syntax duration is an unanchored duration operator to a number.
length of time, created by applying a
1 year 21 hours
The duration operators year month day hour minute second
are
years months days hours minutes seconds
There are several operators for combining time and duration. After adds a duration to a time, and before subtracts a duration from a time. They both correct for different days in a month.
G.
344
HKIPCSAK
1 month after 1990-Ol-OlT12:34:56 equals 1990-02-OlT12:34:56 1 month before 1~0-01-01T12:~:56 equals 1989-12-OlT12:34:56 1 month after 1990-Ol-31TOO:OO:O0 equals 1990-02-28TOO:OO:OO 30 days after 1990-Ol-31TOO:OO:O0 equals lo-03-02TOO:OO:~ One can also use arithmetic operators