msberends / AMR

Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by using evidence-based methods, as described in https://doi.org/10.18637/jss.v104.i03.

Home Page:https://msberends.github.io/AMR/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prevent unknown ATC codes from getting coerced

msberends opened this issue · comments

ATC codes that are not in the antibiotics data set, should not be coerced, but should return this:

AMR/R/ab.R

Lines 454 to 460 in 70a07ba

# take failed ATC codes apart from rest
x_unknown_ATCs <- x_unknown[x_unknown %like% "[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]"]
x_unknown <- x_unknown[!x_unknown %in% x_unknown_ATCs]
if (length(x_unknown_ATCs) > 0 & fast_mode == FALSE) {
warning_("in `as.ab()`: these ATC codes are not (yet) in the antibiotics data set: ",
vector_and(x_unknown_ATCs), ".")
}

For example, this should be not happening (since J01CR50 is not piptazo, see #55):

ab_info("J01CR50")
#> $ab
#> [1] "TZP"
#> 
#> $cid
#> [1] 461573
#> 
#> $name
#> [1] "Piperacilline/tazobactam"
#> 
#> $group
#> [1] "Beta-lactams/penicillines"
#> 
#> $atc
#> [1] "J01CR05"
#> 
#> $atc_group1
#> [1] "Beta-lactam antibacterials, penicillins"
#> 
#> $atc_group2
#> [1] "Combinations of penicillins, incl. beta-lactamase inhibitors"
#> 
#> $tradenames
#> [1] ""           "tazocel"    "tazocillin" "tazocin"    "zosyn"     
#> 
#> $loinc
#> character(0)
#> 
#> $ddd
#> $ddd$oral
#> $ddd$oral$amount
#> [1] NA
#> 
#> $ddd$oral$units
#> [1] NA
#> 
#> 
#> $ddd$iv
#> $ddd$iv$amount
#> [1] 14
#> 
#> $ddd$iv$units
#> [1] "g"
#> 
#> 
#> 
#> Warning messages:
#> 1: in `ab_ddd()`: DDDs of some combined products are available for different dose combinations and not (yet) part of the AMR package.Please
#> refer to the WHOCC website:
#> www.whocc.no/ddd/list_of_ddds_combined_products/ 
#> 2: in `ab_ddd_units()`: DDDs of combined products are available for different dose combinations and not (yet) part of the AMR
#> package.Please refer to the WHOCC website:
#> www.whocc.no/ddd/list_of_ddds_combined_products/ 
#> 3: in `ab_ddd_units()`: DDDs of combined products are available for different dose combinations and not (yet) part of the AMR
#> package.Please refer to the WHOCC website:
#> www.whocc.no/ddd/list_of_ddds_combined_products/