Specialized Rules Design
Document Type: Rule Design (Tier 2) Domain: RULES-SPECIALIZED Domain Character: Algorithmic SRS References: Multiple specialized rules (see Requirements Covered) Status: Draft Last Updated: 2026-01-25
1. Overview
1.0 Rule Summary
| Property | Value |
|---|---|
| Intent | Implement specialized analytical rules including well-type checks, cross-contamination detection, resolution propagation, repeat sample validation, missing mix handling, inconclusive detection, and standard curve quantification. |
| Inputs | Well observations, kit configuration, resolution codes, historical wells, quantification settings |
| Outputs | Error codes, LIMS statuses, calculated quantities, resolution propagation |
| Precedence | Varies by rule - see individual rule precedence in table below |
1.1 Purpose
This document describes the design of specialized analytics rules that handle specific well-type scenarios, cross-contamination detection, resolution workflows, and quantification. These rules are distinct from the core classification and outcome rules, addressing edge cases and specialized laboratory workflows.
1.2 Rules Covered
| Rule ID | Name | Description | Precedence |
|---|---|---|---|
WC | Cross Talk | - | |
WT | Well Transfer | Propagate control errors to patient wells | After control failure detection |
WCAF | Multiple Control Failures | Detect 2+ control failures in run | Run-level QC |
RWAC | Resolution Well Affecting Control | Apply resolution outcomes to patient wells | After control resolution |
ADJ | Adjacent CT | Detect cross-contamination between adjacent wells | Standalone |
ADJ_ZIKA | Adjacent Zika | Zika-specific cross-contamination with history | Standalone |
RRESOLUTION | Resolution LIMS | Set LIMS from resolution code | Resolution processing |
WREP | Repeat Sample | Validate repeat sample consistency | Standalone |
MISSING_MIXES | Missing Mixes | Detect missing mixes for combined outcomes | After Multi Mix Combined Check |
INCONCLUSIVE | Inconclusive | Flag inconclusive result patterns | Post-analysis |
QSSC | Standard Curve Quantification | Calculate quantity from CT using stored curve | Quantification phase |
1.3 Requirements Covered
| REQ ID | Title | Priority |
|---|---|---|
| - | ||
| REQ-RULES-WT-001 | Propagate Control Failure Errors to Patient Wells | Must |
| REQ-RULES-WT-002 | Clear Patient Well Errors on Control Resolution | Must |
| REQ-RULES-WT-003 | Check Fallback Mixes for Control Errors | Must |
| REQ-RULES-WCAF-001 | Detect and Mark Multiple Control Failures | Must |
| REQ-RULES-WCAF-002 | Exclude Unknown Mix Wells from Failure Counting | Must |
| REQ-RULES-WCAF-003 | Clear Error When Failures Reduce Below Threshold | Must |
| REQ-RULES-RWAC-001 | Apply Resolution Code LIMS Status to Patient Wells | Must |
| REQ-RULES-RWAC-002 | Use Fallback Controls When Primary Controls Unavailable | Must |
| REQ-RULES-RWAC-003 | Apply Highest Priority Resolution When Multiple Controls Resolved | Must |
| REQ-RULES-RWAC-004 | Allow Error Wells to Receive Resolution Outcomes | Must |
| REQ-RULES-ADJ-001 | Detect Cross-Contamination Between Adjacent Wells | Must |
| REQ-RULES-ADJ-002 | Persist Cross-Contamination Errors After Export and Re-Analysis | Must |
| REQ-RULES-ADJ-003 | Allow Resolution of Cross-Contamination Errors | Should |
| REQ-RULES-ADJ-004 | Capture Configuration Changes in Audit Log | Should |
| REQ-RULES-ADJ-005 | Support Quant-Based Cross-Contamination Detection | Should |
| REQ-RULES-ADJ-006 | Flag Wells with Missing Configuration | Must |
| REQ-RULES-ADJZIKA-001 | Apply Adjacent Well Contamination Thresholds | Must |
| REQ-RULES-ADJZIKA-002 | Suppress Errors for Repeat Accessions with Low-Positive History | Must |
| REQ-RULES-ADJZIKA-003 | Use Latest Well Number for Same-Accession History | Must |
| REQ-RULES-RRES-001 | Set Well LIMS Export from Resolution Code | Must |
| REQ-RULES-REPEATSAMP-001 | Validate Repeat Sample Consistency | Must |
| REQ-RULES-MIXMISS-001 | Identify Missing Mixes for Combined Outcome Evaluation | Must |
| REQ-RULES-MIXMISS-002 | Track and Display Missing Mixes Information | Must |
| REQ-RULES-MIXMISS-003 | Indicate Re-analysis Readiness for Missing Mixes | Must |
| REQ-RULES-MIXMISS-004 | Execute Multi Mix Combined Check Before Missing Check | Must |
| REQ-RULES-INCONCLUSIVE-001 | Generate Inconclusive Sample Error | Must |
| REQ-RULES-QSSC-001 | Execute QSSC Rule with Resolution Code Status Assignment | Must |
| REQ-RULES-QSSC-002 | Calculate Quantity Using Stored Standard Curve Settings | Must |
| REQ-RULES-QSSC-003 | Set Error When Quantification Standards Are Missing | Must |
1.4 Dependencies
2. Component Architecture
2.1 Component Diagram
2.2 Component Responsibilities
| Component | File | Responsibility | REQ Trace |
|---|---|---|---|
WcRule | Analyzer/Rules/WcRule.php | ||
WtRule | Analyzer/Rules/WtRule.php | Control error propagation | REQ-RULES-WT-* |
WcafRule | Analyzer/Rules/WcafRule.php | Multiple control failure detection | REQ-RULES-WCAF-* |
RwacRule | Analyzer/Rules/RwacRule.php | Resolution-to-patient propagation | REQ-RULES-RWAC-* |
BaseAdjRule | Analyzer/Rules/BaseAdjRule.php | Base adjacency detection logic | REQ-RULES-ADJ-001, -005, -006 |
AdjRule | Analyzer/Rules/AdjRule.php | Standard adjacency detection | REQ-RULES-ADJ-* |
AdjZikaRule | Analyzer/Rules/AdjZikaRule.php | Zika-specific adjacency with history | REQ-RULES-ADJZIKA-* |
RresolutionRule | Analyzer/Rules/RresolutionRule.php | Resolution code LIMS assignment | REQ-RULES-RRES-001 |
WrepRule | Analyzer/Rules/WrepRule.php | Repeat sample validation | REQ-RULES-REPEATSAMP-001 |
MissingMixesRule | Analyzer/Rules/MissingMixesRule.php | Missing mix detection | REQ-RULES-MIXMISS-* |
InconclusiveRule | Analyzer/Rules/InconclusiveRule.php | Inconclusive pattern detection | REQ-RULES-INCONCLUSIVE-001 |
QsscRule | Analyzer/Rules/QsscRule.php | Standard curve quantification | REQ-RULES-QSSC-* |
SetErrorToWell | Analyzer/Rules/Concerns/SetErrorToWell.php | Error assignment concern | All error rules |
SetLimsStatusToWell | Analyzer/Rules/Concerns/SetLimsStatusToWell.php | LIMS status assignment | RWAC, RRES, QSSC |
CalculateQuantityUsingQuantificationSettings | Analyzer/Rules/Concerns/... | Exponential quantity calculation | REQ-RULES-QSSC-002 |
3. Data Design
3.1 Entities
This rule collection operates across multiple entities:
| Entity | Owner | Read/Write | Used By |
|---|---|---|---|
wells | RUNRPT | Read/Write | All rules |
observations | RUNRPT | Read/Write | ADJ, WREP, QSSC |
resolution_codes | KITCFG | Read | RWAC, RRES, QSSC |
calculated_quantification_settings | KITCFG | Read | QSSC |
adjacents | KITCFG | Read | ADJ, ADJ_ZIKA |
combined_outcomes | KITCFG | Read | MISSING_MIXES |
previous_patient_wells | RUNRPT | Read | WREP, ADJ_ZIKA |
3.2 Configuration Structure
// Adjacency Configuration
interface AdjacentConfig {
mix_id: string;
target_id: string;
quant_or_ct: 'Ct' | 'Quant';
potential_contaminated: number; // threshold
potential_contaminating: number; // threshold
}
// Resolution Code Configuration
interface ResolutionCode {
code: string;
lims_status: string | null;
sets_lims_export: boolean;
affected_lims_statuses: string[] | 'All Wells';
resolution_priority: number;
error_code: ErrorCode | null;
}
// Quantification Settings
interface QuantificationSetting {
target_id: string;
slope: number;
intercept: number;
}
4. Interface Design
4.1 Rule Interface
All specialized rules implement the standard rule contract:
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 |
|---|---|---|
containsFailedExtractionControlForMixWell() | WellCollection | Check extraction control failure |
containsFailedNonExtractionControlForWell() | WellCollection | Check non-extraction control failure |
hasMultipleControlWellsWhichHasNonLabelError() | WellCollection | WCAF threshold check |
adjacentWells() | WellCollection | Get adjacent well positions |
getMatchingObservationForObservation() | PatientWellCollection | Historical observation lookup |
5. Behavioral Design
5.1 WC Rule (Cross Talk) - DEPRECATED
DEPRECATED (2026-02-02): This rule was never implemented. No
WcRule.phpexists in the codebase. Section retained for historical reference.
Algorithm: Detect Cross-Talk
Inputs:
- well: Well with observations
- assay_type: string (HSV, HTLV, or other)
- extraction_status: 'first' | 're-extraction'
Outputs:
- void (sets RXT LIMS status and warning on well)
Assumptions:
- Target positivity already determined
- Well is patient sample (not control)
Steps:
1. IF assay_type NOT IN ['HSV', 'HTLV']: RETURN (skip)
2. IF well is control sample: RETURN (skip)
3. IF extraction_status == 're-extraction': RETURN (skip)
4. Count positive non-IC targets in well
5. IF count <= 1: RETURN (no cross-talk)
6. Set LIMS = 'RXT'
7. Generate warning: "{target_a} and {target_b} are both positive. Re-extract sample"
Notes:
- IC targets always excluded from count
- Only first-time extractions trigger rule
Cross-Talk Decision Logic
| Assay | Sample Type | Extraction | Positive Non-IC Targets | Result |
|---|---|---|---|---|
| HSV/HTLV | Patient | First | 0 or 1 | No action |
| HSV/HTLV | Patient | First | 2+ | RXT + Warning |
| HSV/HTLV | Patient | Re-extract | Any | No action |
| HSV/HTLV | Control | Any | Any | No action |
| Other | Any | Any | Any | No action |
Precedence: During analytics processing phase. Default: No action when conditions not met.
5.2 WT Rule (Well Transfer) - REQ-RULES-WT-*
Algorithm: Propagate Control Errors
Inputs:
- well: Patient well being evaluated
- wells: All wells in run
- config: Kit configuration
- fallback_enabled: boolean
Outputs:
- void (sets error on well)
Steps:
1. IF well has WT resolution code:
a. Apply LIMS status from resolution
b. RETURN
2. IF wells contain failed extraction control for mix:
a. Set INHERITED_EXTRACTION_FAILURE error on well
b. RETURN
3. IF wells contain failed non-extraction control for well:
a. Set INHERITED_CONTROL_FAILURE error on well
b. RETURN
4. IF fallback_enabled AND no primary control present:
a. Check backup mix controls
b. IF backup control has failure: Set INHERITED_CONTROL_FAILURE
Notes:
- Error message distinguishes extraction vs non-extraction control type
- Errors block export until resolved
- Resolution clears WT errors automatically
WT Error Propagation Decision Logic
| Control Type | Control Status | Patient Well Action |
|---|---|---|
| Extraction | Failed | INHERITED_EXTRACTION_FAILURE |
| Non-Extraction | Failed | INHERITED_CONTROL_FAILURE |
| Any | Passed | No action |
| Fallback (enabled) | Failed | INHERITED_CONTROL_FAILURE |
| Fallback (disabled) | Failed | No action |
Precedence: After all control failure detection rules. Default: No error if no associated control has failed.
5.3 WCAF Rule (Multiple Control Failures) - REQ-RULES-WCAF-*
Algorithm: Detect Multiple Control Failures
Inputs:
- well: Well being evaluated
- wells: All wells in run
- config: Kit configuration
Outputs:
- void (sets CROSS_CNTRL_FAIL_WELL error on well and mix)
Assumptions:
- Wells with unknown mixes are excluded from count
- WCAF-generated errors are not counted in re-evaluation
Steps:
1. IF well is crossover: RETURN (skip)
2. IF well has WCAF resolution code:
a. Apply LIMS status from resolution
b. RETURN
3. IF well is control well:
a. Count control wells with non-label errors (excluding unknown mix)
b. IF count >= 2:
- Set CROSS_CNTRL_FAIL_WELL error on well
- Set CROSS_CNTRL_FAIL_MIX error on mix
Notes:
- Threshold is 2+ failures (not 1)
- Unknown mix wells excluded to prevent configuration issues from triggering
- When errors resolved below threshold, WCAF errors auto-clear
WCAF Threshold Decision Logic
| Known Mix Failures | Unknown Mix Failures | Total | Result |
|---|---|---|---|
| 0 | Any | 0 | No WCAF |
| 1 | Any | 1 | No WCAF |
| 2 | 0 | 2 | WCAF error |
| 2 | 1 | 2 | WCAF error |
| 1 | 1 | 1 | No WCAF (unknown excluded) |
Precedence: Run-level QC rule. Default: No error if fewer than 2 countable failures.
5.4 RWAC Rule (Resolution Well Affecting Control) - REQ-RULES-RWAC-*
Algorithm: Apply Resolution to Patient Wells
Inputs:
- well: Patient well
- wells: All wells in run
- config: Kit configuration (resolution codes, fallback settings)
Outputs:
- void (sets LIMS status on well)
Steps:
1. IF well has RWAC resolution code:
a. Apply LIMS status from resolution
b. RETURN
2. Get associated resolved control wells:
a. First check original mix controls
b. IF fallback enabled AND no original control: check backup mix
3. IF no resolved control found: RETURN
4. IF multiple resolved controls:
a. Sort by resolution_priority ascending (lower = higher priority)
b. Select first (highest priority)
5. Get resolution code from selected control
6. Check affected_lims_statuses:
a. IF 'All Wells': apply to patient well
b. ELSE IF patient LIMS status in affected list: apply
c. ELSE: no change
7. Set well LIMS status to resolution's lims_status
Notes:
- Fallback controls only used when primary absent
- Priority 1 beats priority 2
- Error wells can receive outcomes if error in affected list
RWAC Status Application Decision Logic
| affected_lims_statuses | Patient Current Status | Result |
|---|---|---|
| "All Wells" | Any | Apply resolution LIMS |
| ["NEG", "POS"] | "NEG" | Apply resolution LIMS |
| ["NEG", "POS"] | "IND" | No change |
| null | Any | No change |
Precedence: After control well resolution assignment. Default: No change if no matching resolution or affected status.
5.5 ADJ Rule (Adjacent CT) - REQ-RULES-ADJ-*
Algorithm: Detect Adjacent Well Cross-Contamination
Inputs:
- observation: Current observation with CT/Quant
- well: Well being evaluated
- wells: All wells in run
- adjacent_config: Contamination thresholds
Outputs:
- void (sets ADJ_CT or ADJ_LIMITS_MISSED error)
Assumptions:
- Wells arranged in standard plate grid
- Only positive, non-IC targets evaluated
Steps:
1. IF well has ADJ resolution code: RETURN
2. IF observation has negative CLS: RETURN (skip negatives)
3. IF adjacent_config is null:
a. Set ADJ_LIMITS_MISSED error
b. RETURN
4. IF observation CT/Quant is null or equals readings count: RETURN
5. Check if observation meets "potentially contaminated" threshold:
- CT mode: observation.ct > potential_contaminated_ct
- Quant mode: observation.quant < potential_contaminated_quant
IF NOT met: RETURN
6. Get adjacent well observations for same target
7. IF any adjacent missing config:
a. Set ADJ_LIMITS_MISSED error
b. RETURN
8. Check if any adjacent meets "potentially contaminating" threshold:
- CT mode: adjacent.ct < potential_contaminating_ct
- Quant mode: adjacent.quant > potential_contaminating_quant
IF met: Set ADJ_CT error
Notes:
- Errors persist through export and re-analysis
- Resolution available via Manage Outcomes
- Config changes logged to audit trail
ADJ Detection Logic (CT Mode)
| Current Well CT | Adjacent Well CT | Contaminated Threshold | Contaminating Threshold | Result |
|---|---|---|---|---|
| 35 | 18 | 30 | 25 | ADJ_CT (35 > 30 AND 18 < 25) |
| 28 | 18 | 30 | 25 | No error (28 < 30) |
| 35 | 28 | 30 | 25 | No error (28 > 25) |
| null | Any | Any | Any | No error (skip) |
Precedence: Standalone detection rule. Default: No error if thresholds not exceeded.
5.6 ADJ_ZIKA Rule - REQ-RULES-ADJZIKA-*
Algorithm: Zika-Specific Adjacent Contamination with History
Inputs:
- observation: Current observation
- well: Well being evaluated
- wells: All wells in run
- previousPatientWells: Historical patient wells
Outputs:
- void (sets ZIKA_ADJ_CT or ZIKA_ADJ_LIMITS_MISSED error)
Steps:
1. Find historical well for same accession and mix:
a. Filter by accession match
b. Filter by mix match
c. Sort by well number descending
d. Take first (latest well position)
2. IF no historical well:
a. Execute standard ADJ rule with ZIKA error codes
b. RETURN
3. Get matching observation from historical well
4. IF no matching observation:
a. Execute standard ADJ rule
b. RETURN
5. IF observation has no adjacent config: RETURN
6. Check if historical observation has "low-positive" quantity:
- Low-positive = quantity > 0 AND quantity <= potential_contaminated
IF historical is low-positive: RETURN (suppress error)
7. Execute standard ADJ rule with ZIKA error codes
Notes:
- Historical suppression prevents false positives on repeat samples
- Latest well number used when multiple wells share accession on same run
- Uses Quant mode (not CT)
ADJ_ZIKA Suppression Logic
| Historical Qty | Contaminated Threshold | Current Scenario | Result |
|---|---|---|---|
| 50 | 200 | Would trigger ADJ | Suppressed (50 in 1-200 range) |
| 300 | 200 | Would trigger ADJ | ZIKA_ADJ_CT (300 > 200) |
| null | Any | Would trigger ADJ | ZIKA_ADJ_CT (no history) |
| Any | Any | Doesn't trigger | No error |
Precedence: Standalone detection rule. Default: Falls through to standard ADJ logic.
5.7 RRESOLUTION Rule - REQ-RULES-RRES-001
Algorithm: Resolution Code LIMS Assignment
Inputs:
- well: Well with potential resolution codes
- config: Resolution code configurations
Outputs:
- void (sets LIMS status on well)
Steps:
1. IF well has no resolution codes OR has RRESOLUTION code:
a. Apply LIMS status from resolution codes
b. RETURN
2. FOR each resolution code on well:
a. Get resolution configuration from kit
b. IF not found: CONTINUE
c. Get LIMS status:
- IF resolution has error_code: use error_code.lims_status
- ELSE: use resolution.lims_status
d. IF LIMS status exists:
- Set well LIMS status
- BREAK (first match wins)
Notes:
- First matching resolution code with LIMS status wins
- Supports both direct lims_status and error_code.lims_status paths
Precedence: Resolution processing phase. Default: No modification if no resolution or no LIMS configuration.
5.8 WREP Rule (Repeat Sample) - REQ-RULES-REPEATSAMP-001
Algorithm: Validate Repeat Sample Consistency
Inputs:
- observation: Current observation
- well: Patient well
- previousPatientWells: Historical wells for comparison
Outputs:
- void (sets RQ_CLS or RQ_LOG error)
Steps:
1. IF well is not patient well: RETURN
2. IF well has WREP resolution code:
a. Apply LIMS status from resolution
b. RETURN
3. Get matching historical observation:
- Same accession, same mix, same target
4. IF no matching observation: RETURN (first-time sample)
5. IF classifications differ:
a. Set RQ_CLS error
b. RETURN
6. IF current classification is negative: RETURN (pass)
7. Calculate Log10 quantity difference:
diff = ABS(LOG10(current.quantity) - LOG10(previous.quantity))
8. IF diff > 0.5:
a. Set RQ_LOG error
Notes:
- Uses most recent previous sample when multiple exist
- Threshold 0.5 applies to Log10 values (approximately 3x difference)
- Only positive samples checked for quantitative consistency
WREP Decision Logic
| Previous CLS | Current CLS | Log10 Diff | Result |
|---|---|---|---|
| null | Any | N/A | Pass (first-time) |
| Positive | Negative | N/A | RQ_CLS error |
| Negative | Positive | N/A | RQ_CLS error |
| Negative | Negative | N/A | Pass |
| Positive | Positive | 0.3 | Pass |
| Positive | Positive | 0.7 | RQ_LOG error |
Precedence: Standalone validation rule. Default: Pass if first-time or consistent.
5.9 MISSING_MIXES Rule - REQ-RULES-MIXMISS-*
Algorithm: Detect Missing Mixes for Combined Outcomes
Inputs:
- well: Patient well
- wells: All wells in run
- config: Combined outcome mappings
- recentlyUploadedWells: Wells from other recent runs
Outputs:
- void (sets COMBINED_MIXES_WELLS_MISSING error)
Assumptions:
- Multi Mix Combined Check executes before this rule
- mixes_missing toggle controls rule activation
Steps:
1. IF well has no mix OR not patient well: RETURN
2. Get combined outcome mappings with mixes_missing=true
3. FOR each mapping:
a. Get required mixes from mapping
b. FOR each required mix:
- Check if successful well exists for mix
- "Successful" = no error, or has mixes_missing error, or has info-typed LIMS
- IF allow_other_runs_to_be_used:
- Also check recently uploaded wells with mixes_missing error
c. IF any mix missing:
- Set COMBINED_MIXES_WELLS_MISSING error
- Store list of missing mix names
- Populate outcome message with missing mixes
4. On new run import with missing mix now available:
- Update old run status to "Reanalysis required (Missing mixes uploaded)"
- Only if all previously missing mixes now available
- Only if no existing resolution status
Notes:
- Wells with mixes_missing error are considered "successful" for mix availability
- Cross-run resolution requires wells with mixes_missing error (not just any well)
Successful Well Definition
| Well State | Successful? |
|---|---|
| No errors | Yes |
| COMBINED_MIXES_WELLS_MISSING error | Yes |
| Information-typed LIMS | Yes |
| Label Error | No |
| Warning Error | No |
| Warning/Exclude LIMS | No |
Precedence: After Multi Mix Combined Check. Default: No error if all mixes present.
5.10 INCONCLUSIVE Rule - REQ-RULES-INCONCLUSIVE-001
Algorithm: Detect Inconclusive Result Pattern
Inputs:
- well: Well with observations
- config: Kit configuration (error codes)
Outputs:
- void (sets INCONCLUSIVE_WELL error)
Steps:
1. IF well has INCONCLUSIVE resolution code:
a. Set LIMS status to 'INCONCLUSIVE'
b. RETURN
2. Get non-IC, active target observations
3. Check if:
- At least one observation has Negative final CLS
- At least one observation has Positive final CLS
4. IF both conditions met:
a. Set INCONCLUSIVE_WELL error
b. Flag for bulk management visibility
Notes:
- Passive targets excluded from evaluation
- IC targets excluded from evaluation
- Enables bulk processing of inconclusive samples
INCONCLUSIVE Pattern Detection
| Non-IC Target 1 | Non-IC Target 2 | Result |
|---|---|---|
| Positive | Positive | No error |
| Negative | Negative | No error |
| Positive | Negative | INCONCLUSIVE_WELL |
| Negative | Positive | INCONCLUSIVE_WELL |
Precedence: Post-analysis (after classification). Default: No error if pattern not detected.
5.11 QSSC Rule (Standard Curve Quantification) - REQ-RULES-QSSC-*
Algorithm: Calculate Quantity from Standard Curve
Inputs:
- observation: Observation with CT value
- well: Well (for quantity multiplier)
- config: Quantification settings, resolution codes
Outputs:
- void (sets quantity on observation, or error, or LIMS status)
Steps:
1. IF well has QSSC resolution code:
a. Apply LIMS status from resolution code config
b. RETURN (bypass calculation)
2. Get quantification settings for observation's target:
- slope, intercept
3. IF settings missing OR no slope/intercept:
a. Set QUANT_STANDARDS_MISSING error
b. RETURN
4. Calculate quantity:
quantity = multiplier * pow(10, ((ct - intercept) / slope))
5. Set observation quantity
Notes:
- Uses accurate CT (not rounded)
- Multiplier is well-level scaling factor
- Exponential formula is authoritative (base-10 logarithmic)
QSSC Calculation Examples
| CT | Slope | Intercept | Multiplier | Quantity |
|---|---|---|---|---|
| 28.1235 | -1 | 30 | 1 | 75.248873017358 |
| 28.12345678 | -1 | 30 | 1 | 75.256361986851 |
| 36 | 0.123 | 0.234 | 100 | 466 (approx) |
| 40 | -1 | 30 | 1 | 0.0000000001 |
Precedence: Quantification phase. Default: Error if configuration missing.
6. Error Handling
| Rule | Condition | Error Code | Response |
|---|---|---|---|
| WT | Extraction control failed | INHERITED_EXTRACTION_FAILURE | Block export |
| WT | Non-extraction control failed | INHERITED_CONTROL_FAILURE | Block export |
| WCAF | 2+ control failures | CROSS_CNTRL_FAIL_WELL | Mark for replate |
| ADJ | Cross-contamination detected | ADJ_CT | Flag for resolution |
| ADJ | Missing configuration | ADJ_LIMITS_MISSED | Block rule execution |
| ADJ_ZIKA | Cross-contamination detected | ZIKA_ADJ_CT | Flag for resolution |
| ADJ_ZIKA | Missing configuration | ZIKA_ADJ_LIMITS_MISSED | Block rule execution |
| WREP | Classification mismatch | RQ_CLS | Flag for review |
| WREP | Quantity threshold exceeded | RQ_LOG | Flag for review |
| MIXMISS | Mixes missing | COMBINED_MIXES_WELLS_MISSING | Block until mixes available |
| INCONC | Inconclusive pattern | INCONCLUSIVE_WELL | Flag for bulk management |
| QSSC | Missing settings | QUANT_STANDARDS_MISSING | Block quantification |
7. Configuration
| Setting | Rule | Path | Default | Effect |
|---|---|---|---|---|
fallback_shared_control | WT, RWAC | Client config | false | Enable fallback mix checking |
resolution_priority | RWAC | Per role | Per role | Lower = higher priority |
potential_contaminated_ct | ADJ | Per mix/target | Required | Contaminated threshold |
potential_contaminating_ct | ADJ | Per mix/target | Required | Contaminating threshold |
quant_or_ct | ADJ | Per mix/target | Ct | Evaluation mode |
mixes_missing | MIXMISS | Per combined outcome | false | Enable missing mixes check |
allow_other_runs_to_be_used | MIXMISS | Per combined outcome | false | Cross-run resolution |
wrep_log_quant_threshold | WREP | Client config | 0.5 | Log10 difference threshold |
See Configuration Reference for full documentation.
8. Implementation Mapping
8.1 Code Locations
| Component | Path |
|---|---|
code/app/Analyzer/Rules/WcRule.php | |
| WT Rule | code/app/Analyzer/Rules/WtRule.php |
| WCAF Rule | code/app/Analyzer/Rules/WcafRule.php |
| RWAC Rule | code/app/Analyzer/Rules/RwacRule.php |
| Base ADJ Rule | code/app/Analyzer/Rules/BaseAdjRule.php |
| ADJ Rule | code/app/Analyzer/Rules/AdjRule.php |
| ADJ Zika Rule | code/app/Analyzer/Rules/AdjZikaRule.php |
| RRESOLUTION Rule | code/app/Analyzer/Rules/RresolutionRule.php |
| WREP Rule | code/app/Analyzer/Rules/WrepRule.php |
| Missing Mixes Rule | code/app/Analyzer/Rules/MissingMixesRule.php |
| Inconclusive Rule | code/app/Analyzer/Rules/InconclusiveRule.php |
| QSSC Rule | code/app/Analyzer/Rules/QsscRule.php |
| Error Setter | code/app/Analyzer/Rules/Concerns/SetErrorToWell.php |
| LIMS Setter | code/app/Analyzer/Rules/Concerns/SetLimsStatusToWell.php |
| Quantity Calculator | code/app/Analyzer/Rules/Concerns/CalculateQuantityUsingQuantificationSettings.php |
8.2 Requirement Traceability
| REQ ID | Design Section | Primary Code |
|---|---|---|
WcRule.php | ||
| REQ-RULES-WT-001 | Section 5.2 | WtRule.php |
| REQ-RULES-WT-002 | Section 5.2 | WtRule.php |
| REQ-RULES-WT-003 | Section 5.2 | WtRule.php |
| REQ-RULES-WCAF-001 | Section 5.3 | WcafRule.php |
| REQ-RULES-WCAF-002 | Section 5.3 | WcafRule.php |
| REQ-RULES-WCAF-003 | Section 5.3 | WcafRule.php |
| REQ-RULES-RWAC-001 | Section 5.4 | RwacRule.php |
| REQ-RULES-RWAC-002 | Section 5.4 | RwacRule.php |
| REQ-RULES-RWAC-003 | Section 5.4 | RwacRule.php |
| REQ-RULES-RWAC-004 | Section 5.4 | RwacRule.php |
| REQ-RULES-ADJ-001 | Section 5.5 | AdjRule.php, BaseAdjRule.php |
| REQ-RULES-ADJ-002 | Section 5.5 | AdjRule.php |
| REQ-RULES-ADJ-003 | Section 5.5 | AdjRule.php |
| REQ-RULES-ADJ-004 | Section 5.5 | Audit logging |
| REQ-RULES-ADJ-005 | Section 5.5 | BaseAdjRule.php |
| REQ-RULES-ADJ-006 | Section 5.5 | BaseAdjRule.php |
| REQ-RULES-ADJZIKA-001 | Section 5.6 | AdjZikaRule.php |
| REQ-RULES-ADJZIKA-002 | Section 5.6 | AdjZikaRule.php |
| REQ-RULES-ADJZIKA-003 | Section 5.6 | AdjZikaRule.php |
| REQ-RULES-RRES-001 | Section 5.7 | RresolutionRule.php |
| REQ-RULES-REPEATSAMP-001 | Section 5.8 | WrepRule.php |
| REQ-RULES-MIXMISS-001 | Section 5.9 | MissingMixesRule.php |
| REQ-RULES-MIXMISS-002 | Section 5.9 | MissingMixesRule.php |
| REQ-RULES-MIXMISS-003 | Section 5.9 | MissingMixesRule.php |
| REQ-RULES-MIXMISS-004 | Section 5.9 | MissingMixesRule.php |
| REQ-RULES-INCONCLUSIVE-001 | Section 5.10 | InconclusiveRule.php |
| REQ-RULES-QSSC-001 | Section 5.11 | QsscRule.php |
| REQ-RULES-QSSC-002 | Section 5.11 | QsscRule.php, CalculateQuantityUsingQuantificationSettings.php |
| REQ-RULES-QSSC-003 | Section 5.11 | QsscRule.php |
9. Design Decisions
| Decision | Rationale | Alternatives Considered |
|---|---|---|
| Inheritance for ADJ rules | Share core logic, specialize error codes/history | Duplicate code (rejected: maintenance burden) |
| Resolution code bypass pattern | Consistent manual override mechanism | Per-rule bypass logic (rejected: inconsistent) |
| Threshold-based contamination | Configurable per assay/target | Hardcoded thresholds (rejected: inflexible) |
| Cross-run for missing mixes | Support multi-run workflows | Single-run only (rejected: workflow limitation) |
| Log10 for quantity comparison | Industry standard for PCR | Linear comparison (rejected: inappropriate scale) |
| Exponential formula for QSSC | Corrects earlier linear model error | Linear formula (rejected: mathematically incorrect) |
10. Performance Considerations
| Rule | Scenario | Concern | Mitigation |
|---|---|---|---|
| ADJ | Large plates (384 wells) | O(n) adjacent lookups | Pre-compute adjacency map |
| WREP | Many historical samples | Database queries | Index on accession/mix |
| MIXMISS | Cross-run lookups | Multiple run queries | Cache recently uploaded wells |
| RWAC | Multiple controls | Priority sorting | Sort once per well |
11. Related Documents
| Document | Relevant Sections |
|---|---|
| SRS: rule-wt.md | WT requirements |
| SRS: rule-wcaf.md | WCAF requirements |
| SRS: rule-rwac.md | RWAC requirements |
| SRS: rule-adj.md | ADJ requirements |
| SRS: rule-adj-zika.md | ADJ_ZIKA requirements |
| SRS: rule-rresolution.md | RRESOLUTION requirements |
| SRS: rule-repeat-sample.md | WREP requirements |
| SRS: rule-mixes-missing.md | MISSING_MIXES requirements |
| SRS: rule-managing-inconclusive.md | INCONCLUSIVE requirements |
| SRS: rule-qssc.md | QSSC requirements |
| SDS: Rules Engine | Framework overview |
| SDS: Combined Outcomes | Combined outcome rules |