Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("AllergyId,PatientId,IngredientId,Type,Notes")] Allergy allergy)
        {
            if (id != allergy.AllergyId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(allergy);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AllergyExists(allergy.AllergyId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["IngredientId"] = new SelectList(_context.Ingredients, "IngredientId", "Name", allergy.IngredientId);
            ViewData["PatientId"]    = new SelectList(_context.Patients, "PatientId", "Name", allergy.PatientId);
            return(View(allergy));
        }
Exemplo n.º 2
0
 ///<summary>Inserts one Allergy into the database.  Returns the new priKey.</summary>
 internal static long Insert(Allergy allergy)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         allergy.AllergyNum=DbHelper.GetNextOracleKey("allergy","AllergyNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(allergy,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     allergy.AllergyNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(allergy,false);
     }
 }
Exemplo n.º 3
0
        public void AddPersonDiseaseInfo(string doctorId, string personId, PersonDiseaseInfoInputModel diseaseInputModel)
        {
            Allergy allergy   = null;
            int     allergyId = this.allergiesService.GetAllergyId(diseaseInputModel.Name);

            if (allergyId == 0)
            {
                allergyId = allergiesService.Add(diseaseInputModel.Name);
                allergy   = this.allergiesService.GetAllergy(allergyId);
            }
            else
            {
                allergy = this.allergiesService.GetAllergy(allergyId);
            }

            PersonAllergy personAllergy = new PersonAllergy()
            {
                DoctorId    = doctorId,
                PersonId    = personId,
                Allergy     = allergy,
                DiagnosedOn = DateTime.Parse(diseaseInputModel.DiagnosedOn)
            };

            this.db.PersonAllergies.Add(personAllergy);
            this.db.SaveChanges();
        }
Exemplo n.º 4
0
 ///<summary>Inserts one Allergy into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Allergy allergy,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         allergy.AllergyNum=ReplicationServers.GetKey("allergy","AllergyNum");
     }
     string command="INSERT INTO allergy (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="AllergyNum,";
     }
     command+="AllergyDefNum,PatNum,Reaction,StatusIsActive,DateAdverseReaction) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(allergy.AllergyNum)+",";
     }
     command+=
              POut.Long  (allergy.AllergyDefNum)+","
         +    POut.Long  (allergy.PatNum)+","
         +"'"+POut.String(allergy.Reaction)+"',"
         +    POut.Bool  (allergy.StatusIsActive)+","
         //DateTStamp can only be set by MySQL
         +    POut.Date  (allergy.DateAdverseReaction)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         allergy.AllergyNum=Db.NonQ(command,true);
     }
     return allergy.AllergyNum;
 }
Exemplo n.º 5
0
 ///<summary>Inserts one Allergy into the database.  Returns the new priKey.</summary>
 internal static long Insert(Allergy allergy)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         allergy.AllergyNum = DbHelper.GetNextOracleKey("allergy", "AllergyNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(allergy, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     allergy.AllergyNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(allergy, false));
     }
 }
Exemplo n.º 6
0
        private Allergy BuildAllergy(Patient patient, AllergyStatus allergyStatus, CodedConcept allergen)
        {
            var allergy = new Allergy(patient, allergyStatus, allergen);

            Session.SaveOrUpdate(allergy);
            return(allergy);
        }
        private bool MapAllergyProperties(AllergyDto allergyDto, Allergy allergy)
        {
            var allergySeverityType = _mappingHelper.MapLookupField <AllergySeverityType> (allergyDto.AllergySeverityType);
            var allergyType         = _mappingHelper.MapLookupField <AllergyType> (allergyDto.AllergyType);
            var allergyStatus       = _mappingHelper.MapLookupField <AllergyStatus> (allergyDto.AllergyStatus);

            CodedConcept allergen = null;

            if (allergyDto.AllergenCodedConcept != null)
            {
                allergen = new CodedConceptBuilder().WithCodedConceptDto(allergyDto.AllergenCodedConcept);
            }

            allergy.ReviseAllergySeverityType(allergySeverityType);
            allergy.ReviseAllergyType(allergyType);
            allergy.ReviseOnsetDateRange(new DateRange(allergyDto.OnsetStartDate, allergyDto.OnsetEndDate));
            allergy.ReviseAllergyStatus(allergyStatus);
            allergy.ReviseCodedConcept(allergen);

            // Map reactions
            var deletedReactions = allergy.AllergyReactions.Where(
                a => !allergyDto.AllergyReactions.Any(ad => ad.Key == a.Reaction.Key)).ToList();

            deletedReactions.ForEach(allergy.DeleteReaction);

            var addedReactions = allergyDto.AllergyReactions.Where(
                a => !allergy.AllergyReactions.Any(ad => ad.Reaction.Key == a.Key)).ToList();

            addedReactions.ForEach(r => allergy.AddReaction(_mappingHelper.MapLookupField <Reaction> (r)));

            return(true);
        }
        public Allergy CreateAllergy(PatientAllergyDetail detail, IPersistenceContext context)
        {
            var allergy = new Allergy();

            UpdateAllergy(allergy, detail, context);
            return(allergy);
        }
