Setting a Default Next Action

Often, a protocol step will have just a single 'next action' that is required to continue the workflow. In such cases, it can be desirable to automatically set the default action of the next step.

This example script shows how this task can be achieved programmatically.

Solution

Step configuration

The step is configured to invoke a script that sets the default next action when you exit the Record Details screen of the step.

Parameters

The automation command is configured to pass the following parameters to the script:

-u

The username of the current user (Required)

-p

The password of the current user (Required)

-s

The URI of the step that launches the script (Required)

The {stepURI} token

-a

Sets the next action to a fixed value. (Optional)

This is for advanced use, for example, when you would like to set the next action to a fixed value — 'repeat step', 'remove from workflow', and so on.

An example of the full syntax to invoke the script is as follows:

/usr/bin/python /opt/gls/clarity/customextensions/setDefaultNextAction.py 
-u admin -p securepassword -s 
https://demo-5-1.claritylims.com/api/v2/steps/122-7953 

User Interaction

When the lab scientist exits the Record Details screen, the script is invoked and the following message displays:

If the script completes successfully, the LIMS displays the default next action. If the current step is the final step of the protocol, it is instead marked as complete:

Manual Intervention

At this point the lab scientist is able to manually intervene and reroute failed samples accordingly.

NOTE: it is not possible to prevent the user from selecting a particular next-step action. However, it is possible to add a validation script that checks the next actions that have been selected by the user against a list of valid choices.

If the selected next step is not a valid choice, you can configure the script such that it takes one of the following actions:

  • Replaces the next steps with steps that suit your business rules.

  • Issues a warning, and prevents the step from completing until the user has changed the next step according to your business rules.

About the Code

The main method in the script is routeAnalytes(). The method in turn carries out several operations:

  1. The actions resource of the current protocol step is investigated.

  2. The possible next step(s) are identified.

  3. If there is no next step, the current step is set to 'Mark protocol as complete.'

  4. If there are multiple next steps, the first is used to set the next action.

Assumptions and Notes

  • The attached file is placed on the LIMS server, in the /opt/gls/clarity/customextensions folder.

  • The Python API Library (glsapiutil.py) is placed on the Clarity LIMS server, in the /opt/gls/clarity/customextensions folder. You can download the latest glsapiutil library from our GitHub page.

  • The example code is provided for illustrative purposes only. It does not contain sufficient exception handling for use 'as is' in a production environment.

Attachments

setDefaultNextAction.py:

Last updated