COHHIO / COHHIO_HMIS

Code for pulling in HMIS data, writing it out to reports
GNU Affero General Public License v3.0
10 stars 5 forks source link

Rme Utilization pulls in records by served_between() instead of stayed_between() #131

Closed kiadso closed 3 years ago

kiadso commented 3 years ago

When you select a provider that has a client who has an Entry Date in one month and a Move in Date in another month and then you look at the month they entered (but didn't move in yet), the record pulls in with a null for '# of bed nights in [month]" This causes the infobox that's meant to calculate utilization to return "NA" when it should not.

To Reproduce

  1. run it on Merici PSH, January 2020
  2. check last record, client 266812
  3. it should either not be there or it should show a 0 for # of bed nights

Expected behavior When this happens, the record should either not be there or it should show a 0 for # of bed nights

Strategy I can't just switch it to stayed_between() because there's no "EntryAdjust" in the utilizers_clients df. Could either add this or just overwrite the NA's with zeros and show the record, since they had entered that month.

yogat3ch commented 3 years ago

I'm attempting to reproduce #131. I'm unable to find Merici as a provider. Maybe this data was added retrospectively in the merge of the new region because I'm not seeing it in my outdated dataset?

I think the part surrounded in asterisk marks should fix it, but since I am not able to reproduce I don't know for sure. It would need to be added in both the code for the datatable and infobox.

a <- utilizers_clients %>%
        filter(
          ProjectName == input$providerListUtilization,
          served_between(., ReportStart, ReportEnd)
        ) %>%
        mutate(BedStart = if_else(ProjectType %in% c(3, 9, 13),
                                  MoveInDate, EntryDate),
               PersonalID = as.character(PersonalID),
               **across(.fns = ~dplyr::if_else(is.null(.x), 0 , .x))) %>%**
        select(PersonalID, BedStart, ExitDate, all_of(y))
kiadso commented 3 years ago

Thanks- solved.

I moved this code back into the Utilization script in COHHIO_HMIS instead of doing it in Rme, this way Rm and Rme both get utilizers_clients (and HH_utilizers) with 0s instead of nulls so that can be added neatly. Used your same code here mostly as is even though I tried using replace_na(0) but that didn't work. Here's what I wound up with:

  mutate(across(starts_with("Month"), ~if_else(is.na(.x), 0, .x)))

Thanks again!