Exemple #1
0
 ///<summary>Inserts one Disease into the database.  Returns the new priKey.</summary>
 internal static long Insert(Disease disease)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         disease.DiseaseNum=DbHelper.GetNextOracleKey("disease","DiseaseNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(disease,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     disease.DiseaseNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(disease,false);
     }
 }
Exemple #2
0
 ///<summary>Inserts one Disease into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Disease disease,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         disease.DiseaseNum=ReplicationServers.GetKey("disease","DiseaseNum");
     }
     string command="INSERT INTO disease (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="DiseaseNum,";
     }
     command+="PatNum,DiseaseDefNum,PatNote,ICD9Num,ProbStatus,DateStart,DateStop) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(disease.DiseaseNum)+",";
     }
     command+=
              POut.Long  (disease.PatNum)+","
         +    POut.Long  (disease.DiseaseDefNum)+","
         +"'"+POut.String(disease.PatNote)+"',"
         //DateTStamp can only be set by MySQL
         +    POut.Long  (disease.ICD9Num)+","
         +    POut.Int   ((int)disease.ProbStatus)+","
         +    POut.Date  (disease.DateStart)+","
         +    POut.Date  (disease.DateStop)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         disease.DiseaseNum=Db.NonQ(command,true);
     }
     return disease.DiseaseNum;
 }
            public EventModels()
            {
                strEventENName = string.Empty;
                strEventCNName = string.Empty;

                oDisease = new Disease();
                lstSymptoms = new List<Symptom>();
                em_InferneceType = EnumInferenceType.PRIMARY;
                em_InferenceResultType = EnumInferenceResultType.OTHER;
            }
Exemple #4
0
 ///<summary>Converts one Disease object to its mobile equivalent.  Warning! CustomerNum will always be 0.</summary>
 internal static Diseasem ConvertToM(Disease disease)
 {
     Diseasem diseasem=new Diseasem();
     //CustomerNum cannot be set.  Remains 0.
     diseasem.DiseaseNum   =disease.DiseaseNum;
     diseasem.PatNum       =disease.PatNum;
     diseasem.DiseaseDefNum=disease.DiseaseDefNum;
     diseasem.PatNote      =disease.PatNote;
     diseasem.ICD9Num      =disease.ICD9Num;
     diseasem.ProbStatus   =disease.ProbStatus;
     diseasem.DateStart    =disease.DateStart;
     diseasem.DateStop     =disease.DateStop;
     return diseasem;
 }
Exemple #5
0
        public bool EditDisease(Disease disease)
        {
            using (var db = new ZooMasterDBEntities())
            {
                var originalDisease = db.Diseases.First(d => d.DiseaseID == disease.DiseaseID);

                originalDisease.Name = disease.Name;
                originalDisease.Description = disease.Description;
                originalDisease.Treatment = disease.Treatment;
                originalDisease.StartDate = disease.StartDate;
                originalDisease.EndDate = disease.EndDate;

                return db.SaveChanges() == 1;
            }
        }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Disease> TableToList(DataTable table){
			List<Disease> retVal=new List<Disease>();
			Disease disease;
			for(int i=0;i<table.Rows.Count;i++) {
				disease=new Disease();
				disease.DiseaseNum       = PIn.Long  (table.Rows[i]["DiseaseNum"].ToString());
				disease.PatNum           = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				disease.DiseaseDefNum    = PIn.Long  (table.Rows[i]["DiseaseDefNum"].ToString());
				disease.PatNote          = PIn.String(table.Rows[i]["PatNote"].ToString());
				disease.DateTStamp       = PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
				disease.ProbStatus       = (ProblemStatus)PIn.Int(table.Rows[i]["ProbStatus"].ToString());
				disease.DateStart        = PIn.Date  (table.Rows[i]["DateStart"].ToString());
				disease.DateStop         = PIn.Date  (table.Rows[i]["DateStop"].ToString());
				disease.SnomedProblemType= PIn.String(table.Rows[i]["SnomedProblemType"].ToString());
				disease.FunctionStatus   = (FunctionalStatus)PIn.Int(table.Rows[i]["FunctionStatus"].ToString());
				retVal.Add(disease);
			}
			return retVal;
		}
Exemple #7
0
        /// <summary>
        /// Sets the default disease and table via query string
        /// </summary>
        private void SetQueryDefaults()
        {
            if (!string.IsNullOrEmpty(QueryTableId))
            {
                MetadataTable table = new MetadataTable();
                int           key   = int.Parse(QueryTableId);
                table.Get(key);

                SetTable(table);
            }
            else if (!string.IsNullOrEmpty(QueryTableName))
            {
                MetadataTable metaTable = BusinessObject.GetByFields <MetadataTable>(new Dictionary <string, object> {
                    { MetadataTable.TableName_Field, QueryTableName }
                }).FirstOrDefault();
                if (metaTable != null)
                {
                    SetTable(metaTable);
                }
            }
            // sets current disease id field
            if (QueryDiseaseId.HasValue)
            {
                // set pri key
                CurrentDiseaseId.Value = QueryDiseaseId.Value.ToString();
                // set display name
                Disease disease = new Disease();
                disease.Get(QueryDiseaseId.Value);
                CurrentDiseaseName.Value = disease[Disease.DiseaseName].ToString();

                // show tables edit
                ManageTablesBtn.Visible = true;
                // set title
                ManageTablesBtn.InnerText = "Add/Remove " + QueryDiseaseName + " Forms";
            }
            else
            {
                // show tables edit
                //ManageTablesBtn.Visible = false;
            }
        }
Exemple #8
0
        public ActionResult GetDiagnosis(int diagnosisId)
        {
            Diagnosis diagnosis = unitOfWork.Diagnoses.FindById(diagnosisId);

            if (diagnosis == null)
            {
                diagnosis = new Diagnosis()
                {
                    DiagnosisId              = diagnosisId,
                    DiagnosisComment         = "Комментария нет",
                    DiagnosisRecommendations = "Рекомендаций нет"
                };
                Disease disease = new Disease()
                {
                    DiseaseTitle = "Нет диагноза"
                };
                diagnosis.Disease = disease;
                DiagnosisViewModel diagnosisViewModel = new DiagnosisViewModel()
                {
                    DiagnosisId              = diagnosis.DiagnosisId,
                    DiagnosisComment         = diagnosis.DiagnosisComment,
                    DiagnosisRecommendations = diagnosis.DiagnosisRecommendations,
                    DiseaseId    = diagnosis.DiseaseId,
                    DiseaseTitle = disease.DiseaseTitle
                };

                return(View(diagnosisViewModel));
            }
            else
            {
                DiagnosisViewModel diagnosisViewModel = new DiagnosisViewModel()
                {
                    DiagnosisId              = diagnosis.DiagnosisId,
                    DiagnosisComment         = diagnosis.DiagnosisComment,
                    DiagnosisRecommendations = diagnosis.DiagnosisRecommendations,
                    DiseaseId    = diagnosis.DiseaseId,
                    DiseaseTitle = unitOfWork.Diseases.FindById((int)diagnosis.DiseaseId).DiseaseTitle,
                };
                return(View(diagnosisViewModel));
            }
        }
Exemple #9
0
        public void DiscoverCure(Disease disease, IEnumerable <PandemicPlayerCard> cardsToDiscard)
        {
            var playerState   = State.PlayerStates[CurrentPlayerId];
            var newPlayerTurn = new PlayerAction
            {
                PlayerId         = CurrentPlayerId,
                PlayerActionType = PlayerActionType.DiscoverCure,
                City             = playerState.Location,
                Disease          = disease,
                CardsToDiscard   = cardsToDiscard
            };

            var validationFailures = _validator.ValidatePlayerAction(CurrentPlayerId, State, newPlayerTurn).ToList();

            if (validationFailures.Any())
            {
                throw new CardboardException(validationFailures[0]);
            }

            ActionTaken = newPlayerTurn;
        }
