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!
 }
        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();
        }
        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();
        }
        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;
		}
Exemple #6
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!
		}
Exemple #7
0
		private void butAdd_Click(object sender, System.EventArgs e) {
			//select medication from list.  Additional meds can be added to the list from within that dlg
			FormMedications FormM=new FormMedications();
			FormM.IsSelectionMode=true;
			FormM.ShowDialog();
			if(FormM.DialogResult!=DialogResult.OK){
				return;
			} 
			if(CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS) {
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(Medications.GetMedication(FormM.SelectedMedicationNum),PatCur);
				FormCDSI.ShowIfRequired();
				if(FormCDSI.DialogResult==DialogResult.Abort) {
					return;//do not add medication
				}
			}
			MedicationPat MedicationPatCur=new MedicationPat();
			MedicationPatCur.PatNum=PatCur.PatNum;
			MedicationPatCur.MedicationNum=FormM.SelectedMedicationNum;
			MedicationPatCur.RxCui=Medications.GetMedication(FormM.SelectedMedicationNum).RxCui;
			MedicationPatCur.ProvNum=PatCur.PriProv;
			FormMedPat FormMP=new FormMedPat();
			FormMP.MedicationPatCur=MedicationPatCur;
			FormMP.IsNew=true;
			FormMP.ShowDialog();
			if(FormMP.DialogResult!=DialogResult.OK){
				return;
			}
			FillMeds();
		}
Exemple #8
0
		private void butAddAllergy_Click(object sender,EventArgs e) {
			FormAllergyEdit formA=new FormAllergyEdit();
			formA.AllergyCur=new Allergy();
			formA.AllergyCur.StatusIsActive=true;
			formA.AllergyCur.PatNum=PatCur.PatNum;
			formA.AllergyCur.IsNew=true;
			formA.ShowDialog();
			if(formA.DialogResult!=DialogResult.OK) {
				return;
			}
			if(CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).AllergyCDS) {
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(AllergyDefs.GetOne(formA.AllergyCur.AllergyDefNum),PatCur);
				FormCDSI.ShowIfRequired(false);
			}
			FillAllergies();
		}
		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();
		}
Exemple #10
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;
		}
        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;
        }
        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;
        }
