CALCULATE_FROM_READINGS
STRING, comprising a script code
When the Readings Calculation grid flow option is selected from the readings grid in the lower panel in a Workbook session, then:
- If empty (default on deploy), then the result is the latest reading.
- If an active script that has Script Type of Workbook, and the Groovy code within the script contains the Execute event, then it is run to perform the averaging of readings and return either a new FinalResult, or exit in some Cancel state, in which case no new result is supplied.
- The script should implement the calculateReading(WorkbookSession session, List<CCSampleSchemeAnalyteReadingDTO>selectedReadings) method that averages the Numeric Final Value of selected active SSARs. and write the determined average as a new reading and thereby set a new final value on the SSA. This method does not return a value.
- Objects and properties/methods are exposed from Workbook to the script, allowing the script to access the selected SSAR records, and perform iterations through this collection to perform the required calculations and determine a new SSA result, including the full Workbook session which exposes the analyte and reading object collections.
- The Workbook user must select the rows (using the normal row selection check boxes) to indicate which readings are used to calculate a new SSA result.
- The SSAR.isActive flag that indicates whether to include a SSAR in the average determination. This flag may be modified by an API method in the script, for example, session.service.get('CCSampleSchemeAnalyteReading').updateFlag(array of dtos). Note that the new SSAR's isActive flag is cleared as it was not used to calculate its own result.
Typically the preference is not set at role or user level.
