Пример #1
0
        private void FillForm()
        {
            textMedName.Text = MedicationCur.MedName;
            if (!IsNew)
            {
                textMedName.ReadOnly = true;
            }
            if (MedicationCur.MedicationNum == MedicationCur.GenericNum)
            {
                textGenericName.Text = MedicationCur.MedName;
                textNotes.Text       = MedicationCur.Notes;
                textNotes.ReadOnly   = false;
                Brands = Medications.GetBrands(MedicationCur.MedicationNum);
                comboBrands.Items.Clear();
                comboBrands.Items.AddRange(Brands);
                if (Brands.Length > 0)
                {
                    comboBrands.SelectedIndex = 0;
                }
            }
            else
            {
                textGenericName.Text = Medications.GetMedication(MedicationCur.GenericNum).MedName;
                textNotes.Text       = Medications.GetMedication(MedicationCur.GenericNum).Notes;
                textNotes.ReadOnly   = true;
                Brands = new string[0];
                comboBrands.Visible = false;
                labelBrands.Visible = false;
            }
            _patNameMeds = Medications.GetPatNamesForMed(MedicationCur.MedicationNum);
            comboPatients.Items.Clear();
            comboPatients.Items.AddRange(_patNameMeds);
            if (_patNameMeds.Length > 0)
            {
                comboPatients.SelectedIndex = 0;
            }
            AllergyDef alD = AllergyDefs.GetAllergyDefFromMedication(MedicationCur.MedicationNum);

            if (alD != null)
            {
                _patNameAllergies = Allergies.GetPatNamesForAllergy(alD.AllergyDefNum);
                comboPatientAllergy.Items.Clear();
                comboPatientAllergy.Items.AddRange(_patNameAllergies);
                if (_patNameAllergies.Length > 0)
                {
                    comboPatientAllergy.SelectedIndex = 0;
                }
            }
            if (CultureInfo.CurrentCulture.Name.EndsWith("US"))             //United States
            {
                textRxNormDesc.Text = RxNorms.GetDescByRxCui(MedicationCur.RxCui.ToString());
            }
            else
            {
                labelRxNorm.Visible     = false;
                textRxNormDesc.Visible  = false;
                butRxNormSelect.Visible = false;
            }
        }
Пример #2
0
        private void butIntervention_Click(object sender, EventArgs e)
        {
            if (comboInterventionCode.SelectedIndex < 0)
            {
                MsgBox.Show(this, "You must select an intervention code.");
                return;
            }
            EhrCode  iCodeCur = _listInterventionCodes[comboInterventionCode.SelectedIndex];
            DateTime dateCur  = PIn.Date(textDateIntervention.Text);

            if (iCodeCur.CodeSystem == "RXNORM" && !checkPatientDeclined.Checked)           //if patient declines the medication, enter as a declined intervention
            //codeVal will be RxCui of medication, see if it already exists in Medication table
            {
                Medication medCur = Medications.GetMedicationFromDbByRxCui(PIn.Long(iCodeCur.CodeValue));
                if (medCur == null)               //no med with this RxCui, create one
                {
                    medCur = new Medication();
                    Medications.Insert(medCur);                    //so that we will have the primary key
                    medCur.GenericNum = medCur.MedicationNum;
                    medCur.RxCui      = PIn.Long(iCodeCur.CodeValue);
                    medCur.MedName    = RxNorms.GetDescByRxCui(iCodeCur.CodeValue);
                    Medications.Update(medCur);
                    Medications.RefreshCache();                    //refresh cache to include new medication
                }
                MedicationPat medPatCur = new MedicationPat();
                medPatCur.PatNum        = PatCur.PatNum;
                medPatCur.ProvNum       = PatCur.PriProv;
                medPatCur.MedicationNum = medCur.MedicationNum;
                medPatCur.RxCui         = medCur.RxCui;
                medPatCur.DateStart     = dateCur;
                FormMedPat FormMP = new FormMedPat();
                FormMP.MedicationPatCur = medPatCur;
                FormMP.IsNew            = true;
                FormMP.ShowDialog();
                if (FormMP.DialogResult != DialogResult.OK)
                {
                    return;
                }
                if (FormMP.MedicationPatCur.DateStart.Date < dateCur.AddMonths(-6).Date || FormMP.MedicationPatCur.DateStart.Date > dateCur.Date)
                {
                    MsgBox.Show(this, "The medication order just entered is not within the 6 months prior to the date of this intervention.  You can modify the "
                                + "date of the medication order in the patient's medical history section.");
                }
            }
            else
            {
                Intervention iCur = new Intervention();
                iCur.PatNum        = PatCur.PatNum;
                iCur.ProvNum       = PatCur.PriProv;
                iCur.DateEntry     = dateCur;
                iCur.CodeValue     = iCodeCur.CodeValue;
                iCur.CodeSystem    = iCodeCur.CodeSystem;
                iCur.CodeSet       = InterventionCodeSet.TobaccoCessation;
                iCur.IsPatDeclined = checkPatientDeclined.Checked;
                Interventions.Insert(iCur);
            }
            comboInterventionCode.SelectedIndex = -1;
            FillGridInterventions();
        }
