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: 441abbd92e02d893eb5136ccdfcc717d
#> → DM: State initialized
#> → DM: ds checksum updated: 641fcbc6616d24d05acded4317a3bb12
#> → DM: module checksum updated: 5c077c5702479f330bf233040eb4a51b
#> → 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: 90805ca6c41a39696e1572d9b0a75868
#> → DM: module checksum updated: e23d5c825540acc0ebc26cb74c8b151a
#> → DM: added element idx: 1
#> → DM: loading element idx: 2
#> → DM: ds checksum updated: e928598f7610a9009925b0af7f34b532
#> → DM: module checksum updated: dc1431368925bed725e54c07119172e6
#> → DM: added element idx: 2
#> → DM: loading element idx: 3
#> → DM: ds checksum updated: 0860e7b844ed0ea5a463d7f9fe2c47ef
#> → DM: module checksum updated: d6a8f486c3ab0d739363c9c480fe65c8
#> → DM: added element idx: 3
#> → DM: loading element idx: 4
#> → DM: ds checksum updated: 8e31bb49736f7ae048cd2b6c0b42a6e0
#> → DM: module checksum updated: 07c12049f72c1a8b702dbad7ea9ae5c4
#> → 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