private void butAddFrom_Click(object sender,System.EventArgs e)
 {
     FormReferralSelect FormRS=new FormReferralSelect();
     FormRS.IsSelectionMode=true;
     FormRS.ShowDialog();
     if(FormRS.DialogResult!=DialogResult.OK) {
         return;
     }
     RefAttach refattach=new RefAttach();
     refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum;
     refattach.PatNum=PatNum;
     refattach.IsFrom=true;
     refattach.RefDate=DateTime.Today;
     if(FormRS.SelectedReferral.IsDoctor) {//whether using ehr or not
         //we're not going to ask.  That's stupid.
         //if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Is this an incoming transition of care from another provider?")){
         refattach.IsTransitionOfCare=true;
     }
     int order=0;
     for(int i=0;i<RefAttachList.Count;i++) {
         if(RefAttachList[i].ItemOrder > order) {
             order=RefAttachList[i].ItemOrder;
         }
     }
     refattach.ItemOrder=order+1;
     RefAttaches.Insert(refattach);
     FillGrid();
     for(int i=0;i<RefAttachList.Count;i++){
         if(RefAttachList[i].RefAttachNum==refattach.RefAttachNum) {
             gridMain.SetSelected(i,true);
         }
     }
 }
Exemple #2
0
 ///<summary>Inserts one RefAttach into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(RefAttach refAttach,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         refAttach.RefAttachNum=ReplicationServers.GetKey("refattach","RefAttachNum");
     }
     string command="INSERT INTO refattach (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="RefAttachNum,";
     }
     command+="ReferralNum,PatNum,ItemOrder,RefDate,IsFrom,RefToStatus,Note,IsTransitionOfCare,ProcNum,DateProcComplete) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(refAttach.RefAttachNum)+",";
     }
     command+=
              POut.Long  (refAttach.ReferralNum)+","
         +    POut.Long  (refAttach.PatNum)+","
         +    POut.Int   (refAttach.ItemOrder)+","
         +    POut.Date  (refAttach.RefDate)+","
         +    POut.Bool  (refAttach.IsFrom)+","
         +    POut.Int   ((int)refAttach.RefToStatus)+","
         +"'"+POut.String(refAttach.Note)+"',"
         +    POut.Bool  (refAttach.IsTransitionOfCare)+","
         +    POut.Long  (refAttach.ProcNum)+","
         +    POut.Date  (refAttach.DateProcComplete)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         refAttach.RefAttachNum=Db.NonQ(command,true);
     }
     return refAttach.RefAttachNum;
 }
Exemple #3
0
 ///<summary>Inserts one RefAttach into the database.  Returns the new priKey.</summary>
 internal static long Insert(RefAttach refAttach)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         refAttach.RefAttachNum=DbHelper.GetNextOracleKey("refattach","RefAttachNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(refAttach,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     refAttach.RefAttachNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(refAttach,false);
     }
 }
		///<summary>Returns a copy of this RefAttach.</summary>
		public RefAttach Copy(){
			RefAttach r=new RefAttach();
			r.RefAttachNum=RefAttachNum;
			r.ReferralNum=ReferralNum;
			r.PatNum=PatNum;
			r.ItemOrder=ItemOrder;
			r.RefDate=RefDate;
			r.IsFrom=IsFrom;
			return r;
		}
 ///<summary>Returns true if Update(RefAttach,RefAttach) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(RefAttach refAttach, RefAttach oldRefAttach)
 {
     if (refAttach.ReferralNum != oldRefAttach.ReferralNum)
     {
         return(true);
     }
     if (refAttach.PatNum != oldRefAttach.PatNum)
     {
         return(true);
     }
     if (refAttach.ItemOrder != oldRefAttach.ItemOrder)
     {
         return(true);
     }
     if (refAttach.RefDate.Date != oldRefAttach.RefDate.Date)
     {
         return(true);
     }
     if (refAttach.RefType != oldRefAttach.RefType)
     {
         return(true);
     }
     if (refAttach.RefToStatus != oldRefAttach.RefToStatus)
     {
         return(true);
     }
     if (refAttach.Note != oldRefAttach.Note)
     {
         return(true);
     }
     if (refAttach.IsTransitionOfCare != oldRefAttach.IsTransitionOfCare)
     {
         return(true);
     }
     if (refAttach.ProcNum != oldRefAttach.ProcNum)
     {
         return(true);
     }
     if (refAttach.DateProcComplete.Date != oldRefAttach.DateProcComplete.Date)
     {
         return(true);
     }
     if (refAttach.ProvNum != oldRefAttach.ProvNum)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     return(false);
 }
Exemple #6
0
 ///<summary>Inserts one RefAttach into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(RefAttach refAttach)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(refAttach, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             refAttach.RefAttachNum = DbHelper.GetNextOracleKey("refattach", "RefAttachNum");                  //Cacheless method
         }
         return(InsertNoCache(refAttach, true));
     }
 }
        ///<summary>Inserts one RefAttach into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(RefAttach refAttach, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO refattach (";

            if (!useExistingPK && isRandomKeys)
            {
                refAttach.RefAttachNum = ReplicationServers.GetKeyNoCache("refattach", "RefAttachNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "RefAttachNum,";
            }
            command += "ReferralNum,PatNum,ItemOrder,RefDate,RefType,RefToStatus,Note,IsTransitionOfCare,ProcNum,DateProcComplete,ProvNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(refAttach.RefAttachNum) + ",";
            }
            command +=
                POut.Long(refAttach.ReferralNum) + ","
                + POut.Long(refAttach.PatNum) + ","
                + POut.Int(refAttach.ItemOrder) + ","
                + POut.Date(refAttach.RefDate) + ","
                + POut.Int((int)refAttach.RefType) + ","
                + POut.Int((int)refAttach.RefToStatus) + ","
                + DbHelper.ParamChar + "paramNote,"
                + POut.Bool(refAttach.IsTransitionOfCare) + ","
                + POut.Long(refAttach.ProcNum) + ","
                + POut.Date(refAttach.DateProcComplete) + ","
                + POut.Long(refAttach.ProvNum) + ")";
            //DateTStamp can only be set by MySQL
            if (refAttach.Note == null)
            {
                refAttach.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(refAttach.Note));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNote);
            }
            else
            {
                refAttach.RefAttachNum = Db.NonQ(command, true, "RefAttachNum", "refAttach", paramNote);
            }
            return(refAttach.RefAttachNum);
        }
Exemple #8
0
        ///<summary>Updates one RefAttach in the database.</summary>
        internal static void Update(RefAttach refAttach)
        {
            string command = "UPDATE refattach SET "
                             + "ReferralNum       =  " + POut.Long(refAttach.ReferralNum) + ", "
                             + "PatNum            =  " + POut.Long(refAttach.PatNum) + ", "
                             + "ItemOrder         =  " + POut.Int(refAttach.ItemOrder) + ", "
                             + "RefDate           =  " + POut.Date(refAttach.RefDate) + ", "
                             + "IsFrom            =  " + POut.Bool(refAttach.IsFrom) + ", "
                             + "RefToStatus       =  " + POut.Int((int)refAttach.RefToStatus) + ", "
                             + "Note              = '" + POut.String(refAttach.Note) + "', "
                             + "IsTransitionOfCare=  " + POut.Bool(refAttach.IsTransitionOfCare) + ", "
                             + "ProcNum           =  " + POut.Long(refAttach.ProcNum) + ", "
                             + "DateProcComplete  =  " + POut.Date(refAttach.DateProcComplete) + " "
                             + "WHERE RefAttachNum = " + POut.Long(refAttach.RefAttachNum);

            Db.NonQ(command);
        }
Exemple #9
0
        ///<summary></summary>
        public static Referral CreateReferral(long patNum, bool isDoctor = true)
        {
            Referral refNew = new Referral()
            {
                IsDoctor = isDoctor
            };

            Referrals.Insert(refNew);
            RefAttach refattach = new RefAttach();

            refattach.ReferralNum        = refNew.ReferralNum;
            refattach.PatNum             = patNum;
            refattach.RefType            = ReferralType.RefFrom;
            refattach.RefDate            = DateTime.Today;
            refattach.IsTransitionOfCare = refNew.IsDoctor;
            refattach.ItemOrder          = 0;
            RefAttaches.Insert(refattach);
            return(refNew);
        }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<RefAttach> TableToList(DataTable table){
			List<RefAttach> retVal=new List<RefAttach>();
			RefAttach refAttach;
			for(int i=0;i<table.Rows.Count;i++) {
				refAttach=new RefAttach();
				refAttach.RefAttachNum      = PIn.Long  (table.Rows[i]["RefAttachNum"].ToString());
				refAttach.ReferralNum       = PIn.Long  (table.Rows[i]["ReferralNum"].ToString());
				refAttach.PatNum            = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				refAttach.ItemOrder         = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				refAttach.RefDate           = PIn.Date  (table.Rows[i]["RefDate"].ToString());
				refAttach.IsFrom            = PIn.Bool  (table.Rows[i]["IsFrom"].ToString());
				refAttach.RefToStatus       = (ReferralToStatus)PIn.Int(table.Rows[i]["RefToStatus"].ToString());
				refAttach.Note              = PIn.String(table.Rows[i]["Note"].ToString());
				refAttach.IsTransitionOfCare= PIn.Bool  (table.Rows[i]["IsTransitionOfCare"].ToString());
				refAttach.ProcNum           = PIn.Long  (table.Rows[i]["ProcNum"].ToString());
				refAttach.DateProcComplete  = PIn.Date  (table.Rows[i]["DateProcComplete"].ToString());
				refAttach.ProvNum           = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				retVal.Add(refAttach);
			}
			return retVal;
		}
Exemple #11
0
        ///<summary>Inserts one RefAttach into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(RefAttach refAttach, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                refAttach.RefAttachNum = ReplicationServers.GetKey("refattach", "RefAttachNum");
            }
            string command = "INSERT INTO refattach (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "RefAttachNum,";
            }
            command += "ReferralNum,PatNum,ItemOrder,RefDate,IsFrom,RefToStatus,Note,IsTransitionOfCare,ProcNum,DateProcComplete,ProvNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(refAttach.RefAttachNum) + ",";
            }
            command +=
                POut.Long(refAttach.ReferralNum) + ","
                + POut.Long(refAttach.PatNum) + ","
                + POut.Int(refAttach.ItemOrder) + ","
                + POut.Date(refAttach.RefDate) + ","
                + POut.Bool(refAttach.IsFrom) + ","
                + POut.Int((int)refAttach.RefToStatus) + ","
                + "'" + POut.String(refAttach.Note) + "',"
                + POut.Bool(refAttach.IsTransitionOfCare) + ","
                + POut.Long(refAttach.ProcNum) + ","
                + POut.Date(refAttach.DateProcComplete) + ","
                + POut.Long(refAttach.ProvNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                refAttach.RefAttachNum = Db.NonQ(command, true);
            }
            return(refAttach.RefAttachNum);
        }
