{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  
  "title" : "Clinical data generic template for visualization",
  
  "description" : "This report visualizes input data with a function of the clinical data review package. The data can be compared to the data of a previous batch, in the table associated to the plot ('comparisonTable' parameters).Summary statistics can be computed optionally and included in the plot (see 'tableParams' parameter).",
  
  "type": "object",
  
  "properties": {
  
    "template": {
      "const": "plotTemplate.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}"
    },
    
    "plotFunction": {
      "type": "string",
      "enum": ["timeProfileIntervalPlot", "scatterplotClinData", "boxplotClinData"],
      "doc": "plotting function of the package to consider"
    },
    "plotParams": {
      "type": "object",
      "doc": "parameters for the plotting function. Parameters depending on the dataset of interest can be specified as:\\cr \\code{[parameterName]: !r-lazy [dataI]}"
    },
    
    "tableParams": {
      "type": "object",
      "doc": "parameters for a summary table, passed to \\link[inTextSummaryTable]{computeSummaryStatisticsTable}\\cr Summary statistics are computed and merged as extra columns available for the plot data."
    },
    "tableProcessing": {
      "type": "array",
      "doc": "data processing parameters for the summary table, passed to \\link[clinDataReview]{processData}"
    },
    
    "comparisonTableType": {
      "type": "string",
      "doc": "output type of the comparison table. If specified, an additional column: 'Comparison Type' is included in the table attached to the plot.",
      "enum": ["none", "newData-diff"]
    },
    "comparisonTableParams": {
      "type": "object",
      "doc": "parameters for the comparison table, passed to \\link[clinUtils]{compareTables}. If referenceVars is not specified, all variables displayed in the plot are used."
    },
    
    "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"
    },
    
    "startup": {
      "type": ["array", "string"],
      "doc": "R commands that should be run at the start of the report"
    }
    
  },
  
  "required": ["template", "templatePackage", "reportTitle", "dataFileName", "plotFunction", "plotParams"],
  
  /*   doesn't allow extra parameters in the config files */
  "additionalProperties": false
  
}
