Appends report elements to a formods report.
Arguments
- state
DM state from
DM_fetch_state()- rpt
Report with the current content of the report which will be appended to in this function. For details on the structure see the documentation for
template_details- rpttype
Type of report to generate (supported "xlsx", "pptx", "docx").
- gen_code_only
Boolean value indicating that only code should be generated (
FALSE).
Value
list containing the following elements
isgood: Return status of the function.
hasrptele: Boolean indicator if the module has any reportable elements.
code: Code to generate reporting elements.
msgs: Messages to be passed back to the user.
rpt: Report with any additions passed back to the user.
Examples
# We need a state object to use below
sess_res = DM_test_mksession()
#> → ASM: including file
#> → ASM: source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM: dest: file.path("config","report.docx")
#> → ASM: including file
#> → ASM: source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM: dest: file.path("config","report.pptx")
#> → ASM: including file
#> → ASM: source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM: dest: file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders:
#> → ASM: -> setting docx ph: HEADERLEFT = left header
#> → ASM: -> setting docx ph: HEADERRIGHT = right header
#> → ASM: -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
#> → DM: including file
#> → DM: source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → DM: dest: file.path("config","report.docx")
#> → DM: including file
#> → DM: source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → DM: dest: file.path("config","report.pptx")
#> → DM: including file
#> → DM: source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → DM: dest: file.path("config","report.yaml")
#> → DM: module checksum updated: f280116ab6b4488df6de76aff513a83f
#> → DM: State initialized
#> → DM: ds checksum updated: 641fcbc6616d24d05acded4317a3bb12
#> → DM: module checksum updated: 78099100dae67cc0fee50517ea72a920
#> → DM: adding preload sources
#> → DM: - file added: TEST_DATA.xlsx
#> → DM: added: TEST_DATA.xlsx
#> → DM: - url added: https://raw.githubusercontent.com/john-harrold/formods/refs/heads/master/inst/test_data/SDTM_PC.csv
#> → DM: url added: https://raw.githubusercontent.com/john-harrold/formods/refs/heads/master/inst/test_data/SDTM_PC.csv
#> → DM: - url added: https://raw.githubusercontent.com/john-harrold/formods/refs/heads/master/inst/test_data/SDTM_EX.csv
#> → DM: url added: https://raw.githubusercontent.com/john-harrold/formods/refs/heads/master/inst/test_data/SDTM_EX.csv
#> → DM: - url added: https://raw.githubusercontent.com/john-harrold/formods/refs/heads/master/inst/test_data/SDTM_DM.csv
#> → DM: url added: https://raw.githubusercontent.com/john-harrold/formods/refs/heads/master/inst/test_data/SDTM_DM.csv
#> → DM: loading element idx: 1
#> → DM: ds checksum updated: 6641a9032f26b9a5970020c4a16d4b9c
#> → DM: module checksum updated: 5b01d4cdd1ef718f70073e51bd741fee
#> → DM: added element idx: 1
#> → DM: loading element idx: 2
#> → DM: ds checksum updated: 4c86652ce91b3b5ff581b7a7baba2fcf
#> → DM: module checksum updated: 00b95c8b5784296caef2fe2f65e8ae1b
#> → DM: added element idx: 2
#> → DM: loading element idx: 3
#> → DM: ds checksum updated: eb2887d19c490daf5c189ec3aee1ec76
#> → DM: module checksum updated: 15ee3d9a7c55c5dd517d21db57f88463
#> → DM: added element idx: 3
#> → DM: loading element idx: 4
#> → DM: ds checksum updated: 1353bff97a3a12f262bcc68667c9bc29
#> → DM: module checksum updated: a28d483033c692e5b9493cb0b6cd86c3
#> → DM: added element idx: 4
#> → DM: module isgood: TRUE
#> → # preload_complete is good: TRUE ------------------------------------------
state = sess_res$state
rpt = list(summary = list(), sheets=list())
rpt_res = DM_append_report(state,
rpt = rpt,
rpttype = "xlsx")
# Shows if report elements are present
rpt_res$hasrptele
#> [1] TRUE
# Code chunk to generate report element
cat(paste(rpt_res$code, collapse="\n"))
#> # Excel (from file)
#> rpt[["sheets"]][["DM_obj_1"]] <- DM_obj_1
#> rpt[["summary"]] <- rbind(rpt[["summary"]],
#> data.frame(
#> Sheet_Name="DM_obj_1",
#> Description="Excel (from file)"
#> )
#> )
#>
#> # STDM PC (url)
#> rpt[["sheets"]][["DM_obj_2"]] <- DM_obj_2
#> rpt[["summary"]] <- rbind(rpt[["summary"]],
#> data.frame(
#> Sheet_Name="DM_obj_2",
#> Description="STDM PC (url): PC"
#> )
#> )
#>
#> # STDM EX (url)
#> rpt[["sheets"]][["DM_obj_3"]] <- DM_obj_3
#> rpt[["summary"]] <- rbind(rpt[["summary"]],
#> data.frame(
#> Sheet_Name="DM_obj_3",
#> Description="STDM EX (url): EX"
#> )
#> )
#>
#> # STDM DM (url)
#> rpt[["sheets"]][["DM_obj_5"]] <- DM_obj_5
#> rpt[["summary"]] <- rbind(rpt[["summary"]],
#> data.frame(
#> Sheet_Name="DM_obj_5",
#> Description="STDM DM (url): DM"
#> )
#> )
# Tabular summary of data views
rpt_res$rpt$summary
#> Sheet_Name Description
#> 1 DM_obj_1 Excel (from file)
#> 2 DM_obj_2 STDM PC (url): PC
#> 3 DM_obj_3 STDM EX (url): EX
#> 4 DM_obj_5 STDM DM (url): DM
