public async Task <HttpResponseMessage> RemovePatientAllergy(long allergyID)
        {
            try
            {
                PatientAllergy pallergy = db.PatientAllergies.Where(all => all.allergiesID == allergyID && all.active == true).FirstOrDefault();

                if (pallergy == null)
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Allergy not found."
                    });
                    return(response);
                }
                pallergy.active          = false;//Delete Operation changed
                pallergy.mb              = pallergy.patientID.ToString();
                pallergy.md              = System.DateTime.Now;
                db.Entry(pallergy).State = EntityState.Modified;
                await db.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(ThrowError(ex, "DeletePatientAllergy in PatientAllergiesController."));
            }

            response = Request.CreateResponse(HttpStatusCode.OK, new ApiResultModel {
                ID = allergyID, message = ""
            });
            return(response);
        }
Exemple #2
0
        public static void UpdatePatientAllergy(PatientAllergyBE patientAllergyBE, Guid lastAccessUserId)
        {
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                PatientAllergy patientAllergy_db = dc.PatientAllergies.Where(p => p.PatientId.Equals(patientAllergyBE.PatientId)).FirstOrDefault <PatientAllergy>();

                patientAllergy_db.AnimalAllergy      = patientAllergyBE.AnimalAllergy;
                patientAllergy_db.ChemicalAllergy    = patientAllergyBE.ChemicalAllergy;
                patientAllergy_db.FoodAllergy        = patientAllergyBE.FoodAllergy;
                patientAllergy_db.InsectAllergy      = patientAllergyBE.InsectAllergy;
                patientAllergy_db.MedicamentsAllergy = patientAllergyBE.MedicamentsAllergy;
                patientAllergy_db.MiteAllergy        = patientAllergyBE.MiteAllergy;
                patientAllergy_db.PollenAllergy      = patientAllergyBE.PollenAllergy;
                patientAllergy_db.SunAllergy         = patientAllergyBE.SunAllergy;

                patientAllergy_db.Observation  = patientAllergyBE.Observation;
                patientAllergy_db.OtherAllergy = patientAllergyBE.OtherAllergy;

                patientAllergy_db.GeneralDetails   = patientAllergyBE.GeneralDetails;
                patientAllergy_db.Enabled          = patientAllergyBE.Enabled;
                patientAllergy_db.LastAccessTime   = System.DateTime.Now;
                patientAllergy_db.LastAccessUserId = lastAccessUserId;
                dc.SaveChanges();
            }
        }
Exemple #3
0
        public static void CreatePatientAllergy(PatientAllergyBE patientAllergyBE, Guid lastAccessUserId)
        {
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                PatientAllergy patientAllergy_db = new PatientAllergy();
                patientAllergy_db.PatientId = patientAllergyBE.PatientId;

                patientAllergy_db.AnimalAllergy      = patientAllergyBE.AnimalAllergy;
                patientAllergy_db.ChemicalAllergy    = patientAllergyBE.ChemicalAllergy;
                patientAllergy_db.FoodAllergy        = patientAllergyBE.FoodAllergy;
                patientAllergy_db.InsectAllergy      = patientAllergyBE.InsectAllergy;
                patientAllergy_db.MedicamentsAllergy = patientAllergyBE.MedicamentsAllergy;
                patientAllergy_db.MiteAllergy        = patientAllergyBE.MiteAllergy;
                patientAllergy_db.PollenAllergy      = patientAllergyBE.PollenAllergy;
                patientAllergy_db.SunAllergy         = patientAllergyBE.SunAllergy;

                patientAllergy_db.Observation  = patientAllergyBE.Observation;
                patientAllergy_db.OtherAllergy = patientAllergyBE.OtherAllergy;


                patientAllergy_db.GeneralDetails   = patientAllergyBE.GeneralDetails;
                patientAllergy_db.MedicalEventId   = patientAllergyBE.MedicalEventId;
                patientAllergy_db.Enabled          = true;
                patientAllergy_db.LastAccessTime   = System.DateTime.Now;
                patientAllergy_db.LastAccessUserId = lastAccessUserId;

                dc.PatientAllergies.AddObject(patientAllergy_db);
                dc.SaveChanges();
            }
        }
