arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Advancing/Completing a Protocol Step via the API

This topic forms a natural partner to the Starting a Protocol Step via the API application example. When protocol steps are being initiated programmatically, we must know how to advance the step through the various states to completion.

hashtag
Solution

Advancing a step is actually quite a simple task. It requires the use of the steps/advance API endpoint - in fact, little else is needed.

Let us consider a partially completed step with ID 24-1234. To advance the step to the next state, the following is required:

  1. Perform a GET to the resource .../api/v2/steps/24-1234, saving the XML response.

  2. POST the XML from step 1 to .../api/v2/steps/24-1234/advance, and monitor the returned XML for success.

  3. If successful, the protocol step advances to its next state, just as if the lab scientist had advanced it via the Clarity LIMS interface.

The Python advanceStep (STEP_URI) method shown below advances a step through its various states. To achieve this, the URI of the step is passed to the method to be advanced/completed.

hashtag
Assumptions and Notes

  • The glsapiutil.py file is placed on the Clarity LIMS server, in the /opt/gls/clarity/customextensions folder. You will find the latest glsapiutil (and glsapiutil3) Python libraries on our .

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

Advancing a protocol step that is in its final state completes the step.
GitHub pagearrow-up-right
def advanceStep( STEP_URI ):

    response = False

    stXML = API.getResourceByURI( STEP_URI )
    rXML = API.createObject( stXML, STEP_URI + "/advance" )
    rDOM = parseString( rXML )
    nodes = rDOM.getElementsByTagName( "configuration" )
    if len( nodes ) > 0:
        response = True

    return response