Пример #1
0
 private void FillAlerts()
 {
     RxAlertList = RxAlerts.Refresh(RxDefCur.RxDefNum);
     listAlerts.Items.Clear();
     for (int i = 0; i < RxAlertList.Count; i++)
     {
         if (RxAlertList[i].DiseaseDefNum > 0)
         {
             listAlerts.Items.Add(DiseaseDefs.GetName(RxAlertList[i].DiseaseDefNum));
         }
         if (RxAlertList[i].AllergyDefNum > 0)
         {
             AllergyDef allergyDef = AllergyDefs.GetOne(RxAlertList[i].AllergyDefNum);
             if (allergyDef != null)
             {
                 listAlerts.Items.Add(allergyDef.Description);
             }
         }
         if (RxAlertList[i].MedicationNum > 0)
         {
             Medications.RefreshCache();
             Medication med = Medications.GetMedication(RxAlertList[i].MedicationNum);
             if (med != null)
             {
                 listAlerts.Items.Add(med.MedName);
             }
         }
     }
 }
Пример #2
0
        private static bool AllergyComparison(AutomationCondition autoCond, long patNum)
        {
            List <Allergy> allergyList = Allergies.GetAll(patNum, false);

            switch (autoCond.Comparison)
            {
            case AutoCondComparison.Equals:
                for (int i = 0; i < allergyList.Count; i++)
                {
                    if (AllergyDefs.GetOne(allergyList[i].AllergyDefNum).Description == autoCond.CompareString)
                    {
                        return(true);
                    }
                }
                break;

            case AutoCondComparison.Contains:
                for (int i = 0; i < allergyList.Count; i++)
                {
                    if (AllergyDefs.GetOne(allergyList[i].AllergyDefNum).Description.ToLower().Contains(autoCond.CompareString.ToLower()))
                    {
                        return(true);
                    }
                }
                break;
            }
            return(false);
        }
Пример #3
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn("Reminder Criterion", 200);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Message", 200);
            gridMain.Columns.Add(col);
            listReminders = ReminderRules.SelectAll();
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < listReminders.Count; i++)
            {
                row = new ODGridRow();
                switch (listReminders[i].ReminderCriterion)
                {
                case EhrCriterion.Problem:
                    DiseaseDef def = DiseaseDefs.GetItem(listReminders[i].CriterionFK);
                    row.Cells.Add("Problem =" + def.ICD9Code + " " + def.DiseaseName);
                    break;

                case EhrCriterion.Medication:
                    Medication tempMed = Medications.GetMedication(listReminders[i].CriterionFK);
                    if (tempMed.MedicationNum == tempMed.GenericNum)                           //handle generic medication names.
                    {
                        row.Cells.Add("Medication = " + tempMed.MedName);
                    }
                    else
                    {
                        row.Cells.Add("Medication = " + tempMed.MedName + " / " + Medications.GetGenericName(tempMed.GenericNum));
                    }
                    break;

                case EhrCriterion.Allergy:
                    row.Cells.Add("Allergy = " + AllergyDefs.GetOne(listReminders[i].CriterionFK).Description);
                    break;

                case EhrCriterion.Age:
                    row.Cells.Add("Age " + listReminders[i].CriterionValue);
                    break;

                case EhrCriterion.Gender:
                    row.Cells.Add("Gender is " + listReminders[i].CriterionValue);
                    break;

                case EhrCriterion.LabResult:
                    row.Cells.Add("LabResult " + listReminders[i].CriterionValue);
                    break;
                    //case EhrCriterion.ICD9:
                    //  row.Cells.Add("ICD9 "+ICD9s.GetDescription(listReminders[i].CriterionFK));
                    //  break;
                }
                row.Cells.Add(listReminders[i].Message);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Пример #4
0
        private void butAddNew_Click(object sender, EventArgs e)
        {
            if (gridAllergyImport.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "A row must be selected to add");
                return;
            }
            Allergy    al;
            AllergyDef alD;
            AllergyDef alDR      = null;
            int        skipCount = 0;
            bool       isValid;

            for (int i = 0; i < gridAllergyImport.SelectedIndices.Length; i++)
            {
                isValid = true;
                //Since gridAllergyImport and ListAllergyNew are a 1:1 list we can use the selected index position to get our allergy
                al  = ListAllergyNew[gridAllergyImport.SelectedIndices[i]];
                alD = ListAllergyDefNew[gridAllergyImport.SelectedIndices[i]];              //ListAllergyDefNew is also a 1:1 to gridAllergyImport.
                for (int j = 0; j < _listAllergyReconcile.Count; j++)
                {
                    if (_listAllergyReconcile[j].IsNew)
                    {
                        alDR = ListAllergyDefNew[ListAllergyNew.IndexOf(_listAllergyReconcile[j])];
                    }
                    else
                    {
                        alDR = AllergyDefs.GetOne(_listAllergyReconcile[j].AllergyDefNum);
                    }
                    if (alDR == null)
                    {
                        continue;
                    }
                    //if(alDR.SnomedAllergyTo!="" && alDR.SnomedAllergyTo!=null && alDR.SnomedAllergyTo==alD.SnomedAllergyTo) {//TODO: Change to UNII
                    //	isValid=false;
                    //	skipCount++;
                    //	break;
                    //}
                    if (alDR.MedicationNum != 0 && alDR.MedicationNum == alD.MedicationNum)
                    {
                        isValid = false;
                        skipCount++;
                        break;
                    }
                }
                if (isValid)
                {
                    _listAllergyReconcile.Add(al);
                }
            }
            if (skipCount > 0)
            {
                MessageBox.Show(Lan.g(this, " Row(s) skipped because allergy already present in the reconcile list") + ": " + skipCount);
            }
            FillReconcileGrid();
        }
