Esempio n. 1
0
        public Response <PatientMedicalAidDependancyDto> DeleteCheck(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            Response <PatientMedicalAidDependancyDto> response = new Response <PatientMedicalAidDependancyDto>();

            if (patientMedicalAidDependancyDto == null ||
                patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId == null ||
                patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId.Value == int.MinValue)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "The entry you trying to delete does not exist."
                });
                return(response);
            }

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                PatientMedicalAidDependancy patientMedicalAidDependancy = unitOfWork.PatientMedicalAidDependancyRepository.GetByID(p => p.PatientMedicalAidDependanciesId == patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId.Value);

                if (patientMedicalAidDependancy == null)
                {
                    response.HasErrors = true;
                    response.FieldErrors.Add(new FieldError()
                    {
                        ErrorMessage = "The entry you trying to delete does not exist."
                    });
                    return(response);
                }
            }

            return(response);
        }
Esempio n. 2
0
        public Response <PatientMedicalAidDependancyDto> SaveCheck(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            Response <PatientMedicalAidDependancyDto> response = new Response <PatientMedicalAidDependancyDto>();

            if (patientMedicalAidDependancyDto == null)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "The entry you trying to save does not exist."
                });

                return(response);
            }

            switch (patientMedicalAidDependancyDto.CrudOperation)
            {
            case CrudOperations.Create:
                return(CreateCheck(patientMedicalAidDependancyDto));

            case CrudOperations.Update:
                return(UpdateCheck(patientMedicalAidDependancyDto));

            case CrudOperations.Delete:
                return(DeleteCheck(patientMedicalAidDependancyDto));

            default:
                throw new ArgumentException("Invalid crud operation.");
            }
        }
Esempio n. 3
0
        public void UpdateNullPatientMedicalAidDependancy()
        {
            PatientMedicalAidDependancyDto            patientMedicalAidDependancyDto = null;
            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
Esempio n. 4
0
        public void UpdateEmptyPatientMedicalAidDependancy()
        {
            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto()
            {
                CrudOperation = CrudOperations.Update
            };
            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
        private void DeletePatientMedicalAidDependancy(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    unitOfWork.PatientMedicalAidDependancyRepository.Delete(patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId.Value);
                    unitOfWork.Save();
                }

                scope.Complete();
            }
        }
Esempio n. 6
0
        public void CreateInvalidPatientMedicalAidDependancy()
        {
            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto()
            {
                PatientId     = 1,
                FirstFullName = "Makhosazana",
                CrudOperation = CrudOperations.Create
            };

            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
Esempio n. 7
0
        public void CreateValidPatientPatientMedicalAidDependancyAsPrincipalMember()
        {
            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto()
            {
                CrudOperation  = CrudOperations.Create,
                PrincipalInd   = true,
                PatientId      = 2,
                FirstFullName  = "Siyabonga",
                LastName       = "Molefe",
                BirthDate      = new DateTime(1988, 4, 21),
                MedicalAidCode = "123543968",
                Relationship   = "Brother",
                Title          = "Mr"
            };

            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsFalse(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count == 0);
            Assert.IsNotNull(response.Model);
        }
Esempio n. 8
0
        public void UpdateNonExistingPatientMedicalAidDependancy()
        {
            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto()
            {
                PatientId = 1,
                PatientMedicalAidDependanciesId = -5,
                CrudOperation  = CrudOperations.Update,
                FirstFullName  = "Makhosazana",
                LastName       = "Molefe",
                BirthDate      = new DateTime(1988, 4, 21),
                MedicalAidCode = "123543968",
                Relationship   = "Brother",
                Title          = "Mr"
            };

            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
Esempio n. 9
0
        public void CreateWithExistingPrincipal()
        {
            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto()
            {
                CrudOperation  = CrudOperations.Create,
                PrincipalInd   = true,
                PatientId      = 1,
                FirstFullName  = "Existing FirstName",
                LastName       = "Molefe",
                BirthDate      = new DateTime(1981, 6, 27),
                MedicalAidCode = "567343968",
                Relationship   = "Mother",
                Title          = "Miss"
            };

            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsTrue(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count > 0);
            Assert.IsNull(response.Model);
        }
        private PatientMedicalAidDependancyDto CreatePatientMedicalAidDependancy(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            PatientMedicalAidDependancyDto addedPatientMedicalAidDependancyDto = null;
            PatientMedicalAidDependancy    patientMedicalAidDependancy         = new PatientMedicalAidDependancy();

            _PatientMedicalAidDependancyMapper.MapToPatientMedicalAidDependancy(patientMedicalAidDependancy, patientMedicalAidDependancyDto);

            using (TransactionScope scope = new TransactionScope())
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    unitOfWork.PatientMedicalAidDependancyRepository.Insert(patientMedicalAidDependancy);
                    unitOfWork.Save();

                    addedPatientMedicalAidDependancyDto = _PatientMedicalAidDependancyMapper.MapToPatientMedicalAidDependancyDto(unitOfWork.PatientMedicalAidDependancyRepository.GetByID(p => p.PatientMedicalAidDependanciesId == patientMedicalAidDependancy.PatientMedicalAidDependanciesId));
                }

                scope.Complete();
            }

            return(addedPatientMedicalAidDependancyDto);
        }
        public PatientMedicalAidDependancyDto MapToPatientMedicalAidDependancyDto(PatientMedicalAidDependancy patientMedicalAidDependancy)
        {
            if (patientMedicalAidDependancy == null)
            {
                return(null);
            }

            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto();

            patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId = patientMedicalAidDependancy.PatientMedicalAidDependanciesId;
            patientMedicalAidDependancyDto.PatientId      = patientMedicalAidDependancy.PatientId;
            patientMedicalAidDependancyDto.FirstFullName  = patientMedicalAidDependancy.FirstFullName;
            patientMedicalAidDependancyDto.LastName       = patientMedicalAidDependancy.LastName;
            patientMedicalAidDependancyDto.MedicalAidCode = patientMedicalAidDependancy.MedicalAidCode;
            patientMedicalAidDependancyDto.BirthDate      = patientMedicalAidDependancy.BirthDate;
            patientMedicalAidDependancyDto.Relationship   = patientMedicalAidDependancy.Relationship;
            patientMedicalAidDependancyDto.PrincipalInd   = patientMedicalAidDependancy.PrincipalInd;
            patientMedicalAidDependancyDto.Title          = patientMedicalAidDependancy.Title;
            patientMedicalAidDependancyDto.CrudOperation  = CrudOperations.Update;

            return(patientMedicalAidDependancyDto);
        }
