Auto bulk import
Got feedback or spotted a mistake?

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

  1. 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.

  2. Copy the bulk import CSV files into the 'scheduled-bulk-import' directory. You can do this via scripts in case of integrations.

  3. The file name should be in the format mentioned in the table below

    Data

    Format

    Description

    Data

    Format

    Description

    Standard entities (e.g. participant, specimen, etc) 

    <object_type>_<operation>_<timestamp>_[<csv_type>].csv

    1. object_type: Entity name specified in bulk import schema file (see list below)

    2. operation: Operation to perform, valid values are "create" or "update".

    3. timestamp: In yyyyMMddHHmmssSSS.

    4. csv_type (optional): Specify "m" in case of "Order" and "Shipment".

    5. Examples

      • cp_create_20160511162033124.csv

      • distributionOrder_create_20160511162033124.csv

    Custom fields

    <entity>_<operation>_<timestamp>_cpId_<cpId>.csv

    1. entity: cpr, visit, specimen.

    2. operation - Operation to be performed, "create" or "update".

    3. timestamp - In "yyyyMMddHHmmssSSS" format

    4. cpId - Identifier of collection protocol. 

    5. <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.

    6. Example: Specimen custom field level update file

      specimen_update_20200925115950000_cpId_4292.csv

    Custom forms

    extensions_<attached_level><form_name><operation>_<timestamp>.csv

    1. extensions: Static word to identify a custom form.

    2. attached_level: Level at which the form is attached. 

      1. Participant

      2. SpecimenCollectionGroup (i.e., Visit)

      3. Specimen

      4. SpecimenEvent

    3. form_name - System generated 'Form Name' of the custom form.

    4. operation - Operation to be performed, "create" or "update".

    5. timestamp - In "yyyyMMddHHmmssSSS" format

    6. Example: extensions_Participant_familyHistoryAnnotation_create_20160511162246252.csv

  4. Once the files are processed (uploaded into OpenSpecimen), they are moved to a folder named 'processed-bulk-import'.

  5. 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'.

  6. 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.

  7. To view the bulk import jobs, use the URL <https://IP address/openspecimen/#/bulk-import-jobs>.

  8. The following is the list of object types for OpenSpecimen entities

Entity

Object Type

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:

  1. Participant update CSV: Name of CSV should follow cpr_update_yyyyMMddHHmmssSSS_cpId_<cpId>.csv format. e.g., cpr_update_20220715185015000_cpId_18.csv

  2. Create a folder called 'files', and insert the required files (PDF, JPEG, PNG, etc.) into the folder.

  3. 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:

Got feedback or spotted a mistake?

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