Пример #3
0
 private void FillRxCui()
 {
     if (RxDefCur.RxCui == 0)
     {
         textRxCui.Text = "";
     }
     else
     {
         textRxCui.Text = RxDefCur.RxCui.ToString() + " - " + RxNorms.GetDescByRxCui(RxDefCur.RxCui.ToString());
     }
 }
Пример #4
0
        private void butRxNorm_Click(object sender, EventArgs e)
        {
            FormRxNorms FormRN = new FormRxNorms();

            FormRN.ShowDialog();
            if (FormRN.DialogResult != DialogResult.OK)
            {
                return;
            }
            MedicationCur.RxCui = PIn.Long(FormRN.SelectedRxNorm.RxCui);
            textRxNormDesc.Text = RxNorms.GetDescByRxCui(MedicationCur.RxCui.ToString());
            if (IsNew)
            {
                textMedName.Text = RxNorms.GetDescByRxCui(MedicationCur.RxCui.ToString());
            }
        }
Пример #5
0
        private void butEdit_Click(object sender, System.EventArgs e)
        {
            Medications.Refresh();
            FormMedicationEdit FormME = new FormMedicationEdit();

            FormME.MedicationCur = Medications.GetMedication(MedicationPatCur.MedicationNum);          //The edit button is not visible if MedicationNum=0.
            FormME.ShowDialog();
            if (FormME.DialogResult != DialogResult.OK)
            {
                return;
            }
            MedicationPatCur.RxCui = FormME.MedicationCur.RxCui;
            textMedName.Text       = Medications.GetMedication(MedicationPatCur.MedicationNum).MedName; //The edit button is not visible if MedicationNum=0.
            textGenericName.Text   = Medications.GetGeneric(MedicationPatCur.MedicationNum).MedName;    //The edit button is not visible if MedicationNum=0.
            textMedNote.Text       = Medications.GetGeneric(MedicationPatCur.MedicationNum).Notes;      //The edit button is not visible if MedicationNum=0.
            textRxNormDesc.Text    = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString());
        }
Пример #6
0
 private void FillRxCui()
 {
     if (!CultureInfo.CurrentCulture.Name.EndsWith("US"))             //Not United States
     {
         labelRxNorm.Visible     = false;
         textRxCui.Visible       = false;
         butRxNormSelect.Visible = false;
         return;
     }
     if (RxDefCur.RxCui == 0)
     {
         textRxCui.Text = "";
     }
     else
     {
         textRxCui.Text = RxDefCur.RxCui.ToString() + " - " + RxNorms.GetDescByRxCui(RxDefCur.RxCui.ToString());
     }
 }
Пример #7
0
        //New Crop now handles formulary checks

        /*private void butFormulary_Click(object sender,EventArgs e) {
         *      FormFormularies FormF=new FormFormularies();
         *      FormF.IsSelectionMode=true;
         *      FormF.ShowDialog();
         *      Cursor=Cursors.WaitCursor;
         *      if(FormF.DialogResult!=DialogResult.OK) {
         *              Cursor=Cursors.Default;
         *              return;
         *      }
         *      List<FormularyMed> ListMeds=FormularyMeds.GetMedsForFormulary(FormF.SelectedFormularyNum);
         *      bool medIsInFormulary=false;
         *      for(int i=0;i<ListMeds.Count;i++) {
         *              if(ListMeds[i].MedicationNum==MedicationPatCur.MedicationNum) {
         *                      medIsInFormulary=true;
         *              }
         *      }
         *      Cursor=Cursors.Default;
         *      if(medIsInFormulary){
         *              MsgBox.Show(this,"This medication is in the selected formulary.");
         *      }
         *      else {
         *              MsgBox.Show(this,"This medication is not in the selected forumulary.");
         *      }
         * }*/

        private void butRxNormSelect_Click(object sender, EventArgs e)
        {
            FormRxNorms FormRN = new FormRxNorms();

            FormRN.IsSelectionMode          = true;
            FormRN.InitSearchCodeOrDescript = textMedName.Text;
            FormRN.ShowDialog();
            if (FormRN.DialogResult != DialogResult.OK)
            {
                return;
            }
            MedicationPatCur.RxCui = PIn.Long(FormRN.SelectedRxNorm.RxCui);
            textRxNormDesc.Text    = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString());
            if (IsNew)
            {
                textMedName.Text = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString());
            }
        }