Esempio n. 12
0
        public void UpdateValidPatientPatientMedicalAidDependancy()
        {
            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto()
            {
                PatientMedicalAidDependanciesId = 13,
                CrudOperation  = CrudOperations.Update,
                PrincipalInd   = false,
                PatientId      = 1,
                FirstFullName  = "TestUpdateFirstName",
                LastName       = "UpdateLastName",
                BirthDate      = new DateTime(1986, 6, 20),
                MedicalAidCode = "123543968",
                Relationship   = "Sister",
                Title          = "Miss"
            };

            Response <PatientMedicalAidDependancyDto> response = _PhekoServiceClient.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto);

            Assert.IsFalse(response.HasErrors);
            Assert.IsTrue(response.FieldErrors.Count == 0);
            Assert.IsNotNull(response.Model);
        }
Esempio n. 13
0
        public PatientMedicalAidDependancyDto MapToPatientMedicalAidDependancyDto(PatientMedicalAidDependancyViewModel patientMedicalAidDependancyViewModel)
        {
            if (patientMedicalAidDependancyViewModel == null)
            {
                return(null);
            }

            PatientMedicalAidDependancyDto patientMedicalAidDependancyDto = new PatientMedicalAidDependancyDto();

            CrudOperationsMapper crudOperationsMapper = new CrudOperationsMapper();

            patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId = patientMedicalAidDependancyViewModel.PatientMedicalAidDependanciesId;
            patientMedicalAidDependancyDto.PatientId      = patientMedicalAidDependancyViewModel.PatientId;
            patientMedicalAidDependancyDto.Title          = patientMedicalAidDependancyViewModel.Title;
            patientMedicalAidDependancyDto.FirstFullName  = patientMedicalAidDependancyViewModel.FirstFullName;
            patientMedicalAidDependancyDto.LastName       = patientMedicalAidDependancyViewModel.LastName;
            patientMedicalAidDependancyDto.MedicalAidCode = patientMedicalAidDependancyViewModel.MedicalAidCode;
            patientMedicalAidDependancyDto.BirthDate      = Converter.StringToDate(patientMedicalAidDependancyViewModel.BirthDate);
            patientMedicalAidDependancyDto.Relationship   = patientMedicalAidDependancyViewModel.Relationship;
            patientMedicalAidDependancyDto.PrincipalInd   = patientMedicalAidDependancyViewModel.PrincipalInd;
            patientMedicalAidDependancyDto.CrudOperation  = crudOperationsMapper.MapToCrudOperations(patientMedicalAidDependancyViewModel.CrudOperation);

            return(patientMedicalAidDependancyDto);
        }
        public Response <PatientMedicalAidDependancyDto> SavePatientMedicalAidDependancy(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            Response <PatientMedicalAidDependancyDto> response = _PatientMedicalAidDependancyBusinessRules.SaveCheck(patientMedicalAidDependancyDto);

            if (response.HasErrors)
            {
                return(response);
            }

            switch (patientMedicalAidDependancyDto.CrudOperation)
            {
            case CrudOperations.Create:
                response.Model = CreatePatientMedicalAidDependancy(patientMedicalAidDependancyDto);
                break;

            case CrudOperations.Update:
                response.Model = UpdatePatientMedicalAidDependancy(patientMedicalAidDependancyDto);
                break;

            case CrudOperations.Delete:
                DeletePatientMedicalAidDependancy(patientMedicalAidDependancyDto);
                break;

            default:
                throw new ArgumentException("Invalid crud operation.");
            }

            return(response);
        }
