arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Comparing Stop/Start Dates and Times with LLTK

Lab scientists need to record both a start and stop date/time for an incubation. As a second evaluation of how many hours the incubation lasted, the scientists want BaseSpace Clarity LIMS to calculate the elapsed time.

The Lab Logic Toolkit evaluateDynamicExpression script can compare date/time entries and calculate elapsed hours. As Date fields in the LIMS do not display the required time component for this calculation, Text fields are needed.

The bash command uses a 'Date' function to convert the Text date/time entries into dates, and also uses a 'getTime' method to convert those dates into milliseconds since 1 January 1970 00:00:00 UTC. The difference between the two converted entries is then changed from milliseconds to hours.

hashtag
Example

  1. Create a step level Text field for the Start Date/Time.

    • In this example, the field is named Incubation Start yyyy-mm-dd hh24:mi. The format is included in the name to assist the scientist entering the date/time.

  2. Create a step level Text field for the Stop Date/Time.

If you want to use a button to populate a Text field with the current date/time, then use:

  • In this example, the field is named Incubation Stop yyyy-mm-dd hh24:mi.

  • Create a step level Numeric field for the Incubation Hours. Set your preferred decimal place limit.

  • Create an automation and enter the following command line (if you have used different field names, edit the example command line to match):

  • Set the automation to be triggered by a button on the step. This allows the scientist to enter/edit the Start and Stop Date/Time before the elapsed hours are calculated.

    ℹ Adjustment for the Start/Stop events taking place over the 'daylight savings change events' is not included in this example.

  • bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar -i {stepURI:v2} -u {username} -p {password} script:evaluateDynamicExpression 
    -exp 'step.::Incubation Hours:: = (Date.parse(::yyyy-mm-dd H:m::, step.::Incubation Stop yyyy-mm-dd hh24:mi::).getTime() - Date.parse(::yyyy-mm-dd H:m::, step.::Incubation Start yyyy-mm-dd hh24:mi::).getTime()) / (1000*60*60)' -log {compoundOutputFileLuid0}"
    bash -l -c "/opt/gls/clarity/bin/java -jar /opt/gls/clarity/extensions/ngs-common/v5/EPP/ngs-extensions.jar -i {stepURI:v2} -u {username} -p {password} script:evaluateDynamicExpression -exp 'step.::Formulation:: = new Date().getDateTimeString()' -log {compoundOutputFileLuid0}"