Пример #8
0
        private void butEdit_Click(object sender, System.EventArgs e)
        {
            Medications.RefreshCache();
            FormMedicationEdit FormME = new FormMedicationEdit();
            Medication         med    = Medications.GetMedication(MedicationPatCur.MedicationNum); //The edit button is not visible if MedicationNum=0.

            if (med == null)                                                                       //Possible to delete the medication from a separate WS while medication loaded in memory.
            {
                MsgBox.Show(this, "An error occurred loading medication.");
                return;
            }
            FormME.ShowDialog();
            if (FormME.DialogResult != DialogResult.OK)
            {
                return;
            }
            MedicationPatCur.RxCui = FormME.MedicationCur.RxCui;
            textMedName.Text       = Medications.GetMedication(MedicationPatCur.MedicationNum).MedName; //The edit button is not visible if MedicationNum=0.
            textGenericName.Text   = Medications.GetGeneric(MedicationPatCur.MedicationNum).MedName;    //The edit button is not visible if MedicationNum=0.
            textMedNote.Text       = Medications.GetGeneric(MedicationPatCur.MedicationNum).Notes;      //The edit button is not visible if MedicationNum=0.
            textRxNormDesc.Text    = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString());
        }
Пример #9
0
 private void FillForm()
 {
     textMedName.Text = MedicationCur.MedName;
     if (!IsNew)
     {
         textMedName.ReadOnly = true;
     }
     if (MedicationCur.MedicationNum == MedicationCur.GenericNum)
     {
         textGenericName.Text = MedicationCur.MedName;
         textNotes.Text       = MedicationCur.Notes;
         textNotes.ReadOnly   = false;
         Brands = Medications.GetBrands(MedicationCur.MedicationNum);
         comboBrands.Items.Clear();
         comboBrands.Items.AddRange(Brands);
         if (Brands.Length > 0)
         {
             comboBrands.SelectedIndex = 0;
         }
     }
     else
     {
         textGenericName.Text = Medications.GetMedication(MedicationCur.GenericNum).MedName;
         textNotes.Text       = Medications.GetMedication(MedicationCur.GenericNum).Notes;
         textNotes.ReadOnly   = true;
         Brands = new string[0];
         comboBrands.Visible = false;
         labelBrands.Visible = false;
     }
     PatNames = Medications.GetPats(MedicationCur.MedicationNum);
     comboPatients.Items.Clear();
     comboPatients.Items.AddRange(PatNames);
     if (PatNames.Length > 0)
     {
         comboPatients.SelectedIndex = 0;
     }
     textRxNormDesc.Text = RxNorms.GetDescByRxCui(MedicationCur.RxCui.ToString());
 }
Пример #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 FillForm()
        {
            textMedName.Text = MedicationCur.MedName;
            if (!IsNew)
            {
                textMedName.ReadOnly = true;
            }
            if (MedicationCur.GenericNum == 0)
            {
                //Probably occurred from a previous bug.  This makes sure we have a generic num that is not 0.
                MedicationCur.GenericNum = MedicationCur.MedicationNum;
                MsgBox.Show(this, "This medication had a missing generic name.  The generic name has been set to the medication name.");
            }
            if (MedicationCur.MedicationNum == MedicationCur.GenericNum)
            {
                textGenericName.Text = MedicationCur.MedName;
                textNotes.Text       = MedicationCur.Notes;
                textNotes.ReadOnly   = false;
                Brands = Medications.GetBrands(MedicationCur.MedicationNum);
                comboBrands.Items.Clear();
                comboBrands.Items.AddRange(Brands);
                if (Brands.Length > 0)
                {
                    comboBrands.SelectedIndex = 0;
                }
            }
            else
            {
                textGenericName.Text = Medications.GetMedication(MedicationCur.GenericNum).MedName;
                textNotes.Text       = Medications.GetMedication(MedicationCur.GenericNum).Notes;
                textNotes.ReadOnly   = true;
                Brands = new string[0];
                comboBrands.Visible = false;
                labelBrands.Visible = false;
            }
            _patNameMeds = Medications.GetPatNamesForMed(MedicationCur.MedicationNum);
            comboPatients.Items.Clear();
            comboPatients.Items.AddRange(_patNameMeds);
            if (_patNameMeds.Length > 0)
            {
                comboPatients.SelectedIndex = 0;
            }
            AllergyDef alD = AllergyDefs.GetAllergyDefFromMedication(MedicationCur.MedicationNum);

            if (alD != null)
            {
                _patNameAllergies = Allergies.GetPatNamesForAllergy(alD.AllergyDefNum);
                comboPatientAllergy.Items.Clear();
                comboPatientAllergy.Items.AddRange(_patNameAllergies);
                if (_patNameAllergies.Length > 0)
                {
                    comboPatientAllergy.SelectedIndex = 0;
                }
            }
            if (CultureInfo.CurrentCulture.Name.EndsWith("US"))             //United States
            {
                textRxNormDesc.Text = RxNorms.GetDescByRxCui(MedicationCur.RxCui.ToString());
            }
            else
            {
                labelRxNorm.Visible     = false;
                textRxNormDesc.Visible  = false;
                butRxNormSelect.Visible = false;
            }
        }