Exemple #13
0
		private void butOK_Click(object sender,EventArgs e) {
			#region Validate
			DateTime date;
			if(textDateTaken.Text=="") {
				MsgBox.Show(this,"Please enter a date.");
				return;
			}
			try {
				date=DateTime.Parse(textDateTaken.Text);
			}
			catch {
				MsgBox.Show(this,"Please fix date first.");
				return;
			}
			if(date<patCur.Birthdate) {
				MsgBox.Show(this,"Exam date cannot be before the patient's birthdate.");
				return;
			}
			//validate height
			float height=0;
			try {
				if(textHeight.Text!="") {
					height = float.Parse(textHeight.Text);
				}
			}
			catch {
				MsgBox.Show(this,"Please fix height first.");
				return;
			}
			if(height<0) {
				MsgBox.Show(this,"Please fix height first.");
				return;
			}
			//validate weight
			float weight=0;
			try {
				if(textWeight.Text!="") {
					weight = float.Parse(textWeight.Text);
				}
			}
			catch {
				MsgBox.Show(this,"Please fix weight first.");
				return;
			}
			if(weight<0) {
				MsgBox.Show(this,"Please fix weight first.");
				return;
			}
			//validate bp
			int BPsys=0;
			int BPdia=0;
			try {
				if(textBPs.Text!="") {
					BPsys = int.Parse(textBPs.Text);
				}
				if(textBPd.Text!="") {
					BPdia = int.Parse(textBPd.Text);
				}
			}
			catch {
				MsgBox.Show(this,"Please fix BP first.");
				return;
			}
			if(BPsys<0 || BPdia<0) {
				MsgBox.Show(this,"Please fix BP first.");
				return;
			}
			#endregion
			#region Save
			VitalsignCur.DateTaken=date;
			VitalsignCur.Height=height;
			VitalsignCur.Weight=weight;
			VitalsignCur.BpDiastolic=BPdia;
			VitalsignCur.BpSystolic=BPsys;
			//textBMIPercentile will be the calculated percentile or -1 if not in age range or there is an error calculating the percentile.
			//In this case the text box will be not visible, but the text will be set to -1 and we will store it that way to indicate no valid BMIPercentile
			VitalsignCur.BMIPercentile=PIn.Int(textBMIPercentile.Text);//could be -1 if not in age range or error calculating percentile
			VitalsignCur.BMIExamCode="";
			if(textBMIPercentileCode.Visible && textBMIPercentileCode.Text!="") {
				VitalsignCur.BMIExamCode="59576-9";//Body mass index (BMI) [Percentile] Per age and gender, only code used for percentile, only visible if under 17 at time of exam
			}
			if(comboHeightExamCode.SelectedIndex>0) {
				VitalsignCur.HeightExamCode=listHeightCodes[comboHeightExamCode.SelectedIndex-1].LoincCode;
			}
			if(comboWeightExamCode.SelectedIndex>0) {
				VitalsignCur.WeightExamCode=listWeightCodes[comboWeightExamCode.SelectedIndex-1].LoincCode;
			}
			switch(labelWeightCode.Text) {
				case "Overweight":
					if(Snomeds.GetByCode("238131007")!=null) {
						VitalsignCur.WeightCode="238131007";
					}
					break;
				case "Underweight":
					if(Snomeds.GetByCode("248342006")!=null) {
						VitalsignCur.WeightCode="248342006";
					}
					break;
				case "":
				default:
					VitalsignCur.WeightCode="";
					break;
			}
			#region PregnancyDx
			if(checkPregnant.Checked) {//pregnant, add pregnant dx if necessary
				if(pregDisDefNumCur==0) {
					//shouldn't happen, if checked this must be set to either an existing problem def or a new problem that requires inserting, return to form with checkPregnant unchecked
					MsgBox.Show(this,"This exam must point to a valid pregnancy diagnosis.");
					checkPregnant.Checked=false;
					labelPregNotice.Visible=false;
					return;
				}
				if(VitalsignCur.PregDiseaseNum==0) {//insert new preg disease and update vitalsign to point to it
					Disease pregDisNew=new Disease();
					pregDisNew.PatNum=VitalsignCur.PatNum;
					pregDisNew.DiseaseDefNum=pregDisDefNumCur;
					pregDisNew.DateStart=VitalsignCur.DateTaken;
					pregDisNew.ProbStatus=ProblemStatus.Active;
					VitalsignCur.PregDiseaseNum=Diseases.Insert(pregDisNew);
				}
				else {
					Disease disCur=Diseases.GetOne(VitalsignCur.PregDiseaseNum);
					if(VitalsignCur.DateTaken<disCur.DateStart
						|| (disCur.DateStop.Year>1880 && VitalsignCur.DateTaken>disCur.DateStop))
					{//the current exam is no longer within dates of preg problem, uncheck the pregnancy box and remove the pointer to the disease
						MsgBox.Show(this,"This exam is not within the active dates of the attached pregnancy problem.");
						checkPregnant.Checked=false;
						textPregCode.Clear();
						textPregCodeDescript.Clear();
						labelPregNotice.Visible=false;
						VitalsignCur.PregDiseaseNum=0;
						butChangeDefault.Text="Change Default";
						return;
					}
				}
			}
			else {//checkPregnant not checked
				VitalsignCur.PregDiseaseNum=0;
			}
			#endregion
			#region EhrNotPerformed
			if(!checkNotPerf.Checked) {
				if(VitalsignCur.EhrNotPerformedNum!=0) {
					EhrNotPerformeds.Delete(VitalsignCur.EhrNotPerformedNum);
					VitalsignCur.EhrNotPerformedNum=0;
				}
			}
			if(VitalsignCur.IsNew) {
			  Vitalsigns.Insert(VitalsignCur);
			}
			else {
				Vitalsigns.Update(VitalsignCur);
			}
			#endregion
			#endregion
			#region CDS Intervention Trigger
			if(CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).VitalCDS) {
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(VitalsignCur,Patients.GetPat(VitalsignCur.PatNum));
				FormCDSI.ShowIfRequired(false);
			}
			#endregion
			DialogResult=DialogResult.OK;
		}
