Esempio n. 1
0
        public DemographicData GetDemographicById(string userName)
        {
            AspNetUser              user                    = _dbContext.AspNetUsers.SingleOrDefault(x => x.UserName == userName);
            int                     patientId               = _dbContext.PatientMasters.Where(x => x.UserLoginDetailsId == user.Id).SingleOrDefault().Id;
            PatientMaster           patientMaster           = _dbContext.PatientMasters.SingleOrDefault(x => x.Id == patientId);
            PatientEmergencyContact patientEmergencyContact = _dbContext.PatientEmergencyContacts.SingleOrDefault(x => x.PatientId == patientId);
            DemographicData         data                    = new DemographicData();

            if (patientEmergencyContact != null)
            {
                data = new DemographicData
                {
                    id                  = patientEmergencyContact.Id,
                    patientid           = patientMaster.Id,
                    race                = patientMaster.Race,
                    ethnicity           = patientMaster.Ethnicity,
                    languagesKnown      = patientMaster.LanguagesKnown,
                    address             = patientMaster.Address,
                    nomineeFirstName    = patientEmergencyContact.FirstName,
                    nomineeLastName     = patientEmergencyContact.LastName,
                    nomineeAddress      = patientEmergencyContact.Address,
                    nomineeEmail        = patientEmergencyContact.Email,
                    nomineeContact      = patientEmergencyContact.ContactNumber,
                    nomineeRelationship = patientEmergencyContact.Relationship,
                    isNeedportalAccess  = patientEmergencyContact.AccessPatientPortal
                };
            }
            return(data);
        }
Esempio n. 2
0
        public ResultModel AddPatientDemographicData(string userName, DemographicData demographicData)
        {
            ResultModel   rs            = new ResultModel();
            AspNetUser    user          = _dbContext.AspNetUsers.SingleOrDefault(x => x.UserName == userName);
            PatientMaster patientMaster = _dbContext.PatientMasters.SingleOrDefault(x => x.UserLoginDetailsId == user.Id);

            if (patientMaster != null)
            {
                patientMaster.Race           = demographicData.race;
                patientMaster.Ethnicity      = demographicData.ethnicity;
                patientMaster.Address        = demographicData.address;
                patientMaster.LanguagesKnown = demographicData.languagesKnown;
                patientMaster.ModifiedOn     = DateTime.Now;
                _dbContext.SaveChanges();
                rs.Code = 1;
            }
            PatientEmergencyContact patientEmergencyContact = _dbContext.PatientEmergencyContacts.SingleOrDefault(x => x.PatientId == patientMaster.Id);

            if (patientEmergencyContact == null)
            {
                PatientEmergencyContact patientEmergencyContact1 = new PatientEmergencyContact
                {
                    FirstName           = demographicData.nomineeFirstName,
                    LastName            = demographicData.nomineeLastName,
                    Email               = demographicData.nomineeEmail,
                    Relationship        = demographicData.nomineeRelationship,
                    ContactNumber       = demographicData.nomineeContact,
                    PatientId           = patientMaster.Id,
                    Address             = demographicData.nomineeAddress,
                    AccessPatientPortal = demographicData.isNeedportalAccess,
                    CreatedOn           = DateTime.Now,
                    ModifiedOn          = DateTime.Now,
                    IsActive            = true
                };
                _dbContext.PatientEmergencyContacts.Add(patientEmergencyContact1);
                _dbContext.SaveChanges();
                rs.Code     = 1;
                rs.Response = "Demographic data saved successfully";
            }
            else
            {
                patientEmergencyContact.FirstName           = demographicData.nomineeFirstName;
                patientEmergencyContact.LastName            = demographicData.nomineeLastName;
                patientEmergencyContact.Email               = demographicData.nomineeEmail;
                patientEmergencyContact.Relationship        = demographicData.nomineeRelationship;
                patientEmergencyContact.ContactNumber       = demographicData.nomineeContact;
                patientEmergencyContact.PatientId           = patientMaster.Id;
                patientEmergencyContact.Address             = demographicData.nomineeAddress;
                patientEmergencyContact.AccessPatientPortal = demographicData.isNeedportalAccess;
                patientEmergencyContact.ModifiedOn          = DateTime.Now;
                patientEmergencyContact.IsActive            = true;
                _dbContext.SaveChanges();
                rs.Code     = 1;
                rs.Response = "Demographic data saved successfully";
            }
            return(rs);
        }