7 Calculations
Lab managers configure the lab's analysis results Calculations without programmer intervention using standard arithmetic operations +, -, *, / and more advanced percentages, square roots, exponentiation, and logarithmic functions to derive results from dependent analyses and interim fields
Calculations
Powerful. Calculations are used to determine Analysis results by applying a formula to dependent results and user defined interim fields. The results for Analyses set up with a calculation cannot be entered directly - the LIMS calculates it as soon as all dependent results are available
The Calculation formula references the unique Analysis Services keywords configured for them, and where applicable the keywords of Interim fields set up for the Calculation
Calculations are maintained in the LIMS Setup by authorised labmanagers, where their correct execution can also be tested. Saved Calculations are then available to be selected when configuring Methods and individual Analysis Services
Dependent results
Most results calculations will depend on a number of earlier Analysis results, and these are referenced using their unique keywords maintained on their Analysis Service pages
E.g. Total Hardness = Calcium + Magnesium, will be captured as [Ca] +[Mg] where Ca and Mg are the keywords for the Calcium and Magnesium Analysis Services respectively
Interim Fields
Some calculations require constants, and often variable factors, used for dilution, or weights. To use these in the calculation, specify them in the Interim Fields part of the screen, giving each a title, keyword, default value and unit
E.g. Titration = [Reading] * [Factor] - the user captures the Titration volume and Dilution factor values, and the LIMS calculates the results for the Analysis using the Calculation on the same line. Volume and Dilution are the keywords for their Interim Fields defined for the calculation
Note that the system tries to optimise the number of columns at display time, and forces the user to use the same keyword and title combinations already in use
Create or Edit a Calculation
Navigate to Calculations in the LIMS setup and select [+ Add] create a new one, or to edit an existing one, click on it's title. Use the [Deactivate] button if you want to decommission a calculation
Edit the calculation's title and description, and proceed to the real stuff
The Calculation tab is made up of two parts, Interim fields at the top, and the Formula itself
Interim Fields
The Interim values can be referenced by their keywords in the Calculation formula. Columns and entry or display fields are automatically generated by the LIMS for interim fields on Samples and Worksheets
Formula
The formula you type here will be dynamically calculated when an analysis using this calculation is displayed.
Standard mathematical operators, + - * / (), and percentages, square roots, exponentiation, and logarithmic functions can be used on any Analysis Service or Interim Field keywords, as well as valid Python Expressions and Builtins
Enclose keywords in square brackets, [ ]
Press [Save] to submit your edits
With the Calculations configured, how to use them
Tips. Handy Formulas
Division by zero
To prevent division by zero issues, use an if structure, e.g. for Terpenes to CBD ration, normally [Terpenes]/[CBD]:
N/A if [CBD] == 0 else [Terpenes]/[CBD]
Generic Correction calculation
Optimise the use of Interim Results columns on Sample and Worksheet views by using generic names like Reading and Factor for interim fields in correction and dilution calculations, [Reading] * [Factor]. Else a multitude of different names makes for too many and confusing columns on views
Weight calculations
Using interim fields, Weight Loss % =
( [Grossmass] - [Nettmass] ) / ( [Grossmass] - [Vesslmass] ) * 100
Residual Weight % =
(( [Nettmass] - [Vesslmass] ) / ( [Grossmass] - [Vesslmass] )) * 100
Langelier. Ryznar
Some very complex formulas can be used, e.g. for the Langelier Saturation Index, LSI, in Bika Water - an approximate indicator of the degree of saturation of calcium carbonate. Negative values are indicative of corrosion whilst positive values indicate scaling or coating
[pH]-((math.log10(100000/[CaHardnessasCaCO3]))+(math.log10(50000/[MAlkalinityasCaCO3]))+(2.6045*math.exp((-0.0108*[FieldTemp]))+(0.0144*[TtlDS]**0.4545))+(math.log10(1+((10**-(10.6-[pH]))*(1+[FieldTemp]/30))*2)))
Calculated pH = (math.log10(100000 / [CaHard])) + (math.log10(50000 / [Alk])) + (2.6045 * math.exp( ( -0.0108 * [pHT]))) + (0.0144 * [TDS] **0.4545) + (math.log10(1 + ( (10 ** - (10.6 - [pH]) ) * (1 + [pHT] / ) ) * 2)
Ryznar = 2 * pH - Calculated pH
or Langelier = pH - calculated pH
Testing a Calculation
When the user navigates away from the formula field, the LIMS populates a list Test parameters lower down on the page, collecting the Keywords from the formula
The user may then enter values for them and when the calculation is saved, a test results is calculated and displayed from which the formula's accuracy can be determined
Applying Calculations
In Methods
Once the Calculation is configured, it can be used to configure Methods and by implication the Analysis Services usiong them. They may be tweaked further per indiviual AS
On Analysis Services
Applying Methods to Analysis Services will automatically clone the Calculations associated with the Method onto the AS where they can be tweaked one final time
Calculations can also be directly selected for Analysis Service