Exemple #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <RefAttach> TableToList(DataTable table)
        {
            List <RefAttach> retVal = new List <RefAttach>();
            RefAttach        refAttach;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                refAttach = new RefAttach();
                refAttach.RefAttachNum       = PIn.Long(table.Rows[i]["RefAttachNum"].ToString());
                refAttach.ReferralNum        = PIn.Long(table.Rows[i]["ReferralNum"].ToString());
                refAttach.PatNum             = PIn.Long(table.Rows[i]["PatNum"].ToString());
                refAttach.ItemOrder          = PIn.Int(table.Rows[i]["ItemOrder"].ToString());
                refAttach.RefDate            = PIn.Date(table.Rows[i]["RefDate"].ToString());
                refAttach.IsFrom             = PIn.Bool(table.Rows[i]["IsFrom"].ToString());
                refAttach.RefToStatus        = (ReferralToStatus)PIn.Int(table.Rows[i]["RefToStatus"].ToString());
                refAttach.Note               = PIn.String(table.Rows[i]["Note"].ToString());
                refAttach.IsTransitionOfCare = PIn.Bool(table.Rows[i]["IsTransitionOfCare"].ToString());
                refAttach.ProcNum            = PIn.Long(table.Rows[i]["ProcNum"].ToString());
                refAttach.DateProcComplete   = PIn.Date(table.Rows[i]["DateProcComplete"].ToString());
                retVal.Add(refAttach);
            }
            return(retVal);
        }
        ///<summary>Updates one RefAttach in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(RefAttach refAttach, RefAttach oldRefAttach)
        {
            string command = "";

            if (refAttach.ReferralNum != oldRefAttach.ReferralNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ReferralNum = " + POut.Long(refAttach.ReferralNum) + "";
            }
            if (refAttach.PatNum != oldRefAttach.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(refAttach.PatNum) + "";
            }
            if (refAttach.ItemOrder != oldRefAttach.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(refAttach.ItemOrder) + "";
            }
            if (refAttach.RefDate.Date != oldRefAttach.RefDate.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RefDate = " + POut.Date(refAttach.RefDate) + "";
            }
            if (refAttach.RefType != oldRefAttach.RefType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RefType = " + POut.Int((int)refAttach.RefType) + "";
            }
            if (refAttach.RefToStatus != oldRefAttach.RefToStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RefToStatus = " + POut.Int((int)refAttach.RefToStatus) + "";
            }
            if (refAttach.Note != oldRefAttach.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = " + DbHelper.ParamChar + "paramNote";
            }
            if (refAttach.IsTransitionOfCare != oldRefAttach.IsTransitionOfCare)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsTransitionOfCare = " + POut.Bool(refAttach.IsTransitionOfCare) + "";
            }
            if (refAttach.ProcNum != oldRefAttach.ProcNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcNum = " + POut.Long(refAttach.ProcNum) + "";
            }
            if (refAttach.DateProcComplete.Date != oldRefAttach.DateProcComplete.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateProcComplete = " + POut.Date(refAttach.DateProcComplete) + "";
            }
            if (refAttach.ProvNum != oldRefAttach.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(refAttach.ProvNum) + "";
            }
            //DateTStamp can only be set by MySQL
            if (command == "")
            {
                return(false);
            }
            if (refAttach.Note == null)
            {
                refAttach.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(refAttach.Note));

            command = "UPDATE refattach SET " + command
                      + " WHERE RefAttachNum = " + POut.Long(refAttach.RefAttachNum);
            Db.NonQ(command, paramNote);
            return(true);
        }
