Files
vigilcare-records/VigilCareRecordsAPI/Controllers/WorkQueueController.cs
T

71 lines
2.8 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
/// <summary>
/// Work queue endpoints for each workflow stage.
/// Each queue returns batches filtered by status and sorted by submission time ASC
/// so the oldest pending item is always at the top.
/// </summary>
[ApiController]
[Route("api/v1/work-queue")]
[Produces("application/json")]
[Authorize]
public class WorkQueueController : ControllerBase
{
private readonly IWorkQueueService _workQueue;
public WorkQueueController(IWorkQueueService workQueue)
{
_workQueue = workQueue;
}
/// <summary>
/// Returns batches in PendingVerification status, sorted by submittedAt ASC.
/// Verifiers use this queue to pick the next batch to verify.
/// </summary>
[HttpGet("verification")]
[Authorize(Roles = "VERIFIER,CLINICAL_APPROVER,ADMINISTRATOR")]
[ProducesResponseType(typeof(ApiResponse<WorkQueueResponse>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetVerificationQueue(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 20)
{
var result = await _workQueue.GetVerificationQueueAsync(page, pageSize);
return Ok(ApiResponse<WorkQueueResponse>.Ok(result));
}
/// <summary>
/// Returns batches awaiting or currently in data entry.
/// Includes batches in Uploaded (awaiting assignment), InEntry (being entered),
/// and Rejected (returned for re-entry) statuses.
/// Data entry clerks use this queue to find their next assignment.
/// </summary>
[HttpGet("entry")]
[Authorize(Roles = "DATA_ENTRY_CLERK,ADMINISTRATOR")]
[ProducesResponseType(typeof(ApiResponse<WorkQueueResponse>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetEntryQueue(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 20)
{
var result = await _workQueue.GetEntryQueueAsync(page, pageSize);
return Ok(ApiResponse<WorkQueueResponse>.Ok(result));
}
/// <summary>
/// Returns batches in AwaitingClinicalApproval status, sorted by submittedAt ASC.
/// Clinical approvers use this queue to find batches that need clinical sign-off
/// after verification. Only batch types configured to require clinical approval
/// in site config will appear here.
/// </summary>
[HttpGet("clinical-approval")]
[Authorize(Roles = "CLINICAL_APPROVER,ADMINISTRATOR")]
[ProducesResponseType(typeof(ApiResponse<WorkQueueResponse>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetClinicalApprovalQueue(
[FromQuery] int page = 1,
[FromQuery] int pageSize = 20)
{
var result = await _workQueue.GetClinicalApprovalQueueAsync(page, pageSize);
return Ok(ApiResponse<WorkQueueResponse>.Ok(result));
}
}