Exemplo n.º 9
0
        public async Task <IActionResult> CreateAllergy([FromBody] AllergyViewModel allergy)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest("Bad data"));
            }

            try
            {
                // Save to the database
                Allergy newAllergy = this.mapper.Map <Allergy>(allergy);
                if (allergy.Id.Equals(Guid.Empty))
                {
                    newAllergy.Id = Guid.NewGuid();
                }

                await this.unitOfWork.Allergies.Add(newAllergy);

                return(this.Ok(this.mapper.Map <AllergyViewModel>(newAllergy)));
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Failed to create the allergy: {ex}");
                return(this.BadRequest("Error Occurred"));
            }
        }
Exemplo n.º 10
0
        public async Task <long> CreateAllergyAsync(Allergy allergy)
        {
            using IDbConnection connection = new SqliteConnection(_databaseConfig.Name);
            var sql = @"INSERT INTO allergy (name, created_by) VALUES (@Name, @CreatedBy);";

            return(await connection.QuerySingleAsync <long>(sql, allergy));
        }
Exemplo n.º 11
0
        public async Task <IHttpActionResult> PutAllergy(long id, Allergy allergy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != allergy.allergyID)
            {
                return(BadRequest());
            }

            db.Entry(allergy).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllergyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 12
0
        public async Task <IActionResult> PutAllergy(long id, Allergy allergy)
        {
            if (id != allergy.ID)
            {
                return(BadRequest());
            }

            _context.Entry(allergy).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllergyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 13
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameTxt.BackColor = Color.Red;
                return;
            }

            string id = Guid.NewGuid().ToString();

            if (chronicBtn.Checked == true)
            {
                _chronic = new Chronic(id, nameTxt.Text, descriptionTxt.Text, PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);
                DBConnect.Insert(_chronic);
            }
            if (allergyBtn.Checked == true)
            {
                _allergy = new Allergy(id, nameTxt.Text, descriptionTxt.Text, PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);
                DBConnect.Insert(_allergy);
            }
            if (additBtn.Checked == true)
            {
                _addiction = new Addiction(id, nameTxt.Text, descriptionTxt.Text, PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);
                DBConnect.Insert(_addiction);
            }
            nameTxt.Text        = "";
            descriptionTxt.Text = "";

            MessageBox.Show("Information Saved");
            LoadAddiction(PatientID);
            LoadAllergy(PatientID);
            LoadChronic(PatientID);
        }
Exemplo n.º 14
0
        public IActionResult Put(int id, [FromBody] Allergy allergy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != allergy.AllergyId)
            {
                return(BadRequest());
            }

            _context.Entry(allergy).State = EntityState.Modified;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AllergyExists(allergy.AllergyId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(new StatusCodeResult(StatusCodes.Status204NoContent));
        }
