Skip to contents

Converts a single row of patient data into a formatted list of parameters for preeclampsia risk calculation, performing necessary data transformations and validation.

Usage

row_to_list(row, validate = TRUE)

Arguments

row

Data frame row or vector containing patient data

validate

Boolean, whether to validate column names (default: TRUE)

Value

List of processed parameters with appropriate types and formats

Details

Performs the following transformations:

  • Calculates maternal age at conception

  • Converts categorical variables from strings to numeric codes

  • Processes date fields

  • Validates categorical inputs against expected values

  • Handles special cases for diabetes medication and biomarker data

Input format expectations:

  • Dates should be in format "dd-mm-yyyy" or "dd.mm.yyyy"

  • Categorical variables (yes/no) should be case-insensitive

  • Twins status: "no", "monochorionic", "dichorionic"

  • Race: 1=White, 2=Black, 3=South Asian, 4=East Asian, 5=Mixed

  • Biomarker inclusion: "no", "mom", "raw"

  • Biomarker machines: "delfia", "kryptor", "roche"

Warnings

The function issues warnings for:

  • Missing required columns

  • Invalid categorical values

  • Unexpected values in medical history fields

  • Invalid biomarker specifications

Examples

if (FALSE) { # \dontrun{
patient_data <- data.frame(
  twins = "no",
  ga = 12,
  height = 165,
  weight = 70,
  smoking = "no",
  # ... other required fields ...
)
params <- row_to_list(patient_data)
} # }