This is a R package to produce dynamisk tabellverk web pages. The web page is hosted on www.shinyapps.io and can be found here: https://skde.shinyapps.io/tabellverk/ The data in itself is not included in this package.

How to install the package

remotes::install_github("mong/tmongr")

If behind proxy

Include the following in your ~/.Renviron file before you install the package:

Development

Functions from the shiny package that is not on cran are used when running tests. Thus, the github version of shiny has to be installed to be able to run the tests locally:

remotes::install_github("rstudio/shiny")

Docker

This R package can be added to a docker image together with all R and system dependencies needed to run the the tmongr web application from any docker host.

Build

Since the tmongr R package is to be installed into the image please make sure to build the source tarball first. From a system command terminal navigate into the tmongr-directory and run:

Then, build the docker image:

Run

To run the docker container from a system command terminal do:

Then, open a web browser window and navigate to your localhost at port 3838 to use the tmongr web application.

To stop the docker container hit Ctrl + c in the system comman terminal.

Running SAS code

Running the following SAS code will produce the aggregated data used by the shiny app:

%let sasfolder = <folder>\tmongr\sas;

%include "&sasfolder\formater.sas";
%include "&sasfolder\macroer.sas";
%include "&sasfolder\rater_og_aggr.sas";
%include "&sasfolder\tilrettelegging.sas";
%include "&sasfolder\tilretteleggInnbyggerfil.sas";

%include "&sasfolder\avd_tabell.sas";

The following data files will be produced:

<folder>\csv_filer\avd_behandlert19.csv
<folder>\csv_filer\avd_justoverft18.csv
<folder>\csv_filer\avd_fagt18.csv
<folder>\csv_filer\avd_icd10t18.csv

Convert the data to R

The csv files produced by SAS have to be converted to utf-8 and unix file ending format by git bash:

Then saved as RDS files, as follows:

data <- read.table('../csv_filer/unix_avd_behandlert18.csv', 
                  sep = ",", 
                  header=T, 
                  encoding = 'UTF-8', 
                  stringsAsFactors = FALSE)

names(data) <- tolower(names(data))
saveRDS(data, "data/behandler.rds")

Running the app

# read the data
uten_overf <- readRDS("../tabellverk/data/behandler.rds")
med_overf <- readRDS("../tabellverk/data/justertoverf.rds")

# define `niva`
uten_overf$niva <- "Uten overf"
med_overf$niva <- "Med overf"

# bind the data together
datasett <- rbind(uten_overf, med_overf)

# run the app
run_app()