Пример #12
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Date", 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Prov", 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Intervention Type", 115);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Code", 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Code System", 85);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Code Description", 300);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Note", 100);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            #region Interventions
            listIntervention = Interventions.Refresh(PatCur.PatNum);
            for (int i = 0; i < listIntervention.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(listIntervention[i].DateEntry.ToShortDateString());
                row.Cells.Add(Providers.GetAbbr(listIntervention[i].ProvNum));
                row.Cells.Add(listIntervention[i].CodeSet.ToString());
                row.Cells.Add(listIntervention[i].CodeValue);
                row.Cells.Add(listIntervention[i].CodeSystem);
                //Description of Intervention---------------------------------------------
                //to get description, first determine which table the code is from.  Interventions are allowed to be SNOMEDCT, ICD9, ICD10, HCPCS, or CPT.
                string descript = "";
                switch (listIntervention[i].CodeSystem)
                {
                case "SNOMEDCT":
                    Snomed sCur = Snomeds.GetByCode(listIntervention[i].CodeValue);
                    if (sCur != null)
                    {
                        descript = sCur.Description;
                    }
                    break;

                case "ICD9CM":
                    ICD9 i9Cur = ICD9s.GetByCode(listIntervention[i].CodeValue);
                    if (i9Cur != null)
                    {
                        descript = i9Cur.Description;
                    }
                    break;

                case "ICD10CM":
                    Icd10 i10Cur = Icd10s.GetByCode(listIntervention[i].CodeValue);
                    if (i10Cur != null)
                    {
                        descript = i10Cur.Description;
                    }
                    break;

                case "HCPCS":
                    Hcpcs hCur = Hcpcses.GetByCode(listIntervention[i].CodeValue);
                    if (hCur != null)
                    {
                        descript = hCur.DescriptionShort;
                    }
                    break;

                case "CPT":
                    Cpt cptCur = Cpts.GetByCode(listIntervention[i].CodeValue);
                    if (cptCur != null)
                    {
                        descript = cptCur.Description;
                    }
                    break;
                }
                row.Cells.Add(descript);
                row.Cells.Add(listIntervention[i].Note);
                row.Tag = listIntervention[i];
                gridMain.Rows.Add(row);
            }
            #endregion
            #region MedicationPats
            listMedPats = MedicationPats.Refresh(PatCur.PatNum, true);
            if (listMedPats.Count > 0)
            {
                //The following medications are used as interventions for some measures.  Include them in the intervention window if they belong to these value sets.
                //Above Normal Medications RxNorm Value Set, Below Normal Medications RxNorm Value Set, Tobacco Use Cessation Pharmacotherapy Value Set
                List <string> listVS = new List <string> {
                    "2.16.840.1.113883.3.600.1.1498", "2.16.840.1.113883.3.600.1.1499", "2.16.840.1.113883.3.526.3.1190"
                };
                List <EhrCode> listEhrMeds = EhrCodes.GetForValueSetOIDs(listVS, true);
                for (int i = listMedPats.Count - 1; i > -1; i--)
                {
                    bool found = false;
                    for (int j = 0; j < listEhrMeds.Count; j++)
                    {
                        if (listMedPats[i].RxCui.ToString() == listEhrMeds[j].CodeValue)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        listMedPats.RemoveAt(i);
                    }
                }
            }
            for (int i = 0; i < listMedPats.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(listMedPats[i].DateStart.ToShortDateString());
                row.Cells.Add(Providers.GetAbbr(listMedPats[i].ProvNum));
                if (listMedPats[i].RxCui == 314153 || listMedPats[i].RxCui == 692876)
                {
                    row.Cells.Add(InterventionCodeSet.AboveNormalWeight.ToString() + " Medication");
                }
                else if (listMedPats[i].RxCui == 577154 || listMedPats[i].RxCui == 860215 || listMedPats[i].RxCui == 860221 || listMedPats[i].RxCui == 860225 || listMedPats[i].RxCui == 860231)
                {
                    row.Cells.Add(InterventionCodeSet.BelowNormalWeight.ToString() + " Medication");
                }
                else                  //There are 48 total medications that can be used as interventions.  The remaining 41 medications are tobacco cessation medications
                {
                    row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication");
                }
                row.Cells.Add(listMedPats[i].RxCui.ToString());
                row.Cells.Add("RXNORM");
                //Medications that are used as interventions are all RxNorm codes, get description from that table
                string descript = RxNorms.GetDescByRxCui(listMedPats[i].RxCui.ToString());
                row.Cells.Add(descript);
                row.Cells.Add(listMedPats[i].PatNote);
                row.Tag = listMedPats[i];
                gridMain.Rows.Add(row);
            }
            #endregion
            gridMain.EndUpdate();
        }
