From 97330ac437ce0b4bb68e8a26a4796f7201371eb1 Mon Sep 17 00:00:00 2001 From: VS Date: Tue, 16 Jul 2024 13:03:02 +0100 Subject: [PATCH 1/8] incomplete Bio functionality --- src/Application/Application.csproj | 39 ++++++---- .../Features/Bio/Caching/BioCacheKey.cs | 30 +++++++ .../Features/Bio/Commands/BeginBio.cs | 74 ++++++++++++++++++ .../Features/Bio/Commands/SaveAssessment.cs | 78 +++++++++++++++++++ src/Application/Features/Bio/DTOs/BioDto.cs | 19 +++++ .../Features/Bio/DTOs/BioPathwayValidator.cs | 12 +++ .../Features/Bio/DTOs/BioSurvey.cs | 8 ++ .../Features/Bio/DTOs/BioValidator.cs | 9 +++ .../Features/Bio/DTOs/PathwayBase.cs | 18 +++++ .../Features/Bio/DTOs/QuestionBase.cs | 53 +++++++++++++ .../Features/Bio/DTOs/SingleChoiceQuestion.cs | 46 +++++++++++ .../V1/Pathways/ChildhoodExperiences/B1.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B10.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B11.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B12.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B13.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B14.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B15.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B2.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B3.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B4.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B5.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B6.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B7.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B8.cs | 12 +++ .../V1/Pathways/ChildhoodExperiences/B9.cs | 12 +++ .../Bio/DTOs/V1/Pathways/Diversity/A1.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A10.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A11.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A12.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A13.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A14.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A15.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A16.cs | 12 +++ .../Bio/DTOs/V1/Pathways/Diversity/A17.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A18.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A19.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A2.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A20.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A3.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A4.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A5.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A6.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A7.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A8.cs | 13 ++++ .../Bio/DTOs/V1/Pathways/Diversity/A9.cs | 13 ++++ .../V1/Pathways/Diversity/DiversityPathway.cs | 62 +++++++++++++++ .../Bio/DTOs/V1/Pathways/Exemption/D1.cs | 10 +++ .../DTOs/V1/Pathways/RecentExperiences/C1.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C10.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C2.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C3.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C4.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C5.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C6.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C7.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C8.cs | 12 +++ .../DTOs/V1/Pathways/RecentExperiences/C9.cs | 12 +++ src/Domain/Common/Enums/Pathway.cs | 6 ++ src/Domain/Domain.csproj | 8 +- src/Domain/Entities/Bios/Bio.cs | 54 +++++++++++++ src/Domain/Events/BioEvents.cs | 8 ++ .../Pages/Bio/BioComponents/BioCheckbox.razor | 21 +++++ .../Pages/Bio/BioComponents/BioQuestion.razor | 21 +++++ 64 files changed, 1116 insertions(+), 19 deletions(-) create mode 100644 src/Application/Features/Bio/Caching/BioCacheKey.cs create mode 100644 src/Application/Features/Bio/Commands/BeginBio.cs create mode 100644 src/Application/Features/Bio/Commands/SaveAssessment.cs create mode 100644 src/Application/Features/Bio/DTOs/BioDto.cs create mode 100644 src/Application/Features/Bio/DTOs/BioPathwayValidator.cs create mode 100644 src/Application/Features/Bio/DTOs/BioSurvey.cs create mode 100644 src/Application/Features/Bio/DTOs/BioValidator.cs create mode 100644 src/Application/Features/Bio/DTOs/PathwayBase.cs create mode 100644 src/Application/Features/Bio/DTOs/QuestionBase.cs create mode 100644 src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs create mode 100644 src/Domain/Entities/Bios/Bio.cs create mode 100644 src/Domain/Events/BioEvents.cs create mode 100644 src/Server.UI/Pages/Bio/BioComponents/BioCheckbox.razor create mode 100644 src/Server.UI/Pages/Bio/BioComponents/BioQuestion.razor diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj index 7c2c1356..59debf34 100644 --- a/src/Application/Application.csproj +++ b/src/Application/Application.csproj @@ -8,27 +8,36 @@ default true + + + + - - - - - - - - - - - + + + + + + + + + + + - + + + + - + + - - + + + \ No newline at end of file diff --git a/src/Application/Features/Bio/Caching/BioCacheKey.cs b/src/Application/Features/Bio/Caching/BioCacheKey.cs new file mode 100644 index 00000000..6a372d72 --- /dev/null +++ b/src/Application/Features/Bio/Caching/BioCacheKey.cs @@ -0,0 +1,30 @@ +namespace Cfo.Cats.Application.Features.Assessments.Caching; + +public class BioCacheKey +{ + //note: we currently only have one but may need more in the future + public const string GetAllCacheKey = "all-bios"; + private static readonly TimeSpan RefreshInterval = TimeSpan.FromMinutes(60); + private static CancellationTokenSource tokenSource; + + static BioCacheKey() + { + tokenSource = new CancellationTokenSource(RefreshInterval); + } + + public static MemoryCacheEntryOptions MemoryCacheEntryOptions => + new MemoryCacheEntryOptions() + .AddExpirationToken(new CancellationChangeToken(SharedExpiryTokenSource().Token)); + + public static CancellationTokenSource SharedExpiryTokenSource() + { + if (tokenSource.IsCancellationRequested) tokenSource = new CancellationTokenSource(RefreshInterval); + + return tokenSource; + } + + public static void Refresh() + { + SharedExpiryTokenSource().Cancel(); + } +} \ No newline at end of file diff --git a/src/Application/Features/Bio/Commands/BeginBio.cs b/src/Application/Features/Bio/Commands/BeginBio.cs new file mode 100644 index 00000000..0fbad339 --- /dev/null +++ b/src/Application/Features/Bio/Commands/BeginBio.cs @@ -0,0 +1,74 @@ +using System.Text.Json.Serialization; +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Bio.Caching; +using Cfo.Cats.Application.Features.Bio.DTOs; +using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Exemption; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Domain.Entities.Bios; +using Newtonsoft.Json; +using Cfo.Cats.Application.Features.Assessments.Caching; + +namespace Cfo.Cats.Application.Features.Assessments.Commands; + +public static class BeginBio +{ + [RequestAuthorize(Policy = PolicyNames.AllowEnrol)] + public class Command : ICacheInvalidatorRequest> + { + public required string ParticipantId { get; set; } + + //TODO: this could be done at a per participant level + public string[] CacheKeys => [ BioCacheKey.GetAllCacheKey ]; + public CancellationTokenSource? SharedExpiryTokenSource + => BioCacheKey.SharedExpiryTokenSource(); + } + + public class Handler : IRequestHandler> + { + private readonly IUnitOfWork _unitOfWork; + private readonly ICurrentUserService _currentUserService; + public Handler(IUnitOfWork unitOfWork, ICurrentUserService currentUserService) + { + _unitOfWork = unitOfWork; + _currentUserService = currentUserService; + } + + public async Task> Handle(Command request, CancellationToken cancellationToken) + { + BioSurvey bio = new BioSurvey() + { + Id = Guid.NewGuid(), + ParticipantId = request.ParticipantId, + Pathways = + [ + new DiversityPathway(), + ] + }; + + string json = JsonConvert.SerializeObject(bio, new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }); + + BioSurvey bs = bio.Create(bio.Id, request.ParticipantId, bioJson: json, _currentUserService.TenantId!); + + + _unitOfWork.DbContext.bios.Add(bs); + return await Result.SuccessAsync(bio.Id); + } + } + + public class Validator : AbstractValidator + { + public Validator() + { + RuleFor(c => c.ParticipantId) + .MinimumLength(9) + .MaximumLength(9); + } + } + +} diff --git a/src/Application/Features/Bio/Commands/SaveAssessment.cs b/src/Application/Features/Bio/Commands/SaveAssessment.cs new file mode 100644 index 00000000..5526f65a --- /dev/null +++ b/src/Application/Features/Bio/Commands/SaveAssessment.cs @@ -0,0 +1,78 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Assessments.Caching; +using Cfo.Cats.Application.Features.Assessments.DTOs; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Domain.Entities.Assessments; +using Newtonsoft.Json; + +namespace Cfo.Cats.Application.Features.Assessments.Commands; + +public static class SaveAssessment +{ + [RequestAuthorize(Policy = PolicyNames.AllowEnrol)] + public class Command : ICacheInvalidatorRequest + { + //TODO: cache individually + public string[] CacheKeys => [ AssessmentsCacheKey.GetAllCacheKey ]; + public CancellationTokenSource? SharedExpiryTokenSource => AssessmentsCacheKey.SharedExpiryTokenSource(); + + public bool Submit { get; set; } = false; + + public required Assessment Assessment { get; set; } + + } + + public class Handler : IRequestHandler + { + private readonly IUnitOfWork _unitOfWork; + + public Handler(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + } + + public async Task Handle(Command request, CancellationToken cancellationToken) + { + ParticipantAssessment pa = _unitOfWork.DbContext.ParticipantAssessments.FirstOrDefault(r => r.Id == request.Assessment.Id && r.ParticipantId == request.Assessment.ParticipantId) + ?? throw new NotFoundException(nameof(Assessment), new + { + request.Assessment.Id, + request.Assessment.ParticipantId + }); + + + pa.UpdateJson(JsonConvert.SerializeObject(request.Assessment, new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + })); + + if (request.Submit) + { + var details = await _unitOfWork.DbContext.Participants + .Where(p => p.Id == request.Assessment.ParticipantId) + .Select(p => + new + { + p.DateOfBirth, + LotNumber = p.EnrolmentLocation!.Contract!.LotNumber, + Gender = "Male" + } + ).FirstAsync(cancellationToken); + + Sex sex = Sex.FromName(details.Gender); + AssessmentLocation location = AssessmentLocation.FromValue(details.LotNumber); + var age = details.DateOfBirth!.Value.CalculateAge(); + + foreach(var pathway in request.Assessment.Pathways) + { + pa.SetPathwayScore(pathway.Title, pathway.GetRagScore(age, location, sex)); + } + pa.Submit(); + } + + return await Result.SuccessAsync(); + } + } + +} diff --git a/src/Application/Features/Bio/DTOs/BioDto.cs b/src/Application/Features/Bio/DTOs/BioDto.cs new file mode 100644 index 00000000..c880c7ec --- /dev/null +++ b/src/Application/Features/Bio/DTOs/BioDto.cs @@ -0,0 +1,19 @@ +using Cfo.Cats.Domain.Entities.Bios; + +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +public class BioDto +{ + public required string ParticipantId { get; set; } + public required DateTime CreatedDate { get; set; } + + private class Mapping : Profile + { + public Mapping() + { + CreateMap() + .ForMember(p => p.CreatedDate, options => options.MapFrom(source => source.Created)); + } + } +} + diff --git a/src/Application/Features/Bio/DTOs/BioPathwayValidator.cs b/src/Application/Features/Bio/DTOs/BioPathwayValidator.cs new file mode 100644 index 00000000..24781b77 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/BioPathwayValidator.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +public class BioPathwayValidator : AbstractValidator +{ + public BioPathwayValidator() + { + RuleForEach(model => model.Questions()) + .Must(q => q.IsValid()) + .WithMessage("You must select a valid option!") + .OverridePropertyName("Questions"); + } +} \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/BioSurvey.cs b/src/Application/Features/Bio/DTOs/BioSurvey.cs new file mode 100644 index 00000000..1ef07888 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/BioSurvey.cs @@ -0,0 +1,8 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +public class BioSurvey +{ + public required Guid Id { get; set; } + public required string ParticipantId { get; set; } + public required PathwayBase[] Pathways { get; set; } +} \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/BioValidator.cs b/src/Application/Features/Bio/DTOs/BioValidator.cs new file mode 100644 index 00000000..e9105b82 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/BioValidator.cs @@ -0,0 +1,9 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +public class BioValidator : AbstractValidator +{ + public BioValidator() + { + RuleForEach(model => model.Pathways).SetValidator(new BioPathwayValidator()); + } +} \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/PathwayBase.cs b/src/Application/Features/Bio/DTOs/PathwayBase.cs new file mode 100644 index 00000000..a1ab431f --- /dev/null +++ b/src/Application/Features/Bio/DTOs/PathwayBase.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; + +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +public abstract class PathwayBase +{ + [JsonIgnore] + public abstract string Title { get; } + + [JsonIgnore] + public abstract double Constant { get; } + + [JsonIgnore] + public abstract string Icon { get; } + + public abstract IEnumerable Questions(); + +} \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/QuestionBase.cs b/src/Application/Features/Bio/DTOs/QuestionBase.cs new file mode 100644 index 00000000..15cd640a --- /dev/null +++ b/src/Application/Features/Bio/DTOs/QuestionBase.cs @@ -0,0 +1,53 @@ +using Newtonsoft.Json; + +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +/// +/// Base class for the all questions +/// +public abstract partial class QuestionBase +{ + +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + protected QuestionBase() + { + } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + + protected QuestionBase(string question, string[] options) + { + this.Question = question; + this.Options = options; + } + + protected QuestionBase(string question, string otherInformation, string[] options) + : this(question, options) + { + this.OtherInformation = otherInformation; + } + + /// + /// The question we are asking + /// + [JsonIgnore] + public string Question { get; } + + /// + /// Any other errata about the question. + /// + [JsonIgnore] + public string? OtherInformation { get; } + + /// + /// A collection of options for the answers + /// + [JsonIgnore] + public string[] Options { get; } + + /// + /// Is the answer valid + /// + /// True if the answer has a valid return value + public abstract bool IsValid(); +} + diff --git a/src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs b/src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs new file mode 100644 index 00000000..939e2123 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs @@ -0,0 +1,46 @@ +using System.Text.Json.Serialization; +using Cfo.Cats.Application.Features.Assessments.DTOs.V1.Pathways.Education; +using Cfo.Cats.Application.Features.Assessments.DTOs.V1.Pathways.HealthAndAdditiction; +using Cfo.Cats.Application.Features.Assessments.DTOs.V1.Pathways.Working; + +namespace Cfo.Cats.Application.Features.Bio.DTOs; + +/// +/// An implementation of QuestionBase that only allows a +/// single answer +/// + +public abstract class SingleChoiceQuestion : QuestionBase +{ + protected SingleChoiceQuestion() + : base() + { + } + + protected SingleChoiceQuestion(string question, string[] options) + : base(question, options) + { + + } + + protected SingleChoiceQuestion(string question, string otherInformation, string[] options) + : base(question, otherInformation, options) + { + } + + + /// + /// The answer the user has provided + /// + public string? Answer { get; set; } + + /// + /// Checks the validity of the answer given. + /// + /// true if the answer has been entered, and is contained in our option list, otherwise false + public override bool IsValid() + { + return string.IsNullOrEmpty(Answer) == false + && Options.Any(a => a == Answer); + } +} \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs new file mode 100644 index 00000000..6df90a9a --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B1() : SingleChoiceQuestion("Spent time in care as a child", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs new file mode 100644 index 00000000..ee25656c --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B10() : SingleChoiceQuestion("Felt safe at home", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs new file mode 100644 index 00000000..152fbe9e --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B11() : SingleChoiceQuestion("Enjoyed going to school", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs new file mode 100644 index 00000000..489829b1 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B12() : SingleChoiceQuestion("Parent or guardian had a drug / alcohol problem", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs new file mode 100644 index 00000000..f2b268ce --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B13() : SingleChoiceQuestion("Parent or guardian was seriously ill / passed away", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs new file mode 100644 index 00000000..b80f7e7b --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B14() : SingleChoiceQuestion("Had a close friend you could confide in", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs new file mode 100644 index 00000000..0d3a5123 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B15() : SingleChoiceQuestion("Had someone you looked up to", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs new file mode 100644 index 00000000..53853773 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B2() : SingleChoiceQuestion("Spent most of childhood in the same family home", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs new file mode 100644 index 00000000..83e0e9dd --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B3() : SingleChoiceQuestion("Suffered abuse or neglect as a child", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs new file mode 100644 index 00000000..15f63095 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B4() : SingleChoiceQuestion("Had a difficult childhood", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs new file mode 100644 index 00000000..674f50d1 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B5() : SingleChoiceQuestion("Both parents/guardians were mostly present", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs new file mode 100644 index 00000000..e0c06b25 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B6() : SingleChoiceQuestion("At least one parent or guardian was mostly in work", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs new file mode 100644 index 00000000..f37de8a5 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B7() : SingleChoiceQuestion("A parent or guardian was in trouble with the police", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs new file mode 100644 index 00000000..0479b8ee --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B8() : SingleChoiceQuestion("A parent or guardian spent time in prison", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs new file mode 100644 index 00000000..35542776 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +public class B9() : SingleChoiceQuestion("Felt loved and cared for at home", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs new file mode 100644 index 00000000..d9ab0f8a --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A1() : SingleChoiceQuestion("Consider yourself a religious person", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs new file mode 100644 index 00000000..4352ed9f --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A10() : SingleChoiceQuestion("Are/have been a member of a gang", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs new file mode 100644 index 00000000..ed87e75c --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A11() : SingleChoiceQuestion("Have carried an illegal weapon at some point in the past", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs new file mode 100644 index 00000000..04f19454 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A12() : SingleChoiceQuestion("Have undertaken prostitution or sex work", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs new file mode 100644 index 00000000..5acff049 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A13() : SingleChoiceQuestion("Feel you are being taken advantage of by others", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs new file mode 100644 index 00000000..ed01b552 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A14() : SingleChoiceQuestion("Feel you are part of a community ", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs new file mode 100644 index 00000000..b110d7fa --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A15() : SingleChoiceQuestion("Feel you have been discriminated against because of who you are", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs new file mode 100644 index 00000000..a90fdb39 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +public class A16() : SingleChoiceQuestion("Feel you generally share the same views of those around you", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs new file mode 100644 index 00000000..445b03d2 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A17() : SingleChoiceQuestion("Feel you are always getting into trouble, since you were a child", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs new file mode 100644 index 00000000..ec19222a --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A18() : SingleChoiceQuestion("Regret the offence(s) you committed", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs new file mode 100644 index 00000000..4acafdc8 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A19() : SingleChoiceQuestion("Feel your current situation is not your fault", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs new file mode 100644 index 00000000..5ce0f61f --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A2() : SingleChoiceQuestion("Practise your faith regularly", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs new file mode 100644 index 00000000..194cd2be --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A20() : SingleChoiceQuestion("Feel you are a better person than you used to be", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs new file mode 100644 index 00000000..2d26a4c9 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A3() : SingleChoiceQuestion("Gay, lesbian, bisexual, or other non-hetero orientation", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs new file mode 100644 index 00000000..ba561519 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A4() : SingleChoiceQuestion("Gender you identify with is different to your registered sex at birth", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs new file mode 100644 index 00000000..e4fcf31c --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A5() : SingleChoiceQuestion("A member of a Gypsy or Irish traveller community", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs new file mode 100644 index 00000000..4ef512d8 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A6() : SingleChoiceQuestion("A member of the Roma community", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs new file mode 100644 index 00000000..51154148 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A7() : SingleChoiceQuestion("Served in the British Armed Forces, inc. Reserves", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs new file mode 100644 index 00000000..5895dd94 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A8() : SingleChoiceQuestion("Undertook an operational tour with the British Armed Forces", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs new file mode 100644 index 00000000..1e55b111 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs @@ -0,0 +1,13 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public class A9() : SingleChoiceQuestion("Have seen combat while a member of the British Armed Forces", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs new file mode 100644 index 00000000..5dffb59f --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs @@ -0,0 +1,62 @@ +using System.Text.Json.Serialization; + +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; + +public sealed partial class DiversityPathway + : PathwayBase +{ + + [JsonIgnore] + public override string Title => "Diversity"; + + + + [JsonIgnore] + public override string Icon => CatsIcons.Diversity; + public override IEnumerable Questions() + { + yield return A1; + yield return A2; + yield return A3; + yield return A4; + yield return A5; + yield return A6; + yield return A7; + yield return A8; + yield return A9; + yield return A10; + yield return A11; + yield return A12; + yield return A13; + yield return A14; + yield return A15; + yield return A16; + yield return A17; + yield return A18; + yield return A19; + yield return A20; + } + + public A1 A1 { get; private set; } = new(); + public A2 A2 { get; private set; } = new(); + public A3 A3 { get; private set; } = new(); + public A4 A4 { get; private set; } = new(); + public A5 A5 { get;private set; } = new(); + public A6 A6 { get;private set; } = new(); + public A7 A7 { get;private set; } = new(); + public A8 A8 { get;private set; } = new(); + public A9 A9 { get; private set; } = new(); + public A10 A10 { get; private set; } = new(); + public A10 A11 { get; private set; } = new(); + public A10 A12 { get; private set; } = new(); + public A10 A13 { get; private set; } = new(); + public A10 A14 { get; private set; } = new(); + public A10 A15 { get; private set; } = new(); + public A10 A16 { get; private set; } = new(); + public A10 A17 { get; private set; } = new(); + public A10 A18 { get; private set; } = new(); + public A10 A19 { get; private set; } = new(); + public A10 A20 { get; private set; } = new(); + + public override double Constant => throw new NotImplementedException(); +} diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs new file mode 100644 index 00000000..f17d7a3d --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs @@ -0,0 +1,10 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Exemption; +public class B1() : SingleChoiceQuestion("Exempted from bio survey?", +[ + Yes, + No +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs new file mode 100644 index 00000000..7995012f --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C1() : SingleChoiceQuestion("Had a loved one become seriously ill or pass away", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs new file mode 100644 index 00000000..3e8bcc93 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C10() : SingleChoiceQuestion("Found a new hobby or interest", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs new file mode 100644 index 00000000..833c0c2b --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C2() : SingleChoiceQuestion("Got engaged, married, entered a civil partnership", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs new file mode 100644 index 00000000..6867a2d7 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C3() : SingleChoiceQuestion("Became a parent", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs new file mode 100644 index 00000000..b4ef6447 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C4() : SingleChoiceQuestion("Started a new personal relationship", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs new file mode 100644 index 00000000..7f2bc48d --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C5() : SingleChoiceQuestion("Left a significant long-term relationship / divorce", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs new file mode 100644 index 00000000..1b29b50c --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C6() : SingleChoiceQuestion("Subject to verbal abuse or harassment", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs new file mode 100644 index 00000000..1ff4f855 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C7() : SingleChoiceQuestion("Subject to violence or harm by another person", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs new file mode 100644 index 00000000..50d4451c --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C8() : SingleChoiceQuestion("Lost your job", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs new file mode 100644 index 00000000..53d8e57b --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs @@ -0,0 +1,12 @@ +namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +public class C9() : SingleChoiceQuestion("Started a new job", +[ + Yes, + No, + NA +]) +{ + public const string Yes = "Yes"; + public const string No = "No"; + public const string NA = "N/A"; +}; \ No newline at end of file diff --git a/src/Domain/Common/Enums/Pathway.cs b/src/Domain/Common/Enums/Pathway.cs index cffd9c41..937ece1c 100644 --- a/src/Domain/Common/Enums/Pathway.cs +++ b/src/Domain/Common/Enums/Pathway.cs @@ -33,5 +33,11 @@ public static class CatsIcons public const string Money = ""; public const string Thoughts = ""; public const string AboutYou = ""; + + public const string Diversity = ""; + public const string Exemption = ""; + public const string ChildhoodExperiences = ""; + public const string RecentExperiences = ""; + } diff --git a/src/Domain/Domain.csproj b/src/Domain/Domain.csproj index d5ac3d03..102abbf1 100644 --- a/src/Domain/Domain.csproj +++ b/src/Domain/Domain.csproj @@ -11,10 +11,10 @@ - - - - + + + + diff --git a/src/Domain/Entities/Bios/Bio.cs b/src/Domain/Entities/Bios/Bio.cs new file mode 100644 index 00000000..a1d94012 --- /dev/null +++ b/src/Domain/Entities/Bios/Bio.cs @@ -0,0 +1,54 @@ +using Cfo.Cats.Domain.Common.Contracts; +using Cfo.Cats.Domain.Common.Entities; +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Domain.Entities.Bios +{ + + public class Bio : OwnerPropertyEntity, IMayHaveTenant, IAuditTrial + { + +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + private Bio() + { + } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + + + + public string ParticipantId { get; private set; } + public string BioJson { get; private set; } + + private Bio(Guid id, string participantId, string bioJson, string tenantId) + { + Id = id; + ParticipantId = participantId; + BioJson = bioJson; + TenantId = tenantId; + AddDomainEvent(new BioCreatedDomainEvent(this)); + } + + public Bio UpdateJson(string json) + { + //TODO: Add events for update, and logic to stop locked assessments being updated + this.BioJson = json; + return this; + } + + public Bio Submit() + { + // this does nothing except raise the event. + AddDomainEvent(new BioCreatedDomainEvent(this)); + return this; + } + + + public static Bio Create(Guid id, string participantId, string bioJson, string tenantId) + { + return new Bio(id, participantId, bioJson, tenantId); + } + + public string? TenantId { get; set; } + + } +} \ No newline at end of file diff --git a/src/Domain/Events/BioEvents.cs b/src/Domain/Events/BioEvents.cs new file mode 100644 index 00000000..d347718a --- /dev/null +++ b/src/Domain/Events/BioEvents.cs @@ -0,0 +1,8 @@ +using Cfo.Cats.Domain.Common.Events; +using Cfo.Cats.Domain.Entities.Bios; + +namespace Cfo.Cats.Domain.Events; + +public sealed class BioCreatedDomainEvent(Bio entity) + : CreatedDomainEvent(entity); + diff --git a/src/Server.UI/Pages/Bio/BioComponents/BioCheckbox.razor b/src/Server.UI/Pages/Bio/BioComponents/BioCheckbox.razor new file mode 100644 index 00000000..2f3dbbea --- /dev/null +++ b/src/Server.UI/Pages/Bio/BioComponents/BioCheckbox.razor @@ -0,0 +1,21 @@ + + + +@code { + + public string Statement = string.Empty; + public bool Toggle; + + public BioCheckbox() + { } + + public BioCheckbox(string statement) : this() + { + Statement = statement; + } + + public BioCheckbox(string statement, bool toggle) : this(statement) + { + Toggle = toggle; + } +} diff --git a/src/Server.UI/Pages/Bio/BioComponents/BioQuestion.razor b/src/Server.UI/Pages/Bio/BioComponents/BioQuestion.razor new file mode 100644 index 00000000..a2e3bc45 --- /dev/null +++ b/src/Server.UI/Pages/Bio/BioComponents/BioQuestion.razor @@ -0,0 +1,21 @@ + + + + @Question + + @if (HelperText is not null) + { + + @HelperText + + } + + +@code { + + [Parameter, EditorRequired] + public required string Question { get; init; } = string.Empty; + + [Parameter] + public string? HelperText { get; init; } +} From b139a589d572ee5721ca4c83aa5df5745debc6ae Mon Sep 17 00:00:00 2001 From: VS Date: Tue, 16 Jul 2024 13:23:47 +0100 Subject: [PATCH 2/8] removed Constant from PathwayBase as its not required for Bio --- src/Application/Features/Bio/DTOs/PathwayBase.cs | 3 --- .../Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs | 1 - 2 files changed, 4 deletions(-) diff --git a/src/Application/Features/Bio/DTOs/PathwayBase.cs b/src/Application/Features/Bio/DTOs/PathwayBase.cs index a1ab431f..39a5dd86 100644 --- a/src/Application/Features/Bio/DTOs/PathwayBase.cs +++ b/src/Application/Features/Bio/DTOs/PathwayBase.cs @@ -7,9 +7,6 @@ public abstract class PathwayBase [JsonIgnore] public abstract string Title { get; } - [JsonIgnore] - public abstract double Constant { get; } - [JsonIgnore] public abstract string Icon { get; } diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs index 5dffb59f..dcef2eb5 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs @@ -58,5 +58,4 @@ public override IEnumerable Questions() public A10 A19 { get; private set; } = new(); public A10 A20 { get; private set; } = new(); - public override double Constant => throw new NotImplementedException(); } From 9856cbce9031b82f50cc5a3ba1d1806fb1f8c8d0 Mon Sep 17 00:00:00 2001 From: VS Date: Tue, 16 Jul 2024 13:41:23 +0100 Subject: [PATCH 3/8] added pathway classes --- .../ChildhoodExperiencesPathway.cs | 53 +++++++++++++++++++ .../V1/Pathways/Diversity/DiversityPathway.cs | 20 +++---- .../RecentExperiencesPathway.cs | 44 +++++++++++++++ 3 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs create mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs new file mode 100644 index 00000000..de7cf76a --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs @@ -0,0 +1,53 @@ +using Cfo.Cats.Application.Features.Bio.DTOs; +using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +using System.Text.Json.Serialization; + +namespace Cfo.Cats.Bpplication.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; + +public sealed partial class ChildhoodExperiencesPathway + : PathwayBase +{ + + [JsonIgnore] + public override string Title => "ChildhoodExperiences"; + + + + [JsonIgnore] + public override string Icon => CatsIcons.ChildhoodExperiences; + public override IEnumerable Questions() + { + yield return B1; + yield return B2; + yield return B3; + yield return B4; + yield return B5; + yield return B6; + yield return B7; + yield return B8; + yield return B9; + yield return B10; + yield return B11; + yield return B12; + yield return B13; + yield return B14; + yield return B15; + + } + + public B1 B1 { get; private set; } = new(); + public B2 B2 { get; private set; } = new(); + public B3 B3 { get; private set; } = new(); + public B4 B4 { get; private set; } = new(); + public B5 B5 { get;private set; } = new(); + public B6 B6 { get;private set; } = new(); + public B7 B7 { get;private set; } = new(); + public B8 B8 { get;private set; } = new(); + public B9 B9 { get; private set; } = new(); + public B10 B10 { get; private set; } = new(); + public B11 B11 { get; private set; } = new(); + public B12 B12 { get; private set; } = new(); + public B13 B13 { get; private set; } = new(); + public B14 B14 { get; private set; } = new(); + public B15 B15 { get; private set; } = new(); +} diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs index dcef2eb5..60a422f7 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs @@ -47,15 +47,15 @@ public override IEnumerable Questions() public A8 A8 { get;private set; } = new(); public A9 A9 { get; private set; } = new(); public A10 A10 { get; private set; } = new(); - public A10 A11 { get; private set; } = new(); - public A10 A12 { get; private set; } = new(); - public A10 A13 { get; private set; } = new(); - public A10 A14 { get; private set; } = new(); - public A10 A15 { get; private set; } = new(); - public A10 A16 { get; private set; } = new(); - public A10 A17 { get; private set; } = new(); - public A10 A18 { get; private set; } = new(); - public A10 A19 { get; private set; } = new(); - public A10 A20 { get; private set; } = new(); + public A11 A11 { get; private set; } = new(); + public A12 A12 { get; private set; } = new(); + public A13 A13 { get; private set; } = new(); + public A14 A14 { get; private set; } = new(); + public A15 A15 { get; private set; } = new(); + public A16 A16 { get; private set; } = new(); + public A17 A17 { get; private set; } = new(); + public A18 A18 { get; private set; } = new(); + public A19 A19 { get; private set; } = new(); + public A20 A20 { get; private set; } = new(); } diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs new file mode 100644 index 00000000..844eef37 --- /dev/null +++ b/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs @@ -0,0 +1,44 @@ +using System.Text.Json.Serialization; +using Cfo.Cats.Application.Features.Bio.DTOs; +using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; + +namespace Cfo.Cats.Application.Features.Cio.DTOs.V1.Pathways.RecentExperiences; + +public sealed partial class RecentExperiencesPathway + : PathwayBase +{ + + [JsonIgnore] + public override string Title => "RecentExperiences"; + + + + [JsonIgnore] + public override string Icon => CatsIcons.RecentExperiences; + public override IEnumerable Questions() + { + yield return C1; + yield return C2; + yield return C3; + yield return C4; + yield return C5; + yield return C6; + yield return C7; + yield return C8; + yield return C9; + yield return C10; + + } + + public C1 C1 { get; private set; } = new(); + public C2 C2 { get; private set; } = new(); + public C3 C3 { get; private set; } = new(); + public C4 C4 { get; private set; } = new(); + public C5 C5 { get; private set; } = new(); + public C6 C6 { get; private set; } = new(); + public C7 C7 { get; private set; } = new(); + public C8 C8 { get; private set; } = new(); + public C9 C9 { get; private set; } = new(); + public C10 C10 { get; private set; } = new(); + +} From 532e2dc5a0bf183930c57e50469a50d5dcf2fb12 Mon Sep 17 00:00:00 2001 From: VS Date: Wed, 14 Aug 2024 14:28:42 +0100 Subject: [PATCH 4/8] Added io functionality --- src/Application/Application.csproj | 8 +- .../Interfaces/IApplicationDbContext.cs | 3 +- .../Features/Bio/Commands/SaveAssessment.cs | 78 - .../Bio/DTOs/V1/Pathways/Exemption/D1.cs | 10 - .../Caching/BiosCacheKey.cs} | 6 +- .../{Bio => Bios}/Commands/BeginBio.cs | 34 +- .../Features/Bios/Commands/SaveBio.cs | 61 + .../Features/Bios/Commands/SkipBioForNow.cs | 50 + .../DTOs/BioSurvey.cs => Bios/DTOs/Bio.cs} | 5 +- .../{Bio => Bios}/DTOs/BioPathwayValidator.cs | 2 +- .../{Bio => Bios}/DTOs/BioValidator.cs | 4 +- .../DTOs/ParticipantBioDto.cs} | 6 +- .../{Bio => Bios}/DTOs/PathwayBase.cs | 2 +- .../{Bio => Bios}/DTOs/QuestionBase.cs | 2 +- .../DTOs/SingleChoiceQuestion.cs | 7 +- .../V1/Pathways/ChildhoodExperiences/B1.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B10.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B11.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B12.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B13.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B14.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B15.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B2.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B3.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B4.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B5.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B6.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B7.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B8.cs | 2 +- .../V1/Pathways/ChildhoodExperiences/B9.cs | 2 +- .../ChildhoodExperiencesPathway.cs | 4 +- .../DTOs/V1/Pathways/Diversity/A1.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A10.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A11.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A12.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A13.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A14.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A15.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A16.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A17.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A18.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A19.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A2.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A20.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A3.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A4.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A5.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A6.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A7.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A8.cs | 2 +- .../DTOs/V1/Pathways/Diversity/A9.cs | 2 +- .../V1/Pathways/Diversity/DiversityPathway.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C1.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C10.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C2.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C3.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C4.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C5.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C6.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C7.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C8.cs | 2 +- .../DTOs/V1/Pathways/RecentExperiences/C9.cs | 2 +- .../RecentExperiencesPathway.cs | 4 +- .../Bios/Exceptions/InvalidAnswerException.cs | 11 + .../Features/Bios/Queries/GetBio.cs | 74 + .../DTOs/ParticipantSummaryDto.cs | 33 + .../Queries/GetParticipantSummary.cs | 8 +- src/Domain/Common/Enums/BioStatus.cs | 14 + src/Domain/Domain.csproj | 8 +- .../Bios/{Bio.cs => ParticipantBio.cs} | 27 +- src/Domain/Events/BioEvents.cs | 4 +- .../Constants/Database/DatabaseConstants.cs | 1 + .../Persistence/ApplicationDbContext.cs | 4 +- .../BioEntityTypeConfiguration.cs | 35 + .../Migrations/20240813132251_bio.Designer.cs | 2347 +++++++++++++++++ .../Migrations/20240813132251_bio.cs | 55 + .../ApplicationDbContextModelSnapshot.cs | 48 + src/Server.UI/Pages/Bio/Bio.razor | 115 + src/Server.UI/Pages/Bio/BioPathway.razor | 87 + .../Participants/Components/CaseBio.razor | 121 + .../Participants/Components/CaseSummary.razor | 72 + .../Components/CaseSummary.razor.cs | 98 +- .../Pages/Participants/Participant.razor | 3 + 83 files changed, 3339 insertions(+), 204 deletions(-) delete mode 100644 src/Application/Features/Bio/Commands/SaveAssessment.cs delete mode 100644 src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs rename src/Application/Features/{Bio/Caching/BioCacheKey.cs => Bios/Caching/BiosCacheKey.cs} (88%) rename src/Application/Features/{Bio => Bios}/Commands/BeginBio.cs (62%) create mode 100644 src/Application/Features/Bios/Commands/SaveBio.cs create mode 100644 src/Application/Features/Bios/Commands/SkipBioForNow.cs rename src/Application/Features/{Bio/DTOs/BioSurvey.cs => Bios/DTOs/Bio.cs} (54%) rename src/Application/Features/{Bio => Bios}/DTOs/BioPathwayValidator.cs (85%) rename src/Application/Features/{Bio => Bios}/DTOs/BioValidator.cs (53%) rename src/Application/Features/{Bio/DTOs/BioDto.cs => Bios/DTOs/ParticipantBioDto.cs} (71%) rename src/Application/Features/{Bio => Bios}/DTOs/PathwayBase.cs (82%) rename src/Application/Features/{Bio => Bios}/DTOs/QuestionBase.cs (96%) rename src/Application/Features/{Bio => Bios}/DTOs/SingleChoiceQuestion.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs (71%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs (70%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs (70%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs (71%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs (71%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs (70%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs (71%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs (87%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A1.cs (74%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A10.cs (74%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A11.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A12.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A13.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A14.cs (74%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A15.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A16.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A17.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A18.cs (74%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A19.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A2.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A20.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A3.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A4.cs (77%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A5.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A6.cs (74%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A7.cs (75%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A8.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/A9.cs (76%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/Diversity/DiversityPathway.cs (96%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C1.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C10.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C2.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C3.cs (70%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C4.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C5.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C6.cs (72%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C7.cs (73%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C8.cs (70%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/C9.cs (70%) rename src/Application/Features/{Bio => Bios}/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs (84%) create mode 100644 src/Application/Features/Bios/Exceptions/InvalidAnswerException.cs create mode 100644 src/Application/Features/Bios/Queries/GetBio.cs create mode 100644 src/Domain/Common/Enums/BioStatus.cs rename src/Domain/Entities/Bios/{Bio.cs => ParticipantBio.cs} (58%) create mode 100644 src/Infrastructure/Persistence/Configurations/Participants/BioEntityTypeConfiguration.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.cs create mode 100644 src/Server.UI/Pages/Bio/Bio.razor create mode 100644 src/Server.UI/Pages/Bio/BioPathway.razor create mode 100644 src/Server.UI/Pages/Participants/Components/CaseBio.razor diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj index 6940e3d1..4c98a60c 100644 --- a/src/Application/Application.csproj +++ b/src/Application/Application.csproj @@ -9,8 +9,7 @@ true - - + @@ -34,9 +33,4 @@ - - - - - \ No newline at end of file diff --git a/src/Application/Common/Interfaces/IApplicationDbContext.cs b/src/Application/Common/Interfaces/IApplicationDbContext.cs index 2886ede6..f2b3d5ed 100644 --- a/src/Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/Application/Common/Interfaces/IApplicationDbContext.cs @@ -2,6 +2,7 @@ using Cfo.Cats.Domain.Entities.Assessments; using Cfo.Cats.Domain.Entities.Documents; using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Entities.Bios; using Cfo.Cats.Domain.Identity; using Cfo.Cats.Domain.ValueObjects; using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; @@ -30,7 +31,7 @@ public interface IApplicationDbContext public DbSet KeyValues { get; } public DbSet ParticipantAssessments { get; } - + public DbSet ParticipantBios { get; } public DbSet ParticipantEnrolmentHistories { get; } public DbSet Timelines { get; } diff --git a/src/Application/Features/Bio/Commands/SaveAssessment.cs b/src/Application/Features/Bio/Commands/SaveAssessment.cs deleted file mode 100644 index 5526f65a..00000000 --- a/src/Application/Features/Bio/Commands/SaveAssessment.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Cfo.Cats.Application.Common.Security; -using Cfo.Cats.Application.Features.Assessments.Caching; -using Cfo.Cats.Application.Features.Assessments.DTOs; -using Cfo.Cats.Application.SecurityConstants; -using Cfo.Cats.Domain.Entities.Assessments; -using Newtonsoft.Json; - -namespace Cfo.Cats.Application.Features.Assessments.Commands; - -public static class SaveAssessment -{ - [RequestAuthorize(Policy = PolicyNames.AllowEnrol)] - public class Command : ICacheInvalidatorRequest - { - //TODO: cache individually - public string[] CacheKeys => [ AssessmentsCacheKey.GetAllCacheKey ]; - public CancellationTokenSource? SharedExpiryTokenSource => AssessmentsCacheKey.SharedExpiryTokenSource(); - - public bool Submit { get; set; } = false; - - public required Assessment Assessment { get; set; } - - } - - public class Handler : IRequestHandler - { - private readonly IUnitOfWork _unitOfWork; - - public Handler(IUnitOfWork unitOfWork) - { - _unitOfWork = unitOfWork; - - } - - public async Task Handle(Command request, CancellationToken cancellationToken) - { - ParticipantAssessment pa = _unitOfWork.DbContext.ParticipantAssessments.FirstOrDefault(r => r.Id == request.Assessment.Id && r.ParticipantId == request.Assessment.ParticipantId) - ?? throw new NotFoundException(nameof(Assessment), new - { - request.Assessment.Id, - request.Assessment.ParticipantId - }); - - - pa.UpdateJson(JsonConvert.SerializeObject(request.Assessment, new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.Auto - })); - - if (request.Submit) - { - var details = await _unitOfWork.DbContext.Participants - .Where(p => p.Id == request.Assessment.ParticipantId) - .Select(p => - new - { - p.DateOfBirth, - LotNumber = p.EnrolmentLocation!.Contract!.LotNumber, - Gender = "Male" - } - ).FirstAsync(cancellationToken); - - Sex sex = Sex.FromName(details.Gender); - AssessmentLocation location = AssessmentLocation.FromValue(details.LotNumber); - var age = details.DateOfBirth!.Value.CalculateAge(); - - foreach(var pathway in request.Assessment.Pathways) - { - pa.SetPathwayScore(pathway.Title, pathway.GetRagScore(age, location, sex)); - } - pa.Submit(); - } - - return await Result.SuccessAsync(); - } - } - -} diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs b/src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs deleted file mode 100644 index f17d7a3d..00000000 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Exemption/D1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Exemption; -public class B1() : SingleChoiceQuestion("Exempted from bio survey?", -[ - Yes, - No -]) -{ - public const string Yes = "Yes"; - public const string No = "No"; -}; \ No newline at end of file diff --git a/src/Application/Features/Bio/Caching/BioCacheKey.cs b/src/Application/Features/Bios/Caching/BiosCacheKey.cs similarity index 88% rename from src/Application/Features/Bio/Caching/BioCacheKey.cs rename to src/Application/Features/Bios/Caching/BiosCacheKey.cs index 6a372d72..416a4a5c 100644 --- a/src/Application/Features/Bio/Caching/BioCacheKey.cs +++ b/src/Application/Features/Bios/Caching/BiosCacheKey.cs @@ -1,13 +1,13 @@ -namespace Cfo.Cats.Application.Features.Assessments.Caching; +namespace Cfo.Cats.Application.Features.Bios.Caching; -public class BioCacheKey +public class BiosCacheKey { //note: we currently only have one but may need more in the future public const string GetAllCacheKey = "all-bios"; private static readonly TimeSpan RefreshInterval = TimeSpan.FromMinutes(60); private static CancellationTokenSource tokenSource; - static BioCacheKey() + static BiosCacheKey() { tokenSource = new CancellationTokenSource(RefreshInterval); } diff --git a/src/Application/Features/Bio/Commands/BeginBio.cs b/src/Application/Features/Bios/Commands/BeginBio.cs similarity index 62% rename from src/Application/Features/Bio/Commands/BeginBio.cs rename to src/Application/Features/Bios/Commands/BeginBio.cs index 0fbad339..bba42857 100644 --- a/src/Application/Features/Bio/Commands/BeginBio.cs +++ b/src/Application/Features/Bios/Commands/BeginBio.cs @@ -1,29 +1,27 @@ -using System.Text.Json.Serialization; using Cfo.Cats.Application.Common.Security; -using Cfo.Cats.Application.Features.Bio.Caching; -using Cfo.Cats.Application.Features.Bio.DTOs; -using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; -using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; -using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; -using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Exemption; +using Cfo.Cats.Application.Features.Bios.Caching; +using Cfo.Cats.Application.Features.Bios.DTOs; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Bios; using Newtonsoft.Json; -using Cfo.Cats.Application.Features.Assessments.Caching; -namespace Cfo.Cats.Application.Features.Assessments.Commands; + +namespace Cfo.Cats.Application.Features.Bios.Commands; public static class BeginBio { - [RequestAuthorize(Policy = PolicyNames.AllowEnrol)] + [RequestAuthorize(Policy = SecurityPolicies.Enrol)] public class Command : ICacheInvalidatorRequest> { public required string ParticipantId { get; set; } //TODO: this could be done at a per participant level - public string[] CacheKeys => [ BioCacheKey.GetAllCacheKey ]; + public string[] CacheKeys => [ BiosCacheKey.GetAllCacheKey ]; public CancellationTokenSource? SharedExpiryTokenSource - => BioCacheKey.SharedExpiryTokenSource(); + => BiosCacheKey.SharedExpiryTokenSource(); } public class Handler : IRequestHandler> @@ -38,13 +36,16 @@ public Handler(IUnitOfWork unitOfWork, ICurrentUserService currentUserService) public async Task> Handle(Command request, CancellationToken cancellationToken) { - BioSurvey bio = new BioSurvey() + await Task.CompletedTask; + Bio bio = new Bio() { Id = Guid.NewGuid(), ParticipantId = request.ParticipantId, Pathways = [ + new ChildhoodExperiencesPathway(), new DiversityPathway(), + new RecentExperiencesPathway(), ] }; @@ -53,11 +54,10 @@ public async Task> Handle(Command request, CancellationToken cancel TypeNameHandling = TypeNameHandling.Auto }); - BioSurvey bs = bio.Create(bio.Id, request.ParticipantId, bioJson: json, _currentUserService.TenantId!); - + ParticipantBio bioSurvey = ParticipantBio.Create(bio.Id, request.ParticipantId, bioJson: json, BioStatus.NotStarted); - _unitOfWork.DbContext.bios.Add(bs); - return await Result.SuccessAsync(bio.Id); + _unitOfWork.DbContext.ParticipantBios.Add(bioSurvey); + return Result.Success(bio.Id); } } diff --git a/src/Application/Features/Bios/Commands/SaveBio.cs b/src/Application/Features/Bios/Commands/SaveBio.cs new file mode 100644 index 00000000..81fc0300 --- /dev/null +++ b/src/Application/Features/Bios/Commands/SaveBio.cs @@ -0,0 +1,61 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Bios.Caching; +using Cfo.Cats.Application.Features.Bios.DTOs; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Domain.Entities.Bios; +using Newtonsoft.Json; + +namespace Cfo.Cats.Application.Features.Bios.Commands; + +public static class SaveBio +{ + [RequestAuthorize(Policy = SecurityPolicies.Enrol)] + public class Command : ICacheInvalidatorRequest + { + //TODO: cache individually + public string[] CacheKeys => [ BiosCacheKey.GetAllCacheKey ]; + public CancellationTokenSource? SharedExpiryTokenSource => BiosCacheKey.SharedExpiryTokenSource(); + + public bool Submit { get; set; } = false; + + public required Bio Bio { get; set; } + + } + + public class Handler : IRequestHandler + { + private readonly IUnitOfWork _unitOfWork; + + public Handler(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + } + + public async Task Handle(Command request, CancellationToken cancellationToken) + { + await Task.CompletedTask; + Domain.Entities.Bios.ParticipantBio bio = _unitOfWork.DbContext.ParticipantBios.FirstOrDefault(r => r.Id == request.Bio.Id && r.ParticipantId == request.Bio.ParticipantId) + ?? throw new NotFoundException(nameof(Bio), new + { + request.Bio.Id, + request.Bio.ParticipantId + }); + + + bio.UpdateJson(JsonConvert.SerializeObject(request.Bio, new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + })); + bio.UpdateStatus(BioStatus.InProgress); + if (request.Submit) + { + bio.UpdateStatus(BioStatus.Complete); + bio.Submit(); + } + + return Result.Success(); + } + } + +} diff --git a/src/Application/Features/Bios/Commands/SkipBioForNow.cs b/src/Application/Features/Bios/Commands/SkipBioForNow.cs new file mode 100644 index 00000000..016bb80c --- /dev/null +++ b/src/Application/Features/Bios/Commands/SkipBioForNow.cs @@ -0,0 +1,50 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Bios.Caching; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; +using Cfo.Cats.Application.Features.Bios.DTOs; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Domain.Entities.Bios; +using Newtonsoft.Json; + +namespace Cfo.Cats.Application.Features.Bios.Commands; + +public static class SkipBioForNow +{ + [RequestAuthorize(Policy = SecurityPolicies.Enrol)] + public class Command : ICacheInvalidatorRequest + { + //TODO: cache individually + public string[] CacheKeys => [BiosCacheKey.GetAllCacheKey]; + public CancellationTokenSource? SharedExpiryTokenSource => BiosCacheKey.SharedExpiryTokenSource(); + + public required Guid BioId { get; set; } + + } + + public class Handler : IRequestHandler + { + private readonly IUnitOfWork _unitOfWork; + + public Handler(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + } + + public async Task Handle(Command request, CancellationToken cancellationToken) + { + await Task.CompletedTask; + Domain.Entities.Bios.ParticipantBio bio = _unitOfWork.DbContext.ParticipantBios.FirstOrDefault(r => r.Id == request.BioId) + ?? throw new NotFoundException(nameof(Bio), new + { + request.BioId + }); + + bio.UpdateStatus(BioStatus.SkippedForNow); + return Result.Success(); + } + } + +} diff --git a/src/Application/Features/Bio/DTOs/BioSurvey.cs b/src/Application/Features/Bios/DTOs/Bio.cs similarity index 54% rename from src/Application/Features/Bio/DTOs/BioSurvey.cs rename to src/Application/Features/Bios/DTOs/Bio.cs index 1ef07888..b6a6107e 100644 --- a/src/Application/Features/Bio/DTOs/BioSurvey.cs +++ b/src/Application/Features/Bios/DTOs/Bio.cs @@ -1,8 +1,9 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; -public class BioSurvey +public class Bio { public required Guid Id { get; set; } public required string ParticipantId { get; set; } + public BioStatus Status { get; set; } = BioStatus.NotStarted; public required PathwayBase[] Pathways { get; set; } } \ No newline at end of file diff --git a/src/Application/Features/Bio/DTOs/BioPathwayValidator.cs b/src/Application/Features/Bios/DTOs/BioPathwayValidator.cs similarity index 85% rename from src/Application/Features/Bio/DTOs/BioPathwayValidator.cs rename to src/Application/Features/Bios/DTOs/BioPathwayValidator.cs index 24781b77..ac7423d2 100644 --- a/src/Application/Features/Bio/DTOs/BioPathwayValidator.cs +++ b/src/Application/Features/Bios/DTOs/BioPathwayValidator.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; public class BioPathwayValidator : AbstractValidator { diff --git a/src/Application/Features/Bio/DTOs/BioValidator.cs b/src/Application/Features/Bios/DTOs/BioValidator.cs similarity index 53% rename from src/Application/Features/Bio/DTOs/BioValidator.cs rename to src/Application/Features/Bios/DTOs/BioValidator.cs index e9105b82..899b05c0 100644 --- a/src/Application/Features/Bio/DTOs/BioValidator.cs +++ b/src/Application/Features/Bios/DTOs/BioValidator.cs @@ -1,6 +1,6 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; -public class BioValidator : AbstractValidator +public class BioValidator : AbstractValidator { public BioValidator() { diff --git a/src/Application/Features/Bio/DTOs/BioDto.cs b/src/Application/Features/Bios/DTOs/ParticipantBioDto.cs similarity index 71% rename from src/Application/Features/Bio/DTOs/BioDto.cs rename to src/Application/Features/Bios/DTOs/ParticipantBioDto.cs index c880c7ec..1913500a 100644 --- a/src/Application/Features/Bio/DTOs/BioDto.cs +++ b/src/Application/Features/Bios/DTOs/ParticipantBioDto.cs @@ -1,8 +1,8 @@ using Cfo.Cats.Domain.Entities.Bios; -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; -public class BioDto +public class ParticipantBioDto { public required string ParticipantId { get; set; } public required DateTime CreatedDate { get; set; } @@ -11,7 +11,7 @@ private class Mapping : Profile { public Mapping() { - CreateMap() + CreateMap() .ForMember(p => p.CreatedDate, options => options.MapFrom(source => source.Created)); } } diff --git a/src/Application/Features/Bio/DTOs/PathwayBase.cs b/src/Application/Features/Bios/DTOs/PathwayBase.cs similarity index 82% rename from src/Application/Features/Bio/DTOs/PathwayBase.cs rename to src/Application/Features/Bios/DTOs/PathwayBase.cs index 39a5dd86..78f8445d 100644 --- a/src/Application/Features/Bio/DTOs/PathwayBase.cs +++ b/src/Application/Features/Bios/DTOs/PathwayBase.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; public abstract class PathwayBase { diff --git a/src/Application/Features/Bio/DTOs/QuestionBase.cs b/src/Application/Features/Bios/DTOs/QuestionBase.cs similarity index 96% rename from src/Application/Features/Bio/DTOs/QuestionBase.cs rename to src/Application/Features/Bios/DTOs/QuestionBase.cs index 15cd640a..5d234e5e 100644 --- a/src/Application/Features/Bio/DTOs/QuestionBase.cs +++ b/src/Application/Features/Bios/DTOs/QuestionBase.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; /// /// Base class for the all questions diff --git a/src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs b/src/Application/Features/Bios/DTOs/SingleChoiceQuestion.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs rename to src/Application/Features/Bios/DTOs/SingleChoiceQuestion.cs index 939e2123..c0d67c34 100644 --- a/src/Application/Features/Bio/DTOs/SingleChoiceQuestion.cs +++ b/src/Application/Features/Bios/DTOs/SingleChoiceQuestion.cs @@ -1,9 +1,4 @@ -using System.Text.Json.Serialization; -using Cfo.Cats.Application.Features.Assessments.DTOs.V1.Pathways.Education; -using Cfo.Cats.Application.Features.Assessments.DTOs.V1.Pathways.HealthAndAdditiction; -using Cfo.Cats.Application.Features.Assessments.DTOs.V1.Pathways.Working; - -namespace Cfo.Cats.Application.Features.Bio.DTOs; +namespace Cfo.Cats.Application.Features.Bios.DTOs; /// /// An implementation of QuestionBase that only allows a diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs similarity index 71% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs index 6df90a9a..86afe238 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B1.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B1() : SingleChoiceQuestion("Spent time in care as a child", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs similarity index 70% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs index ee25656c..d369f109 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B10.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B10() : SingleChoiceQuestion("Felt safe at home", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs similarity index 70% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs index 152fbe9e..9f89aae8 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B11.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B11() : SingleChoiceQuestion("Enjoyed going to school", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs index 489829b1..5e46bcf2 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B12.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B12() : SingleChoiceQuestion("Parent or guardian had a drug / alcohol problem", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs index f2b268ce..da7dd2c0 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B13.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B13() : SingleChoiceQuestion("Parent or guardian was seriously ill / passed away", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs index b80f7e7b..c711e5aa 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B14.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B14() : SingleChoiceQuestion("Had a close friend you could confide in", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs similarity index 71% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs index 0d3a5123..1e76f819 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B15.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B15() : SingleChoiceQuestion("Had someone you looked up to", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs index 53853773..333c8626 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B2.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B2() : SingleChoiceQuestion("Spent most of childhood in the same family home", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs similarity index 71% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs index 83e0e9dd..2e8b0bdd 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B3.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B3() : SingleChoiceQuestion("Suffered abuse or neglect as a child", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs similarity index 70% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs index 15f63095..ca2e6137 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B4.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B4() : SingleChoiceQuestion("Had a difficult childhood", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs index 674f50d1..7c88d529 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B5.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B5() : SingleChoiceQuestion("Both parents/guardians were mostly present", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs index e0c06b25..dd8128b8 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B6.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B6() : SingleChoiceQuestion("At least one parent or guardian was mostly in work", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs index f37de8a5..5d33d923 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B7.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B7() : SingleChoiceQuestion("A parent or guardian was in trouble with the police", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs index 0479b8ee..2a19e242 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B8.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B8() : SingleChoiceQuestion("A parent or guardian spent time in prison", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs similarity index 71% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs index 35542776..73510665 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/B9.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public class B9() : SingleChoiceQuestion("Felt loved and cared for at home", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs similarity index 87% rename from src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs index de7cf76a..47b54180 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/ChildhoodExperiences/ChildhoodExperiencesPathway.cs @@ -1,8 +1,6 @@ -using Cfo.Cats.Application.Features.Bio.DTOs; -using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; using System.Text.Json.Serialization; -namespace Cfo.Cats.Bpplication.Features.Bio.DTOs.V1.Pathways.ChildhoodExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; public sealed partial class ChildhoodExperiencesPathway : PathwayBase diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A1.cs similarity index 74% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A1.cs index d9ab0f8a..5ee0324c 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A1.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A1.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A1() : SingleChoiceQuestion("Consider yourself a religious person", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A10.cs similarity index 74% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A10.cs index 4352ed9f..9ea30f29 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A10.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A10.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A10() : SingleChoiceQuestion("Are/have been a member of a gang", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A11.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A11.cs index ed87e75c..7e5c4d47 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A11.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A11.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A11() : SingleChoiceQuestion("Have carried an illegal weapon at some point in the past", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A12.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A12.cs index 04f19454..f42c1cef 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A12.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A12.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A12() : SingleChoiceQuestion("Have undertaken prostitution or sex work", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A13.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A13.cs index 5acff049..5052a9b6 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A13.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A13.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A13() : SingleChoiceQuestion("Feel you are being taken advantage of by others", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A14.cs similarity index 74% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A14.cs index ed01b552..5a64def2 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A14.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A14.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A14() : SingleChoiceQuestion("Feel you are part of a community ", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A15.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A15.cs index b110d7fa..49052816 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A15.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A15.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A15() : SingleChoiceQuestion("Feel you have been discriminated against because of who you are", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A16.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A16.cs index a90fdb39..31640637 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A16.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A16.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A16() : SingleChoiceQuestion("Feel you generally share the same views of those around you", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A17.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A17.cs index 445b03d2..56c7f1bd 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A17.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A17.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A17() : SingleChoiceQuestion("Feel you are always getting into trouble, since you were a child", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A18.cs similarity index 74% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A18.cs index ec19222a..36ec327f 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A18.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A18.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A18() : SingleChoiceQuestion("Regret the offence(s) you committed", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A19.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A19.cs index 4acafdc8..9ddbc953 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A19.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A19.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A19() : SingleChoiceQuestion("Feel your current situation is not your fault", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A2.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A2.cs index 5ce0f61f..efaf52a3 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A2.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A2.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A2() : SingleChoiceQuestion("Practise your faith regularly", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A20.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A20.cs index 194cd2be..b134256f 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A20.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A20.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A20() : SingleChoiceQuestion("Feel you are a better person than you used to be", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A3.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A3.cs index 2d26a4c9..4e2d52b0 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A3.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A3.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A3() : SingleChoiceQuestion("Gay, lesbian, bisexual, or other non-hetero orientation", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A4.cs similarity index 77% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A4.cs index ba561519..cc1f6a77 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A4.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A4.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A4() : SingleChoiceQuestion("Gender you identify with is different to your registered sex at birth", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A5.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A5.cs index e4fcf31c..fdab4654 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A5.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A5.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A5() : SingleChoiceQuestion("A member of a Gypsy or Irish traveller community", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A6.cs similarity index 74% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A6.cs index 4ef512d8..ed156c05 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A6.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A6.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A6() : SingleChoiceQuestion("A member of the Roma community", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A7.cs similarity index 75% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A7.cs index 51154148..555c4ad7 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A7.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A7.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A7() : SingleChoiceQuestion("Served in the British Armed Forces, inc. Reserves", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A8.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A8.cs index 5895dd94..0ddd3824 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A8.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A8.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A8() : SingleChoiceQuestion("Undertook an operational tour with the British Armed Forces", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A9.cs similarity index 76% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A9.cs index 1e55b111..680e00f6 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/A9.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/A9.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public class A9() : SingleChoiceQuestion("Have seen combat while a member of the British Armed Forces", [ diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/DiversityPathway.cs similarity index 96% rename from src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/DiversityPathway.cs index 60a422f7..3831bbe7 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/Diversity/DiversityPathway.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/Diversity/DiversityPathway.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.Diversity; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; public sealed partial class DiversityPathway : PathwayBase diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C1.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C1.cs index 7995012f..16ddeffc 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C1.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C1.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C1() : SingleChoiceQuestion("Had a loved one become seriously ill or pass away", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C10.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C10.cs index 3e8bcc93..e3ff853b 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C10.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C10.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C10() : SingleChoiceQuestion("Found a new hobby or interest", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C2.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C2.cs index 833c0c2b..00d76888 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C2.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C2.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C2() : SingleChoiceQuestion("Got engaged, married, entered a civil partnership", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C3.cs similarity index 70% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C3.cs index 6867a2d7..7281fdca 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C3.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C3.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C3() : SingleChoiceQuestion("Became a parent", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C4.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C4.cs index b4ef6447..ea68f919 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C4.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C4.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C4() : SingleChoiceQuestion("Started a new personal relationship", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C5.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C5.cs index 7f2bc48d..cceddcae 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C5.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C5.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C5() : SingleChoiceQuestion("Left a significant long-term relationship / divorce", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C6.cs similarity index 72% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C6.cs index 1b29b50c..85284b8b 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C6.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C6.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C6() : SingleChoiceQuestion("Subject to verbal abuse or harassment", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C7.cs similarity index 73% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C7.cs index 1ff4f855..af37baa0 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C7.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C7.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C7() : SingleChoiceQuestion("Subject to violence or harm by another person", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C8.cs similarity index 70% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C8.cs index 50d4451c..c51f4d38 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C8.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C8.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C8() : SingleChoiceQuestion("Lost your job", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C9.cs similarity index 70% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C9.cs index 53d8e57b..2ef1f1da 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/C9.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/C9.cs @@ -1,4 +1,4 @@ -namespace Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public class C9() : SingleChoiceQuestion("Started a new job", [ Yes, diff --git a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs similarity index 84% rename from src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs rename to src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs index 844eef37..57114594 100644 --- a/src/Application/Features/Bio/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs +++ b/src/Application/Features/Bios/DTOs/V1/Pathways/RecentExperiences/RecentExperiencesPathway.cs @@ -1,8 +1,6 @@ using System.Text.Json.Serialization; -using Cfo.Cats.Application.Features.Bio.DTOs; -using Cfo.Cats.Application.Features.Bio.DTOs.V1.Pathways.RecentExperiences; -namespace Cfo.Cats.Application.Features.Cio.DTOs.V1.Pathways.RecentExperiences; +namespace Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; public sealed partial class RecentExperiencesPathway : PathwayBase diff --git a/src/Application/Features/Bios/Exceptions/InvalidAnswerException.cs b/src/Application/Features/Bios/Exceptions/InvalidAnswerException.cs new file mode 100644 index 00000000..e9d9f2a1 --- /dev/null +++ b/src/Application/Features/Bios/Exceptions/InvalidAnswerException.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cfo.Cats.Application.Features.Bios.Exceptions; +public class InvalidAnswerException(string question, string answer) + : Exception($"The answer {answer} is not valid for the question {question}"); + + diff --git a/src/Application/Features/Bios/Queries/GetBio.cs b/src/Application/Features/Bios/Queries/GetBio.cs new file mode 100644 index 00000000..6047be77 --- /dev/null +++ b/src/Application/Features/Bios/Queries/GetBio.cs @@ -0,0 +1,74 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Application.Features.Bios.DTOs; +using Newtonsoft.Json; + + +namespace Cfo.Cats.Application.Features.Bios.Queries; + +public static class GetBio +{ + + /// + /// Returns a Bio for a Participant + /// + [RequestAuthorize(Policy = SecurityPolicies.Enrol)] + public class Query : IRequest> + { + public required string ParticipantId { get; set; } + public Guid? BioId { get; set; } + + } + + internal class Handler : IRequestHandler> + { + private readonly IUnitOfWork _unitOfWork; + public Handler(IUnitOfWork unitOfWork) + { + this._unitOfWork = unitOfWork; + } + + public async Task> Handle(Query request, CancellationToken cancellationToken) + { + var query = _unitOfWork.DbContext.ParticipantBios + .Where(p => p.ParticipantId == request.ParticipantId); + + if (request.BioId is not null) + { + query = query.Where(p => p.Id == request.BioId); + } + + var bioSurvey = await query.OrderByDescending(bioSurvey => bioSurvey.Created) + .FirstOrDefaultAsync(cancellationToken); + + if (bioSurvey is null) + { + return Result.Failure(["Participant not found"]); + } + + Bio bio = JsonConvert.DeserializeObject(bioSurvey.BioJson, + new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + })!; + return Result.Success(bio); + } + } + + public class Validator : AbstractValidator + { + public Validator() + { + + RuleFor(x => x.ParticipantId) + .NotNull(); + + RuleFor(x => x.ParticipantId) + .MinimumLength(9) + .MaximumLength(9) + .Matches(ValidationConstants.AlphaNumeric) + .WithMessage(string.Format(ValidationConstants.AlphaNumericMessage, "Participant Id")); + } + } +} \ No newline at end of file diff --git a/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs b/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs index 63c339a6..7feb044e 100644 --- a/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs +++ b/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs @@ -1,3 +1,4 @@ +using Cfo.Cats.Application.Features.Bios.DTOs; using Cfo.Cats.Domain.Entities.Assessments; using Cfo.Cats.Domain.Entities.Participants; @@ -40,6 +41,7 @@ public class ParticipantSummaryDto public RiskSummaryDto? LatestRisk { get; set; } + public BioSummaryDto? BioSummary { get; set; } private class Mapping : Profile { @@ -56,6 +58,12 @@ public Mapping() .ForMember(target => target.AssessmentDate, options => options.MapFrom(source => source.Created)) .ForMember(target => target.AssessmentCreator, options => options.MapFrom(source => source.CreatedBy)) .ForMember(target => target.AssessmentScored, options => options.MapFrom(source => source.Scores.All(s => s.Score >= 0))); + + CreateMap() + .ForMember(target => target.BioId, options => options.MapFrom(source => source.Id)) + .ForMember(target => target.BioDate, options => options.MapFrom(source => source.Created)) + .ForMember(target => target.BioStatus, options => options.MapFrom(source => source.Status)) + .ForMember(target => target.BioCreator, options => options.MapFrom(source => source.CreatedBy)); } } @@ -86,3 +94,28 @@ public class AssessmentSummaryDto /// public bool? AssessmentScored { get; set; } } + +public class BioSummaryDto +{ + /// + /// The id of the one and only Bio, atleast for now + /// + public Guid? BioId { get; set; } + + + /// + /// The date when Bio was created. + /// + public DateTime? BioDate { get; set; } + + /// + /// Who created the Bio (if available) + /// + public string? BioCreator { get; set; } + + /// + /// Status of the Bio + /// + public BioStatus BioStatus { get; set; } = BioStatus.NotStarted; + +} diff --git a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs index 6cc84c26..20bfe64d 100644 --- a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs +++ b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs @@ -46,7 +46,13 @@ public async Task> Handle(Query request, Cancellat .FirstOrDefaultAsync(x => x.ParticipantId == request.ParticipantId, cancellationToken); summary.LatestRisk = mapper.Map(risk); - + + var bio = await unitOfWork.DbContext.ParticipantBios + .OrderByDescending(x => x.Created) + .FirstOrDefaultAsync(x => x.ParticipantId == request.ParticipantId, cancellationToken); + + summary.BioSummary = mapper.Map(bio); + return Result.Success(summary); } diff --git a/src/Domain/Common/Enums/BioStatus.cs b/src/Domain/Common/Enums/BioStatus.cs new file mode 100644 index 00000000..8ba0a2d1 --- /dev/null +++ b/src/Domain/Common/Enums/BioStatus.cs @@ -0,0 +1,14 @@ +using Ardalis.SmartEnum; + +namespace Cfo.Cats.Domain.Common.Enums; + +public class BioStatus : SmartEnum +{ + public static readonly BioStatus NotStarted = new(nameof(NotStarted), 0); + public static readonly BioStatus SkippedForNow = new(nameof(SkippedForNow), 1); + public static readonly BioStatus InProgress = new(nameof(InProgress), 2); + public static readonly BioStatus Complete = new(nameof(Complete), 3); + + private BioStatus(string name, int value) + : base(name, value) { } +} diff --git a/src/Domain/Domain.csproj b/src/Domain/Domain.csproj index 40f57329..dfa01cf8 100644 --- a/src/Domain/Domain.csproj +++ b/src/Domain/Domain.csproj @@ -11,10 +11,10 @@ - - - - + + + + diff --git a/src/Domain/Entities/Bios/Bio.cs b/src/Domain/Entities/Bios/ParticipantBio.cs similarity index 58% rename from src/Domain/Entities/Bios/Bio.cs rename to src/Domain/Entities/Bios/ParticipantBio.cs index a1d94012..ef9efac6 100644 --- a/src/Domain/Entities/Bios/Bio.cs +++ b/src/Domain/Entities/Bios/ParticipantBio.cs @@ -1,15 +1,17 @@ using Cfo.Cats.Domain.Common.Contracts; using Cfo.Cats.Domain.Common.Entities; +using Cfo.Cats.Domain.Common.Enums; using Cfo.Cats.Domain.Events; +using System.Security.Cryptography; namespace Cfo.Cats.Domain.Entities.Bios { - public class Bio : OwnerPropertyEntity, IMayHaveTenant, IAuditTrial + public class ParticipantBio : BaseAuditableEntity, IAuditTrial { #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - private Bio() + private ParticipantBio() { } #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. @@ -18,24 +20,24 @@ private Bio() public string ParticipantId { get; private set; } public string BioJson { get; private set; } - - private Bio(Guid id, string participantId, string bioJson, string tenantId) + public BioStatus Status { get; private set; } = BioStatus.NotStarted; + private ParticipantBio(Guid id, string participantId, string bioJson, BioStatus status) { Id = id; ParticipantId = participantId; BioJson = bioJson; - TenantId = tenantId; + Status = status; AddDomainEvent(new BioCreatedDomainEvent(this)); } - public Bio UpdateJson(string json) + public ParticipantBio UpdateJson(string json) { //TODO: Add events for update, and logic to stop locked assessments being updated this.BioJson = json; return this; } - public Bio Submit() + public ParticipantBio Submit() { // this does nothing except raise the event. AddDomainEvent(new BioCreatedDomainEvent(this)); @@ -43,12 +45,15 @@ public Bio Submit() } - public static Bio Create(Guid id, string participantId, string bioJson, string tenantId) + public static ParticipantBio Create(Guid id, string participantId, string bioJson, BioStatus status) { - return new Bio(id, participantId, bioJson, tenantId); + return new ParticipantBio(id, participantId, bioJson, status); } - public string? TenantId { get; set; } - + public ParticipantBio UpdateStatus(BioStatus status) + { + this.Status = status; + return this; + } } } \ No newline at end of file diff --git a/src/Domain/Events/BioEvents.cs b/src/Domain/Events/BioEvents.cs index d347718a..2a97b2c5 100644 --- a/src/Domain/Events/BioEvents.cs +++ b/src/Domain/Events/BioEvents.cs @@ -3,6 +3,6 @@ namespace Cfo.Cats.Domain.Events; -public sealed class BioCreatedDomainEvent(Bio entity) - : CreatedDomainEvent(entity); +public sealed class BioCreatedDomainEvent(ParticipantBio entity) + : CreatedDomainEvent(entity); diff --git a/src/Infrastructure/Constants/Database/DatabaseConstants.cs b/src/Infrastructure/Constants/Database/DatabaseConstants.cs index 0e54a4f8..d79cf886 100644 --- a/src/Infrastructure/Constants/Database/DatabaseConstants.cs +++ b/src/Infrastructure/Constants/Database/DatabaseConstants.cs @@ -22,6 +22,7 @@ public static class Tables public const string LocationMapping = nameof(LocationMapping); public const string Participant = nameof(Participant); public const string Assessment = nameof(Assessment); + public const string Bio = nameof(Bio); public const string Note = nameof(Note); public const string Tenant = nameof(Tenant); public const string TenantDomain = nameof(TenantDomain); diff --git a/src/Infrastructure/Persistence/ApplicationDbContext.cs b/src/Infrastructure/Persistence/ApplicationDbContext.cs index 9dae66a3..7ebc7819 100644 --- a/src/Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/Infrastructure/Persistence/ApplicationDbContext.cs @@ -4,6 +4,7 @@ using Cfo.Cats.Domain.Entities.Assessments; using Cfo.Cats.Domain.Entities.Documents; using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Entities.Bios; using Cfo.Cats.Domain.Identity; using Cfo.Cats.Infrastructure.Persistence.Configurations.Enrolments; using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; @@ -40,7 +41,8 @@ public ApplicationDbContext(DbContextOptions options) public DbSet Risks => Set(); public DbSet ParticipantAssessments => Set(); - + + public DbSet ParticipantBios => Set(); public DbSet KeyValues => Set(); diff --git a/src/Infrastructure/Persistence/Configurations/Participants/BioEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Participants/BioEntityTypeConfiguration.cs new file mode 100644 index 00000000..bf41a465 --- /dev/null +++ b/src/Infrastructure/Persistence/Configurations/Participants/BioEntityTypeConfiguration.cs @@ -0,0 +1,35 @@ +using Cfo.Cats.Domain.Common.Enums; +using Cfo.Cats.Domain.Entities.Bios; +using Cfo.Cats.Infrastructure.Constants.Database; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Cfo.Cats.Infrastructure.Persistence.Configurations.Bios +{ + public class BioEntityTypeConfiguration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable( + DatabaseConstants.Tables.Bio, + DatabaseConstants.Schemas.Participant); + + builder.HasKey(t => t.Id); + + builder.HasOne() + .WithMany() + .HasForeignKey(pa => pa.ParticipantId) + .OnDelete(DeleteBehavior.Cascade); + + builder.Property(x => x.ParticipantId) + .HasMaxLength(DatabaseConstants.FieldLengths.ParticipantId); + builder.Property(x => x.Status) + .HasConversion( + x => x!.Value, + x => BioStatus.FromValue(x) + ); + + builder.Property(x => x.CreatedBy).HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + builder.Property(x => x.LastModifiedBy).HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + } + } +} \ No newline at end of file diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.Designer.cs new file mode 100644 index 00000000..cb178e4e --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.Designer.cs @@ -0,0 +1,2347 @@ +// +using System; +using Cfo.Cats.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240813132251_bio")] + partial class bio + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Property("Id") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LotNumber") + .HasColumnType("int"); + + b.Property("_tenantId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("_tenantId"); + + b.ToTable("Contract", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_contractId") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)") + .HasColumnName("ContractId"); + + b.Property("_genderProvisionId") + .HasColumnType("int") + .HasColumnName("GenderProvisionId"); + + b.Property("_locationTypeId") + .HasColumnType("int") + .HasColumnName("LocationTypeId"); + + b.Property("_parentLocationId") + .HasColumnType("int") + .HasColumnName("ParentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("_contractId"); + + b.HasIndex("_parentLocationId"); + + b.ToTable("Location", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.Property("Code") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CodeType") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("DeliveryRegion") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_locationId") + .HasColumnType("int") + .HasColumnName("LocationId"); + + b.HasKey("Code", "CodeType"); + + b.HasIndex("_locationId"); + + b.ToTable("LocationMapping", "Dms"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.Property("Id") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AssessmentJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Assessment", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BioJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Bio", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("URL") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Document", "Document"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("KeyValue", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("EscalationQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("PqaQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa1Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa2Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.Property("Id") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("ConsentStatus") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DateOfBirth") + .IsRequired() + .HasColumnType("date"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentLocationJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MiddleName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ReferralComments") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferralSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("_currentLocationId") + .HasColumnType("int") + .HasColumnName("CurrentLocationId"); + + b.Property("_enrolmentLocationId") + .HasColumnType("int") + .HasColumnName("EnrolmentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("_currentLocationId"); + + b.HasIndex("_enrolmentLocationId"); + + b.ToTable("Participant", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantEnrolmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("EnrolmentHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityRecommendations") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRecommendationsReceived") + .HasColumnType("datetime2"); + + b.Property("ActivityRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("AdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DeclarationSigned") + .HasColumnType("bit"); + + b.Property("IsRelevantToCommunity") + .HasColumnType("bit"); + + b.Property("IsRelevantToCustody") + .HasColumnType("bit"); + + b.Property("IsSubjectToSHPO") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LicenseConditions") + .HasColumnType("nvarchar(max)"); + + b.Property("LicenseEnd") + .HasColumnType("datetime2"); + + b.Property("MappaCategory") + .HasColumnType("int"); + + b.Property("MappaLevel") + .HasColumnType("int"); + + b.Property("NSDCase") + .HasColumnType("int"); + + b.Property("PSFRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("PSFRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("ReferredOn") + .HasColumnType("datetime2"); + + b.Property("ReferrerEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferrerName") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewReason") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCommunity") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCustody") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCommunity") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCustody") + .HasColumnType("int"); + + b.Property("RiskToOtherPrisonersInCommunity") + .HasColumnType("int"); + + b.Property("RiskToOtherPrisonersInCustody") + .HasColumnType("int"); + + b.Property("RiskToPublicInCommunity") + .HasColumnType("int"); + + b.Property("RiskToPublicInCustody") + .HasColumnType("int"); + + b.Property("RiskToSelfInCommunity") + .HasColumnType("int"); + + b.Property("RiskToSelfInCustody") + .HasColumnType("int"); + + b.Property("RiskToStaffInCommunity") + .HasColumnType("int"); + + b.Property("RiskToStaffInCustody") + .HasColumnType("int"); + + b.Property("SpecificRisk") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Risk", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(36)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Line1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line2") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line3") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Timeline", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleRank") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Role", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MemorableDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MemorablePlace") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasColumnType("text"); + + b.Property("ProviderId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RefreshToken") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("RequiresPasswordReset") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("SuperiorId") + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("User", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("RoleId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRole", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("UserToken", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogin", "Identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasColumnType("nvarchar(max)"); + + b.Property("Xml") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("LocationId", "TenantId"); + + b.HasIndex("TenantId"); + + b.ToTable("TenantLocation", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("_tenantId"); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("ContractId") + .HasColumnType("nvarchar(12)"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("ContractId"); + + b1.ToTable("Contract", "Configuration"); + + b1.WithOwner() + .HasForeignKey("ContractId"); + }); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Contract", "Contract") + .WithMany("Locations") + .HasForeignKey("_contractId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "ParentLocation") + .WithMany("ChildLocations") + .HasForeignKey("_parentLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("LocationId") + .HasColumnType("int"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("LocationId"); + + b1.ToTable("Location", "Configuration"); + + b1.WithOwner() + .HasForeignKey("LocationId"); + }); + + b.Navigation("Contract"); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("ParentLocation"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany("LocationMappings") + .HasForeignKey("_locationId"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.TenantDomain", "Domains", b1 => + { + b1.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b1.Property("Domain") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("TenantId", "Domain"); + + b1.ToTable("TenantDomain", "Configuration"); + + b1.WithOwner() + .HasForeignKey("TenantId"); + }); + + b.Navigation("Domains"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.PathwayScore", "Scores", b1 => + { + b1.Property("AssessmentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Pathway") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b1.Property("Score") + .HasColumnType("float"); + + b1.HasKey("AssessmentId", "Pathway"); + + b1.ToTable("AssessmentPathwayScore", "Participant"); + + b1.WithOwner() + .HasForeignKey("AssessmentId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentEscalationQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentEscalationQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("EscalationNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentEscalationQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentPqaQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentPqaQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("PqaQueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentPqaQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa1QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa1QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa1QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa1QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa2QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa2QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa2QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa2QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "CurrentLocation") + .WithMany() + .HasForeignKey("_currentLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Participant_Location"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "EnrolmentLocation") + .WithMany() + .HasForeignKey("_enrolmentLocationId") + .HasConstraintName("FK_Participant_EnrolmentLocation"); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Consent", "Consents", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("Consent", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("ConsentParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("ConsentId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("ConsentParticipantId", "ConsentId"); + + b2.ToTable("Consent", "Participant"); + + b2.WithOwner() + .HasForeignKey("ConsentParticipantId", "ConsentId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("Note", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.RightToWork", "RightToWorks", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("RightToWork", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId"); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("RightToWorkParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("RightToWorkId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("RightToWorkParticipantId", "RightToWorkId"); + + b2.ToTable("RightToWork", "Participant"); + + b2.WithOwner() + .HasForeignKey("RightToWorkParticipantId", "RightToWorkId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.Navigation("Consents"); + + b.Navigation("CurrentLocation"); + + b.Navigation("Editor"); + + b.Navigation("EnrolmentLocation"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("RightToWorks"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("UserId"); + + b1.ToTable("Note", "Identity"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("UserId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Notes"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Navigation("Locations"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Navigation("ChildLocations"); + + b.Navigation("LocationMappings"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.cs new file mode 100644 index 00000000..76e0cb74 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240813132251_bio.cs @@ -0,0 +1,55 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class bio : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Bio", + schema: "Participant", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ParticipantId = table.Column(type: "nvarchar(9)", maxLength: 9, nullable: false), + BioJson = table.Column(type: "nvarchar(max)", nullable: false), + Status = table.Column(type: "int", nullable: false), + Created = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Bio", x => x.Id); + table.ForeignKey( + name: "FK_Bio_Participant_ParticipantId", + column: x => x.ParticipantId, + principalSchema: "Participant", + principalTable: "Participant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Bio_ParticipantId", + schema: "Participant", + table: "Bio", + column: "ParticipantId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Bio", + schema: "Participant"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 1ddda9ea..9428eef4 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -275,6 +275,45 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("AuditTrail", "Audit"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BioJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Bio", "Participant"); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => { b.Property("Id") @@ -1414,6 +1453,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Owner"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => { b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") diff --git a/src/Server.UI/Pages/Bio/Bio.razor b/src/Server.UI/Pages/Bio/Bio.razor new file mode 100644 index 00000000..5f4ed0d1 --- /dev/null +++ b/src/Server.UI/Pages/Bio/Bio.razor @@ -0,0 +1,115 @@ +@using Cfo.Cats.Application.Features.Bios.Commands +@using Cfo.Cats.Application.Features.Bios.DTOs +@using Cfo.Cats.Application.Features.Bios.Queries +@using Cfo.Cats.Server.UI.Components.Stepper + +@inherits CatsComponentBase + +@page "/pages/participants/{Upci}/bio/{BioId:guid}" + +@if (_model != null) +{ +
+ + + + @*This top-level form is responsible for submission *@ + + @foreach (var pathway in _model.Pathways) + { + + } + + + + +} + +@code { + + private bool _showPrevious = false; + private ElementReference topOfPageElement; + + [Parameter] + public string Upci { get; set; } = string.Empty; + + [Parameter] + public Guid BioId { get; set; } = Guid.Empty; + + [Parameter] + public Cfo.Cats.Application.Features.Bios.DTOs.Bio? Model { get; set; } + + private Cfo.Cats.Application.Features.Bios.DTOs.Bio? _model; + + private CatsMudStepper Stepper { get; set; } = new(); + + private int TabsLength => Stepper.Steps.Count(); + + //These should be local to result step component in future. + private bool Processing { get; set; } + private bool SubmissionSuccess { get; set; } = false; + + protected override async Task OnInitializedAsync() + { + _model ??= Model; + + if (_model is null) + { + var response = await GetNewMediator().Send(new GetBio.Query() + { + BioId = BioId, + ParticipantId = Upci + }); + + if (response.Succeeded) + { + _model = response.Data!; + } + } + } + + private async Task OnStepChange(int step) + { + Processing = true; + await GetNewMediator().Send(new SaveBio.Command() + { + Bio = _model! + }); + + // Do not show the previous step on the first or last steps. + _showPrevious = Stepper.GetActiveIndex() > 0 && Stepper.IsResultStep == false; + await topOfPageElement.FocusAsync(); + if (step == Stepper.Steps.Count()) + { + await SubmitBio(); + } + + Processing = false; + + + } + + private async Task SubmitBio() + { + if (Stepper.IsAllStepsCompleted()) + { + var validator = new BioValidator(); + var result = await validator.ValidateAsync(_model!); + + if (result.IsValid) + { + Processing = true; + var response = await GetNewMediator().Send(new SaveBio.Command() + { + Bio = _model!, + Submit = true + }); + Processing = false; + SubmissionSuccess = response.Succeeded; + } + + } + } +} diff --git a/src/Server.UI/Pages/Bio/BioPathway.razor b/src/Server.UI/Pages/Bio/BioPathway.razor new file mode 100644 index 00000000..c7dd9ba3 --- /dev/null +++ b/src/Server.UI/Pages/Bio/BioPathway.razor @@ -0,0 +1,87 @@ +@using Cfo.Cats.Application.Features.Bios.DTOs +@using Cfo.Cats.Server.UI.Components.Stepper + + + + +@if (Model != null) +{ + + + + + + + + @foreach (var question in Model.Questions()) + { + + + + @if (validateCalled && question.IsValid() == false) + { + + You must select an option! + + } + + + + @if (question is SingleChoiceQuestion atq) + { + + @foreach (var item in atq.Options) + { + + } + + + } + + + } + + + + + +} + +@code { + + private MudForm form = new(); + + private bool validateCalled = false; + + + [Parameter] + public PathwayBase? Model { get; set; } + + private async Task Validate() + { + validateCalled = true; + BioPathwayValidator validator = new BioPathwayValidator(); + var result = await validator.ValidateAsync(Model!); + return result.IsValid; + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + await JS.InvokeVoidAsync("removeInlineStyle", ".two-columns"); + } + } +} diff --git a/src/Server.UI/Pages/Participants/Components/CaseBio.razor b/src/Server.UI/Pages/Participants/Components/CaseBio.razor new file mode 100644 index 00000000..dd523aa9 --- /dev/null +++ b/src/Server.UI/Pages/Participants/Components/CaseBio.razor @@ -0,0 +1,121 @@ +@using Cfo.Cats.Application.Features.Bios.DTOs +@using Cfo.Cats.Application.Features.Bios.Queries +@using Cfo.Cats.Domain.Common.Enums + +@inherits CatsComponentBase + + + +@if (_notFound) +{ + + No assessment found. + +} + + +@if (_model is not null) +{ + + + @foreach (var pathway in _model.Pathways) + { + + +
+ + @pathway.Title +
+
+ + + + @foreach (var question in pathway.Questions()) + { + + + + + + + @if (question is SingleChoiceQuestion atq) + { + + @foreach (var item in atq.Options) + { + + } + + + } + + + } + + +
+ } + +
+} + + + +@code { + + private Bio? _model; + private bool _notFound = false; + + [Parameter] + [EditorRequired] + public string ParticipantId { get; set; } = default!; + + protected override async Task OnInitializedAsync() + { + if (_model is not null) + { + return; + } + + try + { + var result = await GetNewMediator().Send(new GetBio.Query() + { + ParticipantId = ParticipantId + }); + + if (result.Succeeded) + { + _model = result.Data; + } + + } + finally + { + _notFound = _model is null; + } + + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await JS.InvokeVoidAsync("removeInlineStyle", ".two-columns"); + } + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Participants/Components/CaseSummary.razor b/src/Server.UI/Pages/Participants/Components/CaseSummary.razor index aa0717cd..6a48efa7 100644 --- a/src/Server.UI/Pages/Participants/Components/CaseSummary.razor +++ b/src/Server.UI/Pages/Participants/Components/CaseSummary.razor @@ -129,4 +129,76 @@ + + + + + Bio Information + + + + + @if (_bio is null) + { + No Bio has been created. + } + else + { +
+
+
+
+ Date Created +
+
+ @_bio.BioDate!.Value.ToString("dd/MM/yyyy") +
+
+
+
+ Created By +
+
+ @UserService.DataSource.First(u => u.Id == _bio.BioCreator).DisplayName +
+
+
+
+ Status +
+
+ @_bio.BioStatus!.Name.Humanize() +
+
+
+ + +
+ + } +
+ + + @if (CanBeginBio()) + { + + + + + } + @if (CanContinueBio()) + { + + + + } + @if (CanSkipBio()) + { + + + + } + +
+
\ No newline at end of file diff --git a/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs b/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs index 08f17ea0..4c485f67 100644 --- a/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs +++ b/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs @@ -1,5 +1,6 @@ using Cfo.Cats.Application.Common.Interfaces.Identity; using Cfo.Cats.Application.Features.Assessments.Commands; +using Cfo.Cats.Application.Features.Bios.Commands; using Cfo.Cats.Application.Features.Participants.Commands; using Cfo.Cats.Application.Features.Participants.DTOs; using Cfo.Cats.Domain.Common.Enums; @@ -10,7 +11,7 @@ namespace Cfo.Cats.Server.UI.Pages.Participants.Components; public partial class CaseSummary { private AssessmentSummaryDto? _latestAssessment; - + private BioSummaryDto? _bio; [Inject] private IUserService UserService { get; set; } = default!; @@ -24,6 +25,7 @@ protected override void OnParametersSet() ? null : ParticipantSummaryDto.Assessments.OrderByDescending(a => a.AssessmentDate) .First(); + _bio = ParticipantSummaryDto.BioSummary; } public async Task BeginAssessment() @@ -150,4 +152,98 @@ public async Task ExpandRiskInformation() var result = await dialog.Result; } + public async Task BeginBio() + { + var command = new BeginBio.Command + { + ParticipantId = ParticipantSummaryDto.Id + }; + var result = await GetNewMediator().Send(command); + + if (result.Succeeded) + { + Navigation.NavigateTo($"/pages/participants/{ParticipantSummaryDto.Id}/bio/{result.Data}"); + } + else + { + Snackbar.Add($"{result.ErrorMessage}", Severity.Error); + } + } + public async Task SkipBioForNow() + { + Result? resultBioCreated; + if (_bio is null) + { + var commandCreateBio = new BeginBio.Command + { + ParticipantId = ParticipantSummaryDto.Id + }; + resultBioCreated = await GetNewMediator().Send(commandCreateBio); + if (resultBioCreated.Succeeded) + { + var commandSkipBio = new SkipBioForNow.Command + { + BioId = resultBioCreated.Data + }; + var resultBioSkipped = await GetNewMediator().Send(commandSkipBio); + + if (resultBioSkipped.Succeeded) + { + Snackbar.Add($"Bio skipped for now, you can add bio information at any time by clicking Continue Bio button", Severity.Info, + config => { config.ShowTransitionDuration = 500; config.HideTransitionDuration = 500; config.ShowCloseIcon = false; }); + await Task.Delay(2000); + Navigation.Refresh(true); + } + else + { + Snackbar.Add($"{resultBioSkipped.ErrorMessage}", Severity.Error); + } + } + } + else + { + var commandSkipExistingBio = new SkipBioForNow.Command + { + BioId = _bio!.BioId!.Value + }; + var result = await GetNewMediator().Send(commandSkipExistingBio); + + if (result.Succeeded) + { + Snackbar.Add($"Bio skipped for now, you can add bio information at any time by clicking Continue Bio button", Severity.Info, + config => { config.ShowTransitionDuration = 500;config.HideTransitionDuration = 500;config.ShowCloseIcon = false;}); + await Task.Delay(2000); + Navigation.Refresh(true); + } + else + { + Snackbar.Add($"{result.ErrorMessage}", Severity.Error); + } + } + } + public void ContinueBio() + { + Navigation.NavigateTo($"/pages/participants/{ParticipantSummaryDto.Id}/bio/{_bio!.BioId}"); + } + + /// + /// If true, indicates we are creating Bio. + /// + private bool CanBeginBio() => _bio == null; + + /// + /// If true indicates we have a Bio that is continuable + /// (i.e. Id is not null or do we need a status (Complete or Incomplete etc.)) + /// + /// + private bool CanContinueBio() => _bio != null; + + /// + /// If true, indicates that either the bio doesn't exist OR No step is completed yet + /// + private bool CanSkipBio() + { + return _bio is null || _bio!.BioStatus == BioStatus.NotStarted; + } + } diff --git a/src/Server.UI/Pages/Participants/Participant.razor b/src/Server.UI/Pages/Participants/Participant.razor index 503f6df6..81d12372 100644 --- a/src/Server.UI/Pages/Participants/Participant.razor +++ b/src/Server.UI/Pages/Participants/Participant.razor @@ -90,6 +90,9 @@ + + + From 9bac8cfd4e26d61362f79387a829eb23643ed658 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Thu, 15 Aug 2024 09:28:47 +0100 Subject: [PATCH 5/8] Address review comments --- src/Application/Application.csproj | 6 -- .../Features/Bios/Caching/BiosCacheKey.cs | 30 --------- .../Features/Bios/Commands/BeginBio.cs | 17 ++--- .../Features/Bios/Commands/SaveBio.cs | 44 ++++++++----- .../Features/Bios/Commands/SkipBioForNow.cs | 53 ++++++++-------- src/Domain/Entities/Bios/ParticipantBio.cs | 11 ++-- .../Components/CaseSummary.razor.cs | 62 +++++-------------- 7 files changed, 84 insertions(+), 139 deletions(-) delete mode 100644 src/Application/Features/Bios/Caching/BiosCacheKey.cs diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj index 6570db4d..c6c4b8de 100644 --- a/src/Application/Application.csproj +++ b/src/Application/Application.csproj @@ -8,9 +8,6 @@ default true - - - @@ -30,7 +27,4 @@ - - - \ No newline at end of file diff --git a/src/Application/Features/Bios/Caching/BiosCacheKey.cs b/src/Application/Features/Bios/Caching/BiosCacheKey.cs deleted file mode 100644 index 416a4a5c..00000000 --- a/src/Application/Features/Bios/Caching/BiosCacheKey.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace Cfo.Cats.Application.Features.Bios.Caching; - -public class BiosCacheKey -{ - //note: we currently only have one but may need more in the future - public const string GetAllCacheKey = "all-bios"; - private static readonly TimeSpan RefreshInterval = TimeSpan.FromMinutes(60); - private static CancellationTokenSource tokenSource; - - static BiosCacheKey() - { - tokenSource = new CancellationTokenSource(RefreshInterval); - } - - public static MemoryCacheEntryOptions MemoryCacheEntryOptions => - new MemoryCacheEntryOptions() - .AddExpirationToken(new CancellationChangeToken(SharedExpiryTokenSource().Token)); - - public static CancellationTokenSource SharedExpiryTokenSource() - { - if (tokenSource.IsCancellationRequested) tokenSource = new CancellationTokenSource(RefreshInterval); - - return tokenSource; - } - - public static void Refresh() - { - SharedExpiryTokenSource().Cancel(); - } -} \ No newline at end of file diff --git a/src/Application/Features/Bios/Commands/BeginBio.cs b/src/Application/Features/Bios/Commands/BeginBio.cs index bba42857..eccbb519 100644 --- a/src/Application/Features/Bios/Commands/BeginBio.cs +++ b/src/Application/Features/Bios/Commands/BeginBio.cs @@ -1,5 +1,4 @@ using Cfo.Cats.Application.Common.Security; -using Cfo.Cats.Application.Features.Bios.Caching; using Cfo.Cats.Application.Features.Bios.DTOs; using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; @@ -7,6 +6,7 @@ using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Bios; using Newtonsoft.Json; +using Cfo.Cats.Application.Common.Validators; namespace Cfo.Cats.Application.Features.Bios.Commands; @@ -14,14 +14,9 @@ namespace Cfo.Cats.Application.Features.Bios.Commands; public static class BeginBio { [RequestAuthorize(Policy = SecurityPolicies.Enrol)] - public class Command : ICacheInvalidatorRequest> + public class Command : IRequest> { public required string ParticipantId { get; set; } - - //TODO: this could be done at a per participant level - public string[] CacheKeys => [ BiosCacheKey.GetAllCacheKey ]; - public CancellationTokenSource? SharedExpiryTokenSource - => BiosCacheKey.SharedExpiryTokenSource(); } public class Handler : IRequestHandler> @@ -36,7 +31,6 @@ public Handler(IUnitOfWork unitOfWork, ICurrentUserService currentUserService) public async Task> Handle(Command request, CancellationToken cancellationToken) { - await Task.CompletedTask; Bio bio = new Bio() { Id = Guid.NewGuid(), @@ -55,8 +49,7 @@ public async Task> Handle(Command request, CancellationToken cancel }); ParticipantBio bioSurvey = ParticipantBio.Create(bio.Id, request.ParticipantId, bioJson: json, BioStatus.NotStarted); - - _unitOfWork.DbContext.ParticipantBios.Add(bioSurvey); + await _unitOfWork.DbContext.ParticipantBios.AddAsync(bioSurvey); return Result.Success(bio.Id); } } @@ -67,7 +60,9 @@ public Validator() { RuleFor(c => c.ParticipantId) .MinimumLength(9) - .MaximumLength(9); + .MaximumLength(9) + .Matches(ValidationConstants.AlphaNumeric) + .WithMessage(string.Format(ValidationConstants.AlphaNumericMessage, nameof(Command.ParticipantId))); } } diff --git a/src/Application/Features/Bios/Commands/SaveBio.cs b/src/Application/Features/Bios/Commands/SaveBio.cs index 81fc0300..98007d99 100644 --- a/src/Application/Features/Bios/Commands/SaveBio.cs +++ b/src/Application/Features/Bios/Commands/SaveBio.cs @@ -1,5 +1,5 @@ using Cfo.Cats.Application.Common.Security; -using Cfo.Cats.Application.Features.Bios.Caching; +using Cfo.Cats.Application.Common.Validators; using Cfo.Cats.Application.Features.Bios.DTOs; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Bios; @@ -10,16 +10,11 @@ namespace Cfo.Cats.Application.Features.Bios.Commands; public static class SaveBio { [RequestAuthorize(Policy = SecurityPolicies.Enrol)] - public class Command : ICacheInvalidatorRequest + public class Command : IRequest { - //TODO: cache individually - public string[] CacheKeys => [ BiosCacheKey.GetAllCacheKey ]; - public CancellationTokenSource? SharedExpiryTokenSource => BiosCacheKey.SharedExpiryTokenSource(); - public bool Submit { get; set; } = false; public required Bio Bio { get; set; } - } public class Handler : IRequestHandler @@ -34,14 +29,14 @@ public Handler(IUnitOfWork unitOfWork) public async Task Handle(Command request, CancellationToken cancellationToken) { - await Task.CompletedTask; - Domain.Entities.Bios.ParticipantBio bio = _unitOfWork.DbContext.ParticipantBios.FirstOrDefault(r => r.Id == request.Bio.Id && r.ParticipantId == request.Bio.ParticipantId) - ?? throw new NotFoundException(nameof(Bio), new - { - request.Bio.Id, - request.Bio.ParticipantId - }); - + + ParticipantBio? bio = await _unitOfWork.DbContext.ParticipantBios + .FirstOrDefaultAsync(r => r.Id == request.Bio.Id && r.ParticipantId == request.Bio.ParticipantId, cancellationToken); + + if(bio == null) + { + return Result.Failure("Bio not found"); + } bio.UpdateJson(JsonConvert.SerializeObject(request.Bio, new JsonSerializerSettings { @@ -58,4 +53,23 @@ public async Task Handle(Command request, CancellationToken cancellation } } + public class Validator : AbstractValidator + { + public Validator() + { + RuleFor(x => x.Bio) + .NotNull(); + + RuleFor(x => x.Bio.ParticipantId) + .MinimumLength(9) + .MaximumLength(9) + .Matches(ValidationConstants.AlphaNumeric) + .WithMessage(string.Format(ValidationConstants.AlphaNumericMessage, nameof(Command.Bio.ParticipantId))); + + RuleFor(x => x.Bio.Id) + .NotEmpty(); + + } + } + } diff --git a/src/Application/Features/Bios/Commands/SkipBioForNow.cs b/src/Application/Features/Bios/Commands/SkipBioForNow.cs index 016bb80c..cd7991ed 100644 --- a/src/Application/Features/Bios/Commands/SkipBioForNow.cs +++ b/src/Application/Features/Bios/Commands/SkipBioForNow.cs @@ -1,49 +1,50 @@ using Cfo.Cats.Application.Common.Security; -using Cfo.Cats.Application.Features.Bios.Caching; -using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; -using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; -using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; +using Cfo.Cats.Application.Common.Validators; using Cfo.Cats.Application.Features.Bios.DTOs; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Bios; -using Newtonsoft.Json; +using DocumentFormat.OpenXml.Office.PowerPoint.Y2021.M06.Main; namespace Cfo.Cats.Application.Features.Bios.Commands; public static class SkipBioForNow { [RequestAuthorize(Policy = SecurityPolicies.Enrol)] - public class Command : ICacheInvalidatorRequest + public class Command : IRequest { - //TODO: cache individually - public string[] CacheKeys => [BiosCacheKey.GetAllCacheKey]; - public CancellationTokenSource? SharedExpiryTokenSource => BiosCacheKey.SharedExpiryTokenSource(); - - public required Guid BioId { get; set; } - + public string? ParticipantId { get; set;} } - public class Handler : IRequestHandler + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler { - private readonly IUnitOfWork _unitOfWork; - - public Handler(IUnitOfWork unitOfWork) + public async Task Handle(Command request, CancellationToken cancellationToken) { - _unitOfWork = unitOfWork; + ParticipantBio? bio = await unitOfWork.DbContext.ParticipantBios.FirstOrDefaultAsync(r => r.ParticipantId == request.ParticipantId); + + if (bio == null) + { + bio = ParticipantBio.Create(Guid.NewGuid(), request.ParticipantId!, string.Empty, BioStatus.NotStarted); + unitOfWork.DbContext.ParticipantBios.Add(bio); + } + bio.UpdateStatus(BioStatus.SkippedForNow); + return Result.Success(); } + } - public async Task Handle(Command request, CancellationToken cancellationToken) + public class Validator : AbstractValidator + { + private IUnitOfWork _unitOfWork; + + public Validator(IUnitOfWork unitOfWork) { - await Task.CompletedTask; - Domain.Entities.Bios.ParticipantBio bio = _unitOfWork.DbContext.ParticipantBios.FirstOrDefault(r => r.Id == request.BioId) - ?? throw new NotFoundException(nameof(Bio), new - { - request.BioId - }); + _unitOfWork = unitOfWork; - bio.UpdateStatus(BioStatus.SkippedForNow); - return Result.Success(); + RuleFor(x => x.ParticipantId) + .MinimumLength(9) + .MaximumLength(9) + .Matches(ValidationConstants.AlphaNumeric) + .WithMessage(string.Format(ValidationConstants.AlphaNumericMessage, nameof(Command.ParticipantId))); } } diff --git a/src/Domain/Entities/Bios/ParticipantBio.cs b/src/Domain/Entities/Bios/ParticipantBio.cs index ef9efac6..da832898 100644 --- a/src/Domain/Entities/Bios/ParticipantBio.cs +++ b/src/Domain/Entities/Bios/ParticipantBio.cs @@ -16,8 +16,6 @@ private ParticipantBio() } #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - - public string ParticipantId { get; private set; } public string BioJson { get; private set; } public BioStatus Status { get; private set; } = BioStatus.NotStarted; @@ -32,8 +30,7 @@ private ParticipantBio(Guid id, string participantId, string bioJson, BioStatus public ParticipantBio UpdateJson(string json) { - //TODO: Add events for update, and logic to stop locked assessments being updated - this.BioJson = json; + BioJson = json; return this; } @@ -44,7 +41,6 @@ public ParticipantBio Submit() return this; } - public static ParticipantBio Create(Guid id, string participantId, string bioJson, BioStatus status) { return new ParticipantBio(id, participantId, bioJson, status); @@ -52,7 +48,10 @@ public static ParticipantBio Create(Guid id, string participantId, string bioJso public ParticipantBio UpdateStatus(BioStatus status) { - this.Status = status; + if(Status != BioStatus.Complete) + { + Status = status; + } return this; } } diff --git a/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs b/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs index 4c485f67..2214a7a0 100644 --- a/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs +++ b/src/Server.UI/Pages/Participants/Components/CaseSummary.razor.cs @@ -6,6 +6,7 @@ using Cfo.Cats.Domain.Common.Enums; using Cfo.Cats.Server.UI.Pages.Risk; + namespace Cfo.Cats.Server.UI.Pages.Participants.Components; public partial class CaseSummary @@ -171,54 +172,25 @@ public async Task BeginBio() } public async Task SkipBioForNow() { - Result? resultBioCreated; - if (_bio is null) - { - var commandCreateBio = new BeginBio.Command - { - ParticipantId = ParticipantSummaryDto.Id - }; - resultBioCreated = await GetNewMediator().Send(commandCreateBio); - if (resultBioCreated.Succeeded) - { - var commandSkipBio = new SkipBioForNow.Command - { - BioId = resultBioCreated.Data - }; - var resultBioSkipped = await GetNewMediator().Send(commandSkipBio); - - if (resultBioSkipped.Succeeded) - { - Snackbar.Add($"Bio skipped for now, you can add bio information at any time by clicking Continue Bio button", Severity.Info, - config => { config.ShowTransitionDuration = 500; config.HideTransitionDuration = 500; config.ShowCloseIcon = false; }); - await Task.Delay(2000); - Navigation.Refresh(true); - } - else - { - Snackbar.Add($"{resultBioSkipped.ErrorMessage}", Severity.Error); - } - } + var command = new SkipBioForNow.Command() + { + ParticipantId = ParticipantSummaryDto.Id + }; + + var result = await GetNewMediator().Send(command); + if (result.Succeeded) + { + Snackbar.Add($"Bio skipped for now, you can add bio information at any time by clicking Continue Bio button", Severity.Info, + config => { + config.ShowTransitionDuration = 500; + config.HideTransitionDuration = 500; + config.ShowCloseIcon = false; + }); + Navigation.Refresh(true); } else { - var commandSkipExistingBio = new SkipBioForNow.Command - { - BioId = _bio!.BioId!.Value - }; - var result = await GetNewMediator().Send(commandSkipExistingBio); - - if (result.Succeeded) - { - Snackbar.Add($"Bio skipped for now, you can add bio information at any time by clicking Continue Bio button", Severity.Info, - config => { config.ShowTransitionDuration = 500;config.HideTransitionDuration = 500;config.ShowCloseIcon = false;}); - await Task.Delay(2000); - Navigation.Refresh(true); - } - else - { - Snackbar.Add($"{result.ErrorMessage}", Severity.Error); - } + Snackbar.Add($"Skipping bio failed", Severity.Error); } } public void ContinueBio() From 099e4f11ecfe9d60b6b00c3f3db7d71777ea8501 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Thu, 15 Aug 2024 09:53:52 +0100 Subject: [PATCH 6/8] Add bio when skipping --- .../Features/Bios/Commands/SkipBioForNow.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Application/Features/Bios/Commands/SkipBioForNow.cs b/src/Application/Features/Bios/Commands/SkipBioForNow.cs index cd7991ed..9f59b286 100644 --- a/src/Application/Features/Bios/Commands/SkipBioForNow.cs +++ b/src/Application/Features/Bios/Commands/SkipBioForNow.cs @@ -1,9 +1,13 @@ using Cfo.Cats.Application.Common.Security; using Cfo.Cats.Application.Common.Validators; using Cfo.Cats.Application.Features.Bios.DTOs; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.ChildhoodExperiences; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.Diversity; +using Cfo.Cats.Application.Features.Bios.DTOs.V1.Pathways.RecentExperiences; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Bios; using DocumentFormat.OpenXml.Office.PowerPoint.Y2021.M06.Main; +using Newtonsoft.Json; namespace Cfo.Cats.Application.Features.Bios.Commands; @@ -23,7 +27,24 @@ public async Task Handle(Command request, CancellationToken cancellation if (bio == null) { - bio = ParticipantBio.Create(Guid.NewGuid(), request.ParticipantId!, string.Empty, BioStatus.NotStarted); + Bio newBio = new Bio() + { + Id = Guid.NewGuid(), + ParticipantId = request.ParticipantId!, + Pathways = + [ + new ChildhoodExperiencesPathway(), + new DiversityPathway(), + new RecentExperiencesPathway(), + ] + }; + + string json = JsonConvert.SerializeObject(newBio, new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.Auto + }); + + bio = ParticipantBio.Create(Guid.NewGuid(), request.ParticipantId!, json, BioStatus.NotStarted); unitOfWork.DbContext.ParticipantBios.Add(bio); } From 8c981348b50876862827eeeb5cc6eb340253dd01 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Thu, 15 Aug 2024 10:25:04 +0100 Subject: [PATCH 7/8] Fix issue with missmatched ids --- src/Application/Features/Bios/Commands/SkipBioForNow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/Features/Bios/Commands/SkipBioForNow.cs b/src/Application/Features/Bios/Commands/SkipBioForNow.cs index 9f59b286..8a0d3084 100644 --- a/src/Application/Features/Bios/Commands/SkipBioForNow.cs +++ b/src/Application/Features/Bios/Commands/SkipBioForNow.cs @@ -44,7 +44,7 @@ public async Task Handle(Command request, CancellationToken cancellation TypeNameHandling = TypeNameHandling.Auto }); - bio = ParticipantBio.Create(Guid.NewGuid(), request.ParticipantId!, json, BioStatus.NotStarted); + bio = ParticipantBio.Create(newBio.Id, request.ParticipantId!, json, BioStatus.NotStarted); unitOfWork.DbContext.ParticipantBios.Add(bio); } From 489ce3d74d5cae38341ae6f02d181d7eb134250f Mon Sep 17 00:00:00 2001 From: VS Date: Thu, 15 Aug 2024 11:26:30 +0100 Subject: [PATCH 8/8] removed status from json --- src/Application/Features/Bios/DTOs/Bio.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Application/Features/Bios/DTOs/Bio.cs b/src/Application/Features/Bios/DTOs/Bio.cs index b6a6107e..6fb362f1 100644 --- a/src/Application/Features/Bios/DTOs/Bio.cs +++ b/src/Application/Features/Bios/DTOs/Bio.cs @@ -4,6 +4,5 @@ public class Bio { public required Guid Id { get; set; } public required string ParticipantId { get; set; } - public BioStatus Status { get; set; } = BioStatus.NotStarted; public required PathwayBase[] Pathways { get; set; } } \ No newline at end of file