2021-05-15 21:36:22 +02:00
|
|
|
# ==================================================================== #
|
|
|
|
# TITLE #
|
2022-10-05 09:12:22 +02:00
|
|
|
# AMR: An R Package for Working with Antimicrobial Resistance Data #
|
2021-05-15 21:36:22 +02:00
|
|
|
# #
|
|
|
|
# SOURCE #
|
|
|
|
# https://github.com/msberends/AMR #
|
|
|
|
# #
|
2022-10-05 09:12:22 +02:00
|
|
|
# CITE AS #
|
|
|
|
# Berends MS, Luz CF, Friedrich AW, Sinha BNM, Albers CJ, Glasner C #
|
|
|
|
# (2022). AMR: An R Package for Working with Antimicrobial Resistance #
|
|
|
|
# Data. Journal of Statistical Software, 104(3), 1-31. #
|
2023-05-27 10:39:22 +02:00
|
|
|
# https://doi.org/10.18637/jss.v104.i03 #
|
2022-10-05 09:12:22 +02:00
|
|
|
# #
|
2022-12-27 15:16:15 +01:00
|
|
|
# Developed at the University of Groningen and the University Medical #
|
|
|
|
# Center Groningen in The Netherlands, in collaboration with many #
|
|
|
|
# colleagues from around the world, see our website. #
|
2021-05-15 21:36:22 +02:00
|
|
|
# #
|
|
|
|
# This R package is free software; you can freely use and distribute #
|
|
|
|
# it for both personal and commercial purposes under the terms of the #
|
|
|
|
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
|
|
|
# the Free Software Foundation. #
|
|
|
|
# We created this package for both routine data analysis and academic #
|
|
|
|
# research and it was publicly released in the hope that it will be #
|
|
|
|
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
|
|
|
# #
|
|
|
|
# Visit our website for the full manual and a complete tutorial about #
|
|
|
|
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
|
|
|
|
# ==================================================================== #
|
|
|
|
|
|
|
|
expect_identical(ab_name("AMX", language = NULL), "Amoxicillin")
|
2021-07-07 20:34:05 +02:00
|
|
|
expect_identical(ab_atc("AMX"), "J01CA04")
|
2021-05-15 21:36:22 +02:00
|
|
|
expect_identical(ab_cid("AMX"), as.integer(33613))
|
|
|
|
|
|
|
|
expect_inherits(ab_tradenames("AMX"), "character")
|
|
|
|
expect_inherits(ab_tradenames(c("AMX", "AMX")), "list")
|
|
|
|
|
|
|
|
expect_identical(ab_group("AMX", language = NULL), "Beta-lactams/penicillins")
|
|
|
|
expect_identical(ab_atc_group1("AMX", language = NULL), "Beta-lactam antibacterials, penicillins")
|
|
|
|
expect_identical(ab_atc_group2("AMX", language = NULL), "Penicillins with extended spectrum")
|
|
|
|
|
|
|
|
expect_identical(ab_name("Fluclox", language = NULL), "Flucloxacillin")
|
|
|
|
expect_identical(ab_name("fluklox", language = NULL), "Flucloxacillin")
|
|
|
|
expect_identical(ab_name("floxapen", language = NULL), "Flucloxacillin")
|
|
|
|
expect_identical(ab_name(21319, language = NULL), "Flucloxacillin")
|
|
|
|
expect_identical(ab_name("J01CF05", language = NULL), "Flucloxacillin")
|
|
|
|
|
|
|
|
expect_identical(ab_ddd("AMX", "oral"), 1.5)
|
2021-08-16 21:54:34 +02:00
|
|
|
expect_identical(ab_ddd_units("AMX", "iv"), "g")
|
2021-05-15 21:36:22 +02:00
|
|
|
expect_identical(ab_ddd("AMX", "iv"), 3)
|
|
|
|
|
|
|
|
expect_identical(ab_name(x = c("AMC", "PLB"), language = NULL), c("Amoxicillin/clavulanic acid", "Polymyxin B"))
|
2022-08-28 10:31:50 +02:00
|
|
|
expect_identical(
|
|
|
|
ab_name(x = c("AMC", "PLB"), tolower = TRUE, language = NULL),
|
|
|
|
c("amoxicillin/clavulanic acid", "polymyxin B")
|
|
|
|
)
|
2021-05-15 21:36:22 +02:00
|
|
|
|
|
|
|
expect_inherits(ab_info("AMX"), "list")
|
|
|
|
|
|
|
|
expect_error(ab_property("amox", "invalid property"))
|
|
|
|
expect_error(ab_name("amox", language = "INVALID"))
|
|
|
|
expect_stdout(print(ab_name("amox", language = NULL)))
|
|
|
|
|
|
|
|
expect_equal(ab_name("21066-6", language = NULL), "Ampicillin")
|
2022-08-28 10:31:50 +02:00
|
|
|
expect_equal(
|
|
|
|
ab_loinc("ampicillin"),
|
|
|
|
c("21066-6", "3355-5", "33562-0", "33919-2", "43883-8", "43884-6", "87604-5")
|
|
|
|
)
|
2021-05-15 21:36:22 +02:00
|
|
|
|
|
|
|
expect_true(ab_url("AMX") %like% "whocc.no")
|
2023-02-14 10:41:01 +01:00
|
|
|
# expect_warning(ab_url("ASP"))
|
2021-08-16 21:54:34 +02:00
|
|
|
|
2022-08-28 10:31:50 +02:00
|
|
|
expect_identical(
|
2022-08-28 19:17:12 +02:00
|
|
|
colnames(set_ab_names(example_isolates[, 17:22])),
|
2022-08-28 10:31:50 +02:00
|
|
|
c("cefoxitin", "cefotaxime", "ceftazidime", "ceftriaxone", "gentamicin", "tobramycin")
|
|
|
|
)
|
|
|
|
expect_identical(
|
2022-08-28 19:17:12 +02:00
|
|
|
colnames(set_ab_names(example_isolates[, 17:22], language = "nl", snake_case = FALSE)),
|
2022-08-28 10:31:50 +02:00
|
|
|
c("Cefoxitine", "Cefotaxim", "Ceftazidim", "Ceftriaxon", "Gentamicine", "Tobramycine")
|
|
|
|
)
|
|
|
|
expect_identical(
|
2022-08-28 19:17:12 +02:00
|
|
|
colnames(set_ab_names(example_isolates[, 17:22], property = "atc")),
|
2022-08-28 10:31:50 +02:00
|
|
|
c("J01DC01", "J01DD01", "J01DD02", "J01DD04", "J01GB03", "J01GB01")
|
|
|
|
)
|
2021-12-09 10:48:25 +01:00
|
|
|
|
2023-02-18 14:56:06 +01:00
|
|
|
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) {
|
2022-08-28 10:31:50 +02:00
|
|
|
expect_identical(
|
|
|
|
example_isolates %>% set_ab_names(),
|
|
|
|
example_isolates %>% rename_with(set_ab_names)
|
|
|
|
)
|
|
|
|
expect_true(all(c(
|
|
|
|
"SXT", "nitrofurantoin", "fosfomycin", "linezolid", "ciprofloxacin",
|
|
|
|
"moxifloxacin", "vancomycin", "TEC"
|
|
|
|
) %in%
|
|
|
|
(example_isolates %>%
|
|
|
|
set_ab_names(NIT:VAN) %>%
|
|
|
|
colnames())))
|
2021-09-29 12:12:35 +02:00
|
|
|
}
|