Пример #1
0
        public PatientViewModelValidator(IFutureDateValidator futureDateValidator, INhsValidator nhsValidator, IClinicalSystemIdDescriptionProvider clinicalSystemIdDescriptionProvider)
        {
            RuleFor(model => model.ClinicalSystemId)
            .NotEmpty()
            .WithMessage(string.Format("{0} is mandatory", clinicalSystemIdDescriptionProvider.GetDescription()))
            .Length(1, 50)
            .WithMessage(string.Format("{0} must be less than 50 characters", clinicalSystemIdDescriptionProvider.GetDescription()));

            RuleFor(model => model.FirstName)
            .NotEmpty()
            .WithMessage("First name is mandatory")
            .Length(1, 50)
            .WithMessage("First name must be less than 50 characters");

            RuleFor(model => model.LastName)
            .NotEmpty()
            .WithMessage("Last name is mandatory")
            .Length(1, 50)
            .WithMessage("Last name must be less than 50 characters");;

            RuleFor(model => model.DateOfBirthViewModel)
            .NotNull()
            .SetValidator(new DateOfBirthViewModelValidator(futureDateValidator));

            RuleFor(model => model.GenderId)
            .NotEmpty()
            .WithMessage("Gender is mandatory");

            RuleFor(model => model.NhsNumber)
            .Must(nhsValidator.Valid)
            .WithMessage("NHS number is not valid");
        }
Пример #2
0
        public void EditPatientViewModelValidator_GivenDuplicateClinicalSystemId_ErrorMessageShouldContainClinicalSystemIdDescription()
        {
            const string clinicalsystemid = "clinicalSystemId";

            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(clinicalsystemid);
            A.CallTo(() => _clinicalIdValidator.Unique(A <string> ._)).Returns(false);

            var model = new EditPatientViewModel()
            {
                ClinicalSystemId        = "clinicalsystemid1",
                CurrentClinicalSystemId = "clinicalsystemid",
                DateOfBirthViewModel    = DateOfBirthViewModel(),
                FirstName        = "David",
                LastName         = "Miller",
                GenderId         = 1,
                NhsNumber        = 4567899881,
                CurrentNhsNumber = 4567899881
            };

            var result = ValidationResult(model);

            result.Errors.Should()
            .Contain(x =>
                     x.PropertyName == "ClinicalSystemId" &&
                     x.ErrorMessage == string.Format("A person with this {0} already exists", clinicalsystemid));
        }
Пример #3
0
        public virtual ActionResult Index()
        {
            var clinicalSystemIdDescription = _clinicalSystemIdDescriptionProvider.GetDescription();
            var viewModel = _clinicalSystemViewModelBuilder.BuildClinicalSystemText(clinicalSystemIdDescription);

            return(View(viewModel));
        }
        public void Setup()
        {
            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();

            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(Clinicalsystemid);

            _patientSearchViewModelValidator = new PatientSearchViewModelValidator(_clinicalSystemIdDescriptionProvider);
        }
Пример #5
0
        public void Setup()
        {
            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();
            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(Description);

            _customModelMetadataProvider = new CustomModelMetadataProvider(_clinicalSystemIdDescriptionProvider);

            ModelMetadataProviders.Current = _customModelMetadataProvider;
        }
        public void Setup()
        {
            _futureDateValidator = A.Fake <IFutureDateValidator>();
            _nhsValidator        = A.Fake <INhsValidator>();
            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();

            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(Clinicalsystemid);
            A.CallTo(() => _futureDateValidator.Valid(A <DateTime?> ._)).Returns(true);
            A.CallTo(() => _nhsValidator.Valid(A <decimal?> ._)).Returns(true);
        }
Пример #7
0
        public void Setup()
        {
            _dateTimeProvider = A.Fake <IDateTimeProvider>();
            _questionAnswerViewModelBuilder = A.Fake <IQuestionAnswerViewModelBuilder>();
            _queryDispatcher = A.Fake <IQueryDispatcher>();
            _pdfHelper       = A.Fake <IPdfHelper>();
            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();

            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(ClinicalSystemId);

            _pdfGenerator = new GeneratePdf(_dateTimeProvider, _questionAnswerViewModelBuilder, _queryDispatcher, _pdfHelper, _clinicalSystemIdDescriptionProvider);
        }
Пример #8
0
        public void Setup()
        {
            Mapper.AddProfile(new AutomapperMappingProfile());

            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();
            _userRoleProvider   = A.Fake <IUserRoleProvider>();
            _dateOfBirthBuilder = A.Fake <IDateOfBirthBuilder>();

            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(Description);
            A.CallTo(() => _dateOfBirthBuilder.BuildDateOfBirthViewModel(null)).Returns(new DateOfBirthViewModel());

            _builder = new PatientViewModelBuilder(_clinicalSystemIdDescriptionProvider, _userRoleProvider, _dateOfBirthBuilder);
        }
Пример #9
0
        public CreatePatientViewModelValidator(IFutureDateValidator futureDateValidator,
                                               IClinicalIdValidator clinicalIdValidator,
                                               INhsValidator nhsValidator,
                                               IClinicalSystemIdDescriptionProvider clinicalSystemIdDescriptionProvider)
            : base(futureDateValidator, nhsValidator, clinicalSystemIdDescriptionProvider)
        {
            RuleFor(model => model.NhsNumber)
            .Must(nhsValidator.Unique)
            .WithMessage("A person with this NHS Number already exists");

            RuleFor(model => model.ClinicalSystemId)
            .Must(clinicalIdValidator.Unique)
            .WithMessage(string.Format("A person with this {0} already exists", clinicalSystemIdDescriptionProvider.GetDescription()));
        }