Exemplo n.º 15
0
 ///<summary>Returns true if Update(Allergy,Allergy) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(Allergy allergy, Allergy oldAllergy)
 {
     if (allergy.AllergyDefNum != oldAllergy.AllergyDefNum)
     {
         return(true);
     }
     if (allergy.PatNum != oldAllergy.PatNum)
     {
         return(true);
     }
     if (allergy.Reaction != oldAllergy.Reaction)
     {
         return(true);
     }
     if (allergy.StatusIsActive != oldAllergy.StatusIsActive)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     if (allergy.DateAdverseReaction.Date != oldAllergy.DateAdverseReaction.Date)
     {
         return(true);
     }
     if (allergy.SnomedReaction != oldAllergy.SnomedReaction)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 16
0
        ///<summary>Inserts one Allergy into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(Allergy allergy, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                allergy.AllergyNum = ReplicationServers.GetKey("allergy", "AllergyNum");
            }
            string command = "INSERT INTO allergy (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "AllergyNum,";
            }
            command += "AllergyDefNum,PatNum,Reaction,StatusIsActive,DateAdverseReaction) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(allergy.AllergyNum) + ",";
            }
            command +=
                POut.Long(allergy.AllergyDefNum) + ","
                + POut.Long(allergy.PatNum) + ","
                + "'" + POut.String(allergy.Reaction) + "',"
                + POut.Bool(allergy.StatusIsActive) + ","
                //DateTStamp can only be set by MySQL
                + POut.Date(allergy.DateAdverseReaction) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                allergy.AllergyNum = Db.NonQ(command, true);
            }
            return(allergy.AllergyNum);
        }
Exemplo n.º 17
0
        public async Task <long> DeletePatientAllergyAsync(long patientId, Allergy allergy)
        {
            using IDbConnection connection = new SqliteConnection(_databaseConfig.Name);
            var sql = @"DELETE patient_allergies WHERE patient_id = @PatientId and allergy_id = @AllergyId;";

            return(await connection.QuerySingleAsync <long>(sql, new { PatientId = patientId, AllergyId = allergy.Id }));
        }
Exemplo n.º 18
0
        public async Task <IActionResult> UpdateAllergy(Guid uid, [FromBody] AllergyViewModel allergy)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest("Bad data"));
            }

            // Save to the database
            Allergy results = await this.unitOfWork.Allergies.Get(uid);

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

            if (!string.IsNullOrWhiteSpace(allergy.Name))
            {
                results.Name = allergy.Name;
            }

            if (!string.IsNullOrWhiteSpace(allergy.Signs))
            {
                results.Signs = allergy.Signs;
            }

            if (!string.IsNullOrWhiteSpace(allergy.Symptoms))
            {
                results.Symptoms = allergy.Symptoms;
            }

            await this.unitOfWork.Allergies.Update(results);

            return(this.Ok(this.mapper.Map <AllergyViewModel>(results)));
        }
Exemplo n.º 19
0
        public async Task <ActionResult <Allergy> > PostAllergy(Allergy allergy)
        {
            _context.Allergies.Add(allergy);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAllergy", new { id = allergy.ID }, allergy));
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Remove(Guid uid)
        {
            try
            {
                if (uid.Equals(Guid.Empty))
                {
                    return(this.BadRequest("Bad data"));
                }

                Allergy allergyToDelete = await this.unitOfWork.Allergies.Get(uid);

                if (allergyToDelete == null)
                //TODO do here something general
                {
                    throw new PatientNotFoundException();
                }

                await this.unitOfWork.Allergies.Remove(allergyToDelete);

                return(this.Ok());
            }
            catch (Exception ex)
            {
                this.logger.LogError($"Failed to get the allergy: {ex}");
                return(this.BadRequest("Error Occurred"));
            }
        }
Exemplo n.º 21
0
 ///<summary>Inserts one Allergy into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Allergy allergy,bool useExistingPK)
 {
     bool isRandomKeys=Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
     string command="INSERT INTO allergy (";
     if(!useExistingPK && isRandomKeys) {
         allergy.AllergyNum=ReplicationServers.GetKeyNoCache("allergy","AllergyNum");
     }
     if(isRandomKeys || useExistingPK) {
         command+="AllergyNum,";
     }
     command+="AllergyDefNum,PatNum,Reaction,StatusIsActive,DateAdverseReaction,SnomedReaction) VALUES(";
     if(isRandomKeys || useExistingPK) {
         command+=POut.Long(allergy.AllergyNum)+",";
     }
     command+=
              POut.Long  (allergy.AllergyDefNum)+","
         +    POut.Long  (allergy.PatNum)+","
         +"'"+POut.String(allergy.Reaction)+"',"
         +    POut.Bool  (allergy.StatusIsActive)+","
         //DateTStamp can only be set by MySQL
         +    POut.Date  (allergy.DateAdverseReaction)+","
         +"'"+POut.String(allergy.SnomedReaction)+"')";
     if(useExistingPK || isRandomKeys) {
         Db.NonQ(command);
     }
     else {
         allergy.AllergyNum=Db.NonQ(command,true,"AllergyNum","allergy");
     }
     return allergy.AllergyNum;
 }
Exemplo n.º 22
0
        public ActionResult Create(Allergy d)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                var result = allergyService.Insertar(d);
                if (result)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Create"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error al agregar el Medicamento", ex);
                return(View());
            }
        }
