Leave a comment at the end of this page or email contact@krishagni.com
Integrating with External Data Warehouse
Introduction
Many customers want to pull data out of OpenSpecimen into an external data warehouse. You can achieve this in two ways:
Using APIs
Using Query
This page explains the option to use the OpenSpecimen Query interface to achieve this option. This option is easy to achieve.
Importantly, this avoids outside developers learning OpenSpecimen APIs and writing custom programs. Writing programs need a lot of programming efforts, can be a maintenance overhead in the long run, and can be error-prone.
Overview
Exporting data
Create a Query using OpenSpecimen Query module. Reference Reporting
Include all the fields needed in the data warehouse. Reference Query Results view.
Save the query
Create a Scheduled Job for the saved query using the Jobs module. Select frequency of job run as nightly, weekly, monthly, etc. Reference Scheduling Queries
OpenSpecimen creates a CSV file every time the job is run at the scheduled frequency.
Fetching CSV Files Via APIs
Refer to https://openspecimen.atlassian.net/l/c/xi6pnzz0 on how to run the scheduled jobs and download the data output via API.
How to query for records that have been added/updated since the last run?
You may not want all data in every run. To pull only the data that has changed since the last query run, you can use the fields “Update Time” field within Participant, Visit, and Specimen objects in the query UI.
To retrieve specimens modified in the last 60 minutes, use the temporal filter given below:
minutes_between(current_date(), Specimen.updateTime) < 60
To retrieve visits modified in the last 24 hours:
minutes_between(current_date(), SpecimenCollectionGroup.updateTime) < 1440
To retrieve participants modified in the last one week (7 days):
minutes_between(current_date(), Participant.updateTime) < 10080
To retrieve participants modified in the last one month:
months_between(current_date(), Participant.updateTime) < 1
Leave a comment at the end of this page or email contact@krishagni.com