Пример #5
0
        private void FillFK()
        {
            if (RuleCur.CriterionFK == -1 || RuleCur.CriterionFK == 0)
            {
                textCriterionFK.Text = "";
                return;
            }
            switch ((EhrCriterion)comboReminderCriterion.SelectedIndex)
            {
            case EhrCriterion.Problem:
                DiseaseDef def = DiseaseDefs.GetItem(RuleCur.CriterionFK);
                textCriterionFK.Text = def.DiseaseName;
                textICD9.Text        = def.ICD9Code;
                break;

            //case EhrCriterion.ICD9:
            //  textCriterionFK.Text=ICD9s.GetDescription(RuleCur.CriterionFK);
            //  break;
            case EhrCriterion.Medication:
                Medication tempMed = Medications.GetMedication(RuleCur.CriterionFK);
                if (tempMed.MedicationNum == tempMed.GenericNum)                       //handle generic medication names.
                {
                    textCriterionFK.Text = tempMed.MedName;
                }
                else
                {
                    textCriterionFK.Text = tempMed.MedName + " / " + Medications.GetGenericName(tempMed.GenericNum);
                }
                break;

            case EhrCriterion.Allergy:
                textCriterionFK.Text = AllergyDefs.GetOne(RuleCur.CriterionFK).Description;
                break;

            case EhrCriterion.Age:
            case EhrCriterion.Gender:
            case EhrCriterion.LabResult:
                //The FK boxes won't even be visible.
                break;

            default:                    //This should not happen.
                break;
            }
        }
Пример #6
0
 private void FillAlerts()
 {
     RxAlertList = RxAlerts.Refresh(RxDefCur.RxDefNum);
     listAlerts.Items.Clear();
     for (int i = 0; i < RxAlertList.Count; i++)
     {
         if (RxAlertList[i].DiseaseDefNum > 0)
         {
             listAlerts.Items.Add(DiseaseDefs.GetName(RxAlertList[i].DiseaseDefNum));
         }
         if (RxAlertList[i].AllergyDefNum > 0)
         {
             listAlerts.Items.Add(AllergyDefs.GetOne(RxAlertList[i].AllergyDefNum).Description);
         }
         if (RxAlertList[i].MedicationNum > 0)
         {
             Medications.Refresh();
             listAlerts.Items.Add(Medications.GetMedication(RxAlertList[i].MedicationNum).MedName);
         }
     }
 }
Пример #7
0
 private void FormRxAlertEdit_Load(object sender, EventArgs e)
 {
     textRxName.Text = RxDefCur.Drug;
     if (RxAlertCur.DiseaseDefNum > 0)
     {
         labelName.Text = Lan.g(this, "If the patient already has this Problem");
         textName.Text  = DiseaseDefs.GetName(RxAlertCur.DiseaseDefNum);
     }
     if (RxAlertCur.AllergyDefNum > 0)
     {
         labelName.Text = Lan.g(this, "If the patient already has this Allergy");
         textName.Text  = AllergyDefs.GetOne(RxAlertCur.AllergyDefNum).Description;
     }
     if (RxAlertCur.MedicationNum > 0)
     {
         labelName.Text = Lan.g(this, "If the patient is already taking this medication");
         textName.Text  = Medications.GetMedicationFromDb(RxAlertCur.MedicationNum).MedName;
     }
     textMessage.Text = RxAlertCur.NotificationMsg;
     checkIsHighSignificance.Checked = RxAlertCur.IsHighSignificance;
 }