Пример #13
0
 private void FormMedPat_Load(object sender, System.EventArgs e)
 {
     if (PrefC.GetBool(PrefName.ShowFeatureEhr))
     {
         labelPatNote.Text = "Count, Instructions, and Refills";
         groupOrder.Text   = "Medication Order";
     }
     //Formulary checks now handled in NewCrop
     //else {
     //	butFormulary.Visible=false;
     //}
     if (CultureInfo.CurrentCulture.Name.EndsWith("US"))             //United States
     {
         textRxNormDesc.Text = RxNorms.GetDescByRxCui(MedicationPatCur.RxCui.ToString());
         if (Erx.IsFromErx(MedicationPatCur.ErxGuid))                 //This is a medical order that was automatically created when fetching prescriptions from eRx.
         //We allow the user to change the RxCui on the medical order, because eRx does not always supply an RxCui.
         //Also the MedicaitonNum on the order will always be 0, so there is no link between the order and the medication table.
         //If MedicationOrder was non-zero and we changed the RxCui on the order, then the automatic sync between medicationpat.RxCui and medication.RxCui would be tainted.
         {
             butRxNormSelect.Visible = true;
         }
     }
     else
     {
         labelRxNorm.Visible    = false;
         textRxNormDesc.Visible = false;
     }
     if (MedicationPatCur.MedicationNum == 0)           //Probably a medical order created during eRx prescription fetching, but not necessarily.
     {
         textMedName.Text          = MedicationPatCur.MedDescript;
         labelGenericNotes.Visible = false;
         labelGenericName.Visible  = false;
         textGenericName.Visible   = false;
         textMedNote.Visible       = false;
         butEdit.Visible           = false;
         labelEdit.Visible         = false;
     }
     else
     {
         textMedName.Text     = Medications.GetMedication(MedicationPatCur.MedicationNum).MedName;
         textGenericName.Text = Medications.GetGeneric(MedicationPatCur.MedicationNum).MedName;
         textMedNote.Text     = Medications.GetGeneric(MedicationPatCur.MedicationNum).Notes;
     }
     comboProv.Items.Add(Lan.g(this, "none"));
     _listProviders = Providers.GetDeepCopy(true);
     for (int i = 0; i < _listProviders.Count; i++)
     {
         comboProv.Items.Add(_listProviders[i].GetLongDesc());
     }
     if (MedicationPatCur.ProvNum == 0)
     {
         comboProv.SelectedIndex = 0;
     }
     else
     {
         for (int i = 0; i < _listProviders.Count; i++)
         {
             if (MedicationPatCur.ProvNum == _listProviders[i].ProvNum)
             {
                 comboProv.SelectedIndex = i + 1;
             }
         }
         //if a provider was subsequently hidden, then the combobox may now be -1.
     }
     if (MedicationPatCur.IsCpoe)
     {
         //We cannot allow the user to change the provider, because our EHR reports use the provider in combination with the IsCpoe flag to report CPOE.
         comboProv.Enabled = false;
     }
     textPatNote.Text = MedicationPatCur.PatNote;
     if (MedicationPatCur.DateStart.Year > 1880)
     {
         textDateStart.Text = MedicationPatCur.DateStart.ToShortDateString();
     }
     if (MedicationPatCur.DateStop.Year > 1880)
     {
         textDateStop.Text = MedicationPatCur.DateStop.ToShortDateString();
     }
     if (IsNew)
     {
         butEdit.Visible   = false;
         labelEdit.Visible = false;
     }
 }
Пример #14
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Code", 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("CodeSystem", 90);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Description", 200);
            gridMain.Columns.Add(col);
            string        selectedValue  = comboCodeSet.SelectedItem.ToString();
            List <string> listValSetOIDs = new List <string>();

            if (selectedValue == "All")
            {
                listValSetOIDs = new List <string>(dictValueCodeSets.Values);
            }
            else              //this will limit the codes to only one value set oid
            {
                listValSetOIDs.Add(dictValueCodeSets[selectedValue]);
            }
            listCodes = EhrCodes.GetForValueSetOIDs(listValSetOIDs, true);         //these codes will exist in the corresponding table or will not be in the list
            gridMain.Rows.Clear();
            ODGridRow row;
            int       selectedIdx = -1;

            for (int i = 0; i < listCodes.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(listCodes[i].CodeValue);
                row.Cells.Add(listCodes[i].CodeSystem);
                //Retrieve description from the associated table
                string descript = "";
                switch (listCodes[i].CodeSystem)
                {
                case "CPT":
                    Cpt cCur = Cpts.GetByCode(listCodes[i].CodeValue);
                    if (cCur != null)
                    {
                        descript = cCur.Description;
                    }
                    break;

                case "HCPCS":
                    Hcpcs hCur = Hcpcses.GetByCode(listCodes[i].CodeValue);
                    if (hCur != null)
                    {
                        descript = hCur.DescriptionShort;
                    }
                    break;

                case "ICD9CM":
                    ICD9 i9Cur = ICD9s.GetByCode(listCodes[i].CodeValue);
                    if (i9Cur != null)
                    {
                        descript = i9Cur.Description;
                    }
                    break;

                case "ICD10CM":
                    Icd10 i10Cur = Icd10s.GetByCode(listCodes[i].CodeValue);
                    if (i10Cur != null)
                    {
                        descript = i10Cur.Description;
                    }
                    break;

                case "RXNORM":
                    descript = RxNorms.GetDescByRxCui(listCodes[i].CodeValue);
                    break;

                case "SNOMEDCT":
                    Snomed sCur = Snomeds.GetByCode(listCodes[i].CodeValue);
                    if (sCur != null)
                    {
                        descript = sCur.Description;
                    }
                    break;
                }
                row.Cells.Add(descript);
                gridMain.Rows.Add(row);
                if (listCodes[i].CodeValue == InterventionCur.CodeValue && listCodes[i].CodeSystem == InterventionCur.CodeSystem)
                {
                    selectedIdx = i;
                }
            }
            gridMain.EndUpdate();
            if (selectedIdx > -1)
            {
                gridMain.SetSelected(selectedIdx, true);
                gridMain.ScrollToIndex(selectedIdx);
            }
        }
