data_02: Data-02 Calculation

View source: R/data_02.R

data_02R Documentation

Data-02 Calculation

Description

Calculates documentation timeliness summaries for Data-02.

Data-02 evaluates the elapsed time between a user-defined event at which patient care documentation could reasonably begin and a user-defined event representing documentation occurrence. The function produces descriptive summaries of documentation timeliness and counts of records within predefined documentation time bands.

Results are generated for all patients, adult patients, and pediatric patients. Optional subgroup analyses may be performed using variables supplied through group_vars.

Data-02 is not an official NEMSQA measure. It was developed to support EMS registry data quality assessment and quality improvement initiatives related to EMS documenation timeliness.

Usage

data_02(
  df = NULL,
  patient_scene_table = NULL,
  audit_table = NULL,
  disposition_table = NULL,
  times_table = NULL,
  erecord_01_col,
  incident_date_col = NULL,
  patient_DOB_col = NULL,
  epatient_15_col,
  epatient_16_col,
  patient_care_col,
  time_available_to_document_col,
  time_documentation_occurred_col,
  confidence_interval = FALSE,
  method = c("wilson", "clopper-pearson"),
  conf.level = 0.95,
  correct = TRUE,
  group_vars = NULL
)

Arguments

df

A dataframe or tibble contianing EMS data where each row represents an observation and columns represent features.

patient_scene_table

A data.frame or tibble containing at least ePatient, and eScene as a fact table.

audit_table

A data.frame or tibble containing audit-related fields, such as record creation timestamps and record-level validity scores. The contents of this table are typically registry- or vendor-specific and may not correspond to elements defined within the National EMS Information System (NEMSIS) data standard.

disposition_table

A data.frame or tibble containing only the edisposition fields needed for this measure's calculations.

times_table

A data.frame or tibble containing event date-time variables used to evaluate documentation timeliness. These variables may include NEMSIS time elements (e.g., unit back in service date/time) or registry-, vendor-, or agency-specific timestamps related to record creation, modification, submission, approval, or other documentation workflow events. The contents of this table may not correspond entirely to elements defined within the National EMS Information System (NEMSIS) data standard.

erecord_01_col

The column representing the EMS record unique identifier.

incident_date_col

Column that contains the incident date. This defaults to NULL as it is optional in case not available due to PII restrictions.

patient_DOB_col

Column that contains the patient's date of birth. This defaults to NULL as it is optional in case not available due to PII restrictions.

epatient_15_col

Column representing the patient's numeric age agnostic of unit.

epatient_16_col

Column representing the patient's age unit ("Years", "Months", "Days", "Hours", or "Minutes").

patient_care_col

Disposition variable used to identify patient contact encounters.

time_available_to_document_col

Date-time variable representing the point at which patient care documentation could reasonably begin. Examples may include unit back in service time, back at home location time, ems call completed time, and others.

time_documentation_occurred_col

Date-time variable representing when patient care documentation was completed or first entered into the EMS software, registry, or other documentation system. This variable is typically vendor- or registry-specific and may not correspond to a NEMSIS data element. Examples include incident created time, incident completed time, and others.

confidence_interval

Logical. If TRUE, the function calculates a confidence interval for the proportion estimate.

method

Character. Specifies the method used to calculate confidence intervals. Options are "wilson" (Wilson score interval) and "clopper-pearson" (exact binomial interval). Partial matching is supported, so "w" and "c" can be used as shorthand.

conf.level

Numeric. The confidence level for the interval, expressed as a proportion (e.g., 0.95 for a 95% confidence interval). Defaults to 0.95.

correct

Logical. If TRUE, applies a continuity correction to the Wilson score interval when method = "wilson". Defaults to TRUE.

group_vars

Optional character vector of column names used to perform subgroup analyses.

Value

A named list with two primary elements:

  • distribution: Documentation time distribution summaries.

  • counts: Documentation time band counts and proportions.

Both elements contain:

  • overall: Results for the selected populations (All, Adults, and Peds).

  • stratified: Results stratified by group_vars (when requested).

Population-specific results are combined within each output and identified by the pop variable. Distribution summaries include separate rows for documentation time expressed in hours and days, identified by time_unit.

Distribution summaries include separate results for documentation time expressed in hours and days, identified by the time_unit variable.

Distribution summaries include:

  • time_unit: The unit of measurement used for the documentation timeliness summary (Hours or Days).

  • Number of observations.

  • Number of missing documentation times.

  • Minimum, maximum, mean, and standard deviation.

  • Percentiles: 25, median, 75, and 90.

Count summaries include:

  • Documentation time band.

  • Count (numerator).

  • Population total (denominator).

  • Proportion (prop).

  • Confidence intervals when requested.

Author(s)

Nicolas Foss, Ed.D., MS

Examples


# Synthetic Data-02 example
test_data <- tibble::tibble(
  erecord_01 = paste0("R", 1:10),

  # Incident and demographic variables
  incident_date = as.Date("2024-01-01"),
  patient_dob = as.Date(c(
    "1980-01-01", "1975-01-01", "1990-01-01", "1985-01-01",
    "1970-01-01", "2015-01-01", "2012-01-01", "2010-01-01",
    "2018-01-01", "2016-01-01"
  )),
  epatient_15 = c(44, 49, 34, 39, 54, 9, 12, 14, 6, 8),
  epatient_16 = rep("Years", 10),

  # Patient contact disposition
  patient_disposition = rep(
    "Patient Treated, Transported by this EMS Unit (4212033)",
    10
  ),

  # Time documentation became available
  unit_back_in_service = as.POSIXct(
    "2024-01-01 08:00:00",
    tz = "UTC"
  ) + c(
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ) * 86400,

  # Time documentation occurred
  incident_created = as.POSIXct(
    c(
      "2024-01-01 11:00:00",  # 3 hours
      "2024-01-01 18:00:00",  # 10 hours
      "2024-01-02 04:00:00",  # 20 hours
      "2024-01-02 12:00:00",  # 28 hours
      "2024-01-03 12:00:00",  # 52 hours
      "2024-01-05 12:00:00",  # 4 days
      "2024-01-10 12:00:00",  # 9 days
      "2024-01-20 12:00:00",  # 19 days
      "2024-02-15 12:00:00",  # 45 days
      "2024-04-15 12:00:00"   # >60 days
    ),
    tz = "UTC"
  )
)

# Calculate Data-02 timeliness summaries
data_02(
  df = test_data,
  erecord_01_col = erecord_01,
  incident_date_col = incident_date,
  patient_DOB_col = patient_dob,
  epatient_15_col = epatient_15,
  epatient_16_col = epatient_16,
  patient_care_col = patient_disposition,
  time_available_to_document_col = unit_back_in_service,
  time_documentation_occurred_col = incident_created
)


nemsqar documentation built on Dec. 4, 2026, 1:06 a.m.