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

lab2godata: app errors when match column is empty in Go.Data #11

Open
AmyMikhail opened this issue Sep 21, 2022 · 2 comments
Open

lab2godata: app errors when match column is empty in Go.Data #11

AmyMikhail opened this issue Sep 21, 2022 · 2 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@AmyMikhail
Copy link
Contributor

AmyMikhail commented Sep 21, 2022

godataR version / branch:

amymikhail_labimportfunctions

Reported by:

@sarahollis cc @jamesfuller-cdc

Problem statement:

If a user runs the lab2godata shiny app and selects e.g. First name, last name and date of birth to match on but there are no dates of birth entered in their active outbreak in Go.Data, the shiny app exits with an error after pressing the submit parameters button.

Proposed solution:

  1. Check what is returned by get_cases_epiwindow() when, as in this example, one of the core match columns is empty;
  2. Edit match_cases() to return 'no match' for that column if is.null(dob) or is.na(dob).

This should allow the generation of the match report and return 'no match' for that column. The main match columns that could be empty in a given Go.Data instance (and therefore affected by this error) are date of birth or document number. First name and surname will always be present (mandatory) as will age if date of birth is missing.

It might also be useful to return an informative stop error to the user if one of their selected match columns is completely empty. Something like:


stop("One of the match columns you selected has no data in Go.Data.  All match columns must be complete in both Go.Data case records and the laboratory records you are trying to match.  Please select a different combination of columns to match on.")

@AmyMikhail AmyMikhail added bug Something isn't working documentation Improvements or additions to documentation labels Sep 21, 2022
@AmyMikhail AmyMikhail self-assigned this Sep 21, 2022
@AmyMikhail AmyMikhail changed the title lab2godata shiny app: gives NA/NAN error when column to match on is empty in Go.Data lab2godata: app gives NA/NAN error when match column is empty in Go.Data Sep 21, 2022
@AmyMikhail AmyMikhail changed the title lab2godata: app gives NA/NAN error when match column is empty in Go.Data lab2godata: app gives error when match column is empty in Go.Data Sep 21, 2022
@AmyMikhail AmyMikhail changed the title lab2godata: app gives error when match column is empty in Go.Data lab2godata: app errors when match column is empty in Go.Data Sep 21, 2022
@AmyMikhail
Copy link
Contributor Author

AmyMikhail commented Sep 26, 2022

Update:

If a required column such as date of birth has no data in the active outbreak, get_cases_epiwindow() still returns cases within the selected date range, and the column with no data (in this case dob) is just filled with NA. So the problem lies in lab2godata_wrapper() which needs a suitable error added for this scenario.

Running the following code when there is no date of birth in the active outbreak in Go.Data:

# Import lab data:
labdata <- rio::import("inst/extdata/Lab_results_new.xlsx")

# Check lab2godata_wrapper when DOB is not filled:
r21labmatches <- godataR::lab2godata_wrapper(url = url,
                                    username = username,
                                    password = password,
                                    reason = "link new",
                                    daterangeformat = "ymd",
                                    epiwindow = 120,
                                    method = "fuzzy",
                                    matchcols = "names & dob",
                                    labdata = labdata,
                                    basedatecol = "sample_collection_date",
                                    firstnamecol = "firstname",
                                    lastnamecol = "surname",
                                    dobcol = "birthdate")

gives the following error:

Error in 1:ceiling(8 * length(table) * length(x)/limitMem) : 
  NA/NaN argument

@AmyMikhail
Copy link
Contributor Author

Further update:

The function is now producing a user friendly error which asks you to choose a different set of columns to match on if there is no data in one of the ones you have chosen. However for some reason, the error is appearing in the R console, along with the traceback (which is handy for me but probably too much for users). I will find out how to make the error appear in the app instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant