Ejemplo n.º 1
0
        public override T Convert <T, U>(U entity)
        {
            PatientFamilyMember patientfamilymember = entity as PatientFamilyMember;

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

            BO.PatientFamilyMember patientfamilymemberBO = new BO.PatientFamilyMember();

            patientfamilymemberBO.ID             = patientfamilymember.Id;
            patientfamilymemberBO.CaseId         = patientfamilymember.CaseId;
            patientfamilymemberBO.RelationId     = patientfamilymember.RelationId;
            patientfamilymemberBO.FirstName      = patientfamilymember.FirstName;
            patientfamilymemberBO.MiddleName     = patientfamilymember.MiddleName;
            patientfamilymemberBO.LastName       = patientfamilymember.LastName;
            patientfamilymemberBO.Age            = patientfamilymember.Age;
            patientfamilymemberBO.RaceId         = (byte)patientfamilymember.RaceId;
            patientfamilymemberBO.EthnicitesId   = (byte)patientfamilymember.EthnicitesId;
            patientfamilymemberBO.GenderId       = (byte)patientfamilymember.GenderId;
            patientfamilymemberBO.CellPhone      = patientfamilymember.CellPhone;
            patientfamilymemberBO.WorkPhone      = patientfamilymember.WorkPhone;
            patientfamilymemberBO.PrimaryContact = patientfamilymember.PrimaryContact;
            patientfamilymemberBO.IsDeleted      = patientfamilymember.IsDeleted;
            patientfamilymemberBO.CreateByUserID = patientfamilymember.CreateByUserID;
            patientfamilymemberBO.UpdateByUserID = patientfamilymember.UpdateByUserID;



            return((T)(object)patientfamilymemberBO);
        }
 public HttpResponseMessage Post([FromBody] PatientFamilyMember data)
 {
     return(requestHandler.CreateGbObject(Request, data));
 }
Ejemplo n.º 3
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);
        }