Пример #15
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //validate--------------------------------------
            DateTime date;

            if (textDate.Text == "")
            {
                MsgBox.Show(this, "Please enter a date.");
                return;
            }
            try {
                date = DateTime.Parse(textDate.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix date first.");
                return;
            }
            string codeVal = "";
            string codeSys = "";

            if (gridMain.GetSelectedIndex() == -1)           //no intervention code selected
            {
                MsgBox.Show(this, "You must select a code for this intervention.");
                return;
            }
            else
            {
                codeVal = listCodes[gridMain.GetSelectedIndex()].CodeValue;
                codeSys = listCodes[gridMain.GetSelectedIndex()].CodeSystem;
            }
            //save--------------------------------------
            //Intervention grid may contain medications, have to insert a new med if necessary and load FormMedPat for user to input data
            if (codeSys == "RXNORM" && !checkPatientDeclined.Checked)
            {
                //codeVal will be RxCui of medication, see if it already exists in Medication table
                Medication medCur = Medications.GetMedicationFromDbByRxCui(PIn.Long(codeVal));
                if (medCur == null)               //no med with this RxCui, create one
                {
                    medCur = new Medication();
                    Medications.Insert(medCur);                    //so that we will have the primary key
                    medCur.GenericNum = medCur.MedicationNum;
                    medCur.RxCui      = PIn.Long(codeVal);
                    medCur.MedName    = RxNorms.GetDescByRxCui(codeVal);
                    Medications.Update(medCur);
                    Medications.RefreshCache();                    //refresh cache to include new medication
                }
                MedicationPat medPatCur = new MedicationPat();
                medPatCur.PatNum        = InterventionCur.PatNum;
                medPatCur.ProvNum       = InterventionCur.ProvNum;
                medPatCur.MedicationNum = medCur.MedicationNum;
                medPatCur.RxCui         = medCur.RxCui;
                medPatCur.DateStart     = date;
                FormMedPat FormMP = new FormMedPat();
                FormMP.MedicationPatCur = medPatCur;
                FormMP.IsNew            = true;
                FormMP.ShowDialog();
                if (FormMP.DialogResult != DialogResult.OK)
                {
                    return;
                }
                if (FormMP.MedicationPatCur.DateStart.Date < InterventionCur.DateEntry.AddMonths(-6).Date || FormMP.MedicationPatCur.DateStart.Date > InterventionCur.DateEntry.Date)
                {
                    MsgBox.Show(this, "The medication order just entered is not within the 6 months prior to the date of this intervention.  You can modify the date of the medication order in the patient's medical history section.");
                }
                DialogResult = DialogResult.OK;
                return;
            }
            InterventionCur.DateEntry     = date;
            InterventionCur.CodeValue     = codeVal;
            InterventionCur.CodeSystem    = codeSys;
            InterventionCur.Note          = textNote.Text;
            InterventionCur.IsPatDeclined = checkPatientDeclined.Checked;
            string selectedCodeSet = comboCodeSet.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];

            if (IsAllTypes)                   //CodeSet will be set by calling function unless showing all types, in which case we need to determine which InterventionCodeSet to assign
            {
                if (selectedCodeSet == "All") //All types showing and set to All, have to determine which InterventionCodeSet this code belongs to
                {
                    List <string> listVSFound = new List <string>();
                    foreach (KeyValuePair <string, string> kvp in dictValueCodeSets)
                    {
                        List <EhrCode> listCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                            kvp.Value
                        }, true);
                        for (int i = 0; i < listCodes.Count; i++)
                        {
                            if (listCodes[i].CodeValue == codeVal)
                            {
                                listVSFound.Add(kvp.Key);
                                break;
                            }
                        }
                    }
                    if (listVSFound.Count > 1)                   //Selected code found in more than one value set, ask the user which InterventionCodeSet to assign to this intervention
                    {
                        InputBox chooseSet = new InputBox(Lan.g(this, "The selected code belongs to more than one intervention code set.  Select the code set to assign to this intervention from the list below."), listVSFound);
                        if (chooseSet.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        if (chooseSet.comboSelection.SelectedIndex == -1)
                        {
                            MsgBox.Show(this, "You must select an intervention code set for the selected code.");
                            return;
                        }
                        selectedCodeSet = chooseSet.comboSelection.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    }
                    else                      //the code must belong to at least one value set, since count in listVSFound is not greater than 1, it must be a code from exactly one set, use that for the InterventionCodeSet
                    {
                        selectedCodeSet = listVSFound[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    }
                }
                InterventionCur.CodeSet = (InterventionCodeSet)Enum.Parse(typeof(InterventionCodeSet), selectedCodeSet);
            }
            //Nutrition is used for both nutrition and physical activity counseling for children, we have to determine which set this code belongs to
            else if (InterventionCur.CodeSet == InterventionCodeSet.Nutrition && selectedCodeSet != "Nutrition") //Nutrition set by calling form, user is showing all or physical activity codes only
            {
                if (selectedCodeSet == "All")                                                                    //showing all codes from Nutrition and PhysicalActivity interventions, determine which set it belongs to
                //No codes exist in both code sets, so if it is not in the PhysicalActivity code set, we can safely assume this is a Nutrition intervention
                {
                    List <EhrCode> listCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                        dictValueCodeSets[InterventionCodeSet.PhysicalActivity.ToString() + " Counseling"]
                    }, true);
                    for (int i = 0; i < listCodes.Count; i++)
                    {
                        if (listCodes[i].CodeValue == codeVal)
                        {
                            InterventionCur.CodeSet = InterventionCodeSet.PhysicalActivity;
                            break;
                        }
                    }
                }
                else
                {
                    InterventionCur.CodeSet = InterventionCodeSet.PhysicalActivity;
                }
            }
            else
            {
                //if not all types, and not Nutrition with All or PhysicalActivity selected in combo box, the code set sent in by calling form will remain the code set for this intervention
            }
            if (InterventionCur.IsNew)
            {
                Interventions.Insert(InterventionCur);
            }
            else
            {
                Interventions.Update(InterventionCur);
            }
            DialogResult = DialogResult.OK;
        }
