Esempio n. 1
0
        public JsonResult EditSurgeryType(int surgerytypeId, string surgerytypename)
        {
            var status = true;
            var exist  = db.SurgeryTypes.ToList().Exists(st => st.SurgeryTypeName == surgerytypename & st.SurgeryTypeId != surgerytypeId);

            if (exist)
            {
                status = false;
            }
            else
            {
                SurgeryType surgeryType = db.SurgeryTypes.Find(surgerytypeId);
                if (surgeryType == null)
                {
                    status = false;
                }
                else
                {
                    surgeryType.SurgeryTypeName = surgerytypename;
                    db.Entry(surgeryType).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }

            return(Json(status, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        /// <summary>
        ///     Attempts to perform surgery of the given <see cref="SurgeryType"/>. Returns whether the operation was successful.
        /// </summary>
        /// <param name="surgeryType">The <see cref="SurgeryType"/> used for this surgery.</param>
        /// <param name="performer">The entity performing the surgery.</param>
        public bool PerformSurgery(SurgeryType surgeryType, IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
        {
            SurgeryAction step = GetSurgeryStep(surgeryType);

            if (step == null)
            {
                return(false);
            }
            step(container, surgeon, performer);
            return(true);
        }
Esempio n. 3
0
        public async Task <IEnumerable <SurgeryGroup> > GetSurgeryGroups(SurgeryType surgeryType)
        {
            using (HospitalDbContext db = _contextFactory.CreateDbContext())
            {
                IList <SurgeryGroup> result = await db.SurgeryGroups
                                              .AsQueryable().AsNoTracking()
                                              .Where(s => s.SurgeryType == surgeryType)
                                              .ToListAsync();

                return(result);
            }
        }
 public override SurgeryAction GetSurgeryStep(SurgeryType toolType)
 {
     if (toolType == SurgeryType.Amputation)
     {
         return(RemoveBodyPartSurgery);
     }
     if (!_skinOpened) //Case: skin is normal.
     {
         if (toolType == SurgeryType.Incision)
         {
             return(OpenSkinSurgery);
         }
     }
     else if (!_vesselsClamped) //Case: skin is opened, but not clamped.
     {
         if (toolType == SurgeryType.VesselCompression)
         {
             return(ClampVesselsSurgery);
         }
         else if (toolType == SurgeryType.Cauterization)
         {
             return(CautizerizeIncisionSurgery);
         }
     }
     else if (!_skinRetracted) //Case: skin is opened and clamped, but not retracted.
     {
         if (toolType == SurgeryType.Retraction)
         {
             return(RetractSkinSurgery);
         }
         else if (toolType == SurgeryType.Cauterization)
         {
             return(CautizerizeIncisionSurgery);
         }
     }
     else  //Case: skin is fully open.
     {
         if (_parent.Mechanisms.Count > 0 && toolType == SurgeryType.VesselCompression && (_disconnectedOrgans.Except(_parent.Mechanisms).Count() != 0 || _parent.Mechanisms.Except(_disconnectedOrgans).Count() != 0))
         {
             return(LoosenOrganSurgery);
         }
         else if (_disconnectedOrgans.Count > 0 && toolType == SurgeryType.Incision)
         {
             return(RemoveOrganSurgery);
         }
         else if (toolType == SurgeryType.Cauterization)
         {
             return(CautizerizeIncisionSurgery);
         }
     }
     return(null);
 }
Esempio n. 5
0
        public JsonResult DeleteSurgeryType(int surgeryTypeId)
        {
            SurgeryType surgeryType = db.SurgeryTypes.Find(surgeryTypeId);

            if (surgeryType != null & !surgeryType.Surgeries.Any())
            {
                db.SurgeryTypes.Remove(surgeryType);
                db.SaveChanges();

                return(Json(true, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 6
0
        private async Task GetSurgeryGroups(SurgeryType type)
        {
            IsLoadingSurgery = true;
            try
            {
                var res = await _therapyDataService.GetSurgeryGroups(type);

                SurgeryGroups.Clear();
                foreach (SurgeryGroup group in res)
                {
                    SurgeryGroups.Add(group);
                }
            }
            catch (Exception ex)
            {
                NotificationManager.AddException(ex, 4);
            }
            IsLoadingSurgery = false;
        }
Esempio n. 7
0
        public PartialViewResult Save(SurgeryType model)
        {
            if (model.Id > 0)
            {
                var surgeryType = db.SurgeryTypes.Where(i => i.Id == model.Id).FirstOrDefault();
                surgeryType.Name     = model.Name;
                surgeryType.NameFr   = model.NameFr;
                surgeryType.IsActive = model.IsActive;
                db.SaveChanges(User.Identity.Name);
            }
            else
            {
                db.SurgeryTypes.Add(model);
                db.SaveChanges(User.Identity.Name);
            }

            var result = db.SurgeryTypes.ToList();

            return(PartialView("_List", result));
        }
Esempio n. 8
0
        public JsonResult CreateSurgeryType(SurgeryType surgeryType)
        {
            var exist = db.SurgeryTypes.ToList().Exists(st => st.SurgeryTypeName == surgeryType.SurgeryTypeName);

            if (exist)
            {
                return(new JsonResult {
                    Data = new { status = false }
                });
            }
            else
            {
                db.SurgeryTypes.Add(surgeryType);
                db.SaveChanges();

                return(new JsonResult {
                    Data = new { status = true, surgeryTypeId = surgeryType.SurgeryTypeId }
                });
            }
        }
Esempio n. 9
0
 public bool CheckSurgery(SurgeryType toolType)
 {
     return(GetSurgeryStep(toolType) != null);
 }
Esempio n. 10
0
 protected abstract SurgeryAction?GetSurgeryStep(SurgeryType toolType);
Esempio n. 11
0
        protected override SurgeryAction?GetSurgeryStep(SurgeryType toolType)
        {
            if (Parent == null)
            {
                return(null);
            }

            if (toolType == SurgeryType.Amputation)
            {
                return(RemoveBodyPartSurgery);
            }

            if (!_skinOpened)
            {
                // Case: skin is normal.
                if (toolType == SurgeryType.Incision)
                {
                    return(OpenSkinSurgery);
                }
            }
            else if (!_vesselsClamped)
            {
                // Case: skin is opened, but not clamped.
                switch (toolType)
                {
                case SurgeryType.VesselCompression:
                    return(ClampVesselsSurgery);

                case SurgeryType.Cauterization:
                    return(CauterizeIncisionSurgery);
                }
            }
            else if (!_skinRetracted)
            {
                // Case: skin is opened and clamped, but not retracted.
                switch (toolType)
                {
                case SurgeryType.Retraction:
                    return(RetractSkinSurgery);

                case SurgeryType.Cauterization:
                    return(CauterizeIncisionSurgery);
                }
            }
            else
            {
                // Case: skin is fully open.
                if (Parent.Mechanisms.Count > 0 &&
                    toolType == SurgeryType.VesselCompression)
                {
                    if (_disconnectedOrgans.Except(Parent.Mechanisms).Count() != 0 ||
                        Parent.Mechanisms.Except(_disconnectedOrgans).Count() != 0)
                    {
                        return(LoosenOrganSurgery);
                    }
                }

                if (_disconnectedOrgans.Count > 0 && toolType == SurgeryType.Incision)
                {
                    return(RemoveOrganSurgery);
                }

                if (toolType == SurgeryType.Cauterization)
                {
                    return(CauterizeIncisionSurgery);
                }
            }

            return(null);
        }
Esempio n. 12
0
 /// <summary>
 ///     Gets the delegate corresponding to the surgery step using the given <see cref="SurgeryType"/>. Returns null if no surgery step can be performed.
 /// </summary>
 public abstract SurgeryAction GetSurgeryStep(SurgeryType toolType);
Esempio n. 13
0
 /// <summary>
 ///     Attempts to perform surgery on this BodyPart with the given tool. Returns false if there was an error, true if successful.
 /// </summary>
 public bool AttemptSurgery(SurgeryType toolType, IBodyPartContainer target, ISurgeon surgeon, IEntity performer)
 {
     return(_surgeryData.PerformSurgery(toolType, target, surgeon, performer));
 }
Esempio n. 14
0
 /// <summary>
 ///     Returns whether the given <see cref="SurgeryType"/> can be used on the current state of this BodyPart.
 /// </summary>
 public bool SurgeryCheck(SurgeryType toolType)
 {
     return(_surgeryData.CheckSurgery(toolType));
 }