Exemple #14
0
		private void butAddTo_Click(object sender,EventArgs e) {
			if(!Security.IsAuthorized(Permissions.RefAttachAdd)) {
				return;
			}
			FormReferralSelect FormRS=new FormReferralSelect();
			FormRS.IsSelectionMode=true;
			FormRS.ShowDialog();
			if(FormRS.DialogResult!=DialogResult.OK) {
				return;
			}
			RefAttach refattach=new RefAttach();
			refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum;
			refattach.PatNum=PatNum;
			refattach.IsFrom=false;
			refattach.RefDate=DateTimeOD.Today;
			if(FormRS.SelectedReferral.IsDoctor) {
				refattach.IsTransitionOfCare=true;
			}
			int order=0;
			for(int i=0;i<RefAttachList.Count;i++) {
				if(RefAttachList[i].ItemOrder > order) {
					order=RefAttachList[i].ItemOrder;
				}
			}
			refattach.ItemOrder=order+1;
			refattach.ProcNum=ProcNum;
			//We want to help EHR users meet their measures.  Therefore, we are going to make an educated guess as to who is making this referral.
			//We are doing this for non-EHR users as well because we think it might be nice automation.
			long provNumLastAppt=Appointments.GetProvNumFromLastApptForPat(PatNum);
			if(Security.CurUser.ProvNum!=0) {
				refattach.ProvNum=Security.CurUser.ProvNum;
			}
			else if(provNumLastAppt!=0) {
				refattach.ProvNum=provNumLastAppt;
			}
			else {
				refattach.ProvNum=Patients.GetPat(PatNum).PriProv;
			}
			RefAttaches.Insert(refattach);
			SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd,PatNum,"Referred To "+Referrals.GetNameFL(refattach.ReferralNum));
			if(PrefC.GetBool(PrefName.ShowFeatureEhr)) {
				FormRefAttachEdit FormRAE=new FormRefAttachEdit();
				FormRAE.RefAttachCur=refattach;
				FormRAE.ShowDialog();
				//In order to help offices meet EHR Summary of Care measure 1 of Core Measure 15 of 17, we are going to send a summary of care to the patient portal behind the scenes.
				//We can send the summary of care to the patient instead of to the Dr. because of the following point in the Additional Information section of the Core Measure:
				//"The EP can send an electronic or paper copy of the summary care record directly to the next provider or can provide it to the patient to deliver to the next provider, if the patient can reasonably expected to do so and meet Measure 1."
				//We will only send the summary of care if the ref attach is a TO referral and is a transition of care.
				if(FormRAE.DialogResult==DialogResult.OK && !refattach.IsFrom && refattach.IsTransitionOfCare) {
					try {
						//This is like FormEhrClinicalSummary.butSendToPortal_Click such that the email gets treated like a web mail.
						Patient PatCur=Patients.GetPat(PatNum);
						string strCcdValidationErrors=EhrCCD.ValidateSettings();
						if(strCcdValidationErrors!="") {
							throw new Exception();
						}
						strCcdValidationErrors=EhrCCD.ValidatePatient(PatCur);
						if(strCcdValidationErrors!="") {
							throw new Exception();
						}
						Provider prov=null;
						if(Security.CurUser.ProvNum!=0) {
							prov=Providers.GetProv(Security.CurUser.ProvNum);
						}
						else {
							prov=Providers.GetProv(PatCur.PriProv);
						}
						EmailMessage msgWebMail=new EmailMessage();//New mail object				
						msgWebMail.FromAddress=prov.GetFormalName();//Adding from address
						msgWebMail.ToAddress=PatCur.GetNameFL();//Adding to address
						msgWebMail.PatNum=PatCur.PatNum;//Adding patient number
						msgWebMail.SentOrReceived=EmailSentOrReceived.WebMailSent;//Setting to sent
						msgWebMail.ProvNumWebMail=prov.ProvNum;//Adding provider number
						msgWebMail.Subject="Referral To "+FormRS.SelectedReferral.GetNameFL();
						msgWebMail.BodyText=
							"You have been referred to another provider.  Your summary of care is attached.\r\n"
							+"You may give a copy of this summary of care to the referred provider if desired.\r\n"
							+"The contact information for the doctor you are being referred to is as follows:\r\n"
							+"\r\n";
						//Here we provide the same information that would go out on a Referral Slip.
						//When the user prints a Referral Slip, the doctor referred to information is included and contains the doctor's name, address, and phone.
						msgWebMail.BodyText+="Name: "+FormRS.SelectedReferral.GetNameFL()+"\r\n";
						if(FormRS.SelectedReferral.Address.Trim()!="") {
							msgWebMail.BodyText+="Address: "+FormRS.SelectedReferral.Address.Trim()+"\r\n";
							if(FormRS.SelectedReferral.Address2.Trim()!="") {
								msgWebMail.BodyText+="\t"+FormRS.SelectedReferral.Address2.Trim()+"\r\n";
							}
							msgWebMail.BodyText+="\t"+FormRS.SelectedReferral.City+" "+FormRS.SelectedReferral.ST+" "+FormRS.SelectedReferral.Zip+"\r\n";
						}
						if(FormRS.SelectedReferral.Telephone!="") {
							msgWebMail.BodyText+="Phone: ("+FormRS.SelectedReferral.Telephone.Substring(0,3)+")"+FormRS.SelectedReferral.Telephone.Substring(3,3)+"-"+FormRS.SelectedReferral.Telephone.Substring(6)+"\r\n";
						}
						msgWebMail.BodyText+=
							"\r\n"
							+"To view the Summary of Care for the referral to this provider:\r\n"
							+"1) Download all attachments to the same folder.  Do not rename the files.\r\n"
							+"2) Open the ccd.xml file in an internet browser.";
						msgWebMail.MsgDateTime=DateTime.Now;//Message time is now
						msgWebMail.PatNumSubj=PatCur.PatNum;//Subject of the message is current patient
						string ccd="";
						Cursor=Cursors.WaitCursor;
						ccd=EhrCCD.GenerateSummaryOfCare(Patients.GetPat(PatNum));//Create summary of care, can throw exceptions but they're caught below
						msgWebMail.Attachments.Add(EmailAttaches.CreateAttach("ccd.xml",Encoding.UTF8.GetBytes(ccd)));//Create summary of care attachment, can throw exceptions but caught below
						msgWebMail.Attachments.Add(EmailAttaches.CreateAttach("ccd.xsl",Encoding.UTF8.GetBytes(FormEHR.GetEhrResource("CCD"))));//Create xsl attachment, can throw exceptions
						EmailMessages.Insert(msgWebMail);//Insert mail into DB for patient portal
						EhrMeasureEvent newMeasureEvent=new EhrMeasureEvent();
						newMeasureEvent.DateTEvent=DateTime.Now;
						newMeasureEvent.EventType=EhrMeasureEventType.SummaryOfCareProvidedToDr;
						newMeasureEvent.PatNum=PatCur.PatNum;
						newMeasureEvent.FKey=FormRAE.RefAttachCur.RefAttachNum;//Can be 0 if user didn't pick a referral for some reason.
						EhrMeasureEvents.Insert(newMeasureEvent);
					}
					catch {
						//We are just trying to be helpful so it doesn't really matter if something failed above. 
						//They can simply go to the EHR dashboard and send the summary of care manually like they always have.  They will get detailed validation errors there.
						MsgBox.Show(this,Lan.g(this,"There was a problem automatically sending a summary of care.  Please go to the EHR dashboard to send a summary of care to meet the summary of care core measure."));
					}
				}
			}
			Cursor=Cursors.Default;
			FillGrid();
			for(int i=0;i<RefAttachList.Count;i++) {
				if(RefAttachList[i].ReferralNum==refattach.ReferralNum) {
					gridMain.SetSelected(i,true);
				}
			}
		}
 ///<summary>Inserts one RefAttach into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(RefAttach refAttach)
 {
     return(InsertNoCache(refAttach, false));
 }
		private void butOK_Click(object sender,EventArgs e) {
			bool importsPresent=false;
			for(int i=0;i<Rows.Count;i++) {
				if(Rows[i].DoImport) {
					importsPresent=true;
					break;
				}
			}
			if(!importsPresent) {
				MsgBox.Show(this,"No rows are set for import.");
				return;
			}
			#region Patient Form
			if(SheetCur.SheetType==SheetTypeEnum.PatientForm) {
				bool importPriIns=false;
				bool importSecIns=false;
				for(int i=0;i<Rows.Count;i++) {
					if(!Rows[i].DoImport) {
						continue;
					}
					//Importing insurance happens later.
					if(Rows[i].FieldName.StartsWith("ins1")) {
						importPriIns=true;
						continue;
					}
					if(Rows[i].FieldName.StartsWith("ins2")) {
						importSecIns=true;
						continue;
					}
					switch(Rows[i].FieldName) {
						#region Personal
						case "LName":
							PatCur.LName=Rows[i].ImpValDisplay;
							break;
						case "FName":
							PatCur.FName=Rows[i].ImpValDisplay;
							break;
						case "MiddleI":
							PatCur.MiddleI=Rows[i].ImpValDisplay;
							break;
						case "Preferred":
							PatCur.Preferred=Rows[i].ImpValDisplay;
							break;
						case "Gender":
							PatCur.Gender=(PatientGender)Rows[i].ImpValObj;
							break;
						case "Position":
							PatCur.Position=(PatientPosition)Rows[i].ImpValObj;
							break;
						case "Birthdate":
							PatCur.Birthdate=(DateTime)Rows[i].ImpValObj;
							break;
						case "SSN":
							PatCur.SSN=Rows[i].ImpValDisplay;
							break;
						case "WkPhone":
							PatCur.WkPhone=Rows[i].ImpValDisplay;
							break;
						case "WirelessPhone":
							PatCur.WirelessPhone=Rows[i].ImpValDisplay;
							break;
						case "Email":
							PatCur.Email=Rows[i].ImpValDisplay;
							break;
						case "PreferContactMethod":
							PatCur.PreferContactMethod=(ContactMethod)Rows[i].ImpValObj;
							break;
						case "PreferConfirmMethod":
							PatCur.PreferConfirmMethod=(ContactMethod)Rows[i].ImpValObj;
							break;
						case "PreferRecallMethod":
							PatCur.PreferRecallMethod=(ContactMethod)Rows[i].ImpValObj;
							break;
						case "referredFrom":
							RefAttach ra=new RefAttach();
							ra.IsFrom=true;
							ra.ItemOrder=1;
							ra.PatNum=PatCur.PatNum;
							ra.RefDate=DateTimeOD.Today;
							ra.ReferralNum=((Referral)Rows[i].ImpValObj).ReferralNum;
							RefAttaches.Insert(ra);//no security to block this action.
							SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd,PatCur.PatNum,"Referred From "+Referrals.GetNameFL(ra.ReferralNum));
							break;
						#endregion
						#region Address and Home Phone
						//AddressSameForFam already set, but not really importable by itself
						case "Address":
							PatCur.Address=Rows[i].ImpValDisplay;
							break;
						case "Address2":
							PatCur.Address2=Rows[i].ImpValDisplay;
							break;
						case "City":
							PatCur.City=Rows[i].ImpValDisplay;
							break;
						case "State":
							PatCur.State=Rows[i].ImpValDisplay;
							break;
						case "Zip":
							PatCur.Zip=Rows[i].ImpValDisplay;
							break;
						case "HmPhone":
							PatCur.HmPhone=Rows[i].ImpValDisplay;
							break;
						#endregion
					}
				}
				//Insurance importing happens before updating the patient information because there is a possibility of returning for more information.
				if(HasRequiredInsFields) {//Do not attempt to import any insurance unless they have the required fields for importing.
					#region Insurance importing
					bool primaryImported=false;
					if(importPriIns) {//A primary insurance field was flagged for importing.
						if(!ValidateAndImportInsurance(true)) {
							//Field missing or user chose to back out to correct information.
							return;//Nothing has been updated so it's okay to just return here.
						}
						primaryImported=true;
					}
					if(importSecIns) {//A secondary insurance field was flagged for importing.
						if(!ValidateAndImportInsurance(false)) {
							//Field missing or user chose to back out to correct information.
							if(primaryImported) {
								//Primary has been imported, we cannot return at this point.  Simply notify the user that secondary could not be imported correctly.
								MsgBox.Show(this,"Primary insurance was imported successfully but secondary was unable to import.");
							}
							else {//Secondary had problems importing or the user chose to back out and correct information.
								return;//Nothing has been updated so it's okay to just return here.
							}
						}
					}
					#endregion
				}
				else {//Sheet does not contain the required ins fields.
					if(importPriIns) {//The user has manually flagged a primary ins row for importing.
						MsgBox.Show(this,"Required primary insurance fields are missing on this sheet.  You cannot import primary insurance with this sheet until it contains all of required fields.  Required fields: Relationship, Subscriber, SubscriberID, CarrierName, and CarrierPhone.");
					}
					if(importSecIns) {//The user has manually flagged a secondary ins row for importing.
						MsgBox.Show(this,"Required secondary insurance fields are missing on this sheet.  You cannot import secondary insurance with this sheet until it contains all of required fields.  Required fields: Relationship, Subscriber, SubscriberID, CarrierName, and CarrierPhone.");
					}
				}
				//Patient information updating---------------------------------------------------------------------------------------------------------
				Patients.Update(PatCur,PatOld);
				if(AddressSameForFam) {
					Patients.UpdateAddressForFam(PatCur);
				}
			}
			#endregion
			#region Medical History
			else if(SheetCur.SheetType==SheetTypeEnum.MedicalHistory) {
				for(int i=0;i<Rows.Count;i++) {
					if(!Rows[i].DoImport) {
						continue;
					}
					if(Rows[i].ObjType==null) {//Should never happen.
						continue;
					}
					YN hasValue=YN.Unknown;
					if(Rows[i].ImpValDisplay=="Y") {
						hasValue=YN.Yes;
					}
					if(Rows[i].ImpValDisplay=="N") {
						hasValue=YN.No;
					}
					if(hasValue==YN.Unknown) {//Unknown, nothing to do.
						continue;
					}
					#region Allergies
					if(Rows[i].ObjType==typeof(Allergy)) {
						//Patient has this allergy in the db so just update the value.
						if(Rows[i].OldValObj!=null) {
							Allergy oldAllergy=(Allergy)Rows[i].OldValObj;
							if(hasValue==YN.Yes) {
								oldAllergy.StatusIsActive=true;
							}
							else {
								oldAllergy.StatusIsActive=false;
							}
							Allergies.Update(oldAllergy);
							continue;
						}
						if(hasValue==YN.No) {//We never import allergies with inactive status.
							continue;
						}
						//Allergy does not exist for this patient yet so create one.
						List<AllergyDef> allergyList=AllergyDefs.GetAll(false);
						SheetField allergySheet=(SheetField)Rows[i].NewValObj;
						//Find what allergy user wants to import.
						for(int j=0;j<allergyList.Count;j++) {
							if(allergyList[j].Description==allergySheet.FieldName.Remove(0,8)) {
								Allergy newAllergy=new Allergy();
								newAllergy.AllergyDefNum=allergyList[j].AllergyDefNum;
								newAllergy.PatNum=PatCur.PatNum;
								newAllergy.StatusIsActive=true;
								Allergies.Insert(newAllergy);
								break;
							}
						}
					}
					#endregion
					#region Medications
					else if(Rows[i].ObjType==typeof(MedicationPat)) {
					  //Patient has this medication in the db so leave it alone or set the stop date.
					  if(Rows[i].OldValObj!=null) {
					    //Set the stop date for the current medication(s).
					    MedicationPat oldMedPat=(MedicationPat)Rows[i].OldValObj;
					    if(hasValue==YN.Yes) {
								if(!MedicationPats.IsMedActive(oldMedPat)) {
									oldMedPat.DateStop=new DateTime(0001,1,1);//This will activate the med.
					      }
					    }
							else {
								oldMedPat.DateStop=DateTime.Today;//Set the med as inactive.
							}
							MedicationPats.Update(oldMedPat);
					    continue;
					  }
						if(hasValue==YN.No) {//Don't import medications with inactive status.
							continue;
						}
					  //Medication does not exist for this patient yet so create it.
					  List<Medication> medList=Medications.GetList("");
					  SheetField medSheet=(SheetField)Rows[i].NewValObj;
					  //Find what medication user wants to import.
					  for(int j=0;j<medList.Count;j++) {
					    if(Medications.GetDescription(medList[j].MedicationNum)==medSheet.FieldValue) {
					      MedicationPat medPat=new MedicationPat();
					      medPat.PatNum=PatCur.PatNum;
					      medPat.MedicationNum=medList[j].MedicationNum;
					      MedicationPats.Insert(medPat);
					      break;
					    }
					  }
					}
					#endregion
					#region Diseases
					else if(Rows[i].ObjType==typeof(Disease)) {
						//Patient has this problem in the db so just update the value.
						if(Rows[i].OldValObj!=null) {
							Disease oldDisease=(Disease)Rows[i].OldValObj;
							if(hasValue==YN.Yes) {
								oldDisease.ProbStatus=ProblemStatus.Active;
							}
							else {
								oldDisease.ProbStatus=ProblemStatus.Inactive;
							}
							Diseases.Update(oldDisease);
							continue;
						}
						if(hasValue==YN.No) {//Don't create new problem with inactive status.
							continue;
						}
						//Problem does not exist for this patient yet so create one.
						SheetField diseaseSheet=(SheetField)Rows[i].NewValObj;
						//Find what allergy user wants to import.
						for(int j=0;j<DiseaseDefs.List.Length;j++) {
							if(DiseaseDefs.List[j].DiseaseName==diseaseSheet.FieldName.Remove(0,8)) {
								Disease newDisease=new Disease();
								newDisease.PatNum=PatCur.PatNum;
								newDisease.DiseaseDefNum=DiseaseDefs.List[j].DiseaseDefNum;
								newDisease.ProbStatus=ProblemStatus.Active;
								Diseases.Insert(newDisease);
								break;
							}
						}
					}
					#endregion
				}
			}
			#endregion
			MsgBox.Show(this,"Done.");
			DialogResult=DialogResult.OK;
		}
