This repository was archived by the owner on Nov 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart_template.Rmd
More file actions
91 lines (73 loc) · 2.41 KB
/
chart_template.Rmd
File metadata and controls
91 lines (73 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
output:
pdf_document:
latex_engine: xelatex
keep_tex: false
documentclass: article
header-includes:
- \usepackage{amssymb}
- \usepackage[margin=2cm]{geometry}
- \usepackage{ragged2e} # text alignment utilities
- \usepackage{ltablex} # tabularx with longtable functionality
- \usepackage{rotating} # rotating table cells
- \usepackage{fancyhdr} # custom page numbering
- \usepackage{lastpage} # support custom page number
- \usepackage{fontspec} # font utilities
- \setmainfont{Arial} # default font type
params:
client_data: NULL
chart_num_diseases: NULL
chart_col_header: NULL
---
```{=latex}
% Custom circle indicator for vaccination history charts
\newcommand{\mycircle}{\raisebox{-0.2\height}{\resizebox{1em}{!}{$\bullet$}}}
% Removes the horizontal line under the header when using fancyhdr
\renewcommand{\headrulewidth}{0pt}
% Define a command to reset page counter and update last page reference
\newcommand{\newdocument}{
\setcounter{page}{1}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{Page \thepage\ of \pageref{LastPage}}
% ltablex setting
\keepXColumns
}
```
```{r, results='asis', echo=FALSE}
# One client per row
for (j in seq_len(nrow(params$client_data))) {
# Extract single row of data
client = as.list(params$client_data[j,])
client$`Page LaTeX` = c(
"
\\newdocument
\\huge \\textbf{Immunization Record}
\\normalsize Client ID: \\textbf{", client$`Client ID`, "}
\\vspace{0.25cm}
\\normalsize Below is a record of all immunizations received by the client on file with Public Health, excluding seasonal vaccinations against influenza and COVID-19.
\\setlength{\\arrayrulewidth}{1pt}
\\renewcommand{\\arraystretch}{1.25}
\\setlength{\\tabcolsep}{1pt}
\\begin{tabularx}{\\textwidth}{|l|l", rep("|>{\\centering\\arraybackslash}p{0.35cm}", params$chart_num_diseases + 1L), "|>{\\raggedright\\arraybackslash}X|}
\\hline
", params$chart_col_header, "\\\\
\\hline
\\endfirsthead
\\multicolumn{", params$chart_num_diseases + 4L, "}{c}{{Continuation of immunization record}} \\\\
\\hline
", params$chart_col_header, "\\\\
\\hline
\\endhead
\\multicolumn{", params$chart_num_diseases + 4L, "}{c}{{Immunization record continued on next page}} \\\\
\\endfoot
\\multicolumn{", params$chart_num_diseases + 4L, "}{c}{{End of immunization record}} \\\\
\\endlastfoot
",
client$`Vaccine History LaTeX`[[1]],
"
\\end{tabularx}
\\clearpage")
cat(client$`Page LaTeX`, sep = "")
}
```