feature: FHIR R4 Inbound Facade

This commit is contained in:
voltsrage
2026-06-21 13:53:38 +08:00
parent 9f96f54007
commit a43db52813
42 changed files with 2873 additions and 3 deletions
@@ -0,0 +1,32 @@
using Hl7.Fhir.Serialization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
public class FhirExceptionFilter : IExceptionFilter
{
private static readonly FhirJsonSerializer Serializer = new();
public void OnException(ExceptionContext context)
{
if (!context.HttpContext.Request.Path.StartsWithSegments("/fhir"))
return;
var outcome = FhirOperationOutcomeBuilder.FromException(context.Exception);
var status = context.Exception switch
{
FhirMappingException fme => fme.HttpStatus,
NotFoundException => 404,
ValidationException => 422,
ConflictException => 409,
_ => 500
};
context.Result = new ContentResult
{
StatusCode = status,
ContentType = "application/fhir+json",
Content = Serializer.SerializeToString(outcome)
};
context.ExceptionHandled = true;
}
}