Skip to content

Commit

Permalink
Merge pull request #54 from OHDSI/develop
Browse files Browse the repository at this point in the history
Release 0.5.7
  • Loading branch information
azimov authored May 2, 2024
2 parents 5810069 + 665b71a commit 1cff4f0
Show file tree
Hide file tree
Showing 48 changed files with 202 additions and 92 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ deploy.sh
compare_versions
^doc$
^Meta$
LICENSE
LICENSE
.git
..Rcheck
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ResultModelManager
Title: Result Model Manager (RMM) for OHDSI packages
Version: 0.5.6
Title: Result Model Manager
Version: 0.5.7
Authors@R:
person("Jamie", "Gilbert", , "[email protected]", role = c("aut", "cre"))
Description: Database data model management utilities for OHDSI packages.
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ResultModelManager 0.5.7

Bug fixes:

1. Added type conversion checking on upload of data where columns are characters but interpreted as numeric from reading
inserted data

# ResultModelManager 0.5.6

Expand Down
2 changes: 1 addition & 1 deletion R/ConnectionHandler.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CemConnector
#
Expand Down
2 changes: 1 addition & 1 deletion R/DataMigrationManager.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
42 changes: 39 additions & 3 deletions R/DataModel.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of OHdsiSharing
#
Expand Down Expand Up @@ -309,7 +309,7 @@ uploadChunk <- function(chunk, pos, env, specifications, resultsFolder, connecti
# Ensure dates are formatted properly
toDate <- specifications %>%
dplyr::filter(
tableName == env$tableName &
.data$tableName == env$tableName &
tolower(.data$dataType) == "date"
) %>%
dplyr::select("columnName") %>%
Expand All @@ -322,7 +322,7 @@ uploadChunk <- function(chunk, pos, env, specifications, resultsFolder, connecti

toTimestamp <- specifications %>%
dplyr::filter(
tableName == env$tableName &
.data$tableName == env$tableName &
grepl("timestamp", tolower(.data$dataType))
) %>%
dplyr::select("columnName") %>%
Expand All @@ -347,6 +347,10 @@ uploadChunk <- function(chunk, pos, env, specifications, resultsFolder, connecti

# Check if inserting data would violate primary key constraints:
if (!is.null(env$primaryKeyValuesInDb)) {
chunk <- formatChunk(
pkValuesInDb = env$primaryKeyValuesInDb,
chunk = chunk
)
primaryKeyValuesInChunk <- unique(chunk[env$primaryKey])
duplicates <-
dplyr::inner_join(env$primaryKeyValuesInDb,
Expand Down Expand Up @@ -791,3 +795,35 @@ loadResultsDataModelSpecifications <- function(filePath) {
assertSpecificationColumns(colnames(spec))
return(spec)
}


#' This helper function will convert the data in the
#' primary key values in the `chunk` which is read from
#' the csv file to the format of the primary key data
#' retrieved from the database (`pkValuesInDb`). The assumption made
#' by this function is that the `pkValuesInDb` reflect the proper data
#' types while `chunk` is the best guess from the readr
#' package. In the future, if we adopt strongly-types data.frames
#' this will no longer be necessary.
#'
#' Another assumption of this function is that we're only attempting to
#' recast to a character data type and not try to handle different type
#' conversions.
formatChunk <- function(pkValuesInDb, chunk) {
for (columnName in names(pkValuesInDb)) {
if (class(pkValuesInDb[[columnName]]) != class(chunk[[columnName]])) {
if (class(pkValuesInDb[[columnName]]) == "character") {
chunk <- chunk |> dplyr::mutate_at(columnName, as.character)
} else {
errorMsg <- paste0(
columnName,
" is of type ",
class(pkValuesInDb[[columnName]]),
" which cannot be converted between data frames pkValuesInDb and chunk"
)
stop(errorMsg)
}
}
}
return(chunk)
}
2 changes: 1 addition & 1 deletion R/PooledConnectionHandler.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
2 changes: 1 addition & 1 deletion R/QueryNamespace.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
2 changes: 1 addition & 1 deletion R/ResultExportManager.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
2 changes: 1 addition & 1 deletion R/ResultModelManager.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
2 changes: 1 addition & 1 deletion R/SchemaGenerator.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
2 changes: 1 addition & 1 deletion R/Utils.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of CohortDiagnostics
#
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ResultModelManager
==================
[![Build Status](https://github.com/OHDSI/ResultModelManager/workflows/R-CMD-check/badge.svg)](https://github.com/OHDSI/ResultModelManager/actions?query=workflow%3AR-CMD-check)
[![codecov.io](https://codecov.io/github/OHDSI/ResultModelManager/coverage.svg?branch=main)](https://codecov.io/github/OHDSI/ResultModelManager?branch=main)
[![codecov.io](https://app.codecov.io/github/OHDSI/ResultModelManager/coverage.svg?branch=main)](https://codecov.io/github/OHDSI/ResultModelManager?branch=main)

ResultModelManager (RMM) [HADES](https://ohdsi.github.io/Hades).
ResultModelManager (RMM) [HADES](https://ohdsi.github.io/Hades/).

Introduction
============
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

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

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

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

4 changes: 2 additions & 2 deletions docs/articles/CreatingMigrations.html

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

14 changes: 4 additions & 10 deletions docs/articles/ExampleProject.html

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

4 changes: 2 additions & 2 deletions docs/articles/PackageDesign.html

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

4 changes: 2 additions & 2 deletions docs/articles/UploadFunctionality.html

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

10 changes: 5 additions & 5 deletions docs/articles/UsingAnExportManager.html

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

4 changes: 2 additions & 2 deletions docs/articles/UsingConnectionHandlers.html

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

Loading

0 comments on commit 1cff4f0

Please sign in to comment.