Exemple #10
0
        public void Update_InCorrectInputDiseaseId_ExpectedException()
        {
            // Arrange
            TestData testData = new TestData();
            int      expectedUpdatedDiseaseId = testData.disease.DiseaseId;
            var      mockDataProvider         = new Mock <IDataAccessManager>();
            Disease  nullDisease = null;

            mockDataProvider.Setup(mock => mock.GetDisease(testData.disease.DiseaseId)).Returns(nullDisease);
            mockDataProvider.Setup(mock => mock.GetDiseaseCategories()).Returns(testData.Categories);
            mockDataProvider.Setup(mock => mock.GetDiseasesInCategory(It.IsAny <int>())).Returns(testData.Diseases);
            mockDataProvider.Setup(mock => mock.UpdateDisease(expectedUpdatedDiseaseId, testData.disease)).
            Returns(expectedUpdatedDiseaseId);
            var service = new DiseaseManager(mockDataProvider.Object);

            // Act
            int actualUpdatedDiseaseId = service.Update(expectedUpdatedDiseaseId, testData.disease);

            // Assert
            Assert.AreEqual(expectedUpdatedDiseaseId, actualUpdatedDiseaseId);
        }
    public void RequestDisease(ConsumeEffect type, float delay, int level)
    {
        if (this.m_Diseases[(int)type].IsActive())
        {
            return;
        }
        Disease disease = this.GetDisease(type);

        if (disease == null)
        {
            return;
        }
        DiseaseRequest diseaseRequest = new DiseaseRequest();

        diseaseRequest.m_RequestTime = Time.time;
        diseaseRequest.m_Disease     = disease;
        diseaseRequest.m_Delay       = delay;
        diseaseRequest.m_Level       = level;
        this.m_Requests.Add(diseaseRequest);
        this.UpdateRequests();
    }
Exemple #12
0
        public IStateSnippet GetState()
        {
            var state = new ActiveDiseaseSnippet
            {
                DiseaseId          = Disease.Id,
                InjuryId           = _linkedInjury?.Injury?.Id,
                DiseaseType        = Disease.GetType(),
                IsDiseaseActivated = _isDiseaseActivated,
                IsSelfHealActive   = _isSelfHealActive,
                IsChainInverted    = _isChainInverted,
                DiseaseStartTime   = _diseaseStartTime,
                TreatedStageLevel  = TreatedStage?.Level,
                IsTreated          = this.IsTreated,
            };

            state.ChildStates.Add("ChangedVitals", _changedVitals?.GetState());
            state.ChildStates.Add("ChangedCritialStage", _changedCritialStage?.GetState());
            state.ChildStates.Add("Treatments", Disease.GetState());

            return(state);
        }
Exemple #13
0
 public Efetch(int retstart, int maxBatch, Disease diseaseP, List <long> ids, HttpClient clientP, string urlEfetchP, PublicationRepository publicationRepositoryP)
 {
     urlContent = new FormUrlEncodedContent(
         new Dictionary <string, string> {
         { "db", "pmc" },
         { "retstart", $"{retstart}" },
         { "retmax", $"{maxBatch}" },
         { "rettype", "xml" },
         { "retmode", "xml" },
         { "api_key", $"{ConfigurationManager.Instance.config.API_Key}" },
         { "email", $"{ConfigurationManager.Instance.config.Email}" },
         { "tool", $"{ConfigurationManager.Instance.config.Tool}" },
         { "id", String.Join(", ", ids.ToArray()) }
     }
         );
     disease               = diseaseP;
     client                = clientP;
     urlEfetch             = urlEfetchP;
     publicationRepository = publicationRepositoryP;
     monDocActuel          = new XmlDocument();
 }
Exemple #14
0
        public List <Disease> LoadDiseases()
        {
            SqlConnection connection = new SqlConnection(connectionString);
            string        query      = "select * from tbl_Disease_Entry";
            SqlCommand    command    = new SqlCommand(query, connection);

            connection.Open();
            List <Disease> diseaseList = new List <Disease>();
            SqlDataReader  reader      = command.ExecuteReader();

            while (reader.Read())
            {
                Disease aDisease = new Disease();
                aDisease.id          = int.Parse(reader["ID"].ToString());
                aDisease.diseaseName = reader["DiseaseName"].ToString();
                diseaseList.Add(aDisease);
            }
            reader.Close();
            connection.Close();
            return(diseaseList);
        }
Exemple #15
0
        public ActionResult Create([Bind(Include = "RefId,Name,Phone,DiseaseId,Cardiovascular,Breathing,URM,SportsOthers,Specific,Gastric,Specificgastric,Allergy,Specificallergy")] Disease disease)
        {
            if (ModelState.IsValid)
            {
                string a = Request.Form["RefId"];
                int    b = Convert.ToInt32(a);
                disease.Phone = Request.Form["Phone"];
                MySqlConnection mysql        = getMySqlConnection();
                MySqlCommand    mySqlCommand = getSqlCommand("INSERT INTO disease(phone,disease,cardiovascular,breathing,URM,SportsOthers,specifics,gastric,specificgastric,allergy,specificallergy)VALUES" + "(" +
                                                             "'" + disease.Phone + "'," + disease.DiseaseId + "," + disease.Cardiovascular + "," + disease.Breathing + "," + disease.URM + "," +
                                                             disease.SportsOthers + "," + "\"" + disease.Specific + "\"" + "," + disease.Gastric + "," + "\"" + disease.Specificgastric + "\"" + "," + disease.Allergy + "," + "\"" + disease.Specificallergy + "\""
                                                             + ")", mysql);
                mysql.Open();
                MySqlDataAdapter adapter = new MySqlDataAdapter(mySqlCommand);
                mySqlCommand.ExecuteNonQuery();
                mysql.Close();
                return(RedirectToAction("Details/" + b, "UserMangers"));
            }

            return(View(disease));
        }
        public IActionResult ChildrenInfo(int Bid)
        {
            List <Child> children = _context.children.Where(b => b.BeneficiarID == Bid).ToList();

            foreach (Child c in children)
            {
                Disease disease = _context.diseases.Where(d => d.ChildID == c.Id).FirstOrDefault();
                if (disease != null)
                {
                    c.disease = disease;
                }
                Work work = _context.works.Where(w => w.ChildID == c.Id).FirstOrDefault();
                if (work != null)
                {
                    c.work = work;
                }
            }

            ViewBag.Name = TempData.Peek("Name").ToString();
            return(View(children));
        }
Exemple #17
0
        public static List <Disease> ClearDiseases(List <Disease> diseases)
        {
            List <Disease> manipulate = new List <Disease>();

            if (diseases != null)
            {
                foreach (var disease in diseases)
                {
                    Disease Search = manipulate.Find(x => x.D_ID.Contains(disease.D_ID));
                    if (Search == null)
                    {
                        manipulate.Add(disease);
                    }
                }
                return(manipulate);
            }
            else
            {
                return(null);
            }
        }
Exemple #18
0
        // GET: Diseases/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Disease disease = db.Diseases.Find(id);

            if (disease == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new DiseasesViewModel()
            {
                Disease        = disease,
                CategoryNameAr = db.Categories.FirstOrDefault(x => x.Id == disease.CategoryId).CategoryName,
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> CreateEdit(Disease disease)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _diseasesRepository.CreateEdit(disease);

                    AddMessage("Save Disease Is success-ful", isSuccess: true);
                }
                catch (Exception e)
                {
                    AddMessage("Save Disease Is Not success-ful");
                }
            }
            else
            {
                AddError(ModelState);
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemple #20
0
    public static float CalculateDelta(int disease_count, int element_idx, float mass, int environment_cell, float temperature, float tags_multiplier_base, Disease disease, float dt)
    {
        float          num            = 0f;
        ElemGrowthInfo elemGrowthInfo = disease.elemGrowthInfo[element_idx];

        num += elemGrowthInfo.CalculateDiseaseCountDelta(disease_count, mass, dt);
        float half_life_in_seconds = Disease.CalculateRangeHalfLife(temperature, ref disease.temperatureRange, ref disease.temperatureHalfLives);
        float num2 = Disease.HalfLifeToGrowthRate(half_life_in_seconds, dt);

        num += (float)disease_count * num2 - (float)disease_count;
        float num3 = Mathf.Pow(tags_multiplier_base, dt);

        num += (float)disease_count * num3 - (float)disease_count;
        if (Grid.IsValidCell(environment_cell))
        {
            byte             b = Grid.ElementIdx[environment_cell];
            ElemExposureInfo elemExposureInfo = disease.elemExposureInfo[b];
            num += elemExposureInfo.CalculateExposureDiseaseCountDelta(disease_count, dt);
        }
        return(num);
    }
        public ActionResult <Schedule> EditPlaceSchedule(int facilityID, int placeID, int scheduleID, int diseaseID, int intervalMin)
        {
            User     user     = UserRep.FindByEmail(User.Identity.Name);
            Facility facility = FacilityRep.Find(facilityID);
            Place    place    = PlaceRep.Find(placeID);
            Schedule schedule = ScheduleRep.Find(scheduleID);
            Disease  disease  = DiseaseRep.Find(diseaseID);

            if (place.FacilityID != facilityID || schedule.PlaceID != placeID)
            {
                return(new ForbidResult());
            }
            else if (FacilityRep.IsAdmin(user, facility))
            {
                return(Ok(ScheduleRep.EditSchedule(schedule, place, disease, intervalMin)));
            }
            else
            {
                return(new ForbidResult());
            }
        }
Exemple #22
0
        public Disease Find(string name)
        {
            string query = "SELECT *FROM tbl_disease where name='" + name + "';";

            ASqlConnection.Open();
            ASqlCommand    = new SqlCommand(query, ASqlConnection);
            ASqlDataReader = ASqlCommand.ExecuteReader();
            Disease aDisease = new Disease();

            while (ASqlDataReader.Read())
            {
                aDisease.Id                 = Convert.ToInt32(ASqlDataReader["id"]);
                aDisease.Name               = ASqlDataReader["name"].ToString();
                aDisease.Description        = ASqlDataReader["description"].ToString();
                aDisease.TreatmentProcedure = ASqlDataReader["treatment_procedure"].ToString();
                aDisease.PreferedDrugs      = ASqlDataReader["prefered_drugs"].ToString();
            }
            ASqlDataReader.Close();
            ASqlConnection.Close();
            return(aDisease);
        }
Exemple #23
0
        public bool Save(Disease d)
        {
            connection = new SqlConnection(connectionString);

            string query = "INSERT INTO disease VALUES (@name, @description, @treatment, @drugs)";

            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.AddWithValue("@name", d.Name);
            command.Parameters.AddWithValue("@description", d.Description);
            command.Parameters.AddWithValue("@treatment", d.Treatment);
            command.Parameters.AddWithValue("@drugs", d.Drugs);



            connection.Open();
            int rowAffected = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffected > 0);
        }