Exemple #17
0
 private void butAddTo_Click(object sender,EventArgs e)
 {
     FormReferralSelect FormRS=new FormReferralSelect();
     FormRS.IsSelectionMode=true;
     FormRS.ShowDialog();
     if(FormRS.DialogResult!=DialogResult.OK) {
         return;
     }
     RefAttach refattach=new RefAttach();
     refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum;
     refattach.PatNum=PatNum;
     refattach.IsFrom=false;
     refattach.RefDate=DateTime.Today;
     if(FormRS.SelectedReferral.IsDoctor) {
         refattach.IsTransitionOfCare=true;
     }
     int order=0;
     for(int i=0;i<RefAttachList.Count;i++) {
         if(RefAttachList[i].ItemOrder > order) {
             order=RefAttachList[i].ItemOrder;
         }
     }
     refattach.ItemOrder=order+1;
     refattach.ProcNum=ProcNum;
     RefAttaches.Insert(refattach);
     FillGrid();
     for(int i=0;i<RefAttachList.Count;i++) {
         if(RefAttachList[i].ReferralNum==refattach.ReferralNum) {
             gridMain.SetSelected(i,true);
         }
     }
 }
		private void butAddTo_Click(object sender,EventArgs e) {
			if(!Security.IsAuthorized(Permissions.RefAttachAdd)) {
				return;
			}
			FormReferralSelect FormRS=new FormReferralSelect();
			FormRS.IsSelectionMode=true;
			FormRS.ShowDialog();
			if(FormRS.DialogResult!=DialogResult.OK) {
				return;
			}
			RefAttach refattach=new RefAttach();
			refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum;
			refattach.PatNum=PatNum;
			refattach.IsFrom=false;
			refattach.RefDate=DateTimeOD.Today;
			if(FormRS.SelectedReferral.IsDoctor) {
				refattach.IsTransitionOfCare=true;
			}
			int order=0;
			for(int i=0;i<RefAttachList.Count;i++) {
				if(RefAttachList[i].ItemOrder > order) {
					order=RefAttachList[i].ItemOrder;
				}
			}
			refattach.ItemOrder=order+1;
			refattach.ProcNum=ProcNum;
			RefAttaches.Insert(refattach);
			SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd,PatNum,"Referred To "+Referrals.GetNameFL(refattach.ReferralNum));
			FillGrid();
			for(int i=0;i<RefAttachList.Count;i++) {
				if(RefAttachList[i].ReferralNum==refattach.ReferralNum) {
					gridMain.SetSelected(i,true);
				}
			}
		}
		//<summary>for this patient only</summary>
		//public static RefAttach[] List;
		//<summary></summary>
		//public static RefAttach Cur;
		//<summary></summary>
		//public static Hashtable HList;//key:refAttachNum, value:RefAttach

		///<summary>For one patient</summary>
		public static RefAttach[] Refresh(int patNum){
			string command=
				"SELECT * FROM refattach"
				+" WHERE patnum = "+patNum.ToString()
				+" ORDER BY itemorder";
 			DataTable table=General.GetTable(command);
			RefAttach[] List=new RefAttach[table.Rows.Count];
			//HList=new Hashtable();
			for(int i=0;i<table.Rows.Count;i++){
				List[i]=new RefAttach();
				List[i].RefAttachNum= PIn.PInt   (table.Rows[i][0].ToString());
				List[i].ReferralNum = PIn.PInt   (table.Rows[i][1].ToString());
				List[i].PatNum      = PIn.PInt   (table.Rows[i][2].ToString());
				List[i].ItemOrder   = PIn.PInt   (table.Rows[i][3].ToString());
				List[i].RefDate     = PIn.PDate  (table.Rows[i][4].ToString());
				List[i].IsFrom      = PIn.PBool  (table.Rows[i][5].ToString());       
				//HList.Add(List[i].RefAttachNum,List[i]);
			}
			return List;
		}
		///<summary>Updates one RefAttach in the database.</summary>
		public static void Update(RefAttach refAttach){
			string command="UPDATE refattach SET "
				+"ReferralNum       =  "+POut.Long  (refAttach.ReferralNum)+", "
				+"PatNum            =  "+POut.Long  (refAttach.PatNum)+", "
				+"ItemOrder         =  "+POut.Int   (refAttach.ItemOrder)+", "
				+"RefDate           =  "+POut.Date  (refAttach.RefDate)+", "
				+"IsFrom            =  "+POut.Bool  (refAttach.IsFrom)+", "
				+"RefToStatus       =  "+POut.Int   ((int)refAttach.RefToStatus)+", "
				+"Note              = '"+POut.String(refAttach.Note)+"', "
				+"IsTransitionOfCare=  "+POut.Bool  (refAttach.IsTransitionOfCare)+", "
				+"ProcNum           =  "+POut.Long  (refAttach.ProcNum)+", "
				+"DateProcComplete  =  "+POut.Date  (refAttach.DateProcComplete)+", "
				+"ProvNum           =  "+POut.Long  (refAttach.ProvNum)+" "
				+"WHERE RefAttachNum = "+POut.Long(refAttach.RefAttachNum);
			Db.NonQ(command);
		}
		///<summary>Pass in all the refattaches for the patient.  This funtion finds the first referral from a Dr and returns that Dr's name.  Used in specialty practices.  Function is only used right now in the Dr. Ceph bridge.</summary>
		public static string GetReferringDr(RefAttach[] attachList){
			if(attachList.Length==0){
				return "";
			}
			if(!attachList[0].IsFrom){
				return "";
			}
			Referral referral=Referrals.GetReferral(attachList[0].ReferralNum);
			if(referral.PatNum!=0){
				return "";
			}
			string retVal=referral.FName+" "+referral.MName+" "+referral.LName;
			if(referral.Title!=""){
				retVal+=", "+referral.Title;
			}
			return retVal;
		}
		///<summary>Updates one RefAttach in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
		public static void Update(RefAttach refAttach,RefAttach oldRefAttach){
			string command="";
			if(refAttach.ReferralNum != oldRefAttach.ReferralNum) {
				if(command!=""){ command+=",";}
				command+="ReferralNum = "+POut.Long(refAttach.ReferralNum)+"";
			}
			if(refAttach.PatNum != oldRefAttach.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(refAttach.PatNum)+"";
			}
			if(refAttach.ItemOrder != oldRefAttach.ItemOrder) {
				if(command!=""){ command+=",";}
				command+="ItemOrder = "+POut.Int(refAttach.ItemOrder)+"";
			}
			if(refAttach.RefDate != oldRefAttach.RefDate) {
				if(command!=""){ command+=",";}
				command+="RefDate = "+POut.Date(refAttach.RefDate)+"";
			}
			if(refAttach.IsFrom != oldRefAttach.IsFrom) {
				if(command!=""){ command+=",";}
				command+="IsFrom = "+POut.Bool(refAttach.IsFrom)+"";
			}
			if(refAttach.RefToStatus != oldRefAttach.RefToStatus) {
				if(command!=""){ command+=",";}
				command+="RefToStatus = "+POut.Int   ((int)refAttach.RefToStatus)+"";
			}
			if(refAttach.Note != oldRefAttach.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(refAttach.Note)+"'";
			}
			if(refAttach.IsTransitionOfCare != oldRefAttach.IsTransitionOfCare) {
				if(command!=""){ command+=",";}
				command+="IsTransitionOfCare = "+POut.Bool(refAttach.IsTransitionOfCare)+"";
			}
			if(refAttach.ProcNum != oldRefAttach.ProcNum) {
				if(command!=""){ command+=",";}
				command+="ProcNum = "+POut.Long(refAttach.ProcNum)+"";
			}
			if(refAttach.DateProcComplete != oldRefAttach.DateProcComplete) {
				if(command!=""){ command+=",";}
				command+="DateProcComplete = "+POut.Date(refAttach.DateProcComplete)+"";
			}
			if(refAttach.ProvNum != oldRefAttach.ProvNum) {
				if(command!=""){ command+=",";}
				command+="ProvNum = "+POut.Long(refAttach.ProvNum)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE refattach SET "+command
				+" WHERE RefAttachNum = "+POut.Long(refAttach.RefAttachNum);
			Db.NonQ(command);
		}
Exemple #23
0
		private void gridMu_CellClick(object sender,ODGridClickEventArgs e) {
			FormMedical FormMed;
			if(e.Col==3) {
				switch(listMu[e.Row].MeasureType) {
					case EhrMeasureType.ProblemList:
						FormMed=new FormMedical(PatNotCur,PatCur);
						FormMed.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.Medical;
						//Close();
						break;
					case EhrMeasureType.MedicationList:
						FormMed=new FormMedical(PatNotCur,PatCur);
						FormMed.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.Medical;
						//Close();
						break;
					case EhrMeasureType.AllergyList:
						FormMed=new FormMedical(PatNotCur,PatCur);
						FormMed.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.Medical;
						//Close();
						break;
					case EhrMeasureType.Demographics:
						FormPatientEdit FormPatEdit=new FormPatientEdit(PatCur, PatFamCur);
						FormPatEdit.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.PatientEdit;
						//Close();
						break;
					case EhrMeasureType.Education:
						FormEhrEduResourcesPat FormEDUPat = new FormEhrEduResourcesPat();
						FormEDUPat.patCur=PatCur;
						FormEDUPat.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.TimelyAccess:
					case EhrMeasureType.ElectronicCopyAccess:
						FormPatientPortal FormPatPort=new FormPatientPortal();
						FormPatPort.PatCur=PatCur;
						FormPatPort.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.Online;
						//Close();
						break;
					case EhrMeasureType.ProvOrderEntry:
					case EhrMeasureType.CPOE_MedOrdersOnly:
					case EhrMeasureType.CPOE_PreviouslyOrdered:
						//LaunchOrdersWindow();
						break;
					case EhrMeasureType.Rx:
						//no action available
						break;
					case EhrMeasureType.VitalSigns:
					case EhrMeasureType.VitalSignsBMIOnly:
					case EhrMeasureType.VitalSignsBPOnly:
					case EhrMeasureType.VitalSigns2014:
						FormVitalsigns FormVital=new FormVitalsigns();
						FormVital.PatNum=PatNum;
						FormVital.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.Smoking:
						FormEhrPatientSmoking FormPS=new FormEhrPatientSmoking();
						FormPS.PatCur=PatCur;
						FormPS.ShowDialog();
						PatCur=Patients.GetPat(PatNum);
						FillGridMu();
						break;
					case EhrMeasureType.Lab:
						if(DataConnection.DBtype==DatabaseType.Oracle) {
							MsgBox.Show(this,"Labs not supported with Oracle");
							break;
						}
						FormEhrLabOrders FormLP=new FormEhrLabOrders();
						FormLP.PatCur=PatCur;
						FormLP.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.ElectronicCopy:
						if(listMu[e.Row].Action=="Provide elect copy to Pt") {
							FormEhrElectronicCopy FormE=new FormEhrElectronicCopy();
							FormE.PatCur=PatCur;
							FormE.ShowDialog();
							FillGridMu();
						}
						break;
					case EhrMeasureType.ClinicalSummaries:
						FormEhrClinicalSummary FormCS=new FormEhrClinicalSummary();
						FormCS.PatCur=PatCur;
						FormCS.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.Reminders:
						FormEhrReminders FormRem = new FormEhrReminders();
						FormRem.PatCur=PatCur;
						FormRem.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.MedReconcile:
						int compare=EhrMeasures.CompareReferralsToReconciles(PatNum);
						if(compare==1 || compare==0) {//Referral count is less than reconcile count or both are zero.
							FormReferralSelect FormRS=new FormReferralSelect();
							FormRS.IsDoctorSelectionMode=true;
							FormRS.IsSelectionMode=true;
							FormRS.ShowDialog();
							if(FormRS.DialogResult!=DialogResult.OK) {
								return;
							}
							List<RefAttach> RefAttachList=RefAttaches.RefreshFiltered(PatNum,false,0);
							RefAttach refattach=new RefAttach();
							refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum;
							refattach.PatNum=PatNum;
							refattach.IsFrom=true;
							refattach.RefDate=DateTimeOD.Today;
							if(FormRS.SelectedReferral.IsDoctor) {//whether using ehr or not
								refattach.IsTransitionOfCare=true;
							}
							int order=0;
							for(int i=0;i<RefAttachList.Count;i++) {
								if(RefAttachList[i].ItemOrder > order) {
									order=RefAttachList[i].ItemOrder;
								}
							}
							refattach.ItemOrder=order+1;
							RefAttaches.Insert(refattach);
							SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd,PatNum,"Referred From "+Referrals.GetNameFL(refattach.ReferralNum));
						}
						else if(compare==-1) {//The referral count is greater than the reconcile count.
							//So we do not need to show the referral window, we just need to reconcile below.
						}
						FormEhrSummaryOfCare FormMedRec=new FormEhrSummaryOfCare();
						FormMedRec.PatCur=PatCur;
						FormMedRec.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.MedReconcile;
						//Close();
						break;
					case EhrMeasureType.SummaryOfCare:
						FormEhrSummaryOfCare FormSoC=new FormEhrSummaryOfCare();
						FormSoC.PatCur=PatCur;
						FormSoC.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.SummaryOfCareElectronic:
						FormEhrSummaryOfCare FormSoCE=new FormEhrSummaryOfCare();
						FormSoCE.PatCur=PatCur;
						FormSoCE.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.SecureMessaging:
						//Patient Sent
						break;
					case EhrMeasureType.FamilyHistory:
						FormMed=new FormMedical(PatNotCur,PatCur);
						FormMed.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.ElectronicNote:
						//Sign a Note
						break;
					case EhrMeasureType.CPOE_LabOrdersOnly:
						if(DataConnection.DBtype==DatabaseType.Oracle) {
							MsgBox.Show(this,"Labs not supported with Oracle");
							break;
						}
						FormEhrLabOrders FormLab=new FormEhrLabOrders();
						FormLab.PatCur=PatCur;
						FormLab.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.CPOE_RadiologyOrdersOnly:
						if(DataConnection.DBtype==DatabaseType.Oracle) {
							MsgBox.Show(this,"Labs not supported with Oracle");
							break;
						}
						FormEhrLabOrders FormRad=new FormEhrLabOrders();
						FormRad.PatCur=PatCur;
						FormRad.ShowDialog();
						FillGridMu();
						break;
					case EhrMeasureType.LabImages:
						if(DataConnection.DBtype==DatabaseType.Oracle) {
							MsgBox.Show(this,"Labs not supported with Oracle");
							break;
						}
						FormEhrLabOrders FormLO=new FormEhrLabOrders();
						FormLO.PatCur=PatCur;
						FormLO.ShowDialog();
						FillGridMu();
						break;
				}
			}
			if(e.Col==4) {
				switch(listMu[e.Row].MeasureType) {
					case EhrMeasureType.MedReconcile:
						int compare=EhrMeasures.CompareReferralsToReconciles(PatNum);
						if(compare==1 || compare==0) {
							FormReferralSelect FormRS=new FormReferralSelect();
							FormRS.IsDoctorSelectionMode=true;
							FormRS.IsSelectionMode=true;
							FormRS.ShowDialog();
							if(FormRS.DialogResult==DialogResult.OK) {
								List<RefAttach> RefAttachList=RefAttaches.RefreshFiltered(PatNum,false,0);
								RefAttach refattach=new RefAttach();
								refattach.ReferralNum=FormRS.SelectedReferral.ReferralNum;
								refattach.PatNum=PatNum;
								refattach.IsFrom=true;
								refattach.RefDate=DateTimeOD.Today;
								if(FormRS.SelectedReferral.IsDoctor) {//whether using ehr or not
									//we're not going to ask.  That's stupid.
									//if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Is this an incoming transition of care from another provider?")){
									refattach.IsTransitionOfCare=true;
								}
								int order=0;
								for(int i=0;i<RefAttachList.Count;i++) {
									if(RefAttachList[i].ItemOrder > order) {
										order=RefAttachList[i].ItemOrder;
									}
								}
								refattach.ItemOrder=order+1;
								RefAttaches.Insert(refattach);
								SecurityLogs.MakeLogEntry(Permissions.RefAttachAdd,PatNum,"Referred From "+Referrals.GetNameFL(refattach.ReferralNum));
								FormMedicationReconcile FormMedRec=new FormMedicationReconcile();
								FormMedRec.PatCur=PatCur;
								FormMedRec.ShowDialog();
							}
						}
						else if(compare==-1) {
							FormMedicationReconcile FormMedRec=new FormMedicationReconcile();
							FormMedRec.PatCur=PatCur;
							FormMedRec.ShowDialog();
						}
						FillGridMu();
						//ResultOnClosing=EhrFormResult.Referrals;
						//Close();
						break;
					case EhrMeasureType.SummaryOfCare:
					case EhrMeasureType.SummaryOfCareElectronic:
						FormReferralsPatient FormRefSum=new FormReferralsPatient();
						FormRefSum.PatNum=PatCur.PatNum;
						FormRefSum.ShowDialog();
						FillGridMu();
						//ResultOnClosing=EhrFormResult.Referrals;
						//Close();
						break;
					case EhrMeasureType.Lab:
						//Redundant now that everything is done from one window
						break;
				}
			}
		}
