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); }
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))); }
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); }
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); }
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); }
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; }