Skip to contents

The first pass only reports issues. Decisions passed through issue_decisions are the only allowed route for corrections; raw event rows are never changed.

Usage

convert_raw_logs(
  raw_logs,
  protocol_manifest = NULL,
  errors = c("raise", "warn", "error"),
  create_report = FALSE,
  issue_decisions = NULL,
  sampling_schedule = NULL,
  manual_diary = NULL,
  check_compliance = TRUE,
  compliance_checker = new_sampling_compliance_checker()
)

Arguments

raw_logs

Immutable events returned by read_raw_logs().

protocol_manifest

Optional ordered registration configuration.

errors

Unresolved-issue handling: "raise", "warn", or legacy "error".

create_report

Return a list containing results and the issue report.

issue_decisions

A prior editable issue report with decisions.

sampling_schedule

Optional fallback schedule for use_default sample decisions. Supply a position-indexed vector, a named sample list, or a named day list containing either form.

manual_diary

Optional normalized manual diary.

check_compliance

Whether to calculate timing compliance.

compliance_checker

Timing tolerance configuration.

Value

Canonical results, or a results/report list.

Examples

fixture <- system.file("extdata", "parity", "v1.0.0", package = "carwatch")
raw_logs <- read_raw_logs(file.path(fixture, "raw", "VP01"))
converted <- convert_raw_logs(raw_logs, errors = "warn", create_report = TRUE)
converted$report$issues
#> # A tibble: 0 × 15
#> # ℹ 15 variables: participant <chr>, day <chr>, sample_id <chr>, code <chr>,
#> #   registration <int>, registration_day <int>, sample_position <int>,
#> #   issue_id <chr>, message <chr>, details <chr>, proposed_action <chr>,
#> #   proposed_action_description <chr>, resolution_status <chr>,
#> #   user_decision <chr>, user_decision_value <chr>
as_sample_events(converted$results)
#> # A tibble: 2 × 32
#>   participant day   sample sampling_time       barcode   recorded_sample
#>   <chr>       <chr> <chr>  <dttm>              <chr>     <chr>          
#> 1 VP01        D1    tube-a 2025-05-15 06:06:40 barcode-a tube-a         
#> 2 VP01        D1    tube-b 2025-05-15 06:36:40 barcode-b tube-b         
#> # ℹ 26 more variables: sampling_time_source <chr>, sample_position <int>,
#> #   day_expected <int>, day_scanned <int>, schedule_type <chr>,
#> #   expected_interval_min <dbl>, actual_interval_min <dbl>,
#> #   scheduled_sampling_time <dttm>, time_deviation_min <dbl>,
#> #   sample_compliant <lgl>, awakening_time <dttm>, awakening_type <chr>,
#> #   registration <int>, study_name <chr>, registration_day <int>,
#> #   registration_sources <chr>, possible_reregistration <lgl>, …