Universal Field Validator

@UVRANGE

@UVRANGE is a REDCap action tag that checks a number against two ranges: a soft range that asks before saving an unusual value, and a hard range that holds an implausible one.

REDCap's number validation takes one minimum and one maximum, and only warns. A lab value has two kinds of limit: the range most patients fall in, and the range outside which the number is almost certainly a typing or unit error. @UVRANGE checks both when the field is left and again when the form is saved. Outside the soft range the value is unusual and the save asks first; outside the hard range it is implausible and the save is held.

Syntax

JSON form only. At least one of soft and hard.

@UVRANGE={"soft":[12,17.5],"hard":[3,25],"unit":"g/dL"}

@UVRANGE={"soft":[null,140],"softBlock":"off","hard":[40,250],"hardBlock":"confirm","unit":"mmHg"}

@UVRANGE={"soft":[12,15.5],"hard":[3,25],"unit":"g/dL","when":"[sex]='2'"}
@UVRANGE={"soft":[13.5,17.5],"hard":[3,25],"unit":"g/dL","when":"[sex]='1'"}
KeyMeaning
soft[low, high], both ends included. Outside it the value is unusual. null leaves an end open
hard[low, high], both ends included. Outside it the value is implausible. The soft limits must lie inside the hard ones
softBlockconfirm (default): the save asks first; off: the note only
hardBlockhard (default): the save is held; confirm: the save asks first
unitA short label shown in the note, such as g/dL (up to 20 characters)
message, when, caseSensitive As for the other tags

Limits and values are compared as exact decimals, so 17.50 equals 17.5. A limit is kept exactly as written, quoted or not, so 0.12345678901234567890 keeps all twenty digits. blockSave is refused: use softBlock and hardBlock.

Field types

Text fields with integer or number validation (any number of decimals, comma decimals included) or with no validation, calc fields and sliders. On a comma-decimal field 17,5 reads as 17.5 and the note writes the limits with a comma. A Text field without validation accepts anything, so a value that is not a number is reported as implausible.

What is checked, and when

Growth references

With reference, the limits apply to the value's z-score for the child's sex and age, or length or height, computed the way WHO's own anthro software computes it.

@UVRANGE={"reference":"who-wfa","sex":"[sex]","male":"1","female":"2",
          "age":{"dob":"[dob]","at":"[visit_date]"},"soft":[-3,3],"hard":[-6,5]}

@UVRANGE={"reference":"who-wfh","sex":"[sex]","male":"1","female":"2",
          "by":"[height_cm]","soft":[-3,3],"hard":[-5,5]}
KeyMeaning
referenceThe reference: who-wfa, who-lhfa, who-bfa, who-hcfa, who-acfa, who-ssfa, who-tsfa, who-wfl, who-wfh (WHO 2006, birth to 5 years) or who2007-wfa, who2007-hfa, who2007-bfa (WHO 2007, 5 to 19 years)
sex, male, femaleThe field holding the sex, and the codes it stores for male and for female
age{"dob":"[dob]","at":"[visit_date]"}, {"days":"[age_days]"} or {"months":"[age_months]"}
byFor weight-for-length or weight-for-height: the field holding the length or height in cm
soft, hardz-score limits, from -20 to 20
plausible[low, high] in the reference's unit, judged when no z-score can be worked out (a blank date of birth, say)
measureScaleMultiplies the typed value before the z-score: 0.001 for grams typed into a reference in kg

WHO's software flags a z-score beyond these limits as implausible, and they make good hard limits: weight-for-age -6 to 5; length/height-for-age -6 to 6; weight-for-length, weight-for-height, BMI, head and arm circumference and the skinfolds -5 to 5. For soft, -3 to 3 suits data checking; -2 to 2 asks "save anyway?" for every moderately malnourished child unless "softBlock":"off".

Writing values into fields

A growth rule can also write what it works out into Text fields on the same form, so the z-score, the percentile or the usual range is saved with the record and appears in exports. return maps each value to a field.

@UVRANGE={"reference":"who-wfa","sex":"[sex]","male":"1","female":"2",
          "age":{"dob":"[dob]","at":"[visit_date]"},"soft":[-2,2],"hard":[-5,5],
          "return":{"z":"[wfa_z]","lower":"[wfa_low]","upper":"[wfa_high]","range":"[wfa_range]"}}