Exemple #24
0
        private void createButton_Click(object sender, EventArgs e)
        {
            try
            {
                Disease disease = new Disease(nameBox.Text, descriptionBox.Text);

                if (_disease is null)
                {
                    HospitalManager.GetInstance().DiseaseService.AddElement(disease);
                }
                else
                {
                    HospitalManager.GetInstance().DiseaseService.EditElement(_disease.Id, disease);
                }
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #25
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <Disease> TableToList(DataTable table)
        {
            List <Disease> retVal = new List <Disease>();
            Disease        disease;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                disease               = new Disease();
                disease.DiseaseNum    = PIn.Long(table.Rows[i]["DiseaseNum"].ToString());
                disease.PatNum        = PIn.Long(table.Rows[i]["PatNum"].ToString());
                disease.DiseaseDefNum = PIn.Long(table.Rows[i]["DiseaseDefNum"].ToString());
                disease.PatNote       = PIn.String(table.Rows[i]["PatNote"].ToString());
                disease.DateTStamp    = PIn.DateT(table.Rows[i]["DateTStamp"].ToString());
                disease.ICD9Num       = PIn.Long(table.Rows[i]["ICD9Num"].ToString());
                disease.ProbStatus    = (ProblemStatus)PIn.Int(table.Rows[i]["ProbStatus"].ToString());
                disease.DateStart     = PIn.Date(table.Rows[i]["DateStart"].ToString());
                disease.DateStop      = PIn.Date(table.Rows[i]["DateStop"].ToString());
                retVal.Add(disease);
            }
            return(retVal);
        }
Exemple #26
0
 public DiseaseEntity MapToDiseaseEntity(Disease disease, Guid parentDisease, int state, string mesh = null)
 {
     return(new DiseaseEntity
     {
         Id = Guid.NewGuid(),
         AgeOfOnset = GetTrimmedValue(disease.AgeOfOnset),
         Definition = GetTrimmedValue(disease.Definition),
         Gard = GetTrimmedValue(disease.Gard),
         Icd10 = GetTrimmedValue(disease.Icd10),
         Inheritance = GetTrimmedValue(disease.Inheritance),
         MedDra = GetTrimmedValue(disease.MedDra),
         Name = GetTrimmedValue(disease.Name),
         Omim = GetTrimmedValue(disease.Omim),
         OrphaNumber = GetTrimmedValue(disease.OrphaNumber),
         Prevalence = GetTrimmedValue(disease.Prevalence),
         Umls = GetTrimmedValue(disease.Umls),
         MeSH = GetTrimmedValue(mesh) ?? GetTrimmedValue(disease.MeSH),
         IsTranslationOf = parentDisease,
         State = state
     });
 }
        public List <Disease> GetAllDiseases()
        {
            aGateway.command.CommandText = "SELECT * FROM Disease_tbl";
            aGateway.sqlConnection.Open();
            SqlDataReader  reader       = aGateway.command.ExecuteReader();
            List <Disease> diseasesList = new List <Disease>();

            if (reader != null)
            {
                while (reader.Read())
                {
                    Disease aDisease = new Disease();
                    aDisease.ID   = Convert.ToInt16(reader["ID"].ToString());
                    aDisease.Name = reader["Name"].ToString();
                    diseasesList.Add(aDisease);
                }
            }
            reader.Close();
            aGateway.sqlConnection.Close();
            return(diseasesList);
        }
Exemple #28
0
    public override void Sim200ms(float dt)
    {
        ListPool <int, DiseaseContainers> .PooledList pooledList = ListPool <int, DiseaseContainers> .Allocate();

        pooledList.Capacity = Math.Max(pooledList.Capacity, headers.Count);
        for (int i = 0; i < headers.Count; i++)
        {
            DiseaseHeader diseaseHeader = headers[i];
            if (diseaseHeader.diseaseIdx != 255 && (UnityEngine.Object)diseaseHeader.primaryElement != (UnityEngine.Object)null)
            {
                pooledList.Add(i);
            }
        }
        foreach (int item in pooledList)
        {
            DiseaseContainer container      = payloads[item];
            DiseaseHeader    diseaseHeader2 = headers[item];
            Disease          disease        = Db.Get().Diseases[diseaseHeader2.diseaseIdx];
            float            num            = CalculateDelta(diseaseHeader2, ref container, disease, dt);
            num += container.accumulatedError;
            int num2 = (int)num;
            container.accumulatedError = num - (float)num2;
            bool flag  = diseaseHeader2.diseaseCount > container.overpopulationCount;
            bool flag2 = diseaseHeader2.diseaseCount + num2 > container.overpopulationCount;
            if (flag != flag2)
            {
                EvaluateGrowthConstants(diseaseHeader2, ref container);
            }
            diseaseHeader2.diseaseCount += num2;
            if (diseaseHeader2.diseaseCount <= 0)
            {
                container.accumulatedError  = 0f;
                diseaseHeader2.diseaseCount = 0;
                diseaseHeader2.diseaseIdx   = byte.MaxValue;
            }
            headers[item]  = diseaseHeader2;
            payloads[item] = container;
        }
        pooledList.Recycle();
    }
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MedicinalProductContraindication;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Subject != null)
            {
                dest.Subject = new List <Hl7.Fhir.Model.ResourceReference>(Subject.DeepCopy());
            }
            if (Disease != null)
            {
                dest.Disease = (Hl7.Fhir.Model.CodeableConcept)Disease.DeepCopy();
            }
            if (DiseaseStatus != null)
            {
                dest.DiseaseStatus = (Hl7.Fhir.Model.CodeableConcept)DiseaseStatus.DeepCopy();
            }
            if (Comorbidity != null)
            {
                dest.Comorbidity = new List <Hl7.Fhir.Model.CodeableConcept>(Comorbidity.DeepCopy());
            }
            if (TherapeuticIndication != null)
            {
                dest.TherapeuticIndication = new List <Hl7.Fhir.Model.ResourceReference>(TherapeuticIndication.DeepCopy());
            }
            if (OtherTherapy != null)
            {
                dest.OtherTherapy = new List <Hl7.Fhir.Model.MedicinalProductContraindication.OtherTherapyComponent>(OtherTherapy.DeepCopy());
            }
            if (Population != null)
            {
                dest.Population = new List <Hl7.Fhir.Model.Population>(Population.DeepCopy());
            }
            return(dest);
        }
