Skip to main content
Version: 3.0.0

Run Report Domain Design

Document Type: Domain Design (Tier 2) Domain: RUNRPT Domain Character: Stateful SRS Reference: runfile-report.md, comments.md Status: Draft Last Updated: 2026-01-25


1. Overview

1.1 Purpose

The Run Report domain provides the primary interface for viewing, analyzing, and managing individual run file contents. It orchestrates well data display, quality control analysis, result resolution workflows, and export operations.

This is a stateful domain because it manages:

  • Run entity lifecycle (upload, analysis, resolution, export)
  • Well entity state transitions (error, resolved, exported)
  • Resolution workflow state (proposed, approved, rejected)
  • Widget configuration state (open/closed, pinned, position)

The domain coordinates heavily with NOTIF for status notifications, COMMENTS for user annotations, and the rules engine for outcome determination.

1.2 Requirements Covered

REQ IDTitlePriority
REQ-RUNRPT-001Display Run File ContentsMust
REQ-RUNRPT-002Access Analytical WidgetsMust
REQ-RUNRPT-003Re-analyze Run FileMust
REQ-RUNRPT-004Print Run File ReportMust
REQ-RUNRPT-005View Run InformationMust
REQ-RUNRPT-006Edit Well InformationMust
REQ-RUNRPT-007Manage Well ResultsMust
REQ-RUNRPT-008Export Run Results to LIMSMust
REQ-RUNRPT-009Sort Well TableShould
REQ-RUNRPT-010Filter Well TableShould
REQ-RUNRPT-011Display Amplification CurvesShould
REQ-RUNRPT-012Provide Well Action MenuShould
REQ-RUNRPT-013Select WellsShould
REQ-RUNRPT-014Display Run File NotificationsMust
REQ-RUNRPT-015Configure Composite Assay OutcomesShould
REQ-RUNRPT-016Display Accession HistoryShould
REQ-RUNRPT-017Support Multi-Site OperationShould
REQ-RUNRPT-018Display Westgard Quality Control AnalysisMust
REQ-RUNRPT-019Display Assay SummaryShould
REQ-RUNRPT-020Display Outcome SummaryShould
REQ-RUNRPT-021Display Plate MapShould
REQ-RUNRPT-022Display Quantification AnalysisShould
REQ-RUNRPT-023Bulk Edit WellsShould
REQ-RUNRPT-024Bulk Manage ResultsShould
REQ-RUNRPT-025Display System FlagsShould
REQ-RUNRPT-026Warn Before Losing Unsaved ChangesShould
REQ-RUNRPT-027Persist Widget StateShould
REQ-RUNRPT-028Validate Well DataMust
REQ-COMMENTS-001Tag Internal Users in CommentsMust
REQ-COMMENTS-002Tag External Users by EmailShould
REQ-COMMENTS-003Send Email Notifications for TagsMust
REQ-COMMENTS-004Configure Notification PreferencesShould
REQ-COMMENTS-005Display Notification IndicatorMust
REQ-COMMENTS-006Display Notifications ListMust
REQ-COMMENTS-007Manage Notification Read StatusShould
REQ-COMMENTS-008Mark All Notifications as ReadShould
REQ-COMMENTS-009Navigate to Tagged CommentsMust
REQ-COMMENTS-010Filter Mentionable Users by RoleMust

1.3 Constraints

Tier 2 Constraint: This document describes ownership, patterns, and design rationale. It links to reference docs for full schemas and API specifications.

1.4 Dependencies

DirectionDomain/ComponentPurpose
ConsumesKit ConfigurationMix/target definitions, display order
Analyzer/Rules EngineWell outcome determination
Client ConfigurationWidget availability, export formats
Notification SubsystemStatus indicators, counts
Provides toRUNFILE ListRun status, metadata
LIMS IntegrationExport files
Print SystemFormatted reports

2. Component Architecture

2.1 Component Diagram

2.2 Component Responsibilities