Exemple #24
0
        private void butOK_Click(object sender,EventArgs e)
        {
            bool importsPresent=false;
            for(int i=0;i<rows.Count;i++) {
                if(rows[i].DoImport) {
                    importsPresent=true;
                    break;
                }
            }
            if(!importsPresent) {
                MsgBox.Show(this,"No rows are set for import.");
                return;
            }
            Patient patientOld=pat.Copy();
            for(int i=0;i<rows.Count;i++) {
                if(!rows[i].DoImport) {
                    continue;
                }
                switch(rows[i].FieldName){
                    case "LName":
                        pat.LName=rows[i].ImpValDisplay;
                        break;
                    case "FName":
                        pat.FName=rows[i].ImpValDisplay;
                        break;
                    case "MiddleI":
                        pat.MiddleI=rows[i].ImpValDisplay;
                        break;
                    case "Preferred":
                        pat.Preferred=rows[i].ImpValDisplay;
                        break;
                    case "Gender":
                        pat.Gender=(PatientGender)rows[i].ImpValObj;
                        break;
                    case "Position":
                        pat.Position=(PatientPosition)rows[i].ImpValObj;
                        break;
                    case "Birthdate":
                        pat.Birthdate=(DateTime)rows[i].ImpValObj;
                        break;
                    case "SSN":
                        pat.SSN=rows[i].ImpValDisplay;
                        break;
                    case "WkPhone":
                        pat.WkPhone=rows[i].ImpValDisplay;
                        break;
                    case "WirelessPhone":
                        pat.WirelessPhone=rows[i].ImpValDisplay;
                        break;
                    case "Email":
                        pat.Email=rows[i].ImpValDisplay;
                        break;
                    case "PreferContactMethod":
                        pat.PreferContactMethod=(ContactMethod)rows[i].ImpValObj;
                        break;
                    case "PreferConfirmMethod":
                        pat.PreferConfirmMethod=(ContactMethod)rows[i].ImpValObj;
                        break;
                    case "PreferRecallMethod":
                        pat.PreferRecallMethod=(ContactMethod)rows[i].ImpValObj;
                        break;
                    case "referredFrom":
                        RefAttach ra=new RefAttach();
                        ra.IsFrom=true;
                        ra.ItemOrder=1;
                        ra.PatNum=pat.PatNum;
                        ra.RefDate=DateTime.Today;
                        ra.ReferralNum=((Referral)rows[i].ImpValObj).ReferralNum;
                        RefAttaches.Insert(ra);
                        break;
                    //AddressSameForFam already set, but not really importable by itself
                    case "Address":
                        pat.Address=rows[i].ImpValDisplay;
                        break;
                    case "Address2":
                        pat.Address2=rows[i].ImpValDisplay;
                        break;
                    case "City":
                        pat.City=rows[i].ImpValDisplay;
                        break;
                    case "State":
                        pat.State=rows[i].ImpValDisplay;
                        break;
                    case "Zip":
                        pat.Zip=rows[i].ImpValDisplay;
                        break;
                    case "HmPhone":
                        pat.HmPhone=rows[i].ImpValDisplay;
                        break;

                    //ins1 and ins2 do not get imported.
                }
            }
            Patients.Update(pat,patientOld);
            if(AddressSameForFam) {
                Patients.UpdateAddressForFam(pat);
            }
            MsgBox.Show(this,"Done.");
            DialogResult=DialogResult.OK;
        }