Exemple #4
0
        public ResultModel AddPatientAllergy(string userName, AllergyModel allergyModel)
        {
            ResultModel rs = new ResultModel();
            //var patientId = from a in _dbContext.UserLoginDetails //.Where(x => x.Username == userName)
            //                join b in _dbContext.PatientMasters
            //                on new { cond1 = a.Id.ToString() } equals new { cond1 = b.UserLoginDetailsId } into lg
            //                from p in lg.DefaultIfEmpty()
            //                select new { Id = p.Id };

            AspNetUser user      = _dbContext.AspNetUsers.SingleOrDefault(x => x.UserName == userName);
            int        patientId = _dbContext.PatientMasters.Where(x => x.UserLoginDetailsId == user.Id).SingleOrDefault().Id;

            PatientAllergy allergy = new PatientAllergy
            {
                PatientId    = patientId,
                AllergyId    = GetAllergyId(allergyModel.allergy),
                FatalAllergy = allergyModel.isfatal,
                CreatedOn    = DateTime.Now,
                ModifiedOn   = DateTime.Now,
                IsActive     = true
            };

            _dbContext.PatientAllergies.Add(allergy);
            _dbContext.SaveChanges();
            rs.Code     = 1;
            rs.Response = "Allergy data saved successfully";
            return(rs);
        }
Exemple #5
0
        public async Task <IActionResult> UpdatePatientAllergy(Guid uid, Guid uidAllergy,
                                                               [FromBody] PatientAllergyViewModel patientAllergy)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest("Bad data"));
            }

            // Save to the database
            PatientAllergy results = this.unitOfWork.Patients.GetPatientAllergy(uid, uidAllergy);

            if (results == null || results.Id.Equals(Guid.Empty))
            {
                return(this.BadRequest("User does not exist"));
            }

            if (!string.IsNullOrWhiteSpace(patientAllergy.Note))
            {
                results.Note = patientAllergy.Note;
            }

            if (patientAllergy.LastOcurrence != DateTime.MinValue)
            {
                results.LastOcurrence = patientAllergy.LastOcurrence;
            }

            if (patientAllergy.AssertedDate != DateTime.MinValue)
            {
                results.AssertedDate = patientAllergy.AssertedDate;
            }


            this.unitOfWork.Patients.UpdatePatientAllergy(results);
            return(this.Ok(this.mapper.Map <PatientAllergyViewModel>(results)));
        }
        public async Task <HttpResponseMessage> AddPatientAllergy(PatientAllergies_Custom model)
        {
            PatientAllergy pallergy = new PatientAllergy();

            try
            {
                if (model.allergyName == "" || model.allergyName == null || !Regex.IsMatch(model.allergyName.Trim(), "^[0-9a-zA-Z ]+$"))
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Invalid allergy name. Only letters and numbers are allowed."
                    });
                    return(response);
                }
                if (model.patientID == 0)
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Invalid patient ID."
                    });
                    return(response);
                }

                pallergy = db.PatientAllergies.Where(all => all.patientID == model.patientID && all.allergyName.Trim() == model.allergyName.Trim() && all.active == true).FirstOrDefault();

                if (pallergy == null)
                {
                    pallergy              = new PatientAllergy();
                    pallergy.active       = true;
                    pallergy.allergyName  = model.allergyName;
                    pallergy.severity     = model.severity;
                    pallergy.reaction     = model.reaction;
                    pallergy.patientID    = model.patientID;
                    pallergy.cd           = System.DateTime.Now;
                    pallergy.source       = "S";
                    pallergy.reportedDate = System.DateTime.Now;
                    pallergy.cb           = pallergy.patientID.ToString();

                    db.PatientAllergies.Add(pallergy);
                    await db.SaveChangesAsync();
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, new ApiResultModel {
                        ID = 0, message = "Allergy already exists."
                    });
                    response.ReasonPhrase = "Allergy already exists";
                    return(response);
                }
            }
            catch (Exception ex)
            {
                return(ThrowError(ex, "AddPatientAllergy in PatientAllergiesController."));
            }


            response = Request.CreateResponse(HttpStatusCode.OK, new ApiResultModel {
                ID = pallergy.allergiesID, message = ""
            });
            return(response);
        }
