Skip to content

Commit

Permalink
Merge pull request #140 from darwin-eu/tidying
Browse files Browse the repository at this point in the history
license statements and dbms tests
  • Loading branch information
edward-burn authored May 8, 2024
2 parents d288146 + 1c017e9 commit ca9c76d
Show file tree
Hide file tree
Showing 18 changed files with 3,428 additions and 28 deletions.
2 changes: 1 addition & 1 deletion R/checks.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU (C)
# Copyright 2024 DARWIN EU (C)
#
# This file is part of CodelistGenerator
#
Expand Down
10 changes: 8 additions & 2 deletions R/codesFromConceptSet.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU (C)
# Copyright 2024 DARWIN EU (C)
#
# This file is part of CodelistGenerator
#
Expand Down Expand Up @@ -299,7 +299,13 @@ addDetails <- function(conceptList, cdm){
conceptList <- split(
x = conceptList %>% dplyr::select(!"concept_set"),
f = as.factor(conceptList$concept_set)
)}
)
}

for(i in seq_along(conceptList)){
conceptList[[i]] <- conceptList[[i]] %>%
dplyr::arrange(.data$concept_name)
}

return(conceptList)

Expand Down
16 changes: 16 additions & 0 deletions R/codesInUse.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2024 DARWIN EU (C)
#
# This file is part of CodelistGenerator
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Filter a codelist to keep only the codes used in the database
#'
#' @param x A codelist
Expand Down
2 changes: 1 addition & 1 deletion R/compareCodelists.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
#
Expand Down
2 changes: 1 addition & 1 deletion R/drugCodes.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
#
Expand Down
4 changes: 1 addition & 3 deletions R/getCandidateCodes.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU (C)
#
# This file is part of IncidencePrevalence
#
Expand All @@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.



