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

chemidplus qa of blank RN URL results in the registry number log #9

Open
meerapatelmd opened this issue Oct 12, 2020 · 0 comments
Open

Comments

@meerapatelmd
Copy link
Owner

QA Chemidplus RNL for search results that do not have an RN number

filter for "https://chem.nlm.nih.gov/chemidplus/rn/ " rn_url field

qa_concepts <-
chariot::queryAthena(
"
SELECT DISTINCT raw_concept
FROM chemidplus.registry_number_log
WHERE rn_url = 'https://chem.nlm.nih.gov/chemidplus/rn/'
",
skip_cache = TRUE
) %>%
unlist()

chariot::sendAthena(
sql_statement = "DELETE FROM chemidplus.registry_number_log WHERE rn_url = 'https://chem.nlm.nih.gov/chemidplus/rn/';"
)

concepts <- sample(qa_concepts)
errors <- vector()

for (i in 1:length(concepts)) {

    secretary::typewrite(secretary::blueTxt("QA Concept:"), concepts[i])

    Sys.sleep(5)

    conn <- chariot::connectAthena()
    output <-
            tryCatch(
                    skyscraper::log_registry_number(conn = conn,
                                                    raw_concept = concepts[i],
                                                    type = "contains",
                                                    sleep_time = 5)
                    ,
                    error = function(e) "Error")
    chariot::dcAthena(conn = conn)

    if (length(output) == 1) {
            if (output == "Error") {
                    errors <-
                            c(errors,
                              concepts[i])
            }
    }

    chariot::sendAthena(
            sql_statement = "DELETE FROM chemidplus.registry_number_log WHERE rn_url = 'https://chem.nlm.nih.gov/chemidplus/rn/';"
    )

    secretary::typewrite_progress(iteration = i,
                                  total = length(concepts),
                                  file = log_file)

    secretary::typewrite_error(length(errors))

}

if (length(errors)) {
skyscraper::log_errors(conn = a_conn,
schema = "chemidplus",
errors = errors,
search_type = "contains")
}

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