assign_acns() divides unassigned cases among REDcap investigators scheduled to work on date. It distributes cases randomly and evenly across investigators until either all are assigned or there are too few cases for another round of even distribution. Any remaining cases are assigned randomly with at most one additional case given to an investigator.

assign_acns(
  .data = translate_acns(),
  date = attr(.data, "date"),
  api_token = Sys.getenv("redcap_NCA_token")
)

Arguments

.data

Data frame of cases to assign, passed from translate_acns()

date

The date to use when checking whether investigators are scheduled

api_token

The API token for the Case Assignment REDcap project. The default pulls this from the environment variable redcap_CA_token.

Value

A tibble containing the input data with columns investigator, team, and assign_date added

TODO

  1. Pull school age investigators from team lead sheet

  2. Re-factor expressions to be self-documenting (helpers)

  3. Add documentation to helpers

  4. Create unit tests for all functions in file