Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix falk #42

Merged
merged 10 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ablanor
Title: AblaNor- Rapporteket
Version: 1.1.1
Version: 1.2.0
Authors@R: c(
person(given = "Kristina",
family = "Skaare",
Expand All @@ -20,7 +20,7 @@ License: GPL-3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Suggests:
testthat,
withr
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ablanor 1.2.0
Små justeringer på Rapporteket etter overgang til FALK som innloggings-
portal i prod.
En ny reshid.
Bruker egendefinerte (finere) sykehusnavn i Rapporteket og i rapporter.

# ablanor 1.1.1

* Installer Rapbase fra github i stedet for cran. Rapbase ble fjernet fra Cran i slutten av juni 2023 fordi en test feilet. Testen er fikset nå, men Rapbase er ikke publisert på nytt enda. Enn så lenge må pakken installeres direkte fra github.
Expand Down
6 changes: 4 additions & 2 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app_server <- function(input, output, session) {
registryName <- "ablanor"
mapOrgId <- ablanor::getNameReshId(registryName)
reshId <- rapbase::getUserReshId(session)
hospitalName <- ablanor::getHospitalName(registryName, reshId)
hospitalName <- ablanor::getHospitalName(registryName, reshId, shortName = FALSE, newNames = TRUE)
userFullName <- rapbase::getUserFullName(session)
userRole <- rapbase::getUserRole(session)
userOperator <- "Test Operatoresen"
Expand Down Expand Up @@ -314,7 +314,9 @@ app_server <- function(input, output, session) {

# Values shared among subscriptions and dispatchment
orgs <- ablanor::getNameReshId(registryName = registryName,
asNamedList = TRUE)
asNamedList = TRUE,
shortName = FALSE,
newNames = TRUE)

# Abonnement
subReports <- list(
Expand Down
23 changes: 20 additions & 3 deletions R/getData.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ getDataDump <- function(registryName, tableName, fromDate, toDate,

#' @rdname getData
#' @export
getNameReshId <- function(registryName, asNamedList = FALSE) {
getNameReshId <- function(registryName, asNamedList = FALSE, shortNames = FALSE, newNames = FALSE) {
arnfinn marked this conversation as resolved.
Show resolved Hide resolved

query <- "
SELECT
Expand All @@ -132,6 +132,15 @@ GROUP BY

res <- rapbase::loadRegData(registryName, query)

if(newNames){
res %<>%
dplyr::mutate(centreid = id) %>%
ablanor::legg_til_sykehusnavn(., short = shortNames) %>%
dplyr::select(id, sykehusnavn) %>%
dplyr::rename("name" = "sykehusnavn") %>%
dplyr::filter(!is.na(name))
}

if (asNamedList) {
res <- stats::setNames(res$id, res$name)
res <- as.list(res)
Expand All @@ -142,7 +151,7 @@ GROUP BY

#' @rdname getData
#' @export
getHospitalName <- function(registryName, reshId, shortName = FALSE) {
getHospitalName <- function(registryName, reshId, shortName = FALSE, newNames = FALSE) {

if (shortName) {
dbField <- "CENTRESHORTNAME"
Expand All @@ -158,7 +167,15 @@ FROM
WHERE
ID = ", reshId, ";")

name <- rapbase::loadRegData(registryName, query)[1, ]
if(newNames) {
name <- ablanor::legg_til_sykehusnavn(
df = data.frame(centreid = reshId),
short = shortName) %>%
dplyr::pull(sykehusnavn)
} else {
name <- rapbase::loadRegData(registryName, query)[1, ]
}


if (is.na(name)) {
warning(paste("Resh ID", reshId, "did not match any names!"))
Expand Down
6 changes: 3 additions & 3 deletions R/legg_til_sykehusnavn.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' @export
#' @examples
#' df <- data.frame(centreid = c(102966, 104284, 4214492, 700328, 700728))
#' df <- data.frame(centreid = c(102966, 104284, 4214492, 700328, 4219765))
#' ablanor::legg_til_sykehusnavn(df = df, short = TRUE)
legg_til_sykehusnavn <- function(df, short = TRUE) {

Expand All @@ -25,7 +25,7 @@ legg_til_sykehusnavn <- function(df, short = TRUE) {
centreid == 104284 ~ "St.Olavs",
centreid == 4214492 ~ "AHus",
centreid == 700328 ~ "OUS",
centreid == 700728 ~ "UNN",
centreid == 4219765 ~ "UNN",
TRUE ~ NA_character_))
} else {
df %>% dplyr::mutate(
Expand All @@ -34,7 +34,7 @@ legg_til_sykehusnavn <- function(df, short = TRUE) {
centreid == 104284 ~ "St.Olavs Hospital",
centreid == 4214492 ~ "AHus Gardermoen",
centreid == 700328 ~ "Oslo Universitetssykehus",
centreid == 700728 ~ "Universitetssykehuset Nord-Norge",
centreid == 4219765 ~ "Universitetssykehuset Nord-Norge",
TRUE ~ NA_character_))
}
}
9 changes: 7 additions & 2 deletions man/getData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/legg_til_sykehusnavn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-legg_til_sykehusnavn.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
test_that("legg til sykehusnavn works", {

df <- data.frame(centreid = c(102966, 104284, 4214492, 700328, 700728,
df <- data.frame(centreid = c(102966, 104284, 4214492, 700328, 4219765,
NA, 123456))


Expand Down