MatchAllWhere.RdA class that creates the indicator in SQL form which evaluates whether all of the target columns match the specified definition codes under the conditions defined by the filter columns and lookup values. The matching will only be applied to those target columns that are in the same order as the filter columns and satisfy the conditions in lookup values, ensuring that the indicator is TRUE only if every such target column satisfies the matching criteria.
MatchAllWhere(
rule_engine,
indicator_name,
target_columns,
definition_codes,
filter_columns,
lookup_values,
regex_prefix_search = FALSE
)Object of class RuleEngine.The rule engine containing the dataset where the indicators will be applied.
Character. A string representing the name of the indicator, assigned to the `name` property.
List of characters. Column names where the values from `definition_codes` will be searched. Searches will only be performed in the corresponding column of `target_columns` if the condition is met in the column of the same index in `filter_columns`.
List of characters. A set of codes used to define the matching criteria applied to `target_columns`.
List of characters. Column names that define the conditions under which the `lookup_values` must hold. These conditions are evaluated in order and are directly linked to the columns of `target_columns`.
List of characters.A list of values used to define logical conditions that must be satisfied in the order of `filter_columns`.
Logical. Logical value indicating whether to use regex-based prefix searches (`TRUE`) or exact matches (`FALSE`).
Returns an instance of MatchAnyWhere with a generated SQL rule stored in the `sql_rule` field.
if (FALSE) { # \dontrun{
hosp_dataframe <- data.frame(
episode_id = c(1, 2, 3),
age = c(45, 60, 32),
sex = c("M", "F", "M"),
diagnosis1 = c("F10.10", "I20", "I60"),
diagnosis2 = c("E11", "J45", "I25"),
diagnosis3 = c("I60", "K35", "F10.120"),
present_on_admission_d1 = c(FALSE,FALSE,FALSE),
present_on_admission_d2 = c("No","Yes","No"),
present_on_admission_d3 = c(FALSE,TRUE,TRUE)
)
reng <- RuleEngine(hosp_dataframe,"episode_id")
target_columns <- c("diagnosis2","diagnosis3")
definition_codes <- c("F10.10","F10.11","F10.120","F10.121")
filter_columns <- c("present_on_admission_d2","present_on_admission_d3")
lookup_values <- c("Yes", "true")
alcohol_indicator_poa <- IndicR4Health::MatchAllWhere(
reng,
"alcohol_i_poa",
target_columns,
definition_codes ,
filter_columns,
lookup_values
)
# Codes to look for in target_columns (start with "F10")
alcohol_i_regex_poa <- IndicR4Health::MatchAllWhere(
reng,
"alcohol_i_regex_poa",
target_columns,
c("F10") ,
filter_columns,
lookup_values,
regex_prefix_search = TRUE
)
indicators_list <- list(alcohol_indicator_poa, alcohol_i_regex_poa)
IndicR4Health::RunIndicators(reng,indicators_list, append_results = FALSE, csv_path="./results.csv")
} # }