#' Generate candidate codelist for the OMOP CDM
#'
#' @description
Expand Down
16 changes: 16 additions & 0 deletions R/getICD10StandardCodes.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2024 DARWIN EU (C)
#
# This file is part of IncidencePrevalence
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Get corresponding standard codes for ICD-10 chapters and sub-chapters
#'
#' @param cdm cdm_reference via CDMConnector
Expand Down
2 changes: 1 addition & 1 deletion R/getMappings.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
#
Expand Down
2 changes: 1 addition & 1 deletion R/inputValidation.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU (C)
#
# This file is part of IncidencePrevalence
#
Expand Down
2 changes: 1 addition & 1 deletion R/mockVocabRef.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU (C)
#
# This file is part of IncidencePrevalence
#
Expand Down
15 changes: 4 additions & 11 deletions R/runSearch.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU®
#
# This file is part of IncidencePrevalence
#
Expand Down Expand Up @@ -421,16 +421,9 @@ getMatches <- function(words,
for (j in seq_along(workingExclude)) {
if (nchar(workingExclude[j]) >= 1) {

if(inherits(workingConcepts, "tbl_sql")){
workingConcepts <- workingConcepts %>%
dplyr::filter(dplyr::sql(paste0("concept_name LIKE '%", .env$workingExclude[j], "%'")))
} else {
workingConcepts <- workingConcepts %>%
dplyr::filter(stringr::str_detect(
.data$concept_name,
.env$workingExclude[j]
))
}
cToSearch <- paste0("%", workingExclude[j], "%")
workingConcepts <- workingConcepts %>%
dplyr::filter(stringr::str_like(.data$concept_name, .env$cToSearch))

}
}
Expand Down
16 changes: 16 additions & 0 deletions R/summariseCodeUse.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2024 DARWIN EU (C)
#
# This file is part of IncidencePrevalence
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Summarise code use in patient-level data
#'
#' @param x List of concept IDs
Expand Down
16 changes: 11 additions & 5 deletions R/vocabUtilities.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 DARWIN EU®
# Copyright 2024 DARWIN EU (C)
#
# This file is part of IncidencePrevalence
#
Expand Down Expand Up @@ -390,14 +390,20 @@ getDescendantsOnly <- function(cdm, conceptId, ingredientRange, doseForm) {
}

getDescendantsAndAncestor <- function(cdm, conceptId, ingredientRange, doseForm) {
conceptIdDbTable <- omopgenerics::uniqueTableName()
cdm <- omopgenerics::insertTable(cdm = cdm,
name = conceptIdDbTable,
table = dplyr::tibble(ancestor_concept_id = as.integer(conceptId)),
overwrite = TRUE)

descendants <- cdm$concept_ancestor %>%
dplyr::inner_join(dplyr::tibble(ancestor_concept_id = as.integer(conceptId)),
by = "ancestor_concept_id",
copy = TRUE) %>%
dplyr::inner_join(cdm[[conceptIdDbTable]],
by = "ancestor_concept_id") %>%
dplyr::rename("concept_id" = "descendant_concept_id") %>%
dplyr::left_join(cdm$concept,
by = "concept_id")
by = "concept_id") %>%
dplyr::compute()
CDMConnector::dropTable(cdm, conceptIdDbTable)

descendants <- addIngredientCount(cdm = cdm, concepts = descendants) %>%
dplyr::filter(.data$ingredient_count >= !!ingredientRange[1],
Expand Down
120 changes: 120 additions & 0 deletions inst/cohorts2/GIBleed_male.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"ConceptSets": [
{
"id": 0,
"name": "Gastrointestinal hemorrhage",
"expression": {
"items": [
{
"concept": {
"CONCEPT_CLASS_ID": "Clinical Finding",
"CONCEPT_CODE": "74474003",
"CONCEPT_ID": 192671,
"CONCEPT_NAME": "Gastrointestinal hemorrhage",
"DOMAIN_ID": "Condition",
"INVALID_REASON": "V",
"INVALID_REASON_CAPTION": "Valid",
"STANDARD_CONCEPT": "S",
"STANDARD_CONCEPT_CAPTION": "Standard",
"VOCABULARY_ID": "SNOMED"
},
"includeDescendants": true
}
]
}
}
],
"PrimaryCriteria": {
"CriteriaList": [
{
"ConditionOccurrence": {
"CodesetId": 0
}
}
],
"ObservationWindow": {
"PriorDays": 0,
"PostDays": 0
},
"PrimaryCriteriaLimit": {
"Type": "All"
}
},
"QualifiedLimit": {
"Type": "First"
},
"ExpressionLimit": {
"Type": "First"
},
"InclusionRules": [
{
"name": "Male",
"expression": {
"Type": "ALL",
"CriteriaList": [],
"DemographicCriteriaList": [
{
"Gender": [
{
"CONCEPT_CODE": "M",
"CONCEPT_ID": 8507,
"CONCEPT_NAME": "MALE",
"DOMAIN_ID": "Gender",
"INVALID_REASON_CAPTION": "Unknown",
"STANDARD_CONCEPT_CAPTION": "Unknown",
"VOCABULARY_ID": "Gender"
}
]
}
],
"Groups": []
}
},
{
"name": "30 days prior observation",
"expression": {
"Type": "ALL",
"CriteriaList": [
{
"Criteria": {
"ObservationPeriod": {}
},
"StartWindow": {
"Start": {
"Coeff": -1
},
"End": {
"Days": 30,
"Coeff": -1
},
"UseEventEnd": false
},
"EndWindow": {
"Start": {
"Days": 0,
"Coeff": 1
},
"End": {
"Coeff": 1
},
"UseEventEnd": true
},
"Occurrence": {
"Type": 2,
"Count": 1
}
}
],
"DemographicCriteriaList": [],
"Groups": []
}
}
],
"CensoringCriteria": [],
"CollapseSettings": {
"CollapseType": "ERA",
"EraPad": 0
},
"CensorWindow": {},
"cdmVersionRange": ">=5.0.0"
}
Loading

0 comments on commit ca9c76d

Please sign in to comment.