Summary
All invocations of formal expressions have available to them a number of custom methods injected into their execution context by ClinSpark. These methods provide access to specific access to backend functionality as described below.
customErrorMessage
This method is meant to be used only for edit checks. When invoked, it overrides the default error message configured in the edit check with the value of the parameter.
customErrorMessage('This is a new error message.');
findCompletedFormData
This method looks up previously collected study data for the current subject. Timepoint is optional.
var baselineForms = findCompletedFormData("Study Event Name", "Form Name, "TIMEPOINT");
Note that this method will return ALL collected instances of matching form data, including nonconformant and canceled data. To account for this be sure to filter the returned data accordingly.
findFormData
This method looks up previously collected study data for the current subject. Timepoint is optional.
var baselineForms = findFormData("Study Event Name", "Form Name, "TIMEPOINT");
Note that this method will return ALL collected instances of matching form data, including nonconformant and canceled data. To account for this be sure to filter the returned data accordingly.
getItemDataContext
This method takes no parameters, and returns a JSON object which exposes the various context data pertaining to the itemData, including unique primary database keys of the itemData, and its enclosing itemGroupData and formData objects. These values are useful if a unique identifier for this collected data entity is needed.
Here is an example of the JSON returned:
{ "itemDataId": 223, "itemGroupDataId": 22, "formDataId": 9, "siteName": 12, "investigatorName": 'Dr. Johnson', "investigatorId": 19 }
Here’s an example of accessing this context data, parsing it in Javascript and working with data:
var itemDataContext = JSON.parse(getItemDataContext()); logger(itemDataContext); var itemDataId = itemDataContext.itemDataId; logger('itemDataId '+itemDataContext.itemDataId); logger('investigatorId '+itemDataContext.investigatorId); logger('investigatorName '+itemDataContext.investigatorName); return itemDataId;
Note that this is standard in 22.3, but can be made available to older ClinSpark environments with a support ticket.
In 23.3 and later this context contains additional data, listing all collection item data barcodes for all Specimen Containers, and additionally a transferBarcodes element which shows all transfers which were created from an itemData:
"collectedBarcodes": "F00123478134, F00123478196", "transferBarcodes": "T00000022588, T00000022589, T00000022590, T00000022591, T00000022592, T00000022593, T00000022594, T00000022595",
logger
This method emits the parameter as debug output in the Method and Edit Check tooling.
logger('Some debug value '+value);