Exemple #25
0
 private void butOK_Click(object sender,EventArgs e)
 {
     if(  textBirthdate1.errorProvider1.GetError(textBirthdate1)!=""
         || textBirthdate2.errorProvider1.GetError(textBirthdate2)!=""
         || textBirthdate3.errorProvider1.GetError(textBirthdate3)!=""
         || textBirthdate4.errorProvider1.GetError(textBirthdate4)!=""
         || textBirthdate5.errorProvider1.GetError(textBirthdate5)!=""
         ){
         MsgBox.Show(this,"Please fix data entry errors first.");
         return;
     }
     //no validation on birthdate reasonableness.
     if(textLName1.Text=="" || textFName1.Text==""){
         MsgBox.Show(this,"Guarantor name must be entered.");
         return;
     }
     // Validate Insurance subscribers--------------------------------------------------------------------------------------------------------
     if((comboSubscriber1.SelectedIndex==2 || comboSubscriber2.SelectedIndex==2) && (textFName2.Text=="" || textLName2.Text=="")){
         MsgBox.Show(this,"Subscriber must have name entered.");
         return;
     }
     if((comboSubscriber1.SelectedIndex==3 || comboSubscriber2.SelectedIndex==3) && (textFName3.Text=="" || textLName3.Text=="")){
         MsgBox.Show(this,"Subscriber must have name entered.");
         return;
     }
     if((comboSubscriber1.SelectedIndex==4 || comboSubscriber2.SelectedIndex==4) && (textFName4.Text=="" || textLName4.Text=="")){
         MsgBox.Show(this,"Subscriber must have name entered.");
         return;
     }
     if((comboSubscriber1.SelectedIndex==5 || comboSubscriber2.SelectedIndex==5) && (textFName5.Text=="" || textLName5.Text=="")){
         MsgBox.Show(this,"Subscriber must have name entered.");
         return;
     }
     // Validate Insurance Plans--------------------------------------------------------------------------------------------------------------
     bool insComplete1=false;
     bool insComplete2=false;
     if(comboSubscriber1.SelectedIndex>0
         && textSubscriberID1.Text!=""
         && textCarrier1.Text!="")
     {
         insComplete1=true;
     }
     if(comboSubscriber2.SelectedIndex>0
         && textSubscriberID2.Text!=""
         && textCarrier2.Text!="")
     {
         insComplete2=true;
     }
     //test for insurance having only some of the critical fields filled in
     if(comboSubscriber1.SelectedIndex>0
         || textSubscriberID1.Text!=""
         || textCarrier1.Text!="")
     {
         if(!insComplete1){
             MsgBox.Show(this,"Subscriber, Subscriber ID, and Carrier are all required fields if adding insurance.");
             return;
         }
     }
     if(comboSubscriber2.SelectedIndex>0
         || textSubscriberID2.Text!=""
         || textCarrier2.Text!="")
     {
         if(!insComplete2){
             MsgBox.Show(this,"Subscriber, Subscriber ID, and Carrier are all required fields if adding insurance.");
             return;
         }
     }
     if(checkInsOne1.Checked
         || checkInsOne2.Checked
         || checkInsOne3.Checked
         || checkInsOne4.Checked
         || checkInsOne5.Checked)
     {
         if(!insComplete1){
             MsgBox.Show(this,"Subscriber, Subscriber ID, and Carrier are all required fields if adding insurance.");
             return;
         }
     }
     if(checkInsTwo1.Checked
         || checkInsTwo2.Checked
         || checkInsTwo3.Checked
         || checkInsTwo4.Checked
         || checkInsTwo5.Checked)
     {
         if(!insComplete2){
             MsgBox.Show(this,"Subscriber, Subscriber ID, and Carrier are all required fields if adding insurance.");
             return;
         }
     }
     //Validate Insurance subscriptions---------------------------------------------------------------------------------------------------
     if(insComplete1){
         if(!checkInsOne1.Checked
             && !checkInsOne2.Checked
             && !checkInsOne3.Checked
             && !checkInsOne4.Checked
             && !checkInsOne5.Checked)
         {
             MsgBox.Show(this,"Insurance information has been filled in, but has not been assigned to any patients.");
             return;
         }
         if(checkInsOne1.Checked && (textLName1.Text=="" || textFName1.Text=="")//Insurance1 assigned to invalid patient1
             || checkInsOne2.Checked && (textLName2.Text=="" || textFName2.Text=="")//Insurance1 assigned to invalid patient2
             || checkInsOne3.Checked && (textLName3.Text=="" || textFName3.Text=="")//Insurance1 assigned to invalid patient3
             || checkInsOne4.Checked && (textLName4.Text=="" || textFName4.Text=="")//Insurance1 assigned to invalid patient4
             || checkInsOne5.Checked && (textLName5.Text=="" || textFName5.Text=="")) //Insurance1 assigned to invalid patient5
         {
             MsgBox.Show(this,"Insurance information 1 has been filled in, but has been assigned to a patient with no name.");
             return;
         }
     }
     if(insComplete2){
         if(!checkInsTwo1.Checked
             && !checkInsTwo2.Checked
             && !checkInsTwo3.Checked
             && !checkInsTwo4.Checked
             && !checkInsTwo5.Checked)
         {
             MsgBox.Show(this,"Insurance information 2 has been filled in, but has not been assigned to any patients.");
             return;
         }
         if(checkInsTwo1.Checked && (textLName1.Text=="" || textFName1.Text=="")//Insurance2 assigned to invalid patient1
             || checkInsTwo2.Checked && (textLName2.Text=="" || textFName2.Text=="")//Insurance2 assigned to invalid patient2
             || checkInsTwo3.Checked && (textLName3.Text=="" || textFName3.Text=="")//Insurance2 assigned to invalid patient3
             || checkInsTwo4.Checked && (textLName4.Text=="" || textFName4.Text=="")//Insurance2 assigned to invalid patient4
             || checkInsTwo5.Checked && (textLName5.Text=="" || textFName5.Text=="")) //Insurance2 assigned to invalid patient5
         {
             MsgBox.Show(this,"Insurance information 2 has been filled in, but has been assigned to a patient with no name.");
             return;
         }
     }
     //End of validation------------------------------------------------------------------------------------------
     //Create Guarantor-------------------------------------------------------------------------------------------
     Patient guar=new Patient();
     guar.LName=textLName1.Text;
     guar.FName=textFName1.Text;
     if(listGender1.SelectedIndex==0){
         guar.Gender=PatientGender.Male;
     }
     else{
         guar.Gender=PatientGender.Female;
     }
     if(listPosition1.SelectedIndex==0){
         guar.Position=PatientPosition.Single;
     }
     else{
         guar.Position=PatientPosition.Married;
     }
     guar.Birthdate=PIn.Date(textBirthdate1.Text);
     guar.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
     guar.PatStatus=PatientStatus.Patient;
     guar.PriProv=ProviderC.ListShort[comboPriProv1.SelectedIndex].ProvNum;
     if(comboSecProv1.SelectedIndex>0){
         guar.SecProv=ProviderC.ListShort[comboSecProv1.SelectedIndex-1].ProvNum;
     }
     guar.HmPhone=textHmPhone.Text;
     guar.Address=textAddress.Text;
     guar.Address2=textAddress2.Text;
     guar.City=textCity.Text;
     guar.State=textState.Text;
     guar.Zip=textZip.Text;
     guar.AddrNote=textAddrNotes.Text;
     guar.ClinicNum=Security.CurUser.ClinicNum;
     Patients.Insert(guar,false);
     Patient guarOld=guar.Copy();
     guar.Guarantor=guar.PatNum;
     Patients.Update(guar,guarOld);
     RefAttach refAttach;
     if(textReferral.Text!=""){
         //selectedReferral will already be set if user picked from list.
         //but, if selectedReferral doesn't match data in boxes, then clear it.
         if(selectedReferral!=null
             && (selectedReferral.LName!=textReferral.Text
             || selectedReferral.FName!=textReferralFName.Text))
         {
             selectedReferral=null;
         }
         if(selectedReferral==null){
             selectedReferral=new Referral();
             selectedReferral.LName=textReferral.Text;
             selectedReferral.FName=textReferralFName.Text;
             Referrals.Insert(selectedReferral);
         }
         //Now we will always have a valid referral to attach.  We will use it again for the other family members.
         refAttach=new RefAttach();
         refAttach.IsFrom=true;
         refAttach.RefDate=DateTime.Today;
         refAttach.ReferralNum=selectedReferral.ReferralNum;
         refAttach.PatNum=guar.PatNum;
         RefAttaches.Insert(refAttach);
     }
     //Patient #2-----------------------------------------------------------------------------------------------------
     Patient pat2=null;
     if(textFName2.Text!="" && textLName2.Text!=""){
         pat2=new Patient();
         pat2.LName=textLName2.Text;
         pat2.FName=textFName2.Text;
         if(listGender2.SelectedIndex==0){
             pat2.Gender=PatientGender.Male;
         }
         else{
             pat2.Gender=PatientGender.Female;
         }
         if(listPosition2.SelectedIndex==0){
             pat2.Position=PatientPosition.Single;
         }
         else{
             pat2.Position=PatientPosition.Married;
         }
         pat2.Birthdate=PIn.Date(textBirthdate2.Text);
         pat2.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
         pat2.PatStatus=PatientStatus.Patient;
         pat2.PriProv=ProviderC.ListShort[comboPriProv2.SelectedIndex].ProvNum;
         if(comboSecProv2.SelectedIndex>0){
             pat2.SecProv=ProviderC.ListShort[comboSecProv2.SelectedIndex-1].ProvNum;
         }
         pat2.HmPhone=textHmPhone.Text;
         pat2.Address=textAddress.Text;
         pat2.Address2=textAddress2.Text;
         pat2.City=textCity.Text;
         pat2.State=textState.Text;
         pat2.Zip=textZip.Text;
         pat2.AddrNote=textAddrNotes.Text;
         pat2.ClinicNum=Security.CurUser.ClinicNum;
         pat2.Guarantor=guar.Guarantor;
         Patients.Insert(pat2,false);
         if(textReferral.Text!=""){
             //selectedReferral will already have been set in the guarantor loop
             refAttach=new RefAttach();
             refAttach.IsFrom=true;
             refAttach.RefDate=DateTime.Today;
             refAttach.ReferralNum=selectedReferral.ReferralNum;
             refAttach.PatNum=pat2.PatNum;
             RefAttaches.Insert(refAttach);
         }
     }
     //Patient #3-----------------------------------------------------------------------------------------------------
     Patient pat3=null;
     if(textFName3.Text!="" && textLName3.Text!=""){
         pat3=new Patient();
         pat3.LName=textLName3.Text;
         pat3.FName=textFName3.Text;
         if(listGender3.SelectedIndex==0){
             pat3.Gender=PatientGender.Male;
         }
         else{
             pat3.Gender=PatientGender.Female;
         }
         pat3.Position=PatientPosition.Child;
         pat3.Birthdate=PIn.Date(textBirthdate3.Text);
         pat3.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
         pat3.PatStatus=PatientStatus.Patient;
         pat3.PriProv=ProviderC.ListShort[comboPriProv3.SelectedIndex].ProvNum;
         if(comboSecProv3.SelectedIndex>0){
             pat3.SecProv=ProviderC.ListShort[comboSecProv3.SelectedIndex-1].ProvNum;
         }
         pat3.HmPhone=textHmPhone.Text;
         pat3.Address=textAddress.Text;
         pat3.Address2=textAddress2.Text;
         pat3.City=textCity.Text;
         pat3.State=textState.Text;
         pat3.Zip=textZip.Text;
         pat3.AddrNote=textAddrNotes.Text;
         pat3.ClinicNum=Security.CurUser.ClinicNum;
         pat3.Guarantor=guar.Guarantor;
         Patients.Insert(pat3,false);
         if(textReferral.Text!=""){
             //selectedReferral will already have been set in the guarantor loop
             refAttach=new RefAttach();
             refAttach.IsFrom=true;
             refAttach.RefDate=DateTime.Today;
             refAttach.ReferralNum=selectedReferral.ReferralNum;
             refAttach.PatNum=pat3.PatNum;
             RefAttaches.Insert(refAttach);
         }
     }
     //Patient #4-----------------------------------------------------------------------------------------------------
     Patient pat4=null;
     if(textFName4.Text!="" && textLName4.Text!=""){
         pat4=new Patient();
         pat4.LName=textLName4.Text;
         pat4.FName=textFName4.Text;
         if(listGender4.SelectedIndex==0){
             pat4.Gender=PatientGender.Male;
         }
         else{
             pat4.Gender=PatientGender.Female;
         }
         pat4.Position=PatientPosition.Child;
         pat4.Birthdate=PIn.Date(textBirthdate4.Text);
         pat4.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
         pat4.PatStatus=PatientStatus.Patient;
         pat4.PriProv=ProviderC.ListShort[comboPriProv4.SelectedIndex].ProvNum;
         if(comboSecProv4.SelectedIndex>0){
             pat4.SecProv=ProviderC.ListShort[comboSecProv4.SelectedIndex-1].ProvNum;
         }
         pat4.HmPhone=textHmPhone.Text;
         pat4.Address=textAddress.Text;
         pat4.Address2=textAddress2.Text;
         pat4.City=textCity.Text;
         pat4.State=textState.Text;
         pat4.Zip=textZip.Text;
         pat4.AddrNote=textAddrNotes.Text;
         pat4.ClinicNum=Security.CurUser.ClinicNum;
         pat4.Guarantor=guar.Guarantor;
         Patients.Insert(pat4,false);
         if(textReferral.Text!=""){
             //selectedReferral will already have been set in the guarantor loop
             refAttach=new RefAttach();
             refAttach.IsFrom=true;
             refAttach.RefDate=DateTime.Today;
             refAttach.ReferralNum=selectedReferral.ReferralNum;
             refAttach.PatNum=pat4.PatNum;
             RefAttaches.Insert(refAttach);
         }
     }
     //Patient #5-----------------------------------------------------------------------------------------------------
     Patient pat5=null;
     if(textFName5.Text!="" && textLName5.Text!=""){
         pat5=new Patient();
         pat5.LName=textLName5.Text;
         pat5.FName=textFName5.Text;
         if(listGender5.SelectedIndex==0){
             pat5.Gender=PatientGender.Male;
         }
         else{
             pat5.Gender=PatientGender.Female;
         }
         pat5.Position=PatientPosition.Child;
         pat5.Birthdate=PIn.Date(textBirthdate5.Text);
         pat5.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
         pat5.PatStatus=PatientStatus.Patient;
         pat5.PriProv=ProviderC.ListShort[comboPriProv5.SelectedIndex].ProvNum;
         if(comboSecProv5.SelectedIndex>0){
             pat5.SecProv=ProviderC.ListShort[comboSecProv5.SelectedIndex-1].ProvNum;
         }
         pat5.HmPhone=textHmPhone.Text;
         pat5.Address=textAddress.Text;
         pat5.Address2=textAddress2.Text;
         pat5.City=textCity.Text;
         pat5.State=textState.Text;
         pat5.Zip=textZip.Text;
         pat5.AddrNote=textAddrNotes.Text;
         pat5.ClinicNum=Security.CurUser.ClinicNum;
         pat5.Guarantor=guar.Guarantor;
         Patients.Insert(pat5,false);
         if(textReferral.Text!=""){
             //selectedReferral will already have been set in the guarantor loop
             refAttach=new RefAttach();
             refAttach.IsFrom=true;
             refAttach.RefDate=DateTime.Today;
             refAttach.ReferralNum=selectedReferral.ReferralNum;
             refAttach.PatNum=pat5.PatNum;
             RefAttaches.Insert(refAttach);
         }
     }
     //Insurance------------------------------------------------------------------------------------------------------------
     InsSub sub1=null;
     InsSub sub2=null;
     if(selectedPlan1!=null){
         //validate the ins fields.  If they don't match perfectly, then set it to null
         if(Employers.GetName(selectedPlan1.EmployerNum)!=textEmployer1.Text
             || Carriers.GetName(selectedPlan1.CarrierNum)!=textCarrier1.Text
             || selectedPlan1.GroupName!=textGroupName1.Text
             || selectedPlan1.GroupNum!=textGroupNum1.Text)
         {
             selectedPlan1=null;
         }
     }
     if(selectedPlan2!=null){
         if(Employers.GetName(selectedPlan2.EmployerNum)!=textEmployer2.Text
             || Carriers.GetName(selectedPlan2.CarrierNum)!=textCarrier2.Text
             || selectedPlan2.GroupName!=textGroupName2.Text
             || selectedPlan2.GroupNum!=textGroupNum2.Text)
         {
             selectedPlan2=null;
         }
     }
     if(selectedCarrier1!=null){
         //validate the carrier fields.  If they don't match perfectly, then set it to null
         if(selectedCarrier1.CarrierName!=textCarrier1.Text
             || selectedCarrier1.Phone!=textPhone1.Text)
         {
             selectedCarrier1=null;
         }
     }
     if(selectedCarrier2!=null){
         if(selectedCarrier2.CarrierName!=textCarrier2.Text
             || selectedCarrier2.Phone!=textPhone2.Text)
         {
             selectedCarrier2=null;
         }
     }
     if(insComplete1){
         if(selectedCarrier1==null){
             //get a carrier, possibly creating a new one if needed.
             selectedCarrier1=Carriers.GetByNameAndPhone(textCarrier1.Text,textPhone1.Text);
         }
         long empNum1=Employers.GetEmployerNum(textEmployer1.Text);
         if(selectedPlan1==null){
             //don't try to get a copy of an existing plan. Instead, start from scratch.
             selectedPlan1=new InsPlan();
             selectedPlan1.EmployerNum=empNum1;
             selectedPlan1.CarrierNum=selectedCarrier1.CarrierNum;
             selectedPlan1.GroupName=textGroupName1.Text;
             selectedPlan1.GroupNum=textGroupNum1.Text;
             selectedPlan1.PlanType="";
             InsPlans.Insert(selectedPlan1);
             Benefit ben;
             for(int i=0;i<CovCatC.ListShort.Count;i++){
                 if(CovCatC.ListShort[i].DefaultPercent==-1){
                     continue;
                 }
                 ben=new Benefit();
                 ben.BenefitType=InsBenefitType.CoInsurance;
                 ben.CovCatNum=CovCatC.ListShort[i].CovCatNum;
                 ben.PlanNum=selectedPlan1.PlanNum;
                 ben.Percent=CovCatC.ListShort[i].DefaultPercent;
                 ben.TimePeriod=BenefitTimePeriod.CalendarYear;
                 ben.CodeNum=0;
                 Benefits.Insert(ben);
             }
         }
         sub1=new InsSub();
         sub1.PlanNum=selectedPlan1.PlanNum;
         sub1.AssignBen=true;
         sub1.ReleaseInfo=true;
         sub1.DateEffective=DateTime.MinValue;
         sub1.DateTerm=DateTime.MinValue;
         if(comboSubscriber1.SelectedIndex==1){
             sub1.Subscriber=guar.PatNum;
         }
         if(comboSubscriber1.SelectedIndex==2){
             sub1.Subscriber=pat2.PatNum;
         }
         if(comboSubscriber1.SelectedIndex==3){
             sub1.Subscriber=pat3.PatNum;
         }
         if(comboSubscriber1.SelectedIndex==4){
             sub1.Subscriber=pat4.PatNum;
         }
         if(comboSubscriber1.SelectedIndex==5){
             sub1.Subscriber=pat5.PatNum;
         }
         sub1.SubscriberID=textSubscriberID1.Text;
         InsSubs.Insert(sub1);
     }
     if(insComplete2){
         if(selectedCarrier2==null){
             selectedCarrier2=Carriers.GetByNameAndPhone(textCarrier2.Text,textPhone2.Text);
         }
         long empNum2=Employers.GetEmployerNum(textEmployer2.Text);
         if(selectedPlan2==null){
             //don't try to get a copy of an existing plan. Instead, start from scratch.
             selectedPlan2=new InsPlan();
             selectedPlan2.EmployerNum=empNum2;
             selectedPlan2.CarrierNum=selectedCarrier2.CarrierNum;
             selectedPlan2.GroupName=textGroupName2.Text;
             selectedPlan2.GroupNum=textGroupNum2.Text;
             selectedPlan2.PlanType="";
             InsPlans.Insert(selectedPlan2);
             Benefit ben;
             for(int i=0;i<CovCatC.ListShort.Count;i++){
                 if(CovCatC.ListShort[i].DefaultPercent==-1){
                     continue;
                 }
                 ben=new Benefit();
                 ben.BenefitType=InsBenefitType.CoInsurance;
                 ben.CovCatNum=CovCatC.ListShort[i].CovCatNum;
                 ben.PlanNum=selectedPlan2.PlanNum;
                 ben.Percent=CovCatC.ListShort[i].DefaultPercent;
                 ben.TimePeriod=BenefitTimePeriod.CalendarYear;
                 ben.CodeNum=0;
                 Benefits.Insert(ben);
             }
         }
         sub2=new InsSub();
         sub2.PlanNum=selectedPlan2.PlanNum;
         sub2.AssignBen=true;
         sub2.ReleaseInfo=true;
         sub2.DateEffective=DateTime.MinValue;
         sub2.DateTerm=DateTime.MinValue;
         if(comboSubscriber2.SelectedIndex==1){
             sub2.Subscriber=guar.PatNum;
         }
         if(comboSubscriber2.SelectedIndex==2){
             sub2.Subscriber=pat2.PatNum;
         }
         if(comboSubscriber2.SelectedIndex==3){
             sub2.Subscriber=pat3.PatNum;
         }
         if(comboSubscriber2.SelectedIndex==4){
             sub2.Subscriber=pat4.PatNum;
         }
         if(comboSubscriber2.SelectedIndex==5){
             sub2.Subscriber=pat5.PatNum;
         }
         sub2.SubscriberID=textSubscriberID2.Text;
         InsSubs.Insert(sub2);
     }
     PatPlan patplan;
     //attach insurance to subscriber--------------------------------------------------------------------------------
     if(checkInsOne1.Checked){
         patplan=new PatPlan();
         //the only situation where ordinal would be 2 is if ins2 has this patient as the subscriber.
         if(comboSubscriber2.SelectedIndex==1){
             patplan.Ordinal=2;
         }
         else{
             patplan.Ordinal=1;
         }
         patplan.PatNum=guar.PatNum;
         patplan.InsSubNum=sub1.InsSubNum;
         if(comboSubscriber1.SelectedIndex==1){
             patplan.Relationship=Relat.Self;
         }
         else if(comboSubscriber1.SelectedIndex==2){
             patplan.Relationship=Relat.Spouse;
         }
         else{
             //the subscriber would never be a child
         }
         PatPlans.Insert(patplan);
     }
     if(checkInsTwo1.Checked){
         patplan=new PatPlan();
         //the only situations where ordinal would be 1 is if ins1 is not checked or if ins2 has this patient as subscriber.
         if(comboSubscriber2.SelectedIndex==1){
             patplan.Ordinal=1;
         }
         else if(!checkInsOne1.Checked){
             patplan.Ordinal=1;
         }
         else{
             patplan.Ordinal=2;
         }
         patplan.PatNum=guar.PatNum;
         patplan.InsSubNum=sub2.InsSubNum;
         if(comboSubscriber2.SelectedIndex==1){
             patplan.Relationship=Relat.Self;
         }
         else if(comboSubscriber2.SelectedIndex==2){
             patplan.Relationship=Relat.Spouse;
         }
         else{
             //the subscriber would never be a child
         }
         PatPlans.Insert(patplan);
     }
     //attach insurance to patient 2, the other parent----------------------------------------------------------------------
     if(checkInsOne2.Checked){
         patplan=new PatPlan();
         //the only situation where ordinal would be 2 is if ins2 has this patient as the subscriber.
         if(comboSubscriber2.SelectedIndex==2){
             patplan.Ordinal=2;
         }
         else{
             patplan.Ordinal=1;
         }
         patplan.PatNum=pat2.PatNum;
         patplan.InsSubNum=sub1.InsSubNum;
         if(comboSubscriber1.SelectedIndex==2){
             patplan.Relationship=Relat.Self;
         }
         else if(comboSubscriber1.SelectedIndex==1){
             patplan.Relationship=Relat.Spouse;
         }
         else{
             //the subscriber would never be a child
         }
         PatPlans.Insert(patplan);
     }
     if(checkInsTwo2.Checked){
         patplan=new PatPlan();
         //the only situations where ordinal would be 1 is if ins1 is not checked or if ins2 has this patient as subscriber.
         if(comboSubscriber2.SelectedIndex==2){
             patplan.Ordinal=1;
         }
         else if(!checkInsOne2.Checked){
             patplan.Ordinal=1;
         }
         else{
             patplan.Ordinal=2;
         }
         patplan.PatNum=pat2.PatNum;
         patplan.InsSubNum=sub2.InsSubNum;
         if(comboSubscriber2.SelectedIndex==2){
             patplan.Relationship=Relat.Self;
         }
         else if(comboSubscriber2.SelectedIndex==1){
             patplan.Relationship=Relat.Spouse;
         }
         else{
             //the subscriber would never be a child
         }
         PatPlans.Insert(patplan);
     }
     //attach insurance to patient 3, a child----------------------------------------------------------------------
     if(checkInsOne3.Checked){
         patplan=new PatPlan();
         patplan.Ordinal=1;
         patplan.PatNum=pat3.PatNum;
         patplan.InsSubNum=sub1.InsSubNum;
         patplan.Relationship=Relat.Child;
         PatPlans.Insert(patplan);
     }
     if(checkInsTwo3.Checked){
         patplan=new PatPlan();
         //the only situation where ordinal would be 1 is if ins1 is not checked.
         if(!checkInsOne3.Checked){
             patplan.Ordinal=1;
         }
         else{
             patplan.Ordinal=2;
         }
         patplan.PatNum=pat3.PatNum;
         patplan.InsSubNum=sub2.InsSubNum;
         patplan.Relationship=Relat.Child;
         PatPlans.Insert(patplan);
     }
     //attach insurance to patient 4, a child----------------------------------------------------------------------
     if(checkInsOne4.Checked){
         patplan=new PatPlan();
         patplan.Ordinal=1;
         patplan.PatNum=pat4.PatNum;
         patplan.InsSubNum=sub1.InsSubNum;
         patplan.Relationship=Relat.Child;
         PatPlans.Insert(patplan);
     }
     if(checkInsTwo4.Checked){
         patplan=new PatPlan();
         //the only situation where ordinal would be 1 is if ins1 is not checked.
         if(!checkInsOne4.Checked){
             patplan.Ordinal=1;
         }
         else{
             patplan.Ordinal=2;
         }
         patplan.PatNum=pat4.PatNum;
         patplan.InsSubNum=sub2.InsSubNum;
         patplan.Relationship=Relat.Child;
         PatPlans.Insert(patplan);
     }
     //attach insurance to patient 5, a child----------------------------------------------------------------------
     if(checkInsOne5.Checked){
         patplan=new PatPlan();
         patplan.Ordinal=1;
         patplan.PatNum=pat5.PatNum;
         patplan.InsSubNum=sub1.InsSubNum;
         patplan.Relationship=Relat.Child;
         PatPlans.Insert(patplan);
     }
     if(checkInsTwo5.Checked){
         patplan=new PatPlan();
         //the only situation where ordinal would be 1 is if ins1 is not checked.
         if(!checkInsOne5.Checked){
             patplan.Ordinal=1;
         }
         else{
             patplan.Ordinal=2;
         }
         patplan.PatNum=pat5.PatNum;
         patplan.InsSubNum=sub2.InsSubNum;
         patplan.Relationship=Relat.Child;
         PatPlans.Insert(patplan);
     }
     SelectedPatNum=guar.PatNum;
     MessageBox.Show("Done");
     DialogResult=DialogResult.OK;
 }
