R Under development (unstable) (2025-10-08 r88906 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(medicalcoder) > > # lookup exact vs regex consistency > lx <- lookup_icd_codes(c("E11.9","I50.9"), regex = FALSE) > lr <- lookup_icd_codes(c("^E11\\.9$","^I50\\.9$"), regex = TRUE) > stopifnot(all(lx$full_code %in% lr$full_code), + all(lr$full_code %in% lx$full_code)) > > # the following used to give an error: > # Error in merge.data.frame(x = input, y = matches, all.x = TRUE, by = c(ifelse(regex, : > # negative length vectors are not allowed > m <- tryCatch(lookup_icd_codes(x = "", regex = TRUE), error = function(e) e) > stopifnot(inherits(m, "error")) > > # out of the data.frame should be the same columns with or without matches > m1 <- lookup_icd_codes(x = "", regex = FALSE) > m2 <- lookup_icd_codes(x = "^$", regex = TRUE) > m3 <- lookup_icd_codes(x = "C84", regex = FALSE) > m4 <- lookup_icd_codes(x = "^C84$", regex = TRUE) > > expected_regex_false_names <- + c("input_code", "match_type", "icdv", "dx", "full_code", "code", "src", "known_start", "known_end", "assignable_start", "assignable_end") > expected_regex_true_names <- + c("input_regex", "match_type", "icdv", "dx", "full_code", "code", "src", "known_start", "known_end", "assignable_start", "assignable_end") > > stopifnot( + identical(names(m1), expected_regex_false_names), + identical(names(m2), expected_regex_true_names), + identical(names(m3), expected_regex_false_names), + identical(names(m4), expected_regex_true_names) + ) > > ################################################################################ > # End of File # > ################################################################################ > > proc.time() user system elapsed 12.29 0.84 13.12