public Result <PatientClinicalExaminationDto> GetPatientClinicalExaminations(int patientConsultationId)
        {
            Result <PatientClinicalExaminationDto> response = new Result <PatientClinicalExaminationDto>();

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                IEnumerable <ClinicalExamination>        ClinicalExaminations        = unitOfWork.ClinicalExaminationRepository.GetEntities();
                IEnumerable <PatientClinicalExamination> patientClinicalExaminations = unitOfWork.PatientClinicalExaminationRepository.GetEntities(item => item.PatientConsultationId == patientConsultationId, p => p.OrderBy(o => o.ClinicalExamination.SortKey));

                foreach (ClinicalExamination ClinicalExamination in ClinicalExaminations)
                {
                    ClinicalExaminationDto     ClinicalExaminationDto     = _ClinicalExaminationMapper.MapToClinicalExaminationDto(ClinicalExamination);
                    PatientClinicalExamination patientClinicalExamination = patientClinicalExaminations.Where(item => item.ClinicalExaminationId == ClinicalExamination.ClinicalExaminationId).FirstOrDefault();

                    PatientClinicalExaminationDto patientClinicalExaminationDto = new PatientClinicalExaminationDto()
                    {
                        PatientClinicalExaminationId = patientClinicalExamination == null ? default(int?) : patientClinicalExamination.PatientClinicalExaminationId,
                        PatientConsultationId        = patientConsultationId,
                        ClinicalExamination          = ClinicalExaminationDto,
                        Value = patientClinicalExamination == null ? null : patientClinicalExamination.Value
                    };

                    response.Models.Add(patientClinicalExaminationDto);
                }
            }

            return(response);
        }
Exemple #2
0
        public PatientClinicalExaminationDto MapToPatientClinicalExaminationDto(PatientClinicalExamination patientClinicalExamination)
        {
            if (patientClinicalExamination == null)
            {
                return(null);
            }

            PatientClinicalExaminationDto patientClinicalExaminationDto = new PatientClinicalExaminationDto();

            patientClinicalExaminationDto.PatientClinicalExaminationId = patientClinicalExamination.PatientClinicalExaminationId;
            patientClinicalExaminationDto.PatientConsultationId        = patientClinicalExamination.PatientConsultationId;
            patientClinicalExaminationDto.ClinicalExamination          = _ClinicalExaminationMapper.MapToClinicalExaminationDto(patientClinicalExamination.ClinicalExamination);
            patientClinicalExaminationDto.Value = patientClinicalExamination.Value;

            return(patientClinicalExaminationDto);
        }
Exemple #3
0
        public PatientClinicalExaminationDto MapToPatientClinicalExaminationDto(PatientClinicalExaminationViewModel patientClinicalExaminationViewModel)
        {
            if (patientClinicalExaminationViewModel == null)
            {
                return(null);
            }

            PatientClinicalExaminationDto patientClinicalExaminationDto = new PatientClinicalExaminationDto();

            patientClinicalExaminationDto.PatientClinicalExaminationId = patientClinicalExaminationViewModel.PatientClinicalExaminationId;
            patientClinicalExaminationDto.PatientConsultationId        = patientClinicalExaminationViewModel.PatientConsultationId;
            patientClinicalExaminationDto.ClinicalExamination          = new ClinicalExaminationDto()
            {
                ClinicalExaminationId = patientClinicalExaminationViewModel.ClinicalExamination_Id,
                Name = patientClinicalExaminationViewModel.ClinicalExamination_Name
            };
            patientClinicalExaminationDto.Value = patientClinicalExaminationViewModel.ClinicalExaminationValue;

            return(patientClinicalExaminationDto);
        }
        public Response <PatientClinicalExaminationDto> SaveCheck(PatientClinicalExaminationDto patientClinicalExaminationDto)
        {
            Response <PatientClinicalExaminationDto> response = new Response <PatientClinicalExaminationDto>();

            if (patientClinicalExaminationDto.PatientConsultationId == int.MinValue)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "Patient clinical examination must belong to an consultation."
                });
                return(response);
            }

            if (patientClinicalExaminationDto.ClinicalExamination == null || patientClinicalExaminationDto.ClinicalExamination.ClinicalExaminationId == null)
            {
                response.HasErrors = true;
                response.FieldErrors.Add(new FieldError()
                {
                    ErrorMessage = "The patient clinical examination has no clinical examination for it."
                });
                return(response);
            }

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                if (patientClinicalExaminationDto.PatientClinicalExaminationId != null && unitOfWork.PatientClinicalExaminationRepository.GetByID(item => item.PatientClinicalExaminationId == patientClinicalExaminationDto.PatientClinicalExaminationId) == null)
                {
                    response.HasErrors = true;
                    response.FieldErrors.Add(new FieldError()
                    {
                        ErrorMessage = "The clinical examination you trying to edit does not exist."
                    });
                    return(response);
                }
            }

            return(response);
        }
Exemple #5
0
        public PatientClinicalExaminationViewModel MapToPatientClinicalExaminationViewModel(PatientClinicalExaminationDto patientClinicalExaminationDto)
        {
            if (patientClinicalExaminationDto == null)
            {
                return(null);
            }

            PatientClinicalExaminationViewModel patientClinicalExaminationViewModel = new PatientClinicalExaminationViewModel();

            patientClinicalExaminationViewModel.PatientClinicalExaminationId = patientClinicalExaminationDto.PatientClinicalExaminationId;
            patientClinicalExaminationViewModel.PatientConsultationId        = patientClinicalExaminationDto.PatientConsultationId;
            patientClinicalExaminationViewModel.ClinicalExamination_Id       = patientClinicalExaminationDto.ClinicalExamination.ClinicalExaminationId.Value;
            patientClinicalExaminationViewModel.ClinicalExamination_Name     = patientClinicalExaminationDto.ClinicalExamination.Name;
            patientClinicalExaminationViewModel.ClinicalExaminationValue     = patientClinicalExaminationDto.Value;

            return(patientClinicalExaminationViewModel);
        }
Exemple #6
0
        public void MapToPatientClinicalExamination(PatientClinicalExamination patientClinicalExamination, PatientClinicalExaminationDto patientClinicalExaminationDto)
        {
            if (patientClinicalExaminationDto == null)
            {
                return;
            }

            patientClinicalExamination.PatientConsultationId = patientClinicalExaminationDto.PatientConsultationId;

            if (patientClinicalExaminationDto.ClinicalExamination != null && patientClinicalExaminationDto.ClinicalExamination.ClinicalExaminationId != null)
            {
                patientClinicalExamination.ClinicalExaminationId = patientClinicalExaminationDto.ClinicalExamination.ClinicalExaminationId.Value;
            }

            patientClinicalExamination.Value = patientClinicalExaminationDto.Value;
        }