Commit ebd4a6a6 authored by Petar Horki's avatar Petar Horki

feat: added the integerLevels parameter to the SetDF function(map character...

feat: added the integerLevels parameter to the SetDF function(map character factor levels to integer numbers, enabled by default). BREAKING CHANGE: the behaviour of the SetDF function has changed: character factor levels are now mapped to integer numbers per default. The original character factor levels are stored as labels.
parent 1b5f35eb
......@@ -481,10 +481,12 @@ Category.Equal <- function(catInA, catInB) {
#' constraints of the 'OpalValueType' function are inherited.\cr
#' duplicate entries are silently ignored.\cr
#'
#' @param dfIn The data frame to be set.
#' @param dfIn The data frame to be set.
#' @param integerLevels Map character factor levels to integer numbers\cr
#' (enabled by default)
#'
#' @export
SetDF <- function(dfIn) {
SetDF <- function(dfIn, integerLevels = 1) {
myNames <- names(dfIn)
for (myNameIter in myNames) {
......@@ -497,12 +499,24 @@ SetDF <- function(dfIn) {
Set(myDomain, 'isRepeatable', FALSE)
if(!is.null(levels(dfIn[[myNameIter]]))) {
myType <- typeof(levels(dfIn[[myNameIter]]))
if(1 == integerLevels) {
myType <- "integer"
myLevels <- unique(levels(dfIn[[myNameIter]]))
myLevels <- unique(levels(dfIn[[myNameIter]]))
for (myLevelIter in myLevels) {
Set(myDomain, 'Category', Category(Attribute(myLevelIter, 'label', 'en'), myLevelIter))
for (myOrderIter in 1:length(myLevels)) {
myLevelIter <- myLevels[myOrderIter]
Set(myDomain, 'Category', Category(Attribute(myLevelIter, 'label', 'en'), myOrderIter))
}
} else {
myType <- typeof(levels(dfIn[[myNameIter]]))
myLevels <- unique(levels(dfIn[[myNameIter]]))
for (myLevelIter in myLevels) {
Set(myDomain, 'Category', Category(Attribute(myLevelIter, 'label', 'en'), myLevelIter))
}
}
} else {
myType <- typeof(dfIn[[myNameIter]])
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataPackage.R
\name{AggConceptIDsByDomainID}
\alias{AggConceptIDsByDomainID}
\title{AggConceptIDsByDomainID}
\usage{
AggConceptIDsByDomainID(dataGroupDomainIDIn = GetDataGroupDomainIDs())
}
\arguments{
\item{dataGroupDomainIDIn}{dataGroupDomainID(s) of interest, defaults to all\cr
distinct dataGroupDomainIDs in the dictionary.\cr}
}
\description{
Aggregate concept IDS by the domain IDs.\cr
}
\details{
Assumption: the global dictionary has a `_DF_DOMAIN_NAME` column, which\cr
contains entries of the following form:\cr
'DomainID:ConceptID'(e.g. 'Condition:255573', 'Measurement:3027018')\cr
The AggConceptIDsByDomainID does the following:\cr
separate the DomainIDs from the ConceptIDs\cr
select the desired domain(s)\cr
aggregate the ConceptIDs by the DomainIDs\cr
Output is a data frame with the following columns:\cr
`_DF_DATA_GROUP_DOMAIN_NAME` ... character constant\cr
'aggConceptIDs' ... character constant\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Attribute.Equal}
\alias{Attribute.Equal}
\title{Attribute.Equal}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Attribute.FromDict}
\alias{Attribute.FromDict}
\title{Attribute.FromDict}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Attribute.IsAttribute}
\alias{Attribute.IsAttribute}
\title{Attribute.IsAttribute}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Attribute}
\alias{Attribute}
\title{Attribute}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Category.Equal}
\alias{Category.Equal}
\title{Category.Equal}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Category.FromDict}
\alias{Category.FromDict}
\title{Category.FromDict}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Category.IsCategory}
\alias{Category.IsCategory}
\title{Category.IsCategory}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Category}
\alias{Category}
\title{Category}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Utils.R
\name{Constants}
\alias{Constants}
\title{Constants}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataPackage.R
\name{DataGroupClosure}
\alias{DataGroupClosure}
\title{DataGroupClosure}
\usage{
DataGroupClosure(dataGroupDomainIDIn, aggConceptIDIn)
}
\arguments{
\item{aggConceptIDIn}{}
}
\description{
Create ...
}
\details{
Create ...
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataModels.R
\name{DataModel.BodyMeasurementTestData}
\alias{DataModel.BodyMeasurementTestData}
\title{DataModel.BodyMeasurementTestData}
\usage{
DataModel.BodyMeasurementTestData()
}
\description{
Fill the global dictionary variable with body measurement test data.
}
\details{
Fill the global `_myDict`variable with the following variable definitions:\cr
'Measurement:3024171', 'Measurement:3027018', and 'Measurement:40762499'.\cr
Returns the associated dictionary entries without printing them.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataModels.R
\name{DataModel.ConditionTestData}
\alias{DataModel.ConditionTestData}
\title{DataModel.ConditionTestData}
\usage{
DataModel.ConditionTestData()
}
\description{
Fill the global dictionary variable with condition test data.
}
\details{
Fill the global `_myDict`variable with definitions of the 'Condition:255573'\cr
and 'Condition:317009' variables.\cr
Returns the associated dictionary entries without printing them.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/DataModels.R
\name{DataModel.Demographics}
\alias{DataModel.Demographics}
\title{DataModel.Demographics}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataModels.R
\name{DataModel.SynpuffConditionTestData}
\alias{DataModel.SynpuffConditionTestData}
\title{DataModel.SynpuffConditionTestData}
\usage{
DataModel.SynpuffConditionTestData()
}
\description{
Fill the global dictionary variable with a selection of condition test\cr
data, also available in the synpuff data set.
}
\details{
Fill the global `_myDict`variable with the following variable definitions:\cr
'Condition:201826', 'Condition:319835'.\cr
Returns the associated dictionary entries without printing them.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataModels.R
\name{DataModel.SynpuffMeasurementTestData}
\alias{DataModel.SynpuffMeasurementTestData}
\title{DataModel.SynpuffMeasurementTestData}
\usage{
DataModel.SynpuffMeasurementTestData()
}
\description{
Fill the global dictionary variable with a selection of measurement test\cr
data, also available in the synpuff data set.
}
\details{
Fill the global `_myDict`variable with the following variable definitions:\cr
'Measurement:2212648:', 'Measurement:2212093'.\cr
Returns the associated dictionary entries without printing them.
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{DecorateICD10GM}
\alias{DecorateICD10GM}
\title{DecorateICD10GM}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{DecorateLOINC}
\alias{DecorateLOINC}
\title{DecorateLOINC}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Delete}
\alias{Delete}
\title{Delete}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{DeleteAllCohorts}
\alias{DeleteAllCohorts}
\title{DeleteAllCohorts}
\usage{
DeleteAllCohorts(baseUrl)
}
\arguments{
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Delete all Cohorts from Atlas
}
\details{
Delete all Cohorts from Atlas (via WebAPI)
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{DeleteAllConceptSets}
\alias{DeleteAllConceptSets}
\title{DeleteAllConceptSet}
\usage{
DeleteAllConceptSets(baseUrl)
}
\arguments{
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Delete all ConceptSet from Atlas
}
\details{
Delete all ConceptSet from Atlas (via WebAPI)
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{DeleteCohortDefinition}
\alias{DeleteCohortDefinition}
\title{DeleteCohortDefinition}
\usage{
DeleteCohortDefinition(id, baseUrl)
}
\arguments{
\item{id}{id of cohort}
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Delete Cohort from Atlas by ID
}
\details{
Delete Cohort from Atlas by ID (via WebAPI)
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{DeleteConceptSetDefinition}
\alias{DeleteConceptSetDefinition}
\title{DeleteConceptSetDefiniton}
\usage{
DeleteConceptSetDefinition(id, baseUrl)
}
\arguments{
\item{id}{id of cohort}
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Delete ConceptSet from Atlas by ID
}
\details{
Delete ConceptSet from Atlas by ID (via WebAPI)
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataPackage.R
\name{Factory.DataPackage}
\alias{Factory.DataPackage}
\title{Factory.DataPackage}
\usage{
Factory.DataPackage(dataGroupDomainIDIn)
}
\arguments{
\item{dataGroupDomainIDIn}{Set of dataGroupDomainIDs to map.}
}
\description{
Construct and return a function for mapping a data package.
}
\details{
Construct and return a function for mapping a data package composed of the\cr
following data groups:\cr
Condition(subset)\cr
Measurement(subset)\cr
Following (sub)methods are employed:\cr
`_MapClass.Get`\cr
Assumptions:\cr
the global dictionary exists, and contains metadata for the data package.
the SQL template file is located in the 'inst \ sql \ postgres' folder\cr
the 'dataGroupDomainIDIn' parameter takes on the following values(s)\cr
'Condition', 'Measurement'\cr
the following methods are defined\cr:
RenderCohortCondition, RenderMeasurementCohort\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Factory.Dict}
\alias{Factory.Dict}
\title{Factory.Dict}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{Factory.Map}
\alias{Factory.Map}
\title{Factory.Map}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Get}
\alias{Get}
\title{Get}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetAllCohortDefinitions}
\alias{GetAllCohortDefinitions}
\title{GetAllCohortDefinitions}
\usage{
GetAllCohortDefinitions(baseUrl)
}
\arguments{
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Get Cohort from Atlas via WebAPI by ID
}
\details{
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
\cr
Constraint:\cr
#
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetAllConceptSets}
\alias{GetAllConceptSets}
\title{GetAllConceptSets}
\usage{
GetAllConceptSets(baseUrl,
columnNames = `_GET_CONCEPT_SETS_COLUMN_NAMES`)
}
\arguments{
\item{baseUrl}{Url of WebAPI host}
}
\description{
Returns dataframe of all the concepts
}
\details{
Columns: CREATED_BY,MODIFIED_BY, CREATED_DATE, MODIFIED_DATE, ID, NAME
Create the following global variables for use as constants variable:
`_GET_CONCEPT_SETS_COLUMN_NAMES`
Assumptions: Connection to omop exists\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{GetChildren}
\alias{GetChildren}
\title{GetChildren}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetCohortDefinitionFromDatabase}
\alias{GetCohortDefinitionFromDatabase}
\title{GetCohortDefinitionFromDatabase}
\usage{
GetCohortDefinitionFromDatabase(id, connection,
sqlTemplate = `_GET_COHORT_DEFINITION_FROM_DATABASE_SQL_TEMPLATE_`,
databaseSchema = `_GET_COHORT_DEFINITION_FROM_DATABASE_SCHEMA_`)
}
\arguments{
\item{dataTypeIn}{The data type to be mapped.}
}
\description{
Gets cohort definition from database
}
\details{
Assumptions:\cr
Create the following global variables for use as constants variable:#
`_GET_COHORT_DEFINITION_FROM_DATABASE_SCHEMA_`
`_GET_COHORT_DEFINITION_FROM_DATABASE_SQL_TEMPLATE_`
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetCohortDefinitionFromWebApi}
\alias{GetCohortDefinitionFromWebApi}
\title{GetCohortDefinitionFromWebApi}
\usage{
GetCohortDefinitionFromWebApi(id, baseUrl)
}
\arguments{
\item{id}{ID of cohort definition (int/string)}
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Get Cohort from Atlas via WebAPI by ID
}
\details{
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
\cr
Constraint:\cr
#
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetConceptSetFromWebApi}
\alias{GetConceptSetFromWebApi}
\title{GetConceptSetDefinitionFromWebApi}
\usage{
GetConceptSetFromWebApi(id, baseUrl)
}
\arguments{
\item{id}{ID of concept set(int/string)}
\item{baseUrl}{URL of WebAPI Host}
}
\description{
Get Concept Set from Atlas via WebAPI by ID
}
\details{
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
\cr
Constraint:\cr
#
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetConceptSetsFromDatabase}
\alias{GetConceptSetsFromDatabase}
\title{GetConceptSetsFromDatabase}
\usage{
GetConceptSetsFromDatabase(connection,
sqlTemplate = `_GET_CONCEPT_SETS_SQL_TEMPLATE_`)
}
\arguments{
\item{connection}{connection to OMOP}
}
\description{
Returns dataframe of all the concepts
}
\details{
Columns: CONCEPT_SET_ID, CONCEPT_SET_NAME, CONCEPT_ID
Create the following global variables for use as constants variable:
#' `_GET_CONCEPT_SETS_SQL_TEMPLATE_`
`_GET_CONCEPT_SETS_DATABASE_SCHEMA_`
Assumptions: Connection to omop exists\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/DataPackage.R
\name{GetDataGroupDomainIDs}
\alias{GetDataGroupDomainIDs}
\title{GetDataGroupDomainIDs}
\usage{
GetDataGroupDomainIDs()
}
\description{
Returns distinct dataGroupDomainIDs from the global dictionary.\cr
}
\details{
Assumption: the global dictionary has a `_DF_DOMAIN_NAME` column, which\cr
contains entries of the following form:\cr
'DomainID:ConceptID'(e.g. 'Condition:255573', 'Measurement:3027018')\cr
The GetDataGroupDomainIDs function returns the distinct DomainIDs.\cr
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetIdFromCohortDefinitionName}
\alias{GetIdFromCohortDefinitionName}
\title{GetIdFromCohortDefinitionName}
\usage{
GetIdFromCohortDefinitionName(cohorts, name)
}
\arguments{
\item{cohorts}{dataframe of cohorts (created by GetCohorts())}
\item{name}{name of cohort}
}
\description{
Get Cohort from Atlas via WebAPI by ID
}
\details{
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
\cr
Constraint:\cr
#
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{GetIdFromConceptSetDefinitionName}
\alias{GetIdFromConceptSetDefinitionName}
\title{GetIdFromConceptSetDefinitionName}
\usage{
GetIdFromConceptSetDefinitionName(conceptSets, name)
}
\arguments{
\item{conceptSets}{dataframe of conceptSets (created by GetAllCohortDefinitions())}
\item{name}{name of conceptSet}
}
\description{
Get ConceptSets ID from Atlas via WebAPI by Name
}
\details{
baseUrl can be retrieved from config.yml
Assumptions: Connection to WebAPI exists\cr
\cr
Constraint:\cr
#
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{GetLoinc}
\alias{GetLoinc}
\title{Function name}
\title{GetLoinc}
\usage{
GetLoinc(loincCode, connection, searchChildren)
}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Variable.R
\name{GetVariables}
\alias{GetVariables}
\title{GetVariables}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/Dict.R
\name{Keys}
\alias{Keys}
\title{Keys}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{LoincCodeToUnit}
\alias{LoincCodeToUnit}
\title{LoincCodeToUnit}
......
% 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
% Please edit documentation in R/Utils.R
\name{OpalValueType}
\alias{OpalValueType}
\title{OpalValueType}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functions.R
% Please edit documentation in R/MapClass.R
\name{ParseICD}
\alias{ParseICD}
\title{Function name}
\title{ParseICD}
\usage{
ParseICD(sqlResults)
}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{ParseJson}
\alias{ParseJson}
\title{ParseJson}
\usage{
ParseJson(inputJsonFile)
}
\arguments{
\item{inputJsonFile}{Json file to be parsed}
}
\description{
Parse function for json file.
}
\details{
Create Dataframe from Json file.
Columns: (CONCEPT_CODE, CONCEPT_ID, CONCEPT_NAME,
DOMAIN_ID, STANDARD_CONCEPT, VOCABULARY_ID)
Assumptions: input json file is in correct format\cr
#
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/OHDSIWrappers.R
\name{ParseJson2}
\alias{ParseJson2}
\title{ParseJson2}
\usage{
ParseJson2(inputJsonFile)
}
\arguments{
\item{inputJsonFile}{Json file to be parsed}
}
\description{
Parse function for json file.
}
\details{
Create Dataframe from Json file.
Columns: (CONCEPT_CODE, CONCEPT_ID, CONCEPT_NAME,
DOMAIN_ID, STANDARD_CONCEPT, VOCABULARY_ID)