コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: FormEhrOnlineAccess.cs プロジェクト: nampn/ODental
        private void butGiveAccess_Click(object sender, EventArgs e)
        {
            string interval = PrefC.GetStringSilent(PrefName.MobileSyncIntervalMinutes);

            if (interval == "" || interval == "0")         //not a paid customer or chooses not to synch
            {
                MessageBox.Show("Synch must be setup first from the Tools menu, Mobile and Patient Portal Synch.  Interval must not be blank or zero.");
                return;
            }
            //we won't check PrefName.MobileSyncWorkstationName because we are forcing the synch
            if (System.Environment.MachineName.ToUpper() != PrefC.GetStringSilent(PrefName.MobileSyncWorkstationName).ToUpper())
            {
                //Since GetStringSilent returns "" before OD is connected to db, this gracefully loops out
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel,
                                 "Warning.  Workstation is not entered in the Tools menu, Mobile and Patient Portal Synch.  No automatic synch is taking place.  Continue anyway?"))
                {
                    return;
                }
            }
            if (PrefC.GetDate(PrefName.MobileExcludeApptsBeforeDate).Year < 1880)
            {
                MessageBox.Show("Full Synch must be run first first from the Tools menu, Mobile and Patient Portal Synch.");
                return;
            }
            if (butGiveAccess.Text == "Provide Online Access")           //When form open opens with a blank password
            {
                Cursor = Cursors.WaitCursor;
                //1. Fill password.
                textOnlinePassword.Text = GenerateRandomPassword(8, 10);             //won't save until OK or Print
                //2. Fill link.
                textOnlineLink.Text = GetPatientPortalLink();
                //3. Reset timestamps for this patient to trigger all their objects to upload with the next synch
                LabPanels.ResetTimeStamps(PatCur.PatNum);
                Diseases.ResetTimeStamps(PatCur.PatNum);
                Allergies.ResetTimeStamps(PatCur.PatNum);
                MedicationPats.ResetTimeStamps(PatCur.PatNum);
                Statements.ResetTimeStamps(PatCur.PatNum);
                Documents.ResetTimeStamps(PatCur.PatNum);
                //4. Make the password editable in case they want to change it.
                textOnlinePassword.ReadOnly = false;
                //5. Save password to db
                PatCur.OnlinePassword = textOnlinePassword.Text;
                Patients.Update(PatCur, PatOld);
                PatOld.OnlinePassword = textOnlinePassword.Text;              //so that subsequent Updates will work.
                //6. Force a synch
                FormMobile.SynchFromMain(true);
                //7. Insert EhrMeasureEvent
                EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
                newMeasureEvent.DateTEvent = DateTime.Now;
                newMeasureEvent.EventType  = EhrMeasureEventType.OnlineAccessProvided;
                newMeasureEvent.PatNum     = PatCur.PatNum;
                newMeasureEvent.MoreInfo   = "";
                EhrMeasureEvents.Insert(newMeasureEvent);
                //8. Rename button
                butGiveAccess.Text = "Remove Online Access";
                Cursor             = Cursors.Default;
            }
            else              //remove access
            {
                Cursor = Cursors.WaitCursor;
                //1. Clear password
                textOnlinePassword.Text = "";
                //2. Make in uneditable
                textOnlinePassword.ReadOnly = true;
                //3. Save password to db
                PatCur.OnlinePassword = textOnlinePassword.Text;
                Patients.Update(PatCur, PatOld);
                PatOld.OnlinePassword = textOnlinePassword.Text;
                //5. Force a synch
                FormMobile.SynchFromMain(true);
                //no event to insert
                //6. Rename button
                butGiveAccess.Text = "Provide Online Access";
                Cursor             = Cursors.Default;
            }
        }