From 192a348e9883b603b2f07e749bc773432e69ef42 Mon Sep 17 00:00:00 2001 From: Arnfinn Hykkerud Steindal Date: Thu, 23 Jan 2025 10:37:51 +0100 Subject: [PATCH 1/3] linters_with_defaults i stedet for with_defaults (#51) --- .lintr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintr b/.lintr index 64018fd9..baddc717 100644 --- a/.lintr +++ b/.lintr @@ -1,4 +1,4 @@ -linters: with_defaults( +linters: linters_with_defaults( object_name_linter(c("camelCase", "snake_case")), cyclocomp_linter(complexity_limit = 35), line_length_linter(80)) From 6a2b504f1ffa2ea57aa4aa451fb68aff5c838eae Mon Sep 17 00:00:00 2001 From: Arnfinn Hykkerud Steindal Date: Thu, 23 Jan 2025 11:28:02 +0100 Subject: [PATCH 2/3] Fjernet funksjonen getProsPatientData (#52) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Denne funksjonen brukte den allerede fjernet funksjonen getProsPatient. Sistnevnte ble fjernet i commit 5914012a3da (PR #41, versjon 1.3.0). Fjernet også en test av getProsPatient --- DESCRIPTION | 2 +- NAMESPACE | 1 - R/getProsPatientData.R | 165 ---------------------------------- man/getProsPatientData.Rd | 47 ---------- tests/testthat/test-getData.R | 12 --- 5 files changed, 1 insertion(+), 226 deletions(-) delete mode 100644 R/getProsPatientData.R delete mode 100644 man/getProsPatientData.Rd diff --git a/DESCRIPTION b/DESCRIPTION index d4c3c0f8..8ea7b856 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,7 @@ License: GPL-3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Suggests: testthat, withr diff --git a/NAMESPACE b/NAMESPACE index 7bf8b6ca..d2b43fe6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -42,7 +42,6 @@ export(getProms) export(getPromsData) export(getPros) export(getProsData) -export(getProsPatientData) export(getRand12) export(getRand12Data) export(indik_akuttsuksess) diff --git a/R/getProsPatientData.R b/R/getProsPatientData.R deleted file mode 100644 index 7eb98c2d..00000000 --- a/R/getProsPatientData.R +++ /dev/null @@ -1,165 +0,0 @@ -#' Hent merget datasett -#' Hent datasett fra basis-skjema, prosedyreskjema, mce, og pasientskjema. Merge -#' sammen, filtrere på forløp der prosedyre er utført. Legge til utledete -#' variabler og nye variabler. -#' @param registryName Dersom verdien "test_ablanor_lokalt" leser vi inn -#' lokal RData-fil. Ellers er det SQL spørring -#' @param singleRow bools. TRUE bare metadata, FALSE hele datasettet -#' @param reshId Integer organization id -#' @param userRole String dummy/placeholder role. "LC" has access only -#' to local data (defined by reshId), "SC" has access to national data. -#' @param fromDate Character string of format YYYY-MM-DD with start date. Value -#' NULL if no filter on date. -#' @param toDate Character string of format YYYY-MM-DD with end date. Value -#' NULL if no filter on date. -#' @param ... Optional arguments to be passed to the function -#' -#' @return data.frame med rad per forløp og kolonner for variabler -#' @export - -getProsPatientData <- function(registryName, - singleRow = FALSE, - reshId = NULL, - userRole, - fromDate, - toDate, ...) { - - . <- "" - - d <- ablanor::getProsPatient(registryName, singleRow, reshId = reshId, - userRole = userRole, - fromDate = fromDate, toDate = toDate, ...) - - d_basereg <- d$basereg - d_pros <- d$pros - d_mce <- d$mce - d_patientlist <- d$patientlist - d_followup <- d$followup - - ## BEHANDLING AV DATABASEN I R: - # FELLES VARIABEL-NAVN I TO TABELLER (status for skjema etc) - # Vi angir en prefix for å få med variablene fra begge tabellene - d_basereg %<>% - dplyr::rename_at(dplyr::vars(.data$USERCOMMENT:.data$CREATEDBY), - function(x) { - paste0("basereg_", x) - }) - d_pros %<>% - dplyr::rename_at(dplyr::vars(.data$USERCOMMENT:.data$CREATEDBY), - function(x) { - paste0("pros_", x) - }) - - d_mce %<>% - dplyr::rename_at(dplyr::vars(.data$STATUS), - function(x) { - paste0("mce_", x) - }) - - - # MERGE DATASETTENE : - # NB: I Ablanor skal berre skjema som høyrer til forløp som har resultert i - # ein prosedyre (eventuelt ein avbroten ein) analyserast. Bruker derfor - # kun prosedyrar som finst i d_pros (Prosedyre-skjemaet) - - # REKKEFØLGE FILER: BASISDATA + PASIENT-DATA FØRST, PROSEDYRE ETTERPÅ - d_ablanor <- dplyr::right_join(d_basereg, - d_pros, - by = c("MCEID", "CENTREID")) %>% - # Legg til pasient_id til venstre - dplyr::right_join(d_mce %>% dplyr::select(.data$MCEID, - .data$PATIENT_ID, - .data$mce_STATUS), - ., - by = "MCEID") %>% - # Legg til pasientinformasjon til venstre - dplyr::right_join(d_patientlist %>% dplyr::rename("PATIENT_ID" = "ID"), - ., - by = "PATIENT_ID") %>% - dplyr::relocate(c("MCEID", "CENTREID"), .before = "PATIENT_ID") - - - # Forberede Followup-data - followup_data <- d_followup %>% - dplyr::rename("MCEID_FOLLOWUP" = .data$MCEID) %>% - dplyr::rename_at(dplyr::vars(.data$USERCOMMENT:.data$CREATEDBY, - .data$COMPLETE, .data$INCOMPLETE_REASON), - function(x) { - paste0("followup_", x) - }) %>% - # Kobler med alle forløp av type = 9, for å legge til parentmceid. - # (Parentmceid er forløpet som ligger til grunn for utsending av oppf.) - dplyr::left_join(., - d_mce %>% - dplyr::filter(.data$MCETYPE == 9) %>% - dplyr::select(.data$MCEID, .data$PARENTMCEID) %>% - dplyr::rename("MCEID_FOLLOWUP" = .data$MCEID, - "MCEID" = .data$PARENTMCEID), - by = "MCEID_FOLLOWUP") %>% - dplyr::relocate(.data$MCEID, .before = "MCEID_FOLLOWUP") - - # Sjekk at bare en oppfølging per forløp - # (I starten ble flere skjema sendt ut da er det nyeste skjema som gjelder) - followup_data %<>% - dplyr::group_by(.data$MCEID) %>% - dplyr::mutate(max_mceid_followup = max(.data$MCEID_FOLLOWUP)) %>% - dplyr::ungroup() %>% - dplyr::filter(.data$MCEID_FOLLOWUP == .data$max_mceid_followup) %>% - dplyr::select(- .data$max_mceid_followup) - - - # Legg til follow-up i pasient - prosedyre - data - d_ablanor %<>% - dplyr::left_join(., - followup_data, - by = c("MCEID", "CENTREID")) - - - names(d_ablanor) <- tolower(names(d_ablanor)) - - - # UTLEDETE VARIABLER - - # ALDER : - d_ablanor %<>% - ablanor::utlede_alder(.) %>% - ablanor::utlede_alder_75(.) %>% - ablanor::utlede_aldersklasse(.) - - # BMI klasse - d_ablanor %<>% - ablanor::utlede_bmi(.) %>% - ablanor::utlede_bmi_klasse(.) - - - # UKE, MÅNED, ÅR - d_ablanor %<>% ablanor::utlede_tidsvariabler(.) - - - # AFLI : ICD - d_ablanor %<>% ablanor::utlede_kateg_afli_aryt_i48(.) - - - # VT : KARDIOMYOPATI - d_ablanor %<>% ablanor::utlede_kardiomyopati(.) - - - # HJERTESVIKT OG REDUSERT EF - d_ablanor %<>% ablanor::utlede_hjertesvikt_redusert_ef(.) - - - # Indikator tamponade, indikator for avbrudd - d_ablanor %<>% - # ablanor::utlede_dager_sensur(df=., dager_sensur =?? ) %>% - # ablanor::indik_overlevelse30dg() %>% - ablanor::indik_tamponade(.) %>% - ablanor::indik_prom_klineff(.) %>% - ablanor::indik_ferdig_komplik(.) %>% - ablanor::indik_akuttsuksess(.) %>% - ablanor::indik_pacemaker(.) %>% - ablanor::indik_avbrudd(.) - - d_ablanor %>% dplyr::arrange(.data$mceid) - - -} diff --git a/man/getProsPatientData.Rd b/man/getProsPatientData.Rd deleted file mode 100644 index 78a1eeb9..00000000 --- a/man/getProsPatientData.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/getProsPatientData.R -\name{getProsPatientData} -\alias{getProsPatientData} -\title{Hent merget datasett -Hent datasett fra basis-skjema, prosedyreskjema, mce, og pasientskjema. Merge -sammen, filtrere på forløp der prosedyre er utført. Legge til utledete -variabler og nye variabler.} -\usage{ -getProsPatientData( - registryName, - singleRow = FALSE, - reshId = NULL, - userRole, - fromDate, - toDate, - ... -) -} -\arguments{ -\item{registryName}{Dersom verdien "test_ablanor_lokalt" leser vi inn -lokal RData-fil. Ellers er det SQL spørring} - -\item{singleRow}{bools. TRUE bare metadata, FALSE hele datasettet} - -\item{reshId}{Integer organization id} - -\item{userRole}{String dummy/placeholder role. "LC" has access only -to local data (defined by reshId), "SC" has access to national data.} - -\item{fromDate}{Character string of format YYYY-MM-DD with start date. Value -NULL if no filter on date.} - -\item{toDate}{Character string of format YYYY-MM-DD with end date. Value -NULL if no filter on date.} - -\item{...}{Optional arguments to be passed to the function} -} -\value{ -data.frame med rad per forløp og kolonner for variabler -} -\description{ -Hent merget datasett -Hent datasett fra basis-skjema, prosedyreskjema, mce, og pasientskjema. Merge -sammen, filtrere på forløp der prosedyre er utført. Legge til utledete -variabler og nye variabler. -} diff --git a/tests/testthat/test-getData.R b/tests/testthat/test-getData.R index de215054..f3c75b66 100644 --- a/tests/testthat/test-getData.R +++ b/tests/testthat/test-getData.R @@ -123,18 +123,6 @@ test_that("tables can be dumped", { rapbase::rapCloseDbConnection(con) }) -test_that("pros patient data can be read from db", { - check_db() - expect_equal(class(getProsPatient("testReg", singleRow = FALSE, - userRole = "SC", - fromDate = NULL, toDate = NULL)), - "list") - expect_equal(class(getProsPatient("testReg", singleRow = TRUE, - userRole = "SC", - fromDate = NULL, toDate = NULL)), - "list") -}) - test_that("rand12 data can be read from db", { check_db() expect_equal(class(getRand12("testReg", singleRow = FALSE, userRole = "SC")), "list") From 79ae9c4fdbba55fd26a99e0433daeacd78e9accc Mon Sep 17 00:00:00 2001 From: Arnfinn Hykkerud Steindal Date: Thu, 23 Jan 2025 13:25:06 +0100 Subject: [PATCH 3/3] Fornyet github actions (#53) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Stoppe jobber hvis det kommer ny commit * Like mange nocov start som nocov end (codecov-fix) * Bruker ubuntu-24.04 i stedet for ubuntu-20.04, macOS eller ubuntu-latest * Bruker r-lib/actions/setup-r-dependencies for å installere avhengigheter --- .github/.gitignore | 1 - .github/workflows/R-CMD-check.yaml | 47 +++++++++------------------- .github/workflows/docker.yml | 12 ++++--- .github/workflows/lint.yaml | 32 +++++++------------ .github/workflows/pkgdown.yaml | 27 +++++----------- .github/workflows/test-coverage.yaml | 30 ++++++------------ R/getData.R | 1 - 7 files changed, 51 insertions(+), 99 deletions(-) delete mode 100644 .github/.gitignore diff --git a/.github/.gitignore b/.github/.gitignore deleted file mode 100644 index 2d19fc76..00000000 --- a/.github/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index c47ddd3e..0cd2103b 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -10,6 +10,10 @@ on: name: R-CMD-check +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: R-CMD-check: runs-on: ${{ matrix.config.os }} @@ -22,8 +26,8 @@ jobs: config: - {os: windows-latest, r: 'release'} - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} - - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: ubuntu-24.04, r: 'release'} + - {os: ubuntu-24.04, r: 'devel'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true @@ -31,7 +35,7 @@ jobs: GITHUB_PAT: ${{ secrets.GH_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: @@ -53,50 +57,29 @@ jobs: else echo "GITHUB_ACTIONS_RUN_DB_UNIT_TESTS=false" >> $GITHUB_ENV fi + - name: Set up MySQL, ubuntu only if: runner.os == 'Linux' run: | sudo /etc/init.d/mysql start mysql -e 'CREATE DATABASE IF NOT EXISTS testdb;' -uroot -proot - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} + extra-packages: any::rcmdcheck + needs: check - name: Check env: _R_CHECK_CRAN_INCOMING_REMOTE_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check") + run: | + options(crayon.enabled = TRUE) + rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "error", check_dir = "check") shell: Rscript {0} - name: Upload check results if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ runner.os }}-r${{ matrix.config.r }}-results path: check diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ce91d028..0f7659fd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,15 +9,19 @@ on: schedule: - cron: '0 21 * * 6' # run every Saturday at 21 +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: push_to_registries: name: Push Docker image to docker hub - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 env: IMAGE_NAME: ${{ github.repository }} steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: R setup uses: r-lib/actions/setup-r@v2 - name: Build package (tarball) @@ -28,11 +32,11 @@ jobs: dockerfile: "Dockerfile" - name: Prepare tags id: docker_meta - uses: docker/metadata-action@v3.6.2 + uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE_NAME }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' uses: docker/login-action@v1 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fb75ba62..1b15a1e8 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,37 +8,27 @@ on: name: lint +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: lint: - runs-on: macOS-latest + runs-on: ubuntu-24.04 env: GITHUB_PAT: ${{ secrets.GH_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies - run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("lintr") - shell: Rscript {0} + extra-packages: any::lintr, local::. + needs: lint - name: Lint run: lintr::lint_package() shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: false diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index ee5b2aa5..daa3dfe4 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -5,9 +5,13 @@ on: name: pkgdown +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-24.04 env: GITHUB_PAT: ${{ secrets.GH_TOKEN }} steps: @@ -17,25 +21,10 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown", type = "binary") - shell: Rscript {0} + extra-packages: any::pkgdown, local::. + needs: website - name: Install package run: R CMD INSTALL . diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 1d8f9359..dd818813 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -8,9 +8,13 @@ on: name: test-coverage +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: test-coverage: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 env: GITHUB_PAT: ${{ secrets.GH_TOKEN }} GITHUB_ACTIONS_RUN_DB_UNIT_TESTS: true @@ -29,27 +33,11 @@ jobs: sudo /etc/init.d/mysql start mysql -e 'CREATE DATABASE IF NOT EXISTS testdb;' -uroot -proot - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - - name: Install dependencies - run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("covr") - shell: Rscript {0} + extra-packages: any::covr, any::xml2 + needs: coverage - name: Test coverage - run: covr::codecov() + run: covr::codecov(token = "${{ secrets.CODECOV_TOKEN }}") shell: Rscript {0} diff --git a/R/getData.R b/R/getData.R index c24f8359..d065e477 100644 --- a/R/getData.R +++ b/R/getData.R @@ -771,7 +771,6 @@ getBaseregPros <- function(registryName, d_mcepatientdata <- rapbase::loadRegData(registryName, query_mcepatientdata) - # nocov end } else { d_mce <- rapbase::loadRegData(registryName, query_mce) d_patientlist <- rapbase::loadRegData(registryName, query_patientlist)