Пример #8
0
        private void FillAllergies()
        {
            allergyList = Allergies.GetAll(PatCur.PatNum, checkShowInactiveAllergies.Checked);
            gridAllergies.BeginUpdate();
            gridAllergies.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableAllergies", "Allergy"), 100);

            gridAllergies.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAllergies", "Reaction"), 180);
            gridAllergies.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAllergies", "Status"), 60, HorizontalAlignment.Center);
            gridAllergies.Columns.Add(col);
            gridAllergies.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < allergyList.Count; i++)
            {
                row = new ODGridRow();
                AllergyDef allergyDef = AllergyDefs.GetOne(allergyList[i].AllergyDefNum);
                row.Cells.Add(allergyDef.Description);
                if (allergyList[i].DateAdverseReaction < DateTime.Parse("1-1-1800"))
                {
                    row.Cells.Add(allergyList[i].Reaction);
                }
                else
                {
                    row.Cells.Add(allergyList[i].Reaction + " " + allergyList[i].DateAdverseReaction.ToShortDateString());
                }
                if (allergyList[i].StatusIsActive)
                {
                    row.Cells.Add("Active");
                }
                else
                {
                    row.Cells.Add("Inactive");
                }
                gridAllergies.Rows.Add(row);
            }
            gridAllergies.EndUpdate();
        }
Пример #9
0
        private void FillFK()
        {
            if (RuleCur.CriterionFK == -1 || RuleCur.CriterionFK == 0)
            {
                textCriterionFK.Text = "";
                return;
            }
            switch ((EhrCriterion)comboReminderCriterion.SelectedIndex)
            {
            case EhrCriterion.Problem:
                textCriterionFK.Text = DiseaseDefs.GetName(RuleCur.CriterionFK);
                break;

            case EhrCriterion.ICD9:
                textCriterionFK.Text = ICD9s.GetDescription(RuleCur.CriterionFK);
                break;

            case EhrCriterion.Medication:
                Medication tempMed = Medications.GetMedication(RuleCur.CriterionFK);
                if (tempMed.MedicationNum == tempMed.GenericNum)                       //handle generic medication names.
                {
                    textCriterionFK.Text = tempMed.MedName;
                }
                else
                {
                    textCriterionFK.Text = tempMed.MedName + " / " + Medications.GetGenericName(tempMed.GenericNum);
                }
                break;

            case EhrCriterion.Allergy:
                textCriterionFK.Text = AllergyDefs.GetOne(RuleCur.CriterionFK).Description;
                break;

            default:
                //Nothing should happen here.
                break;
            }
        }
Пример #10
0
 private void FormRxAlertEdit_Load(object sender, EventArgs e)
 {
     textRxName.Text = RxDefCur.Drug;
     if (RxAlertCur.DiseaseDefNum > 0)
     {
         labelName.Text = Lan.g(this, "If the patient already has this Problem");
         textName.Text  = DiseaseDefs.GetName(RxAlertCur.DiseaseDefNum);
     }
     if (RxAlertCur.AllergyDefNum > 0)
     {
         labelName.Text = Lan.g(this, "If the patient already has this Allergy");
         textName.Text  = AllergyDefs.GetOne(RxAlertCur.AllergyDefNum).Description;
     }
     if (RxAlertCur.MedicationNum > 0)
     {
         labelName.Text = Lan.g(this, "If the patient is already taking this medication");
         textName.Text  = Medications.GetMedicationFromDb(RxAlertCur.MedicationNum).MedName;
     }
     if (RxDefCur.RxCui != 0)
     {
         textRxNorm.Text = RxDefCur.RxCui.ToString() + " - " + RxNorms.GetDescByRxCui(RxDefCur.RxCui.ToString());
     }
     textMessage.Text = RxAlertCur.NotificationMsg;
 }
