{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  
  "title" : "Clinical data template for a summary table of the data",
  
  "description" : "This report summarizes the data of interest (with the \\code{inTextSummaryTable} package). This table is displayed with an interactive table in the report, and exported to a docx file. This table can be compared to a summary table of a previous batch ('comparisonTable' parameters).",
  
  "type": "object",
  
  "properties": {
  
    "template": {
      "const": "summaryTableTemplate.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}"
    },
    
    "tableParams": {
      "type": "object",
      "doc": "parameters to summarize the data in a table, passed to \\link[inTextSummaryTable]{computeSummaryStatisticsTable}\n.Parameters depending on the dataset of interest can be specified as:\\cr\\code{[parameterName]: !r-lazy [dataI]}."
    },
    "tableParamsDocx": {
      "type": "object",
      "doc": "parameters to format the table to the docx format, passed to \\link[inTextSummaryTable]{exportSummaryStatisticsTable}"
    },
    "tableParamsDT": {
      "type": "object",
      "doc": "parameters to format the table to the DT interactive table included in the report, passed to \\link[inTextSummaryTable]{exportSummaryStatisticsTable}"
    },
    
    "comparisonTableType": {
      "type": "string",
      "doc": "output type of the comparison table: \\itemize{\\item{'table-comparison-interactive': the summary statistics are computed for the old and new batch separately, and the statistics are compared}\\item{'newData-diff': the differences at a record level between the new and old batch are first identified, and then summarized}\\item{'table-combine': the summary tables are computed for the old and new batch and displayed next to each other in a combined table}}",
      "enum": ["none", "table-comparison-interactive", "newData-diff", "table-combine"]
    },
    "comparisonTableParams": {
      "type": "object",
      "doc": "parameters for the comparison table, passed to \\link[clinUtils]{compareTables}. By default, statistics variables are compared across row and column elements."
    },
    "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)?"
    }
    
  },
  
  "required": ["template", "templatePackage", "reportTitle", "dataFileName", "tableParams"],
  
  /*   doesn't allow extra parameters in the config files */
  "additionalProperties": false
  
}