Exemplo n.º 23
0
        public ActionResult Edit(Allergy d)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }

                using (var db = new Nu34lifeEntities())
                {
                    Allergy all = db.Allergies.Find(d);
                    all.Description   = d.Description;
                    all.Ingredient_Id = d.Ingredient_Id;
                    all.Patient_Id    = d.Patient_Id;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 24
0
        private void dtAllergy_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            string updateID = dtAllergy.Rows[e.RowIndex].Cells[0].Value.ToString();

            _allergy = new Allergy(updateID, dtAllergy.Rows[e.RowIndex].Cells[1].Value.ToString(), dtAllergy.Rows[e.RowIndex].Cells[2].Value.ToString(), PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);
            DBConnect.Update(_allergy, updateID);
        }
        public ActionResult Results()
        {
            Score          newScore     = new Score(int.Parse(Request.Form["score"]));
            List <Allergy> allAllergies = Allergy.GetAllAllergies();
            List <string>  finalList    = newScore.GetAllergyList(allAllergies);

            return(View(finalList));
        }
 public JObject Create(Allergy allergy)
 {
     _db.Allergies.Add(allergy);
     _db.SaveChanges();
     dynamic result = new JObject();
     result.result = "ok";
     return result;
 }
Exemplo n.º 27
0
 public ActionResult Details(int id)
 {
     using (var db = new Nu34lifeEntities())
     {
         Allergy i = db.Allergies.Find(id);
         return(View(i));
     }
 }
Exemplo n.º 28
0
        public IActionResult PostIndex()
        {
            int           userInput     = Convert.ToInt32(Request.Form["allergy-score"]);
            Allergy       myAllergy     = new Allergy();
            List <String> myAllergyList = myAllergy.GetAllergyList(userInput);

            return(View("index", myAllergyList));
        }
 public JObject Edit(Allergy allergy)
 {
     _db.Entry(allergy).State = EntityState.Modified;
     _db.SaveChanges();
     dynamic result = new JObject();
     result.result = "ok";
     return result;
 }
Exemplo n.º 30
0
        public async Task <long> UpdateAllergyAsync(Allergy allergy)
        {
            using IDbConnection connection = new SqliteConnection(_databaseConfig.Name);
            var sql = @"INSERT OR REPLACE INTO allergy (id, name, enabled, created_by, last_modified, last_modified_by) 
            VALUES (@Id, @Name, @Enabled, @CreatedBy, @LastModified, @LastModifiedBy);";

            return(await connection.QuerySingleAsync <long>(sql, allergy));
        }
Exemplo n.º 31
0
        public async Task AddAllergy(string pacientId, Allergy allergy)
        {
            allergy.Card = await _dbContext.Cards.Where(x => x.Pacient.Id == pacientId).FirstOrDefaultAsync();

            allergy.DateOfIssue = DateTime.Now;
            _dbContext.Allergies.Add(allergy);
            await _dbContext.SaveChangesAsync();
        }