Exemple #30
0
    public bool AddDisease(Node n)
    {
        if (n.Lost)
        {
            return(false);
        }
        if (Movement.PlayerCharacter != null && n == Movement.PlayerCharacter.CurrentNode)
        {
            return(false);
        }

        // Was just healed
        if (n.LastHealed > 0 && n.LastHealed + healProtectionTime > Time.time)
        {
            return(false);
        }

        Disease disease = n.GetComponent <Disease>();

        if (disease == null)
        {
            disease = n.gameObject.AddComponent <Disease>();

            if (OnDiseaseAdded != null)
            {
                OnDiseaseAdded(n, disease);
            }

            if (creationEffectPrefab != null)
            {
                Instantiate(creationEffectPrefab, disease.transform.position, Quaternion.identity);
            }

            diseases.Add(disease);

            return(true);
        }

        return(false);
    }
        public ActionResult Create()
        {
            var stru  = dbcontext.StructureModels.FirstOrDefault(m => m.All_Models == ChModels.Medical);
            var model = dbcontext.Disease.ToList();
            var count = 0;

            if (model.Count() == 0)
            {
                count = 1;
            }
            else
            {
                var te = model.LastOrDefault().ID;
                count = te + 1;
            }

            var model_ = new Disease {
                Disease_Code = stru.Structure_Code + count
            };

            return(View(model_));
        }
        public async Task ValidateAsync_DiseaseNotExists_ThrowsError()
        {
            // Arrange
            var fixture = new Fixture();
            var id      = fixture.Create <int>();

            var diseaseContainer = new Mock <IDiseaseContainer>();

            diseaseContainer.Setup(x => x.DiseaseId).Returns(id);
            var diseaseIdentity = new Mock <IDiseaseIdentity>();
            var disease         = new Disease();
            var diseaseDAL      = new Mock <IDiseaseDAL>();

            diseaseDAL.Setup(x => x.GetAsync(diseaseIdentity.Object)).ReturnsAsync((Disease)null);

            var diseaseGetService = new DiseaseService(diseaseDAL.Object);

            // Act
            var action = new Func <Task>(() => diseaseGetService.ValidateAsync(diseaseContainer.Object));
            // Assert
            await action.Should().ThrowAsync <InvalidOperationException>($"Disease not found by id {id}");
        }
Exemple #33
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Disease> TableToList(DataTable table)
        {
            List <Disease> retVal = new List <Disease>();
            Disease        disease;

            foreach (DataRow row in table.Rows)
            {
                disease                   = new Disease();
                disease.DiseaseNum        = PIn.Long(row["DiseaseNum"].ToString());
                disease.PatNum            = PIn.Long(row["PatNum"].ToString());
                disease.DiseaseDefNum     = PIn.Long(row["DiseaseDefNum"].ToString());
                disease.PatNote           = PIn.String(row["PatNote"].ToString());
                disease.DateTStamp        = PIn.DateT(row["DateTStamp"].ToString());
                disease.ProbStatus        = (OpenDentBusiness.ProblemStatus)PIn.Int(row["ProbStatus"].ToString());
                disease.DateStart         = PIn.Date(row["DateStart"].ToString());
                disease.DateStop          = PIn.Date(row["DateStop"].ToString());
                disease.SnomedProblemType = PIn.String(row["SnomedProblemType"].ToString());
                disease.FunctionStatus    = (OpenDentBusiness.FunctionalStatus)PIn.Int(row["FunctionStatus"].ToString());
                retVal.Add(disease);
            }
            return(retVal);
        }
Exemple #34
0
        public void TestInfect()
        {
            List <String> result = new List <String>();
            PlayerMock    player = new PlayerMock(result);

            DiseaseList list = new DiseaseList(player);

            bool infected = list.TryInfect(Diseases.MOLASSES);

            Assert.IsTrue(infected);

            infected = list.TryInfect(Diseases.MOLASSES);
            Assert.IsFalse(infected);

            AssertResult(result, Infected(Diseases.MOLASSES));

            Disease disease = DiseaseList.DiseaseForType(Diseases.MOLASSES);

            list.Update(disease.duration);

            AssertResult(result, Infected(Diseases.MOLASSES), Cured(Diseases.MOLASSES));
        }
Exemple #35
0
        public static List <Disease> GetAllDisease()
        {
            List <Disease> allD = new List <Disease>();

            dbHelper.conn = new OracleConnection(dbHelper.dbStr);
            dbHelper.conn.Open();

            OracleCommand cmd = new OracleCommand();

            cmd.Connection  = dbHelper.conn;
            cmd.CommandText = "get_all_disease";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("disease", OracleDbType.RefCursor, ParameterDirection.Output);
            int r = cmd.ExecuteNonQuery();

            try
            {
                OracleRefCursor curr = (OracleRefCursor)cmd.Parameters["disease"].Value;
                using (OracleDataReader dr = curr.GetDataReader())
                {
                    if (dr.Read())
                    {
                        Disease disease = new Disease
                        {
                            DiseaseID    = Convert.ToInt32(dr[id]),
                            Name         = dr[name].ToString(),
                            chronic      = dr[chronic].ToString(),
                            derscription = dr[description].ToString()
                        };
                        allD.Add(disease);
                    }
                }
            }
            catch
            {
            }
            dbHelper.conn.Close();
            return(allD);
        }
        private async void ChooseButton_Click(object sender, EventArgs e)
        {
            if (!_dataGridViewService.TryGetSelectedCellIndices(out var columnIndex, out var rowIndex, true))
            {
                return;
            }

            if (columnIndex == -1)
            {
                MessageBoxService.ShowIncorrectSelectionWarning("Select cell you want to edit.");
                return;
            }

            if (!_dataGridViewService.TryParseIntCell(ColumnName.Id, rowIndex, out var diseaseId))
            {
                return;
            }

            DialogResultEntity = await _diseasesService.ReadByIdAsync(diseaseId);

            DialogResult = DialogResult.OK;
        }
 public DiseaseTimer GetDisease(Disease d)
 {
     foreach (DiseaseTimer dt in m_CurrentDiseases)
     {
         if (dt.Disease == d)
             return dt;
     }
     return null;
 }
        public int DiseaseResistance(Disease toResist)
        {
            if (m_Player == null || m_Player.Deleted)
                return 0;
            int baseResist = (m_Player.HitsMax + m_Player.StamMax + m_Player.ManaMax) / 3;
            int backgroundResist = 0;
            if (m_Player is PlayerMobile)
            {
                #region Background Resistance
                PlayerMobile pm = m_Player as PlayerMobile;

                if (pm.GetBackgroundLevel(BackgroundList.Frail) > 0)
                    backgroundResist -= 5;
                if (pm.GetBackgroundLevel(BackgroundList.OutOfShape) > 0)
                    backgroundResist -= 5;
                if (pm.GetBackgroundLevel(BackgroundList.SlowHealer) > 0)
                    backgroundResist -= 5;
                if (pm.GetBackgroundLevel(BackgroundList.Weak) > 0)
                    backgroundResist -= 5;
                if (pm.GetBackgroundLevel(BackgroundList.Unlucky) > 0)
                    backgroundResist -= 15;

                if (pm.GetBackgroundLevel(BackgroundList.Fit) > 0)
                    backgroundResist += 5;
                if (pm.GetBackgroundLevel(BackgroundList.IronWilled) > 0)
                    backgroundResist += 5;
                if (pm.GetBackgroundLevel(BackgroundList.Lucky) > 0)
                    backgroundResist += 15;
                if (pm.GetBackgroundLevel(BackgroundList.QuickHealer) > 0)
                    backgroundResist += 5;
                if (pm.GetBackgroundLevel(BackgroundList.Tough) > 0)
                    backgroundResist += 5;
                if (pm.GetBackgroundLevel(BackgroundList.Strong) > 0)
                    backgroundResist += 5;
                #endregion
            }
            double clothingResist = 0;
            foreach (Item i in m_Player.Items)
            {
                #region Clothing Resistance Bonuses
                if (i is AlyrianRogueMask)
                    clothingResist += 0.2;
                else if (i is SurgicalMask)
                    clothingResist += 0.5;
                else if (i is LargeScarf)
                    clothingResist += 0.2;
                else if (i is Scarf)
                    clothingResist += 0.15;
                else if (i is SmallScarf)
                    clothingResist += 0.1;
                else if (i is KhemetarRogueTurban)
                    clothingResist += 0.33;
                else if (i is HatWithMask)
                    clothingResist += 0.25;
                #endregion
            }

            baseResist = baseResist + (int)(baseResist * clothingResist) + m_DiseaseImmunities[toResist];

            return (baseResist + backgroundResist -  ( InjuryLevel * (int)toResist) );
        }
    void SetupLevel()
    {
        switch (Level)
        {
            case 1:
                Placable[(int)PlacableTiles.Street] = 3;
                Placable[(int)PlacableTiles.Blockade] = 8;
                Placable[(int)PlacableTiles.Checkpoint] = 2;
                TimeLeft = TimeSpan.FromSeconds(60);
                Filename = @"Assets\Levels\Level.dat";
                DiseaseProto = new Disease();
                break;
            case 2:
                Placable[(int)PlacableTiles.Street] = 2;
                Placable[(int)PlacableTiles.Blockade] = 6;
                Placable[(int)PlacableTiles.Checkpoint] = 1;
                TimeLeft = TimeSpan.FromSeconds(60);
                Filename = @"Assets\Levels\Level.dat";
                DiseaseProto = new Disease();
                break;
            case 3:
                Placable[(int)PlacableTiles.Street] = 1;
                Placable[(int)PlacableTiles.Blockade] = 4;
                Placable[(int)PlacableTiles.Checkpoint] = 1;
                TimeLeft = TimeSpan.FromSeconds(60);
                Filename = @"Assets\Levels\Level.dat";
                DiseaseProto = new Disease();
                break;
        }

        InfoScreen.text = string.Format(
            "Welcome to Level {0}.\nPrevent the disease from spreading and keep the people happy!" +
            "\nSurvive {1} Seconds to clear this level.\n"+
            "If the amount of uninfected poeple drops below {2}%, you lose this level.\n"+
            "Press START to begin.",
            Level,
            (int)TimeLeft.TotalSeconds,
            (int)(HealthMin * 100));
    }
