# Scheduled Signal Calculations & Alerts

The signal detection process involves <a href="/en/gr/935433/">running _Signal Calculations_</a> on Safety pharmacovigilance (PV) data, <a href="/en/gr/935435/">creating relevant records</a>, and running the <a href="/en/gr/808066/">Signal Alert Rule Engine</a> to flag _Product-Event Combinations_ (PECs) as potential signals. Vault can automate these processes by scheduling signal detection based on your Admin's configuration.

## Prerequisites
Consider the following prerequisites:
* To automate the signal detection process of running calculations and the signal alert rule engine, your Admin must <a href="/en/gr/826977/">enable</a> and <a href="/en/gr/826976/">configure</a> scheduled _Signal Calculations_ and alerts.
* To store _Signal Calculations_ of different data sources in a single _Statistical Data_ record, your Admin must <a href="/en/gr/1005912/">enable multi-source signal data consolidation</a>. 

## How Vault Runs Scheduled Signal Detection

Your Admin sets the frequency and day on which automated signal detection runs. The following process outlines how Vault runs scheduled signal detection:
1. [Vault runs _Signal Calculations_][1] on PV data and creates _Statistical Data_ and CSV attachments to store the results, depending on the _Output Type_ on the calculations.
2. [Vault runs the Signal Alert Rule Engine][2] to flag _Statistical Data_ records as potential signals.

### Scheduled Signal Calculations

Vault runs _Signal Calculations_ as follows:
1. Vault looks for every _Signal Reporting Period_ that meets the following criteria:
    * Is associated with a _Signal Product Profile_
    * Is associated with a _Product Family_ or _Aggregate Reporting Group_
    * Is in the _Queued_ state type 
2. If the associated _Signal Product Profile_ includes _Signal Calculations_:
    1. Vault sets the _Signal Reporting Period_ record to the _System Processing_ state type.
    2. Vault runs each calculation in the _Signal Calculation_ record.
    3. {: #create-update-records} For each _Product_ and event combination, Vault creates (if none exists) or updates records in the following order:
        * The <a href="/en/gr/896824/#create-pec">_Product-Event Combination_ (PEC)</a> for the _Product Family_ or _Aggregate Reporting Group_ and primary _MedDRA Term_ combination.
        * The <a href="/en/gr/896824/#create-pec-periods">_PEC Period_</a> for the _Product Family_ or _Aggregate Reporting Group_ and primary _MedDRA Term_ combination.
        * To store the _Signal Calculation_ results: 
            * For all calculations with an _Output Type_ of _Statistical Data Record_ or blank, Vault creates a <a href="/en/gr/935435/">_Statistical Data_</a> record if none exists for the _PEC Period_, detection date, _Source_, _Signal Source Data_, and, when configured, _Subgroup_ and _Subgroup_ value combination. Otherwise, Vault updates the existing record. Vault sets the _Statistical Data_ record to the _System Processing_ state type and the <a href="/en/gr/935435/#detection-type">_Detection Type_</a> field to _Routine_.
            * For each calculation with an _Output Type_ of _CSV Attachment_, Vault creates a CSV file and attaches it to the _Attachments_ section of the first _Statistical Data_ record matching on: 
                * MedDRA query
                * Reporting period 
                * _Source_ 
                * _Product Family_ or _Aggregate Reporting Group_ \
            Vault replaces this attachment when the calculation is re-run and there are CSV updates.
        * The <a href="/en/gr/935435/#signal-case-series">_Signal Case Series_</a>, if the _Signal Calculation_ being run is <a href="/en/gr/753144/#case-series-view">associated with a _Case_ series view</a>. Vault does not support _Signal Case Series_ for _Signal Calculations_ associated with a <a href="/en/gr/753144/#signal-view-field">safety view at the MedDRA query level</a>.

If your Admin did not configure _Signal Calculations_ for the _Signal Product Profile_, Vault sets the _Signal Reporting Period_ to the _Ready_ state type. For this _Signal Reporting Period_, Vault stops the scheduled job.

In the scenario where you update a _Signal Reporting Period_ while Vault is running the scheduled job, Vault considers the start and end dates before the update. When filtering on datasheets and events on datasheets, Vault determines the datasheet and event are active if they meet the following criteria:
* The active start date is before the _Reporting Period_ end date.
* The active end date is after the _Reporting Period_ end date.

### Scheduled Signal Alert Rule Engine

After running _Signal Calculations_ and creating the relevant records, Vault runs the Signal Alert Rule Engine as follows:

1. If the associated _Signal Product Profile_ includes _Signal Alert Rule Sets_, Vault <a href="/en/gr/808066/#how-the-signal-alert-rule-engine-runs">runs the Signal Alert Rule Engine</a> to evaluate each _Signal Alert Rule_ in the set on every _Statistical Data_ record in the _System Processing_ or _Initial_ state type, associated with the evaluated _Signal Reporting Period_.
2. Once the rules are evaluated on the applicable _Statistical Data_ records, Vault sets the _Statistical Data_ records to either the <a href="/en/gr/808066/#a-statistical-data-record-meets-the-criteria-for-a-signal-alert-rule">_Ready_</a> or <a href="/en/gr/808066/#a-statistical-data-record-does-not-meet-any-signal-alert-rule-criteria">_Complete_</a> state type, depending on if the record meets _Signal Alert Rule_ criteria.
3. Once all applicable _Statistical Data_ records have been evaluated, Vault sets the _Reporting Period_ state type to _Ready_.

If your Admin did not configure _Alert Rule Sets_ for the _Signal Product Profile_:
* Vault sets the _Signal Reporting Period_ associated with the _Signal Product Profile_ to the _Ready_ state type.
* Vault sets the _Statistical Data_ record to the _Ready_ state type.

In the scenario where your Admin updates _Signal Alert Rule Sets_ and _Signal Alert Rules_ while Vault is running the scheduled job, the Signal Alert Rule Engine considers the rule sets and rules before the update.

## Scheduled Signal Detection Errors {#scheduled-signal-detection-errors}

Vault sends a notification to the job owner (by default, this is the System Admin) for each _Signal Reporting Period_ that resulted in an error during the scheduled run and sets the relevant _Signal Reporting Periods_ to the _Error_ state. The notification includes a CSV file with error details such as the _Signal Calculation_, _Statistical Data_ record creation, _Signal Case Series_ creation, or _Signal Alert Rules_ that failed.

If an error occurs during part of a _Signal Calculation_ run, records that were successfully [created or updated][3] by Vault before the point of failure will still be accessible. Before running the calculation again, your Admin should delete these records.

[1]: #scheduled-signal-calculations
[2]: #scheduled-signal-alert-rule-engine
[3]: #create-update-records