Skip to content

Commit

Permalink
Merge pull request #377 from onc-healthit/LANTERN-587-fix-profiles-tab
Browse files Browse the repository at this point in the history
Lantern 587 fix profiles tab
  • Loading branch information
vishnu-mettles authored Aug 8, 2024
2 parents 670df91 + 1daced2 commit 77906a0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 26 deletions.
27 changes: 1 addition & 26 deletions shinydashboard/lantern/modules/profilemodule.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ selected_fhir_endpoint_profiles <- reactive({
)
} else {
tagList(
reactable::reactableOutput(ns("no_filter_profile_table"))
DT::dataTableOutput("no_filter_profile_table")
)
}
}
Expand Down Expand Up @@ -90,29 +90,4 @@ selected_fhir_endpoint_profiles <- reactive({

)
})

output$no_filter_profile_table <- reactable::renderReactable({
reactable(
selected_fhir_endpoint_profiles(),
defaultColDef = colDef(
align = "center"
),
columns = list(
url = colDef(name = "Endpoint", minWidth = 300, sortable = TRUE, align = "left", html = TRUE),
profileurl = colDef(name = "Profile URL", minWidth = 300, align = "left", sortable = FALSE, aggregate = "count",
format = list(aggregated = colFormat(prefix = "Count: "))),
profilename = colDef(name = "Profile Name", minWidth = 200, sortable = FALSE),
resource = colDef(name = "Resource", sortable = FALSE),
fhir_version = colDef(name = "FHIR Version", sortable = FALSE, aggregate = "unique"),
vendor_name = colDef(name = "Certified API Developer Name", minWidth = 110, sortable = FALSE)
),
groupBy = "url",
striped = TRUE,
searchable = TRUE,
showSortIcon = TRUE,
highlight = TRUE,
defaultPageSize = 10

)
})
}
47 changes: 47 additions & 0 deletions shinydashboard/lantern/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,39 @@ library(dygraphs)

# Define server function
function(input, output, session) { #nolint

selected_fhir_endpoint_profiles <- reactive({
res <- isolate(app_data$supported_profiles())
req(input$fhir_version, input$vendor)

res <- res %>% filter(fhir_version %in% input$fhir_version)

if (input$vendor != ui_special_values$ALL_DEVELOPERS) {
res <- res %>% filter(vendor_name == input$vendor)
}

if (length(input$profile_resource) > 0) {
if (input$profile_resource != ui_special_values$ALL_RESOURCES) {
res <- res %>% filter(resource == input$profile_resource)
}
}

if (length(input$profile_resource) > 0) {
if (input$profile_resource != ui_special_values$ALL_RESOURCES) {
res <- res %>% filter(resource == input$profile_resource)
}
}

res <- res %>%
distinct(url, profileurl, profilename, resource, fhir_version, vendor_name) %>%
select(url, profileurl, profilename, resource, fhir_version, vendor_name) %>%
group_by(url) %>%
mutate(url = paste0("<a class=\"lantern-url\" tabindex=\"0\" aria-label=\"Press enter to open pop up modal containing additional information for this endpoint.\" onkeydown = \"javascript:(function(event) { if (event.keyCode === 13){event.target.click()}})(event)\" onclick=\"Shiny.setInputValue(\'endpoint_popup\',&quot;", url, "&&", "None", "&quot,{priority: \'event\'});\">", url, "</a>")) %>%
mutate_at(vars(-group_cols()), as.character)

return(res)
})

# Trigger this observer every time the session changes, which is on first load of page, and switch tab to tab stored in url
observeEvent(session, {
message(sprintf("I am in observe session *********************************** %s", database_fetch()))
Expand Down Expand Up @@ -1280,4 +1313,18 @@ output$endpoint_http_response_table <- reactable::renderReactable({
easyClose = TRUE
))
})

output$no_filter_profile_table <- DT::renderDataTable({
DT::datatable(
selected_fhir_endpoint_profiles(),
escape = FALSE,
colnames = c("Endpoint", "Profile URL", "Profile Name", "Resource", "FHIR Version", "Certified API Developer Name"),
options = list(
lengthMenu = c(5, 30, 50),
pageLength = 5,
scrollX = TRUE
)
)
})

}

0 comments on commit 77906a0

Please sign in to comment.