Skip to content

Data Types

Before we start writing clever medical logic, we need to know what “stuff” we can actually store and work with in Arden Syntax. These “stuffs” are called data types and they’re the building blocks of every MLM you’ll ever write.

Null

Let's start with a special one: Null. Null is a special value representing “no data” or “unknown.” For example:

arden-syntax
data:
    allergy_info := null;
    allergy_Info := Null;   
    allergy_INFO := NULL;   
;;

Case Sensitivity in Arden Syntax

Arden Syntax is mostly case-insensitive when it comes to keywords and variable names.

Numeric Values

You can store numeric values, including integers and real (decimal) numbers:

arden-syntax
data:
    heart_rate := 72;        // beats per minute  
    temperature := 37.5;     // degrees Celsius

Truth Value (Boolean)

You are probably familiar with Boolean values (just 1 -> true or 0 -> false), and Arden supports those too, but Arden Syntax also has special data types used for storing how true something is., values in the range of [0,1]. Truth value and Boolean are treated the same for backwards compatibility.

You can see them in action here.

Lists

Arden Syntax comes with built-in functions to make working with lists easier:

arden-syntax
data:
    mixed_data := "Glucose", 5.6, true;  
    med_allergens := "Penicillin", "Aspirin", "Sulfonamides";
    temperatures := 37.5, 37.8, 38, 37.9, 37.7;

To access any one data point in the list we can simply use the element operator [].

arden-syntax
logic: 
    allergen := med_allergens[3];

Here are some of the most useful built-in operations for lists:

  • num := count(med_allergens) tells you exactly how many elements there are in a list
  • partialList := first 2 from med_allergens, simply returns the first two values
  • temperatures := add 37.6 to temperatures, can be used to add one element to a list
  • sorted := sort temperatures can arrange a list’s items in order. according to the actual data points (numerically or lexicographically), their primary time or applicability

More of these can be found in the operator reference.

Strings

Strings are sequences of characters of any length, Used for names, labels, messages, or codes. You can write a string constant by enclosing it in double quotes:

arden-syntax
data:
    dna_sequence := "ATGCTAGC";
    bases := extract characters dna_sequence;
;;

Terms are a special kind of constant, written in single quotes. Right now, Arden Syntax mostly uses them for MLM names in structured slots or the link text part of a structured link record, for example, when calling another MLM or represent controlled vocabulary terms (think standardized codes like SNOMED or LOINC).

'mlm_name1'
'http://www.nlm.nih.gov/'

Concatenation & Extraction of Characters

The extract characters operator expects a string as its argument. It returns a list of the single characters in the string.

If the argument has more than one element, the elements are first concatenated, as for the || operator (see Section 9.8.1). If the argument is an empty list, the result is the empty list (). The string operator (Section 9.8.3) can be used to put the list back together

Now we assume we are screening for a known pathogenic mutation, "TAG". We add the following to our data section from before:

arden-syntax
data:
    codon_to_find := "T", "A", "G";
    codon_found := false;
    num := 1;
;;

and can follow this logc part:

arden-syntax
logic:
    while num <= (count bases - 2) do
        current_codon := bases[num], bases[num+1], bases[num+2];
        if all of (current_codon = codon_to_find) then
            codon_found := true;
            breakloop;
        endif;
        num := num + 1;       
    enddo;
    conclude true;;
action: 
    return string codon_to_find || " found in " || dna_sequence || " : " || codon_found;;

We loop over the list, taking triples like (bases[1], bases[2], bases[3]). If we find the target ("A", "T", "G"), we set codon_found to true and break the loop. This happens with our input sequence which results in the String "TAG found in ATGCTAGC : true".

Pattern Matching

So far, we’ve been pulling apart DNA strings character-by-character, checking them one base at a time. But isn't there some easier way? Yes there is and it's called pattern matching. Think of it like the “find” function in your word processor, we could have replaced our entire logic section with jut these two lines and still get the same result:

arden-syntax
logic:
    codon_found := (dna_sequence matches pattern "%TAG%");
    conclude true;;

And let Arden Syntax do the searching for you.

TIP

If we want to determine if a sequences starts with "AT", we can use the search term "AT%"

See another pattern matching example at the end of this example.

DATE & TIME

Date and time values in Arden Syntax follow the ISO 8601 extended format. This means dates follow yyyy-mm-dd syntax and date-time stamps look like yyyy-mm-ddThh:mm:ss, with optional fractional seconds and optional time zone e.g., 1989-01-02T13:30:00Z. Dates and times are used for temporal reasoning, like comparing when events happened or checking intervals between them. The T (or lowercase t) separates date and time.

TIP

The earliest supported time stamp is 1800-01-01T00:00:00Z.

Duration

Durations represent a length of time (not a specific point in time) and are handy for interval checks. Arden lets you convert between time units directly, no manual math required. You can freely convert between years, months, days, hours, minutes, and seconds. An example would be: duration := 2.5 YEAR; // equals 30 months