/******************************************************************************
 *
 * This package includes procedures required by missing bag processing.
 *
 ******************************************************************************/
CREATE OR REPLACE PACKAGE missing_bag AS

/******************************************************************************
 *
 * PROCEDURE insert_rule
 *
 * Description:
 *   Inserts a missing bag rule.
 *
 * In parameters:
 *   p_site_id            - the site at which the rule will apply.
 *   p_timing_group_1     - the first timing location group of the rule.
 *   p_timing_group_2     - the second timing location group of the rule.
 *   p_period             - the period of time a bag must exceed between the
 *                          two points to become missing.
 *
 * Out parameters:
 *   p_out_row_id         - the unique row identifier for the created row.
 *
 * Exceptions:
 *   APPLICATION_ERROR    - 20792 when the two location groups are identical.
 *
 ******************************************************************************/
PROCEDURE insert_rule
(      p_site_id          IN  missing_bag_rule.site_id%TYPE
     , p_timing_group_1   IN  missing_bag_rule.timing_group_1%TYPE
     , p_timing_group_2   IN  missing_bag_rule.timing_group_2%TYPE
     , p_period           IN  missing_bag_rule.time_period%TYPE
     , p_out_row_id       OUT missing_bag_rule.appn_row_id%TYPE
);

/******************************************************************************
 *
 * PROCEDURE edit_rule
 *
 * Description:
 *   Edits a missing bag rule.
 *
 * In parameters:
 *   p_row_id             - the row id of the rule to edit.
 *   p_timing_group_1     - the first timing location group of the rule.
 *   p_timing_group_2     - the second timing location group of the rule.
 *   p_period             - the period of time a bag must exceed between the
 *                          two points to become missing.
 *
 * Exceptions:
 *   APPLICATION_ERROR    - 20792 when the two location groups are identical.
 *
 ******************************************************************************/
PROCEDURE edit_rule
(      p_row_id           IN  missing_bag_rule.appn_row_id%TYPE
     , p_timing_group_1   IN  missing_bag_rule.timing_group_1%TYPE
     , p_timing_group_2   IN  missing_bag_rule.timing_group_2%TYPE
     , p_period           IN  missing_bag_rule.time_period%TYPE
);

/******************************************************************************
 *
 * PROCEDURE delete_rule
 *
 * Description:
 *   Deletes a missing bag rule.
 *
 * In parameters:
 *   p_row_id             - the row id of the rule to edit.
 *
 ******************************************************************************/
PROCEDURE delete_rule
(      p_row_id           IN  missing_bag_rule.appn_row_id%TYPE
);

/******************************************************************************
 *
 * PROCEDURE acknowledge_missing_bag
 *
 * Description:
 *   Acknowledges a missing bag.
 *
 * In parameters:
 *   p_row_id             - the row id of the rule to edit.
 *   p_user_id            - the ID of the user who has acknowledged the missing
 *                          bag.
 *   p_location           - the location of the user who has acknowledged the
 *
 ******************************************************************************/
PROCEDURE acknowledge_missing_bag
(      p_row_id           IN  missing_bag_alert.appn_row_id%TYPE
      ,p_user_id          IN  missing_bag_alert.acknowledged_by%TYPE
      ,p_location         IN  missing_bag_alert.acknowledged_where%TYPE
);

/******************************************************************************
 *
 * PROCEDURE process_missing_bags
 *
 * Description:
 *   Processes missing bags.
 *
 *
 ******************************************************************************/
PROCEDURE process_missing_bags;


END missing_bag;
/
