Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDrugIngredientCodes and non UTF-8 characters #233

Open
tleht opened this issue Dec 12, 2024 · 1 comment
Open

getDrugIngredientCodes and non UTF-8 characters #233

tleht opened this issue Dec 12, 2024 · 1 comment

Comments

@tleht
Copy link

tleht commented Dec 12, 2024

Describe the bug
Calling the function getDrugIngredientCodes with the argument "name" specified returns the following error

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

The error comes from lines 
    ingredientConcepts <- cdm$concept %>% dplyr::filter(.data$standard_concept == 
        "S") %>% dplyr::filter(.data$concept_class_id == "Ingredient") %>% 
        dplyr::select("concept_id", "concept_name", "concept_code") %>% 
        dplyr::collect()
    if (!is.null(name)) {
        ingredientConcepts <- ingredientConcepts %>% dplyr::filter(tidyWords(.data$concept_name) %in% 
            tidyWords(.env$name))
    }

The error is caused by the standard RxNorm Extension drug ingredient concept 1253507 "[ ¹⁸ F]AlF-NOTA-FAPI-04" present in our concept-table.

To Reproduce
getDrugIngredientCodes(cdm = cdm, name = "Adalimumab")

@tleht
Copy link
Author

tleht commented Dec 12, 2024

To be more exact, this seems to be an issue with the helper function tidyWords:

> tidyWords("[ ¹⁸ F]AlF-NOTA-FAPI-04")
Error in sub(re, "", x, perl = TRUE) : input string 1 is invalid UTF-8
In addition: Warning message:
In sub(re, "", x, perl = TRUE) :
  unable to translate '[ ¹â<81>¸ F]AlF-NOTA-FAPI-04' to UTF-8

More specifically the following lines:

    Encoding(words) <- "latin1"
    
    # some generic formatting
    workingWords <- trimws(words)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant