Quantification Rules Design
Document Type: Rule Design (Tier 2) Domain: RULES-QUANT Domain Character: Algorithmic SRS Reference: rule-rquant.md, rule-quant-validation.md, rule-stdqt.md, rule-linear-regression-validation.md, rule-standard-curve-validation.md, rule-managing-quantities.md, rule-quantity-weight.md, rule-notts-quant-multiply.md, rule-reporting-qual.md, rule-reporting-quant-as-qual.md Status: Draft Last Updated: 2026-01-25
1. Overview
1.0 Rule Summary
| Property | Value |
|---|---|
| Intent | Calculate, validate, format, and report quantities from PCR analysis using standard curve quantification, linear regression parameters, and configurable reporting thresholds. Supports tiered quantity formatting, specimen-type-specific configurations, and qualitative/quantitative outcome determination. |
| Inputs | Well observations (CT, quantity, classification), Standard curve parameters (slope, intercept, R2, efficiency), Quantification settings (thresholds, ranges), Reporting configurations (groups, boundaries, specimen types), Tissue weight, Concentration factor |
| Outputs | Calculated quantities, Formatted reporting quantities, LIMS status codes (DETECTED, NOT DETECTED, DETECTED_QUANT, DETECTED_LOQ), Error codes (UNABLE_TO_QUANTIFY, RQUANT_LIMITS_MISSED, BAD_R2, BAD_GRADIENT, etc.) |
| Precedence | QUANT_VALIDATION and LINEAR_REGRESSION_VALIDATION run early (during import); STDQT after CT calculation; RQUANT/RQUANTASQUAL/RQUAL after quantification; TISSUE_WEIGHT and NOTES_QUANT_MULTIPLY during analysis |
1.1 Purpose
The Quantification Rules cluster handles all aspects of PCR quantity calculation, validation, formatting, and reporting. This encompasses:
- Standard Curve Validation - Validates CT values and R-squared correlation against standard curve parameters
- Linear Regression Validation - Calculates and validates regression parameters (slope, intercept, R2, efficiency) from standard controls
- Quantity Validation - Assigns known quantities to observations, validates standard controls, performs CT range validation
- Standard Quantity Calculation (STDQT) - Calculates patient sample quantities using standard curve parameters
- Quantity Formatting (RQUANT) - Applies tiered formatting rules (Groups 2-9) to quantities for LIMS export
- Qualitative Reporting (RQUAL) - Determines Detected/Not Detected outcomes by CT vs cutoff comparison
- Quant-as-Qual Reporting (RQUANTASQUAL) - Converts quantitative results to qualitative outcomes using LoD thresholds
- Quantity Weight Normalization (TISSUE_WEIGHT) - Normalizes quantities by tissue weight
- Quantity Multiplier (NOTES_QUANT_MULTIPLY) - Applies concentration factor as quantity multiplier
- Placeholder Substitution (Managing Quantities) - Substitutes {LOQ} and {QUANT} placeholders in LIMS messages
1.2 Requirements Covered
| REQ ID | Title | Priority | Source Rule |
|---|---|---|---|
| REQ-RULES-RQUANT-001 | Evaluate and Format Sample Quantities | Must | RQUANT |
| REQ-RULES-RQUANT-002 | Handle Missing Configuration | Must | RQUANT |
| REQ-RULES-RQUANT-003 | Select Reporting Configuration by Specimen Type | Should | RQUANT |
| REQ-RULES-QUANTVAL-001 | Assign Known Quantities to Observations | Must | QUANT_VALIDATION |
| REQ-RULES-QUANTVAL-002 | Exclude Non-Quantifiable Observations | Must | QUANT_VALIDATION |
| REQ-RULES-QUANTVAL-003 | Calculate Linear Regression Parameters | Must | QUANT_VALIDATION |
| REQ-RULES-QUANTVAL-004 | Validate Standard Controls Against Thresholds | Must | QUANT_VALIDATION |
| REQ-RULES-QUANTVAL-005 | Validate CT Values Against Range Bounds | Must | QUANT_VALIDATION |
| REQ-RULES-QUANTVAL-006 | Support Error Resolution | Should | QUANT_VALIDATION |
| REQ-RULES-LINREG-001 | Calculate Linear Regression Parameters | Must | LINEAR_REGRESSION_VALIDATION |
| REQ-RULES-LINREG-002 | Exclude Error Wells from Regression Calculation | Must | LINEAR_REGRESSION_VALIDATION |
| REQ-RULES-LINREG-003 | Classify Insufficient Standard Control Errors | Must | LINEAR_REGRESSION_VALIDATION |
| REQ-RULES-LINREG-004 | Apply Resolutions to Linear Regression Errors | Should | LINEAR_REGRESSION_VALIDATION |
| REQ-RULES-LINREG-005 | Propagate Series-Level Resolutions | Should | LINEAR_REGRESSION_VALIDATION |
| REQ-RULES-LINREG-006 | Exclude Wells from Regression via Resolution | Should | LINEAR_REGRESSION_VALIDATION |
| REQ-RULES-STDQT-001 | Calculate Standard Quantity | Must | STDQT |
| REQ-RULES-STDQT-002 | Apply Quantity Multiplier | Should | STDQT |
| REQ-RULES-STDQT-003 | Use Fallback Standard Controls | Should | STDQT |
| REQ-RULES-STDQT-004 | Propagate Run Target Quantification Errors | Must | STDQT |
| REQ-RULES-STDQT-005 | Configure Well Failure Scope | Should | STDQT |
| REQ-RULES-STDCURVE-001 | Validate CT Values Against Standard Curve | Must | STDQT |
| REQ-RULES-QTYWEIGHT-001 | Normalize Quantity Using Tissue Weight | Must | TISSUE_WEIGHT |
| REQ-RULES-QTYWEIGHT-002 | Generate Error for Invalid Tissue Weight | Must | TISSUE_WEIGHT |
| REQ-RULES-NOTTSQM-001 | Set Quantity Multiplier from Concentration Factor | Must | NOTES_QUANT_MULTIPLY |
| REQ-RULES-QUANTITIES-001 | Support Quantity Placeholders in LIMS Export | Must | RQUANTASQUAL |
| REQ-RULES-RQUAL-001 | Qualitative Reporting Outcome Determination | Must | RQUAL |
| REQ-RULES-RQUAL-002 | Specimen-Specific Reporting Configuration Selection | Should | RQUAL |
| REQ-RULES-RQUANTQUAL-001 | Report Quantitative Results as Qualitative Outcomes | Must | RQUANTASQUAL |
| REQ-RULES-RQUANTQUAL-002 | Select LoD Threshold Based on Specimen Type | Should | RQUANTASQUAL |
1.3 Constraints
Tier 2 Constraint: This document describes ownership, patterns, and design rationale. It links to reference docs for full schemas.
1.4 Dependencies
| Direction | Component | Purpose |
|---|---|---|
| Consumes | Well + Observations | CT values, classifications, quantities |
| Kit Configuration | Standard curves, reporting configs, thresholds | |
| Runfile Data | Machine quantities, tissue weights | |
| Related | WDCLS Rule | Classification for eligibility checks |
| Combined Outcome Rule | May set outcomes before RQUANT | |
| Precedes | LIMS Export | Formatted quantities exported |
2. Component Architecture
2.1 Component Diagram
2.2 Component Responsibilities
| Component | File | Responsibility | REQ Trace |
|---|---|---|---|
QuantValidationRule | Analyzer/Rules/QuantValidationRule.php | Known quantity assignment, CT range validation | QUANTVAL-001 to 006 |
LinearRegressionValidationRule | Analyzer/Rules/LinearRegressionValidationRule.php | Regression calculation and validation | LINREG-001 to 006 |
StdqtRule | Analyzer/Rules/StdqtRule.php | Patient quantity calculation | STDQT-001 to 005 |
RquantRule | Analyzer/Rules/RquantRule.php | Tiered quantity formatting | RQUANT-001 to 003 |
RqualRule | Analyzer/Rules/RqualRule.php | Qualitative outcome determination | RQUAL-001, 002 |
RquantasqualRule | Analyzer/Rules/RquantasqualRule.php | Quant-to-qual conversion | RQUANTQUAL-001, 002 |
QuantityWeightRule | Analyzer/Rules/QuantityWeightRule.php | Tissue weight normalization | QTYWEIGHT-001, 002 |
NotesQuantMultiplyRule | Analyzer/Rules/NotesQuantMultiplyRule.php | Concentration factor multiplier | NOTTSQM-001 |
FillObservationQuantity | Concerns/QuantValidationRule/FillObservationQuantity.php | Assigns known quantities | QUANTVAL-001 |
ValidateCT | Concerns/QuantValidationRule/ValidateCT.php | CT range validation | QUANTVAL-005 |
ValidateCoordinates | Concerns/QuantValidationRule/ValidateCoordinates.php | Standard control count validation | LINREG-002, 003 |
ValidateSlope | Concerns/QuantValidationRule/ValidateSlope.php | Slope range validation | LINREG-001 |
ValidateR2 | Concerns/QuantValidationRule/ValidateR2.php | R-squared threshold validation | LINREG-001 |
ValidateEfficiency | Concerns/QuantValidationRule/ValidateEfficiency.php | PCR efficiency validation | LINREG-001 |
LinearRegressionGenerator | Support/LinearRegressionGenerator.php | Math: slope, intercept, R2 calculation | LINREG-001 |
CalculateQuantityUsingInterceptAndSlope | Concerns/CalculateQuantityUsingInterceptAndSlope.php | Math: quantity from CT | STDQT-001 |
SetErrorToSeriesWells | Concerns/QuantValidationRule/SetErrorToSeriesWells.php | Error propagation to series | QUANTVAL-004, LINREG-003 |
HandleResolutions | Concerns/QuantValidationRule/HandleResolutions.php | Resolution management | QUANTVAL-006, LINREG-004 to 006 |
3. Data Design
3.1 Entities
| Entity | Owner | Read/Write | Fields Used |
|---|---|---|---|
wells | RUNRPT | Read/Write | observations, error_code, lims_status, reporting_quantity, quantity_multiplier, tissue_weight, concentration_factor |
observations | RUNRPT | Read/Write | final_ct, final_cls, quantity, target_id, role |
run_targets | RUNRPT | Read/Write | slope, intercept, r2, efficiency |
known_quantities | KITCFG | Read | target_id, role, known_quantity |
calculated_quantification_settings | KITCFG | Read | target, role, min_controls, min_r2, min_slope, max_slope, min_efficiency, max_efficiency |
curve_control_range_settings | KITCFG | Read | low_bound, upper_bound |
reportings | KITCFG | Read | group_id, upper_boundary, specimen_type |
See Database Reference for full schema.
3.2 Key Data Structures
// Linear Regression Parameters
interface LinearRegression {
slope: number; // Gradient of log(qty) vs CT
intercept: number; // Y-intercept
r2: number; // Correlation coefficient (0-1)
efficiency: number; // PCR efficiency: -1 + 10^(-1/slope)
}
// Quantity Group Configuration (RQUANT)
interface ReportingGroup {
group_id: number; // 1-9
upper_boundary: number; // Quantity threshold
specimen_type?: string; // Optional specimen filter
last_modified: Date; // For fallback selection
}
// Quantification Settings
interface QuantificationSettings {
target_id: string;
role: string;
min_controls: number; // Default: 2
min_r2: number; // R2 threshold
min_slope: number; // Slope range lower bound
max_slope: number; // Slope range upper bound
min_efficiency: number; // Efficiency range lower bound
max_efficiency: number; // Efficiency range upper bound
}
// Standard Control Coordinate
interface Coordinate {
quantity: number; // Known quantity (log scale)
ct: number; // Cycle threshold
}
4. Interface Design
4.1 Rule Interface
All quantification rules implement AnalyzerRuleContract:
interface AnalyzerRuleContract {
public function handle(
ConfigurationRepository $config,
AnalyzableObservation $observation,
RunMix $runMix,
RunTarget $runTarget,
AnalyzableWell $well,
WellCollection $wells,
PatientWellCollection $previousPatientWells,
PecWellCollection $previousPecWells,
RunTargetsCollection $runTargets
): void;
}
4.2 Internal APIs
| Method | Class | Purpose |
|---|---|---|
shouldNotBeQuantified(obs) | QuantValidationRule | Check IC target, negative CLS, non-quant role |
mapCoordinatesFromQuantitativeObservations(obs) | WellCollection | Extract coordinates for regression |
generate(coordinates) | LinearRegressionGenerator | Calculate slope, intercept, R2 |
calculateEfficiency(runTarget) | LinearRegressionValidationRule | Compute PCR efficiency from slope |
roundFromSignificant(number, sigFigs) | RquantRule | Round to N significant figures |
getAllGroupReportingsForObservation(obs) | ConfigurationRepository | Get reporting groups |
getFirstGroupReportingForObservation(obs) | ConfigurationRepository | Get LoD threshold |
5. Behavioral Design
5.1 Standard Quantity Calculation (REQ-RULES-STDQT-001)
Algorithm: Calculate Standard Quantity
Inputs:
- ct: number - Well's final CT value
- intercept: number - Standard curve intercept
- slope: number - Standard curve slope (gradient)
- multiplier: number - Quantity multiplier (default: 1)
Outputs:
- quantity: number - Calculated quantity
Assumptions:
- Slope and intercept are non-null and valid
- CT is a valid numeric value
- Slope is non-zero (prevents division by zero)
Steps:
1. Calculate log quantity: log_qty = (ct - intercept) / slope
2. Calculate base quantity: base_qty = 10^log_qty
3. Apply multiplier: final_qty = base_qty * multiplier
4. Return final_qty
Notes:
- Slope is typically negative (higher CT = lower quantity)
- Example: CT=27, intercept=33, slope=-1 yields 10^((27-33)/-1) = 10^6 = 1,000,000
5.2 Linear Regression Calculation (REQ-RULES-LINREG-001)
Algorithm: Calculate Linear Regression Parameters
Inputs:
- coordinates: Coordinate[] - Array of {quantity, ct} from standard controls
Outputs:
- slope: number - Regression slope
- intercept: number - Regression intercept
- r2: number - R-squared correlation coefficient
Assumptions:
- Coordinates use log(quantity) as X, CT as Y
- At least 2 valid coordinates exist
Steps:
1. Calculate means:
- x_mean = sum(log(qty)) / n
- y_mean = sum(ct) / n
2. Calculate slope:
- numerator = sum((log(qty) - x_mean) * (ct - y_mean))
- denominator = sum((log(qty) - x_mean)^2)
- slope = numerator / denominator
3. Calculate intercept:
- intercept = y_mean - slope * x_mean
4. Calculate R-squared:
- SS_res = sum((ct - predicted_ct)^2) where predicted_ct = slope * log(qty) + intercept
- SS_tot = sum((ct - y_mean)^2)
- R2 = 1 - (SS_res / SS_tot)
5. Return {slope, intercept, r2}
Notes:
- Efficiency is calculated separately: efficiency = -1 + 10^(-1/slope)
- Typical R2 threshold is 0.99 for high-quality standard curves
5.3 RQUANT Tiered Formatting (REQ-RULES-RQUANT-001)
Algorithm: Format Quantity for LIMS Export
Inputs:
- quantity: number - Calculated quantity
- reportings: ReportingGroup[] - Sorted by group_id ascending
Outputs:
- reporting_quantity: string - Formatted quantity
- lims_status: string - LIMS status code
Steps:
1. IF negative classification: RETURN status = 'NOT DETECTED'
2. IF no reportings configured: SET error = 'RQUANT_LIMITS_MISSED', RETURN
3. Iterate through groups (sorted by group_id):
Group 1 (LoD):
- IF quantity < upper_boundary: RETURN status = 'NOT DETECTED'
Group 2 (LOQ):
- IF quantity < upper_boundary:
- reporting_quantity = format(upper_boundary)
- RETURN status = 'DETECTED_LOQ'
Group 3 (No Rounding):
- IF quantity < upper_boundary:
- reporting_quantity = format(quantity)
- RETURN status = 'DETECTED_QUANT'
Group 4 (Boundary Value):
- IF quantity < upper_boundary:
- reporting_quantity = format(upper_boundary)
- RETURN status = 'DETECTED_QUANT'
Group 5 (1 Sig Fig):
- IF quantity < upper_boundary:
- reporting_quantity = roundSignificant(quantity, 1)
- RETURN status = 'DETECTED_QUANT'
Group 6 (2 Sig Figs):
- IF quantity < upper_boundary:
- reporting_quantity = roundSignificant(quantity, 2)
- RETURN status = 'DETECTED_QUANT'
Group 7 (3 Sig Figs):
- IF quantity < upper_boundary:
- reporting_quantity = roundSignificant(quantity, 3)
- RETURN status = 'DETECTED_QUANT'
Group 8 (2 Sig Figs):
- IF quantity < upper_boundary:
- reporting_quantity = roundSignificant(quantity, 2)
- RETURN status = 'DETECTED_QUANT'
Group 9 (Scientific):
- IF quantity < upper_boundary:
- reporting_quantity = scientific(quantity, 2)
- RETURN status = 'DETECTED_QUANT'
- IF quantity >= upper_boundary:
- reporting_quantity = scientific(upper_boundary, 2)
- RETURN status = 'DETECTED_HIQ'
5.3.1 RQUANT Group Decision Table
| Group | Condition | Rounding | Format | Example Input | Example Output |
|---|---|---|---|---|---|
| 1 (LoD) | qty < threshold | N/A | N/A | 50 < 100 | NOT DETECTED |
| 2 (LOQ) | qty < threshold | None | threshold | 150 < 200 | "200" |
| 3 | qty < threshold | None | raw | 250 | "250" |
| 4 | qty < threshold | None | threshold | 400 | "500" |
| 5 | qty < threshold | 1 sig | rounded | 1,040 | "1,000" |
| 6 | qty < threshold | 2 sig | rounded | 2,123 | "2,100" |
| 7 | qty < threshold | 3 sig | rounded | 12,927 | "12,900" |
| 8 | qty < threshold | 2 sig | rounded | 1,565,323 | "1,600,000" |
| 9 | qty < threshold | 2 sig | scientific | 9,982,000 | "1.00E+07" |
| 9+ | qty >= threshold | 2 sig | scientific | 15,000,000 | ">1.00E+07" |
Precedence: Groups evaluated in ascending order (1 through 9); first match wins. Default: If quantity exceeds all thresholds, Group 9+ applies.
5.4 Tissue Weight Normalization (REQ-RULES-QTYWEIGHT-001)
Algorithm: Normalize Quantity by Tissue Weight
Inputs:
- quantity: number|null - Observation quantity
- tissue_weight: number|null|string - Well tissue weight
Outputs:
- quantity: number|null - Normalized quantity (or unchanged)
Steps:
1. IF tissue_weight is null: RETURN original quantity (skip)
2. IF tissue_weight is non-numeric: SET error = 'INVALID_TISSUE_WEIGHT', RETURN
3. IF tissue_weight == 0: RETURN original quantity (skip, avoid division by zero)
4. IF quantity is null: RETURN null (skip)
5. normalized_quantity = quantity / (2 * tissue_weight)
6. RETURN normalized_quantity
Notes:
- Multiplier of 2 is a fixed domain-specific constant
- Example: quantity=100, tissue_weight=0.1 yields 100/(2*0.1) = 500
5.5 Qualitative Outcome Determination (REQ-RULES-RQUAL-001)
Algorithm: Determine Qualitative Outcome (RQUAL)
Inputs:
- ct: number - Well's CT value
- cutoff: number - Upper boundary from reporting config
- use_sample_type: boolean - Whether to match by specimen type
Outputs:
- lims_status: string - 'DETECTED' or 'NOT DETECTED'
Steps:
1. Select reporting configuration:
- IF use_sample_type enabled: match by specimen type
- ELSE: use most recently modified reporting config
2. Get cutoff from selected reporting's upper_boundary
3. Compare CT against cutoff:
- IF ct < cutoff: RETURN 'NOT DETECTED' (error condition)
- IF ct >= cutoff: RETURN 'DETECTED'
Notes:
- Counter-intuitive: lower CT indicates NOT DETECTED
- Boundary is inclusive (ct == cutoff yields DETECTED)
5.6 Standard Control Validation Decision Logic (REQ-RULES-LINREG-003)
| Valid Well Count | min_controls Config | Error Code |
|---|---|---|
| count = 1 | Any | ONE_STANDARD_CONTROL |
| 1 < count < min_controls | e.g., 3 | INSUFFICIENT_STANDARD_CONTROLS |
| count >= min_controls | e.g., 3 | No error (proceed) |
Precedence: Evaluated before regression calculation. Default: min_controls defaults to 2. Note: ONE_STANDARD_CONTROL is NOT resolvable; INSUFFICIENT_STANDARD_CONTROLS is resolvable.
5.7 Error Propagation from Run Target (REQ-RULES-STDQT-004)
| Run Target Error | Patient Well Effect |
|---|---|
| INSUFFICIENT_STANDARD_CONTROLS | UNABLE_TO_QUANTIFY |
| STANDARD_WITHOUT_QUANT | UNABLE_TO_QUANTIFY |
| BAD_R2 | UNABLE_TO_QUANTIFY |
| BAD_GRADIENT | UNABLE_TO_QUANTIFY |
| BAD_EFFICIENCY | UNABLE_TO_QUANTIFY |
Scope: Configurable via only_fail_positive_wells:
- true: Only positive-classified wells receive error
- false: All patient wells receive error
6. Error Handling
| Condition | Detection | Response | Resolvable |
|---|---|---|---|
| No reporting configuration | reportings.isEmpty() | RQUANT_LIMITS_MISSED | No |
| Target ID null | observation.getTargetId() == null | RQUANT_LIMITS_MISSED | No |
| Missing known quantity | No config match for target/role | STANDARD_WITHOUT_QUANT | No |
| Below min controls (count=1) | coordinates.length == 1 | ONE_STANDARD_CONTROL | No |
| Below min controls (count>1) | coordinates.length < min_controls | INSUFFICIENT_STANDARD_CONTROLS | Yes |
| R2 below threshold | r2 < min_r2 | BAD_R2 | Yes |
| Slope outside range | slope < min_slope OR slope > max_slope | BAD_GRADIENT | Yes |
| Efficiency outside range | eff < min_eff OR eff > max_eff | BAD_EFFICIENCY | Yes |
| CT outside bounds | ct < low_bound OR ct > upper_bound | STANDARD_OUTSIDE_CT_RANGE | Yes |
| Missing slope/intercept | slope == null OR intercept == null | UNABLE_TO_QUANTIFY | No |
| Non-numeric tissue weight | !is_numeric(tissue_weight) | INVALID_TISSUE_WEIGHT | No |
7. Configuration
| Setting | Path | Default | Effect | REQ |
|---|---|---|---|---|
min_controls | Calculated Quantification Settings | 2 | Minimum standard controls | LINREG-003 |
min_r2 | Calculated Quantification Settings | - | R2 threshold | LINREG-001 |
min_slope / max_slope | Calculated Quantification Settings | - | Slope range | LINREG-001 |
min_efficiency / max_efficiency | Calculated Quantification Settings | - | Efficiency range | LINREG-001 |
low_bound / upper_bound | Curve Control Range Settings | - | CT validation bounds | QUANTVAL-005 |
use_sample_type | System Settings | false | Specimen-type-specific reporting | RQUANT-003, RQUAL-002 |
use_fallback_shared_controls | System Settings | false | Backup controls from alternate mixes | STDQT-003 |
only_fail_positive_wells | System Settings | true | Limit error propagation scope | STDQT-005 |
round_ninth_reporting_group | System Settings | false | Round Group 9 scientific notation | RQUANT-001 |
See Configuration Reference for full documentation.
8. Implementation Mapping
8.1 Code Locations
| Component | Path |
|---|---|
| QUANT_VALIDATION Entry | Analyzer/Rules/QuantValidationRule.php |
| LINEAR_REGRESSION_VALIDATION Entry | Analyzer/Rules/LinearRegressionValidationRule.php |
| STDQT Entry | Analyzer/Rules/StdqtRule.php |
| RQUANT Entry | Analyzer/Rules/RquantRule.php |
| RQUAL Entry | Analyzer/Rules/RqualRule.php |
| RQUANTASQUAL Entry | Analyzer/Rules/RquantasqualRule.php |
| TISSUE_WEIGHT Entry | Analyzer/Rules/QuantityWeightRule.php |
| NOTES_QUANT_MULTIPLY Entry | Analyzer/Rules/NotesQuantMultiplyRule.php |
| Fill Quantity | Analyzer/Rules/Concerns/QuantValidationRule/FillObservationQuantity.php |
| CT Validation | Analyzer/Rules/Concerns/QuantValidationRule/ValidateCT.php |
| Coordinate Validation | Analyzer/Rules/Concerns/QuantValidationRule/ValidateCoordinates.php |
| Slope Validation | Analyzer/Rules/Concerns/QuantValidationRule/ValidateSlope.php |
| R2 Validation | Analyzer/Rules/Concerns/QuantValidationRule/ValidateR2.php |
| Efficiency Validation | Analyzer/Rules/Concerns/QuantValidationRule/ValidateEfficiency.php |
| Regression Math | Support/LinearRegressionGenerator.php |
| Quantity Calculation | Analyzer/Rules/Concerns/CalculateQuantityUsingInterceptAndSlope.php |
| Resolution Handling | Analyzer/Rules/Concerns/QuantValidationRule/HandleResolutions.php |
| Series Error Setting | Analyzer/Rules/Concerns/QuantValidationRule/SetErrorToSeriesWells.php |
8.2 Requirement Traceability
| REQ ID | Design Section | Primary Code |
|---|---|---|
| REQ-RULES-RQUANT-001 | §5.3 | RquantRule.php |
| REQ-RULES-RQUANT-002 | §6 | RquantRule.php:56-60 |
| REQ-RULES-RQUANT-003 | §5.3 | ConfigurationRepository.getAllGroupReportingsForObservation() |
| REQ-RULES-QUANTVAL-001 | §5.1 | FillObservationQuantity.php |
| REQ-RULES-QUANTVAL-002 | §2.2 | QuantValidationRule.shouldNotBeQuantified() |
| REQ-RULES-QUANTVAL-003 | §5.2 | LinearRegressionGenerator.php |
| REQ-RULES-QUANTVAL-004 | §6 | SetErrorToSeriesWells.php |
| REQ-RULES-QUANTVAL-005 | §5.4 | ValidateCT.php |
| REQ-RULES-QUANTVAL-006 | §6 | HandleResolutions.php |
| REQ-RULES-LINREG-001 | §5.2 | LinearRegressionValidationRule.php, LinearRegressionGenerator.php |
| REQ-RULES-LINREG-002 | §5.6 | ValidateCoordinates.php |
| REQ-RULES-LINREG-003 | §5.6 | ValidateCoordinates.php |
| REQ-RULES-LINREG-004 | §6 | HandleResolutions.php |
| REQ-RULES-LINREG-005 | §6 | HandleResolutions.updateAllWellsWithSeriesResolution() |
| REQ-RULES-LINREG-006 | §6 | HandleResolutions.php |
| REQ-RULES-STDQT-001 | §5.1 | StdqtRule.php, CalculateQuantityUsingInterceptAndSlope.php |
| REQ-RULES-STDQT-002 | §5.1 | StdqtRule.php:68-71 |
| REQ-RULES-STDQT-003 | §2.2 | StdqtRule.getMatchingRunTarget() |
| REQ-RULES-STDQT-004 | §5.7 | StdqtRule.hasQuantificationError() |
| REQ-RULES-STDQT-005 | §5.7 | StdqtRule.shouldGetError() |
| REQ-RULES-STDCURVE-001 | §5.2, §5.5 | ValidateCT.php, StdqtRule.php |
| REQ-RULES-QTYWEIGHT-001 | §5.4 | QuantityWeightRule.php |
| REQ-RULES-QTYWEIGHT-002 | §6 | QuantityWeightRule.php |
| REQ-RULES-NOTTSQM-001 | §2.2 | NotesQuantMultiplyRule.php |
| REQ-RULES-QUANTITIES-001 | §5.3 | RquantRule.php (placeholder in reporting) |
| REQ-RULES-RQUAL-001 | §5.5 | RqualRule.php |
| REQ-RULES-RQUAL-002 | §5.5 | ConfigurationRepository.getFirstGroupReportingForObservation() |
| REQ-RULES-RQUANTQUAL-001 | §5.5 | RquantasqualRule.php |
| REQ-RULES-RQUANTQUAL-002 | §5.5 | ConfigurationRepository.getFirstGroupReportingForObservation() |
9. Design Decisions
| Decision | Rationale | Alternatives Considered |
|---|---|---|
| Separate validation and calculation rules | Clear separation of concerns; validation can fail independently | Single monolithic rule (rejected: too complex) |
| Series-level error propagation | Standard curve issues affect all wells using that curve | Per-well errors only (rejected: misleading) |
| Tiered formatting with 9 groups | Lab-specific precision requirements vary by magnitude | Single format (rejected: insufficient precision control) |
| Specimen-type config selection | Different sample matrices have different detection thresholds | Single config per target (rejected: insufficient flexibility) |
| Fixed 2x multiplier in tissue weight | Domain-specific constant from assay protocol | Configurable multiplier (rejected: no business need) |
| Resolvable vs non-resolvable errors | Some errors can be manually overridden; others cannot | All resolvable (rejected: ONE_STANDARD_CONTROL is fundamentally unresolvable) |
10. Performance Considerations
| Scenario | Concern | Mitigation |
|---|---|---|
| Large number of standard controls | Regression calculation overhead | Linear time algorithm O(n) |
| Many reporting groups | Iteration overhead | Early exit on first match |
| Series-level resolution propagation | Well collection iteration | Filtered iteration on target match |
| Historical run lookups (fallback controls) | Database queries | Indexed queries, limited to run-level data |
11. Related Documents
| Document | Relevant Sections |
|---|---|
| SRS: rule-rquant.md | RQUANT requirements |
| SRS: rule-quant-validation.md | QUANT_VALIDATION requirements |
| SRS: rule-linear-regression-validation.md | LINEAR_REGRESSION_VALIDATION requirements |
| SRS: rule-stdqt.md | STDQT requirements |
| SRS: rule-standard-curve-validation.md | Standard curve validation |
| SRS: rule-reporting-qual.md | RQUAL requirements |
| SRS: rule-reporting-quant-as-qual.md | RQUANTASQUAL requirements |
| SRS: rule-quantity-weight.md | TISSUE_WEIGHT requirements |
| SRS: rule-notts-quant-multiply.md | NOTES_QUANT_MULTIPLY requirements |
| SRS: rule-managing-quantities.md | Placeholder substitution |
| SDS: Rules Engine | Framework overview |
| SDS: Classification Rules | Classification inputs to quantification |