Exemple #14
0
		private void gridDiseases_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			FormDiseaseEdit FormD=new FormDiseaseEdit(DiseaseList[e.Row]);
			FormD.ShowDialog();
			if(FormD.DialogResult==DialogResult.OK 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ProblemCDS) 
			{
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(DiseaseDefs.GetItem(DiseaseList[e.Row].DiseaseDefNum),PatCur);
				FormCDSI.ShowIfRequired(false);
			}
			FillProblems();
		}
		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.
				}
				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.
					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();
		}
Exemple #16
0
		private void gridAllergies_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			FormAllergyEdit FAE=new FormAllergyEdit();
			FAE.AllergyCur=allergyList[gridAllergies.GetSelectedIndex()];
			FAE.ShowDialog();
			if(FAE.DialogResult==DialogResult.OK 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).AllergyCDS) 
			{
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(AllergyDefs.GetOne(FAE.AllergyCur.AllergyDefNum),PatCur);
				FormCDSI.ShowIfRequired(false);
			}
			FillAllergies();
		}
        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;
        }
Exemple #18
0
		private void gridMeds_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			FormMedPat FormMP=new FormMedPat();
			FormMP.MedicationPatCur=medList[e.Row];
			FormMP.ShowDialog();
			if(FormMP.DialogResult==DialogResult.OK 
				&& FormMP.MedicationPatCur!=null //Can get be null if the user removed the medication from the patient.
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS) 
			{
				object triggerObject=null;
				if(FormMP.MedicationPatCur.MedicationNum > 0) {//0 indicats the med is from NewCrop.
					triggerObject=Medications.GetMedication(FormMP.MedicationPatCur.MedicationNum);
				}
				else if(FormMP.MedicationPatCur.RxCui > 0) {//Meds from NewCrop might have a valid RxNorm.
					triggerObject=RxNorms.GetByRxCUI(FormMP.MedicationPatCur.RxCui.ToString());
				}
				if(triggerObject!=null) {
					FormCDSIntervention FormCDSI=new FormCDSIntervention();
					FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(triggerObject,PatCur);
					FormCDSI.ShowIfRequired(false);
				}
			}
			FillMeds();
		}
		private void butOK_Click(object sender, System.EventArgs e) {
			bool CDSinterventionCheckRequired=false;//checks selected values
			if(  textBirthdate.errorProvider1.GetError(textBirthdate)!=""
				|| textDateFirstVisit.errorProvider1.GetError(textDateFirstVisit)!=""
				|| textAdmitDate.errorProvider1.GetError(textAdmitDate)!=""
				){
				MsgBox.Show(this,"Please fix data entry errors first.");
				return;
			}
			DateTime dateTimeDeceased=DateTime.MinValue;
			try {
				if(textDateDeceased.Text!="") {
					dateTimeDeceased=DateTime.Parse(textDateDeceased.Text);
				}
			}
			catch {
				MsgBox.Show(this,"Date time deceased is invalid.");
				return;
			}
			if(textLName.Text==""){
				MsgBox.Show(this,"Last Name must be entered.");
				return;
			}
			//see if chartNum is a duplicate
			if(textChartNumber.Text!=""){
				//the patNum will be 0 for new
				string usedBy=Patients.ChartNumUsedBy(textChartNumber.Text,PatCur.PatNum);
				if(usedBy!=""){
					MessageBox.Show(Lan.g(this,"This chart number is already in use by:")+" "+usedBy);
					return;
				}
			}
			try{
				PIn.Int(textAskToArriveEarly.Text);
			}
			catch{
				MsgBox.Show(this,"Ask To Arrive Early invalid.");
				return;
			}
			if(textCounty.Text != "" && !Counties.DoesExist(textCounty.Text)){
				MessageBox.Show(Lan.g(this,"County name invalid."));
				return;
			}
			if(textSite.Text=="") {
				PatCur.SiteNum=0;
			}
			if(textSite.Text != "" && textSite.Text != Sites.GetDescription(PatCur.SiteNum)) {
				long matchingSite=Sites.FindMatchSiteNum(textSite.Text);
				if(matchingSite==-1) {
					MessageBox.Show(Lan.g(this,"Invalid Site description."));
					return;
				}
				else {
					PatCur.SiteNum=matchingSite;
				}
			}
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
				if(comboCanadianEligibilityCode.SelectedIndex==1//FT student
					&& textSchool.Text=="" && PIn.Date(textBirthdate.Text).AddYears(18)<=DateTime.Today)
				{
					MsgBox.Show(this,"School should be entered if full-time student and patient is 18 or older.");
					return;
				}
			}
			//If HQ and this is a patient in a reseller family, do not allow the changing of the patient status.
			if(PrefC.GetBool(PrefName.DockPhonePanelShow) 
				&& Resellers.IsResellerFamily(PatCur.Guarantor)
				&& PatOld.PatStatus!=(PatientStatus)listStatus.SelectedIndex) 
			{
				MsgBox.Show(this,"Cannot change the status of a patient in a reseller family.");
				return;
			}
			PatCur.LName=textLName.Text;
			PatCur.FName=textFName.Text;
			PatCur.MiddleI=textMiddleI.Text;
			PatCur.Preferred=textPreferred.Text;
			PatCur.Title=textTitle.Text;
			PatCur.Salutation=textSalutation.Text;
			if(PrefC.GetBool(PrefName.ShowFeatureEhr)) {//Mother's maiden name UI is only used when EHR is enabled.
				_ehrPatientCur.MotherMaidenFname=textMotherMaidenFname.Text;
				_ehrPatientCur.MotherMaidenLname=textMotherMaidenLname.Text;
				EhrPatients.Update(_ehrPatientCur);
			}
			switch(listStatus.SelectedIndex){
				case 0: PatCur.PatStatus=PatientStatus.Patient; break;
				case 1: PatCur.PatStatus=PatientStatus.NonPatient; break;
				case 2: PatCur.PatStatus=PatientStatus.Inactive; break;
				case 3: PatCur.PatStatus=PatientStatus.Archived; break;
				case 4: PatCur.PatStatus=PatientStatus.Deceased; break;
				case 5: PatCur.PatStatus=PatientStatus.Prospective; break;
			}
			switch(listGender.SelectedIndex){
				case 0: PatCur.Gender=PatientGender.Male; break;
				case 1: PatCur.Gender=PatientGender.Female; break;
				case 2: PatCur.Gender=PatientGender.Unknown; break;
			}
			switch(listPosition.SelectedIndex){
				case 0: PatCur.Position=PatientPosition.Single; break;
				case 1: PatCur.Position=PatientPosition.Married; break;
				case 2: PatCur.Position=PatientPosition.Child; break;
				case 3: PatCur.Position=PatientPosition.Widowed; break;
				case 4: PatCur.Position=PatientPosition.Divorced; break;
			}
			PatCur.Birthdate=PIn.Date(textBirthdate.Text);
			PatCur.DateTimeDeceased=dateTimeDeceased;
			if(CultureInfo.CurrentCulture.Name=="en-US"){
				if(Regex.IsMatch(textSSN.Text,@"^\d\d\d-\d\d-\d\d\d\d$")){
					PatCur.SSN=textSSN.Text.Substring(0,3)+textSSN.Text.Substring(4,2)
						+textSSN.Text.Substring(7,4);
				}
				else{
					PatCur.SSN=textSSN.Text;
				}
			}
			else{//other cultures
				PatCur.SSN=textSSN.Text;
			}
			if(IsNew) {//Check if patient already exists.
				List<Patient> patList=Patients.GetListByName(PatCur.LName,PatCur.FName,PatCur.PatNum);
				for(int i=0;i<patList.Count;i++) {
					//If dates match or aren't entered there might be a duplicate patient.
					if(patList[i].Birthdate==PatCur.Birthdate
					|| patList[i].Birthdate.Year<1880
					|| PatCur.Birthdate.Year<1880) {
						if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"This patient might already exist.  Continue anyway?")) {
							return;
						}
						break;
					}
				}
			}
			PatCur.MedicaidID=textMedicaidID.Text;
			PatCur.WkPhone=textWkPhone.Text;
			PatCur.WirelessPhone=textWirelessPhone.Text;
			PatCur.TxtMsgOk=(YN)listTextOk.SelectedIndex;
			PatCur.Email=textEmail.Text;
			//PatCur.RecallInterval=PIn.PInt(textRecall.Text);
			PatCur.ChartNumber=textChartNumber.Text;
			PatCur.SchoolName=textSchool.Text;
			//address:
			PatCur.HmPhone=textHmPhone.Text;
			PatCur.Address=textAddress.Text;
			PatCur.Address2=textAddress2.Text;
			PatCur.City=textCity.Text;
			PatCur.State=textState.Text;
			PatCur.Country=textCountry.Text;
			PatCur.Zip=textZip.Text;
			PatCur.CreditType=textCreditType.Text;
			GetEmployerNum();
			//PatCur.EmploymentNote=textEmploymentNote.Text;
			if(comboLanguage.SelectedIndex==0){
				PatCur.Language="";
			}
			else{
				PatCur.Language=languageList[comboLanguage.SelectedIndex-1];
			}
			PatCur.AddrNote=textAddrNotes.Text;
			PatCur.DateFirstVisit=PIn.Date(textDateFirstVisit.Text);
			PatCur.AskToArriveEarly=PIn.Int(textAskToArriveEarly.Text);
			if(comboPriProv.SelectedIndex!=-1) {
				PatCur.PriProv=ProviderC.ListShort[comboPriProv.SelectedIndex].ProvNum;
			}
			if(comboSecProv.SelectedIndex==0){
				PatCur.SecProv=0;
			}
			else{
				PatCur.SecProv=ProviderC.ListShort[comboSecProv.SelectedIndex-1].ProvNum;
			}
			if(comboFeeSched.SelectedIndex==0){
				PatCur.FeeSched=0;
			}
			else{
				PatCur.FeeSched=FeeSchedC.ListShort[comboFeeSched.SelectedIndex-1].FeeSchedNum;
			}
			if(comboBillType.SelectedIndex!=-1){
				PatCur.BillingType=DefC.Short[(int)DefCat.BillingTypes][comboBillType.SelectedIndex].DefNum;
			}
			if(comboClinic.SelectedIndex==0){
				PatCur.ClinicNum=0;
			}
			else{
				PatCur.ClinicNum=Clinics.List[comboClinic.SelectedIndex-1].ClinicNum;
			}
			List<PatRace> listPatRaces=new List<PatRace>();
			for(int i=0;i<comboBoxMultiRace.SelectedIndices.Count;i++) {
				int selectedIdx=(int)comboBoxMultiRace.SelectedIndices[i];
				if(selectedIdx==0) {//If the none option was chosen, then ensure that no other race information is saved.
					listPatRaces.Clear();
					break;
				}
				if(!PrefC.GetBool(PrefName.ShowFeatureEhr)) {//If not using EHR, then the comboBoxMultiRace item locations are the same as the PatRace enum locations plus 1.
					listPatRaces.Add((PatRace)(selectedIdx-1));
					continue;
				}
				//EHR
				if(selectedIdx==1) {
					listPatRaces.Add(PatRace.AfricanAmerican);
				}
				else if(selectedIdx==2) {
					listPatRaces.Add(PatRace.AmericanIndian);
				}
				else if(selectedIdx==3) {
					listPatRaces.Add(PatRace.Asian);
				}
				else if(selectedIdx==4) {
					listPatRaces.Add(PatRace.DeclinedToSpecifyRace);
				}
				else if(selectedIdx==5) {
					listPatRaces.Add(PatRace.HawaiiOrPacIsland);
				}
				else if(selectedIdx==6) {
					listPatRaces.Add(PatRace.Other);
				}
				else if(selectedIdx==7) {
					listPatRaces.Add(PatRace.White);
				}
			}
			if(listPatRaces.Contains(PatRace.DeclinedToSpecifyRace)) {//If DeclinedToSpecify was chosen, then ensure that no other races are saved.
				listPatRaces.Clear();
				listPatRaces.Add(PatRace.DeclinedToSpecifyRace);
			}
			else if(listPatRaces.Contains(PatRace.Other)) {//If Other was chosen, then ensure that no other races are saved.
				listPatRaces.Clear();
				listPatRaces.Add(PatRace.Other);
			}
			//In order to pass EHR G2 MU testing you must be able to have an ethnicity without a race, or a race without an ethnicity.  This will mean that patients will not count towards
			//  meaningfull use demographic calculations.  If we have time in the future we should probably alert EHR users when a race is chosen but no ethnicity, or a ethnicity but no race.
			if(comboEthnicity.SelectedIndex==1) {
				listPatRaces.Add(PatRace.DeclinedToSpecifyEthnicity);
			}
			else if(comboEthnicity.SelectedIndex==2){
				listPatRaces.Add(PatRace.NotHispanic);
			}
			else if(comboEthnicity.SelectedIndex==3) {
				listPatRaces.Add(PatRace.Hispanic);
			}
			PatientRaces.Reconcile(PatCur.PatNum,listPatRaces);//Insert, Update, Delete if needed.
			PatCur.County=textCounty.Text;
			//site set when user picks from list.
			PatCur.GradeLevel=(PatientGrade)comboGradeLevel.SelectedIndex;
			PatCur.Urgency=(TreatmentUrgency)comboUrgency.SelectedIndex;
			//ResponsParty handled when buttons are pushed.
			if(Programs.IsEnabled(ProgramName.TrophyEnhanced)) {
				PatCur.TrophyFolder=textTrophyFolder.Text;
			}
			PatCur.Ward=textWard.Text;
			PatCur.PreferContactMethod=(ContactMethod)comboContact.SelectedIndex;
			PatCur.PreferConfirmMethod=(ContactMethod)comboConfirm.SelectedIndex;
			PatCur.PreferRecallMethod=(ContactMethod)comboRecall.SelectedIndex;
			PatCur.AdmitDate=PIn.Date(textAdmitDate.Text);
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
				PatCur.CanadianEligibilityCode=(byte)comboCanadianEligibilityCode.SelectedIndex;
			}
			if(PatCur.Guarantor==0){
				PatCur.Guarantor=PatCur.PatNum;
			}
			Patients.Update(PatCur,PatOld);
			if(PatCur.Birthdate!=PatOld.Birthdate || PatCur.Gender!=PatOld.Gender) {
					CDSinterventionCheckRequired=true;
			}
			if(CDSinterventionCheckRequired && CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).LabTestCDS) {
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(PatCur,PatCur);//both should be patCur.
				FormCDSI.ShowIfRequired(false);
			}
			if(checkArriveEarlySame.Checked){
				Patients.UpdateArriveEarlyForFam(PatCur);
			}
			if(checkSame.Checked){
				//might want to include a mechanism for comparing fields to be overwritten
				Patients.UpdateAddressForFam(PatCur);
			}
			if(checkNotesSame.Checked){
				Patients.UpdateNotesForFam(PatCur);
			}
			//If this patient is also a referral source,
			//keep address info synched:
			for(int i=0;i<Referrals.List.Length;i++){
				if(Referrals.List[i].PatNum==PatCur.PatNum){
					//Referrals.Cur=Referrals.List[i];
					Referrals.List[i].LName=PatCur.LName;
					Referrals.List[i].FName=PatCur.FName;
					Referrals.List[i].MName=PatCur.MiddleI;
					Referrals.List[i].Address=PatCur.Address;
					Referrals.List[i].Address2=PatCur.Address2;
					Referrals.List[i].City=PatCur.City;
					Referrals.List[i].ST=PatCur.State;
					Referrals.List[i].SSN=PatCur.SSN;
					Referrals.List[i].Zip=PatCur.Zip;
					Referrals.List[i].Telephone=TelephoneNumbers.FormatNumbersExactTen(PatCur.HmPhone);
					Referrals.List[i].EMail=PatCur.Email;
					Referrals.Update(Referrals.List[i]);
					Referrals.RefreshCache();
					break;
				}
			}
			//if patient is inactive, then disable any recalls
			if(PatCur.PatStatus==PatientStatus.Archived
				|| PatCur.PatStatus==PatientStatus.Deceased
				|| PatCur.PatStatus==PatientStatus.Inactive
				|| PatCur.PatStatus==PatientStatus.NonPatient
				|| PatCur.PatStatus==PatientStatus.Prospective)
			{
				List<Recall> recalls=Recalls.GetList(PatCur.PatNum);
				for(int i=0;i<recalls.Count;i++){
					recalls[i].IsDisabled=true;
					recalls[i].DateDue=DateTime.MinValue;
					Recalls.Update(recalls[i]);
				}
			}
			//if patient was re-activated, then re-enable any recalls
			else if(PatCur.PatStatus!=PatOld.PatStatus && PatCur.PatStatus==PatientStatus.Patient) {//if changed patstatus, and new status is Patient
				List<Recall> recalls=Recalls.GetList(PatCur.PatNum);
				for(int i=0;i<recalls.Count;i++) {
					if(recalls[i].IsDisabled) {
						recalls[i].IsDisabled=false;
						Recalls.Update(recalls[i]);
					}
				}
				Recalls.Synch(PatCur.PatNum);
			}
			DialogResult=DialogResult.OK;
		}
