fix: Missing input validators + No patient update endpoint + Pagination inconsistencies + Missing list/get endpoints
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using FluentValidation;
|
||||
|
||||
public class FhirPatientUpsertRequestValidator : AbstractValidator<FhirPatientUpsertRequest>
|
||||
{
|
||||
private static readonly HashSet<string> ValidGenders = new(StringComparer.OrdinalIgnoreCase)
|
||||
{ "male", "female", "other", "unknown" };
|
||||
|
||||
public FhirPatientUpsertRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.IdentifierSystem).NotEmpty().MaximumLength(500);
|
||||
RuleFor(x => x.IdentifierValue).NotEmpty().MaximumLength(200);
|
||||
RuleFor(x => x.FirstName).NotEmpty().MaximumLength(100);
|
||||
RuleFor(x => x.LastName).NotEmpty().MaximumLength(100);
|
||||
RuleFor(x => x.DateOfBirth).NotEmpty()
|
||||
.LessThanOrEqualTo(DateOnly.FromDateTime(DateTime.UtcNow))
|
||||
.WithMessage("Date of birth cannot be in the future.");
|
||||
RuleFor(x => x.Gender).NotEmpty()
|
||||
.Must(g => ValidGenders.Contains(g))
|
||||
.WithMessage("Gender must be one of: male, female, other, unknown.");
|
||||
RuleFor(x => x.BloodType).IsInEnum()
|
||||
.When(x => x.BloodType is not null);
|
||||
RuleFor(x => x.EmergencyContactName).MaximumLength(200)
|
||||
.When(x => x.EmergencyContactName is not null);
|
||||
RuleFor(x => x.EmergencyContactPhone).MaximumLength(20)
|
||||
.When(x => x.EmergencyContactPhone is not null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user