Esempio n. 1
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();
        }
Esempio n. 2
0
        private void FillGrid()
        {
            medList = Medications.GetList(textSearch.Text);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Drug Name"), 120);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Generic Name"), 120);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Notes for Generic"), 250);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < medList.Count; i++)
            {
                row = new ODGridRow();
                if (medList[i].MedicationNum == medList[i].GenericNum)               //isGeneric
                {
                    row.Cells.Add(medList[i].MedName);
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(medList[i].MedName);
                    row.Cells.Add(Medications.GetGenericName(medList[i].GenericNum));
                }
                row.Cells.Add(medList[i].Notes);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Esempio n. 3
0
        ///<summary>Determines if med is a duplicate of another Medication in listMedsExisting.
        ///Given medGenNamePair is a medication that we are checking and the given generic name if set.
        ///A duplicate is defined as MedName is equal, GenericName is equal, RxCui is equal and either Notes is equal or not defined.
        ///A new medication with all properties being equal to an existing medication except with a blank Notes property is considered to be a
        ///duplicate, as it is likely the existing Medication is simply a user edited version of the same Medication.</summary>
        private static bool IsDuplicateMed(ODTuple <Medication, string> medGenNamePair, List <Medication> listMedsExisting)
        {
            Medication med           = medGenNamePair.Item1;
            string     genericName   = medGenNamePair.Item2;
            bool       isNoteChecked = true;

            //If everything is identical, except med.Notes is blank while x.Notes is not blank, we consider this to be a duplicate.
            if (string.IsNullOrEmpty(med.Notes))
            {
                isNoteChecked = false;
            }
            return(listMedsExisting.Any(
                       x => x.MedName.Trim().ToLower() == med.MedName.Trim().ToLower() &&
                       Medications.GetGenericName(x.GenericNum).Trim().ToLower() == genericName.Trim().ToLower() &&
                       x.RxCui == med.RxCui &&
                       (isNoteChecked ? (x.Notes.Trim().ToLower() == med.Notes.Trim().ToLower()) : true)
                       ));
        }
Esempio n. 4
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;
            }
        }
Esempio n. 5
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;
            }
        }
Esempio n. 6
0
        private void FillGridAllMedications(bool shouldRetainSelection = true)
        {
            Medication medSelected = null;

            if (shouldRetainSelection && gridAllMedications.GetSelectedIndex() != -1)
            {
                medSelected = (Medication)gridAllMedications.Rows[gridAllMedications.GetSelectedIndex()].Tag;
            }
            List <long> listInUseMedicationNums = Medications.GetAllInUseMedicationNums();
            int         sortColIndex            = gridAllMedications.SortedByColumnIdx;
            bool        isSortAscending         = gridAllMedications.SortedIsAscending;

            gridAllMedications.BeginUpdate();
            gridAllMedications.Columns.Clear();
            //The order of these columns is important.  See gridAllMedications_CellClick()
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Drug Name"), 120, GridSortingStrategy.StringCompare);

            gridAllMedications.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Generic Name"), 120, GridSortingStrategy.StringCompare);
            gridAllMedications.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "InUse"), 55, HorizontalAlignment.Center, GridSortingStrategy.StringCompare);
            gridAllMedications.Columns.Add(col);
            if (CultureInfo.CurrentCulture.Name.EndsWith("US"))             //United States
            {
                col = new ODGridColumn(Lan.g(this, "RxNorm"), 70, GridSortingStrategy.StringCompare);
                gridAllMedications.Columns.Add(col);
            }
            col = new ODGridColumn(Lan.g(this, "Notes for Generic"), 250, GridSortingStrategy.StringCompare);
            gridAllMedications.Columns.Add(col);
            gridAllMedications.Rows.Clear();
            List <Medication> listMeds = Medications.GetList(textSearch.Text);

            foreach (Medication med in listMeds)
            {
                ODGridRow row = new ODGridRow();
                row.Tag = med;
                if (med.MedicationNum == med.GenericNum)               //isGeneric
                {
                    row.Cells.Add(med.MedName);
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(med.MedName);
                    row.Cells.Add(Medications.GetGenericName(med.GenericNum));
                }
                if (listInUseMedicationNums.Contains(med.MedicationNum))
                {
                    row.Cells.Add("X");                    //InUse
                }
                else
                {
                    row.Cells.Add("");                              //InUse
                }
                if (CultureInfo.CurrentCulture.Name.EndsWith("US")) //United States
                {
                    if (med.RxCui == 0)
                    {
                        row.Cells.Add(Lan.g(this, "(select)"));
                        row.Cells[row.Cells.Count - 1].Bold = YN.Yes;
                    }
                    else
                    {
                        row.Cells.Add(med.RxCui.ToString());
                    }
                }
                row.Cells.Add(med.Notes);
                gridAllMedications.Rows.Add(row);
            }
            gridAllMedications.EndUpdate();
            gridAllMedications.SortForced(sortColIndex, isSortAscending);
            if (medSelected != null)           //Will be null if nothing is selected.
            {
                for (int i = 0; i < gridAllMedications.Rows.Count; i++)
                {
                    Medication medCur = (Medication)gridAllMedications.Rows[i].Tag;
                    if (medCur.MedicationNum == medSelected.MedicationNum)
                    {
                        gridAllMedications.SetSelected(i, true);
                        break;
                    }
                }
            }
        }
Esempio n. 7
0
        ///<summary>Throws Exception.  Exports all medications to the passed in filename. Throws Exceptions.</summary>
        public static int ExportMedications(string filename, List <Medication> listMedications)
        {
            StringBuilder strBldrOutput = new StringBuilder();

            string encapsulate(string text)
            {
                return("\"" + text.Replace("\"", "\\\"") + "\"");
            }

            foreach (Medication med in listMedications)             //Loop through medications.
            {
                strBldrOutput.AppendLine(encapsulate(med.MedName) + '\t' + encapsulate(Medications.GetGenericName(med.GenericNum)) + '\t' + encapsulate(med.Notes)
                                         + '\t' + encapsulate(POut.Long(med.RxCui)));
            }
            if (ODBuild.IsWeb())
            {
                ThinfinityUtils.ExportForDownload(filename, strBldrOutput.ToString());
            }
            else
            {
                File.WriteAllText(filename, strBldrOutput.ToString());               //Allow Exception to trickle up.
            }
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0,
                                      Lans.g("Medications", "Exported") + " " + POut.Int(listMedications.Count) + " " + Lans.g("Medications", "medications to:") + " " + filename
                                      );
            return(listMedications.Count);
        }