Exemple #40
0
		public static void ProcessPRB(Patient pat,HL7DefSegment segDef,SegmentHL7 seg,MessageHL7 msg) {
			int probActionOrder=-1;
			int probCodeOrder=-1;
			int probStartDateOrder=-1;
			int probStopDateOrder=-1;
			int probUniqueIdOrder=-1;
			for(int i=0;i<segDef.hl7DefFields.Count;i++) {
				int itemOrder=segDef.hl7DefFields[i].OrdinalPos;
				switch(segDef.hl7DefFields[i].FieldName) {
					case "problemAction":
						probActionOrder=itemOrder;
						continue;
					case "problemCode":
						probCodeOrder=itemOrder;
						continue;
					case "problemStartDate":
						probStartDateOrder=itemOrder;
						continue;
					case "problemStopDate":
						probStopDateOrder=itemOrder;
						continue;
					case "problemUniqueId":
						probUniqueIdOrder=itemOrder;
						continue;
					default:
						continue;
				}
			}
			//we need these 3 items defined in order to process the problem
			if(probActionOrder<0 || probCodeOrder<0 || probUniqueIdOrder<0) {
				EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed.  The segment must have an action, code, and unique ID defined.",EventLogEntryType.Information);
				return;
			}
			//get values from defined locations within the segment and validate info
			//We only add or update problems.  Other actions like delete or correct are not yet supported
			if(seg.GetFieldComponent(probActionOrder).ToLower()!="ad" && seg.GetFieldComponent(probActionOrder).ToLower()!="up") {
				EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed.  The action codes supported are 'AD' for add or 'UP' for update.",EventLogEntryType.Information);
				return;
			}
			long probDefNum=DiseaseDefs.GetNumFromSnomed(PIn.String(seg.GetFieldComponent(probCodeOrder,0)));
			//The problem must be a SNOMEDCT code, identified by the coding system table 0396 value "SNM" in component 3 of the CWE problem code field
			//There must be a disease def setup with the SNOMEDCT code in the problem list or we will ignore this problem
			if(seg.GetFieldComponent(probCodeOrder,2).ToLower()!="snm" || probDefNum==0) {
				EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed.  "
					+"The code is not attached to an existing problem definition or is not a SNOMEDCT code.",EventLogEntryType.Information);
				return;
			}
			string probIdExternal=seg.GetFieldComponent(probUniqueIdOrder,0);
			string probRootExternal=seg.GetFieldComponent(probUniqueIdOrder,2);
			if(probIdExternal=="" || probRootExternal=="") {
				EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed. "
					+" The problem does not have a unique ID with assigning authority root.",EventLogEntryType.Information);
				return;
			}
			//If problem external ID and root is in the database, but is used to identify an object other than a problem, do not process the segment
			OIDExternal probOidExt=OIDExternals.GetByRootAndExtension(probRootExternal,probIdExternal);
			if(probOidExt!=null && probOidExt.IDType!=IdentifierType.Problem) {
				EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed.  "
					+"The problem has a unique ID with assigning authority root that has already been used to identify an object of type "
					+probOidExt.IDType.ToString()+".",EventLogEntryType.Information);
				return;
			}
			long diseaseNum=0;
			if(probOidExt!=null) {//exists in oidexternal table and is of type Problem, so IDInternal is a DiseaseNum
				diseaseNum=probOidExt.IDInternal;					
			}
			Disease probCur=new Disease();
			probCur.DiseaseNum=diseaseNum;//probNum could be 0 if new
			//The problem referenced by the external root and ID is already linked in the oidexternal table, get the problem to update
			//Also make sure the problem linked by oidexternal table is for the patient identified in the PID segment
			if(diseaseNum!=0) {
				probCur=Diseases.GetOne(diseaseNum);
				if(probCur==null || probCur.PatNum!=pat.PatNum) {//should never be null if in the oidexternal table
					EventLog.WriteEntry("OpenDentHL7","The PRB segment was not processed.  "
						+"The problem referenced and the patient in the PID segment do not match.",EventLogEntryType.Information);
					return;
				}
			}
			DateTime dateProbStart=DateTime.MinValue;
			if(probStartDateOrder>-1) {
				dateProbStart=FieldParser.DateTimeParse(seg.GetFieldComponent(probStartDateOrder));
			}
			DateTime dateProbStop=DateTime.MinValue;
			if(probStopDateOrder>-1) {
				dateProbStop=FieldParser.DateTimeParse(seg.GetFieldComponent(probStopDateOrder));
			}
			//The patient may already have an active problem with this DiseaseDefNum, but it is not referenced by this problem GUID
			//Mark the existing problem inactive and add a new one with StartDate of today
			//Add an entry in the oidexternal table that will point the problem GUID to this new problem.
			List<Disease> listProbsForPat=Diseases.GetDiseasesForPatient(pat.PatNum,probDefNum,true);
			int markedInactiveCount=0;
			for(int p=0;p<listProbsForPat.Count;p++) {
				if(listProbsForPat[p].DiseaseNum==diseaseNum) {//probNum may be 0 if there was not an existing problem referenced by the GUID in the message
					continue;
				}
				listProbsForPat[p].ProbStatus=ProblemStatus.Inactive;
				Diseases.Update(listProbsForPat[p]);
				markedInactiveCount++;
			}
			if(_isVerboseLogging && markedInactiveCount>0) {
				EventLog.WriteEntry("OpenDentHL7","Updated "+markedInactiveCount.ToString()+" problems to a status of inactive due to an incoming PRB segment.",EventLogEntryType.Information);
			}
			Disease probOld=probCur.Copy();
			probCur.PatNum=pat.PatNum;
			probCur.DiseaseDefNum=probDefNum;
			probCur.ProbStatus=ProblemStatus.Active;
			probCur.DateStart=dateProbStart;//could be '0001-01-01' if not present or not the correct format, handled by FieldParser.DateTimeParse
			probCur.DateStop=dateProbStop;//could be '0001-01-01' if not present or not the correct format, handled by FieldParser.DateTimeParse
			if(probCur.DiseaseNum==0) {//new problem
				//insert new problem
				probCur.DiseaseNum=Diseases.Insert(probCur);
				if(_isVerboseLogging) {
					EventLog.WriteEntry("OpenDentHL7","Inserted a new problem for patient "+pat.GetNameFLnoPref()+" due to an incoming PRB segment.",EventLogEntryType.Information);
				}
				//using DiseaseNum from newly inserted problem, link to the external GUID and root in the oidexternals table
				probOidExt=new OIDExternal();
				probOidExt.IDType=IdentifierType.Problem;
				probOidExt.IDInternal=probCur.DiseaseNum;
				probOidExt.IDExternal=probIdExternal;
				probOidExt.rootExternal=probRootExternal;
				OIDExternals.Insert(probOidExt);
				if(_isVerboseLogging) {
					EventLog.WriteEntry("OpenDentHL7","Added an external problem ID to the oidexternals table due to an incoming PRB segment.\r\nDiseaesNum: "
						+probCur.DiseaseNum.ToString()+", External problem ID: "+probOidExt.IDExternal+", External root: "+probOidExt.rootExternal+".",EventLogEntryType.Information);
				}
			}
			else {//the segment is for an existing problem, update fields if necessary
				Diseases.Update(probCur,probOld);
				if(_isVerboseLogging) {
					EventLog.WriteEntry("OpenDentHL7","Updated an existing problem for patient "+pat.GetNameFLnoPref()+" due to an incoming PRB segment.",EventLogEntryType.Information);
				}
			}
			return;
		}
 public DiscoverCureItem(Disease disease)
 {
     Disease = disease;
     Cards = new List<CityCard>();
 }
 public GiveDiseaseTarget(Disease d)
     : base(20, true, TargetFlags.None)
 {
     m_Dis = d;
 }
 public DiseaseTimer(Mobile m, Disease d, TimeSpan incubation)
     : base(incubation, DiseaseTimer.Virulance(d))
 {
     m_Infected = m;
     m_Disease = d;
     Priority = TimerPriority.OneMinute;
     m_DateInfected = DateTime.Now;
 }
 public static int RecoveryTarget(Disease d)
 {
     switch (d)
         {
             case Disease.Influenza: return 20;
             case Disease.HundredDaysCough: return 500;
             case Disease.Diptheria: return 20;
             case Disease.Dysentery: return 40;
             case Disease.Consumption: return 150;
             case Disease.AzhuranFever: return 30;
             case Disease.Bile: return 50;
             case Disease.Leprosy: return 250;
             case Disease.TyreanDisease: return 350;
             default: return 10;
         }
 }
        public bool HasDisease(Disease d)
        {
            foreach (DiseaseTimer timer in CurrentDiseases)
            {
                if (timer.Disease == d)
                    return true;
            }

            return false;
        }
