public Result <PatientPastMedicalHistoryDto> GetPatientPastMedicalHistories(int patientId) { Result <PatientPastMedicalHistoryDto> response = new Result <PatientPastMedicalHistoryDto>(); using (UnitOfWork unitOfWork = new UnitOfWork()) { IEnumerable <PastMedicalHistory> PastMedicalHistorys = unitOfWork.PastMedicalHistoryRepository.GetEntities(); IEnumerable <PatientPastMedicalHistory> patientPastMedicalHistorys = unitOfWork.PatientPastMedicalHistoryRepository.GetEntities(item => item.PatientId == patientId, p => p.OrderBy(o => o.PastMedicalHistory.SortKey)); foreach (PastMedicalHistory PastMedicalHistory in PastMedicalHistorys) { PastMedicalHistoryDto PastMedicalHistoryDto = _PastMedicalHistoryMapper.MapToPastMedicalHistoryDto(PastMedicalHistory); PatientPastMedicalHistory patientPastMedicalHistory = patientPastMedicalHistorys.Where(item => item.PastMedicalHistoryId == PastMedicalHistory.PastMedicalHistoryId).FirstOrDefault(); PatientPastMedicalHistoryDto patientPastMedicalHistoryDto = new PatientPastMedicalHistoryDto() { PatientPastMedicalHistoryId = patientPastMedicalHistory == null ? default(int?) : patientPastMedicalHistory.PatientPastMedicalHistoryId, PatientId = patientId, PastMedicalHistory = PastMedicalHistoryDto, Value = patientPastMedicalHistory == null ? null : patientPastMedicalHistory.Value }; response.Models.Add(patientPastMedicalHistoryDto); } } return(response); }
public PatientPastMedicalHistoryDto MapToPatientPastMedicalHistoryDto(PatientPastMedicalHistory patientPastMedicalHistory) { if (patientPastMedicalHistory == null) { return(null); } PatientPastMedicalHistoryDto patientPastMedicalHistoryDto = new PatientPastMedicalHistoryDto(); patientPastMedicalHistoryDto.PatientPastMedicalHistoryId = patientPastMedicalHistory.PatientPastMedicalHistoryId; patientPastMedicalHistoryDto.PatientId = patientPastMedicalHistory.PatientId; patientPastMedicalHistoryDto.PastMedicalHistory = _PastMedicalHistoryMapper.MapToPastMedicalHistoryDto(patientPastMedicalHistory.PastMedicalHistory); patientPastMedicalHistoryDto.Value = patientPastMedicalHistory.Value; return(patientPastMedicalHistoryDto); }
public PatientPastMedicalHistoryDto MapToPatientPastMedicalHistoryDto(PatientPastMedicalHistoryViewModel patientPastMedicalHistoryViewModel) { if (patientPastMedicalHistoryViewModel == null) { return(null); } PatientPastMedicalHistoryDto patientPastMedicalHistoryDto = new PatientPastMedicalHistoryDto(); patientPastMedicalHistoryDto.PatientPastMedicalHistoryId = patientPastMedicalHistoryViewModel.PatientPastMedicalHistoryId; patientPastMedicalHistoryDto.PatientId = patientPastMedicalHistoryViewModel.PatientId; patientPastMedicalHistoryDto.PastMedicalHistory = new PastMedicalHistoryDto() { PastMedicalHistoryId = patientPastMedicalHistoryViewModel.PastMedicalHistory_Id, Name = patientPastMedicalHistoryViewModel.PastMedicalHistory_Name }; patientPastMedicalHistoryDto.Value = patientPastMedicalHistoryViewModel.PastMedicalHistoryValue; return(patientPastMedicalHistoryDto); }
public Response <PatientPastMedicalHistoryDto> SaveCheck(PatientPastMedicalHistoryDto patientPastMedicalHistoryDto) { Response <PatientPastMedicalHistoryDto> response = new Response <PatientPastMedicalHistoryDto>(); if (patientPastMedicalHistoryDto.PatientId == int.MinValue) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "Patient does not exists." }); return(response); } if (patientPastMedicalHistoryDto.PastMedicalHistory == null || patientPastMedicalHistoryDto.PastMedicalHistory.PastMedicalHistoryId == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The patient past medical history has no past medical history for it." }); return(response); } using (UnitOfWork unitOfWork = new UnitOfWork()) { if (patientPastMedicalHistoryDto.PatientPastMedicalHistoryId != null && unitOfWork.PatientPastMedicalHistoryRepository.GetByID(item => item.PatientPastMedicalHistoryId == patientPastMedicalHistoryDto.PatientPastMedicalHistoryId) == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The patient past medical history you trying to edit does not exist." }); return(response); } } return(response); }
public void MapToPatientPastMedicalHistory(PatientPastMedicalHistory patientPastMedicalHistory, PatientPastMedicalHistoryDto patientPastMedicalHistoryDto) { if (patientPastMedicalHistoryDto == null) { return; } patientPastMedicalHistory.PatientId = patientPastMedicalHistoryDto.PatientId; if (patientPastMedicalHistoryDto.PastMedicalHistory != null && patientPastMedicalHistoryDto.PastMedicalHistory.PastMedicalHistoryId != null) { patientPastMedicalHistory.PastMedicalHistoryId = patientPastMedicalHistoryDto.PastMedicalHistory.PastMedicalHistoryId.Value; } patientPastMedicalHistory.Value = patientPastMedicalHistoryDto.Value; }
public PatientPastMedicalHistoryViewModel MapToPatientPastMedicalHistoryViewModel(PatientPastMedicalHistoryDto patientPastMedicalHistoryDto) { if (patientPastMedicalHistoryDto == null) { return(null); } PatientPastMedicalHistoryViewModel patientPastMedicalHistoryViewModel = new PatientPastMedicalHistoryViewModel(); patientPastMedicalHistoryViewModel.PatientPastMedicalHistoryId = patientPastMedicalHistoryDto.PatientPastMedicalHistoryId; patientPastMedicalHistoryViewModel.PatientId = patientPastMedicalHistoryDto.PatientId; patientPastMedicalHistoryViewModel.PastMedicalHistory_Id = patientPastMedicalHistoryDto.PastMedicalHistory.PastMedicalHistoryId.Value; patientPastMedicalHistoryViewModel.PastMedicalHistory_Name = patientPastMedicalHistoryDto.PastMedicalHistory.Name; patientPastMedicalHistoryViewModel.PastMedicalHistoryValue = patientPastMedicalHistoryDto.Value; return(patientPastMedicalHistoryViewModel); }