9. Exports

Exports are used to export data generated by SQL queries in either CSV or JSON format. There are 4 URL’s the exporter listens to with each their scope:

GET /exportcsv

Data export in CSV format

This endpoint returns the data in a comma-separated values file (CSV).

Status Codes:
GET /exporttab

data export int tab format

This endpoint returns the data in a CSV file, where the values are separated by “\t”. This format makes the data appropriate for the Orange toolkit for data analysis and visualization.

Status Codes:
GET /exportjson

Data export in JSON format

This endpoint returns the data in a JSON format, where the headers are separated from the rows. The headers are in a “header” object while the rows are accessible in the “rows” object. Here the rows object consists of a list of lists where the first element in the list is the first row, the second element is the second row, etc. The key values of the elements correspond to the fields of the “header” object, i.e., the first field of the header is the key value for the first field of a row. If the “action_column” is not defined in the configuration action_id will not be in the result.

Status Codes:
Response JSON Object:
  • header[] (string) –

  • rows[] (any) –

GET /exportjson/ids

Data export in JSON format

This endpoint returns the data in a JSON format, where only the values of the key-value that is defined by the “action_column” are given as a list. If the “action_column” is not defined in the configuration an empty array will be the result.

Status Codes:
Response JSON Object:
  • [] (integer) –

9.1. Example preset

The following preset is used for this example:

preset:
  name: viewa
  ref: VIEWA
  filterorder: []
  flattable:
    groupfractionorder: []
    groupfractions: {}
    order:
    - preference_date
    - ppatient_id
    - porganization_id
    - pitem_int
    - pitem_bool
    - pitem_text
    - pitem_numeric
    - pitem_date
    sortorder:
    - - pitem_date
      - ASC
  description: description viewa
  category: predefined
  public: true

9.2. Results

The endpoints for the example preset give the following results

9.2.1. /exportcsv

"Nr.";"action_id";"preference_date";"ppatient_id";"porganization_id";"pitem_int";"pitem_bool";"pitem_text";"pitem_numeric";"pitem_date"
"1";"6";"2000-01-01";"6";"6";"6";"False";"6";"6,0";"2000-01-07"
"2";"7";"2000-01-01";"7";"7";"7";"True";"7";"7,0";"2000-01-08"
"3";"8";"2000-01-01";"8";"8";"8";"False";"8";"8,0";"2000-01-09"
"4";"9";"2000-01-01";"9";"9";"9";"True";"9";"9,0";"2000-01-10"
"5";"10";"2000-01-01";"10";"10";"10";"False";"ërganization";"10,0";"2000-01-11"

9.2.2. /exporttab

Nr.\taction_id\tpreference_date\tppatient_id\tporganization_id\tpitem_int\tpitem_bool\tpitem_text\tpitem_numeric\tpitem_date
1\t6\t2000-01-01\t6\t6\t6\tFalse\t6\t6,0\t2000-01-07
2\t7\t2000-01-01\t7\t7\t7\tTrue\t7\t7,0\t2000-01-08
3\t8\t2000-01-01\t8\t8\t8\tFalse\t8\t8,0\t2000-01-09
4\t9\t2000-01-01\t9\t9\t9\tTrue\t9\t9,0\t2000-01-10
5\t10\t2000-01-01\t10\t10\t10\tFalse\tërganization\t10,0\t2000-01-11

9.2.3. /exportjson

{
  "header": [
      "Nr.",
      "action_id",
      "preference_date",
      "ppatient_id",
      "porganization_id",
      "pitem_int",
      "pitem_bool",
      "pitem_text",
      "pitem_numeric",
      "pitem_date"
  ],
  "rows": [
      [1, 6, "2000-01-01", 6, 6, 6, false, "6", 6.0, "2000-01-07"],
      [2, 7, "2000-01-01", 7, 7, 7, true, "7", 7.0, "2000-01-08"],
      [3, 8, "2000-01-01", 8, 8, 8, false, "8", 8.0, "2000-01-09"],
      [4, 9, "2000-01-01", 9, 9, 9, true, "9", 9.0, "2000-01-10"],
      [5, 10, "2000-01-01", 10, 10, 10, false, "ërganization", 10.0, "2000-01-11"]
  ]
}

9.2.4. /exportjson/ids

[6, 7, 8, 9, 10]

9.2.5. Notes

  • If the view type is not flattable the action_id field will not be present. The /exportjson/ids endpoint is an exception, this will return an empty list.