Esempio n. 1
0
        public override T Convert <T, U>(U entity)
        {
            if (entity is AttorneyVisit)
            {
                AttorneyVisit AttorneyVisitDB = entity as AttorneyVisit;

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

                BO.AttorneyVisit AttorneyVisitBO = new BO.AttorneyVisit();
                AttorneyVisitBO.ID = AttorneyVisitDB.Id;
                AttorneyVisitBO.CalendarEventId = AttorneyVisitDB.CalendarEventId;
                AttorneyVisitBO.CaseId          = AttorneyVisitDB.CaseId;
                AttorneyVisitBO.PatientId       = AttorneyVisitDB.PatientId;
                AttorneyVisitBO.CompanyId       = AttorneyVisitDB.CompanyId;
                AttorneyVisitBO.AttorneyId      = AttorneyVisitDB.AttorneyId;
                AttorneyVisitBO.EventStart      = AttorneyVisitDB.EventStart;
                AttorneyVisitBO.EventEnd        = AttorneyVisitDB.EventEnd;
                AttorneyVisitBO.Subject         = AttorneyVisitDB.Subject;
                AttorneyVisitBO.VisitStatusId   = AttorneyVisitDB.VisitStatusId;
                AttorneyVisitBO.ContactPerson   = AttorneyVisitDB.ContactPerson;
                AttorneyVisitBO.Agenda          = AttorneyVisitDB.Agenda;

                AttorneyVisitBO.IsDeleted      = AttorneyVisitDB.IsDeleted;
                AttorneyVisitBO.CreateByUserID = AttorneyVisitDB.CreateByUserID;
                AttorneyVisitBO.UpdateByUserID = AttorneyVisitDB.UpdateByUserID;

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

                        //if (AttorneyVisitDB.Patient.PatientInsuranceInfoes != null && AttorneyVisitDB.Patient.PatientInsuranceInfoes.Count > 0)
                        //{
                        //    List<BO.PatientInsuranceInfo> PatientInsuranceInfoBOList = new List<BO.PatientInsuranceInfo>();
                        //    using (PatientInsuranceInfoRepository patientInsuranceInfoRepo = new PatientInsuranceInfoRepository(_context))
                        //    {
                        //        foreach (PatientInsuranceInfo eachPatientInsuranceInfo in AttorneyVisitDB.Patient.PatientInsuranceInfoes)
                        //        {
                        //            if (eachPatientInsuranceInfo.IsDeleted.HasValue == false || (eachPatientInsuranceInfo.IsDeleted.HasValue == true && eachPatientInsuranceInfo.IsDeleted.Value == false))
                        //            {
                        //                PatientInsuranceInfoBOList.Add(patientInsuranceInfoRepo.Convert<BO.PatientInsuranceInfo, PatientInsuranceInfo>(eachPatientInsuranceInfo));
                        //            }
                        //        }

                        //        AttorneyVisitBO.Patient.PatientInsuranceInfoes = PatientInsuranceInfoBOList;
                        //    }
                        //}
                    }
                }

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

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

                                AttorneyVisitBO.Case.PatientAccidentInfoes = PatientAccidentInfoBOList;
                            }
                        }
                    }
                }

                if (AttorneyVisitDB.Company != null)
                {
                    BO.Company boCompany = new BO.Company();
                    using (CompanyRepository cmp = new CompanyRepository(_context))
                    {
                        boCompany = cmp.Convert <BO.Company, Company>(AttorneyVisitDB.Company);
                        AttorneyVisitBO.Company = boCompany;
                    }
                }

                if (AttorneyVisitDB.CalendarEvent != null)
                {
                    AttorneyVisitBO.CalendarEvent = new BO.CalendarEvent();

                    using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context))
                    {
                        AttorneyVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(AttorneyVisitDB.CalendarEvent);
                    }
                }

                return((T)(object)AttorneyVisitBO);
            }
            else if (entity is CalendarEvent)
            {
                CalendarEvent CalendarEventDB = entity as CalendarEvent;

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

                BO.CalendarEvent CalendarEvent = new BO.CalendarEvent();
                using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context))
                {
                    CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(CalendarEventDB);
                }

                return((T)(object)CalendarEvent);
            }

            return(default(T));
        }
