示例#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);
             }
         }
     }
 }
        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();
        }
        private void FillMeds()
        {
            Medications.RefreshCache();
            medList = MedicationPats.Refresh(PatCur.PatNum, checkDiscontinued.Checked);
            gridMeds.BeginUpdate();
            gridMeds.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableMedications", "Medication"), 140);

            gridMeds.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableMedications", "Notes for Patient"), 225);
            gridMeds.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableMedications", "Disc"), 10, HorizontalAlignment.Center);       //discontinued
            gridMeds.Columns.Add(col);
            gridMeds.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < medList.Count; i++)
            {
                row = new ODGridRow();
                if (medList[i].MedicationNum == 0)
                {
                    row.Cells.Add(medList[i].MedDescript);
                }
                else
                {
                    Medication generic = Medications.GetGeneric(medList[i].MedicationNum);
                    string     medName = Medications.GetMedication(medList[i].MedicationNum).MedName;
                    if (generic.MedicationNum != medList[i].MedicationNum)                   //not generic
                    {
                        medName += " (" + generic.MedName + ")";
                    }
                    row.Cells.Add(medName);
                }
                row.Cells.Add(medList[i].PatNote);
                if (MedicationPats.IsMedActive(medList[i]))
                {
                    row.Cells.Add("");
                }
                else                  //discontinued
                {
                    row.Cells.Add("X");
                }
                gridMeds.Rows.Add(row);
            }
            gridMeds.EndUpdate();
        }
示例#4
0
        private void butEdit_Click(object sender, System.EventArgs e)
        {
            Medications.RefreshCache();
            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());
        }
示例#5
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());
        }
示例#6
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;
        }
示例#7
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);
        }