Esempio n. 1
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn("Description", 200);

            gridMain.Columns.Add(col);
            col = new ODGridColumn("Cardinality", 140);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Trigger Categories", 200);
            gridMain.Columns.Add(col);
            ListEhrTriggers = EhrTriggers.GetAll();
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < ListEhrTriggers.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(ListEhrTriggers[i].Description);
                row.Cells.Add(ListEhrTriggers[i].Cardinality.ToString());
                row.Cells.Add(ListEhrTriggers[i].GetTriggerCategories());
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
Esempio n. 2
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormEhrTriggerEdit FormETE = new FormEhrTriggerEdit();

            FormETE.EhrTriggerCur = ListEhrTriggers[e.Row];
            FormETE.ShowDialog();
            if (FormETE.DialogResult != DialogResult.OK)
            {
                return;
            }
            ListEhrTriggers = EhrTriggers.GetAll();
            FillGrid();
        }
Esempio n. 3
0
 private void butSave_Click(object sender, EventArgs e)
 {
     if (PatCur == null)
     {
         MsgBox.Show(this, "Please attach to patient first.");
         return;
     }
     //Check lab dates to see if these labs already exist.
     for (int i = 0; i < ListEhrLabs.Count; i++)
     {
         EhrLab tempLab = null;              //lab from DB if it exists.
         tempLab = EhrLabs.GetByGUID(ListEhrLabs[i].PlacerOrderUniversalID, ListEhrLabs[i].PlacerOrderNum);
         if (tempLab == null)
         {
             tempLab = EhrLabs.GetByGUID(ListEhrLabs[i].FillerOrderUniversalID, ListEhrLabs[i].FillerOrderNum);
         }
         if (tempLab != null)
         {
             //validate Date of Lab and attached patient.
             //Date
             if (tempLab.ResultDateTime.CompareTo(ListEhrLabs[i].ResultDateTime) < 0)                   //string compare dates will return 1+ if tempLab Date is greater.
             {
                 MsgBox.Show(this, "This lab already exists in the database and has a more recent timestamp.");
                 continue;
             }
             if (PatCur.PatNum != tempLab.PatNum)
             {
                 //do nothing. We are importing an updated lab result and the previous lab result was attached to the wrong patient.
                 //or do something. later maybe.
             }
         }
         ListEhrLabs[i].PatNum = PatCur.PatNum;
         Provider prov = Providers.GetProv(Security.CurUser.ProvNum);
         if (Security.CurUser.ProvNum != 0 && EhrProvKeys.GetKeysByFLName(prov.LName, prov.FName).Count > 0)            //The user who is currently logged in is a provider and has a valid EHR key.
         {
             ListEhrLabs[i].IsCpoe = true;
         }
         ListEhrLabs[i] = EhrLabs.SaveToDB(ListEhrLabs[i]);               //SAVE
         for (int j = 0; j < ListEhrLabs[i].ListEhrLabResults.Count; j++) //EHR TRIGGER
         {
             if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
             {
                 FormCDSIntervention FormCDSI = new FormCDSIntervention();
                 FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(ListEhrLabs[i].ListEhrLabResults[j], PatCur);
                 FormCDSI.ShowIfRequired(false);
             }
         }
     }
     DialogResult = DialogResult.OK;
     //Done!
 }
Esempio n. 4
0
        private void butAddTrigger_Click(object sender, EventArgs e)
        {
            FormEhrTriggerEdit FormETE = new FormEhrTriggerEdit();

            FormETE.EhrTriggerCur = new EhrTrigger();
            FormETE.IsNew         = true;
            FormETE.ShowDialog();
            if (FormETE.DialogResult != DialogResult.OK)
            {
                return;
            }
            ListEhrTriggers = EhrTriggers.GetAll();
            FillGrid();
        }
Esempio n. 5
0
 private void butOK_Click(object sender, EventArgs e)
 {
     EhrTriggerCur.Description  = textDescription.Text;
     EhrTriggerCur.Instructions = textInstruction.Text;
     EhrTriggerCur.Bibliography = textBibliography.Text;
     if (IsNew)
     {
         EhrTriggers.Insert(EhrTriggerCur);
     }
     else
     {
         EhrTriggers.Update(EhrTriggerCur);
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 6
0
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)             //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                return;
            }
            if (e.Col != 0)
            {
                return;
            }
            List <KnowledgeRequest> listKnowledgeRequests = EhrTriggers.ConvertToKnowledgeRequests(Snomeds.GetByCode(gridMain.Rows[e.Row].Cells[1].Text));
            FormInfobutton          FormIB = new FormInfobutton(listKnowledgeRequests);

            FormIB.ShowDialog();
        }
Esempio n. 7
0
        private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
        {
            if (!CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowInfobutton)             //Security.IsAuthorized(Permissions.EhrInfoButton,true)) {
            {
                return;
            }
            if (e.Col != 0)
            {
                return;
            }
            List <KnowledgeRequest> listKnowledgeRequests = EhrTriggers.ConvertToKnowledgeRequests(EhrLabCur.ListEhrLabResults[e.Row]);
            FormInfobutton          FormIB = new FormInfobutton(listKnowledgeRequests);

            //if(PatCurNum>0) {
            //	FormIB.PatCur=Patients.GetPat(PatCurNum);
            //}
            FormIB.ShowDialog();
        }