Esempio n. 2
0
        public T ConvertIMEvisit <T, U>(U entity)
        {
            if (entity is IMEVisit)
            {
                IMEVisit IMEVisit = entity as IMEVisit;

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

                BO.IMEVisit IMEVisitBO = new BO.IMEVisit();
                IMEVisitBO.ID = IMEVisit.ID;
                IMEVisitBO.CalendarEventId         = IMEVisit.CalendarEventId;
                IMEVisitBO.CaseId                  = IMEVisit.CaseId;
                IMEVisitBO.PatientId               = IMEVisit.PatientId;
                IMEVisitBO.EventStart              = IMEVisit.EventStart;
                IMEVisitBO.EventEnd                = IMEVisit.EventEnd;
                IMEVisitBO.Notes                   = IMEVisit.Notes;
                IMEVisitBO.VisitStatusId           = IMEVisit.VisitStatusId;
                IMEVisitBO.TransportProviderId     = IMEVisit.TransportProviderId;
                IMEVisitBO.DoctorName              = IMEVisit.DoctorName;
                IMEVisitBO.VisitCreatedByCompanyId = IMEVisit.VisitCreatedByCompanyId;
                IMEVisitBO.IsDeleted               = IMEVisit.IsDeleted;
                IMEVisitBO.CreateByUserID          = IMEVisit.CreateByUserID;
                IMEVisitBO.UpdateByUserID          = IMEVisit.UpdateByUserID;

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

                if (IMEVisit.TransportProviderId != null)
                {
                    BO.Company CompanyBO = new BO.Company();
                    using (PatientRepository patientRepo = new PatientRepository(_context))
                    {
                        CompanyBO          = patientRepo.Convert <BO.Company, Company>(IMEVisit.Company);
                        IMEVisitBO.Company = CompanyBO;
                    }
                }

                if (IMEVisit.CalendarEvent != null)
                {
                    IMEVisitBO.CalendarEvent = new BO.CalendarEvent();

                    using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context))
                    {
                        IMEVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(IMEVisit.CalendarEvent);
                    }
                }

                return((T)(object)IMEVisitBO);
            }

            return(default(T));
        }
Esempio n. 3
0
        public T ConvertEOvisit <T, U>(U entity)
        {
            if (entity is EOVisit)
            {
                EOVisit EOVisit = entity as EOVisit;

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

                BO.EOVisit EOVisitBO = new BO.EOVisit();
                EOVisitBO.ID = EOVisit.ID;
                EOVisitBO.CalendarEventId         = EOVisit.CalendarEventId;
                EOVisitBO.DoctorId                = EOVisit.DoctorId;
                EOVisitBO.PatientId               = EOVisit.PatientId;
                EOVisitBO.VisitCreatedByCompanyId = EOVisit.PatientId;
                EOVisitBO.InsuranceProviderId     = EOVisit.InsuranceProviderId;
                EOVisitBO.VisitStatusId           = EOVisit.VisitStatusId;
                EOVisitBO.EventStart              = EOVisit.EventStart;
                EOVisitBO.EventEnd                = EOVisit.EventEnd;
                EOVisitBO.Notes = EOVisit.Notes;

                EOVisitBO.IsDeleted      = EOVisit.IsDeleted;
                EOVisitBO.CreateByUserID = EOVisit.CreateByUserID;
                EOVisitBO.UpdateByUserID = EOVisit.UpdateByUserID;

                if (EOVisit.Doctor != null)
                {
                    BO.Doctor doctorBO = new BO.Doctor();
                    using (DoctorRepository patientRepo = new DoctorRepository(_context))
                    {
                        doctorBO         = patientRepo.Convert <BO.Doctor, Doctor>(EOVisit.Doctor);
                        EOVisitBO.Doctor = doctorBO;
                    }
                }

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

                if (EOVisit.Company != null)
                {
                    BO.Company CompanyBO = new BO.Company();
                    using (CompanyRepository companyRepo = new CompanyRepository(_context))
                    {
                        CompanyBO         = companyRepo.Convert <BO.Company, Company>(EOVisit.Company);
                        EOVisitBO.Company = CompanyBO;
                    }
                }

                if (EOVisit.InsuranceMaster != null)
                {
                    BO.InsuranceMaster InsuranceMasterBO = new BO.InsuranceMaster();
                    using (InsuranceMasterRepository InsuranceMasterRepo = new InsuranceMasterRepository(_context))
                    {
                        InsuranceMasterBO         = InsuranceMasterRepo.ObjectConvert <BO.InsuranceMaster, InsuranceMaster>(EOVisit.InsuranceMaster);
                        EOVisitBO.InsuranceMaster = InsuranceMasterBO;
                    }
                }

                if (EOVisit.CalendarEvent != null)
                {
                    EOVisitBO.CalendarEvent = new BO.CalendarEvent();

                    using (CalendarEventRepository calEventRep = new CalendarEventRepository(_context))
                    {
                        EOVisitBO.CalendarEvent = calEventRep.Convert <BO.CalendarEvent, CalendarEvent>(EOVisit.CalendarEvent);
                    }
                }

                return((T)(object)EOVisitBO);
            }

            return(default(T));
        }
Esempio n. 4
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));
        }