Exemple #46
0
        public void Deserialize( GenericReader reader, bool read )
        {
            base.Deserialize( reader );

            if ( !read )
                return;

            int version = reader.ReadInt();

            switch ( version )
            {
                case 2:
                {
                    m_Disease = (Disease)reader.ReadInt();
                    goto case 1;
                }
                case 1:
                {
                    m_Poisoner = reader.ReadMobile();
                    goto case 0;
                }
                case 0:
                {
                    m_Poison = Poison.Deserialize( reader );
                    m_Content = (BeverageType)reader.ReadInt();
                    m_Quantity = reader.ReadInt();
                    break;
                }
            }
        }
 public static TimeSpan Virulance(Disease d)
 {
     switch (d)
     {
         case Disease.Influenza: return TimeSpan.FromMinutes(Utility.RandomMinMax(15, 30));
         case Disease.HundredDaysCough: return TimeSpan.FromMinutes(Utility.RandomMinMax(5, 10));
         case Disease.Diptheria: return TimeSpan.FromHours(Utility.RandomMinMax(3, 6));
         case Disease.Dysentery: return TimeSpan.FromHours(Utility.RandomMinMax(1, 2));
         case Disease.Consumption: return TimeSpan.FromMinutes(Utility.RandomMinMax(10, 20));
         case Disease.AzhuranFever: return TimeSpan.FromMinutes(Utility.RandomMinMax(3, 5));
         case Disease.Bile: return TimeSpan.FromHours(Utility.RandomMinMax(3, 6));
         case Disease.Leprosy: return TimeSpan.FromDays(Utility.RandomMinMax(1, 3));
         case Disease.TyreanDisease: return TimeSpan.FromDays(Utility.RandomMinMax(6, 12));
         default: return TimeSpan.FromDays(1);
     }
 }
        public bool DoDisease(Disease dis)
        {
            if (m_Player == null || m_Player.Deleted || !m_Player.Alive || (m_Player is PlayerMobile && (m_Player as PlayerMobile).RessSick))
                return false;

            if (m_Player.Map == Map.Internal)
                return false;

            if (!HasDisease(dis))
                return false;

            switch (dis)
            {
                case Disease.Influenza:
                    {
                        List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[Influenza]"))
                                removeMod.Add(mod);

                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if(m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        int amount = (m_Player.StamMax / 2) * -1;
                        m_Player.Emote("*sweats profusely*");
                        XmlStam influenza = new XmlStam(amount, 300);
                        influenza.Name = " [Disease] [Influenza] ";
                        XmlAttach.AttachTo(m_Player, influenza);
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.HundredDaysCough:
                    {
                        List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[HundredDaysCough]"))
                                removeMod.Add(mod);

                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if(m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        m_Player.Emote("*cough cough cough!*");
                        if (m_Player.Female)
                        {
                            if (Utility.RandomBool())
                                m_Player.PlaySound(0x311);
                            else
                                m_Player.PlaySound(0x312);
                        }
                        else
                        {
                            if (Utility.RandomBool())
                                m_Player.PlaySound(0x420);
                            else
                                m_Player.PlaySound(0x421);
                        }
                        XmlStam cough = new XmlStam(-5, 60);
                        XmlHits ache = new XmlHits(-5, 300);
                        cough.Name = " [Disease] [HundredDaysCough] [1] ";
                        ache.Name = " [Disease] [HundredDaysCough] [2] ";
                        XmlAttach.AttachTo(m_Player, cough);
                        XmlAttach.AttachTo(m_Player, ache);
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.Diptheria:
                    {
                         List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[Diptheria]"))
                                removeMod.Add(mod);

                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if(m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        int amount = (m_Player.Dex / 3) * -1;
                        m_Player.Emote("*drools over " + (m_Player.Female ? "her" : "his") + " swollen neck*");
                        XmlDex diptheria = new XmlDex(amount, 600);
                        diptheria.Name = " [Disease] [Diptheria] ";
                        XmlAttach.AttachTo(m_Player, diptheria);
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.Dysentery:
                    {
                         List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[Dysentery]"))
                                removeMod.Add(mod);

                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if(m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        m_Player.Emote("*doubles over in pain!*");
                        m_Player.Hunger -= 10;
                        if (m_Player.Hunger < 0)
                            m_Player.Hunger = 0;
                        m_Player.Thirst -= 10;
                        if (m_Player.Thirst < 0)
                            m_Player.Thirst = 0;
                        XmlHits dysentery = new XmlHits(-10, 3600);
                        dysentery.Name = " [Disease] [Dysentery] ";
                        XmlAttach.AttachTo(m_Player, dysentery);
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.Consumption:
                    {
                         List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[Consumption]"))
                                removeMod.Add(mod);

                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if(m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        m_Player.Emote("*cough cough cough!*");
                        if (m_Player.Female)
                        {
                            if(Utility.RandomBool())
                                m_Player.PlaySound(0x311);
                            else
                                m_Player.PlaySound(0x312);
                        }
                        else
                        {
                            if (Utility.RandomBool())
                                m_Player.PlaySound(0x420);
                            else
                                m_Player.PlaySound(0x421);
                        }

                        int hitsamount = (m_Player.HitsMax / 4) * -1;
                        int stamamount = (m_Player.StamMax / 4) * -1;

                        XmlHits consumption1 = new XmlHits(hitsamount, 1200);
                        XmlStam consumption2 = new XmlStam(stamamount, 1200);
                        consumption1.Name = " [Disease] [Consumption] [1] ";
                        consumption2.Name = " [Disease] [Consumption] [2] ";
                        XmlAttach.AttachTo(m_Player, consumption1);
                        XmlAttach.AttachTo(m_Player, consumption2);

                        if (!m_Player.Mounted)
                            m_Player.Animate(32, 5, 1, true, false, 0);
                        Point3D p = new Point3D(m_Player.Location);
                        switch (m_Player.Direction)
                        {
                            case Direction.North:
                                p.Y--; break;
                            case Direction.South:
                                p.Y++; break;
                            case Direction.East:
                                p.X++; break;
                            case Direction.West:
                                p.X--; break;
                            case Direction.Right:
                                p.X++; p.Y--; break;
                            case Direction.Down:
                                p.X++; p.Y++; break;
                            case Direction.Left:
                                p.X--; p.Y++; break;
                            case Direction.Up:
                                p.X--; p.Y--; break;
                            default:
                                break;
                        }
                        p.Z = m_Player.Map.GetAverageZ(p.X, p.Y);

                        bool canFit = Server.Spells.SpellHelper.AdjustField(ref p, m_Player.Map, 12, false);

                        if (canFit)
                        {
                            Puke puke = new Puke();
                            puke.Name = "blood";
                            puke.Hue = Utility.RandomList(1157, 1609, 2206, 2778, 2795);
                            puke.Map = m_Player.Map;
                            puke.Location = p;
                        }
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.AzhuranFever:
                    {
                        List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[AzhuranFever]"))
                                removeMod.Add(mod);
                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if (m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        m_Player.Emote("*sweats profusely!*");
                        if(m_Player is PlayerMobile)
                            HallucinationEffect.BeginHallucinating(m_Player as PlayerMobile, 120);
                        XmlHue yellowFever = new XmlHue(1052, 120);

                        int stamamount =(m_Player.StamMax / 3) * -1;
                        int stramount = (m_Player.Str / 4) * -1;
                        XmlStam azhuranStam = new XmlStam(stamamount, 60);
                        XmlStr azhuranStr = new XmlStr(stramount, 60);

                        yellowFever.Name = " [Disease] [AzhuranFever] [1] ";
                        azhuranStam.Name = " [Disease] [AzhuranFever] [2] ";
                        azhuranStr.Name = " [Disease] [AzhuranFever] [3] ";

                        XmlAttach.AttachTo(m_Player, yellowFever);
                        XmlAttach.AttachTo(m_Player, azhuranStam);
                        XmlAttach.AttachTo(m_Player, azhuranStr);
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.Bile:
                    {
                        List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[Bile]"))
                                removeMod.Add(mod);
                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if (m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        m_Player.Emote("*doubles over in pain, losing control of " + (m_Player.Female ? "her" : "his") + " bodily functions*");
                        m_Player.Hunger -= 20;
                        if (m_Player.Hunger < 0)
                            m_Player.Hunger = 0;
                        m_Player.Thirst -= 20;
                        if (m_Player.Thirst < 0)
                            m_Player.Thirst = 0;
                        XmlHits dysentery = new XmlHits(-20, 3600);
                        dysentery.Name = " [Disease] [Bile] ";
                        XmlAttach.AttachTo(m_Player, dysentery);

                        if (!m_Player.Mounted)
                            m_Player.Animate(32, 5, 1, true, false, 0);
                        Point3D p = new Point3D(m_Player.Location);
                        switch (m_Player.Direction)
                        {
                            case Direction.North:
                                p.Y--; break;
                            case Direction.South:
                                p.Y++; break;
                            case Direction.East:
                                p.X++; break;
                            case Direction.West:
                                p.X--; break;
                            case Direction.Right:
                                p.X++; p.Y--; break;
                            case Direction.Down:
                                p.X++; p.Y++; break;
                            case Direction.Left:
                                p.X--; p.Y++; break;
                            case Direction.Up:
                                p.X--; p.Y--; break;
                            default:
                                break;
                        }
                        p.Z = m_Player.Map.GetAverageZ(p.X, p.Y);

                        bool canFit = Server.Spells.SpellHelper.AdjustField(ref p, m_Player.Map, 12, false);

                        if (canFit)
                        {
                            Puke puke = new Puke();
                            puke.Name = "vomit";
                            puke.Hue = 2964;
                            puke.Map = m_Player.Map;
                            puke.Location = p;

                            if (m_Player.Female)
                                m_Player.PlaySound(0x32D);
                            else
                                m_Player.PlaySound(0x43F);
                        }
                        if (m_Player.Female)
                            m_Player.PlaySound(0x318);
                        else
                            m_Player.PlaySound(0x428);
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.Leprosy:
                    {
                        XmlAosAttribute leprosy = new XmlAosAttribute(AosAttribute.RegenHits, -25, 15);
                        leprosy.Name = " [Disease] [Leprosy] ";
                        XmlAttach.AttachTo(m_Player, leprosy);
                        Disfigurement++;
                        DiseaseMessage(dis);
                        return true;
                    }
                case Disease.TyreanDisease:
                    {
                        List<StatMod> removeMod = new List<StatMod>();
                        foreach (StatMod mod in m_Player.StatMods)
                        {
                            if (mod.Name.Contains("[TyreanDisease]"))
                                removeMod.Add(mod);
                        }

                        for (int i = 0; i < removeMod.Count; i++)
                            if (m_Player.StatMods.Contains(removeMod[i]))
                                m_Player.StatMods.Remove(removeMod[i]);

                        XmlAosAttribute tyrean = new XmlAosAttribute(AosAttribute.RegenHits, -50, 15);
                        tyrean.Name = " [Disease] [TyreanDisease] ";
                        XmlAttach.AttachTo(m_Player, tyrean);

                        int amount = (m_Player.Int / 2) * -1;
                        XmlInt madness = new XmlInt(amount, 600);
                        madness.Name = " [Disease] [TyreanDisease] ";
                        XmlAttach.AttachTo(m_Player, madness);

                        Disfigurement++;
                        DiseaseMessage(dis);
                        return true;
                    }
            }

            return false;
        }
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 12: m_OldCloth = reader.ReadBool(); goto case 11;
                case 11: m_Disease = (Disease)reader.ReadInt(); goto case 10;
                case 10: goto case 9;
                case 9:	goto case 8;
                case 8:	goto case 7;
                case 7:	goto case 6;
                case 6:
                {
                    m_CraftersOriginalName = reader.ReadString();
                    goto case 5;
                }
                case 5:
                {
                    SaveFlag flags = (SaveFlag)reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.Resource ) )
                        m_Resource = (CraftResource)reader.ReadEncodedInt();
                    else
                        m_Resource = DefaultResource;

                    if ( GetSaveFlag( flags, SaveFlag.Attributes ) )
                        m_AosAttributes = new AosAttributes( this, reader );
                    else
                        m_AosAttributes = new AosAttributes( this );

                    if ( GetSaveFlag( flags, SaveFlag.ClothingAttributes ) )
                        m_AosClothingAttributes = new AosArmorAttributes( this, reader );
                    else
                        m_AosClothingAttributes = new AosArmorAttributes( this );

                    if ( GetSaveFlag( flags, SaveFlag.SkillBonuses ) )
                        m_AosSkillBonuses = new AosSkillBonuses( this, reader );
                    else
                        m_AosSkillBonuses = new AosSkillBonuses( this );

                    if ( GetSaveFlag( flags, SaveFlag.Resistances ) )
                        m_AosResistances = new AosElementAttributes( this, reader );
                    else
                        m_AosResistances = new AosElementAttributes( this );

                    if ( GetSaveFlag( flags, SaveFlag.MaxHitPoints ) )
                        m_MaxHitPoints = reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.HitPoints ) )
                        m_HitPoints = reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.Crafter ) )
                        m_Crafter = reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.Quality ) )
                        m_Quality = (ClothingQuality)reader.ReadEncodedInt();
                    else
                        m_Quality = ClothingQuality.Regular;

                    if ( GetSaveFlag( flags, SaveFlag.StrReq ) )
                        m_StrReq = reader.ReadEncodedInt();
                    else
                        m_StrReq = -1;

                    if ( GetSaveFlag( flags, SaveFlag.PlayerConstructed ) )
                        m_PlayerConstructed = true;

                    break;
                }
                case 4:
                {
                    m_Resource = (CraftResource)reader.ReadInt();

                    goto case 3;
                }
                case 3:
                {
                    m_AosAttributes = new AosAttributes( this, reader );
                    m_AosClothingAttributes = new AosArmorAttributes( this, reader );
                    m_AosSkillBonuses = new AosSkillBonuses( this, reader );
                    m_AosResistances = new AosElementAttributes( this, reader );

                    goto case 2;
                }
                case 2:
                {
                    m_PlayerConstructed = reader.ReadBool();
                    goto case 1;
                }
                case 1:
                {
                    m_Crafter = reader.ReadMobile();
                    m_Quality = (ClothingQuality)reader.ReadInt();
                    break;
                }
                case 0:
                {
                    m_Crafter = null;
                    m_Quality = ClothingQuality.Regular;
                    break;
                }
            }

            if ( version < 2 )
                m_PlayerConstructed = true; // we don't know, so, assume it's crafted

            if ( version < 3 )
            {
                m_AosAttributes = new AosAttributes( this );
                m_AosClothingAttributes = new AosArmorAttributes( this );
                m_AosSkillBonuses = new AosSkillBonuses( this );
                m_AosResistances = new AosElementAttributes( this );
            }

            if ( version < 4 )
                m_Resource = DefaultResource;

            if ( m_MaxHitPoints == 0 && m_HitPoints == 0 )
                m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits );

            Mobile parent = Parent as Mobile;

            if ( parent != null )
            {
                if ( Core.AOS )
                    m_AosSkillBonuses.AddTo( parent );

                AddStatBonuses( parent );
                parent.CheckStatTimers();
            }

            if( version < 7 && this.Hue == 2992 )
                this.Hue = 2990;

            if( version < 8 && Quality == ClothingQuality.Masterwork )
            {
                this.Resistances.Blunt += 1;
                this.Resistances.Slashing += 1;
                this.Resistances.Piercing += 1;
            }

            if( version < 9 && this.Crafter != null )
            {
                this.CraftersOriginalName = this.Crafter.Name;
            }

            if( version < 10 )
            {
                Resistances.Fire = 0;
                Resistances.Cold = 0;
            }
        }
 public void DiseaseMessage(Disease d)
 {
     switch (d)
     {
         case Disease.Influenza: m_Player.SendMessage("You feel warm..."); return;
         case Disease.HundredDaysCough: m_Player.SendMessage("Your throat aches..."); return;
         case Disease.Diptheria: m_Player.SendMessage("It's hard to breathe..."); return;
         case Disease.Dysentery: m_Player.SendMessage("Your stomache aches..."); return;
         case Disease.Consumption: m_Player.SendMessage("You feel fatigued..."); return;
         case Disease.AzhuranFever: m_Player.SendMessage("You feel hot..."); return;
         case Disease.Bile: m_Player.SendMessage("You feel sick to your stomache..."); return;
         case Disease.Leprosy: m_Player.SendMessage("You feel numb..."); return;
         case Disease.TyreanDisease: m_Player.SendMessage("You feel dizzy..."); return;
         default: return;
     }
 }
 public bool CanCatch(Disease d)
 {
     switch (d)
     {
         case Disease.Influenza:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(6) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.HundredDaysCough:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(3) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.Diptheria:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(9) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.Dysentery:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(14) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.Consumption:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(28) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.AzhuranFever:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(20) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.Bile:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(28) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.Leprosy:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(30) < DateTime.Now)
                     return true;
                 return false;
             }
         case Disease.TyreanDisease:
             {
                 if (m_LastCaught[d] + TimeSpan.FromDays(45) < DateTime.Now)
                     return true;
                 return false;
             }
         default: return true;
     }
 }
 public static TimeSpan IncubationPeriod(Disease d)
 {
     switch (d)
     {
         case Disease.Influenza: return TimeSpan.FromDays(1);
         case Disease.HundredDaysCough: return TimeSpan.FromDays(1);
         case Disease.Diptheria: return TimeSpan.FromDays(2);
         case Disease.Dysentery: return TimeSpan.FromHours(6);
         case Disease.Consumption: return TimeSpan.FromDays(Utility.RandomMinMax(15, 30));
         case Disease.AzhuranFever: return TimeSpan.FromHours(1);
         case Disease.Bile: return TimeSpan.FromHours(Utility.RandomMinMax(6, 12));
         case Disease.Leprosy: return TimeSpan.FromDays(Utility.RandomMinMax(15, 30));
         case Disease.TyreanDisease: return TimeSpan.FromDays(Utility.RandomMinMax(30, 60));
         default: return TimeSpan.FromDays(1);
     }
 }
Exemple #53
0
        public bool AddDisease(Animal animal, string description, string name, DateTime startDate, DateTime? endDate, string treatment)
        {
            var newDisease = new Disease
            {
                AnimalID = animal.AnimalID,
                Description = description,
                Treatment = treatment,
                Name = name,
                StartDate = startDate,
                EndDate = endDate == DateTime.MinValue ? null : endDate
            };

            using (var db = new ZooMasterDBEntities())
            {
                db.Diseases.Add(newDisease);
                return db.SaveChanges() == 1;
            }
        }
		///<summary>Updates one Disease 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.</summary>
		public static void Update(Disease disease,Disease oldDisease){
			string command="";
			if(disease.PatNum != oldDisease.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(disease.PatNum)+"";
			}
			if(disease.DiseaseDefNum != oldDisease.DiseaseDefNum) {
				if(command!=""){ command+=",";}
				command+="DiseaseDefNum = "+POut.Long(disease.DiseaseDefNum)+"";
			}
			if(disease.PatNote != oldDisease.PatNote) {
				if(command!=""){ command+=",";}
				command+="PatNote = '"+POut.String(disease.PatNote)+"'";
			}
			//DateTStamp can only be set by MySQL
			if(disease.ProbStatus != oldDisease.ProbStatus) {
				if(command!=""){ command+=",";}
				command+="ProbStatus = "+POut.Int   ((int)disease.ProbStatus)+"";
			}
			if(disease.DateStart != oldDisease.DateStart) {
				if(command!=""){ command+=",";}
				command+="DateStart = "+POut.Date(disease.DateStart)+"";
			}
			if(disease.DateStop != oldDisease.DateStop) {
				if(command!=""){ command+=",";}
				command+="DateStop = "+POut.Date(disease.DateStop)+"";
			}
			if(disease.SnomedProblemType != oldDisease.SnomedProblemType) {
				if(command!=""){ command+=",";}
				command+="SnomedProblemType = '"+POut.String(disease.SnomedProblemType)+"'";
			}
			if(disease.FunctionStatus != oldDisease.FunctionStatus) {
				if(command!=""){ command+=",";}
				command+="FunctionStatus = "+POut.Int   ((int)disease.FunctionStatus)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE disease SET "+command
				+" WHERE DiseaseNum = "+POut.Long(disease.DiseaseNum);
			Db.NonQ(command);
		}
 public DiseaseSource(Disease d, int range)
 {
     m_Disease = d;
     m_Range = range;
     Visible = false;
     Movable = false;
     CanBeGrabbed = false;
     Stackable = false;
 }
 public DiseaseTimer(Mobile m, Disease d)
     : this(m, d, DiseaseTimer.IncubationPeriod(d))
 {
 }
		///<summary>Updates one Disease in the database.</summary>
		public static void Update(Disease disease){
			string command="UPDATE disease SET "
				+"PatNum           =  "+POut.Long  (disease.PatNum)+", "
				+"DiseaseDefNum    =  "+POut.Long  (disease.DiseaseDefNum)+", "
				+"PatNote          = '"+POut.String(disease.PatNote)+"', "
				//DateTStamp can only be set by MySQL
				+"ProbStatus       =  "+POut.Int   ((int)disease.ProbStatus)+", "
				+"DateStart        =  "+POut.Date  (disease.DateStart)+", "
				+"DateStop         =  "+POut.Date  (disease.DateStop)+", "
				+"SnomedProblemType= '"+POut.String(disease.SnomedProblemType)+"', "
				+"FunctionStatus   =  "+POut.Int   ((int)disease.FunctionStatus)+" "
				+"WHERE DiseaseNum = "+POut.Long(disease.DiseaseNum);
			Db.NonQ(command);
		}
Exemple #58
0
        public void SeedDisease(DiagnoseMeDbContext context, DiseaseSeedModel model)
        {
            var symptomsNames = new HashSet<string>(model.Symptoms.Split(';').Select(x => x.Trim()).ToList());

            // Build the Symptoms
            var symptoms = new HashSet<Symptom>();
            foreach (var symptomName in symptomsNames)
            {
                var symptom = this.ExtractedSymptoms.SingleOrDefault(x => x.Name == symptomName);

                // If symptom not found in our list => get it from database
                if (symptom == null)
                {
                    symptom = context.Symptoms.SingleOrDefault(x => x.Name == symptomName);

                    // If symptom not found in db => create and insert it
                    if (symptom == null)
                    {
                        symptom = new Symptom() { Name = symptomName };
                        context.Symptoms.AddOrUpdate(x => x.Name, symptom);
                    }

                    this.ExtractedSymptoms.Add(symptom);
                }

                symptoms.Add(symptom);
            }

            // Build the Disease
            var disease = new Disease()
            {
                Name = model.Name,
                Description = model.Description,
                Occurrence = model.Occurrence,
                Target = model.Target,
                Symptoms = symptoms
            };

            context.Diseases.AddOrUpdate(x => x.Name, disease);
            context.SaveChanges();
        }
 public DiseaseSource(Disease d)
     : this(d, 5)
 {
 }
        public void TryCatchDisease(Disease dis)
        {
            if (m_Player == null || m_Player.Deleted)
            {
                Delete();
                return;
            }

            if (m_Player is PlayerMadeStatue)
                return;

            if (m_Player.IsDeadBondedPet)
                return;

            if (m_Player.Blessed)
                return;

            if (m_Player.Frozen)
                return;

            if (!m_Player.Alive)
                return;

            if (m_Player is PlayerMobile && (m_Player as PlayerMobile).IsVampire)
                return;

            if (dis == Disease.None)
                return;

            if (HasDisease(dis))
                return;

            if (!CanCatch(dis))
                return;

            if (Utility.RandomMinMax(1, 100) < DiseaseResistance(dis))
                return;

            DiseaseTimer newTimer = new DiseaseTimer(m_Player, dis);
            newTimer.Start();
            m_CurrentDiseases.Add(newTimer);
            m_LastCaught[dis] = DateTime.Now;
        }