Esempio n. 8
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormEhrLabOrderEdit2014 FormLOE = new FormEhrLabOrderEdit2014();

            FormLOE.EhrLabCur        = new EhrLab();
            FormLOE.EhrLabCur.PatNum = PatCur.PatNum;
            FormLOE.IsNew            = true;
            FormLOE.ShowDialog();
            if (FormLOE.DialogResult != DialogResult.OK)
            {
                return;
            }
            EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();

            newMeasureEvent.DateTEvent = DateTime.Now;
            newMeasureEvent.EventType  = EhrMeasureEventType.CPOE_LabOrdered;         //default
            Loinc loinc = Loincs.GetByCode(FormLOE.EhrLabCur.UsiID);

            if (loinc != null && loinc.ClassType == "RAD")         //short circuit logic
            {
                newMeasureEvent.EventType = EhrMeasureEventType.CPOE_RadOrdered;
            }
            newMeasureEvent.PatNum   = FormLOE.EhrLabCur.PatNum;
            newMeasureEvent.MoreInfo = "";
            newMeasureEvent.FKey     = FormLOE.EhrLabCur.EhrLabNum;
            EhrMeasureEvents.Insert(newMeasureEvent);
            EhrLabs.SaveToDB(FormLOE.EhrLabCur);
            for (int i = 0; i < FormLOE.EhrLabCur.ListEhrLabResults.Count; i++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                {
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(FormLOE.EhrLabCur.ListEhrLabResults[i], PatCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            FillGrid();
        }
Esempio n. 9
0
        private void butImport_Click(object sender, EventArgs e)
        {
            MsgBoxCopyPaste MBCP = new MsgBoxCopyPaste("Paste HL7 Lab Message Text Here.");

            MBCP.textMain.SelectAll();
            MBCP.ShowDialog();
            if (MBCP.DialogResult != DialogResult.OK)
            {
                return;
            }
            List <EhrLab> listEhrLabs;

            try {
                listEhrLabs = EhrLabs.ProcessHl7Message(MBCP.textMain.Text); //Not a typical use of the msg box copy paste
                if (listEhrLabs[0].PatNum == PatCur.PatNum)                  //only need to check the first lab.
                //nothing to do here. Imported lab matches the current patient.
                {
                }
                else                 //does not match current patient, redirect to import form which displays patient information and is build for importing.
                {
                    FormEhrLabOrderImport FormLOI = new FormEhrLabOrderImport();
                    FormLOI.PatCur        = PatCur;
                    FormLOI.Hl7LabMessage = MBCP.textMain.Text;
                    FormLOI.ShowDialog();
                    FillGrid();
                    return;
                }
                //else if(listEhrLabs[0].PatNum==0) {
                //	if(MessageBox.Show("Lab patient does not match current patient. Lab patient name is "
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//first name
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//last name
                //		+"\r\nWould you like to import lab for the current patient?","",MessageBoxButtons.OKCancel)!=DialogResult.OK)
                //	{
                //		return;
                //	}
                //	//User agreed to import current lab(s) for current patient.
                //	for(int i=0;i<listEhrLabs.Count;i++) {
                //		listEhrLabs[i].PatNum=PatCur.PatNum;
                //		//TODO: Import external OIDs and PatIDs so that we can identify this patient next time.
                //	}
                //}
                //else {//Patnum is already associated with another patient.
                //	MessageBox.Show("This lab contains patient information for a different patient. Lab patient name is "
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]+" "//first name
                //		+MBCP.textMain.Text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries)[1].Split('|')[5].Split('~')[0].Split('^')[1]);
                //	return;
                //}
            }
            catch (Exception Ex) {
                MessageBox.Show(this, "Unable to import lab.\r\n" + Ex.Message);
                return;
            }
            for (int i = 0; i < listEhrLabs.Count; i++)
            {
                EhrLab tempLab = null;              //lab from DB if it exists.
                tempLab = EhrLabs.GetByGUID(listEhrLabs[i].PlacerOrderUniversalID, listEhrLabs[i].PlacerOrderNum);
                if (tempLab == null)
                {
                    tempLab = EhrLabs.GetByGUID(listEhrLabs[i].FillerOrderUniversalID, listEhrLabs[i].FillerOrderNum);
                }
                if (tempLab != null)
                {
                    //Date validation.
                    //if(tempLab.ResultDateTime.CompareTo(listEhrLabs[i].ResultDateTime)<=0) {//string compare dates will return 1+ if tempLab Date is greater.
                    //	MsgBox.Show(this,"This lab already exists in the database and has a more recent timestamp.");
                    //	continue;
                    //}
                    //TODO: The code above works, but ignores more recent lab results. Although the lab order my be unchanged there may be updated lab results.
                    //It would be better to check for updated results, unfortunately results have no unique identifiers.
                }
                Provider prov = Providers.GetProv(Security.CurUser.ProvNum);
                if (Security.CurUser.ProvNum != 0 && EhrProvKeys.GetKeysByFLName(prov.LName, prov.FName).Count > 0)            //The user who is currently logged in is a provider and has a valid EHR key.
                {
                    ListEhrLabs[i].IsCpoe = true;
                }
                listEhrLabs[i] = EhrLabs.SaveToDB(listEhrLabs[i]);               //SAVE
                for (int j = 0; j < listEhrLabs[i].ListEhrLabResults.Count; j++) //EHR TRIGGER
                {
                    if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                    {
                        FormCDSIntervention FormCDSI = new FormCDSIntervention();
                        FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(listEhrLabs[i].ListEhrLabResults[j], PatCur);
                        FormCDSI.ShowIfRequired(false);
                    }
                }
            }
            FillGrid();
        }
Esempio n. 10
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listProblemReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing problems to be removed.  Continue?"))
                {
                    return;
                }
            }
            Disease    dis;
            DiseaseDef disD;
            bool       isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listProblemCur.Count; i++)       //Start looping through all current problems
            {
                isActive = false;
                dis      = _listProblemCur[i];
                disD     = DiseaseDefs.GetItem(dis.DiseaseDefNum);
                for (int j = 0; j < _listProblemReconcile.Count; j++)           //Compare each reconcile problem to the current problem
                {
                    DiseaseDef disDR = DiseaseDefs.GetItem(_listProblemReconcile[j].DiseaseDefNum);
                    if (_listProblemReconcile[j].DiseaseDefNum == _listProblemCur[i].DiseaseDefNum)                   //Has identical DiseaseDefNums
                    {
                        isActive = true;
                        break;
                    }
                    if (disDR == null)
                    {
                        continue;
                    }
                    if (disDR.SnomedCode != "" && disDR.SnomedCode == disD.SnomedCode)                 //Has a Snomed code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)                 //Update current problems.
                {
                    dis.ProbStatus = ProblemStatus.Inactive;
                    Diseases.Update(_listProblemCur[i]);
                }
            }
            //Always update every current problem for the patient so that DateTStamp reflects the last reconcile date.
            if (_listProblemCur.Count > 0)
            {
                Diseases.ResetTimeStamps(_patCur.PatNum, ProblemStatus.Active);
            }
            DiseaseDef disDU = null;
            int        index;

            for (int j = 0; j < _listProblemReconcile.Count; j++)
            {
                index = ListProblemNew.IndexOf(_listProblemReconcile[j]);
                if (index < 0)
                {
                    continue;
                }
                if (_listProblemReconcile[j] == ListProblemNew[index])
                {
                    disDU = DiseaseDefs.GetItem(DiseaseDefs.GetNumFromCode(ListProblemDefNew[index].SnomedCode));
                    if (disDU == null)
                    {
                        ListProblemNew[index].DiseaseDefNum = DiseaseDefs.Insert(ListProblemDefNew[index]);
                    }
                    else
                    {
                        ListProblemNew[index].DiseaseDefNum = disDU.DiseaseDefNum;
                    }
                    Diseases.Insert(ListProblemNew[index]);
                }
            }
            DataValid.SetInvalid(InvalidType.Diseases);
            //EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
            //newMeasureEvent.DateTEvent=DateTime.Now;
            //newMeasureEvent.EventType=EhrMeasureEventType.ProblemReconcile;
            //newMeasureEvent.PatNum=PatCur.PatNum;
            //newMeasureEvent.MoreInfo="";
            //EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listProblemReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ProblemCDS)
                {
                    DiseaseDef          disDInter = DiseaseDefs.GetItem(_listProblemReconcile[inter].DiseaseDefNum);
                    FormCDSIntervention FormCDSI  = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(disDInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }
        private void butOk_Click(object sender, EventArgs e)
        {
            if (IsImport || IsViewOnly)
            {
                DialogResult = DialogResult.OK;
                return;
            }
            if (!EntriesAreValid())
            {
                return;
            }
            if (Security.CurUser.ProvNum != 0 && Providers.GetProv(Security.CurUser.ProvNum).EhrKey != "")         //The user who is currently logged in is a provider and has a valid EHR key.
            {
                EhrLabCur.IsCpoe = true;
            }
            if (EhrLabCur.PatNum == 0 && PatCurNum != null)
            {
                EhrLabCur.PatNum = PatCurNum;
            }
            //EhrLabCur.OrderControlCode=((HL70119)comb);//TODO:UI and this value.
            if (checkAutoID.Checked)
            {
                EhrLabCur.PlacerOrderNum             = EhrLabs.GetNextOrderNum().ToString();
                EhrLabCur.PlacerOrderNamespace       = "";
                EhrLabCur.PlacerOrderUniversalID     = OIDInternals.GetForType(IdentifierType.LabOrder).IDRoot;
                EhrLabCur.PlacerOrderUniversalIDType = "ISO";
            }
            else
            {
                EhrLabCur.PlacerOrderNum             = textPlacerOrderNum.Text;
                EhrLabCur.PlacerOrderNamespace       = textPlacerOrderNamespace.Text;
                EhrLabCur.PlacerOrderUniversalID     = textPlacerOrderUniversalID.Text;
                EhrLabCur.PlacerOrderUniversalIDType = textPlacerOrderUniversalIDType.Text;
            }
            EhrLabCur.FillerOrderNum              = textFillerOrderNum.Text;
            EhrLabCur.FillerOrderNamespace        = textFillerOrderNamespace.Text;
            EhrLabCur.FillerOrderUniversalID      = textFillerOrderUniversalID.Text;
            EhrLabCur.FillerOrderUniversalIDType  = textFillerOrderUniversalIDType.Text;
            EhrLabCur.PlacerGroupNum              = textPlacerGroupNum.Text;
            EhrLabCur.PlacerGroupNamespace        = textPlacerGroupNamespace.Text;
            EhrLabCur.PlacerGroupUniversalID      = textPlacerGroupUniversalID.Text;
            EhrLabCur.PlacerGroupUniversalIDType  = textPlacerGroupUniversalIDType.Text;
            EhrLabCur.OrderingProviderID          = textOrderingProvIdentifier.Text;
            EhrLabCur.OrderingProviderLName       = textOrderingProvLastName.Text;
            EhrLabCur.OrderingProviderFName       = textOrderingProvFirstName.Text;
            EhrLabCur.OrderingProviderMiddleNames = textOrderingProvMiddleName.Text;
            EhrLabCur.OrderingProviderSuffix      = textOrderingProvSuffix.Text;
            EhrLabCur.OrderingProviderPrefix      = textOrderingProvPrefix.Text;
            EhrLabCur.OrderingProviderAssigningAuthorityNamespaceID = textOrderingProvAANID.Text;
            EhrLabCur.OrderingProviderAssigningAuthorityUniversalID = textOrderingProvAAUID.Text;
            EhrLabCur.OrderingProviderAssigningAuthorityIDType      = textOrderingProvAAUIDType.Text;
            EhrLabCur.OrderingProviderNameTypeCode       = ((HL70200)comboOrderingProvNameType.SelectedIndex - 1);
            EhrLabCur.OrderingProviderIdentifierTypeCode = ((HL70203)comboOrderingProvIdType.SelectedIndex - 1);
            //EhrLabCur.SetIdOBR=PIn.Long("");//TODO: UI and Save
            EhrLabCur.UsiID                    = textUsiID.Text;
            EhrLabCur.UsiText                  = textUsiText.Text;
            EhrLabCur.UsiCodeSystemName        = textUsiCodeSystemName.Text;
            EhrLabCur.UsiIDAlt                 = textUsiIDAlt.Text;
            EhrLabCur.UsiTextAlt               = textUsiTextAlt.Text;
            EhrLabCur.UsiCodeSystemNameAlt     = textUsiCodeSystemNameAlt.Text;
            EhrLabCur.UsiTextOriginal          = textUsiTextOriginal.Text;
            EhrLabCur.ObservationDateTimeStart = EhrLab.formatDateToHL7(textObservationDateTimeStart.Text.Trim());
            EhrLabCur.ObservationDateTimeEnd   = EhrLab.formatDateToHL7(textObservationDateTimeEnd.Text.Trim());
            EhrLabCur.SpecimenActionCode       = ((HL70065)comboSpecimenActionCode.SelectedIndex - 1);
            EhrLabCur.ResultDateTime           = EhrLab.formatDateToHL7(textResultDateTime.Text.Trim());//upper right hand corner of form.
            EhrLabCur.ResultStatus             = ((HL70123)comboResultStatus.SelectedIndex - 1);
            //TODO: parent result.

            /*
             * EhrLabCur.ParentObservationID=
             * EhrLabCur.ParentObservationText=
             * EhrLabCur.ParentObservationCodeSystemName=
             * EhrLabCur.ParentObservationIDAlt=
             * EhrLabCur.ParentObservationTextAlt=
             * EhrLabCur.ParentObservationCodeSystemNameAlt=
             * EhrLabCur.ParentObservationTextOriginal=
             * EhrLabCur.ParentObservationSubID=
             * EhrLabCur.ParentPlacerOrderNum=
             * EhrLabCur.ParentPlacerOrderNamespace=
             * EhrLabCur.ParentPlacerOrderUniversalID=
             * EhrLabCur.ParentPlacerOrderUniversalIDType=
             * EhrLabCur.ParentFillerOrderNum=
             * EhrLabCur.ParentFillerOrderNamespace=
             * EhrLabCur.ParentFillerOrderUniversalID=
             * EhrLabCur.ParentFillerOrderUniversalIDType=
             */
            EhrLabCur.ListEhrLabResultsHandlingF = checkResultsHandlingF.Checked;
            EhrLabCur.ListEhrLabResultsHandlingN = checkResultsHandlingN.Checked;
            //EhrLabCur.TQ1SetId=//TODO:this
            EhrLabCur.TQ1DateTimeStart = EhrLab.formatDateToHL7(textTQ1Start.Text);
            EhrLabCur.TQ1DateTimeEnd   = EhrLab.formatDateToHL7(textTQ1Stop.Text);
            EhrLabs.SaveToDB(EhrLabCur);
            Patient patCur = Patients.GetPat(EhrLabCur.PatNum);

            for (int i = 0; i < EhrLabCur.ListEhrLabResults.Count; i++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS)
                {
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(EhrLabCur.ListEhrLabResults[i], patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            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;
        }
Esempio n. 13
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     EhrTriggers.Delete(EhrTriggerCur.EhrTriggerNum);
     DialogResult = DialogResult.OK;
 }
Esempio n. 14
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listAllergyReconcile.Count == 0)
            {
                if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing allergies to be removed.  Continue?"))
                {
                    return;
                }
            }
            Allergy    al;
            AllergyDef alD;
            bool       isActive;

            //Discontinue any current medications that are not present in the reconcile list.
            for (int i = 0; i < _listAllergyCur.Count; i++)       //Start looping through all current allergies
            {
                isActive = false;
                al       = _listAllergyCur[i];
                alD      = AllergyDefs.GetOne(al.AllergyDefNum, _listAllergyDefCur);
                for (int j = 0; j < _listAllergyReconcile.Count; j++)           //Compare each reconcile allergy to the current allergy
                {
                    AllergyDef alDR = AllergyDefs.GetOne(_listAllergyReconcile[j].AllergyDefNum, _listAllergyDefCur);
                    if (_listAllergyReconcile[j].AllergyDefNum == _listAllergyCur[i].AllergyDefNum)                   //Has identical AllergyDefNums
                    {
                        isActive = true;
                        break;
                    }
                    if (alDR == null)
                    {
                        continue;
                    }
                    //if(alDR.SnomedAllergyTo!="" && alDR.SnomedAllergyTo==alD.SnomedAllergyTo) {//TODO: Change to UNII
                    //	isActive=true;
                    //	break;
                    //}
                    if (alDR.MedicationNum != 0 && alDR.MedicationNum == alD.MedicationNum)                 //Has a Snomed code and they are equal
                    {
                        isActive = true;
                        break;
                    }
                }
                if (!isActive)
                {
                    _listAllergyCur[i].StatusIsActive = isActive;
                    Allergies.Update(_listAllergyCur[i]);
                }
            }
            //Always update every current allergy for the patient so that DateTStamp reflects the last reconcile date.
            if (_listAllergyCur.Count > 0)
            {
                Allergies.ResetTimeStamps(_patCur.PatNum, true);
            }
            AllergyDef alDU;
            int        index;

            for (int j = 0; j < _listAllergyReconcile.Count; j++)
            {
                if (!_listAllergyReconcile[j].IsNew)
                {
                    continue;
                }
                index = ListAllergyNew.IndexOf(_listAllergyReconcile[j]);              //Returns -1 if not found.
                if (index < 0)
                {
                    continue;
                }
                //Insert the AllergyDef and Allergy if needed.
                if (ListAllergyDefNew[index].MedicationNum != 0)
                {
                    alDU = AllergyDefs.GetAllergyDefFromMedication(ListAllergyDefNew[index].MedicationNum);
                }
                else
                {
                    alDU = null;                  //remove once UNII is implemented
                    //alDU=AllergyDefs.GetAllergyDefFromCode(ListAllergyDefNew[index].SnomedAllergyTo);//TODO: Change to UNII
                }
                if (alDU == null)               //db is missing the def
                {
                    ListAllergyNew[index].AllergyDefNum = AllergyDefs.Insert(ListAllergyDefNew[index]);
                }
                else
                {
                    ListAllergyNew[index].AllergyDefNum = alDU.AllergyDefNum;                  //Set the allergydefnum on the allergy.
                }
                Allergies.Insert(ListAllergyNew[index]);
            }
            //TODO: Make an allergy measure event if one is needed for MU3.
            //EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
            //newMeasureEvent.DateTEvent=DateTime.Now;
            //newMeasureEvent.EventType=EhrMeasureEventType.AllergyReconcile;
            //newMeasureEvent.PatNum=PatCur.PatNum;
            //newMeasureEvent.MoreInfo="";
            //EhrMeasureEvents.Insert(newMeasureEvent);
            for (int inter = 0; inter < _listAllergyReconcile.Count; inter++)
            {
                if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).AllergyCDS)
                {
                    AllergyDef          alDInter = AllergyDefs.GetOne(_listAllergyReconcile[inter].AllergyDefNum);
                    FormCDSIntervention FormCDSI = new FormCDSIntervention();
                    FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(alDInter, _patCur);
                    FormCDSI.ShowIfRequired(false);
                }
            }
            DialogResult = DialogResult.OK;
        }