Leave a comment at the end of this page or email contact@krishagni.com
Auto bulk import
To perform automatic bulk imports on KSPL-hosted servers, please use this wiki page.
Introduction
Note: This page describes the server-based auto bulk import process, which requires access to the OpenSpecimen server/VM and is intended for technical IT personnel or automated integrations. If you are not an IT/technical user and want to import records from the OpenSpecimen user interface, use the UI-based bulk import option described here: Import Records Auto - Bulk Import.
The details below are for IT personnel who want to run auto-bulk imports from the VMs:
OpenSpecimen continuously monitors a folder and imports bulk files. This simplifies integration with systems such as REDCap and OpenClinica.
External systems no longer need to call OS REST APIs. They create OS BO–compatible CSV files and drop them in a predefined folder. OS monitors that folder and consumes new files. CSV files are processed in ascending order by the timestamp in the filename to preserve import order.
Steps
Create a "scheduled-bulk-import" directory in the app data (os-data) directory if not present. The location of the os-data directory can be retrieved from the $Tomcat_Home/conf/openspecimen.properties file. Check for the app.data_dir property.
Copy the bulk import CSV files into the 'scheduled-bulk-import' directory. You can do this via scripts in case of integrations.
The file name should be in the format mentioned in the table below
Data
Format
Description
Standard entities (e.g. participant, specimen, etc)
<object_type>_<operation>_<timestamp>_[<csv_type>].csv
object_type: Entity name specified in bulk import schema file (see list below)
operation: Operation to perform, valid values are "create" or "update".
timestamp: In yyyyMMddHHmmssSSS.
csv_type (optional): Specify "m" in case of "Order" and "Shipment".
Examples
cp_create_20160511162033124.csv
distributionOrder_create_20160511162033124.csv
Custom fields
<entity>_<operation>_<timestamp>_cpId_<cpId>.csv
entity: cpr, visit, specimen.
operation - Operation to be performed, "create" or "update".
timestamp - In "yyyyMMddHHmmssSSS" format
cpId - Identifier of collection protocol.
<cpId> - Identifier of the collection protocol. You can get this identifier via the DB or from the browser URL on the collection protocol overview page.
Example: Specimen custom field level update file
specimen_update_20200925115950000_cpId_4292.csv
Custom forms
extensions_<attached_level><form_name><operation>_<timestamp>.csv
extensions: Static word to identify a custom form.
attached_level: Level at which the form is attached.
Participant
SpecimenCollectionGroup (i.e., Visit)
Specimen
SpecimenEvent
form_name - System generated 'Form Name' of the custom form.
operation - Operation to be performed, "create" or "update".
timestamp - In "yyyyMMddHHmmssSSS" format
Example: extensions_Participant_familyHistoryAnnotation_create_20160511162246252.csv
Once the files are processed (uploaded into OpenSpecimen), they are moved to a folder named 'processed-bulk-import'.
If there are any issues with the file name format, then the file is not uploaded and is moved to a folder named 'unprocessed-bulk-import'.
The file name needs to be updated, and the file must be moved to the 'scheduled-bulk-import' folder, from where it can be taken up for upload.
To view the bulk import jobs, use the URL <https://IP address/openspecimen/#/bulk-import-jobs>.
The following is the list of object types for OpenSpecimen entities
Entity | Object Type |
|---|---|
Institutes | institute |
Site | site |
User | user |
User Roles | userRoles |
Container | storageContainer |
Distribution Order | distributionOrder |
Shipment | shipment |
Participant registration | cpr |
Participant registrations for multiple CP | cprMultiple |
Participant consents | consent |
Visits | visit |
Specimen | specimen |
Aliquots | specimenAliquot |
Derivatives | specimenDerivative |
Master Specimen | masterSpecimen |
Note: The date format in the files should be <mm-dd-yyyy> for US and <dd-mm-yyyy> for others.
Example 1: Template for Collection Protocol
Example 2: Template for importing files in Participant-level custom field:
Prerequisites:
Participant update CSV: Name of CSV should follow cpr_update_yyyyMMddHHmmssSSS_cpId_<cpId>.csv format. e.g., cpr_update_20220715185015000_cpId_18.csv
Create a folder called 'files', and insert the required files (PDF, JPEG, PNG, etc.) into the folder.
Compress both the folder ('files') and the CSV into a zip. Give the zip the same name as the CSV, i.e., cpr_update_20220715185015000_cpId_18.zip
Example zip file containing the CSV and folder 'files' with PDFs: