public Result <PatientDeseaseScreeningDto> GetPatientDeseaseScreenings(int patientId) { Result <PatientDeseaseScreeningDto> response = new Result <PatientDeseaseScreeningDto>(); using (UnitOfWork unitOfWork = new UnitOfWork()) { IEnumerable <DeseaseScreening> DeseaseScreenings = unitOfWork.DeseaseScreeningRepository.GetEntities(); IEnumerable <PatientDeseaseScreening> patientDeseaseScreenings = unitOfWork.PatientDeseaseScreeningRepository.GetEntities(item => item.PatientId == patientId, p => p.OrderBy(o => o.DeseaseScreening.SortKey)); foreach (DeseaseScreening DeseaseScreening in DeseaseScreenings) { DeseaseScreeningDto DeseaseScreeningDto = _DeseaseScreeningMapper.MapToDeseaseScreeningDto(DeseaseScreening); PatientDeseaseScreening patientDeseaseScreening = patientDeseaseScreenings.Where(item => item.DeseaseScreeningId == DeseaseScreening.DeseaseScreeningId).FirstOrDefault(); PatientDeseaseScreeningDto patientDeseaseScreeningDto = new PatientDeseaseScreeningDto() { PatientDeseaseScreeningId = patientDeseaseScreening == null ? default(int?) : patientDeseaseScreening.PatientDeseaseScreeningId, PatientId = patientId, DeseaseScreening = DeseaseScreeningDto, YearOfScreening = patientDeseaseScreening == null ? default(int?) : patientDeseaseScreening.YearOfScreening, Value = patientDeseaseScreening == null ? null : patientDeseaseScreening.Value, SelectedInd = patientDeseaseScreening == null ? false : true }; response.Models.Add(patientDeseaseScreeningDto); } } return(response); }
public PatientDeseaseScreeningDto MapToPatientDeseaseScreeningDto(PatientDeseaseScreening patientDeseaseScreening) { if (patientDeseaseScreening == null) { return(null); } PatientDeseaseScreeningDto patientDeseaseScreeningDto = new PatientDeseaseScreeningDto(); patientDeseaseScreeningDto.PatientDeseaseScreeningId = patientDeseaseScreening.PatientDeseaseScreeningId; patientDeseaseScreeningDto.PatientId = patientDeseaseScreening.PatientId; patientDeseaseScreeningDto.DeseaseScreening = _DeseaseScreeningMapper.MapToDeseaseScreeningDto(patientDeseaseScreening.DeseaseScreening); patientDeseaseScreeningDto.Value = patientDeseaseScreening.Value; patientDeseaseScreeningDto.YearOfScreening = patientDeseaseScreening.YearOfScreening; patientDeseaseScreeningDto.SelectedInd = true; return(patientDeseaseScreeningDto); }
public Response <PatientDeseaseScreeningDto> SaveCheck(PatientDeseaseScreeningDto patientDeseaseScreeningDto) { Response <PatientDeseaseScreeningDto> response = new Response <PatientDeseaseScreeningDto>(); if (patientDeseaseScreeningDto.PatientId == int.MinValue) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "Patient does not exist." }); return(response); } if (patientDeseaseScreeningDto.DeseaseScreening == null || patientDeseaseScreeningDto.DeseaseScreening.DeseaseScreeningId == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The patient desease screening has no desease screening for it." }); return(response); } using (UnitOfWork unitOfWork = new UnitOfWork()) { if (patientDeseaseScreeningDto.PatientDeseaseScreeningId != null && unitOfWork.PatientDeseaseScreeningRepository.GetByID(item => item.PatientDeseaseScreeningId == patientDeseaseScreeningDto.PatientDeseaseScreeningId) == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The patient desease screening you trying to edit does not exist." }); return(response); } } return(response); }
public PatientDeseaseScreeningDto MapToPatientDeseaseScreeningDto(PatientDeseaseScreeningViewModel patientDeseaseScreeningViewModel) { if (patientDeseaseScreeningViewModel == null) { return(null); } PatientDeseaseScreeningDto patientDeseaseScreeningDto = new PatientDeseaseScreeningDto(); patientDeseaseScreeningDto.PatientDeseaseScreeningId = patientDeseaseScreeningViewModel.PatientDeseaseScreeningId; patientDeseaseScreeningDto.PatientId = patientDeseaseScreeningViewModel.PatientId; patientDeseaseScreeningDto.DeseaseScreening = new DeseaseScreeningDto() { DeseaseScreeningId = patientDeseaseScreeningViewModel.DeseaseScreening_Id, Name = patientDeseaseScreeningViewModel.DeseaseScreening_Name }; patientDeseaseScreeningDto.Value = patientDeseaseScreeningViewModel.DeseaseScreeningValue; patientDeseaseScreeningDto.YearOfScreening = patientDeseaseScreeningViewModel.YearOfScreening; patientDeseaseScreeningDto.SelectedInd = patientDeseaseScreeningViewModel.SelectedInd; return(patientDeseaseScreeningDto); }
public void MapToPatientDeseaseScreening(PatientDeseaseScreening patientDeseaseScreening, PatientDeseaseScreeningDto patientDeseaseScreeningDto) { if (patientDeseaseScreeningDto == null) { return; } patientDeseaseScreening.PatientId = patientDeseaseScreeningDto.PatientId; if (patientDeseaseScreeningDto.DeseaseScreening != null && patientDeseaseScreeningDto.DeseaseScreening.DeseaseScreeningId != null) { patientDeseaseScreening.DeseaseScreeningId = patientDeseaseScreeningDto.DeseaseScreening.DeseaseScreeningId.Value; } patientDeseaseScreening.Value = patientDeseaseScreeningDto.Value; patientDeseaseScreening.YearOfScreening = patientDeseaseScreeningDto.YearOfScreening; }