{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  
  "title" : "Clinical data template for a visualization of count data",
  
  "description" : "This report compute counts of variable(s) of interest (with the \\code{inTextSummaryTable} package) and visualize them with a treemap and/or sunburst.",
  
  "type": "object",
  
  "properties": {
  
    "template": {
      "const": "countsVisualizationTemplate.Rmd",
      "doc": "name of the template report"
    },
    "templatePackage": {
      "const": "clinDataReview",
      "doc": "package from which the template should be extracted"
     },
    
    "reportTitle": {
      "type": "string",
      "doc": "header title"
    },
    "reportTitleLevel": {
      "type": "integer",
      "doc": "header level, 1 by default (1: 'chapter', '2': 'section', '3': subsection, ...)"
    },
    "parallel": {
      "type": "boolean",
      "doc": "does this chapter use parallel execution? If the entire report is run in parallel, this ensures that this specific chapter is created outside of the report parallelization."
    },
    "split_by": {
      "oneOf": [
        {"type": "integer", "minimum": 0, "maximum": 7},
        {"type": "string", "enum": ["none", "chapter", "section"]}
      ],
      "doc": "split the chapter at the specified level: 1 (for 'chapter'), 2 (for 'section') until 7. This overwrites the 'split_by' parameter defined in the output format of the report."
    },
    
    "dataFileName" : {
      "type": ["string", "array"],
      "doc": "name of the data file(s) of interest. If multiple files are specified, the data are combined by rows ('row bind'), with a column: 'DATASET' containing the name of the file (in upper case and without extension) the data originate from."
    },
    "dataProcessing": {
      "type": "array",
      "doc": "data processing parameters, passed to \\link[clinDataReview]{processData}"
    },
    "dataTotalFileName": {
      "type": "string",
      "doc": "filename of the total dataset"
    },
    "dataTotalProcessing": {
      "type": "array",
      "doc": "data processing parameters for 'dataTotalFileName', passed to \\link[clinDataReview]{processData}"
    },
    "countVar": {
      "type": "string",
      "doc": "variable of data to count on"
    },
    "parentVar": {
      "type": ["string", "array"],
      "doc": "parent variable(s) of the counting variable, used for grouping"
    },
    "colorVar": {
      "type": ["string", "object"],
      "doc": "numeric variable(s) to consider for coloring, named by count/parent variable if different for each variable"
    },
    "colorRange": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "minItems": 2,
      "maxItems": 2,
      "doc": "range of the color variable for the visualization"
    },
    "loopingVar": {
      "type": ["array", "string"],
      "doc": "data variable(s) to loop over. Each group of the variable(s) is displayed in a separated section of the report."
    },
    "loopingNMax": {
      "type": "integer",
      "doc": "maximum number of elements of \\code{loopingVar} to include in the report"
    },
    "loopingTotal": {
      "type": "boolean",
      "doc": "should the total also be computed by \\code{loopingVar} (TRUE by default)?"
    },
    "typePlot": {
      "type": ["array", "string"],
      "items": {
        "type": "string",
        "enum": ["sunburst", "treemap"]
      }
    },
    "startup": {
      "type": ["array", "string"],
      "doc": "R commands that should be run at the start of the report"
    }
  },
  
  "required": ["template", "templatePackage", "reportTitle", "dataFileName", "countVar"],
  
/*   doesn't allow extra parameters in the config files */
  "additionalProperties": false 
  
}
