Skip to content

Commit

Permalink
Update ExtractConceptSetsInCohortDefinition.R
Browse files Browse the repository at this point in the history
  • Loading branch information
gowthamrao committed Sep 17, 2024
1 parent ae4d053 commit 6be7152
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions R/ExtractConceptSetsInCohortDefinition.R
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ extractConceptSetsInCohortDefinition <-
dplyr::mutate(conceptSetUsedInEntryEventToQuerySource = 0)

if (length(codeSetsIdsInPrimaryCriteria) > 0) {

conceptSetExpression <- conceptSetExpression |>
dplyr::select(-dplyr::all_of(c("conceptSetUsedInEntryEvent",
"conceptSetUsedInEntryEventToQuerySource"))) |>
Expand All @@ -373,13 +374,19 @@ extractConceptSetsInCohortDefinition <-
dplyr::distinct() |>
dplyr::mutate(conceptSetUsedInEntryEvent = 1),
by = "conceptSetId"
) |>
dplyr::left_join(
dplyr::tibble(conceptSetId = codeSetsIdsUsedToQuerySourceConceptsInPrimaryCriteria) |>
dplyr::distinct() |>
dplyr::mutate(conceptSetUsedInEntryEventToQuerySource = 1),
by = ("conceptSetId")
)
)

if (length(codeSetsIdsUsedToQuerySourceConceptsInPrimaryCriteria) > 0) {
conceptSetExpression <- conceptSetExpression |>
dplyr::left_join(
dplyr::tibble(conceptSetId = codeSetsIdsUsedToQuerySourceConceptsInPrimaryCriteria) |>
dplyr::distinct() |>
dplyr::mutate(conceptSetUsedInEntryEventToQuerySource = 1),
by = ("conceptSetId")
)
} else {
conceptSetExpression$conceptSetUsedInEntryEventToQuerySource <- as.integer(0)
}
}

uniqueConceptSets <- conceptSetExpression |>
Expand Down

0 comments on commit 6be7152

Please sign in to comment.