Beispiel #1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDateStart.errorProvider1.GetError(textDateStart) != "" ||
         textDateStop.errorProvider1.GetError(textDateStop) != ""
         )
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (IsNewMedOrder)
     {
         if (textPatNote.Text == "" || textDateStart.Text == "")
         {
             MsgBox.Show(this, "For a new medical order, instructions and a start date are required.");
             return;
         }
     }
     //MedicationPatCur.MedicationNum is already set before entering this window, or else changed up above.
     if (comboProv.SelectedIndex == -1)
     {
         //don't make any changes to provnum.  ProvNum is a hidden prov.
     }
     else if (comboProv.SelectedIndex == 0)
     {
         MedicationPatCur.ProvNum = 0;
     }
     else
     {
         MedicationPatCur.ProvNum = _listProviders[comboProv.SelectedIndex - 1].ProvNum;
     }
     MedicationPatCur.PatNote   = textPatNote.Text;
     MedicationPatCur.DateStart = PIn.Date(textDateStart.Text);
     MedicationPatCur.DateStop  = PIn.Date(textDateStop.Text);
     if (IsNew)
     {
         MedicationPats.Insert(MedicationPatCur);
         if (MedicationPatCur.MedicationNum == 0)
         {
             SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, MedicationPatCur.MedDescript + " added");
         }
         else
         {
             SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, Medications.GetMedication(MedicationPatCur.MedicationNum).MedName + " added");
         }
     }
     else
     {
         MedicationPats.Update(MedicationPatCur);
         if (MedicationPatCur.MedicationNum == 0)
         {
             SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, MedicationPatCur.MedDescript + " edited");
         }
         else
         {
             SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, Medications.GetMedication(MedicationPatCur.MedicationNum).MedName + " edited");
         }
     }
     DialogResult = DialogResult.OK;
 }
Beispiel #2
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     MedicationPatCur.PatNote = textPatNote.Text;
     if (IsNew)
     {
         MedicationPats.Insert(MedicationPatCur);
     }
     else
     {
         MedicationPats.Update(MedicationPatCur);
     }
     DialogResult = DialogResult.OK;
 }
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listMedicationPatReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing medications to be removed.  Continue?"))
                {
                    return;
                }
            }
            MedicationPat medP;
            bool          isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listMedicationPatCur.Count; i++)       //Start looping through all current medications
            {
                isActive = false;
                medP     = _listMedicationPatCur[i];
                for (int j = 0; j < _listMedicationPatReconcile.Count; j++)                                                                                                             //Compare each reconcile medication to the current medication
                {
                    if (medP.RxCui > 0 && medP.RxCui == _listMedicationPatReconcile[j].RxCui && _listMedicationPatReconcile[j].MedicationNum == _listMedicationPatCur[i].MedicationNum) //Has an RxNorm code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)                                        //Update current medications.
                {
                    _listMedicationPatCur[i].DateStop = DateTime.Now; //Set the current DateStop to today (to set the medication as discontinued)
                    MedicationPats.Update(_listMedicationPatCur[i]);
                }
            }
            //Always update every current medication for the patient so that DateTStamp reflects the last reconcile date.
            if (_listMedicationPatCur.Count > 0)
            {
                MedicationPats.ResetTimeStamps(_patCur.PatNum, true);
            }
            Medication med;
            int        index;

            for (int j = 0; j < _listMedicationPatReconcile.Count; j++)
            {
                index = ListMedicationPatNew.IndexOf(_listMedicationPatReconcile[j]);
                if (index < 0)
                {
                    continue;
                }
                if (_listMedicationPatReconcile[j] == ListMedicationPatNew[index])
                {
                    med = Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[j].RxCui);
                    if (med == null)
                    {
                        med         = new Medication();
                        med.MedName = ListMedicationPatNew[index].MedDescript;
                        med.RxCui   = ListMedicationPatNew[index].RxCui;
                        ListMedicationPatNew[index].MedicationNum = Medications.Insert(med);
                        med.GenericNum = med.MedicationNum;
                        Medications.Update(med);
                    }
                    else
                    {
                        ListMedicationPatNew[index].MedicationNum = med.MedicationNum;
                    }
                    ListMedicationPatNew[index].ProvNum = 0;                  //Since imported, set provnum to 0 so it does not affect CPOE.
                    MedicationPats.Insert(ListMedicationPatNew[index]);
                }
            }
            EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();

            newMeasureEvent.DateTEvent = DateTime.Now;
            newMeasureEvent.EventType  = EhrMeasureEventType.MedicationReconcile;
            newMeasureEvent.PatNum     = _patCur.PatNum;
            newMeasureEvent.MoreInfo   = "";
            EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listMedicationPatReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS)
                {
                    Medication          medInter = Medications.GetMedicationFromDbByRxCui(_listMedicationPatReconcile[inter].RxCui);
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(medInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }