fix: Missing input validators + No patient update endpoint + Pagination inconsistencies + Missing list/get endpoints
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
|
||||
public class FhirEncounterUpsertRequestValidator : AbstractValidator<FhirEncounterUpsertRequest>
|
||||
{
|
||||
public FhirEncounterUpsertRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.IdentifierSystem).NotEmpty().MaximumLength(500);
|
||||
RuleFor(x => x.IdentifierValue).NotEmpty().MaximumLength(200);
|
||||
RuleFor(x => x.PatientId).NotEmpty();
|
||||
RuleFor(x => x.EncounterType).IsInEnum();
|
||||
RuleFor(x => x.Department).IsInEnum();
|
||||
RuleFor(x => x.AttendingPhysician).NotEmpty().MaximumLength(200);
|
||||
RuleFor(x => x.TargetStatus).IsInEnum();
|
||||
RuleFor(x => x.RoomBed).MaximumLength(20)
|
||||
.When(x => x.RoomBed is not null);
|
||||
RuleFor(x => x.AdmissionReason).MaximumLength(500)
|
||||
.When(x => x.AdmissionReason is not null);
|
||||
RuleFor(x => x.DischargeDiagnosis).MaximumLength(500)
|
||||
.When(x => x.DischargeDiagnosis is not null);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using FluentValidation;
|
||||
|
||||
public class RecordOrderResultRequestValidator : AbstractValidator<RecordOrderResultRequest>
|
||||
{
|
||||
public RecordOrderResultRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.ResultSummary).MaximumLength(2000)
|
||||
.When(x => x.ResultSummary is not null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using FluentValidation;
|
||||
|
||||
public class TransitionStatusRequestValidator : AbstractValidator<TransitionStatusRequest>
|
||||
{
|
||||
public TransitionStatusRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.Status).IsInEnum();
|
||||
RuleFor(x => x.DischargeDiagnosis).MaximumLength(500)
|
||||
.When(x => x.DischargeDiagnosis is not null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using FluentValidation;
|
||||
|
||||
public class UpdatePatientRequestValidator : AbstractValidator<UpdatePatientRequest>
|
||||
{
|
||||
public UpdatePatientRequestValidator()
|
||||
{
|
||||
RuleFor(x => x.FirstName).MaximumLength(100)
|
||||
.When(x => x.FirstName is not null);
|
||||
RuleFor(x => x.LastName).MaximumLength(100)
|
||||
.When(x => x.LastName is not null);
|
||||
RuleFor(x => x.DateOfBirth)
|
||||
.LessThanOrEqualTo(DateOnly.FromDateTime(DateTime.UtcNow))
|
||||
.WithMessage("Date of birth cannot be in the future.")
|
||||
.When(x => x.DateOfBirth is not null);
|
||||
RuleFor(x => x.Gender).MaximumLength(10)
|
||||
.When(x => x.Gender is not null);
|
||||
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