Commit cfe849a8 authored by Petar Horki's avatar Petar Horki

fix: restoring master branch to a stable state

parent c09412a3
......@@ -17,6 +17,4 @@ importFrom("purrr", "%>%")
importFrom("jsonlite", "toJSON")
exportPattern("^[[:alpha:]]+")
export(`_MapClass.Get`)
export(`_MapClass.Parse`)
export(`_MapClass.Set`)
This diff is collapsed.
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{Constants}
\alias{Constants}
\title{Constants}
\usage{
Constants()
}
\description{
Create global variables for use as constants.
}
\details{
Create the following global variables for use as constants variable:\cr
`_MAP_ICD_SQL_TEMPLATE`
`_MAP_ICD_DB_SCHEMA`
}
......@@ -2,7 +2,7 @@
% Please edit documentation in R/functions.R
\name{Factory.Dict}
\alias{Factory.Dict}
\title{Dict}
\title{Factory.Dict}
\usage{
Factory.Dict()
}
......
......@@ -15,8 +15,8 @@ the dictionary.}
dictionary.}
}
\description{
Given the domain(s) and key(s), get the values from the global dictionary.\cr
Returns the whole dictionary when called without parameters.
Given the domain(s) and key(s), get the matching entries from the global\cr
dictionary. Returns the whole dictionary when called without parameters.
}
\details{
Assumption: the global dictionary exists.
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{MapClass.Parse}
\alias{MapClass.Parse}
\title{MapClass.Parse}
\name{Keys}
\alias{Keys}
\title{Keys}
\usage{
MapClass.Parse(sqlResults)
Keys(domainIn)
}
\arguments{
\item{sqlResults}{The table returned by MapClass.Get()}
\item{valueIn}{The value(s)}
}
\description{
Parses through table and gets the values later needed for Set() method
Given the value(s), get the the matching entries from the global dictionary.
}
\details{
...\cr
Assumption: ...Results of MapClass.Get() are available
Assumption: the global dictionary exists.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{MapClass.Get}
\alias{MapClass.Get}
\title{MapClass.Get}
\usage{
MapClass.Get(sourceCode, connection, searchChildren)
}
\arguments{
\item{sourceCode}{The code to be mapped}
\item{connection}{The connection to omop database}
\item{searchChildren}{If TRUE will search through all children of code i.e. J44.*}
}
\description{
Gets ICD/OPS etc. code as input an yields results of sql query
}
\details{
...\cr
Assumption: ...ICD/OPS etc. lower level consists of leafs only.
"connection" parameter works.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{MapClass}
\alias{MapClass}
\title{MapClass}
\usage{
MapClass(sourceCode, connection, searchChildren)
}
\arguments{
\item{sourceCode}{code to be mapped}
\item{connection}{connection to database}
\item{searchChildren}{if TRUE, will search through child codes}
}
\description{
Template for executing multiple cohesive functions at once
}
\details{
Template for executing multiple cohesive functions at once
(i.e. MapClass.Get(), MapClass.Parse() and MapClass.Set())\cr
Assumption: ...Results of MapClass.Get() have been parsed and are available\cr
ICD/OPS etc. lower level consists of leafs only.\cr
"connection" parameter works.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
\name{MapClass.Set}
\alias{MapClass.Set}
\title{MapClass.Set}
\usage{
MapClass.Set(parsedResults)
}
\arguments{
\item{parsedResults}{vector which contains myDomain, myKeys and myValues}
}
\description{
Applies set() function for given domain and key-value pairs
}
\details{
...\cr
Assumption: ...Results of MapClass.Get() have been parsed and are available
}
......@@ -904,214 +904,3 @@ test_that("multiple variables can be defined automatically", {
expect_that(myEthnicityAttr$locale, equals(c("en", "en")))
})
#====================================================================
test_that("Getting sql results works", {
myFilePath = file.path("../..", "inst", "config.yml")
myOmopParams <- config::get(file = myFilePath, "omop")
# create OMOP connection
omopConn <- OpenOmopConnection(dbmsIn = myOmopParams$dbms,
serverIn = myOmopParams$server,
userIn = myOmopParams$user,
portIn = myOmopParams$port,
passwordIn = myOmopParams$password,
schemaIn = myOmopParams$schema)
sourceCode = 'J44' # NOTE: not a default value
searchChildren = FALSE
sqlResults <- `_MapClass.Get`(sourceCode, omopConn, searchChildren)
expect_that(sqlResults[,'SOURCE_CODE'], equals('J44'))
expect_that(sqlResults[,'TARGET_CONCEPT_ID'], equals(255573))
expect_that(sqlResults[,'CONCEPT_NAME'], equals('Chronic obstructive lung disease'))
expect_that(sqlResults[,'STANDARD_CONCEPT'], equals('S'))
expect_that(sqlResults[,'SOURCE_VOCABULARY_ID'], equals('ICD10GM'))
})
#====================================================================
test_that("Parsing sql results works", {
myFilePath = file.path("../..", "inst", "config.yml")
myOmopParams <- config::get(file = myFilePath, "omop")
# create OMOP connection
omopConn <- OpenOmopConnection(dbmsIn = myOmopParams$dbms,
serverIn = myOmopParams$server,
userIn = myOmopParams$user,
portIn = myOmopParams$port,
passwordIn = myOmopParams$password,
schemaIn = myOmopParams$schema)
sourceCode = 'J44' # NOTE: not a default value
searchChildren = FALSE
sqlResults <- `_MapClass.Get`(sourceCode, omopConn, searchChildren)
parsedResults <- `_MapClass.Parse`(sqlResults)
expect_that(parsedResults$myDomain, equals("Condition:255573"))
expect_that(parsedResults$myKeys, equals(c("entityType", "isRepeatable", "valueType",
"Attribute", "Attribute", "Attribute")))
expect_that(parsedResults$myValues[[1]], equals("Participant"))
expect_that(parsedResults$myValues[[2]], equals("FALSE"))
expect_that(parsedResults$myValues[[3]], equals("boolean"))
expect_that(parsedResults$myValues[[4]], equals(
tibble(
locale = "en",
name = "label",
value = "Primary diagnosis / Therapy / etc."
)
))
expect_that(parsedResults$myValues[[5]], equals(
tibble(
locale = "en",
name = "description",
value = "Chronic obstructive lung disease"
)
))
expect_that(parsedResults$myValues[[6]], equals(tibble(
locale = "en",
name = "source codes",
value = "ICD10GM: J44"
)))
})
#====================================================================
test_that("Parsed results are correctly set", {
myDictFun <- Factory.Dict()
myDict <- myDictFun()
myFilePath = file.path("../..", "inst", "config.yml")
myOmopParams <- config::get(file = myFilePath, "omop")
# create OMOP connection
omopConn <- OpenOmopConnection(dbmsIn = myOmopParams$dbms,
serverIn = myOmopParams$server,
userIn = myOmopParams$user,
portIn = myOmopParams$port,
passwordIn = myOmopParams$password,
schemaIn = myOmopParams$schema)
sourceCode = 'J44' # NOTE: not a default value
searchChildren = FALSE
sqlResults <- `_MapClass.Get`(sourceCode, omopConn, searchChildren)
parsedResults <- `_MapClass.Parse`(sqlResults)
setResults <- `_MapClass.Set`(parsedResults)
myDomain = setResults$myDomain
myKeys = setResults$myKeys
myValues = setResults$myValues
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[1]])
expect_that(myDict$domain, equals(myDomain))
expect_that(myDict$key, equals(myKeys[[1]]))
expect_that(myDict$value[[1]]$value, equals(myValues[[1]]))
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[2]])
expect_that(myDict$domain, equals(myDomain))
expect_that(myDict$key, equals(myKeys[[2]]))
expect_that(myDict$value[[1]]$value, equals(myValues[[2]]))
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[3]])
expect_that(myDict$domain, equals(myDomain))
expect_that(myDict$key, equals(myKeys[[3]]))
expect_that(myDict$value[[1]]$value, equals(myValues[[3]]))
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[4]])
expect_that(myDict$domain[[1]], equals(myDomain))
expect_that(myDict$key[[1]], equals(myKeys[[4]]))
expect_that(myDict$key[[2]], equals(myKeys[[4]]))
expect_that(myDict$key[[3]], equals(myKeys[[4]]))
expect_that(myDict$value[[1]], equals(myValues[[4]]))
expect_that(myDict$value[[2]], equals(myValues[[5]]))
expect_that(myDict$value[[3]], equals(myValues[[6]]))
})
#====================================================================
test_that("mapping a source ICD code works", {
myFilePath = file.path("../..", "inst", "config.yml")
myOmopParams <- config::get(file = myFilePath, "omop")
# create OMOP connection
omopConn <- OpenOmopConnection(dbmsIn = myOmopParams$dbms,
serverIn = myOmopParams$server,
userIn = myOmopParams$user,
portIn = myOmopParams$port,
passwordIn = myOmopParams$password,
schemaIn = myOmopParams$schema)
sourceCode = 'J44' # NOTE: not a default value
sqlResults <- `_MapClass.Get`(sourceCode, connection=omopConn, searchChildren=FALSE)
parsedResults <- `_MapClass.Parse`(sqlResults)
MapClass(sourceCode, connection = omopConn, searchChildren = FALSE)
myDomain <- parsedResults[[1]]
myKeys <- parsedResults[[2]]
myValues <- parsedResults[[3]]
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[1]])
expect_that(myDict$domain[[1]], equals(myDomain))
expect_that(myDict$key, equals(myKeys[[1]]))
expect_that(myDict$value[[1]]$value, equals(myValues[[1]]))
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[2]])
expect_that(myDict$domain, equals(myDomain))
expect_that(myDict$key, equals(myKeys[[2]]))
expect_that(myDict$value[[1]]$value, equals(myValues[[2]]))
myDict <- Get(domainIn = myDomain, keyIn = myKeys[[3]])
expect_that(myDict$domain, equals(myDomain))
expect_that(myDict$key, equals(myKeys[[3]]))
expect_that(myDict$value[[1]]$value, equals(myValues[[3]]))
# <<<<<<< HEAD
# myDict <- Get(domainIn = myDomain, keyIn = myKeys[[4]])
# expect_that(myDict$domain[[1]], equals(myDomain))
# expect_that(myDict$key[[1]], equals(myKeys[[4]]))
# expect_that(myDict$key[[2]], equals(myKeys[[4]]))
# expect_that(myDict$key[[3]], equals(myKeys[[4]]))
# expect_that(myDict$value[[1]], equals(myValues[[4]]))
# expect_that(myDict$value[[2]], equals(myValues[[5]]))
# expect_that(myDict$value[[3]], equals(myValues[[6]]))
# =======
#====================================================================
test_that("dynamic function calling works", {
AddFooPrefix <- function(param) {
return(paste0("Foo", param))
}
retVal <- do.call("AddFooPrefix", list("bar"))
expect_that(retVal, equals("Foobar"))
})
>>>>>>> master
# free resources
CloseOmopConnection(omopConn)
})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment