Copying Output UDFs to Submitted Samples

It may at times be desirable to take key data derived during a workflow and copy it to the submitted sample. There are several reasons why this could be useful:

  • All key data is combined with all of the submitted sample's data, and becomes available on a single object.

  • Key data determined during a workflow can be made immediately available to external collaborators via the LabLink Collaborations Interface, since these users have access to their submitted samples.

  • Searching for data becomes easier as the data is not spread over several entities.

This example provides a script to allow the copying to occur, and describes how the script can be triggered.

Solution

To illustrate the script, we will copy a user-defined field (UDF) that is collected on the outputs of a QC type protocol step.

  • This UDF is named Concentration, and it is stored on the individual ResultFile entities associated with the analytes that went through the QC protocol step.

  • Once the QC protocol step has completed, the Concentration UDF values are copied to a UDF on the submitted Samples, which is called Sample Conc.

  • The QC protocol step is configured to invoke the script from a button on the step's Record Details screen.

Parameters

The EPP command is configured to pass the following parameters:

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

/usr/bin/python /opt/gls/clarity/customextensions/setUDFonSample.py -l MCL-SA1-131211-24-6813 -u admin -p securepassword -f "Sample Conc., Units" -t ResultFile -v "Concentration, Conc.Units" 

User Interaction

Once the script has copied the UDF values from the output to the submitted samples, the values are visible in the Submitted Samples view of the Operations Interface:

Similarly, assuming that the Sample Conc. UDF is set to be visible within LabLink Collaborations Interface, collaborators are able to see these values in their interface:

About the Code

The main method of interest is setUDFs(). This method carries out several operations:

  1. It harvests just enough information so that the objects required by the subsequent code can retrieve the required artifacts using the 'batch' API operations. This involves using some additional code to build and manage the cache of artifacts retrieved in the batch operations, namely:

    • cacheArtifact()

    • prepareCache()

    • getArtifact()

  2. The cached artifacts are then accessed, and for each one:

    • The corresponding sample is retrieved via the API.

    • The sample XML is updated such that the UDF value is obtained from the artifact by calling api.getUDF(), and stored on the sample by calling api.setUDF().

    • The sample XML is saved by calling api.updateObject().

  3. Finally, a meaningful message is reported back to the user via the contents of the successMsg and/or failMsg variables.

Assumptions and Notes

  • Both of the attached files are placed on the Clarity LIMS server, in the /opt/gls/clarity/customextensions folder.

  • You will need to update the HOSTNAME global variable such that it points to your Clarity LIMS server.

  • 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

setUDFonSample.py:

Last updated