Leave a comment at the end of this page or email contact@krishagni.com
Scheduling Queries
OpenSpecimen’s Scheduled Query feature enables users (with Jobs privilege) to schedule saved queries at daily, weekly, or monthly intervals. This feature replaces manual extraction with an automated model, ensuring stakeholders receive consistent, timely data updates.
Core Features
Intervals: Configure queries to run on a set recurring schedule.
Notifications: Automatically email results to designated users for immediate review.
Privileges needed
The following users can create scheduled queries:
Super administrators
Institute administrators
Users with “Scheduled Jobs” privilege in their role
How to schedule a query?
Create the query and save it.
Go to saved queries
Click on the three dots on the right of the query and click on 'Schedule'
Fill in the details to schedule the query:
Select the users who should receive the query results by email. A CSV link is sent to the users.
Specify the time interval at which the query should run.
Run as User (details below)
Important fields:
Field | Description |
|---|---|
Run as User | Indicates which user login is used to run the query. This is used for privilege checks and filtering data. |
Notify Users | One or more users who should be notified once the query is run. These users can download the data exported in a CSV file. |
Who can schedule queries?
Users with a role having 'Create' privileges on the 'Scheduled Jobs' resource can schedule queries.
How are query results filtered?
The Run as User setting serves as the primary security filter for scheduled queries. When a query executes, OpenSpecimen validates data access based on the privileges of the designated "Run as User," rather than the individual recipients.
Key Access Logic
Privilege-Based Filtering: The query output includes only the records accessible to the account specified in the Run as User field.
Recipient Access: When a query runs, notified users receive a download link. This link grants access to the full dataset generated by the "Run as User," regardless of the recipients' personal Collection Protocol (CP) restrictions.
Administrative Responsibility: The user scheduling the query is responsible for auditing the recipient list to prevent unauthorized data exposure.
Example
Consider a scenario involving two users with differing access levels:
User A (Run as User): Has access to CP1 and CP2.
User B (Recipient): Has access only to CP1.
If User A schedules a query that includes data from both CP1 & CP2, and includes User B on the notification list, User B will be able to download the data for both CP1 and CP2. The system honors the executing user's privileges to ensure the report remains intact for its intended distribution.
How to schedule one query for multiple groups?
Often, you want to reuse a query across multiple groups. This is not possible with a single scheduled query. Because a single scheduled job can execute only under the permissions of a single user (configured in the “Run as User” field), it cannot dynamically filter results for multiple disparate groups simultaneously.
The workaround is:
Create one query
Create multiple scheduled jobs - one per group
Set “Run as user” to a user of that group (this ensures the data is filtered as per that group)
Include receipts of that group in the “Notify users” field.