Esempio n. 15
0
        public Response <PatientMedicalAidDependancyDto> CreateCheck(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            Response <PatientMedicalAidDependancyDto> response = new Response <PatientMedicalAidDependancyDto>();

            if (patientMedicalAidDependancyDto == null)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "The entry you trying to create does not exist."
                });
                return(response);
            }

            if (string.IsNullOrEmpty(patientMedicalAidDependancyDto.FirstFullName))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "FirstFullName", ErrorMessage = "First name is requeired."
                });
            }

            if (string.IsNullOrEmpty(patientMedicalAidDependancyDto.LastName))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "LastName", ErrorMessage = "Last name is required."
                });
            }

            if (string.IsNullOrEmpty(patientMedicalAidDependancyDto.MedicalAidCode))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "MedicalAidCode", ErrorMessage = "Medical Aid Code is required."
                });
            }

            if (string.IsNullOrEmpty(patientMedicalAidDependancyDto.Relationship))
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    FieldName = "Relationship", ErrorMessage = "Relationship is required."
                });
            }

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                Patient patient = unitOfWork.PatientRepository.GetByID(p => p.PatientId == patientMedicalAidDependancyDto.PatientId);

                if (patient == null)
                {
                    response.HasErrors = true;
                    response.FieldErrors.Add(new FieldError()
                    {
                        ErrorMessage = "There is no corresponding patient for the medical aid dependancy."
                    });
                    return(response);
                }

                if (patientMedicalAidDependancyDto.PrincipalInd && patient.PrincipalMemberInd.Value)
                {
                    response.HasErrors = true;
                    response.FieldErrors.Add(new FieldError()
                    {
                        FieldName = "PrincipalInd", ErrorMessage = "The patient is already a principal member."
                    });
                }

                if (patientMedicalAidDependancyDto.PrincipalInd &&
                    unitOfWork.PatientMedicalAidDependancyRepository.GetEntities(p => p.PatientId == patientMedicalAidDependancyDto.PatientId && p.PrincipalInd).Count() > 0)
                {
                    response.HasErrors = true;
                    response.FieldErrors.Add(new FieldError()
                    {
                        FieldName = "PrincipalInd", ErrorMessage = "There is already the medical aid member who is a principal member."
                    });
                }
            }

            return(response);
        }
Esempio n. 16
0
 public Response <PatientMedicalAidDependancyDto> SavePatientMedicalAidDependancy(PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
 {
     return(_IPatientMedicalAidDependancyManager.SavePatientMedicalAidDependancy(patientMedicalAidDependancyDto));
 }
        public void MapToPatientMedicalAidDependancy(PatientMedicalAidDependancy patientMedicalAidDependancy, PatientMedicalAidDependancyDto patientMedicalAidDependancyDto)
        {
            if (patientMedicalAidDependancyDto == null)
            {
                return;
            }

            if (patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId != null)
            {
                patientMedicalAidDependancy.PatientMedicalAidDependanciesId = patientMedicalAidDependancyDto.PatientMedicalAidDependanciesId.Value;
            }

            patientMedicalAidDependancy.PatientId      = patientMedicalAidDependancyDto.PatientId;
            patientMedicalAidDependancy.FirstFullName  = patientMedicalAidDependancyDto.FirstFullName;
            patientMedicalAidDependancy.LastName       = patientMedicalAidDependancyDto.LastName;
            patientMedicalAidDependancy.MedicalAidCode = patientMedicalAidDependancyDto.MedicalAidCode;
            patientMedicalAidDependancy.BirthDate      = patientMedicalAidDependancyDto.BirthDate;
            patientMedicalAidDependancy.Relationship   = patientMedicalAidDependancyDto.Relationship;
            patientMedicalAidDependancy.PrincipalInd   = patientMedicalAidDependancyDto.PrincipalInd;
            patientMedicalAidDependancy.Title          = patientMedicalAidDependancyDto.Title;
        }