Exemple #1
0
        public override T Convert <T, U>(U entity)
        {
            if (entity is PatientVisitUnscheduled)
            {
                PatientVisitUnscheduled PatientVisitUnscheduledDB = entity as PatientVisitUnscheduled;

                if (PatientVisitUnscheduledDB == null)
                {
                    return(default(T));
                }

                BO.PatientVisitUnscheduled PatientVisitUnscheduledBO = new BO.PatientVisitUnscheduled();
                PatientVisitUnscheduledBO.ID                  = PatientVisitUnscheduledDB.Id;
                PatientVisitUnscheduledBO.CaseId              = PatientVisitUnscheduledDB.CaseId;
                PatientVisitUnscheduledBO.PatientId           = PatientVisitUnscheduledDB.PatientId;
                PatientVisitUnscheduledBO.EventStart          = PatientVisitUnscheduledDB.EventStart;
                PatientVisitUnscheduledBO.MedicalProviderName = PatientVisitUnscheduledDB.MedicalProviderName;
                PatientVisitUnscheduledBO.DoctorName          = PatientVisitUnscheduledDB.DoctorName;
                PatientVisitUnscheduledBO.Notes               = PatientVisitUnscheduledDB.Notes;
                PatientVisitUnscheduledBO.SpecialtyId         = PatientVisitUnscheduledDB.SpecialtyId;
                PatientVisitUnscheduledBO.RoomTestId          = PatientVisitUnscheduledDB.RoomTestId;
                PatientVisitUnscheduledBO.ReferralId          = PatientVisitUnscheduledDB.ReferralId;
                PatientVisitUnscheduledBO.Status              = "Completed";

                PatientVisitUnscheduledBO.IsDeleted      = PatientVisitUnscheduledDB.IsDeleted;
                PatientVisitUnscheduledBO.CreateByUserID = PatientVisitUnscheduledDB.CreateByUserID;
                PatientVisitUnscheduledBO.UpdateByUserID = PatientVisitUnscheduledDB.UpdateByUserID;

                if (PatientVisitUnscheduledDB.Patient != null)
                {
                    BO.Patient PatientBO = new BO.Patient();
                    using (PatientRepository patientRepo = new PatientRepository(_context))
                    {
                        PatientBO = patientRepo.Convert <BO.Patient, Patient>(PatientVisitUnscheduledDB.Patient);
                        PatientVisitUnscheduledBO.Patient = PatientBO;
                    }
                }

                if (PatientVisitUnscheduledDB.Specialty != null)
                {
                    BO.Specialty SpecialtyBO = new BO.Specialty();
                    using (SpecialityRepository specialtyRepo = new SpecialityRepository(_context))
                    {
                        SpecialtyBO = specialtyRepo.Convert <BO.Specialty, Specialty>(PatientVisitUnscheduledDB.Specialty);
                        PatientVisitUnscheduledBO.Specialty = SpecialtyBO;
                    }
                }

                if (PatientVisitUnscheduledDB.RoomTest != null)
                {
                    BO.RoomTest RoomTestBO = new BO.RoomTest();
                    using (RoomTestRepository roomTestRepo = new RoomTestRepository(_context))
                    {
                        RoomTestBO = roomTestRepo.Convert <BO.RoomTest, RoomTest>(PatientVisitUnscheduledDB.RoomTest);
                        PatientVisitUnscheduledBO.RoomTest = RoomTestBO;
                    }
                }

                if (PatientVisitUnscheduledDB.Case != null)
                {
                    BO.Case CaseBO = new BO.Case();
                    using (CaseRepository caseRepo = new CaseRepository(_context))
                    {
                        CaseBO = caseRepo.Convert <BO.Case, Case>(PatientVisitUnscheduledDB.Case);
                        PatientVisitUnscheduledBO.Case = CaseBO;

                        if (PatientVisitUnscheduledDB.Case.PatientAccidentInfoes != null && PatientVisitUnscheduledDB.Case.PatientAccidentInfoes.Count > 0)
                        {
                            List <BO.PatientAccidentInfo> PatientAccidentInfoBOList = new List <BO.PatientAccidentInfo>();
                            using (PatientAccidentInfoRepository patientAccidentInfoRepo = new PatientAccidentInfoRepository(_context))
                            {
                                foreach (PatientAccidentInfo eachPatientInsuranceInfo in PatientVisitUnscheduledDB.Case.PatientAccidentInfoes)
                                {
                                    if (eachPatientInsuranceInfo.IsDeleted.HasValue == false || (eachPatientInsuranceInfo.IsDeleted.HasValue == true && eachPatientInsuranceInfo.IsDeleted.Value == false))
                                    {
                                        PatientAccidentInfoBOList.Add(patientAccidentInfoRepo.Convert <BO.PatientAccidentInfo, PatientAccidentInfo>(eachPatientInsuranceInfo));
                                    }
                                }

                                PatientVisitUnscheduledBO.Case.PatientAccidentInfoes = PatientAccidentInfoBOList;
                            }
                        }
                    }
                }

                return((T)(object)PatientVisitUnscheduledBO);
            }

            return(default(T));
        }
        public override T Convert <T, U>(U entity)
        {
            Doctor doctor = entity as Doctor;

            if (doctor == null)
            {
                return(default(T));
            }

            BO.Doctor doctorBO = new BO.Doctor();

            doctorBO.ID               = doctor.Id;
            doctorBO.LicenseNumber    = doctor.LicenseNumber;
            doctorBO.WCBAuthorization = doctor.WCBAuthorization;
            doctorBO.WcbRatingCode    = doctor.WcbRatingCode;
            doctorBO.NPI              = doctor.NPI;
            doctorBO.Title            = doctor.Title;
            doctorBO.TaxType          = (BO.GBEnums.TaxType)doctor.TaxTypeId;

            if (doctor.IsDeleted.HasValue)
            {
                doctorBO.IsDeleted = doctor.IsDeleted.Value;
            }
            if (doctor.UpdateByUserID.HasValue)
            {
                doctorBO.UpdateByUserID = doctor.UpdateByUserID.Value;
            }

            doctorBO.IsCalendarPublic = doctor.IsCalendarPublic;

            if (doctor.User != null)
            {
                if (doctor.User.IsDeleted.HasValue == false || (doctor.User.IsDeleted.HasValue == true && doctor.User.IsDeleted.Value == false))
                {
                    BO.User boUser = new BO.User();
                    using (UserRepository sr = new UserRepository(_context))
                    {
                        boUser        = sr.Convert <BO.User, User>(doctor.User);
                        doctorBO.user = boUser;
                    }

                    if (doctor.DoctorSpecialities != null)
                    {
                        List <BO.DoctorSpeciality> lstDoctorSpecility = new List <BO.DoctorSpeciality>();
                        foreach (var item in doctor.DoctorSpecialities)
                        {
                            if (item.IsDeleted == false)
                            {
                                using (DoctorSpecialityRepository sr = new DoctorSpecialityRepository(_context))
                                {
                                    lstDoctorSpecility.Add(sr.ObjectConvert <BO.DoctorSpeciality, DoctorSpeciality>(item));
                                }
                            }
                        }
                        doctorBO.DoctorSpecialities = lstDoctorSpecility;
                    }

                    if (doctor.DoctorRoomTestMappings != null)
                    {
                        List <BO.DoctorRoomTestMapping> lstDoctorRoomTestMapping = new List <BO.DoctorRoomTestMapping>();
                        foreach (var item in doctor.DoctorRoomTestMappings)
                        {
                            if (item.IsDeleted == false)
                            {
                                BO.DoctorRoomTestMapping doctorRoomTestMappingBO = new BO.DoctorRoomTestMapping();
                                doctorRoomTestMappingBO.ID        = item.Id;
                                doctorRoomTestMappingBO.IsDeleted = item.IsDeleted;
                                if (doctorRoomTestMappingBO.UpdateByUserID.HasValue)
                                {
                                    doctorRoomTestMappingBO.UpdateByUserID = item.UpdateByUserID.Value;
                                }

                                if (item.RoomTest != null && (item.RoomTest.IsDeleted.HasValue == false || (item.RoomTest.IsDeleted.HasValue == true && item.RoomTest.IsDeleted.Value == false)))
                                {
                                    BO.RoomTest boRoomTest = new BO.RoomTest();
                                    using (RoomTestRepository sr = new RoomTestRepository(_context))
                                    {
                                        boRoomTest = sr.Convert <BO.RoomTest, RoomTest>(item.RoomTest);
                                        doctorRoomTestMappingBO.RoomTest = boRoomTest;
                                    }
                                }
                                lstDoctorRoomTestMapping.Add(doctorRoomTestMappingBO);
                            }
                        }
                        doctorBO.DoctorRoomTestMappings = lstDoctorRoomTestMapping;
                    }

                    //if (doctor.User.UserCompanies != null && doctorBO.user.UserCompanies != null && doctorBO.user.UserCompanies.Count <= 0)
                    if (doctor.User.UserCompanies != null)
                    {
                        List <BO.UserCompany> lstUserCompany = new List <BO.UserCompany>();
                        foreach (var item in doctor.User.UserCompanies)
                        {
                            if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false))
                            {
                                using (UserCompanyRepository sr = new UserCompanyRepository(_context))
                                {
                                    BO.UserCompany BOUserCompany = new BO.UserCompany();
                                    BOUserCompany      = sr.Convert <BO.UserCompany, UserCompany>(item);
                                    BOUserCompany.User = null;
                                    lstUserCompany.Add(BOUserCompany);
                                }
                            }
                        }
                        doctorBO.user.UserCompanies = lstUserCompany;
                    }

                    if (doctor.DoctorLocationSchedules != null)
                    {
                        List <BO.DoctorLocationSchedule> lstDoctorLocationSchedule = new List <BO.DoctorLocationSchedule>();
                        foreach (var item in doctor.DoctorLocationSchedules)
                        {
                            if (item.IsDeleted.HasValue == false || (item.IsDeleted.HasValue == true && item.IsDeleted.Value == false))
                            {
                                using (DoctorLocationScheduleRepository sr = new DoctorLocationScheduleRepository(_context))
                                {
                                    BO.DoctorLocationSchedule BODoctorLocationSchedule = new BO.DoctorLocationSchedule();
                                    BODoctorLocationSchedule          = sr.Convert <BO.DoctorLocationSchedule, DoctorLocationSchedule>(item);
                                    BODoctorLocationSchedule.doctor   = null;
                                    BODoctorLocationSchedule.schedule = null;
                                    lstDoctorLocationSchedule.Add(BODoctorLocationSchedule);
                                }
                            }
                        }
                        doctorBO.DoctorLocationSchedules = lstDoctorLocationSchedule;
                    }
                }
            }

            return((T)(object)doctorBO);
        }