diff --git a/app/calculator.R b/app/calculator.R index 7ee52b9..9e9ecb5 100644 --- a/app/calculator.R +++ b/app/calculator.R @@ -16,7 +16,8 @@ calculatorUI <- function(id){ sliderInput("slider2", strong("Największa średnica elementu stałego (w mm):"),min = 0, max = 200, value = 0), selectInput("select3",strong("Nieregularna wewnętrzna ściana torbieli:"),choices = list("Nie"=0,"Tak"=1),selected=0), selectInput("select4",strong("Obecność cieni akustycznych:"),choices = list("Nie"=0,"Tak"=1),selected=0), - actionButton("update" ,"Oblicz") + actionButton("update" ,"Oblicz"), + downloadButton("report", "Generuj raport") ), mainPanel( @@ -35,6 +36,36 @@ calculatorUI <- function(id){ } calculatorServer <- function(input, output, session) { + + + output$report <- downloadHandler( + # For PDF output, change this to "report.pdf" + filename = "raport.pdf", + content = function(file) { + # Copy the report file to a temporary directory before processing it, in + # case we don't have write permissions to the current working dir (which + # can happen when deployed). + tempReport <- file.path(tempdir(), "report.Rmd") + file.copy("report.Rmd", tempReport, overwrite = TRUE) + + # Set up parameters to pass to Rmd document + p=0 + if(as.numeric(input$slider2)>=50){ + p=50 + } + z=-5.3718+0.0354*as.numeric(input$slider1)+1.6159*as.numeric(input$select1)+1.1768*as.numeric(input$select2)+0.0697*p+0.9586*as.numeric(input$select3)-2.9486*as.numeric(input$select4) + x=round(1/(1+exp(-z)),3) + params <- list(n = input$slider1,k=input$slider2,l=input$select1,m=input$select2,p=input$select3,r=input$select4,z=x,y=) + + # Knit the document, passing in the `params` list, and eval it in a + # child of the global environment (this isolates the code in the document + # from the code in this app). + rmarkdown::render(tempReport, output_file = file, + params = params, + envir = new.env(parent = globalenv()) + ) + } + ) output$selected_var <- renderText({ input$update diff --git a/app/report.Rmd b/app/report.Rmd new file mode 100644 index 0000000..5caf2c8 --- /dev/null +++ b/app/report.Rmd @@ -0,0 +1,45 @@ +--- +title: "Dynamiczny raport" +output: pdf_document +params: + n: NA + k: NA + l: NA + m: NA + p: NA + r: NA + z: NA + y: NA +--- + +Wiek pacjenta(w latach): +`r params$n` + +Największa średnica elementu stałego (w mm): `r params$k` + +Obecność wodobrzusza: +```{r, echo=FALSE} +if(params$l==1) {print("Tak")}else {print("Nie")} +``` + +Obecność przepływu krwi w projekcji brodawkowatej: +```{r, echo=FALSE} +if(params$m==1) {print("Tak")}else {print("Nie")} +``` +Nieregularna wewnętrzna ściana torbieli: +```{r, echo=FALSE} +if(params$p==1) {print("Tak")}else {print("Nie")} +``` +Obecność cieni akustycznych: +```{r, echo=FALSE} +if(params$r==1) {print("Tak")}else {print("Nie")} +``` +Surowa wartość predyktora: +```{r, echo=FALSE} +params$z +``` +Klasa guza: +```{r, echo=FALSE} +if(params$z>0.1){print("złośliwy")}else{print("łagodny")} +``` +Próg złośliwości: 0.1 diff --git a/app/report.aux b/app/report.aux new file mode 100644 index 0000000..62837d9 --- /dev/null +++ b/app/report.aux @@ -0,0 +1,19 @@ +\relax +\providecommand\hyper@newdestlabel[2]{} +\providecommand\BKM@entry[2]{} +\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} +\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined +\global\let\oldcontentsline\contentsline +\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} +\global\let\oldnewlabel\newlabel +\gdef\newlabel#1#2{\newlabelxx{#1}#2} +\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} +\AtEndDocument{\ifx\hyper@anchor\@undefined +\let\contentsline\oldcontentsline +\let\newlabel\oldnewlabel +\fi} +\fi} +\global\let\hyper@last\relax +\gdef\HyperFirstAtBeginDocument#1{#1} +\providecommand\HyField@AuxAddToFields[1]{} +\providecommand\HyField@AuxAddToCoFields[2]{} diff --git a/app/report.pdf b/app/report.pdf new file mode 100644 index 0000000..b467f59 Binary files /dev/null and b/app/report.pdf differ diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml index b65094e..ddf045a 100644 --- a/backend/.idea/workspace.xml +++ b/backend/.idea/workspace.xml @@ -1,11 +1,11 @@ + + - - - - + \ No newline at end of file diff --git a/backend/src/backend.iml b/backend/src/backend.iml new file mode 100644 index 0000000..9c6817c --- /dev/null +++ b/backend/src/backend.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file