Exemple #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            PatientAllergy patientAllergy = db.PatientAllergies.Find(id);

            db.PatientAllergies.Remove(patientAllergy);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public bool RemoveAllergy(Guid idPatient, Guid idAllergy)
        {
            PatientAllergy pa = this.context.PatientAllergies.Where(p => p.IdAllergy == idAllergy)
                                .Where(a => a.IdPatient == idPatient).First();

            this.context.PatientAllergies.Remove(pa);
            this.context.SaveChanges();
            return(true);
        }
Exemple #9
0
 public ActionResult Edit([Bind(Include = "PatientAllergyID,PatientID,AllergiesID")] PatientAllergy patientAllergy)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patientAllergy).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PatientID = new SelectList(db.Patients, "PatientID", "FirstName", patientAllergy.PatientID);
     return(View(patientAllergy));
 }
        public void TestPatietnAllergyClass()
        {
            PatientAllergy pa = new PatientAllergy();

            pa.patientId = 1;
            pa.allergyId = 1;

            Assert.IsNotNull(pa);
            Assert.AreEqual(1, pa.patientId);
            Assert.AreEqual(1, pa.allergyId);
        }
Exemple #11
0
        // GET: PatientAllergies/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PatientAllergy patientAllergy = db.PatientAllergies.Find(id);

            if (patientAllergy == null)
            {
                return(HttpNotFound());
            }
            return(View(patientAllergy));
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patientId"></param>
        /// <returns></returns>
        public static PatientAllergyBE GetPatientAllergy(int patientId)
        {
            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                PatientAllergy patientAllergy_db = dc.PatientAllergies.Where(p => p.PatientId.Equals(patientId) && p.Enabled.Equals(true)).FirstOrDefault <PatientAllergy>();

                if (patientAllergy_db != null)
                {
                    return((PatientAllergyBE)patientAllergy_db);
                }

                return(null);
            }
        }
Exemple #13
0
        public static void Create_PatientAllergy_History(PatientAllergyBE patientAllergyBE, Guid lastAccessUserId)
        {
            CreatePatientAllergy(patientAllergyBE, lastAccessUserId);

            using (Health.Back.BE.HealthEntities dc = new Health.Back.BE.HealthEntities(Common.CnnString_Entities))
            {
                PatientAllergy atientAllergy_new = dc.PatientAllergies.Where(p => p.PatientId.Equals(patientAllergyBE.PatientId)).FirstOrDefault <PatientAllergy>();

                atientAllergy_new.Enabled = false;

                atientAllergy_new.LastAccessTime   = System.DateTime.Now;
                atientAllergy_new.LastAccessUserId = lastAccessUserId;
                dc.SaveChanges();
            }
        }
Exemple #14
0
        public PatientAllergy InitializePatientAllergy(PostInitializePatientAllergyRequest request)
        {
            PatientAllergy patientAllergy = null;

            try
            {
                PatientAllergyData data = EndpointUtil.InitializePatientAllergy(request);
                if (data != null)
                {
                    patientAllergy = Mapper.Map <PatientAllergy>(data);
                }
                return(patientAllergy);
            }
            catch (Exception ex) { throw ex; }
        }
Exemple #15
0
        // GET: PatientAllergies/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PatientAllergy patientAllergy = db.PatientAllergies.Find(id);

            if (patientAllergy == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PatientID = new SelectList(db.Patients, "PatientID", "FirstName", patientAllergy.PatientID);
            return(View(patientAllergy));
        }