ComponentLayerResponsibilityREQ Trace
RunBackend ModelCore run entity with metadata, relationships, statusREQ-RUNRPT-001, 005, 014
WellBackend ModelWell entity with results, errors, resolution stateREQ-RUNRPT-001, 006, 007, 008
CommentBackend ModelPolymorphic comments on runs and wellsREQ-COMMENTS-001 through 009
NotificationBackend ModelUser notification entities with read statusREQ-COMMENTS-005 through 008
GetRunStatusBackend ServiceAggregate run status calculationREQ-RUNRPT-001
RunsControllerBackend ControllerRun CRUD and query operationsREQ-RUNRPT-001, 003, 005
WellsControllerBackend ControllerWell editing and resolution operationsREQ-RUNRPT-006, 007
CommentsControllerBackend ControllerComment CRUD with mention handlingREQ-COMMENTS-001, 002
NotificationsControllerBackend ControllerNotification read status managementREQ-COMMENTS-007, 008
RunResultExportJobBackend JobAsynchronous LIMS export generationREQ-RUNRPT-008
RunViewFrontend ViewMain run report page orchestrationREQ-RUNRPT-001, 002
WellsTableFrontend ComponentWell data table with selectionREQ-RUNRPT-001, 009, 010, 013
WidgetSystemFrontend ComponentAnalytical widget container/stateREQ-RUNRPT-002, 027
EditWellWidgetFrontend ComponentWell property editingREQ-RUNRPT-006, 023
ManageResultsWidgetFrontend ComponentResolution workflow UIREQ-RUNRPT-007, 024
CommentSystemFrontend ComponentComment display and mention handlingREQ-COMMENTS-001, 009, 010

3. Data Design

3.1 Entities

This domain owns the following entities:

EntityTablePurpose
RunrunsCore run file entity with metadata
WellwellsIndividual well results and state
CommentcommentsPolymorphic comments (runs, wells)
NotificationnotificationsUser-targeted notifications

See Database Reference for full schema.

3.2 Entity Relationships

3.3 Run Status Calculation

The GetRunStatus service computes aggregate run status based on well states:

Algorithm: Calculate Run Status

Inputs:
- wells: Collection<Well> - All patient wells in the run

Outputs:
- status: string - One of the run status values

Steps:
1. Partition wells into categories:
a. notExportedWells: wells where export_date is null
b. errorWells: wells with Error, Label Error, or Associate Control Error
c. limsStatusWells: wells with a lims_status set

2. Determine status:
a. If notExportedWells is empty:
Return 'ALL_WELLS_EXPORTED'
b. If errorWells is empty:
Return 'ALL_WELLS_READY_FOR_EXPORT'
c. If limsStatusWells is empty:
Return 'NO_EXPORT_ERRORS_TO_RESOLVE'
d. Otherwise:
Return 'SOME_WELLS_READY_FOR_EXPORT_WITH_ERRORS_TO_RESOLVE'

Notes:
- Only patient wells are considered (controls excluded)
- The presence of limsStatusWells indicates resolvable errors

3.4 Data Structures

Run Constants

const RUN_STATUS = [
'ALL_WELLS_EXPORTED' => 1,
'ALL_WELLS_READY_FOR_EXPORT' => 2,
'NO_EXPORT_ERRORS_TO_RESOLVE' => 3,
'SOME_WELLS_READY_FOR_EXPORT_WITH_ERRORS_TO_RESOLVE' => 4,
];

const CALIBRATION_STATUS = [
'NOT_CALIBRATED' => 0,
'CALIBRATING' => 1,
'CALIBRATED' => 2,
];

Well Outcome Type Mapping

const OUTCOME_TYPE_TO_BACKGROUND_COLOR = [
'Passed Control' => 'BLUE',
'Information' => 'GREEN',
'Warning' => 'YELLOW',
'Error' => 'RED',
'Label Error' => 'RED',
'Exclude' => 'GRAY',
'Associate Control Error' => 'RED',
];