Exemple #20
0
		private void butAddProblem_Click(object sender,EventArgs e) {
			FormDiseaseDefs formDD=new FormDiseaseDefs();
			formDD.IsSelectionMode=true;
			formDD.IsMultiSelect=true;
			formDD.ShowDialog();
			if(formDD.DialogResult!=DialogResult.OK) {
				return;
			}
			for(int i=0;i<formDD.SelectedDiseaseDefNums.Count;i++) {
				if(CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS && CDSPermissions.GetForUser(Security.CurUser.UserNum).ProblemCDS){
					FormCDSIntervention FormCDSI=new FormCDSIntervention();
					FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(DiseaseDefs.GetItem(formDD.SelectedDiseaseDefNums[i]),PatCur);
					FormCDSI.ShowIfRequired();
					if(FormCDSI.DialogResult==DialogResult.Abort) {
						continue;//cancel 
					}
				}
				SecurityLogs.MakeLogEntry(Permissions.PatProblemListEdit,PatCur.PatNum,DiseaseDefs.GetName(formDD.SelectedDiseaseDefNums[i])+" added"); //Audit log made outside form because the form is just a list of problems and is called from many places.
				Disease disease=new Disease();
				disease.PatNum=PatCur.PatNum;
				disease.DiseaseDefNum=formDD.SelectedDiseaseDefNums[i];
				Diseases.Insert(disease);
			}
			FillProblems();
		}
		private void gridMeds_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			FormMedPat FormMP=new FormMedPat();
			FormMP.MedicationPatCur=medList[e.Row];
			FormMP.ShowDialog();
			if(FormMP.DialogResult==DialogResult.OK 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS 
				&& CDSPermissions.GetForUser(Security.CurUser.UserNum).MedicationCDS) 
			{
				FormCDSIntervention FormCDSI=new FormCDSIntervention();
				FormCDSI.ListCDSI=EhrTriggers.TriggerMatch(Medications.GetMedication(FormMP.MedicationPatCur.MedicationNum),PatCur);
				FormCDSI.ShowIfRequired(false);
			}
			FillMeds();
		}
Exemple #22
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;
		}
Exemple #23
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;
		}