Skip to contents

Labs, vitals and medication classes are defined by concept-set files in inst/extdata/concept_sets/<domain>/<name>.json, in the format ATLAS, Circe and Capr use (list(items = list(list(concept = list(CONCEPT_ID, CONCEPT_CODE, VOCABULARY_ID), includeDescendants, includeMapped, isExcluded))))), so a set can be pasted into ATLAS and a set exported from ATLAS can be dropped in. manifest.json lists each domain's sets in feature-column order and carries the version.

Usage

concept_set_manifest()

list_concept_sets(domain = NULL)

load_concept_set(name)

load_concept_sets(domain)

concept_set_codes(expression, vocabulary = "LOINC")

concept_set_ids(expression)

concept_set_from_codes(
  codes,
  vocabulary = "LOINC",
  include_descendants = FALSE
)

concept_set_from_ids(ids, include_descendants = TRUE)

resolve_concept_sets(con, sets, warn = TRUE)

loinc_coverage(con, sets, cohort = NULL, pre_days = 0, min_share = 0.01)

Arguments

domain

One of "labs", "vitals", "medications_ederri", "medications".

name

"<domain>/<name>" of a bundled set, or a path to an ATLAS / Circe JSON file.

expression

A concept-set expression (list(items = ...)).

vocabulary

Vocabulary of the codes.

codes, ids

Codes of one vocabulary, or concept ids.

include_descendants

Whether each item includes its descendants.

con

A DBI connection holding concept (and concept_ancestor, concept_relationship when needed).

sets

A named list of expressions.

warn

Whether unknown codes and a missing concept_ancestor raise a warning.

cohort

A data frame with subject_id, cohort_start_date, cohort_end_date (only in-stay rows are counted), or NULL.

pre_days

Days before admission that count as in stay.

min_share

Smallest share of an analyte's rows a missed code must hold to be listed.

Value

load_concept_set(): a list with name, domain, expression. load_concept_sets(): a named list of expressions. concept_set_codes(), concept_set_ids(): vectors. resolve_concept_sets(): a data frame name, concept_id. loinc_coverage(): a data frame name, concept_code, concept_name, same_property, blood, share, or NULL when the vocabulary has no LOINC part links.

Details

resolve_concept_sets() gives the concept ids the way Circe does: each item's concept (looked up by VOCABULARY_ID + CONCEPT_CODE when it has no id), plus its descendants in concept_ancestor when includeDescendants, plus the source concepts that map to those (Maps to) when includeMapped, minus the same for excluded items.

A LOINC lab test has no descendants, so the codes of one lab are linked through their LOINC parts instead: loinc_coverage() lists the codes a site's in-stay rows use for a set's analyte (same Has component) that the set does not hold, and extract_benchmark_features() turns each into a concept_set_coverage warning. The Python script scripts/build_concept_sets.py expands the bundled lab sets from the vocabulary.