darwin-eu / darwin-eu/CodelistGenerator

Issue with getDrugIngredientCodes when drug name [ ¹⁸ F]AlF-NOTA-FAPI-04 is in concepts

Open
#247 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
18
Forks
9
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The function `getDrugIngredientCodes `fails when the drug [ ¹⁸ F]AlF-NOTA-FAPI-04 (concept_id =1253507) is within the _concepts_ part of the cdm, since the function `tidyWords` within `filterIngredientConcepts` throws an error because it contains the `trimws` base function, which requires the format of the string to be in UTF-8. This is regardless if `options(encoding ="latin1")` was used before executing the function

**To Reproduce**
Steps to reproduce the behavior:
1. Create a CDM Object, add the particular concept_id and concept_name
2. Run
```
getDrugIngredientCodes(
cdm = cdm,
name = c("aspirin", "diclofenac"),
nameStyle = "{concept_name}"
)
```
3. See error, it will fail even if it's not a code you're looking for.

**Expected behavior**
Expected the function to return a codelist.

**Screenshots**
No screenshots, but here is the `rlang::last_trace`

```

Error in `dplyr::filter()`:
ℹ In argument: `tidyWords(.data$concept_name) %in% tidyWords(.env$name)`.
Caused by error in `sub()`:
! input string 29815 is invalid UTF-8
---
Backtrace:

1. ├─CodelistGenerator::getDrugIngredientCodes(...)
2. │ └─CodelistGenerator:::filterIngredientConcepts(...)
3. │ ├─dplyr::filter(...)
4. │ └─dplyr:::filter.data.frame(ingredientConcepts, tidyWords(.data$concept_name) %in% tidyWords(.env$name))
5. │ └─dplyr:::filter_rows(.data, dots, by)
6. │ └─dplyr:::filter_eval(...)
7. │ ├─base::withCallingHandlers(...)
8. │ └─mask$eval_all_filter(dots, env_filter)
9. │ └─dplyr (local) eval()
10. ├─tidyWords(.data$concept_name) %in% tidyWords(.env$name)
11. ├─CodelistGenerator:::tidyWords(.data$concept_name)
12. │ └─base::trimws(words)
13. │ ├─base (local) mysub(...)
14. │ │ └─base::sub(re, "", x, perl = TRUE)
15. │ │ └─base::is.factor(x)
16. │ └─base (local) mysub(paste0("^", whitespace, "+"), x)
17. │ └─base::sub(re, "", x, perl = TRUE)
18. └─base::.handleSimpleError(...)
19. └─dplyr (local) h(simpleError(msg, call))
20. └─rlang::abort(message, class = error_class, parent = parent, call = error_call)
```

**Desktop:**
- OS: Ubuntu 22
- Browser: Chrome

**Additional context**
Here's the Athena [link](https://athena.ohdsi.org/search-terms/terms/1253507), both the code and the drug name are supposedly standard. I'm guessing if there's one of these now, there'll probably be more.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.