ThomUK / SPCreporter

Creates Metric Reports using Statistical Process Control in the NHS style
https://thomuk.github.io/SPCreporter/
Other
6 stars 2 forks source link

spcr_make_data_bundle() requires that event data has been supplied #94

Open francisbarton opened 11 months ago

francisbarton commented 11 months ago

Currently this function assumes that the measure data list contains an event list (e_data) element.

e_data <- measure_data |>
    purrr::pluck("events")

The processing of this data could be contained within an if clause, so that it only runs if event data is included - it might not be?

[if ("events" %in% names(measure_data))]

check_measure_data() (line 15-) currently only demands "week" and "month" be present but in the above situation it turns out that "events" is effectively mandatory too.

Further down, the check_e_data() function is called, which tests if(is.null(e_data)) stop("The 'events' worksheet is missing from 'measure_data'.") but by this point the function will already have failed if there was no "events" element / sheet.

It should be possible to run a report even if you don't require any event list / t-chart data to be included.

ThomUK commented 11 months ago

I agree the logic for this flow can be improved, and it's one of the reasons v0.2.0 is a breaking change - it requires the additional sheet on the excel input. The step to confirm whether data is present may need revising too.
The current version is a trade-off between functionality and code complexity but it would be great to find a cleaner way.