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);
        }
Beispiel #2
0
        public PastMedicalHistoryDto MapToPastMedicalHistoryDto(PastMedicalHistory pastMedicalHistory)
        {
            if (pastMedicalHistory == null)
            {
                return(null);
            }

            PastMedicalHistoryDto PastMedicalHistoryDto = new PastMedicalHistoryDto();

            PastMedicalHistoryDto.PastMedicalHistoryId = pastMedicalHistory.PastMedicalHistoryId;
            PastMedicalHistoryDto.Name    = pastMedicalHistory.Name;
            PastMedicalHistoryDto.SortKey = pastMedicalHistory.SortKey;

            return(PastMedicalHistoryDto);
        }
Beispiel #3
0
        public PastMedicalHistory MapToPastMedicalHistory(PastMedicalHistoryDto pastMedicalHistoryDto)
        {
            if (pastMedicalHistoryDto == null)
            {
                return(null);
            }

            PastMedicalHistory pastMedicalHistory = new PastMedicalHistory();

            if (pastMedicalHistoryDto.PastMedicalHistoryId != null)
            {
                pastMedicalHistory.PastMedicalHistoryId = pastMedicalHistoryDto.PastMedicalHistoryId.Value;
            }

            pastMedicalHistory.Name    = pastMedicalHistoryDto.Name;
            pastMedicalHistory.SortKey = pastMedicalHistoryDto.SortKey;

            return(pastMedicalHistory);
        }