const LIMS_STATUS_TO_OUTCOME_TYPE = [
'EXCLUDE' => 'Error',
'RPT' => 'Warning',
'RXT' => 'Warning',
];

4. Interface Design

4.1 APIs Provided

EndpointMethodPurposeResponse
/api/runs/:idGETGet run details with wellsRun with nested wells, notifications
/api/runs/:id/wellsGETGet wells for runPaginated wells with relationships
/api/wells/:idPATCHUpdate well propertiesUpdated well
/api/wells/:id/resolvePOSTApply resolution to wellUpdated well with resolution
/api/runs/:id/exportPOSTTrigger LIMS exportJob status
/api/runs/:id/commentsGET/POSTRun-level commentsComment list/new comment
/api/wells/:id/commentsGET/POSTWell-level commentsComment list/new comment

4.2 APIs Consumed

EndpointMethodPurpose
/api/mixesGETMix definitions for display order
/api/client-configurationGETWidget availability, export formats
/api/notificationsGETUser notification counts

4.3 Events

EventDirectionPayloadPurpose
RunUpdatedBackend -> Frontend{ run_id, status, wells_updated }Real-time status updates
WellUpdatedBackend -> Frontend{ well_id, changes }Well state change notification
NotificationReadBackend{ notification_id, user_id }Update read status
CommentCreatedBackend{ comment_id, mentions }Trigger mention notifications

5. Behavioral Design

5.1 Run State Machine

Runs progress through analysis and export states:

5.2 Well State Machine

Individual wells have their own state progression:

5.3 Resolution Workflow

Algorithm: Apply Resolution to Well

Inputs:
- well_id: UUID - Well to resolve
- resolution_code_id: UUID - Resolution to apply
- user_id: UUID - User performing resolution
- message: string (optional) - Resolution reason

Outputs:
- well: Well - Updated well entity

Assumptions:
- User has permission to resolve wells
- Resolution code is valid for the error type

Steps:
1. Load well with error code relationship
2. Validate resolution code is applicable:
a. Check error type matches resolution's allowed types
b. Check role priority if applicable
3. Update well:
a. Set resolution_codes to resolution_code.resolution_code
b. Set lims_status to resolution_code.limsStatusWhenResolving()
c. Clear proposed_resolution_code_id if approved
4. If resolution affects other wells (contains 'ALL'):
a. Find affected wells (same run, same criteria)
b. Apply resolution to all affected wells
5. Fire WellUpdated event
6. Recalculate run status
7. Return updated well

Notes:
- Some resolutions require manager approval
- Resolution can be rejected, returning well to error state
- Bulk resolutions apply to all selected wells

5.4 Comment Mention Processing

Algorithm: Process Comment Mentions

Inputs:
- comment: Comment - Newly created comment
- mentions: array - Extracted @mentions from text
- commenter: User - User who created the comment

Outputs:
- notifications: Collection<Notification> - Created notifications

Steps:
1. For each mention in mentions:
a. If mention is email format:
- Send external email invitation
- Skip notification creation
b. Else:
- Look up user by display name
- Check mentionable based on commenter's role (REQ-COMMENTS-010)
- Create Notification for mentioned user

2. For each created notification:
a. Check user's notification preference
b. If preference includes 'in-app':
- Save notification to database
c. If preference includes 'email':
- Queue UserHasNotifiedMail job

3. Return created notifications

Notes:
- External email invitations always send email regardless of preference
- Role filtering: JUNIOR/SENIOR/MANAGER can mention JUNIOR/SENIOR/MANAGER
- CLIENT_ADMIN cannot mention anyone
- SUPER_ADMIN can mention all roles

6. Error Handling

ConditionDetectionResponseUser Impact
Invalid accession charactersValidation ruleReject input, show validation errorCannot save until corrected
Control label wildcard errorValidation ruleReject input, show validation errorCannot save until corrected
Well label contains "null"Validation ruleReject labelCannot save until corrected
Export location unavailableFile system checkLog error, show user messageExport fails, retry available
No exportable wellsPre-export validationPrevent export, show messageCannot export until wells resolved
Resolution code invalid for errorBusiness ruleReject resolutionMust select valid resolution
Concurrent edit conflictOptimistic lockingShow conflict warningMust refresh and retry

