# Report-specific parameters
template: patientProfilesTemplate.Rmd
templatePackage: clinDataReview
reportTitle: "Patient profiles"
reportTitleLevel: 1
createPatientProfiles: TRUE

# Parameters used for all modules
# patientProfilesGeneralParams:
# only create patient profiles for a subset for testing
#  subjectSubset: "01-701-1148"
#  subjectSample: 5

# Parameters for the creation of each specific module
patientProfilesParams:

  - typePlot: text
    dataFileName: dm.xpt
    dataProcessing:
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
    plotParams:
      paramValueVar: ["SEX", "RACE", "ETHNIC", "ARM", "ACTARM", "COUNTRY", "SITEID", "RFXSTDTC", "RFXENDTC"]
      title: Demography
      label: Demography

  - typePlot: text
    dataFileName: mh.xpt
    dataProcessing:
      - annotate:
        - dataset: dm
          vars: RFXSTDTC
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
    plotParams:
      paramValueVar: ["MHBODSYS", "MHDECOD", "MHSTDTC"]
      paramGroupVar: MHSTDTC
      table: true
      title: Medical history (Start - End)
      label: Medical history (Start - End)

  - typePlot: interval
    dataFileName: cm.xpt
    dataProcessing:
      - annotate:
        - dataset: dm
          vars: RFXSTDTC
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
    plotParams:
      paramVar: [CMDECOD, CMTRT, CMDOSE, CMDOSU, CMDOSFRQ, CMROUTE]
      paramGroupVar: CMINDC
      timeStartVar: CMSTDY
      timeEndVar: CMENDY
      colorVar: CMCLAS
      timeTrans: !r patientProfilesVis::getTimeTrans(type = "asinh-neg")
      timeExpand: !r ggplot2::expansion(mult = 0.01)
      shapeLab: Date status
      shapeSize: 4
      alpha: 0.6
      title: Concomitant medications
      label: Concomitant medications

  - typePlot: interval
    dataFileName: ex.xpt
    dataProcessing:
      - annotate:
        - dataset: dm
          vars: RFXSTDTC
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
    plotParams:
      paramVar: [EXTRT, EXDOSE, EXDOSU, EXDOSFRQ, EXDOSFRM, EXROUTE]
      timeStartVar: EXSTDY
      timeEndVar: EXENDY
      colorVar: EXDOSFRM
      shapeLab: Date status
      shapeSize: 4
      timeAlign: false
      alpha: 0.6
      title: Treatment exposure
      label: Treatment exposure

  - typePlot: interval
    dataFileName: ae.xpt
    dataProcessing:
      - annotate:
        - dataset: dm
          vars: RFXSTDTC
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
      - annotate:
        - vars: ASEV
          varFct: 'factor(AESEV, levels = c("MILD", "MODERATE", "SEVERE"))'
    plotParams:
      paramVar: AEDECOD
      timeStartVar: AESTDY
      timeEndVar: AEENDY
      colorVar: AESEV
      shapeLab: Date status
      shapeSize: 4
      alpha: 0.6
      title: Adverse events
      label: Adverse events

  - typePlot: line
    dataFileName: lb.xpt
    dataProcessing:
      - annotate:
        - dataset: dm
          vars: RFXSTDTC
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
      - annotate:
        - vars: LBNRIND
          varFct: 'factor(ifelse(is.na(LBNRIND), "UNKNOWN", LBNRIND), levels = c("LOW", "NORMAL", "HIGH", "ABNORMAL", "UNKNOWN"))'
    plotParams:
      paramValueVar: LBSTRESN
      paramValueRangeVar: [LBSTNRLO, LBSTNRHI]
      paramNameVar: [LBTEST]
      paramGroupVar: [LBCAT]
      timeVar: LBDY
      colorVar: LBNRIND
      colorPalette: !r-lazy clinUtils::getPaletteCDISC(x = dataI$LBNRIND, var = "NRIND", type = "color")
      shapeVar: LBNRIND
      shapePalette: !r-lazy clinUtils::getPaletteCDISC(x = dataI$LBNRIND, var = "NRIND", type = "shape")
      shapeSize: 4
      alpha: 0.6
      title: Laboratory test measurements
      label: Laboratory test measurements

  - typePlot: line
    dataFileName: vs.xpt
    dataProcessing:
      - annotate:
        - dataset: dm
          vars: RFXSTDTC
      - filter:
        # safety analysis set: treated-patients
        - var: "RFXSTDTC" 
          value: ""
          rev: true
    plotParams:
      paramValueVar: VSSTRESN
      paramNameVar: [VSTEST]
      timeVar: VSDY
      colorVar: VSPOS
      shapeVar: VSPOS
      shapeSize: 2
      alpha: 0.6
      title: Vital signs
      label: Vital signs

# Parameters for the 'createSubjectProfileReport' function
patientProfilesCreateReportParams:
  exportBatchSize: 3 # create reports by batch of 3 patients
  timeAlignPerSubject: all

# Parameters for the table
tableParams:
  dataFileName: dm.xpt
  dataProcessing:
    - filter:
      # safety analysis set: treated-patients
      - var: "RFXSTDTC" 
        value: ""
        rev: true
  vars: ["SEX", "RACE", "ETHNIC", "ARM", "ACTARM", "COUNTRY", "SITEID", "RFXSTDTC", "RFXENDTC"]

      
