Exemple #1
0
        public Response <PatientConsultationSickNoteDto> SaveCheck(PatientConsultationSickNoteDto patientConsultationSickNoteDto)
        {
            Response <PatientConsultationSickNoteDto> response = new Response <PatientConsultationSickNoteDto>();

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

            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                if (patientConsultationSickNoteDto.PatientConsultationSickNoteId != null)
                {
                    if (unitOfWork.PatientConsultationSickNoteRepository.GetByID(item => item.PatientConsultationSickNoteId == patientConsultationSickNoteDto.PatientConsultationSickNoteId.Value) == null)
                    {
                        response.HasErrors = true;
                        response.FieldErrors.Add(new FieldError()
                        {
                            ErrorMessage = "The entry you trying to save does not exist."
                        });
                    }
                }
            }

            return(response);
        }
Exemple #2
0
        public PatientConsultationSickNoteViewModel GetPatientConsultationSickNote(int patientConsultationId, int patientId)
        {
            PatientConsultationSickNoteDto response = _PhekoServiceClient.GetPatientConsultationSickNote(patientConsultationId);

            return(response == null ? new PatientConsultationSickNoteViewModel()
            {
                PatientId = patientId, PatientConsultationId = patientConsultationId
            } : _PatientConsultationSickNoteViewModelMapper.MapToPatientConsultationSickNoteViewModel(_PhekoServiceClient.GetPatientConsultationSickNote(patientConsultationId)));
        }
Exemple #3
0
        public PatientConsultationSickNoteDto MapToPatientConsultationSickNoteDto(PatientConsultationSickNoteViewModel patientConsultationSickNoteViewModel)
        {
            if (patientConsultationSickNoteViewModel == null)
            {
                return(null);
            }

            PatientConsultationSickNoteDto patientConsultationSickNoteDto = new PatientConsultationSickNoteDto();

            patientConsultationSickNoteDto.PatientConsultationSickNoteId = patientConsultationSickNoteViewModel.PatientConsultationSickNoteId;
            patientConsultationSickNoteDto.PatientConsultationId         = patientConsultationSickNoteViewModel.PatientConsultationId;
            patientConsultationSickNoteDto.PatientId      = patientConsultationSickNoteViewModel.PatientId;
            patientConsultationSickNoteDto.SicknessReason = patientConsultationSickNoteViewModel.SicknessReason;
            patientConsultationSickNoteDto.Diagnoses      = patientConsultationSickNoteViewModel.Diagnoses;
            patientConsultationSickNoteDto.StartDate      = Converter.StringToDate(patientConsultationSickNoteViewModel.StartDate);
            patientConsultationSickNoteDto.EndDate        = Converter.StringToDate(patientConsultationSickNoteViewModel.EndDate);

            return(patientConsultationSickNoteDto);
        }
Exemple #4
0
        public PatientConsultationSickNoteDto MapToPatientConsultationSickNoteDto(PatientConsultationSickNote patientConsultationSickNote)
        {
            if (patientConsultationSickNote == null)
            {
                return(null);
            }

            PatientConsultationSickNoteDto patientConsultationSickNoteDto = new PatientConsultationSickNoteDto();

            patientConsultationSickNoteDto.PatientConsultationSickNoteId = patientConsultationSickNote.PatientConsultationSickNoteId;
            patientConsultationSickNoteDto.PatientConsultationId         = patientConsultationSickNote.PatientConsultationId;
            patientConsultationSickNoteDto.PatientId      = patientConsultationSickNote.PatientId;
            patientConsultationSickNoteDto.SicknessReason = patientConsultationSickNote.SicknessReason;
            patientConsultationSickNoteDto.Diagnoses      = patientConsultationSickNote.Diagnoses;
            patientConsultationSickNoteDto.StartDate      = patientConsultationSickNote.StartDate;
            patientConsultationSickNoteDto.EndDate        = patientConsultationSickNote.EndDate;

            return(patientConsultationSickNoteDto);
        }
Exemple #5
0
 public Response <PatientConsultationSickNoteDto> SavePatientConsultationSickNote(PatientConsultationSickNoteDto patientConsultationSickNoteDto)
 {
     return(_IPatientConsultationSickNoteManager.SavePatientConsultationSickNote(patientConsultationSickNoteDto));
 }
        public Response <PatientConsultationSickNoteDto> SavePatientConsultationSickNote(PatientConsultationSickNoteDto patientConsultationSickNoteDto)
        {
            Response <PatientConsultationSickNoteDto> response = _PatientConsultationSickNoteBusinessRules.SaveCheck(patientConsultationSickNoteDto);

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

            using (TransactionScope scope = new TransactionScope())
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    PatientConsultationSickNote patientConsultationSickNote = unitOfWork.PatientConsultationSickNoteRepository.GetByID(item => item.PatientConsultationId == patientConsultationSickNoteDto.PatientConsultationId);
                    bool isPatientConsultationSickNoteNew = false;

                    if (patientConsultationSickNote == null)
                    {
                        isPatientConsultationSickNoteNew = true;
                        patientConsultationSickNote      = new PatientConsultationSickNote();
                    }

                    _PatientConsultationSickNoteMapper.MapToPatientConsultationSickNote(patientConsultationSickNote, patientConsultationSickNoteDto);

                    if (isPatientConsultationSickNoteNew)
                    {
                        unitOfWork.PatientConsultationSickNoteRepository.Insert(patientConsultationSickNote);
                    }
                    else
                    {
                        unitOfWork.PatientConsultationSickNoteRepository.Update(patientConsultationSickNote);
                    }

                    unitOfWork.Save();
                    response.Model = _PatientConsultationSickNoteMapper.MapToPatientConsultationSickNoteDto(unitOfWork.PatientConsultationSickNoteRepository.GetByID(p => p.PatientConsultationSickNoteId == patientConsultationSickNote.PatientConsultationSickNoteId));
                }

                scope.Complete();
            }

            return(response);
        }
Exemple #7
0
        public void MapToPatientConsultationSickNote(PatientConsultationSickNote patientConsultationSickNote, PatientConsultationSickNoteDto patientConsultationSickNoteDto)
        {
            if (patientConsultationSickNoteDto == null)
            {
                return;
            }

            patientConsultationSickNote.PatientConsultationId = patientConsultationSickNoteDto.PatientConsultationId;
            patientConsultationSickNote.PatientId             = patientConsultationSickNoteDto.PatientId;
            patientConsultationSickNote.SicknessReason        = patientConsultationSickNoteDto.SicknessReason;
            patientConsultationSickNote.Diagnoses             = patientConsultationSickNoteDto.Diagnoses;
            patientConsultationSickNote.StartDate             = patientConsultationSickNoteDto.StartDate;
            patientConsultationSickNote.EndDate = patientConsultationSickNoteDto.EndDate;
        }