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,31 @@
using Hl7.Fhir.Model;
public static class FhirOperationOutcomeBuilder
{
public static OperationOutcome FromException(Exception ex) => ex switch
{
FhirMappingException fme => Create(fme.HttpStatus, fme.FhirIssueCode, fme.Message),
NotFoundException nfe => Create(404, "not-found", nfe.Message),
ValidationException ve => Create(422, "invalid", ve.Message),
ConflictException ce => Create(409, "conflict", ce.Message),
_ => Create(500, "exception", "An unexpected error occurred.")
};
public static OperationOutcome Create(int status, string code, string diagnostics) =>
new()
{
Issue = new List<OperationOutcome.IssueComponent>
{
new()
{
Severity = status >= 500
? OperationOutcome.IssueSeverity.Error
: OperationOutcome.IssueSeverity.Warning,
Code = Enum.TryParse<OperationOutcome.IssueType>(code, true, out var c)
? c
: OperationOutcome.IssueType.Processing,
Diagnostics = diagnostics
}
}
};
}