Assigning Samples to New Workflows
It is sometimes necessary to assign a sample to a new workflow from within another workflow.
You can do this in the BaseSpace Clarity LIMS Operations Interface, by manually adding the sample to the desired workflow. However, it is also possible to perform this action through the API.
This example shows how to use the API to automate the addition of samples to a specified workflow, based on a UDF value.
The script can be run off any protocol step whose underlying process is configured with Analyte inputs and a single per-input ResultFile output.
The process may have any number of per-all-input ResultFile outputs, as they will be ignored by the script.
A Result File UDF, named Validate, will control which samples will be added to the specified workflow.
The script accepts the following parameters:
-i
The limsid of the process invoking the script (Required)
The {processLuid} token
Step 1: Create Result File UDF
Before the example script can be used, first create the ResultFile's Validate UDF in the Operations Interface. This is a single-line text UDF with preset values of 'Yes' and 'No'.
Step 2: Create and Configure Process Type
Also in the Operations Interface, create a new process type named Cookbook Workflow Addition.
This process type must:
Have a single per-input ResultFile output.
Apply the Validate UDF on its ResultFile outputs.
Step 3: Configure an EPP call on this process type as follows:
Step 4: Modify the file paths to suit your server's Groovy installation.
Step 3: Create Protocol
Once the process type is created, in the Clarity LIMS Web Interface, create a protocol named Cookbook Workflow Addition Protocol.
This protocol should have one the protocol step - Cookbook Workflow Addition.
Step 6: Configure EPP
Configure the EPP script to automatically initiate at the end of the Cookbook Workflow Addition step:
Step 7: Create workflows
To finish configuration, create two workflows:
Destination Workflow: THis workflow should contain the DNA Initial QC protocol only.
Sending Workflow: This workflow should contain the new Cookbook Workflow Addition Protocol.
Once the script has processed the input parameters and ensured that all the required information is available, we can start processing the samples to determine if they should be assigned to the new workflow.
To begin, we retrieve the process from the API. This gives us access to the input-output maps of the process. These will be used to determine which ResultFiles we will examine.
Next, we retrieve the protocol step action list. This contains a list of the input analytes' URIs and their next steps.
We then search this list for and collect all analyte URIs whose next action has been set to Mark as protocol complete.
User Interaction
Assuming samples have been placed in the Switching Workflow, the user proceeds as normal through the protocol step.
In the Record Details screen, the user enters Validate values in the ResultFile UDFs.
The user then proceeds to the Assign Next Steps screen, provides a variety of Next Steps, and completes the protocol step.
Assumptions and Notes
The attached file is placed on the Clarity LIMS server, in the /opt/gls/clarity/customextensions folder.
GLSRestApiUtils.groovy is placed in the Groovy lib folder.
The required configuration has been set up, as described in Configuration.
SwitchingWorkflows.groovy: