{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  
  "title" : "Clinical data template for the creation of patient profiles",
  
  "description" : "This report creates the specified patient profiles (with the \\code{patientProfilesVis} package) by subject, and export them to a specified directory.",
  
  "type": "object",
  
  "properties": {
  
    "template": {
      "const": "patientProfilesTemplate.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."
    },
    
    "createPatientProfiles": {
      "type": "boolean",
      "doc": "Should the patient profiles be created or only loaded from a previous execution?"
    },
    
    "patientProfilesGeneralParams": {
      "type": "object",
      "doc": "set of parameters used for all patient profiles modules. These parameters are passed to all \\code{subjectProfile[]Plot} functions."
    },
    
    "patientProfilesParams" : {
      "type": "array",
      "doc": "parameters for each patient profile module",
      "items": {
        "type": "object",
        "properties": {
          "typePlot": {
            "type": "string",
            "enum": ["text", "line", "interval", "event"],
            "doc": "plot type, used to get the appropriate plot module function: \\itemize{\\item{'text': \\link[patientProfilesVis]{subjectProfileTextPlot}}\\item{'line': \\link[patientProfilesVis]{subjectProfileLinePlot}}\\item{'interval': \\link[patientProfilesVis]{subjectProfileIntervalPlot}}\\item{'event': \\link[patientProfilesVis]{subjectProfileEventPlot}}}"
          },
          "dataFileName": {
            "type": "string",
            "doc": "name of the data file of interest"
          },
          "dataProcessing": {
            "type": "array",
            "doc": "data processing parameters, passed to \\link[clinDataReview]{processData}"
          },
          "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]}"
          }
        },
	      "required": ["typePlot", "dataFileName", "plotParams"]
      }

    },
    
    "patientProfilesCreateReportParams" : {
      "type": "object",
      "doc": "parameters for the creation of the patient profile report(s), passed to \\link[patientProfilesVis]{createSubjectProfileReport}"
    },
    
    "tableParams": {
      "type": "object",
      "doc": "parameters specifying a table containing data of interest and links to created patient profiles",
      "properties": {
        "dataFileName": {
          "type": "string",
          "doc": "name of the data file to display in the table"
         },
         "dataProcessing": {
           "type": "array",
           "doc": "data processing parameters, passed to \\link[clinDataReview]{processData}"
         },
         "vars": {
            "type": "array",
            "doc": "variable(s) of data to display in the table"
         }
      },
      "required": ["dataFileName"]   
    },
    
    "startup": {
      "type": ["array", "string"],
      "doc": "R commands that should be run at the start of the report"
    }
     
  },
  
  "required": ["template", "templatePackage", "reportTitle", "patientProfilesParams"],
  
/*   doesn't allow extra parameters in the config files */
  "additionalProperties": false 
  
}