Exemple #16
0
        private static void insertPatientAllergy(PatientAllergy patientAllergy)
        {
            myConnection.Open();

            SqlCommand cmd = new SqlCommand("insert into PatientAllergy(patientID, allergyID) values(@pt_Id, @allergy_Id);");

            cmd.Connection = myConnection;

            cmd.Parameters.AddWithValue("@pt_Id", patientAllergy.patientId);
            cmd.Parameters.AddWithValue("@allergy_Id", patientAllergy.allergyId);

            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();


            myConnection.Close();
        }
 /// <summary>
 /// Removes a PatientAllergy from the Repository.
 /// </summary>
 /// <param name="entity">The PatientAllergy to remove from the Repository.</param>
 public void Remove(PatientAllergy entity)
 {
     Session.Delete(entity);
 }
 /// <summary>
 /// Adds a PatientAllergy to the Repository.
 /// </summary>
 /// <param name="entity">The PatientAllergy to add to the Repository.</param>
 public void Add(PatientAllergy entity)
 {
     Session.Save(entity);
 }
Exemple #19
0
        private void btnAddRecord_Click(object sender, EventArgs e)
        {
            bool DOB_valid;
            bool exp_valid;
            bool pass = false;

            //check whether Insurance numer exits
            dictionary = new Dictionary <string, string>();
            dictionary.Add("@insuranceNumber", txtInsuranceNumber.Text);
            dc          = new DatabaseConnector();
            dtInsurance = dc.getData("CheckInsuranceExists", dictionary);
            int ins_exist = int.Parse(dtInsurance.Rows[0][0].ToString());

            //create new patient
            Patient patient = new Patient();

            patient.firstName = txtFirstName.Text;
            patient.lastName  = txtLastName.Text;
            patient.dob       = txtDOB.Text;
            patient.gender    = cmbxGender.GetItemText(cmbxGender.SelectedItem);

            //create new insurance
            Insurance insurance = new Insurance();

            insurance.timestamp   = (DateTime.Now).ToString();
            insurance.insNumber   = txtInsuranceNumber.Text;
            insurance.versionCode = txtVersionCode.Text;
            insurance.expDate     = txtInsuranceExpDate.Text;

            //create new allergy
            Allergy allergy = new Allergy();

            allergy.name     = txtAllergyName.Text;
            allergy.category = txtAllergyCatergory.Text;

            //create new allergy-patient
            PatientAllergy ptAllgergy = new PatientAllergy();

            //ins number : number only
            //ins vc : character only
            //no blank: name, dob

            Phone phone = new Phone();

            phone.type        = cmbxPhoneType.GetItemText(cmbxPhoneType.SelectedItem);
            phone.phoneNumber = txtPhoneNumber.Text;

            Email email = new Email();

            email.type  = cmbxEmailType.GetItemText(cmbxEmailType.SelectedItem);
            email.email = txtEmail.Text;

            Address address = new Address();

            address.type       = cmbxAddressType.GetItemText(cmbxAddressType.SelectedItem);
            address.address    = txtAddress.Text;
            address.city       = txtCity.Text;
            address.province   = txtProvince.Text;
            address.postalCode = txtPostalCode.Text;

            DOB_valid = DOB_validation();
            exp_valid = exp_validation();

            if (DOB_valid == true && exp_valid == true && ins_exist == 0 && txtInsuranceNumber.TextLength == 10)
            {
                pass = true;
            }

            if (pass == true)
            {
                insertPatient(patient);

                patient.patientID   = getPtIdfromPatienTbl();
                insurance.patientID = patient.patientID;
                phone.patientID     = patient.patientID;
                email.patientID     = patient.patientID;
                address.patientID   = patient.patientID;


                insertInsurance(insurance);

                if (getAllergyIdfromAllergyTbl() != 0)
                {
                    ptAllgergy.patientId = patient.patientID;
                    ptAllgergy.allergyId = getAllergyIdfromAllergyTbl();
                    insertPatientAllergy(ptAllgergy);
                }
                else
                {
                    insertAllergy(allergy);
                    ptAllgergy.patientId = patient.patientID;
                    ptAllgergy.allergyId = getAllergyIdfromAllergyTbl2();
                    insertPatientAllergy(ptAllgergy);
                }

                insertPhone(phone);
                insertAdress(address);
                insertEmail(email);

                clearText();
                MessageBox.Show("Patient was registed");
            }

            else if (txtInsuranceNumber.TextLength != 10)   //number incorrect of left blank
            {
                MessageBox.Show("Please insert correct insurance number");
            }
            else if (ins_exist != 0)
            {
                MessageBox.Show("Insurance Number already exists");
            }
            else if (DOB_valid == false)
            {
                MessageBox.Show("D.O.B not valid");
            }

            else if (exp_valid == false)
            {
                MessageBox.Show("Insurance Expiry Date not valid");
            }
        }
