home api list

Hexostore API Documentation

csvsurveyanswers

/api/csvsurveyanswers/

List methods: post, get

Detail methods: options, post, get

A POST allow to upload many answers to a survey using a CSV file. A GET will return survey answers in a CSV format. It is possible to filter answers for example: /csvsurveyanswers/?user= will return all answers for this user. For more information on what is a survey, check the study section here

Example usage

Header of the CSV file

The first line of the CSV file should be the header of the columns. There are two types of headers we need. First off, we need the id of each question in the survey. For example, let's suppose a call to /api/survey/1/ return a survey that look like this example below. The CSV file will contain 5 columns: 1, 2, 3, user, authored. The table below will explain each column in detail:

Column Description
1 This is the id of the first question of the survey (refer to this example below)
2 This is the id of the second question of the survey
3 This is the id of the third question of the survey
subject The subject uuid of the user who responded to the survey.
authored The date the user answered the survey.

Content of the CSV file

It is possible to include as many users and as many responses for the same user (on a different date) as needed. The only restriction is that only one survey for one study can be entered in one CSV file. The table below contain the content of a valid CSV file that could be submitted to our example survey:

1 2 3 subject authored
no no yes studygroup1_subject1 2020-02-02
no no yes studygroup1_subject1 2020-02-03
no no yes studygroup1_subject1 2020-02-04
yes yes yes studygroup1_subject1 2020-02-05
no no no studygroup2_another_subject 2020-02-02
no no no studygroup2_another_subject 2020-02-03
no no yes studygroup2_another_subject 2020-02-04

And the content of the file would look like this:

1,2,3,survey,study,subject,authored
no,no,yes,studygroup1_subject1,2020-02-02
no,no,yes,studygroup1_subject1,2020-02-03
no,no,yes,studygroup1_subject1,2020-02-04
yes,yes,yes,studygroup1_subject1,2020-02-05
no,no,no,studygroup2_another_subject,2020-02-02
no,no,no,studygroup2_another_subject,2020-02-03
no,no,yes,studygroup2_another_subject,2020-02-04

Calling the API

One important detail about submitting a CSV file of anwers: the study id and the survey id must be passed as variables in the URL. For example calling /api/csvsurveyanswers/study/15/survey/53/ would submit the file for the study with id=15 and survey id=53.

Now that our file is ready, we can submit it to the server. To do so we must be authenticated and make a call to /api/csvsurveyanswers/. The Content-Type of the http header must be text/csv and the file is submitted as an attachment. If all goes well, the answers should be inserted in the database.


Survey used in the example above

{
"id": 1,
"survey_description": "Very short example survey that could be used for a patient suffering of the COVID-19",
"resource_uri": "/api/survey/1/",
"fhir_questionnaire": {
    "id": "1",
    "status": "active",
    "subjectType": ["Patient"],
    "resourceType": "Questionnaire",
    "item": [
    {
        "id": "1",
        "type": "boolean",
        "linkId": "1",
        "text": "Chest pain when breathing deeply?"
    },
    {
        "id": "2",
        "type": "boolean",
        "linkId": "2",
        "text": "Feeling tired or weak?"
    },
    {
        "id": "3",
        "type": "boolean",
        "linkId": "3",
        "text": "Loss of smell or taste?"
    }
    ],
    "url": "/api/questionnaire/1/",
    "name": "COVID-19 Survey",
    "title": "COVID-19 Survey",
    "description": "Daily questionnaire to follow up on a patient with COVID-19."
},
"survey_name": "COVID-19 Example"
}

Fields

survey_answers: ListSerializer

This field will default to: '' (empty string)

Filtering Options

authored: exact, in, gt, gte, lt, lte

id: exact, in, isnull

study: exact, in, gt, gte, lt, lte

survey: exact, in, gt, gte, lt, lte

user: exact, in, gt, gte, lt, lte

Sorting Options

No sorting supported

© 2024 by CarrĂ© Technologies Inc.