gaepdit / complaint-tracking

Complaint Tracking System
The Unlicense
1 stars 3 forks source link

Administratively close complaints by request #496

Closed dougwaldron closed 2 years ago

dougwaldron commented 3 years ago

Requested by Jim C. Multiple lists are expected.

dougwaldron commented 3 years ago
Script for administratively closing complaints ```sql begin declare @adminId uniqueidentifier, @comment nvarchar(4000); declare @complaintsToClose table ( id int ); -- Update comment here. select @comment = 'This complaint is being administratively closed. ' + 'If EPD recieves another compaint regarding this ' + 'issue, we will treat it as a new complaint.'; -- List all complaint IDs here. insert into @complaintsToClose values (999998), (999999); select @adminId = Id from AspNetUsers where Email = 'epd_it@dnr.ga.gov'; -- insert into ComplaintTransitions (Id, Comment, ComplaintId, CreatedById, CreatedDate, DateTransferred, TransferredByUserId, TransitionType) select newid(), @comment, Id, @adminId, sysdatetime(), sysdatetime(), @adminId, 4 -- Closed from Complaints where ComplaintClosed = 0 and Deleted = 0 and Id in (select id from @complaintsToClose); update c set ReviewById = @adminId, ReviewComments = @comment, ComplaintClosed = 1, DateComplaintClosed = sysdatetime(), Status = 4 -- AdministrativelyClosed from Complaints c where ComplaintClosed = 0 and Deleted = 0 and Id in (select id from @complaintsToClose); select Id, ComplaintClosed, CreatedDate, DateComplaintClosed, ReviewById, ReviewComments, Status, UpdatedById, UpdatedDate from Complaints where Id in (select id from @complaintsToClose); select ComplaintId, Comment, CreatedById, CreatedDate, DateTransferred, TransferredByUserId, TransitionType from ComplaintTransitions where ComplaintId in (select id from @complaintsToClose) and TransitionType = 4; end; ```
dougwaldron commented 2 years ago

Received spreadsheet for WPB complaint IDs to close

dougwaldron commented 2 years ago

Added stored procedure admin.CloseComplaintsTableType to administratively close complaints. How to use the SP:

begin
    declare @ComplaintsTVP as admin.CloseComplaintsTableType;

    insert into @ComplaintsTVP
        (Id, ReviewComment)
    values
        (999998, 'Administratively closed with this review comment.'),
        (999999, 'Administratively closed with another review comment.');

    select c.Id,
           c.ComplaintClosed,
           c.Deleted,
           c.CreatedDate,
           c.DateComplaintClosed,
           c.ReviewById,
           c.ReviewComments,
           c.Status,
           c.UpdatedById,
           c.UpdatedDate
    from Complaints c
        inner join @ComplaintsTVP t
        on c.Id = t.Id;

--    exec admin.CloseComplaints @ComplaintsTVP;

end;
dougwaldron commented 2 years ago

Final set of complaints submitted and processed.