Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Search based on time difference

OpenSpecimen supports temporal queries to find specimens based on calculation between date or numeric fields. 

Usecase: User wants to find all aliquots which are processed within 30 minutes of collection. To start with, identify the date fields which will be used for this query:

  • Collection date: Captured at primary specimen level but available at all child specimens in query under field 'Collection Date'
  • Processing date : Captured under 'Created On'


To create the temporal query, follow below steps:

  1. Go to queries, click on 'Create' and click on the temporal expression icon
  2. Type the temporal expression within the text area. There are many temporal functions available, refer to Calculated fields (Temporal Queries) for more details. For the example query, use minutes_between function. Within the function, enter the two date fields and condition like '< 30' outside the brackets. The format of the date fields should be Class.attribute name. OpenSpecimen auto completes as you are typing. Click on 'Add' after entering the temporal expression.

    When creating temporal expressions, the higher date should be the first date.


    Value entered in the 'Description' field will be the calculate value column in the results view.

  3. Add any additional filters like below to the query, for example if I want only collected aliquots in the results.
  4. Click on 'View Records'. By default, the calculated column is not visible. Click on 'Column' and include all the fields needed in the results along with the calculated field 'Processing time difference'
  5. Click on 'Done' and check the results which displays the calculated field 'Processing time difference'


Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com