Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

We can export specimen form data using APIswe can extract all CP data like participants, visits, specimens....etc.

The request methods and URLs are the same for all attributes. Just need to change the request payloads. The request payloads for different CP attributes are mentioned in the below.

An example of extracting specimen forms data using API is given below.

API Details

Method

POST

URI

/rest/ng/export-jobs/

Payload

Code Block
{
  "objectType": "extensions",
   "params":
    {
      "entityType": "Specimen",
      "formName": "<FORM_NAME>",
      "cpId": <CP_ID>
     }
}

Parameter Details

formName

Name of the form that you want to export the data.

cpId

Collection protocol ID.

Example -

Request Payload:-

Code Block
{
    "objectType": "extensions", 
    "params": 
    { 
        "entityType": "Specimen", 
        "formName": "techSpecimenForm", 
        "cpId": 3513
    }
}

Response Payload

Code Block
{
    "id": 4878,
    "name": "extensions",
    "status": "COMPLETED",
    "totalRecords": null,
    "createdBy": {
        "id": 5413,
        "type": "SUPER",
        "firstName": "System",
        "lastName": "Administrator",
        "loginName": "admin",
        "domain": "openspecimen",
        "emailAddress": "admin@localhost",
        "instituteId": 1,
        "instituteName": "Biobank Institute",
        "primarySite": "Biobank_Site_1",
        "admin": true,
        "instituteAdmin": false,
        "manageForms": true,
        "cpCount": 0,
        "creationDate": 1608625532000,
        "activityStatus": "Active"
    },
    "creationTime": 1633773235491,
    "endTime": 1633773235535,
    "params": {
        "timeZone": "Asia/Kolkata",
        "entityType": "Specimen",
        "cpId": "3513",
        "formName": "techSpecimenForm"
    }
}

Exporting data in the file

Enter the id from the above response in the below URL. Send the request. Save response in the file.

Method

GET

URI

/rest/ng/export-jobs/<JOB_ID/output

E.g.

...

Payloads for different attributes of CP

Attribute

Payload

Comments

Participants

Code Block
{
  "objectType": "cpr",
   "params":
    {
      "cpId": <CP_ID>
    }
}

Extracts participants data in the CSV file for a given CP id.

Visits

Code Block
{
  "objectType": "visit",
   "params":
    {
      "cpId": <CP_ID>
    }
}

Extracts visits data in the CSV file for a given CP id.

Specimens

Code Block
{
  "objectType": "specimen",
   "params":
    {
      "cpId": <CP_ID>
    }
}

Extracts specimen data with aliquotes and derivatives in the CSV file for a given CP id.

Error Cases :

code

Applies to

Status Message

200

All resources

Speciemen form data Data exported successfully.

400

All requests

Invalid parameters.(Invalid form name, CP_ID, JOB_ID etc)

401

All requests

Authorization failed, user doesn't have Authority

500

All requests

Internal server error, Encountered server error while performing operations