Often one needs to perform queries based on calculated fields of dates or number fields.
Examples:
Difference between collection time and date of birth (age at collection)
Difference between collection time and received time (warm ischemia time)
Difference between frozen time and received time
All specimens collected "today", "last week" or "last month"
This page describes the way to do it and different options available. For video training session, please refer to Wiki page Temporal Query (Video)
Creating a new temporal query
Info: Attribute names, functions, and operators are auto-completed once you start to type in the temporal expression window. |
Demonstration of a Temporal Query:
creating_temporal_query (1080p).mp4
|
Example 1: Age as of today
![]() Example 2: Age at collection
![]() Temporal Expression: "years_between( Specimen.extensions.SpecimenCollectionEvent.time, Participant.dateOfBirth) any" Example 3: Age at collection
![]() Temporal Expression: "years_between( Specimen.spmnCollRecvDetails.collTime, Participant.dateOfBirth) any" Example 4: Time difference between frozen and received time ![]() Example 5: Tissue specimens collected in the last 2 months ![]() Example 6: Calculating the sample amount ![]() Example 7: Count of specimens collected per month ![]() Example 8: Count of specimens collected after a particular date ![]() Example 9: Age in years (rounded off) ![]() Example 10: Number of participants enrolled and parent samples entered per week. Result view: ![]()
Example 11: Finding percent from 2 numbers in custom form ![]() In the above example, number1 and number2 are two numeric fields defined in a form attached at 'Registration Forms' level. There is no % function in temporal queries, but the formula to find percent can directly used to calculate the same. Example 12: Calculating the initial cell value from the volume processed and initial concentration, where the volume processed and initial concentration are specimen custom fields. ![]() In the above expression,
Example 13: Average of 2 custom fields. ![]() In the above expression,
|
Temporal filters can be parameterized so that users can enter a range to dynamically filter the results. Below operators can be used in the temporal expression to make it parameterized:
Exists: to specify existence condition like age exists
Any: to specify don't care condition like age any
Assuming the present date as 15th March 2017
|
From v10.2 onwards, it is possible to configure URLs using temporal expression.
For the test server URL of participant overview page 'https://test.openspecimen.org/#/cp-view/6636/participants/176857/detail/overview', you need to configure the temporal expression as 'concat("https://test.openspecimen.org/#/cp-view/ " ,CollectionProtocol.id, "/participants/" ,Participant.id , "/detail/overview") != " "
For visit overview page URL https://test.openspecimen.org/#/cp-view/6636/participants/176857/visits/detail/overview?visitId=130492 you need to configure the temporal expression as concat("https://test.openspecimen.org/#/cp-view/" ,CollectionProtocol.id, "/participants/" ,Participant.id, "/visits/detail/overview?visitId=", SpecimenCollectionGroup.id) != " "
Below is the list of fields that are available to be used in the query
Field | Syntax |
Collection Protocol Identifier | CollectionProtocol.id |
Participant Registration Identifier | participant.id |
Participant Identifier | Participant.participantId |
Visit Identifier | SpecimenCollectionGroup.id |
Specimen Identifier | Specimen.id |