Пример #11
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Category", 80);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Code", 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("CodeSystem", 120);
            gridMain.Columns.Add(col);
            //col=new ODGridColumn("Op+Value",80);//Example: >=150
            //gridMain.Columns.Add(col);
            col = new ODGridColumn("Description", 250);         //Also includes values for labloinc and demographics and vitals. Example: ">150, BP Systolic"
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //EhrTriggerCur.ProblemDefNumList-----------------------------------------------------------------------------------------------------------------------
            string[] arrayString = EhrTriggerCur.ProblemDefNumList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Problem Def");
                row.Cells.Add(DiseaseDefs.GetItem(PIn.Long(arrayString[i])).DiseaseName);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.ProblemIcd9List---------------------------------------------------------------------------------------------------------------------------
            arrayString = EhrTriggerCur.ProblemIcd9List.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("ICD9 CM");
                row.Cells.Add(ICD9s.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.ProblemIcd10List;
            arrayString = EhrTriggerCur.ProblemIcd10List.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("ICD10 CM");
                row.Cells.Add(Icd10s.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.ProblemSnomedList;
            arrayString = EhrTriggerCur.ProblemSnomedList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Problem");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("SNOMED CT");
                row.Cells.Add(Snomeds.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.MedicationNumList
            arrayString = EhrTriggerCur.MedicationNumList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Medication");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Medication Def");
                row.Cells.Add(Medications.GetDescription(PIn.Long(arrayString[i])));
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.RxCuiList
            arrayString = EhrTriggerCur.RxCuiList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Medication");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("RxCui");
                row.Cells.Add(RxNorms.GetByRxCUI(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.CvxList
            arrayString = EhrTriggerCur.CvxList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Medication");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Cvx");
                row.Cells.Add(Cvxs.GetByCode(arrayString[i]).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.AllergyDefNumList
            arrayString = EhrTriggerCur.AllergyDefNumList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add("Allergy");
                row.Cells.Add(arrayString[i]);
                row.Cells.Add("Allergy Def");
                row.Cells.Add(AllergyDefs.GetOne(PIn.Long(arrayString[i])).Description);
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.DemographicsList
            arrayString = EhrTriggerCur.DemographicsList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                string[] arrayStringElements = arrayString[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                switch (arrayStringElements[0])
                {
                case "age":
                    row.Cells.Add("Demographic");
                    row.Cells.Add("30525-0");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Age" + arrayStringElements[1]);                          //Example "Age>55"
                    gridMain.Rows.Add(row);
                    break;

                case "gender":
                    row.Cells.Add("Demographic");
                    row.Cells.Add("46098-0");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Gender:" + arrayString[i].Replace("gender,", ""));                         //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                default:
                    //should never happen
                    continue;                            //next trigger
                }
            }
            //EhrTriggerCur.LabLoincList
            arrayString = EhrTriggerCur.LabLoincList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                Loinc _loincTemp = Loincs.GetByCode(arrayString[i]);              //.Split(new string[] { ";" },StringSplitOptions.None)[0]);
                if (_loincTemp == null)
                {
                    continue;
                }
                row.Cells.Add("Laboratory");
                row.Cells.Add(_loincTemp.LoincCode);
                row.Cells.Add("LOINC");
                row.Cells.Add(_loincTemp.NameShort);
                //switch(arrayString[i].Split(new string[] { ";" },StringSplitOptions.RemoveEmptyEntries).Length) {
                //	case 1://loinc only comparison
                //		row.Cells.Add(_loincTemp.NameShort);
                //		break;
                //	case 2://microbiology or unitless lab.
                //		Snomed _snomedTemp=Snomeds.GetByCode(arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[1]);
                //		row.Cells.Add(_loincTemp.NameShort+", "
                //			+(_snomedTemp==null?arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[1]:_snomedTemp.Description));//Example: Bacteria Identified, Campylobacter jenuni
                //		break;
                //	case 3://"traditional lab results"
                //		row.Cells.Add(_loincTemp.NameShort+" "
                //	+arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[1]+" "//example: >150 or a snomed code if microbiology
                //	+arrayString[i].Split(new string[] { ";" },StringSplitOptions.None)[2]    //example: mg/dL or blank
                //			);
                //		break;
                //	default://should never happen. Will display blank.
                //		row.Cells.Add("");
                //		break;
                //}
                gridMain.Rows.Add(row);
            }
            //EhrTriggerCur.VitalLoincList
            arrayString = EhrTriggerCur.VitalLoincList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < arrayString.Length; i++)
            {
                row = new ODGridRow();
                string[] arrayStringElements = arrayString[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                switch (arrayStringElements[0])
                {
                case "height":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("8302-2");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Height" + arrayString[i].Replace("height,", "") + " in.");                       //Example "Age>55"
                    gridMain.Rows.Add(row);
                    break;

                case "weight":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("29463-7");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("Weight:" + arrayString[i].Replace("weight,", ""));                         //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                case "bp???":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("???There are two.");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("???");                            //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                case "BMI":
                    row.Cells.Add("Vitals");
                    row.Cells.Add("39156-5");
                    row.Cells.Add("LOINC");
                    row.Cells.Add("BMI" + arrayString[i].Replace("BMI,", "").Replace("%", "") + "%");                      //Example "Gender:Male, Female, Unknown/Undifferentiated"
                    gridMain.Rows.Add(row);
                    break;

                default:
                    //should never happen
                    continue;                            //next trigger
                }
            }
            //End trigger fields.
            gridMain.EndUpdate();
        }
Пример #12
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listAllergyReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing allergies to be removed.  Continue?"))
                {
                    return;
                }
            }
            Allergy    al;
            AllergyDef alD;
            bool       isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listAllergyCur.Count; i++)       //Start looping through all current allergies
            {
                isActive = false;
                al       = _listAllergyCur[i];
                alD      = AllergyDefs.GetOne(al.AllergyDefNum, _listAllergyDefCur);
                for (int j = 0; j < _listAllergyReconcile.Count; j++)           //Compare each reconcile allergy to the current allergy
                {
                    AllergyDef alDR = AllergyDefs.GetOne(_listAllergyReconcile[j].AllergyDefNum, _listAllergyDefCur);
                    if (_listAllergyReconcile[j].AllergyDefNum == _listAllergyCur[i].AllergyDefNum)                   //Has identical AllergyDefNums
                    {
                        isActive = true;
                        break;
                    }
                    if (alDR == null)
                    {
                        continue;
                    }
                    //if(alDR.SnomedAllergyTo!="" && alDR.SnomedAllergyTo==alD.SnomedAllergyTo) {//TODO: Change to UNII
                    //	isActive=true;
                    //	break;
                    //}
                    if (alDR.MedicationNum != 0 && alDR.MedicationNum == alD.MedicationNum)                 //Has a Snomed code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)
                {
                    _listAllergyCur[i].StatusIsActive = isActive;
                    Allergies.Update(_listAllergyCur[i]);
                }
            }
            //Always update every current allergy for the patient so that DateTStamp reflects the last reconcile date.
            if (_listAllergyCur.Count > 0)
            {
                Allergies.ResetTimeStamps(_patCur.PatNum, true);
            }
            AllergyDef alDU;
            int        index;

            for (int j = 0; j < _listAllergyReconcile.Count; j++)
            {
                if (!_listAllergyReconcile[j].IsNew)
                {
                    continue;
                }
                index = ListAllergyNew.IndexOf(_listAllergyReconcile[j]);              //Returns -1 if not found.
                if (index < 0)
                {
                    continue;
                }
                //Insert the AllergyDef and Allergy if needed.
                if (ListAllergyDefNew[index].MedicationNum != 0)
                {
                    alDU = AllergyDefs.GetAllergyDefFromMedication(ListAllergyDefNew[index].MedicationNum);
                }
                else
                {
                    alDU = null;                  //remove once UNII is implemented
                    //alDU=AllergyDefs.GetAllergyDefFromCode(ListAllergyDefNew[index].SnomedAllergyTo);//TODO: Change to UNII
                }
                if (alDU == null)               //db is missing the def
                {
                    ListAllergyNew[index].AllergyDefNum = AllergyDefs.Insert(ListAllergyDefNew[index]);
                }
                else
                {
                    ListAllergyNew[index].AllergyDefNum = alDU.AllergyDefNum;                  //Set the allergydefnum on the allergy.
                }
                Allergies.Insert(ListAllergyNew[index]);
            }
            //TODO: Make an allergy measure event if one is needed for MU3.
            //EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
            //newMeasureEvent.DateTEvent=DateTime.Now;
            //newMeasureEvent.EventType=EhrMeasureEventType.AllergyReconcile;
            //newMeasureEvent.PatNum=PatCur.PatNum;
            //newMeasureEvent.MoreInfo="";
            //EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listAllergyReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).AllergyCDS)
                {
                    AllergyDef          alDInter = AllergyDefs.GetOne(_listAllergyReconcile[inter].AllergyDefNum);
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(alDInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }
Пример #13
0
        private void butAddExist_Click(object sender, EventArgs e)
        {
            if (gridAllergyExisting.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "A row must be selected to add");
                return;
            }
            Allergy    al;
            AllergyDef alD;
            int        skipCount = 0;
            bool       isValid;

            for (int i = 0; i < gridAllergyExisting.SelectedIndices.Length; i++)
            {
                isValid = true;
                //Since gridAllergyExisting and _listAllergyCur are a 1:1 list we can use the selected index position to get our allergy
                al  = _listAllergyCur[gridAllergyExisting.SelectedIndices[i]];
                alD = AllergyDefs.GetOne(al.AllergyDefNum, _listAllergyDefCur);
                if (_listAllergyReconcile.Count == 0)
                {
                    _listAllergyReconcile.Add(al);
                    continue;
                }
                for (int j = 0; j < _listAllergyReconcile.Count; j++)
                {
                    if (!_listAllergyReconcile[j].IsNew && _listAllergyReconcile[j].AllergyNum == al.AllergyNum)                   //If not new, then from existing list.  Check allergynums
                    {
                        isValid = false;
                        skipCount++;
                        break;
                    }
                    if (_listAllergyReconcile[j].IsNew)
                    {
                        //This is an allergy that is coming in from and external source.
                        AllergyDef alDN  = null;
                        int        index = ListAllergyNew.IndexOf(_listAllergyReconcile[j]);               //Find the corresponding allergy def by looping through the incoming allergies.
                        if (index == -1)
                        {
                            continue;                            //This should not happen
                        }
                        alDN = ListAllergyDefNew[index];         //Incoming allergy and allergy def lists are 1 to 1 so we can use the same index.
                        if (alDN != null && alDN.MedicationNum == alD.MedicationNum)
                        {
                            isValid = false;
                            skipCount++;
                            break;
                        }
                    }
                    if (al.AllergyDefNum == _listAllergyReconcile[j].AllergyDefNum)
                    {
                        isValid = false;
                        skipCount++;
                        break;
                    }
                    if (!isValid)
                    {
                        break;
                    }
                }
                if (isValid)
                {
                    _listAllergyReconcile.Add(al);
                }
            }
            if (skipCount > 0)
            {
                MessageBox.Show(Lan.g(this, " Row(s) skipped because allergy already present in the reconcile list") + ": " + skipCount);
            }
            FillReconcileGrid();
        }
Пример #14
0
        private void FillExistingGrid()
        {
            gridAllergyExisting.BeginUpdate();
            gridAllergyExisting.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Last Modified", 90, HorizontalAlignment.Center);

            gridAllergyExisting.Columns.Add(col);
            col = new ODGridColumn("Description", 200);
            gridAllergyExisting.Columns.Add(col);
            col = new ODGridColumn("Reaction", 100);
            gridAllergyExisting.Columns.Add(col);
            col = new ODGridColumn("Inactive", 80, HorizontalAlignment.Center);
            gridAllergyExisting.Columns.Add(col);
            gridAllergyExisting.Rows.Clear();
            _listAllergyCur = Allergies.GetAll(_patCur.PatNum, false);
            List <long> allergyDefNums = new List <long>();

            for (int h = 0; h < _listAllergyCur.Count; h++)
            {
                if (_listAllergyCur[h].AllergyDefNum > 0)
                {
                    allergyDefNums.Add(_listAllergyCur[h].AllergyDefNum);
                }
            }
            _listAllergyDefCur = AllergyDefs.GetMultAllergyDefs(allergyDefNums);
            ODGridRow  row;
            AllergyDef ald;

            for (int i = 0; i < _listAllergyCur.Count; i++)
            {
                row = new ODGridRow();
                ald = new AllergyDef();
                ald = AllergyDefs.GetOne(_listAllergyCur[i].AllergyDefNum, _listAllergyDefCur);
                row.Cells.Add(_listAllergyCur[i].DateTStamp.ToShortDateString());
                if (ald.Description == null)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(ald.Description);
                }
                if (_listAllergyCur[i].Reaction == null)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(_listAllergyCur[i].Reaction);
                }
                if (_listAllergyCur[i].StatusIsActive)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add("X");
                }
                gridAllergyExisting.Rows.Add(row);
            }
            gridAllergyExisting.EndUpdate();
        }
