STD: Standard Quantity Rule (STDQT)
Version: v1.0.0
Status: Draft
SRS Source: docusaurus/docs/srs/rules/rule-stdqt.md
Rule Name: STDQT
Domain: RULES-STDQT
Overview
This document specifies tests for the Standard Quantity (STDQT) rule using decision tables and test vectors. The rule calculates patient sample quantities using standard curve quantification parameters (gradient and intercept) derived from quantitative standard controls on each run.
Rule Characteristics:
- Pure business logic (no UI)
- Formula-based calculation:
quantity = 10^((CT - intercept) / gradient)
- Post-calculation multiplier application
- Fallback control support for missing standards
- Error propagation from run target quantification failures
- Configurable well failure scope
Test Method: TM-API (per Test Plan - Rules use automated API tests)
Verification Approach:
Rule verification is performed using data-driven test vectors. Each row in a decision table represents a complete verification scenario with defined inputs and expected outputs. This format enables exhaustive condition coverage while remaining concise and auditable.
Coverage Summary
| REQ ID | Title | Conditions | Test Vectors | Coverage | Gaps | Automation Status |
|---|
| REQ-RULES-STDQT-001 | Calculate Standard Quantity | 12 | 18 | 100% | None | Automated |
| REQ-RULES-STDQT-002 | Apply Quantity Multiplier | 3 | 4 | 100% | None | Automated |
| REQ-RULES-STDQT-003 | Use Fallback Standard Controls | 4 | 4 | 100% | None | Automated |
| REQ-RULES-STDQT-004 | Propagate Run Target Errors | 6 | 7 | 100% | None | Automated |
| REQ-RULES-STDQT-005 | Configure Well Failure Scope | 6 | 8 | 100% | None | Automated |
Totals: 5 REQs, 31 Conditions, 41 Test Vectors, 100% Coverage
REQ-RULES-STDQT-001: Calculate Standard Quantity
| Variable | Type | Valid Values | Description |
|---|
obs.role | string | Sample, Extraction Control, Control, Quantitative Control, Ignore | Observation role |
obs.classification | string | Positive, Negative, Ambiguous | Observation classification |
obs.ct | float | numeric, null | Cycle threshold value |
obs.quantity | float? | numeric, null | Pre-existing quantity (from runfile) |
run_target.gradient | float? | numeric, null | Standard curve slope |
run_target.intercept | float? | numeric, null | Standard curve y-intercept |
Output Variables
| Variable | Type | Description |
|---|
obs.quantity | float? | Calculated or preserved quantity |
obs.error_code | string? | Error code (UNABLE_TO_QUANTIFY or null) |
Decision Table: Role Eligibility
| TV | obs.role | eligible | Covers |
|---|
| TV-001-001 | Sample | true | AC: Calculate for role=Sample |
| TV-001-002 | Extraction Control | false | AC: Exclude Extraction Control |
| TV-001-003 | Control | false | AC: Exclude Control |
| TV-001-004 | Quantitative Control | false | AC: Exclude Quantitative Control |
| TV-001-005 | Ignore | false | AC: Exclude Ignore |
Decision Table: Classification Eligibility
| TV | obs.role | obs.classification | quantity_result | error_code | Covers |
|---|
| TV-001-006 | Sample | Positive | calculated | null | AC: Calculate for Positive |
| TV-001-007 | Sample | Negative | null | null | AC: Set null for Negative (no error) |
| TV-001-008 | Sample | Ambiguous | null | null | AC: Set null for Ambiguous (no error) |
| TV | gradient | intercept | ct | expected_quantity | Covers |
|---|
| TV-001-009 | -1 | 33 | 27 | 1,000,000 | AC: Basic formula (10^6) |
| TV-001-010 | -1 | 33 | 32 | 10 | AC: Formula yields 10^1 |
| TV-001-011 | -3.3 | 40 | 30 | 1,000 | AC: Non-integer gradient |
Decision Table: Existing Quantity Override
| TV | gradient | intercept | ct | existing_qty | final_qty | Covers |
|---|
| TV-001-012 | -1 | 33 | 27 | null | 1,000,000 | AC: Calculate when no existing |
| TV-001-013 | -1 | 33 | 27 | 100 | 1,000,000 | AC: Replace existing with calculated |
Decision Table: Missing Parameters
| TV | gradient | intercept | existing_qty | final_qty | error_code | Covers |
|---|
| TV-001-014 | null | 33 | null | null | UNABLE_TO_QUANTIFY | AC: Missing gradient, no existing |
| TV-001-015 | -1 | null | null | null | UNABLE_TO_QUANTIFY | AC: Missing intercept, no existing |
| TV-001-016 | null | null | null | null | UNABLE_TO_QUANTIFY | AC: Both missing, no existing |
| TV-001-017 | null | 33 | 1000 | 1000 | UNABLE_TO_QUANTIFY | AC: Missing gradient, preserve existing |
| TV-001-018 | null | null | 1000 | 1000 | UNABLE_TO_QUANTIFY | AC: Both missing, preserve existing |
REQ-RULES-STDQT-002: Apply Quantity Multiplier
| Variable | Type | Valid Values | Description |
|---|
well.quantity_multiplier | float | numeric (default 1.0) | Scaling factor for quantity |
calculated_quantity | float | numeric | Base quantity from STDQT-001 |
Output Variables
| Variable | Type | Description |
|---|
obs.quantity | float | Final quantity after multiplier |
Decision Table: Multiplier Application
| TV | gradient | intercept | ct | multiplier | base_qty | final_qty | Covers |
|---|
| TV-002-001 | -1 | 33 | 32 | 160 | 10 | 1,600 | AC: Multiply base by multiplier |
| TV-002-002 | -1 | 33 | 27 | 1.0 | 1,000,000 | 1,000,000 | AC: Default multiplier (no change) |
| TV-002-003 | -1 | 33 | 32 | 0.5 | 10 | 5 | AC: Fractional multiplier |
| TV-002-004 | -1 | 33 | 32 | 1000 | 10 | 10,000 | AC: Large multiplier |
REQ-RULES-STDQT-003: Use Fallback Standard Controls
| Variable | Type | Valid Values | Description |
|---|
use_fallback_shared_controls | bool | true, false | Feature toggle |
primary_mix.has_standards | bool | true, false | Whether primary mix has standard controls |
control_mapping | object | configured | Defines backup control relationships |
alternate_mix.has_standards | bool | true, false | Whether alternate mix has standard controls |
Output Variables
| Variable | Type | Description |
|---|
quantification_source | string | primary, fallback, none |
obs.quantity | float? | Calculated quantity or null |
Decision Table: Fallback Controls
| TV | feature_enabled | primary_has_standards | fallback_available | quantification_source | Covers |
|---|
| TV-003-001 | true | false | true | fallback | AC: Use backup when enabled and no primary |
| TV-003-002 | false | false | true | none | AC: No quantification when disabled |
| TV-003-003 | true | true | true | primary | AC: Prefer primary when available |
| TV-003-004 | true | false | false | none | AC: No quantification without any standards |
REQ-RULES-STDQT-004: Propagate Run Target Quantification Errors
| Variable | Type | Valid Values | Description |
|---|
run_target.error_codes | array | see table | Run target quantification errors |
well.role_alias | string | Patient, NEC, PEC, ... | Well role |
Output Variables
| Variable | Type | Description |
|---|
well.error_code | string? | UNABLE_TO_QUANTIFY or null |
Decision Table: Error Propagation by Error Type
| TV | run_target_error | patient_well_receives_error | Covers |
|---|
| TV-004-001 | INSUFFICIENT_STANDARD_CONTROLS | UNABLE_TO_QUANTIFY | AC: Insufficient controls |
| TV-004-002 | STANDARD_WITHOUT_QUANT | UNABLE_TO_QUANTIFY | AC: Standard without quantity |
| TV-004-003 | BAD_R2 | UNABLE_TO_QUANTIFY | AC: Bad R-squared |
| TV-004-004 | BAD_GRADIENT | UNABLE_TO_QUANTIFY | AC: Bad gradient |
| TV-004-005 | BAD_EFFICIENCY | UNABLE_TO_QUANTIFY | AC: Bad efficiency |
| TV-004-006 | none | null | AC: No error, no propagation |
Decision Table: Error Propagation Scope
| TV | run_target_error | well.role_alias | well_receives_error | Covers |
|---|
| TV-004-007 | BAD_R2 | Patient | UNABLE_TO_QUANTIFY | AC: Error propagates to patient wells |
| Variable | Type | Valid Values | Description |
|---|
only_fail_positive_wells | bool | true, false | Configuration option |
well.classification | string | Positive, Negative, Ambiguous | Well classification |
associated_control.outcome | string | Passed, Failed | Control outcome |
Output Variables
| Variable | Type | Description |
|---|
well.error_code | string? | UNABLE_TO_QUANTIFY or null |
Decision Table: Failure Scope (only_fail_positive = true)
| TV | only_fail_positive | classification | control_failed | receives_error | Covers |
|---|
| TV-005-001 | true | Positive | true | UNABLE_TO_QUANTIFY | AC: Positive receives error |
| TV-005-002 | true | Negative | true | null | AC: Negative protected |
| TV-005-003 | true | Ambiguous | true | null | AC: Ambiguous protected |
| TV-005-004 | true | Positive | false | null | AC: No error when control passes |
Decision Table: Failure Scope (only_fail_positive = false)
| TV | only_fail_positive | classification | control_failed | receives_error | Covers |
|---|
| TV-005-005 | false | Positive | true | UNABLE_TO_QUANTIFY | AC: Positive receives error |
| TV-005-006 | false | Negative | true | UNABLE_TO_QUANTIFY | AC: Negative receives error |
| TV-005-007 | false | Ambiguous | true | UNABLE_TO_QUANTIFY | AC: Ambiguous receives error |
| TV-005-008 | false | Positive | false | null | AC: No error when control passes |
Boundary Value Analysis
CT Values
| TV | ct_value | context | Covers |
|---|
| TC-BVA-001 | 0 | Minimum CT | Edge: Zero CT |
| TC-BVA-002 | 45 | Maximum typical CT | Edge: High CT |
| TC-BVA-003 | 33 | CT equals intercept | Edge: Log result = 0, quantity = 1 |
Quantity Multiplier
| TV | multiplier | context | Covers |
|---|
| TC-BVA-004 | 0.001 | Very small multiplier | Edge: Fractional result |
| TC-BVA-005 | 10000 | Very large multiplier | Edge: Large scaling |
Traceability to Existing Tests
| Requirement | Jira Tests | Status | Notes |
|---|
| REQ-RULES-STDQT-001 | BT-5355, BT-5687 | Existing | BT-5355 (v2), BT-5687 (v3) - STDQT calculation |
| REQ-RULES-STDQT-002 | BT-5359 | Existing | NOTES_QUANT_MULTIPLY (v2) |
| REQ-RULES-STDQT-003 | BT-5250 | Existing | MINEXTRACT/FALLBACK (v3) |
| REQ-RULES-STDQT-004 | BT-5000, BT-5001, BT-4999, BT-5072, BT-5083, BT-5002, BT-5081 | Existing | LINEAR_REGRESSION error propagation |
| REQ-RULES-STDQT-005 | Pending | Gap | No valid test found (BT-4931 does not exist) |
Gap Analysis
Identified Gaps
| Gap | Requirement | Description | Priority | Owner |
|---|
| GAP-001 | REQ-RULES-STDQT-005 | No valid test for well failure scope configuration | Medium | TBD |
- GAP-001: Create test ticket covering TV-005-001 through TV-005-008 (well failure scope)
Resolved Gaps
GAP-001 (old): REQ-RULES-STDQT-002 now covered by BT-5359
GAP-002 (old): REQ-RULES-STDQT-003 now covered by BT-5250
GAP-003 (old): REQ-RULES-STDQT-004 now covered by BT-5000/5001/4999/5072/5083/5002/5081