/*
 * Control values for recording processing states in the ebms_article_state
 * table.
 *
 *  state_id            Unique ID of the state value.
 *  state_name          Human readable name.
 *  description         Longer, descriptive help text.
 *  completed           'Y' = article in this state requires no further
 *                        processing.
 *  board_required      'Y' = rows with this state must have a non-NULL
 *                        board_id
 *  topic_required      'Y' = rows with this state must have a non-NULL
 *                        topic_id
 *  active_status       'A'ctive or 'I'nactive.
 *  sequence            The sequence order of states in workflows.
 */
CREATE TABLE ebms_article_state_type (
    state_id            INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
    state_name          VARCHAR(32) NOT NULL UNIQUE,
    description         VARCHAR(2048) NOT NULL,
    completed           ENUM('Y', 'N') NOT NULL DEFAULT 'N',
    board_required      ENUM('Y', 'N') NOT NULL DEFAULT 'Y',
    topic_required      ENUM('Y', 'N') NOT NULL DEFAULT 'Y',
    active_status       ENUM('A','I') NOT NULL DEFAULT 'A',
    sequence            INTEGER NULL
)
    ENGINE=InnoDB;

    -- States that an article can be in in the review process
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Imported', 'Imported into the database', 1, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Ready for initial review', 
        'Article is associated with a summary topic, '
        'typically by a new import or an attempted import of a duplicate.  '
        'It is now ready for initial review', 2, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Rejected by NOT list', 
        'Article appeared in a "NOT listed" journal, rejected without review',
        3, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Rejected in initial review', 
        'Rejected in initial review, before publication to board managers,', 
        5, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Passed initial review', 
        'Article "published" for board manager review,', 5, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Rejected by Board Manager', 
        'Board manager rejected article', 6, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Passed Board Manager', 
        'Board manager accepted article for further review', 6, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Requested full text', 
        'Board manager has requested retrieval of full text', 7, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Full text retrieval failed', 
        'Staff were unable to obtain a copy of the article', 8, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Full text retrieved', 
        'Full text is available, awaiting further review by Board manager', 
        9, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Rejected after full text review',
        'Full text examined at OCE, article rejected', 10, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Passed full text review',
        'Full text examined at OCE, article approved for board member review', 
        10, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Flagged as FYI',
        'Article is being sent out without being linked to a specific topic',
        11, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Rejected for agenda',
        'Decision after board member review is do not discuss',
        12, 'Y');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Queued for later assignment to agenda',
        'Board will take this up at some future meeting',
        13, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Approved for agenda',
        'Show this on the picklist of articles that can be added to agenda',
        14, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('On agenda',
        'Article is on the agenda for an upcoming meeting',
        15, 'N');
    INSERT ebms_article_state_type 
        (state_name, description, sequence, completed)
        VALUES ('Final board decision',
        'Article was discussed at a board meeting and a decision was reached',
        16, 'Y');