Пример #16
0
        private void FillGridInterventions()
        {
            gridInterventions.BeginUpdate();
            gridInterventions.Columns.Clear();
            gridInterventions.Columns.Add(new ODGridColumn("Date", 70));
            gridInterventions.Columns.Add(new ODGridColumn("Type", 150));
            gridInterventions.Columns.Add(new ODGridColumn("Description", 160));
            gridInterventions.Columns.Add(new ODGridColumn("Declined", 60)
            {
                TextAlign = HorizontalAlignment.Center
            });
            gridInterventions.Columns.Add(new ODGridColumn("Documentation", 140));
            gridInterventions.Rows.Clear();
            //build list of rows of CessationInterventions and CessationMedications so we can order the list by date and type before filling the grid
            List <ODGridRow> listRows = new List <ODGridRow>();
            ODGridRow        row;

            #region CessationInterventions
            List <Intervention> listInterventions = Interventions.Refresh(PatCur.PatNum, InterventionCodeSet.TobaccoCessation);
            foreach (Intervention iCur in listInterventions)
            {
                row = new ODGridRow();
                row.Cells.Add(iCur.DateEntry.ToShortDateString());
                string type     = InterventionCodeSet.TobaccoCessation.ToString() + " Counseling";
                string descript = "";
                switch (iCur.CodeSystem)
                {
                case "CPT":
                    Cpt cptCur = Cpts.GetByCode(iCur.CodeValue);
                    descript = cptCur != null?cptCur.Description:"";
                    break;

                case "SNOMEDCT":
                    Snomed sCur = Snomeds.GetByCode(iCur.CodeValue);
                    descript = sCur != null?sCur.Description:"";
                    break;

                case "RXNORM":
                    //if the user checks the "Patient Declined" checkbox, we enter the tobacco cessation medication as an intervention that was declined
                    type = InterventionCodeSet.TobaccoCessation.ToString() + " Medication";
                    RxNorm rCur = RxNorms.GetByRxCUI(iCur.CodeValue);
                    descript = rCur != null?rCur.Description:"";
                    break;
                }
                row.Cells.Add(type);
                row.Cells.Add(descript);
                row.Cells.Add(iCur.IsPatDeclined?"X":"");
                row.Cells.Add(iCur.Note);
                row.Tag = iCur;
                listRows.Add(row);
            }
            #endregion
            #region CessationMedications
            //Tobacco Use Cessation Pharmacotherapy Value Set
            string[] arrayRxCuiStrings = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1190"
            }, true)
                                         .Select(x => x.CodeValue).ToArray();
            //arrayRxCuiStrings will contain 41 RxCui strings for tobacco cessation medications if those exist in the rxnorm table
            List <MedicationPat> listMedPats = MedicationPats.Refresh(PatCur.PatNum, true).FindAll(x => arrayRxCuiStrings.Contains(x.RxCui.ToString()));
            foreach (MedicationPat medPatCur in listMedPats)
            {
                row = new ODGridRow();
                List <string> listMedDates = new List <string>();
                if (medPatCur.DateStart.Year > 1880)
                {
                    listMedDates.Add(medPatCur.DateStart.ToShortDateString());
                }
                if (medPatCur.DateStop.Year > 1880)
                {
                    listMedDates.Add(medPatCur.DateStop.ToShortDateString());
                }
                if (listMedDates.Count == 0)
                {
                    listMedDates.Add(medPatCur.DateTStamp.ToShortDateString());
                }
                row.Cells.Add(string.Join(" - ", listMedDates));
                row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication");
                row.Cells.Add(RxNorms.GetDescByRxCui(medPatCur.RxCui.ToString()));
                row.Cells.Add(medPatCur.PatNote);
                row.Tag = medPatCur;
                listRows.Add(row);
            }
            #endregion
            listRows.OrderBy(x => PIn.Date(x.Cells[0].Text))            //rows ordered by date, oldest first
            .ThenBy(x => x.Cells[3].Text != "")
            //interventions at the top, declined med interventions below normal interventions
            .ThenBy(x => x.Tag.GetType().Name != "Intervention" || ((Intervention)x.Tag).CodeSystem == "RXNORM").ToList()
            .ForEach(x => gridInterventions.Rows.Add(x));                    //then add rows to gridInterventions
            gridInterventions.EndUpdate();
        }
