Skip to content

Commit

Permalink
d
Browse files Browse the repository at this point in the history
  • Loading branch information
gowthamrao committed Aug 28, 2024
1 parent cec7f1e commit e7a9bf7
Show file tree
Hide file tree
Showing 17 changed files with 309 additions and 611 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

export(convertConceptSetDataFrameToExpression)
export(convertConceptSetExpressionToDataFrame)
export(createPheValuatorCohortsFromConceptSet)
export(extractConceptSetsInCohortDefinition)
export(extractConceptSetsInCohortDefinitionSet)
export(findOrphanConcepts)
Expand Down
2 changes: 1 addition & 1 deletion R/ConvertConceptSetDataFrameToExpression.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ convertConceptSetDataFrameToExpression <-
)
)
}

if (selectAllDescendants) {
conceptSetExpressionDataFrame <-
dplyr::bind_rows(
Expand Down
36 changes: 17 additions & 19 deletions R/ConvertConceptSetExpressionToDataFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,41 @@ convertConceptSetExpressionToDataFrame <-

items2 <- list()

errorMessage <-
"Given concept set expression R list object does not conform to expected structure. \n
It is a vector that is more than 3 levels deep."

for (i in (1:length(items))) {
df <- as.data.frame(items[[i]]) |>
dplyr::tibble()
names(df) <- stringr::str_replace(string = tolower(names(df)),
pattern = "concept.",
replacement = "")

if ('isExcluded' %in% names(df)) {
names(df) <- stringr::str_replace(
string = tolower(names(df)),
pattern = "concept.",
replacement = ""
)

if ("isExcluded" %in% names(df)) {
df <- df |>
dplyr::rename("is_excluded" = "isExcluded")
} else if ('isexcluded' %in% names(df)) {
} else if ("isexcluded" %in% names(df)) {
df <- df |>
dplyr::rename("is_excluded" = "isexcluded")
} else {
df <- df |>
dplyr::mutate(is_excluded = FALSE)
}
if ('includeMapped' %in% names(df)) {

if ("includeMapped" %in% names(df)) {
df <- df |>
dplyr::rename("include_mapped" = "includeMapped")
} else if ('includemapped' %in% names(df)) {
} else if ("includemapped" %in% names(df)) {
df <- df |>
dplyr::rename("include_mapped" = "includemapped")
} else {
df <- df |>
dplyr::mutate(include_mapped = FALSE)
}
if ('includeDescendants' %in% names(df)) {

if ("includeDescendants" %in% names(df)) {
df <- df |>
dplyr::rename("include_descendants" = "includeDescendants")
} else if ('includedescendants' %in% names(df)) {
} else if ("includedescendants" %in% names(df)) {
df <- df |>
dplyr::rename("include_descendants" = "includedescendants")
} else {
Expand All @@ -101,9 +99,9 @@ convertConceptSetExpressionToDataFrame <-
}
items2[[i]] <- df
}
conceptSetExpressionDetails <- dplyr::bind_rows(items2) |>
SqlRender::snakeCaseToCamelCaseNames() |>

conceptSetExpressionDetails <- dplyr::bind_rows(items2) |>
SqlRender::snakeCaseToCamelCaseNames() |>
tidyr::replace_na(
replace = list(
isExcluded = FALSE,
Expand Down
Loading

0 comments on commit e7a9bf7

Please sign in to comment.