using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; [ApiController] [Route("fhir/Encounter")] [Produces("application/fhir+json")] [Authorize] public class FhirEncounterController : ControllerBase { private readonly IFhirService _fhir; public FhirEncounterController(IFhirService fhir) => _fhir = fhir; /// /// FHIR read: GET /fhir/Encounter/{id} /// [HttpGet("{id}")] public async Task Read(string id) { var encounter = await _fhir.GetEncounterAsync(Guid.Parse(id)); if (encounter is null) return NotFound(FhirErrorHelper.NotFound("Encounter", id)); return Ok(encounter); } /// /// FHIR search: GET /fhir/Encounter?patient=X&status=Y&date=Z /// Supports search by patient reference, status, and date range. /// [HttpGet] public async Task Search( [FromQuery] string? patient, [FromQuery] string? status, [FromQuery] string? date, [FromQuery(Name = "_count")] int count = 20, [FromQuery(Name = "_offset")] int offset = 0) { var bundle = await _fhir.SearchEncountersAsync(patient, status, date, count, offset); return Ok(bundle); } }