7 Calculations
Disclaimer 
Table of Contents... 

CalculationsPowerful. 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 resultsMost 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 expressed as [Ca] + [Mg] where Ca and Mg are the keywords for the Calcium and Magnesium Analysis Services respectively Interim FieldsSome 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 = [Display] * [Dilution]  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 CalculationNavigate to Calculations in the LIMS setup and select [Add Calculation] to create a new one, or to edit an existing one, click on it's title. Use the [Deactivate] 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 FieldsThe Interim values can now 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 ARs and Worksheets FormulaThe 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 Tips. Handy FormulasDivision by zeroTo 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] ComplexitySome 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 in water. 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))) Sensitivity testingIn Microbiology. Sensitivity Testing. See the formulas used to interpret organism size in Antibiotic Susceptibility and Drug Sensitivity Testing, as used in health care laboratories and applied in Bika Health Generic Correction calculationOptimise 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 views Weight calculationsUsing interim fields, Weight Loss %: ( [Grossmass]  [Nettmass] ) / ( [Grossmass]  [Vesslmass] ) * 100 Residual Weight %: (( [Nettmass]  [Vesslmass] ) / ( [Grossmass]  [Vesslmass] )) * 100 
7.1 Using CalculationsWith the Calculations configured, how to use them Testing a CalculationWhen 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 CalculationsIn MethodsOnce 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 ServicesApplying 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 