using Hl7.Fhir.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("fhir")]
[Produces("application/fhir+json")]
public class FhirMetadataController : ControllerBase
{
    private readonly IFhirService _fhir;

    public FhirMetadataController(IFhirService fhir) => _fhir = fhir;

    /// <summary>
    /// FHIR metadata: GET /fhir/metadata
    /// Returns the server's CapabilityStatement describing supported
    /// resources, interactions, and search parameters.
    /// No authentication required (FHIR spec requirement).
    /// </summary>
    [HttpGet("metadata")]
    [AllowAnonymous]
    [ProducesResponseType(typeof(CapabilityStatement), StatusCodes.Status200OK)]
    public IActionResult GetMetadata()
    {
        return Ok(_fhir.GetCapabilityStatement());
    }
}