using Microsoft.AspNetCore.Mvc;
///
/// Patient registration, search, and encounter opening.
///
[ApiController]
[Route("api/v1/patients")]
[Produces("application/json")]
public class PatientsController : ControllerBase
{
private readonly IPatientService _patients;
public PatientsController(IPatientService patients) => _patients = patients;
///
/// Registers a new patient and assigns a system-generated MRN.
///
/// Patient demographics.
/// The created patient record.
[HttpPost]
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status201Created)]
public async Task Register([FromBody] RegisterPatientRequest req)
{
var patient = await _patients.RegisterAsync(req);
return StatusCode(201, ApiResponse.Created(patient));
}
///
/// Lists patients with optional MRN or name search and pagination.
///
/// MRN (exact) or name substring (ILIKE).
/// Page number (1-based).
/// Results per page.
/// A paginated list of patients.
[HttpGet]
[ProducesResponseType(typeof(ApiResponse