package RequestStatus; use Moose; with 'Role::RebuildTables'; use namespace::clean -except => 'meta'; use Data::Dumper; has $_ => (is => 'ro', isa => 'HashRef', required => 1) foreach qw( db sql ); has log_file => ( is => 'ro', required => 1 ); __PACKAGE__->meta->make_immutable; $|++; # revert request status from 'complete' to 'authorised' if any outstanding lab tests: sub convert { # moved to History: my $self = shift; my $dbh = $self->db->{dbh4}; my $sql = q! update requests r set r.status_option_id = 4 where r.id in ( select s.request_id from request_lab_test_status s where s.status_option_id <> 2 ) and r.status_option_id = 5!; $dbh->do($sql); }