Пример #15
0
        ///<summary>Returns false if user does not wish to continue after seeing alert.</summary>
        public static bool DisplayAlerts(long patNum, long rxDefNum)
        {
            List <RxAlert> alertList = null;

            //if(rxDefNum==0){
            //	alertList=RxAlerts.RefreshByRxCui(rxCui);//for CPOE
            //}
            //else{
            alertList = RxAlerts.Refresh(rxDefNum);          //for Rx
            //}
            List <Disease>       diseases           = Diseases.Refresh(patNum);
            List <Allergy>       allergies          = Allergies.Refresh(patNum);
            List <MedicationPat> medicationPats     = MedicationPats.Refresh(patNum, false);    //Exclude discontinued, only active meds.
            List <string>        diseaseMatches     = new List <string>();
            List <string>        allergiesMatches   = new List <string>();
            List <string>        medicationsMatches = new List <string>();
            List <string>        customMessages     = new List <string>();
            bool showHighSigOnly = PrefC.GetBool(PrefName.EhrRxAlertHighSeverity);

            for (int i = 0; i < alertList.Count; i++)
            {
                for (int j = 0; j < diseases.Count; j++)
                {
                    //This does not look for matches with icd9s.
                    if (alertList[i].DiseaseDefNum == diseases[j].DiseaseDefNum && diseases[j].ProbStatus == 0)                //ProbStatus is active.
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            diseaseMatches.Add(DiseaseDefs.GetName(diseases[j].DiseaseDefNum));
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
                for (int j = 0; j < allergies.Count; j++)
                {
                    if (alertList[i].AllergyDefNum == allergies[j].AllergyDefNum && allergies[j].StatusIsActive)
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            allergiesMatches.Add(AllergyDefs.GetOne(alertList[i].AllergyDefNum).Description);
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
                for (int j = 0; j < medicationPats.Count; j++)
                {
                    bool       isMedInteraction = false;
                    Medication medForAlert      = Medications.GetMedication(alertList[i].MedicationNum);
                    if (medForAlert == null)
                    {
                        continue;                                                                                              //MedicationNum will be 0 for all other alerts that are not medication alerts.
                    }
                    if (medicationPats[j].MedicationNum != 0 && alertList[i].MedicationNum == medicationPats[j].MedicationNum) //Medication from medication list.
                    {
                        isMedInteraction = true;
                    }
                    else if (medicationPats[j].MedicationNum == 0 && medForAlert.RxCui != 0 && medicationPats[j].RxCui == medForAlert.RxCui)               //Medication from NewCrop. Unfortunately, neither of these RxCuis are required.
                    {
                        isMedInteraction = true;
                    }
                    if (!isMedInteraction)
                    {
                        continue;                        //No known interaction.
                    }
                    //Medication interaction.
                    if (showHighSigOnly && !alertList[i].IsHighSignificance) //if set to only show high significance alerts and this is not a high significance interaction, do not show alert
                    {
                        continue;                                            //Low significance alert.
                    }
                    if (alertList[i].NotificationMsg == "")
                    {
                        Medications.RefreshCache();
                        medicationsMatches.Add(Medications.GetMedication(alertList[i].MedicationNum).MedName);
                    }
                    else
                    {
                        customMessages.Add(alertList[i].NotificationMsg);
                    }
                }
            }
            //these matches do not include ones that have custom messages.
            if (diseaseMatches.Count > 0 ||
                allergiesMatches.Count > 0 ||
                medicationsMatches.Count > 0)
            {
                string alert = "";
                for (int i = 0; i < diseaseMatches.Count; i++)
                {
                    if (i == 0)
                    {
                        alert += Lan.g("RxAlertL", "This patient has the following medical problems: ");
                    }
                    alert += diseaseMatches[i];
                    if ((i + 1) == diseaseMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                for (int i = 0; i < allergiesMatches.Count; i++)
                {
                    if (i == 0 && diseaseMatches.Count > 0)
                    {
                        alert += "and the following allergies: ";
                    }
                    else if (i == 0)
                    {
                        alert = Lan.g("RxAlertL", "This patient has the following allergies: ");
                    }
                    alert += allergiesMatches[i];
                    if ((i + 1) == allergiesMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                for (int i = 0; i < medicationsMatches.Count; i++)
                {
                    if (i == 0 && (diseaseMatches.Count > 0 || allergiesMatches.Count > 0))
                    {
                        alert += "and is taking the following medications: ";
                    }
                    else if (i == 0)
                    {
                        alert = Lan.g("RxAlertL", "This patient is taking the following medications: ");
                    }
                    alert += medicationsMatches[i];
                    if ((i + 1) == medicationsMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                alert += "\r\n" + Lan.g("RxAlertL", "Continue anyway?");
                if (MessageBox.Show(alert, "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return(false);
                }
            }
            for (int i = 0; i < customMessages.Count; i++)
            {
                if (MessageBox.Show(customMessages[i] + "\r\n" + Lan.g("RxAlertL", "Continue anyway?"), "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #16
0
        ///<summary>Returns false if user does not with to continue after seeing alert.  If called from FormRxSelect, then rxCui will be 0.  If called from CPOE, then rxDefNum will be 0.</summary>
        public static bool DisplayAlerts(long patNum, long rxCui, long rxDefNum)
        {
            List <RxAlert> alertList = null;

            if (rxDefNum == 0)
            {
                alertList = RxAlerts.RefreshByRxCui(rxCui);              //for CPOE
            }
            else
            {
                alertList = RxAlerts.Refresh(rxDefNum);              //for Rx
            }
            List <Disease>    diseases           = Diseases.Refresh(patNum);
            List <Allergy>    allergies          = Allergies.Refresh(patNum);
            List <Medication> medications        = Medications.GetMedicationsByPat(patNum);
            List <string>     diseaseMatches     = new List <string>();
            List <string>     allergiesMatches   = new List <string>();
            List <string>     medicationsMatches = new List <string>();
            List <string>     customMessages     = new List <string>();

            for (int i = 0; i < alertList.Count; i++)
            {
                for (int j = 0; j < diseases.Count; j++)
                {
                    //This does not look for matches with icd9s.
                    //The only reason we support diseases anyway is for allergies that may have been entered as diseases.
                    if (alertList[i].DiseaseDefNum == diseases[j].DiseaseDefNum && diseases[j].ProbStatus == 0)                //ProbStatus is active.
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            diseaseMatches.Add(DiseaseDefs.GetName(diseases[j].DiseaseDefNum));
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
                for (int j = 0; j < allergies.Count; j++)
                {
                    if (alertList[i].AllergyDefNum == allergies[j].AllergyDefNum && allergies[j].StatusIsActive)
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            allergiesMatches.Add(AllergyDefs.GetOne(alertList[i].AllergyDefNum).Description);
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
                for (int j = 0; j < medications.Count; j++)
                {
                    if (alertList[i].MedicationNum == medications[j].MedicationNum)
                    {
                        if (alertList[i].NotificationMsg == "")
                        {
                            Medications.Refresh();
                            medicationsMatches.Add(Medications.GetMedication(alertList[i].MedicationNum).MedName);
                        }
                        else
                        {
                            customMessages.Add(alertList[i].NotificationMsg);
                        }
                    }
                }
            }
            //these matches do not include ones that have custom messages.
            if (diseaseMatches.Count > 0 ||
                allergiesMatches.Count > 0 ||
                medicationsMatches.Count > 0)
            {
                string alert = "";
                for (int i = 0; i < diseaseMatches.Count; i++)
                {
                    if (i == 0)
                    {
                        alert += Lan.g("RxAlertL", "This patient has the following medical problems: ");
                    }
                    alert += diseaseMatches[i];
                    if ((i + 1) == diseaseMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                for (int i = 0; i < allergiesMatches.Count; i++)
                {
                    if (i == 0 && diseaseMatches.Count > 0)
                    {
                        alert += "and the following allergies: ";
                    }
                    else if (i == 0)
                    {
                        alert = Lan.g("RxAlertL", "This patient has the following allergies: ");
                    }
                    alert += allergiesMatches[i];
                    if ((i + 1) == allergiesMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                for (int i = 0; i < medicationsMatches.Count; i++)
                {
                    if (i == 0 && (diseaseMatches.Count > 0 || allergiesMatches.Count > 0))
                    {
                        alert += "and is taking the following medications: ";
                    }
                    else if (i == 0)
                    {
                        alert = Lan.g("RxAlertL", "This patient is taking the following medications: ");
                    }
                    alert += medicationsMatches[i];
                    if ((i + 1) == medicationsMatches.Count)
                    {
                        alert += ".\r\n";
                    }
                    else
                    {
                        alert += ", ";
                    }
                }
                alert += "\r\n" + Lan.g("RxAlertL", "Continue anyway?");
                if (MessageBox.Show(alert, "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return(false);
                }
            }
            for (int i = 0; i < customMessages.Count; i++)
            {
                if (MessageBox.Show(customMessages[i] + "\r\n" + Lan.g("RxAlertL", "Continue anyway?"), "Alert", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
                {
                    return(false);
                }
            }
            return(true);
        }