Exemple #26
0
        ///<summary>Updates one RefAttach in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
        internal static void Update(RefAttach refAttach, RefAttach oldRefAttach)
        {
            string command = "";

            if (refAttach.ReferralNum != oldRefAttach.ReferralNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ReferralNum = " + POut.Long(refAttach.ReferralNum) + "";
            }
            if (refAttach.PatNum != oldRefAttach.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(refAttach.PatNum) + "";
            }
            if (refAttach.ItemOrder != oldRefAttach.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(refAttach.ItemOrder) + "";
            }
            if (refAttach.RefDate != oldRefAttach.RefDate)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RefDate = " + POut.Date(refAttach.RefDate) + "";
            }
            if (refAttach.IsFrom != oldRefAttach.IsFrom)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsFrom = " + POut.Bool(refAttach.IsFrom) + "";
            }
            if (refAttach.RefToStatus != oldRefAttach.RefToStatus)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RefToStatus = " + POut.Int((int)refAttach.RefToStatus) + "";
            }
            if (refAttach.Note != oldRefAttach.Note)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Note = '" + POut.String(refAttach.Note) + "'";
            }
            if (refAttach.IsTransitionOfCare != oldRefAttach.IsTransitionOfCare)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsTransitionOfCare = " + POut.Bool(refAttach.IsTransitionOfCare) + "";
            }
            if (refAttach.ProcNum != oldRefAttach.ProcNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProcNum = " + POut.Long(refAttach.ProcNum) + "";
            }
            if (refAttach.DateProcComplete != oldRefAttach.DateProcComplete)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateProcComplete = " + POut.Date(refAttach.DateProcComplete) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE refattach SET " + command
                      + " WHERE RefAttachNum = " + POut.Long(refAttach.RefAttachNum);
            Db.NonQ(command);
        }