@UVRANGE={"reference":"who-wfa","sex":"[sex]","male":"1","female":"2",
          "age":{"dob":"[dob]","at":"[visit_date]"},
          "return":{"percentile":"[wfa_pct]","valueAtZ:-2":"[wfa_sd_m2]",
                    "valueAtPercentile:50":"[wfa_p50]","valueAtPercentile:97":"[wfa_p97]"}}

For a boy of exactly one year weighing 9.6 kg the two rules write these values.

FieldWrittenWhat it is
wfa_z-0.04The z-score of the weight
wfa_low7.8The lightest weight, to one decimal, whose z-score passes -2, the low soft limit
wfa_high11.9The heaviest weight, to one decimal, whose z-score passes 2, the high soft limit
wfa_range7.8 to 11.9 kgThe two as text, with the reference's unit
wfa_pct48.3The percentile of the weight, to one decimal
wfa_sd_m27.7The weight whose z-score is -2 (7.74 kg), to one decimal
wfa_p509.6The median weight for his age and sex
wfa_p9711.8The weight at the 97th percentile

The second rule has no soft or hard, since none of its four values is made from a limit. With the weight still blank, wfa_z and wfa_pct stay empty and the bounds and the three weights are still written, so the form shows them before anything is measured. For a girl of the same age the range is 7.1 to 11.5 kg.

The values and the keys that shape them

ValueWhat is written
zThe z-score, with two decimals
lower, upperThe smallest and the largest measurement, written with decimals, whose two-decimal z-score passes the low and the high limit. One unit of the last decimal beyond a bound is flagged
rangeThe two bounds as text, such as 7.8 to 11.9 kg. With only a low limit it reads at least 7.8 kg, with only a high one at most 11.9 kg
percentile100 times the normal distribution function of the unrounded z-score, written with percentileDecimals and rounded half away from zero. Beside a z-score written -0.04 this boy's percentile reads 48.3, the percentile of -0.0437
valueAtZ:<z-score>The measurement at that z-score, such as valueAtZ:-2 or valueAtZ:2.5. The z-score lies from -6 to 6, with at most two decimals
valueAtPercentile:<percentile>The measurement at that percentile, such as valueAtPercentile:97 or valueAtPercentile:2.5. The percentile lies from 0.1 to 99.9, with at most two decimals. valueAtPercentile:50 is the median and equals valueAtZ:0
KeyMeaning
returnAn object from a value to a field of this form, such as {"z":"[wfa_z]","valueAtPercentile:97":"[wfa_p97]"}. At most 16 values, each key once and each to its own field
returnLimitssoft (default) or hard, the limits lower, upper and range are made from
decimals0 to 6, the decimals of lower, upper, the bounds in range and the values at a z-score or percentile. The default is the measured field's: N for number_Ndp (2 for number_2dp, comma forms included), 0 for integer, otherwise 1
percentileDecimals0 to 3, the decimals of percentile. The default is 1

The fields

When the values are written

Growth chart and table on the form

show draws the reference's curves with this visit's point under the field, and a table under them. They are on the page only. Nothing is saved, and the check is the same without them. A rule that only shows needs no limits.

@UVRANGE={"reference":"who-wfa","sex":"[sex]","male":"1","female":"2",
          "age":{"dob":"[dob]","at":"[visit_date]"},"soft":[-2,2],"hard":[-5,5],
          "show":{"chart":{"lines":{"percentiles":[3,15,50,85,97]},"bands":true},
                  "table":true}}

Audit

The post-save audit logs a value outside either range as type: range with reason soft-low, soft-high, hard-low, hard-high, not-a-number or, for a growth reference, not-positive, plausible-low or plausible-high, whatever softBlock says, and the Validation scan counts it. A growth finding carries its reference, and its z-score only where values are kept raw (an audit log set to raw values, a scan that stores raw values). The scan's report, when it returns, labels each one an unusual value, an implausible value, not a number or (for a growth reference) not a positive measurement, with the expected or allowed range.