Exemplo n.º 32
0
        public ActionResult DeleteConfirmed(int id)
        {
            Allergy allergy = db.Allergies.Find(id);

            db.Allergies.Remove(allergy);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public static AllergyDTO AllergyToDTO(Allergy allergy)
 {
     return(new AllergyDTO
     {
         Id = allergy.Id,
         Name = allergy.Name
     });
 }
Exemplo n.º 34
0
        public ActionResult Results()
        {
            Allergy       newAllergy = new Allergy(int.Parse(Request.Form["allergen-score"]));
            List <string> allergies  = new List <string>();

            allergies = newAllergy.GetAllergies();
            return(View(allergies));
        }
        public ActionResult Create(int medicalProfileId)
        {
            var allergyType = _db.AllergyTypes.ToList();
            ViewBag.AllergyTypeId = new SelectList(allergyType, "AllergyTypeId", "Name");

            var allergy = new Allergy
            {
                MedicalProfileId = medicalProfileId
            };
            return PartialView("_Create", allergy);
        }
Exemplo n.º 36
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Allergy> TableToList(DataTable table){
			List<Allergy> retVal=new List<Allergy>();
			Allergy allergy;
			for(int i=0;i<table.Rows.Count;i++) {
				allergy=new Allergy();
				allergy.AllergyNum         = PIn.Long  (table.Rows[i]["AllergyNum"].ToString());
				allergy.AllergyDefNum      = PIn.Long  (table.Rows[i]["AllergyDefNum"].ToString());
				allergy.PatNum             = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				allergy.Reaction           = PIn.String(table.Rows[i]["Reaction"].ToString());
				allergy.StatusIsActive     = PIn.Bool  (table.Rows[i]["StatusIsActive"].ToString());
				allergy.DateTStamp         = PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
				allergy.DateAdverseReaction= PIn.Date  (table.Rows[i]["DateAdverseReaction"].ToString());
				allergy.SnomedReaction     = PIn.String(table.Rows[i]["SnomedReaction"].ToString());
				retVal.Add(allergy);
			}
			return retVal;
		}
Exemplo n.º 37
0
		///<summary>Updates one Allergy in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(Allergy allergy,Allergy oldAllergy){
			string command="";
			if(allergy.AllergyDefNum != oldAllergy.AllergyDefNum) {
				if(command!=""){ command+=",";}
				command+="AllergyDefNum = "+POut.Long(allergy.AllergyDefNum)+"";
			}
			if(allergy.PatNum != oldAllergy.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(allergy.PatNum)+"";
			}
			if(allergy.Reaction != oldAllergy.Reaction) {
				if(command!=""){ command+=",";}
				command+="Reaction = '"+POut.String(allergy.Reaction)+"'";
			}
			if(allergy.StatusIsActive != oldAllergy.StatusIsActive) {
				if(command!=""){ command+=",";}
				command+="StatusIsActive = "+POut.Bool(allergy.StatusIsActive)+"";
			}
			//DateTStamp can only be set by MySQL
			if(allergy.DateAdverseReaction != oldAllergy.DateAdverseReaction) {
				if(command!=""){ command+=",";}
				command+="DateAdverseReaction = "+POut.Date(allergy.DateAdverseReaction)+"";
			}
			if(allergy.SnomedReaction != oldAllergy.SnomedReaction) {
				if(command!=""){ command+=",";}
				command+="SnomedReaction = '"+POut.String(allergy.SnomedReaction)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE allergy SET "+command
				+" WHERE AllergyNum = "+POut.Long(allergy.AllergyNum);
			Db.NonQ(command);
			return true;
		}
Exemplo n.º 38
0
        public ActionResult UpdateIngredients( int name, bool isChecked )
        {
            User user = (User)ControllerContext.HttpContext.Session["loggedInUser"];
            if (user != null)
            {
                User targetUser = entities.Users.Where(x => x.Id == userId).FirstOrDefault();

                if (isChecked == true)
                {
                    Allergy allergy = new Allergy()
                    {
                        User_Id = targetUser.Id,
                        Ingredient_Id = name
                    };

                    targetUser.Allergies.Add(allergy);
                }
                else
                {
                    Allergy a = targetUser.Allergies.Where(x => x.Ingredient_Id == name).FirstOrDefault();
                    targetUser.Allergies.Remove(a);
                }

                entities.SaveChanges();

                return View();
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }
Exemplo n.º 39
0
        internal IList<Allergy> toAllergiesFromXmlNode(XmlNode node)
        {
            IList<Allergy> allergies = new List<Allergy>();

            int total = verifyTopLevelNode(node);
            if (total == 0)
            {
                return allergies;
            }

            XmlNodeList allergyNodes = node.SelectNodes("/allergy");
            if (allergyNodes == null || allergyNodes.Count == 0)
            {
                return allergies;
            }

            foreach (XmlNode allergyNode in allergyNodes)
            {
                Allergy allergy = new Allergy();

                XmlNodeList drugClassesNodes = allergyNode.SelectNodes("drugClasses/drugClass");
                if (drugClassesNodes != null && drugClassesNodes.Count > 0)
                {
                    allergy.DrugClasses = new StringDictionary();
                    foreach (XmlNode drugClassNode in drugClassesNodes)
                    {
                        string vuid = XmlUtils.getXmlAttributeValue(drugClassNode, "/", "vuid");
                        string name = XmlUtils.getXmlAttributeValue(drugClassNode, "/", "name");
                        if (!String.IsNullOrEmpty(vuid))
                        {
                            allergy.DrugClasses.Add(vuid, name);
                        }
                    }
                }

                XmlNodeList drugIngredientsNodes = allergyNode.SelectNodes("drugIngredients/drugIngredient");
                if (drugIngredientsNodes != null && drugIngredientsNodes.Count > 0)
                {
                    allergy.DrugIngredients = new StringDictionary();
                    foreach (XmlNode drugIngredientNode in drugIngredientsNodes)
                    {
                        string vuid = XmlUtils.getXmlAttributeValue(drugIngredientNode, "/", "vuid");
                        string name = XmlUtils.getXmlAttributeValue(drugIngredientNode, "/", "name");
                        if (!String.IsNullOrEmpty(vuid))
                        {
                            allergy.DrugIngredients.Add(vuid, name);
                        }
                    }
                }

                XmlNodeList reactionsNodes = allergyNode.SelectNodes("reactions/reaction");
                if (reactionsNodes != null && reactionsNodes.Count > 0)
                {
                    allergy.Reactions = new List<Symptom>();
                    foreach (XmlNode reactionNode in reactionsNodes)
                    {
                        Symptom symptom = new Symptom();
                        symptom.Name = XmlUtils.getXmlAttributeValue(reactionNode, "/", "name");
                        symptom.Id = XmlUtils.getXmlAttributeValue(reactionNode, "/", "vuid");
                        allergy.Reactions.Add(symptom);
                    }
                }

                allergy.Timestamp = XmlUtils.getXmlAttributeValue(allergyNode, "entered", "value");
                allergy.AllergenId = XmlUtils.getXmlAttributeValue(allergyNode, "id", "value");
                allergy.AllergenName = XmlUtils.getXmlAttributeValue(allergyNode, "name", "value");
                allergy.AllergenType = XmlUtils.getXmlAttributeValue(allergyNode, "type", "name");
                allergy.Comment = XmlUtils.getXmlAttributeValue(allergyNode, "assessment", "value");
                allergy.Facility = new SiteId(XmlUtils.getXmlAttributeValue(allergyNode, "facility", "code"), XmlUtils.getXmlAttributeValue(allergyNode, "facility", "name"));

                allergies.Add(allergy);
            }

            return allergies;
        }
Exemplo n.º 40
0
		public static void ProcessAL1(Patient pat,HL7DefSegment segDef,SegmentHL7 seg) {
			//If there is an allergydef with SnomedType 2 or 3 (DrugAllergy or DrugIntolerance) with attached medication with RxCui=rxnorm supplied
			//And if there is not already an active allergy with that AllergyDefNum for the patient
			//Then insert an allergy with that AllergyDefNum for this patient
			long rxnorm=0;
			string strAllergenType="";
			for(int i=0;i<segDef.hl7DefFields.Count;i++) {
				int intItemOrder=segDef.hl7DefFields[i].OrdinalPos;
				switch(segDef.hl7DefFields[i].FieldName) {
					case "allergenType":
						strAllergenType=seg.GetFieldComponent(intItemOrder).ToLower();
						continue;
					case "allergenRxNorm":
						if(seg.GetFieldComponent(intItemOrder,2).ToLower()!="rxnorm") {
							//if not an RXNORM code, do nothing.  Only RXNORM codes are currently supported
							EventLog.WriteEntry("OpenDentHL7","A drug allergy was not added for patient "+pat.GetNameFLnoPref()
								+".  Only RxNorm codes are currently allowed in the AL1 segment.  The code system name provided was "
								+seg.GetFieldComponent(intItemOrder,2)+".",EventLogEntryType.Information);
							return;
						}
						try {
							rxnorm=PIn.Long(seg.GetFieldComponent(intItemOrder,0));
						}
						catch(Exception ex) {//PIn.Long throws an exception if converting to an Int64 fails
							//do nothing, rxnorm will remain 0
						}
						continue;
					default:
						continue;
				}
			}
			if(rxnorm==0 || strAllergenType!="da") {
				EventLog.WriteEntry("OpenDentHL7","A drug allergy was not added for patient "+pat.GetNameFLnoPref()
					+".  Only drug allergies, identified by type 'DA', are currently allowed in the AL1 segment.  The allergen type received was '"
					+strAllergenType+"'.",EventLogEntryType.Information);
				return;//not able to assign drug allergy if not given a valid rxnorm or allergen type is not a drug allergy
			}
			AllergyDef allergyDefCur=AllergyDefs.GetAllergyDefFromRxnorm(rxnorm);
			if(allergyDefCur==null) {
				EventLog.WriteEntry("OpenDentHL7","A drug allergy was not added for patient "+pat.GetNameFLnoPref()+
					".  There is not a drug allergy in the database with an RxNorm code of "+rxnorm.ToString()+".",EventLogEntryType.Information);
				return;//no allergydef for this rxnorm exists
			}
			//see if there is already an active allergy with this AllergyDefNum for this patient
			List<Allergy> listAllergForPat=Allergies.GetAll(pat.PatNum,false);
			for(int i=0;i<listAllergForPat.Count;i++) {
				if(listAllergForPat[i].AllergyDefNum==allergyDefCur.AllergyDefNum) {
					return;//already an active allergy with this AllergyDefNum
				}
			}
			Allergy allergyCur=new Allergy();
			allergyCur.AllergyDefNum=allergyDefCur.AllergyDefNum;
			allergyCur.PatNum=pat.PatNum;
			allergyCur.StatusIsActive=true;
			Allergies.Insert(allergyCur);
			if(_isVerboseLogging) {
				EventLog.WriteEntry("OpenDentHL7","Inserted a new allergy for patient "+pat.GetNameFLnoPref()+" due to an incoming AL1 segment.",EventLogEntryType.Information);
			}
			return;
		}
Exemplo n.º 41
0
		///<summary>Converts one Allergy object to its mobile equivalent.  Warning! CustomerNum will always be 0.</summary>
		internal static Allergym ConvertToM(Allergy allergy){
			Allergym allergym=new Allergym();
			//CustomerNum cannot be set.  Remains 0.
			allergym.AllergyNum         =allergy.AllergyNum;
			allergym.AllergyDefNum      =allergy.AllergyDefNum;
			allergym.PatNum             =allergy.PatNum;
			allergym.Reaction           =allergy.Reaction;
			allergym.StatusIsActive     =allergy.StatusIsActive;
			allergym.DateAdverseReaction=allergy.DateAdverseReaction;
			return allergym;
		}
Exemplo n.º 42
0
 //        ORWRP REPORT TEXT
 //Params ------------------------------------------------------------------
 //literal	100848
 //literal	OR_BADR:ALLERGIES~ADR;ORDV01;73;10
 //literal
 //literal
 //literal
 //literal	3120319
 //literal	3120326
 //Results -----------------------------------------------------------------
 //1^CAMP MASTER;500
 //2^NONSTEROIDAL ANTI-INFLAMMATORY
 //3^DRUG
 //4^04/03/2011 08:25
 //5^HISTORICAL
 //7^973
 //1^CAMP MASTER;500
 //2^PENICILLIN
 //3^DRUG
 //4^11/28/2011 17:54
 //5^HISTORICAL
 //7^985
 internal Allergy[] toAllergies(string response)
 {
     if (response == "")
     {
         return null;
     }
     string[] lines = StringUtils.split(response, StringUtils.CRLF);
     ArrayList lst = new ArrayList();
     Allergy rec = null;
     string comment = "";
     for (int i = 0; i < lines.Length; i++)
     {
         if (lines[i] == "")
         {
             continue;
         }
         string[] flds = StringUtils.split(lines[i], StringUtils.CARET);
         int fldnum = Convert.ToInt16(flds[0]);
         switch (fldnum)
         {
             case 1:
                 if (rec != null)
                 {
                     rec.Comment = comment;
                     lst.Add(rec);
                 }
                 rec = new Allergy();
                 comment = "";
                 string[] parts = StringUtils.split(flds[1], StringUtils.SEMICOLON);
                 if (parts.Length == 2)
                 {
                     rec.Facility = new SiteId(parts[1], parts[0]);
                 }
                 else if (flds[1] != "")
                 {
                     rec.Facility = new SiteId(cxn.DataSource.SiteId.Id, flds[1]);
                 }
                 else
                 {
                     rec.Facility = cxn.DataSource.SiteId;
                 }
                 break;
             case 2:
                 if (flds.Length == 2)
                 {
                     rec.AllergenName = flds[1];
                 }
                 break;
             case 3:
                 if (flds.Length == 2)
                 {
                     rec.AllergenType = flds[1];
                 }
                 break;
             case 4:
                 if (flds.Length == 2)
                 {
                     rec.Timestamp = VistaTimestamp.toUtcFromRdv(flds[1]);
                 }
                 break;
             case 5:
                 if (flds.Length == 2)
                 {
                     rec.Type = new ObservationType("","Allergies and Adverse Reactions", flds[1]);
                 }
                 break;
             case 6:
                 if (flds.Length == 2)
                 {
                     comment += flds[1] + '\n';
                 }
                 break;
             case 7:
                 if (flds.Length == 2)
                 {
                     rec.AllergenId = flds[1];
                 }
                 break;
         }
     }
     if (rec != null)
     {
         lst.Add(rec);
     }
     return (Allergy[])lst.ToArray(typeof(Allergy));
 }
Exemplo n.º 43
0
        internal Allergy[] toAllergiesFromCover(string response)
        {
            if (String.IsNullOrEmpty(response))
            {
                return new Allergy[0];
            }

            string[] lines = response.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            if (lines == null || lines.Length == 0)
            {
                return new Allergy[0];
            }

            IList<Allergy> allergies = new List<Allergy>();

            foreach (string line in lines)
            {
                string[] flds = line.Split(new char[] { '^' });

                if (flds == null || flds.Length == 0)
                {
                    continue;
                }

                Allergy newAllergy = new Allergy();
                newAllergy.AllergenId = flds[0];
                if (flds.Length > 1)
                {
                    newAllergy.AllergenName = flds[1];
                }
                if (flds.Length > 2)
                {
                    // what is in field 2???
                }
                if (flds.Length > 3)
                {
                    newAllergy.Reactions = new List<Symptom>() { new Symptom() { Name = flds[3] } };
                }

                allergies.Add(newAllergy);
            }

            Allergy[] result = new Allergy[allergies.Count];
            allergies.CopyTo(result, 0);
            return result;
        }
Exemplo n.º 44
0
		///<summary>Updates one Allergy in the database.</summary>
		public static void Update(Allergy allergy){
			string command="UPDATE allergy SET "
				+"AllergyDefNum      =  "+POut.Long  (allergy.AllergyDefNum)+", "
				+"PatNum             =  "+POut.Long  (allergy.PatNum)+", "
				+"Reaction           = '"+POut.String(allergy.Reaction)+"', "
				+"StatusIsActive     =  "+POut.Bool  (allergy.StatusIsActive)+", "
				//DateTStamp can only be set by MySQL
				+"DateAdverseReaction=  "+POut.Date  (allergy.DateAdverseReaction)+", "
				+"SnomedReaction     = '"+POut.String(allergy.SnomedReaction)+"' "
				+"WHERE AllergyNum = "+POut.Long(allergy.AllergyNum);
			Db.NonQ(command);
		}
Exemplo n.º 45
0
        internal Allergy[] supplementAllergies(Allergy[] coverSheetAllergies, Allergy[] rdvAllergies)
        {
            if (coverSheetAllergies == null || coverSheetAllergies.Length == 0)
            {
                return rdvAllergies;
            }
            if (rdvAllergies == null || rdvAllergies.Length == 0)
            {
                return coverSheetAllergies;
            }

            foreach (Allergy allergy in rdvAllergies)
            {
                for (int i = 0; i < coverSheetAllergies.Length; i++)
                {
                    if (String.Equals(coverSheetAllergies[i].AllergenId, allergy.AllergenId))
                    {
                        //allergy.AllergenId = coverSheetAllergies[i].AllergenId;
                        allergy.Reactions = coverSheetAllergies[i].Reactions;
                        break;
                    }
                }
            }

            return rdvAllergies;
        }