public Result <PatientMedicalMonitoringDto> GetPatientMedicalMonitorings(int patientConsultationId) { Result <PatientMedicalMonitoringDto> response = new Result <PatientMedicalMonitoringDto>(); using (UnitOfWork unitOfWork = new UnitOfWork()) { IEnumerable <MedicalMonitoring> MedicalMonitorings = unitOfWork.MedicalMonitoringRepository.GetEntities(); IEnumerable <PatientMedicalMonitoring> patientMedicalMonitorings = unitOfWork.PatientMedicalMonitoringRepository.GetEntities(item => item.PatientConsultationId == patientConsultationId, p => p.OrderBy(o => o.MedicalMonitoring.SortKey)); foreach (MedicalMonitoring MedicalMonitoring in MedicalMonitorings) { MedicalMonitoringDto MedicalMonitoringDto = _MedicalMonitoringMapper.MapToMedicalMonitoringDto(MedicalMonitoring); PatientMedicalMonitoring patientMedicalMonitoring = patientMedicalMonitorings.Where(item => item.MedicalMonitoringId == MedicalMonitoring.MedicalMonitoringId).FirstOrDefault(); PatientMedicalMonitoringDto patientMedicalMonitoringDto = new PatientMedicalMonitoringDto() { PatientMedicalMonitoringId = patientMedicalMonitoring == null ? default(int?) : patientMedicalMonitoring.PatientMedicalMonitoringId, PatientConsultationId = patientConsultationId, MedicalMonitoring = MedicalMonitoringDto, Value = patientMedicalMonitoring == null ? null : patientMedicalMonitoring.Value }; response.Models.Add(patientMedicalMonitoringDto); } } return(response); }
public PatientMedicalMonitoringDto MapToPatientMedicalMonitoringDto(PatientMedicalMonitoring patientMedicalMonitoring) { if (patientMedicalMonitoring == null) { return(null); } PatientMedicalMonitoringDto patientMedicalMonitoringDto = new PatientMedicalMonitoringDto(); patientMedicalMonitoringDto.PatientMedicalMonitoringId = patientMedicalMonitoring.PatientMedicalMonitoringId; patientMedicalMonitoringDto.PatientConsultationId = patientMedicalMonitoring.PatientConsultationId; patientMedicalMonitoringDto.MedicalMonitoring = _MedicalMonitoringMapper.MapToMedicalMonitoringDto(patientMedicalMonitoring.MedicalMonitoring); patientMedicalMonitoringDto.Value = patientMedicalMonitoring.Value; return(patientMedicalMonitoringDto); }
public PatientMedicalMonitoringDto MapToPatientMedicalMonitoringDto(PatientMedicalMonitoringViewModel patientMedicalMonitoringViewModel) { if (patientMedicalMonitoringViewModel == null) { return(null); } PatientMedicalMonitoringDto patientMedicalMonitoringDto = new PatientMedicalMonitoringDto(); patientMedicalMonitoringDto.PatientMedicalMonitoringId = patientMedicalMonitoringViewModel.PatientMedicalMonitoringId; patientMedicalMonitoringDto.PatientConsultationId = patientMedicalMonitoringViewModel.PatientConsultationId; patientMedicalMonitoringDto.MedicalMonitoring = new MedicalMonitoringDto() { MedicalMonitoringId = patientMedicalMonitoringViewModel.MedicalMonitoring_Id, Name = patientMedicalMonitoringViewModel.MedicalMonitoring_Name }; patientMedicalMonitoringDto.Value = patientMedicalMonitoringViewModel.MedicalMonitoringValue; return(patientMedicalMonitoringDto); }
public Response <PatientMedicalMonitoringDto> SaveCheck(PatientMedicalMonitoringDto patientMedicalMonitoringDto) { Response <PatientMedicalMonitoringDto> response = new Response <PatientMedicalMonitoringDto>(); if (patientMedicalMonitoringDto.PatientConsultationId == int.MinValue) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "Patient medical note must belong to an consultation." }); return(response); } if (patientMedicalMonitoringDto.MedicalMonitoring == null || patientMedicalMonitoringDto.MedicalMonitoring.MedicalMonitoringId == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The patient medical note has no medical note for it." }); return(response); } using (UnitOfWork unitOfWork = new UnitOfWork()) { if (patientMedicalMonitoringDto.PatientMedicalMonitoringId != null && unitOfWork.PatientMedicalMonitoringRepository.GetByID(item => item.PatientMedicalMonitoringId == patientMedicalMonitoringDto.PatientMedicalMonitoringId) == null) { response.HasErrors = true; response.FieldErrors.Add(new FieldError() { ErrorMessage = "The medical note you trying to edit does not exist." }); return(response); } } return(response); }
public PatientMedicalMonitoringViewModel MapToPatientMedicalMonitoringViewModel(PatientMedicalMonitoringDto patientMedicalMonitoringDto) { if (patientMedicalMonitoringDto == null) { return(null); } PatientMedicalMonitoringViewModel patientMedicalMonitoringViewModel = new PatientMedicalMonitoringViewModel(); patientMedicalMonitoringViewModel.PatientMedicalMonitoringId = patientMedicalMonitoringDto.PatientMedicalMonitoringId; patientMedicalMonitoringViewModel.PatientConsultationId = patientMedicalMonitoringDto.PatientConsultationId; patientMedicalMonitoringViewModel.MedicalMonitoring_Id = patientMedicalMonitoringDto.MedicalMonitoring.MedicalMonitoringId.Value; patientMedicalMonitoringViewModel.MedicalMonitoring_Name = patientMedicalMonitoringDto.MedicalMonitoring.Name; patientMedicalMonitoringViewModel.MedicalMonitoringValue = patientMedicalMonitoringDto.Value; return(patientMedicalMonitoringViewModel); }
public void MapToPatientMedicalMonitoring(PatientMedicalMonitoring patientMedicalMonitoring, PatientMedicalMonitoringDto patientMedicalMonitoringDto) { if (patientMedicalMonitoringDto == null) { return; } patientMedicalMonitoring.PatientConsultationId = patientMedicalMonitoringDto.PatientConsultationId; if (patientMedicalMonitoringDto.MedicalMonitoring != null && patientMedicalMonitoringDto.MedicalMonitoring.MedicalMonitoringId != null) { patientMedicalMonitoring.MedicalMonitoringId = patientMedicalMonitoringDto.MedicalMonitoring.MedicalMonitoringId.Value; } patientMedicalMonitoring.Value = patientMedicalMonitoringDto.Value; }