Esempio n. 5
0
        public override object Save <T>(T entity)
        {
            BO.PatientFamilyMember patientfamilymemberBO = (BO.PatientFamilyMember)(object) entity;
            BO.Patient             patientBO             = new BO.Patient();
            BO.Common.Gender       genderBO   = new BO.Common.Gender();
            BO.Relation            relationBO = new BO.Relation();

            PatientFamilyMember patientfamilymemberDB = new PatientFamilyMember();

            using (var dbContextTransaction = _context.Database.BeginTransaction())
            {
                bool IsEditMode = false;
                IsEditMode = (patientfamilymemberBO != null && patientfamilymemberBO.ID > 0) ? true : false;

                Patient  patient2DB = new Patient();
                Gender   genderDB   = new Gender();
                Relation relationDB = new Relation();

                #region Patient Family Members
                if (patientfamilymemberBO != null)
                {
                    //if (patientfamilymemberBO.IsInActive == true)
                    //{
                    //    var existingPatientInfoDB = _context.PatientFamilyMembers.Where(p => p.PatientId == patientfamilymemberBO.PatientId).ToList();
                    //    existingPatientInfoDB.ForEach(p => p.IsInActive = false);
                    //}

                    if (patientfamilymemberBO.PrimaryContact.HasValue == true && patientfamilymemberBO.PrimaryContact == true)
                    {
                        var existingPatientInfoDB = _context.PatientFamilyMembers.Where(p => p.CaseId == patientfamilymemberBO.CaseId).ToList();
                        existingPatientInfoDB.ForEach(p => p.PrimaryContact = false);
                    }

                    bool Add_patientfamilymemberDB = false;
                    patientfamilymemberDB = _context.PatientFamilyMembers.Where(p => p.Id == patientfamilymemberBO.ID).FirstOrDefault();

                    if (patientfamilymemberDB == null && patientfamilymemberBO.ID <= 0)
                    {
                        patientfamilymemberDB     = new PatientFamilyMember();
                        Add_patientfamilymemberDB = true;
                    }
                    else if (patientfamilymemberDB == null && patientfamilymemberBO.ID > 0)
                    {
                        dbContextTransaction.Rollback();
                        return(new BO.ErrorObject {
                            errorObject = "", ErrorMessage = "Patient dosent exists.", ErrorLevel = ErrorLevel.Error
                        });
                    }

                    if (IsEditMode == false)
                    {
                        patientfamilymemberDB.CaseId = patientfamilymemberBO.CaseId;
                    }

                    patientfamilymemberDB.RelationId     = (IsEditMode == true && patientfamilymemberBO.RelationId <= 0) ? patientfamilymemberDB.RelationId : patientfamilymemberBO.RelationId;
                    patientfamilymemberDB.FirstName      = (IsEditMode == true && patientfamilymemberBO.FirstName == null) ? patientfamilymemberDB.FirstName : patientfamilymemberBO.FirstName;
                    patientfamilymemberDB.MiddleName     = (IsEditMode == true && patientfamilymemberBO.MiddleName == null) ? patientfamilymemberDB.MiddleName : patientfamilymemberBO.MiddleName;
                    patientfamilymemberDB.LastName       = (IsEditMode == true && patientfamilymemberBO.LastName == null) ? patientfamilymemberDB.LastName : patientfamilymemberBO.LastName;
                    patientfamilymemberDB.Age            = (IsEditMode == true && patientfamilymemberBO.Age <= 0) ? patientfamilymemberDB.Age : patientfamilymemberBO.Age;
                    patientfamilymemberDB.RaceId         = (IsEditMode == true && patientfamilymemberBO.RaceId.HasValue == false) ? patientfamilymemberDB.RaceId : patientfamilymemberBO.RaceId;
                    patientfamilymemberDB.EthnicitesId   = (IsEditMode == true && patientfamilymemberBO.EthnicitesId.HasValue == false) ? patientfamilymemberDB.EthnicitesId : patientfamilymemberBO.EthnicitesId;
                    patientfamilymemberDB.GenderId       = (IsEditMode == true && patientfamilymemberBO.GenderId <= 0) ? patientfamilymemberDB.GenderId : patientfamilymemberBO.GenderId;
                    patientfamilymemberDB.CellPhone      = (IsEditMode == true && patientfamilymemberBO.CellPhone == null) ? patientfamilymemberDB.CellPhone : patientfamilymemberBO.CellPhone;
                    patientfamilymemberDB.WorkPhone      = (IsEditMode == true && patientfamilymemberBO.WorkPhone == null) ? patientfamilymemberDB.WorkPhone : patientfamilymemberBO.WorkPhone;
                    patientfamilymemberDB.PrimaryContact = (IsEditMode == true && patientfamilymemberBO.PrimaryContact == null) ? patientfamilymemberDB.PrimaryContact : patientfamilymemberBO.PrimaryContact;

                    if (Add_patientfamilymemberDB == true)
                    {
                        patientfamilymemberDB = _context.PatientFamilyMembers.Add(patientfamilymemberDB);
                    }
                    _context.SaveChanges();
                }
                else
                {
                    dbContextTransaction.Rollback();
                    return(new BO.ErrorObject {
                        errorObject = "", ErrorMessage = "Please pass valid Patient details.", ErrorLevel = ErrorLevel.Error
                    });
                }

                _context.SaveChanges();
                #endregion

                dbContextTransaction.Commit();

                patientfamilymemberDB = _context.PatientFamilyMembers.Where(p => p.Id == patientfamilymemberDB.Id).FirstOrDefault <PatientFamilyMember>();
            }

            var res = Convert <BO.PatientFamilyMember, PatientFamilyMember>(patientfamilymemberDB);
            return((object)res);
        }