The Junction API already returns the
interpretation field (e.g., “normal”, “abnormal”, “critical”) in the BiomarkerResult object. This documentation is intended for teams that want to build their own interpretation logic and need to parse the reference_range field along with min_range_value and max_range_value to determine whether results are within normal limits.reference_range field in Order results contains a string representation of the normal range for a lab test result. This field is critical for determining whether a result is within normal limits, but it requires parsing to understand the inclusivity/exclusivity of boundary values.
Why Parsing is Needed
Themin_range_value and max_range_value fields contain the boundary numbers from the lab, but they do not indicate whether those boundaries are inclusive or exclusive. This information is only available in the reference_range string, which requires parsing to determine the correct comparison operator.
Example
For a result with:reference_range:"<5.7"max_range_value:5.7min_range_value: Noneresult:"5.7"
5.7 is normal or abnormal. The boundary value 5.7 is the same whether the range is <=5.7 (inclusive, normal) or <5.7 (exclusive, abnormal). You must parse the reference_range string to know which operator to use.
Reference Range Formats
Thereference_range field can appear in several formats:
1. Comparison Operators
Single-bound comparisons using standard operators:<5- Less than 5 (exclusive upper bound)<=10.5- Less than or equal to 10.5 (inclusive upper bound)>3- Greater than 3 (exclusive lower bound)>=7.25- Greater than or equal to 7.25 (inclusive lower bound)
2. Range Notation
Two-bound ranges using hyphen notation:1-10- Between 1 and 10 (both inclusive)3.5-7.8- Between 3.5 and 7.8 (both inclusive)
3. Alternative Comparison Syntax
Some labs use alternative syntax:< OR = 9.9- Less than or equal to 9.9 (inclusive upper bound)> OR = 2- Greater than or equal to 2 (inclusive lower bound)
< or = 9.9 is equivalent).
Parsing Strategy
Parse thereference_range string to extract:
- Lower bound value (if present)
- Upper bound value (if present)
- Whether each bound is inclusive or exclusive
min_range_value and max_range_value, determines the correct comparison operators for evaluating whether results are within the normal range.
Example Implementation
Here’s an example implementation showing how to parse thereference_range field:
This example uses Python’s
re module for regular expression matching.Parsing Examples
Here are examples of what the above parsing function returns for differentreference_range formats: