Processors
Internally, all the processors are stored as a JSON1 file in the database. The processor is always attached to a single test definition. There could be zero, one or more processors for every test. In case of multiple processors, they are run in a predefined order.
There are currently three types of processors - Numeric, Text ans Script (JavaScript). Numeric and Text processors implement When-Then logic, e.g. when the value is less than 5, then make it 'negative'.
Numeric processors
Numeric processors work by comparing the numeric value of the original result. The comparisons are:
IsNull(no arguments, applied when input result is not a number)Equals(requires one argument)LessThan(requires one argument)GreaterThan(requires one argument)Between(requires two arguments)
Except IsNull, (which does not require an argument), arguments for other comparisons are set in the whenValues field (array). The only comparison which uses two arguments is Between. The output of a processor is defied in the thenValue as it is shown bellow.
Inclusive and Exclusive comparisons
LessThan and GreaterThan comparisons are always exclusive, which means that comparison 5.0 LessThan 5.0 will not be satisfied. Contrary, Between is always inclusive. e.g. 7.0 Between
7.0 and 11.0 will be satisfied.
Numeric Prefix in comparisons
If a result bag contains a prefix (operator) such as >, or >>, it will be used in some comparisons. In that case, when limit comparisons are used (LessThan and GreaterThan) prefix matters, e.g. <5.0 LessThan 5.0 will be satisfied. Similarly, <5.0 Equals 5.0 will not satisfy the comparison.
Example
The test (assay) is quantitative (concentration) and has a linearity limitation for values above 5.0. I.e. when the instrument sends values under this limit (5.0) they should be reported as <5.0 as the measured value is uncertain. The processor will be like this
Here is the full example of Numeric processor with flagging
Shorter and simpler example (with no flags)
Text processors
Text processors work by matching the text value of the original result. The comparisons are:
IsNull(no arguments, applied when input result is empty)EqualsContainsStartsWithEndsWith
Except IsNull, (which does not require an argument), arguments (in whenValues) could be as many as you want. All they will be tested in order of appearance and the processor will be applied if any argument satisfies the condition.
Example
{
"$type": "txt",
"comparison": "Equals",
"whenValues": [
"neg",
"-1"
],
"thenValue": {
"textValue": "Negative"
}
}
Script processors
Script processors work by executing JavaScript2 on a results bag. Internally, Iris uses Jint3 as an interpreter.
Th input data for a particular script processor is a JavaScript object, accessible inside the script under variable x. The output data is accessible under the name y. Both of the variables are objects of type TestResult (see Result Bag).
Example
Probably the most common usage of the script processors is conversion from one to another measurement units. Let us have a blood counter which reports Hematocrit as coefficient, e.g. 0.345, but the laboratory wants it as %. The conversion is simply a multiplication by factor 100, i.e. 0.345 * 100 = 34.5.
The JSON form of a simplest processor would look like this:
{
"$type": "js",
"name": "Example script processor",
"script": "y.NumericValue = x.NumericValue * 100;"
}
As you see, the actual JavaScript code comes in the property script. As there is nothing interesting in the JSON itself, lets extend the example, by showing only JavaScript code separately.
The more complete example of a script would look like this:
// Here we convert Hematocrit
y.NumericValue = x.NumericValue * 100;
y.TextValue = y.NumericValue.toLocaleString(); // use .toString() for invariant culture
You may add some flags as a part of the processing, which is done by adding entries in Flags property of the output variable (y). So, the extended version of our example (JS code only) will be:
// Here we convert Hematocrit
y.NumericValue = x.NumericValue * 100;
y.TextValue = y.NumericValue.toLocaleString(); // use .toString() for invariant culture
// Create flag
var Processor = importNamespace('Skyware.Iris.Processor');
var flag = new Processor.ProcessingFlag();
flag.Code = 'XXX';
flag.Value = 'Example flag';
flag.Level = 3; // FlagLevels.Error
// Add flag
y.Flags.Add(flag);