7. Configuration

SettingLocationDefaultEffect
accession_history_enabledclient_configurationsper-clientEnables accession history feature
available_widgetsclient_configurationsper-clientControls widget visibility
available_print_optionsclient_configurationsper-clientControls print option visibility
lims_export_formatsclient_configurationsper-clientAvailable export format list
lims_reports_folderclient_configurationsLIMS_ReportsExport destination folder
multi_site_enabledclient_configurationsper-clientEnables multi-site features
default_pinned_widgetsclient_configurationsper-clientWidgets pinned by default
count_system_generated_commentsclient_configurationstrueInclude system comments in counts
default_notification_preferenceN/ABothDefault for new users

See Configuration Reference for details.


8. Implementation Mapping

8.1 Code Locations

ComponentTypePath
RunModelcode/app/Run.php
WellModelcode/app/Well.php
CommentModelcode/app/Comment.php
NotificationModelcode/app/Notification.php
GetRunStatusServicecode/app/GetRunStatus.php
RunsControllerControllercode/app/Http/Controllers/RunsController.php
WellsControllerControllercode/app/Http/Controllers/WellsController.php
CommentsControllerControllercode/app/Http/Controllers/CommentsController.php
RunCommentsControllerControllercode/app/Http/Controllers/RunCommentsController.php
WellCommentsControllerControllercode/app/Http/Controllers/WellCommentsController.php
NotificationsControllerControllercode/app/Http/Controllers/NotificationsController.php
RunResultExportJobJobcode/app/Jobs/RunResultExportJob.php
RunViewVueviews/run/RunView.vue

8.2 Requirement Traceability

REQ IDDesign SectionCode Location
REQ-RUNRPT-001§3.1 Entities, §5.1 Run StateRun.php, Well.php, RunView.vue
REQ-RUNRPT-003§5.1 Run StateRunAnalyseJob.php
REQ-RUNRPT-006§5.2 Well StateWellsController.php, EditWellWidget.vue
REQ-RUNRPT-007§5.3 Resolution WorkflowWellsController.php, ResolutionCode.php
REQ-RUNRPT-008§4.1 APIs ProvidedRunResultExportJob.php
REQ-RUNRPT-014§1.4 Dependencies (NOTIF)SDS: NOTIF
REQ-RUNRPT-028§6 Error HandlingWell.php (validation)
REQ-COMMENTS-001§5.4 Mention ProcessingCommentsController.php, NotifyMentionedUsers.php
REQ-COMMENTS-005§2.2 Component ResponsibilitiesNotification.php, NotificationsController.php
REQ-COMMENTS-009§4.1 APIs ProvidedUserHasNotified.php (URL generation)
REQ-COMMENTS-010§5.4 Mention ProcessingFrontend role filtering

9. Design Decisions

DecisionRationaleAlternatives Considered
Run status computed on-demandStatus reflects current well states; caching risks stalenessPersisted status column (rejected: sync complexity)
Polymorphic commentsEnables consistent comment handling for runs and wellsSeparate run_comments/well_comments tables (rejected: duplication)
Resolution workflow with approvalManager oversight for critical decisionsAuto-apply all resolutions (rejected: audit risk)
Widget state in user preferencesPer-user customization without affecting othersGlobal widget state (rejected: conflicts)
NOTIF integration for notificationsReuses existing notification infrastructureCustom notification system (rejected: duplication)
Export as background jobLong-running exports don't block UISynchronous export (rejected: timeout risk)

DocumentRelevant Sections
SRS: runfile-report.mdRequirements source
SRS: comments.mdComment/mention requirements
SDS: NOTIF DomainNotification indicators
SDS: ArchitectureSystem context
SDS: Data ArchitectureEntity relationships
Database ReferenceFull schema
Configuration ReferenceClient settings