Closed meerapatelmd closed 3 years ago
#' @title
#' Get CDM Table Concept Id Fields
#'
#' @return
#' Tibble of the concept id fields for each CDM Table
#'
#' @importFrom tibble tribble
#' @export
#' @rdname get.concept_id_fields
#' @family get functions
get.concept_id_fields <-
function(...) {
x <-
list(
ATTRIBUTE_DEFINITION = ("attribute_type_concept_id"),
CARE_SITE = c("place_of_service_concept_id"),
COHORT = c("drug_concept_id"),
COHORT_ATTRIBUTE = c("value_as_concept_id"),
COHORT_DEFINITION = c("definition_type_concept_id", "subject_concept_id"),
CONDITION_ERA = c("condition_concept_id"),
CONDITION_OCCURRENCE = c("condition_concept_id", "condition_type_concept_id", "condition_source_concept_id", "condition_status_concept_id"),
COST = c("cost_type_concept_id", "currency_concept_id", "revenue_code_concept_id", "drg_concept_id"),
DEATH = c("death_type_concept_id", "cause_concept_id", "cause_source_concept_id"),
DEVICE_EXPOSURE = c("device_concept_id", "device_type_concept_id", "device_source_concept_id"),
DOSE_ERA = c("drug_concept_id", "unit_concept_id"),
DRUG_ERA = c("drug_concept_id"),
DRUG_EXPOSURE = c("drug_concept_id", "drug_type_concept_id", "route_concept_id", "drug_source_concept_id"),
EPISODE = c("episode_concept_id", "episode_object_concept_id", "episode_type_concept_id", "episode_source_concept_id"),
EPISODE_EVENT = c("episode_event_field_concept_id"),
FACT_RELATIONSHIP = c("domain_concept_id_1", "domain_concept_id_2", "relationship_concept_id"),
MEASUREMENT = c("measurement_concept_id", "measurement_type_concept_id", "operator_concept_id", "value_as_concept_id", "unit_concept_id", "measurement_source_concept_id", "modifier_of_field_concept_id"),
METADATA = c("metadata_concept_id", "metadata_type_concept_id", "value_as_concept_id"),
NOTE = c("note_type_concept_id", "note_class_concept_id", "encoding_concept_id", "language_concept_id"),
NOTE_NLP = c("section_concept_id", "note_nlp_concept_id", "note_nlp_source_concept_id"),
OBSERVATION = c("observation_concept_id", "observation_type_concept_id", "value_as_concept_id", "qualifier_concept_id", "unit_concept_id", "observation_source_concept_id"),
OBSERVATION_PERIOD = c("period_type_concept_id"),
PAYER_PLAN_PERIOD = c("payer_concept_id", "payer_source_concept_id", "plan_concept_id", "plan_source_concept_id", "sponsor_concept_id", "sponsor_source_concept_id", "stop_reason_concept_id", "stop_reason_source_concept_id"),
PERSON = c("gender_concept_id", "race_concept_id", "ethnicity_concept_id", "gender_source_concept_id", "race_source_concept_id", "ethnicity_source_concept_id"),
PROCEDURE_OCCURRENCE = c("procedure_concept_id", "procedure_type_concept_id", "modifier_concept_id", "procedure_source_concept_id"),
PROVIDER = c("specialty_concept_id", "gender_concept_id", "specialty_source_concept_id", "gender_source_concept_id"),
REGIMEN = c("drug_concept_id"),
SOURCE_TO_CONCEPT_MAP = c("source_concept_id", "target_concept_id"),
SPECIMEN = c("specimen_concept_id", "specimen_type_concept_id", "unit_concept_id", "anatomic_site_concept_id", "disease_status_concept_id"),
VISIT_DETAIL = c("visit_detail_concept_id", "visit_detail_type_concept_id", "admitting_source_concept_id", "discharge_to_concept_id", "visit_detail_source_concept_id"),
VISIT_OCCURRENCE = c("visit_concept_id", "visit_type_concept_id", "visit_source_concept_id", "admitting_source_concept_id", "discharge_to_concept_id")
)
if (missing(...)) {
x
} else {
x[names(x) %in% unlist(rlang::list2(...))]
}
}
Moved it to R/get_test.r