Пример #17
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Date", 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Type", 170);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Description", 170);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Documentation", 170);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow        row;
            List <ODGridRow> listRows = new List <ODGridRow>();

            #region AssessedEvents
            _ListEvents = EhrMeasureEvents.RefreshByType(PatCur.PatNum, EhrMeasureEventType.TobaccoUseAssessed);
            for (int i = 0; i < _ListEvents.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(_ListEvents[i].DateTEvent.ToShortDateString());
                Loinc lCur = Loincs.GetByCode(_ListEvents[i].CodeValueEvent);              //TobaccoUseAssessed events can be one of three types, all LOINC codes
                if (lCur != null)
                {
                    row.Cells.Add(lCur.NameLongCommon);
                }
                else
                {
                    row.Cells.Add(_ListEvents[i].EventType.ToString());
                }
                Snomed sCur = Snomeds.GetByCode(_ListEvents[i].CodeValueResult);
                if (sCur != null)
                {
                    row.Cells.Add(sCur.Description);
                }
                else
                {
                    row.Cells.Add("");
                }
                row.Cells.Add(_ListEvents[i].MoreInfo);
                row.Tag = _ListEvents[i];
                listRows.Add(row);
            }
            #endregion
            #region CessationInterventions
            _ListInterventions = Interventions.Refresh(PatCur.PatNum, InterventionCodeSet.TobaccoCessation);
            for (int i = 0; i < _ListInterventions.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(_ListInterventions[i].DateEntry.ToShortDateString());
                row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Counseling");
                string descript = "";
                switch (_ListInterventions[i].CodeSystem)
                {
                case "CPT":
                    Cpt cptCur = Cpts.GetByCode(_ListInterventions[i].CodeValue);
                    if (cptCur != null)
                    {
                        descript = cptCur.Description;
                    }
                    break;

                case "SNOMEDCT":
                    Snomed sCur = Snomeds.GetByCode(_ListInterventions[i].CodeValue);
                    if (sCur != null)
                    {
                        descript = sCur.Description;
                    }
                    break;
                }
                row.Cells.Add(descript);
                row.Cells.Add(_ListInterventions[i].Note);
                row.Tag = _ListInterventions[i];
                listRows.Add(row);
            }
            #endregion
            #region CessationMedications
            _ListMedPats = MedicationPats.Refresh(PatCur.PatNum, true);
            List <EhrCode> listEhrMeds = EhrCodes.GetForValueSetOIDs(new List <string> {
                "2.16.840.1.113883.3.526.3.1190"
            }, true);                                                                                                                     //Tobacco Use Cessation Pharmacotherapy Value Set
            //listEhrMeds will contain 41 medications for tobacco cessation if those exist in the rxnorm table
            for (int i = _ListMedPats.Count - 1; i > -1; i--)
            {
                bool found = false;
                for (int j = 0; j < listEhrMeds.Count; j++)
                {
                    if (_ListMedPats[i].RxCui.ToString() == listEhrMeds[j].CodeValue)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    _ListMedPats.RemoveAt(i);
                }
            }
            for (int i = 0; i < _ListMedPats.Count; i++)
            {
                row = new ODGridRow();
                string dateRange = "";
                if (_ListMedPats[i].DateStart.Year > 1880)
                {
                    dateRange = _ListMedPats[i].DateStart.ToShortDateString();
                }
                if (_ListMedPats[i].DateStop.Year > 1880)
                {
                    if (dateRange != "")
                    {
                        dateRange += " - ";
                    }
                    dateRange += _ListMedPats[i].DateStop.ToShortDateString();
                }
                if (dateRange == "")
                {
                    dateRange = _ListMedPats[i].DateTStamp.ToShortDateString();
                }
                row.Cells.Add(dateRange);
                row.Cells.Add(InterventionCodeSet.TobaccoCessation.ToString() + " Medication");
                string medDescript = RxNorms.GetDescByRxCui(_ListMedPats[i].RxCui.ToString());
                row.Cells.Add(medDescript);
                row.Cells.Add(_ListMedPats[i].PatNote);
                row.Tag = _ListMedPats[i];
                listRows.Add(row);
            }
            #endregion
            listRows.Sort(SortDate);
            for (int i = 0; i < listRows.Count; i++)
            {
                gridMain.Rows.Add(listRows[i]);
            }
            gridMain.EndUpdate();
        }