Skip to content

Commit

Permalink
Merge branch 'issue-3' into develop
Browse files Browse the repository at this point in the history
* issue-3:
  Title case for title
  Diagnosis as radio buttons (#4)
  Output as table (#4)
  Added calculation of HR for Fontan (#3)
  Simplified variable names
  Added calculation of HR for moderate (#3)
  Changed placeholders to NA (#3)
  Added calculation of heart rate for simple defects (#3)
  • Loading branch information
wleoncio committed Sep 25, 2024
2 parents 7a3cf66 + 4efdf66 commit d1571ac
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 48 deletions.
62 changes: 31 additions & 31 deletions src/server.R
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
server <- function(input, output) {
# Calculate endpoints
output$vo2_ml_min <- renderText({
vo2_ml_min()
})
output$vo2_ml_kg_min <- renderText({
vo2_ml_kg_min()
})
output$heart_rate <- renderText({
heart_rate()
})
output$ventilation <- renderText({
ventilation()
})
output$oxygen_pulse <- renderText({
oxygen_pulse()
})
output$ve_vco2_slope <- renderText({
ve_vco2_slope()
})
output$breathing_frequency <- renderText({
breathing_frequency()
})

vo2_ml_min <- function() {
1
NA
}

vo2_ml_kg_min <- function() {
2
NA
}

heart_rate <- function() {
3
heart_rate <- function(diagnosis, height, bmi, sex) {
software <- 0.0469 # prop. of Vyntus on Fontan (only relevant case here)
switch(diagnosis,
simple = (9168804 * height + 5.13e9) ^ (1 / 4.3),
moderate = (9.9e8 * height - 2.86e9 * bmi + 1.4e11) ^ (1 / 5),
fontan = (-144400.5 * height - 3.81e7 * sex + 2076971 * bmi * sex + 1.24e7 * software + 9.75e7) ^ (1 / 3.5)
)
}

ventilation <- function() {
4
NA
}

oxygen_pulse <- function() {
5
NA
}

ve_vco2_slope <- function() {
6
NA
}

breathing_frequency <- function() {
7
NA
}

output$results_table <- renderTable({
data.frame(
"Metric" = c(
"VO2 ml/min", "VO2 ml/kg/min", "Heart rate", "Ventilation",
"Oxygen pulse", "VE/VCO2 slope", "Breathing frequency"
),
"Value" = c(
vo2_ml_min(),
vo2_ml_kg_min(),
heart_rate(input$diagnosis, input$height, input$bmi, as.numeric(input$sex)),
ventilation(),
oxygen_pulse(),
ve_vco2_slope(),
breathing_frequency()
)
)
})
}
32 changes: 15 additions & 17 deletions src/ui.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
ui <- fluidPage(
# Step 1: selecting diagnosis
h1("Kids with congenital heart defects"),
h1("Kids with Congenital Heart Defects"),
wellPanel(
h2("Select diagnosis"),
selectInput(
inputId = "diagnosis",
label = "Diagnostic group:",
choices = c(
"Simple defects" = "simple_defects",
"Moderate complex defects" = "moderate_complex_defects",
"Fontan circulation" = "fontan_circulation"
)
radioButtons(
"diagnosis", "Diagnostic group:",
choiceNames = c(
"Simple defects",
"Moderate complex defects",
"Univentricular defects with Fontan circulation"
),
choiceValues = c("simple", "moderate", "fontan")
),
# Add "Next" button
actionButton("next", "Next")
Expand All @@ -20,7 +20,11 @@ ui <- fluidPage(
condition = "input.next > 0",
wellPanel(
h2("Select covariates"),
radioButtons("sex", "Sex", c("Male", "Female")),
radioButtons(
"sex", "Sex",
selected = character(0),
choiceNames = list("Male", "Female"), choiceValues = list(1L, 0L)
),
numericInput(
"height", "Height (cm)",
value = 100L, min = 0L, step = 1L, max = 200L
Expand All @@ -37,13 +41,7 @@ ui <- fluidPage(
condition = "input.submit > 0",
wellPanel(
h2("Results"),
"VO2 ml/min: ", textOutput("vo2_ml_min"),
"VO2 ml/kg/min: ", textOutput("vo2_ml_kg_min"),
"Heart rate: ", textOutput("heart_rate"),
"Ventilation: ", textOutput("ventilation"),
"Oxygen pulse: ", textOutput("oxygen_pulse"),
"VE/VCO2 slope: ", textOutput("ve_vco2_slope"),
"Breathing frequency: ", textOutput("breathing_frequency")
tableOutput("results_table")
)
)
)

0 comments on commit d1571ac

Please sign in to comment.