Exemple #20
0
 public PatientAllergyControl()
 {
     InitializeComponent();
     DataContext = new PatientAllergy();
 }
Exemple #21
0
        public void UpdatePatientAllergies_Test()
        {
            List <PatientAllergy> data = new System.Collections.Generic.List <PatientAllergy>();

            PatientAllergy p1 = new PatientAllergy
            {
                AllergyId    = "54580a9b84ac05021485f632",
                IsNewAllergy = true,
                //AllergyName = "Cat dander",
                EndDate     = DateTime.UtcNow,
                Id          = "54580a9d84ac05021485f637",
                Notes       = "AAAAAAAAA",
                PatientId   = "5325daebd6a4850adcbba7be",
                ReactionIds = new List <string> {
                    "54494b5ad433232a446f7323"
                },
                SeverityId     = "54494a8fd433232a446f7311",
                SourceId       = "544e9976d433231d9c0330ae",
                StartDate      = DateTime.UtcNow,
                StatusId       = 1,
                SystemName     = "Engage",
                UpdatedOn      = DateTime.UtcNow,
                DeleteFlag     = false,
                AllergyTypeIds = new List <string> {
                    "5447d6ddfe7a59146485b512", "5446db5efe7a591e74013b6b", "5446db5efe7a591e74013b6c"
                },
            };

            //PatientAllergy p2 = new PatientAllergy
            //{
            //    AllergyId = "5453e6bfd433230468567d33",
            //    IsNewAllergy = true,
            //    //AllergyName = "Cat dander",
            //    EndDate = DateTime.UtcNow,
            //    Id = "5453e7eb84ac0510a8f3ba88",
            //    Notes = "BBBBBBB",
            //    PatientId = "5325da1fd6a4850adcbba54a",
            //    //ReactionIds = new List<string> { "54494b5ad433232a446f7323" },
            //    //SeverityId = "54494a8fd433232a446f7311",
            //    UtilizationSourceId = "544e9976d433231d9c0330ae",
            //    StartDate = DateTime.UtcNow,
            //    StatusId = 2,
            //    SystemName = "Integration",
            //    UpdatedOn = DateTime.UtcNow,
            //    DeleteFlag = false,
            //    AllergyTypeIds = new List<string> { "5446db5efe7a591e74013b6d" },
            //};
            data.Add(p1);
            //data.Add(p2);
            PostPatientAllergiesRequest request = new PostPatientAllergiesRequest
            {
                ContractNumber   = contractNumber,
                PatientAllergies = data,
                UserId           = userId,
                Version          = version
            };

            JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "Token", token));
            //[Route("/{Version}/{ContractNumber}/PatientAllergy/Update", "POST")]
            PostPatientAllergiesResponse response = client.Post <PostPatientAllergiesResponse>(
                string.Format("{0}/{1}/{2}/PatientAllergy/Update", url, version, contractNumber), request);

            Assert.IsNotNull(response);
        }
 public bool UpdatePatientAllergy(PatientAllergy patientAllergy)
 {
     this.context.PatientAllergies.Update(patientAllergy);
     this.context.SaveChanges();
     return(true);
 }
 public bool AddAllergy(PatientAllergy patientAllergy)
 {
     this.context.PatientAllergies.Add(patientAllergy);
     this.context.SaveChanges();
     return(true);
 }