コード例 #1
0
        /// <summary>
        /// Add allergy to the current patient
        /// </summary>
        /// <returns></returns>
        public JsonResult AddAllergyToPatient()
        {
            try
            {
                int patientId = int.Parse(Request.Form["PatientId"]);
                int allergyId = int.Parse(Request.Form["AllergyId"]);

                PatientRepository patientRepo = new PatientRepository();
                var patient = patientRepo.Get(patientId);

                PatientAllergyRepository patientAllergyRepo = new PatientAllergyRepository();
                AllergyRepository allergyRepo = new AllergyRepository();

                PatientAllergy pallergy = new PatientAllergy();
                pallergy.Allergy = allergyRepo.Get(allergyId);
                pallergy.Patient = patient;
                patientAllergyRepo.Add(pallergy);

                return Json(new
                {
                    error = "false",
                    status = "Added patient allergy successfully",
                    ID = pallergy.Id,
                    Name = pallergy.Allergy.Name
                });

            }
            catch (Exception e)
            {

                return Json(new
                {
                    error = "true",
                    status = "Unable to add patient allergy!",
                    errorMessage = e.Message
                });
            }
        }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
 /// <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);
 }
コード例 #4
0
        /// <summary>
        /// Remove allergy from patient
        /// </summary>
        /// <returns></returns>
        public JsonResult RemoveAllergy()
        {
            try
            {
                PatientAllergyRepository patientAllergyRepo = new PatientAllergyRepository();
                PatientRepository patientRepo = new PatientRepository();
                AllergyRepository allergyRepo = new AllergyRepository();

                var patientId = patientRepo.Get(int.Parse(Request.Form["patientID"]));
                var allergyId = allergyRepo.Get(int.Parse(Request.Form["allergyID"]));

                PatientAllergy pa = new PatientAllergy();

                pa.Allergy = allergyId;
                pa.Patient = patientId;

                patientAllergyRepo.Remove(pa);

                //UnitOfWork.CurrentSession.Flush();

                return Json(new
                {
                    error = "false",
                    status = "Allergy Deleted"
                });
            }
            catch (Exception e)
            {

                return Json(new
                {
                    error = "true",
                    status = "Unable to remove patient allergy!",
                    errorMessage = e.Message
                });
            }
        }