Open rbcavanaugh opened 2 months ago
It looks like this is because 'concept_code' is done a little differently for the SDOH (and maybe cope) surveys. In regular surveys (e.g., overall health), the concept code for an answer would be something like GeneralMentalHealth_Excellent
and we strip away the text before the underscore to get the answer.
However, we don't do this for SDOH and COPE, presumably because the text after the underscore (its just a 2-digit number) is meaningless.
if (isTRUE(clean_answers)) {
tmp <- dplyr::mutate(tmp,
value_source_value = dplyr::case_when(
CONTAINS_SUBSTR(.data$value_source_value, "cope_") ~ value_source_value,
CONTAINS_SUBSTR(.data$value_source_value, "SDOH_") ~ value_source_value,
!CONTAINS_SUBSTR(.data$value_source_value, "_") ~ value_source_value,
TRUE ~ REGEXP_EXTRACT(.data$value_source_value, ".+_(.+_*.*)")
)
)
}
So to fix this, we need to find a different way to map the concept_code (SDOH_20, for example) to the human readable response. It looks like aou_codebook has a way of pulling this information from the PPI vocab. looks like its the title of the answer concept or a standard to non-standard map?
Very crude attempt to fix: c186d3af63758136b1d438197b78ba22030b5ba5
Finally returning to this. @louisahsmith this returns an error:
> aou_survey(questions = 40192519)
Job complete
Billed: 0 B
Job complete
Billed: 0 B
Running job terra-vpc-sc-34a20a6f.job_Sn5Od9ImVUa_bFhwoLOYpO8T4at4.US ⠸ 8s
Job complete
Billed: 20.75 GB
Job complete
Billed: 0 B
Error in `bigrquery::bq_project_query()`:
! Job terra-vpc-sc-34a20a6f.job_RqSefm75pvhRSmg2l4avrpeugusX.US failed
✖ Syntax error: Expected ")" or "," but got identifier "t" at [100:29] [invalidQuery]
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
No cohort provided.
→ Pulling survey data for entire All of Us cohort.