(tutorials:reporter-sample-lifecycle)=
# Reporter sample lifecycle

A Reporter sample moves through a sequence of states that mirror a clinical workflow. Each state has a clear purpose, expected handoff artifacts, and role ownership.

## State diagram

```text
PENDING → ANALYSIS → REVIEW → REPORT → CLOSED
  ↓          ↓          ↓        ↓
  └──────────└─REJECTED─└────────┘
```

## States and responsibilities

| State | Purpose | Typical owner                         | Handoff artifact |
| --- | --- |---------------------------------------| --- |
| **PENDING** | The sample is registered but analysis has not started. | ReporterDataEntryOperator             | Patient/order record, biosample metadata, phenotype information. |
| **ANALYSIS** | Sequencing data is uploaded and the pipeline is running. | BioinformaticsScientist               | Input datasets, running or completed workflow run. |
| **REVIEW** | Results are available and ready for interpretation and curation. | MedicalTechnologist, MedicalDirector  | Curated variants, interpretations, comments. |
| **REPORT** | The report has been generated and is awaiting final sign-off. | LaboratorySupervisor, MedicalDirector | Draft PhenopacketReport. |
| **CLOSED** | The report is signed out and the case is complete. | MedicalDirector                       | Signed PhenopacketReport. |
| **REJECTED** | The sample or report is rejected and sent back for rework. | MedicalDirector, LaboratorySupervisor | Rejection reason and instructions for the receiving stage. |

## Transitions

| From | To | Typical action | Who can trigger                                                      |
| --- | --- | --- |----------------------------------------------------------------------|
| PENDING | ANALYSIS | Upload data and launch the analysis pipeline. | MedicalTechnologist, BioinformaticsScientist.                        |
| ANALYSIS | REVIEW | Pipeline completes successfully. | BioinformaticsScientist. |
| REVIEW | REPORT | Curation is complete and the report is drafted. | LaboratorySupervisor.                                                |
| REVIEW | ANALYSIS | Results are insufficient or the pipeline must be rerun. | MedicalTechnologist with a rework reason.                            |
| REPORT | CLOSED | Final sign-off by the MedicalDirector. | MedicalDirector.                                                     |
| REPORT | REJECTED | Report is rejected and returned to REVIEW or ANALYSIS. | MedicalDirector or LaboratorySupervisor.                             |
| REJECTED | ANALYSIS / REVIEW / REPORT | Corrective action is completed and the case is resubmitted. | Owner of the receiving stage.                                        |

## Rollback rules

- Rollback should always be accompanied by a reason and an audit trail.
- Moving backward to ANALYSIS typically requires new or corrected data, a pipeline rerun, or a failed-quality review.
- Moving backward from REPORT to REVIEW is usually for report corrections before sign-off.
- A CLOSED report should generally not be edited; amendments should create a new report version or re-open through a controlled amendment process.

## Audit expectations

Every state change is expected to be recorded with:

- The timestamp.
- The user who performed the action.
- The reason or comment, when required.
- The resulting state and any associated report version.

Consult your organization's standard operating procedures for exact audit and compliance requirements.

## Related material

- {ref}`tutorials:reporter-register-sample` for entering a new case.
- {ref}`tutorials:reporter-upload-and-analysis` for starting the analysis.
- {ref}`tutorials:reporter-review-and-curation` for interpreting results.
- {ref}`tutorials:reporter-reporting` for final sign-off.
- {ref}`security:healthcare-rbac` for the authoritative permission matrix.