Пример #10
0
        public void Setup()
        {
            Mapper.AddProfile(new AutomapperMappingProfile());

            _dateTimeProvider = A.Fake <IDateTimeProvider>();
            A.CallTo(() => _dateTimeProvider.Now).Returns(new DateTime(2015, 1, 1));

            _clinicalSystemIdDescriptionProvider = A.Fake <IClinicalSystemIdDescriptionProvider>();
            A.CallTo(() => _clinicalSystemIdDescriptionProvider.GetDescription()).Returns(Description);

            _userPrincipalProvider = A.Fake <IUserPrincipalProvider>();
            _userRoleProvider      = A.Fake <IUserRoleProvider>();

            _builder = new AssessmentViewModelBuilder(_dateTimeProvider, _clinicalSystemIdDescriptionProvider, _userPrincipalProvider, _userRoleProvider);
        }
Пример #11
0
        public PatientSearchViewModel BuildPatientSearchViewModel(Patients patients)
        {
            if (patients == null)
            {
                throw new ArgumentNullException("patients");
            }

            var viewModel = new PatientSearchViewModel
            {
                Items = patients.Items.Select(Mapper.Map <Patient, PatientViewModel>),
                ClinicalIdDescription = _clinicalSystemIdDescriptionProvider.GetDescription(),
                CanEdit = _userRoleProvider.CurrentUserInAdministratorRole()
            };

            return(viewModel);
        }
Пример #12
0
        protected override ModelMetadata CreateMetadata(IEnumerable <Attribute> attributes,
                                                        Type containerType,
                                                        Func <object> modelAccessor,
                                                        Type modelType,
                                                        string propertyName)
        {
            var data = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName);

            var description = attributes.SingleOrDefault(a => a is ClinicalSystemIdDisplayAttribute);

            if (description != null)
            {
                data.DisplayName = _clinicalSystemIdDescriptionProvider.GetDescription();
            }

            return(data);
        }
Пример #13
0
        private void AddCommonInformation(Assessment assessment)
        {
            var datePart = new DateTime();

            if (assessment.DateAssessmentStarted != null)
            {
                var date1 = (DateTime)assessment.DateAssessmentStarted;
                datePart = date1.Date;
            }
            _pdfHelper.AddTitle(ApplicationStringConstants.McaSubject, false, true);
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.Name);
            _pdfHelper.AppendText(" " + assessment.Patient.FirstName + " " + assessment.Patient.LastName);
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.Dob);
            _pdfHelper.AppendText(" " + assessment.Patient.DateOfBirth.ToLongDateString());
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.NhsNumber);
            _pdfHelper.AppendText(" " + assessment.Patient.NhsNumber);
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.AssessmentStartDateText);
            _pdfHelper.AppendText(" " + datePart.ToString("D"));
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(string.Format("{0}:", _clinicalSystemIdDescriptionProvider.GetDescription()));
            _pdfHelper.AppendText(" " + assessment.Patient.ClinicalSystemId);
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.ClinicianNameText);
            _pdfHelper.AppendText(" " + assessment.AssessorName);
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.RoleText);
            _pdfHelper.AppendText(" " + assessment.Role.Description);
            _pdfHelper.AddLine();
            if ((assessment.RoleId != (int)RoleIdEnum.DecisionMaker) && !string.IsNullOrWhiteSpace(assessment.DecisionMaker))
            {
                _pdfHelper.AddTitle(ApplicationStringConstants.DecisionMakerText);
                _pdfHelper.AppendText(" " + assessment.DecisionMaker);
                _pdfHelper.AddLine();
            }
            _pdfHelper.AddTitle(ApplicationStringConstants.Stage1Text, false);
            _pdfHelper.AddLine();
            _pdfHelper.AddTitle(ApplicationStringConstants.DecisionToBeMade, false);
            _pdfHelper.AddLine();
            _pdfHelper.WriteText(assessment.Stage1DecisionToBeMade);
            _pdfHelper.AddLine();
        }
Пример #14
0
        public AssessmentListViewModel BuildAssessmentListViewModel(Guid patientId, Assessments assessments)
        {
            if (assessments == null)
            {
                throw new ArgumentNullException("assessments");
            }
            if (patientId == Guid.Empty)
            {
                throw new ArgumentException("patientId");
            }

            var assessmentViewModels = new List <AssessmentViewModel>();

            foreach (var assessment in assessments.Items)
            {
                var assessmentViewModel = Mapper.DynamicMap <Assessment, AssessmentViewModel>(assessment);
                var statusViewModel     = Mapper.DynamicMap <Status, StatusViewModel>(assessment.Status);

                assessmentViewModel.Status = statusViewModel;

                assessmentViewModel.Stage1DecisionToBeMade = assessmentViewModel.Stage1DecisionToBeMade.Length > 50
                    ? assessmentViewModel.Stage1DecisionToBeMade.Substring(0, 50)
                    : assessmentViewModel.Stage1DecisionToBeMade;

                SetCanViewPdfProperty(assessment, assessmentViewModel);

                SetCanRestartProperty(assessment, assessmentViewModel);

                SetCanReviseProperty(assessment, assessmentViewModel);

                assessmentViewModels.Add(assessmentViewModel);
            }

            var viewModel = new AssessmentListViewModel
            {
                Items                 = assessmentViewModels,
                PatientId             = patientId,
                ClinicalIdDescription = _clinicalSystemIdDescriptionProvider.GetDescription()
            };

            return(viewModel);
        }
 public PatientSearchViewModelValidator(IClinicalSystemIdDescriptionProvider clinicalSystemIdDescriptionProvider)
 {
     RuleFor(model => model.ClinicalSystemId)
     .NotEmpty()
     .WithMessage(string.Format("{0} is mandatory", clinicalSystemIdDescriptionProvider.GetDescription()));
 }