Tidy lab results
tidy_lab_filesCombines lab results, chain of custody, and field sheets into one table, converts units, and runs six QA checks to flag review items for environmental scientists.
Instructions
Tidy one site's lab results, chain of custody and field sheet into one table, and list what needs review.
Converts units exactly (ug/L for water, mg/kg for soil; ng/L, mg/L and the spellings ug/L, µg/L, μg/L are understood), reads every date day first, matches sample ids across the three files, and runs six QA checks: sample ids, units, field duplicate RPD, holding times to extraction, blank detections linked through the field sheet's equipment column, and LOR against investigation levels (soil HIL A; both drinking-water rules for water, side by side).
Returns counts by matrix and analyte, numbered review items (what was found, the evidence rows, the rule and its source, and what the scientist decides), everything that was checked and not flagged, and what was not checked. The combined rows (one per lab result, with file and row numbers) are included only with include_rows=true; row_count always says how many there are. Show the person every review item and the checked list; never describe the result as "no issues". The tool never merges, rejects or corrects a result, and a guideline value is an investigation level, not a finding that a site is contaminated. The data is synthetic.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | Site id. Only the synthetic site 'FDS-01' is available. | FDS-01 |
| include_rows | No | Include the full combined table (73 rows for FDS-01, about 25 KB). Default false: review items, checks and counts only. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | Yes | The combined table, one row per lab result. Empty unless include_rows is true; row_count says how many rows there are. | |
| site | Yes | ||
| files | Yes | ||
| notes | Yes | ||
| checks | Yes | Every check that ran, what it looked at and what it raised. | |
| counts | Yes | Results by matrix and analyte. | |
| results | Yes | ||
| samples | Yes | Lab samples with results. | |
| summary | Yes | ||
| settings | Yes | ||
| row_count | Yes | How many combined rows the site has, whether or not they are included. | |
| synthetic | Yes | ||
| not_checked | Yes | ||
| review_items | Yes | ||
| rows_included | Yes | ||
| checked_not_flagged | Yes |