Пример #1
0
		public static Patient CreatePatient(string suffix){
			Patient pat=new Patient();
			pat.IsNew=true;
			pat.LName="LName"+suffix;
			pat.FName="FName"+suffix;
			pat.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
			pat.PriProv=PrefC.GetLong(PrefName.PracticeDefaultProv);//This causes standard fee sched to be 53.
			Patients.Insert(pat,false);
			Patient oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			return pat;
		}
Пример #2
0
        ///<summary>Will create folder if needed.  Will validate that folder exists.  It will alter the pat.ImageFolder if needed, but still make sure to pass in a very new Patient because we do not want an invalid patFolder.</summary>
        public static string GetPatientFolder(Patient pat, string AtoZpath)
        {
            string retVal = "";

            if (pat.ImageFolder == "")           //creates new folder for patient if none present
            {
                string name   = pat.LName + pat.FName;
                string folder = "";
                for (int i = 0; i < name.Length; i++)
                {
                    if (Char.IsLetter(name, i))
                    {
                        folder += name.Substring(i, 1);
                    }
                }
                folder += pat.PatNum.ToString();              //ensures unique name
                try {
                    Patient PatOld = pat.Copy();
                    pat.ImageFolder = folder;
                    retVal          = ODFileUtils.CombinePaths(AtoZpath,
                                                               pat.ImageFolder.Substring(0, 1).ToUpper(),
                                                               pat.ImageFolder);
                    Directory.CreateDirectory(retVal);
                    Patients.Update(pat, PatOld);
                }
                catch {
                    throw new Exception(Lans.g("ContrDocs", "Error.  Could not create folder for patient. "));
                }
            }
            else              //patient folder already created once
            {
                retVal = ODFileUtils.CombinePaths(AtoZpath,
                                                  pat.ImageFolder.Substring(0, 1).ToUpper(),
                                                  pat.ImageFolder);
            }
            if (!Directory.Exists(retVal))             //this makes it more resiliant and allows copies
            //of the opendentaldata folder to be used in read-only situations.
            {
                try {
                    Directory.CreateDirectory(retVal);
                }
                catch {
                    throw new Exception(Lans.g("ContrDocs", "Error.  Could not create folder for patient: ") + retVal);
                }
            }
            return(retVal);
        }
Пример #3
0
		///<summary>Will create folder if needed.  Will validate that folder exists.  It will alter the pat.ImageFolder if needed, but still make sure to pass in a very new Patient because we do not want an invalid patFolder.</summary>
		public static string GetPatientFolder(Patient pat,string AtoZpath) {
			string retVal="";
			if(!PrefC.GetBool(PrefName.AtoZfolderUsed)) {
				return retVal;
			}
			if(pat.ImageFolder=="") {//creates new folder for patient if none present
				string name=pat.LName+pat.FName;
				string folder="";
				for(int i=0;i<name.Length;i++) {
					if(Char.IsLetter(name,i)) {
						folder+=name.Substring(i,1);
					}
				}
				folder+=pat.PatNum.ToString();//ensures unique name
				try {
					Patient PatOld=pat.Copy();
					pat.ImageFolder=folder;
					retVal=ODFileUtils.CombinePaths(AtoZpath,
																		pat.ImageFolder.Substring(0,1).ToUpper(),
																		pat.ImageFolder);
					Directory.CreateDirectory(retVal);
					Patients.Update(pat,PatOld);
				}
				catch {
					throw new Exception(Lans.g("ContrDocs","Error.  Could not create folder for patient. "));
				}
			}
			else {//patient folder already created once
				retVal = ODFileUtils.CombinePaths(AtoZpath,
																	pat.ImageFolder.Substring(0,1).ToUpper(),
																	pat.ImageFolder);
			}
			if(!Directory.Exists(retVal)) {//this makes it more resiliant and allows copies
				//of the opendentaldata folder to be used in read-only situations.
				try {
					Directory.CreateDirectory(retVal);
				}
				catch {
					throw new Exception(Lans.g("ContrDocs","Error.  Could not create folder for patient: ")+retVal);
				}
			}
			return retVal;
		}
Пример #4
0
		/*
		///<summary>Only used in GetSearchResults.  All times between start and stop get set to true in provBarSched.</summary>
		private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){
			int startI=GetProvBarIndex(timeStart);
			int stopI=GetProvBarIndex(timeStop);
			for(int i=startI;i<=stopI;i++){
				provBarSched[i]=true;
			}
		}

		private static int GetProvBarIndex(TimeSpan time) {
			return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr
				+(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement))
				*(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr)
				/ApptDrawing.LineH;//rounds down
		}*/

		///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule.  This method creates the appointment and attaches all appropriate procedures.  It's up to the calling class to then place the appointment on the pinboard.  If the appointment doesn't get scheduled, it's important to delete it.  If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary>
		public static Appointment CreateRecallApt(Patient patCur,List<Procedure> procList,List<InsPlan> planList,long recallNum,List<InsSub> subList){
			List<Recall> recallList=Recalls.GetList(patCur.PatNum);
			Recall recallCur=null;
			if(recallNum>0) {
				recallCur=Recalls.GetRecall(recallNum);
			}
			else{
				for(int i=0;i<recallList.Count;i++){
					if(recallList[i].RecallTypeNum==RecallTypes.PerioType || recallList[i].RecallTypeNum==RecallTypes.ProphyType){
						if(!recallList[i].IsDisabled){
							recallCur=recallList[i];
						}
						break;
					}
				}
			}
			if(recallCur==null){// || recallCur.DateDue.Year<1880){
				throw new ApplicationException(Lan.g("AppointmentL","No special type recall is due."));//Typically never happens because everyone has a recall.  However, it can happen when patients have custom recalls due
			}
			if(recallCur.DateScheduled.Date>DateTime.Today) {
				throw new ApplicationException(Lan.g("AppointmentL","Recall has already been scheduled for ")+recallCur.DateScheduled.ToShortDateString());
			}
			Appointment aptCur=new Appointment();
			List<string> procs=RecallTypes.GetProcs(recallCur.RecallTypeNum);
			List<Procedure> listProcs=Appointments.FillAppointmentForRecall(aptCur,recallCur,recallList,patCur,procs,planList,subList);
			for(int i=0;i<listProcs.Count;i++) {
				if(Programs.UsingOrion) {
					FormProcEdit FormP=new FormProcEdit(listProcs[i],patCur.Copy(),Patients.GetFamily(patCur.PatNum));
					FormP.IsNew=true;
					FormP.ShowDialog();
					if(FormP.DialogResult==DialogResult.Cancel) {
						//any created claimprocs are automatically deleted from within procEdit window.
						try {
							Procedures.Delete(listProcs[i].ProcNum);//also deletes the claimprocs
						}
						catch(Exception ex) {
							MessageBox.Show(ex.Message);
						}
					}
					else {
						//Do not synch. Recalls based on ScheduleByDate reports in Orion mode.
						//Recalls.Synch(PatCur.PatNum);
					}
				}
			}
			return aptCur;
		}
Пример #5
0
		///<summary>The supplied payment plan should already have been saved in the database.</summary>
		public FormPayPlan(Patient patCur,PayPlan payPlanCur){
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			PatCur=patCur.Copy();
			PayPlanCur=payPlanCur.Copy();
			FamCur=Patients.GetFamily(PatCur.PatNum);
			SubList=InsSubs.RefreshForFam(FamCur);
			InsPlanList=InsPlans.RefreshForSubList(SubList);
			FormPayPlanOpts=new FormPaymentPlanOptions(PayPlanCur.PaySchedule);
			_formPayPlanRecalculate=new FormPayPlanRecalculate();
			Lan.F(this);
		}
Пример #6
0
		/// <summary>For testing only</summary>
		private static void CreatePatients(int PatientCount) {
			for(int i=0;i<PatientCount;i++) {
				Patient newPat=new Patient();
				newPat.LName="Mathew"+i;
				newPat.FName="Dennis"+i;
				newPat.Address="Address Line 1.Address Line 1___"+i;
				newPat.Address2="Address Line 2. Address Line 2__"+i;
				newPat.AddrNote="Lives off in far off Siberia Lives off in far off Siberia"+i;
				newPat.AdmitDate=new DateTime(1985,3,3).AddDays(i);
				newPat.ApptModNote="Flies from Siberia on specially chartered flight piloted by goblins:)"+i;
				newPat.AskToArriveEarly=1555;
				newPat.BillingType=3;
				newPat.ChartNumber="111111"+i;
				newPat.City="NL";
				newPat.ClinicNum=i;
				newPat.CreditType="A";
				newPat.DateFirstVisit=new DateTime(1985,3,3).AddDays(i);
				newPat.Email="*****@*****.**";
				newPat.HmPhone="416-222-5678";
				newPat.WkPhone="416-222-5678";
				newPat.Zip="M3L 2L9";
				newPat.WirelessPhone="416-222-5678";
				newPat.Birthdate=new DateTime(1970,3,3).AddDays(i);
				Patients.Insert(newPat,false);
				//set Guarantor field the same as PatNum
				Patient patOld=newPat.Copy();
				newPat.Guarantor=newPat.PatNum;
				Patients.Update(newPat,patOld);
			}
		}
Пример #7
0
 ///<summary></summary>
 public FormPatientEdit(Patient patCur,Family famCur)
 {
     InitializeComponent();// Required for Windows Form Designer support
     PatCur=patCur;
     FamCur=famCur;
     PatOld=patCur.Copy();
     listEmps=new ListBox();
     listEmps.Location=new Point(textEmployer.Left,textEmployer.Bottom);
     listEmps.Size=new Size(textEmployer.Width,100);
     listEmps.Visible=false;
     listEmps.Click += new System.EventHandler(listEmps_Click);
     listEmps.DoubleClick += new System.EventHandler(listEmps_DoubleClick);
     listEmps.MouseEnter += new System.EventHandler(listEmps_MouseEnter);
     listEmps.MouseLeave += new System.EventHandler(listEmps_MouseLeave);
     Controls.Add(listEmps);
     listEmps.BringToFront();
     listCounties=new ListBox();
     listCounties.Location=new Point(groupPH.Left+textCounty.Left
         ,groupPH.Top+textCounty.Bottom);
     listCounties.Size=new Size(textCounty.Width,100);
     listCounties.Visible=false;
     listCounties.Click += new System.EventHandler(listCounties_Click);
     //listCounties.DoubleClick += new System.EventHandler(listCars_DoubleClick);
     listCounties.MouseEnter += new System.EventHandler(listCounties_MouseEnter);
     listCounties.MouseLeave += new System.EventHandler(listCounties_MouseLeave);
     Controls.Add(listCounties);
     listCounties.BringToFront();
     listSites=new ListBox();
     listSites.Location=new Point(groupPH.Left+textSite.Left,groupPH.Top+textSite.Bottom);
     listSites.Size=new Size(textSite.Width,100);
     listSites.Visible=false;
     listSites.Click += new System.EventHandler(listSites_Click);
     listSites.MouseEnter += new System.EventHandler(listSites_MouseEnter);
     listSites.MouseLeave += new System.EventHandler(listSites_MouseLeave);
     Controls.Add(listSites);
     listSites.BringToFront();
     Lan.F(this);
     if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
         labelSSN.Text="SIN";
         labelZip.Text="Postal Code";
         labelST.Text="Province";
         butEditZip.Text="Edit Postal Code";
         labelCanadianEligibilityCode.Visible=true;
         comboCanadianEligibilityCode.Visible=true;
         radioStudentN.Visible=false;
         radioStudentP.Visible=false;
         radioStudentF.Visible=false;
     }
     if(CultureInfo.CurrentCulture.Name.EndsWith("GB")){//en-GB
         //labelSSN.Text="?";
         labelZip.Text="Postcode";
         labelST.Text="";//no such thing as state in GB
         butEditZip.Text="Edit Postcode";
     }
 }
Пример #8
0
		///<summary>Guaranteed to always return a valid foldername unless major error or user chooses to exit.  This also saves the TrophyFolder value to this patient in the db.</summary>
		private static string AutomaticallyGetTrophyFolder(Patient pat,string storagePath) {
			string retVal="";
			//try to find the correct trophy folder
			string rvgPortion=pat.LName.Substring(0,1)+".rvg";
			string alphaPath=ODFileUtils.CombinePaths(storagePath,rvgPortion);
			if(!Directory.Exists(alphaPath)) {
				throw new ApplicationException("Could not find expected path: "+alphaPath+".  The enhanced Trophy bridge assumes that folders already exist with that naming convention.");
			}
			DirectoryInfo dirInfo=new DirectoryInfo(alphaPath);
			DirectoryInfo[] dirArray=dirInfo.GetDirectories();
			List<TrophyFolder> listMatchesNot=new List<TrophyFolder>();//list of all patients found, all with same first letter of last name.
			List<TrophyFolder> listMatchesName=new List<TrophyFolder>();//list of all perfect matches for name but not birthdate.
			TrophyFolder folder;
			string maxFolderName="";
			string datafilePath;
			string[] datafileLines;
			string date;
			//loop through each folder.
			for(int i=0;i<dirArray.Length;i++) {
				if(String.Compare(dirArray[i].Name,maxFolderName) > 0) {//eg, if G0000035 > G0000024
					maxFolderName=dirArray[i].Name;
				}
				datafilePath=ODFileUtils.CombinePaths(dirArray[i].FullName,"FILEDATA.txt");
				if(!File.Exists(datafilePath)){
					continue;//fail silently.
				}
				//if this folder is already in use by some other patient, then skip
				if(Patients.IsTrophyFolderInUse(dirArray[i].Name)) {
					continue;
				}
				folder=new TrophyFolder();
				folder.FolderName=dirArray[i].Name;
				datafileLines=File.ReadAllLines(datafilePath);
				if(datafileLines.Length<2) {
					continue;
				}
				folder.FName=GetValueFromLines("PRENOM",datafileLines);
				folder.LName=GetValueFromLines("NOM",datafileLines);
				date=GetValueFromLines("DATE",datafileLines);
				try{
					folder.BirthDate=DateTime.ParseExact(date,"yyyyMMdd",CultureInfo.CurrentCulture.DateTimeFormat);
				}
				catch{}
				if(pat.LName.ToUpper()==folder.LName.ToUpper() && pat.FName.ToUpper()==folder.FName.ToUpper()) {
					if(pat.Birthdate==folder.BirthDate) {
						//We found a perfect match here, so do not display any dialog to user.
						retVal=rvgPortion+@"\"+dirArray[i].Name;
					}
					else{//name is perfect match, but not birthdate.  Maybe birthdate was not entered in one system or the other.
						listMatchesName.Add(folder);
					}
				}
				listMatchesNot.Add(folder);
			}
			if(retVal=="") {//perfect match not found
				if(listMatchesName.Count==1) {//exactly one name matched even though birthdays did not
					retVal=rvgPortion+@"\"+listMatchesName[0].FolderName;
				}
				else{//no or multiple matches
					FormTrophyNamePick formPick=new FormTrophyNamePick();
					formPick.ListMatches=listMatchesNot;
					formPick.ShowDialog();
					if(formPick.DialogResult!=DialogResult.OK) {
						return "";//triggers total exit
					}
					if(formPick.PickedName=="") {//Need to generate new folder name
						int maxInt=0;
						if(maxFolderName!="") {
							maxInt=PIn.Int(maxFolderName.Substring(1));//It will crash here if can't parse the int.
						}
						maxInt++;
						string paddedInt=maxInt.ToString().PadLeft(7,'0');
						retVal=rvgPortion+@"\"+pat.LName.Substring(0,1).ToUpper()+paddedInt;
					}
					else {
						retVal=rvgPortion+@"\"+formPick.PickedName;
					}
				}
			}
			Patient patOld=pat.Copy();
			pat.TrophyFolder=retVal;
			Patients.Update(pat,patOld);
			return retVal;
		}
Пример #9
0
 ///<summary>Guaranteed to always return a valid foldername unless major error or user chooses to exit.  This also saves the TrophyFolder value to this patient in the db and creates the new folder.</summary>
 private static string AutomaticallyGetTrophyFolderNumbered(Patient pat,string storagePath)
 {
     string retVal="";
     string folderDesired=pat.PatNum.ToString();//.PadLeft(6,'0');
     DirectoryInfo dirInfo=new DirectoryInfo(storagePath);
     DirectoryInfo[] dirArray=dirInfo.GetDirectories(folderDesired,SearchOption.AllDirectories);
     List<DirectoryInfo> dirList=new List<DirectoryInfo>();
     for(int i=0;i<dirArray.Length;i++) {
         if(dirArray[i].Parent.FullName.TrimEnd('\\')==storagePath.TrimEnd('\\')){//filter out any that are directly in the AtoZ folder
             continue;
         }
         dirList.Add(dirArray[i]);
     }
     if(dirList.Count==0) {//Create a folder using the numbering convention
         retVal=ODFileUtils.CombinePaths(folderDesired.PadLeft(6,'0').Substring(4,2),folderDesired);
         string fullPath=ODFileUtils.CombinePaths(storagePath,retVal);
         if(!Directory.Exists(fullPath)) {
             try {
                 Directory.CreateDirectory(fullPath);
             }
             catch {
                 throw new Exception("Error.  Could not create folder: "+fullPath);
             }
         }
     }
     else {//use the found folder
         if(storagePath != dirList[0].FullName.Substring(0,storagePath.Length)) {
             throw new ApplicationException("storagePath variable ("+storagePath+") does not match dirList value ("+dirList[0].FullName.Substring(0,storagePath.Length)+")");
         }
         retVal=dirList[0].FullName.Substring(storagePath.Length);
         retVal=retVal.TrimStart('\\');
     }
     Patient PatOld=pat.Copy();
     pat.TrophyFolder=retVal;
     Patients.Update(pat,PatOld);
     return retVal;
 }
Пример #10
0
		///<summary>Remember, this button is not even visible if SelectionModeOnly.</summary>
		private void butAddPt_Click(object sender, System.EventArgs e){
			#if(TRIALONLY)
				MsgBox.Show(this,"Trial version.  Maximum 30 patients");
				if(Patients.GetNumberPatients()>30){
					MsgBox.Show(this,"Maximum reached");
					return;
				}
			#endif
			if(textLName.Text=="" && textFName.Text=="" && textChartNumber.Text==""){
				MessageBox.Show(Lan.g(this,"Not allowed to add a new patient until you have done a search to see if that patient already exists. Hint: just type a few letters into the Last Name box above.")); 
				return;
			}
			Patient PatCur=new Patient();
			if(textLName.Text.Length>1){//eg Sp
				PatCur.LName=textLName.Text.Substring(0,1).ToUpper()+textLName.Text.Substring(1);
			}
			if(textFName.Text.Length>1){
				PatCur.FName=textFName.Text.Substring(0,1).ToUpper()+textFName.Text.Substring(1);
			}
			PatCur.PatStatus=PatientStatus.Patient;
			PatCur.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
			PatCur.PriProv=PrefC.GetLong(PrefName.PracticeDefaultProv);
			if(PrefC.GetBool(PrefName.ShowFeatureEhr)) {
				PatCur.Gender=PatientGender.Unknown;
			}
			PatCur.ClinicNum=Security.CurUser.ClinicNum;
			Patients.Insert(PatCur,false);
			CustReference custRef=new CustReference();
			custRef.PatNum=PatCur.PatNum;
			CustReferences.Insert(custRef);
			Patient PatOld=PatCur.Copy();
			PatCur.Guarantor=PatCur.PatNum;
			Patients.Update(PatCur,PatOld);
			Family FamCur=Patients.GetFamily(PatCur.PatNum);
			FormPatientEdit FormPE=new FormPatientEdit(PatCur,FamCur);
			FormPE.IsNew=true;
			FormPE.ShowDialog();
			if(FormPE.DialogResult==DialogResult.OK){
				NewPatientAdded=true;
				SelectedPatNum=PatCur.PatNum;
				DialogResult=DialogResult.OK;
			}
		}
Пример #11
0
		public static string SetInitialPatients() {
			Patient pat;
			Patient oldPatient;
			InsPlan plan;
			InsSub sub;
			PatPlan patplan;
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Single;
			pat.Gender=PatientGender.Female;
			pat.Birthdate=new DateTime(1960,04,12);
			pat.LName="Fête";
			pat.FName="Lisa";
			pat.MiddleI="Ç";
			pat.Address="124 - 1500 Rue";
			pat.City="Montréal";
			pat.State="QC";
			pat.Zip="H1C2D4";
			pat.Language="fr";
			pat.CanadianEligibilityCode=2;//disabled
			Patients.Insert(pat,false);
			PatNum1=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			//Extractions
			ProcTC.SetExtracted("23",new DateTime(1995,2,7),pat.PatNum);
			ProcTC.SetExtracted("26",new DateTime(1996,11,13),pat.PatNum);
			//Missing teeth
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("666666");
			plan.GroupNum="PLAN012";
			plan.DentaideCardSequence=3;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;
			sub.SubscriberID="AB123C4G";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//PATIENT 2==================================================================
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1948,3,2);
			pat.LName="Smith";
			pat.FName="John";
			pat.MiddleI="";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="P.O. Box 1500";
			pat.Address2="Little Field Estates";
			pat.City="East Westchester";
			pat.State="ON";
			pat.Zip="M7F2J9";
			pat.Language="en";
			Patients.Insert(pat,false);
			PatNum2=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			//plan1
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("666666");
			plan.GroupNum="PLAN02";
			plan.DivisionNo="1542B";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			long planNum_pat2_pri=plan.PlanNum;
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;
			sub.SubscriberID="123432145222";
			InsSubs.Insert(sub);
			long subNum_pat2_pri=sub.InsSubNum;
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//plan2
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("777777");
			plan.GroupNum="P9902";
			plan.DivisionNo="";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			//long planNum_pat2_sec=plan.PlanNum;//won't need this
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;
			sub.SubscriberID="12343B7";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=2;
			PatPlans.Insert(patplan);
			//PATIENT 3=========================================================================
			//common law spouse of pat2.  Pri and sec coverage from spouse.  
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Female;
			pat.Birthdate=new DateTime(1978,4,12);
			pat.LName="Walls";
			pat.FName="Mary";
			pat.MiddleI="A";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="P.O. Box 1500";
			pat.Address2="Little Field Estates";
			pat.City="East Westchester";
			pat.State="ON";
			pat.Zip="M7F2J9";
			pat.Language="en";
			pat.Guarantor=PatNum2;//same family as patient #1.
			Patients.Insert(pat,false);
			PatNum3=pat.PatNum;
			//primary coverage------------------------------
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=subNum_pat2_pri;
			patplan.Relationship=Relat.Spouse;//2
			patplan.PatID="01";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//secondary----------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("777777");
			plan.GroupNum="P9902";
			plan.DivisionNo="";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=PatNum2;
			sub.SubscriberID="12343C7";//had to add this as separate plan because of unique subscriber id.
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Spouse;//2
			patplan.PatID="00";
			patplan.Ordinal=2;
			PatPlans.Insert(patplan);
			//PATIENT 4=========================================================================
			//son of pat#2
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Child;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1988,11,2);
			pat.LName="Smith";
			pat.FName="John";
			pat.MiddleI="B";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="P.O. Box 1500";
			pat.Address2="Little Field Estates";
			pat.City="East Westchester";
			pat.State="ON";
			pat.Zip="M7F2J9";
			pat.Language="en";
			pat.Guarantor=PatNum2;//same family as patient #2.
			Patients.Insert(pat,false);
			PatNum4=pat.PatNum;
			//primary coverage------------------------------
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=subNum_pat2_pri;
			patplan.Relationship=Relat.Child;//3
			patplan.PatID="02";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//secondary----------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("777777");
			plan.GroupNum="P9902";
			plan.DivisionNo="";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=PatNum2;
			sub.SubscriberID="12343D6";//had to add this as separate plan because of unique subscriber id.
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Child;//3
			patplan.PatID="00";
			patplan.Ordinal=2;
			PatPlans.Insert(patplan);
			//PATIENT 5=========================================================================
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Single;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1964,5,16);
			pat.LName="Howard";
			pat.FName="Bob";
			pat.MiddleI="L";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="1542 West Boulevard";
			pat.Address2="";
			pat.City="Fort Happens";
			pat.State="SK";
			pat.Zip="S4J4D4";
			pat.Language="en";
			Patients.Insert(pat,false);
			PatNum5=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			ToothInitialTC.SetMissing("12",pat.PatNum);
			ToothInitialTC.SetMissing("33",pat.PatNum);
			ToothInitialTC.SetMissing("34",pat.PatNum);
			//ins----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("888888");
			plan.GroupNum="17542";
			plan.DivisionNo="";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="N";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;
			sub.SubscriberID="30322145";//concat bandNumber(303) and familyNumber(22145)
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//PATIENT 6=========================================================================
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Female;
			pat.Birthdate=new DateTime(1954,12,25);
			pat.LName="West";
			pat.FName="Martha";
			pat.MiddleI="F";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="156 East 154 Street";
			pat.Address2="";
			pat.City="100 Mile House";
			pat.State="BC";
			pat.Zip="V4V6D7";
			pat.Language="en";
			Patients.Insert(pat,false);
			PatNum6=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			//patient 6b--------------------------------------------------------------------------
			pat=new Patient();
			pat.PatStatus=PatientStatus.NonPatient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1952,06,25);
			pat.LName="West";
			pat.FName="Henry";
			pat.MiddleI="B";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="156 East 154 Street";
			pat.Address2="";
			pat.City="100 Mile House";
			pat.State="BC";
			pat.Zip="V4V6D7";
			pat.Language="en";
			pat.Guarantor=PatNum6;
			Patients.Insert(pat,false);
			//primary----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("666666");
			plan.GroupNum="2221";
			plan.DivisionNo="BA1765";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=PatNum6;
			sub.SubscriberID="19234G";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=PatNum6;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//secondary----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("777777");
			plan.GroupNum="P4042";
			plan.DivisionNo="15476";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;//Henry
			sub.SubscriberID="D6PD4";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=PatNum6;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Spouse;//2
			patplan.PatID="01";
			patplan.Ordinal=2;
			PatPlans.Insert(patplan);
			//PATIENT 7=========================================================================
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Female;
			pat.Birthdate=new DateTime(1940,5,1);
			pat.LName="Arpège";
			pat.FName="Madeleine";
			pat.MiddleI="É";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="1542 Rue de Peel, suite 104";
			pat.Address2="";
			pat.City="Québec";
			pat.State="QC";
			pat.Zip="H4A2D7";
			pat.Language="fr";
			Patients.Insert(pat,false);
			PatNum7=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			//patient 7b--------------------------------------------------------------------------
			pat=new Patient();
			pat.PatStatus=PatientStatus.NonPatient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1945,6,25);
			pat.LName="Arpège";
			pat.FName="Maurice";
			pat.MiddleI="L";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="1542 Rue de Peel, suite 104";
			pat.Address2="";
			pat.City="Québec";
			pat.State="QC";
			pat.Zip="H4A2D7";
			pat.Language="fr";
			pat.Guarantor=PatNum7;
			Patients.Insert(pat,false);
			//primary----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("777777");
			plan.GroupNum="AN99012";
			plan.DivisionNo="887B3";
			plan.DentaideCardSequence=22;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=PatNum7;
			sub.SubscriberID="344C41";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=PatNum7;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//secondary----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("666666");
			plan.GroupNum="P605B2";
			plan.DivisionNo="";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;//Maurice
			sub.SubscriberID="D6577";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=PatNum7;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Spouse;//2
			patplan.PatID="01";
			patplan.Ordinal=2;
			PatPlans.Insert(patplan);
			//PATIENT 8=========================================================================
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1946,5,1);
			pat.LName="Jones";
			pat.FName="Fred";
			pat.MiddleI="M";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="100 Main Street";
			pat.Address2="";
			pat.City="Terrace";
			pat.State="BC";
			pat.Zip="V4A2D7";
			pat.Language="en";
			Patients.Insert(pat,false);
			PatNum8=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			//patient 8b--------------------------------------------------------------------------
			pat=new Patient();
			pat.PatStatus=PatientStatus.NonPatient;
			pat.Position=PatientPosition.Married;
			pat.Gender=PatientGender.Female;
			pat.Birthdate=new DateTime(1945,6,25);
			pat.LName="Jones";
			pat.FName="Wanda";
			pat.MiddleI="L";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="100 Main Street";
			pat.Address2="";
			pat.City="Terrace";
			pat.State="BC";
			pat.Zip="V4A2D7";
			pat.Language="en";
			pat.Guarantor=PatNum8;
			Patients.Insert(pat,false);
			//primary----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("777777");
			plan.GroupNum="BN99012";
			plan.DivisionNo="887OP";
			plan.DentaideCardSequence=03;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=PatNum8;//Fred
			sub.SubscriberID="XX344C41";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=PatNum8;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="00";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			//secondary----------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("999111");
			plan.GroupNum="P300";
			plan.DivisionNo="";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;//Wanda
			sub.SubscriberID="12A6577";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=PatNum8;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Spouse;//2
			patplan.PatID="01";
			patplan.Ordinal=2;
			PatPlans.Insert(patplan);
			//PATIENT 9=========================================================================
			pat=new Patient();
			pat.PatStatus=PatientStatus.Patient;
			pat.Position=PatientPosition.Single;
			pat.Gender=PatientGender.Male;
			pat.Birthdate=new DateTime(1964,5,1);
			pat.LName="Smith";
			pat.FName="Fred";
			pat.MiddleI="A";
			pat.CanadianEligibilityCode=4;//code not applicable
			pat.Address="1500 West 4th Street";
			pat.Address2="";
			pat.City="Wells";
			pat.State="BC";
			pat.Zip="V2D2D7";
			pat.Language="en";
			Patients.Insert(pat,false);
			PatNum9=pat.PatNum;
			oldPatient=pat.Copy();
			pat.Guarantor=pat.PatNum;
			Patients.Update(pat,oldPatient);
			//ins-----------------------------------------------------------------------------
			plan=new InsPlan();
			plan.CarrierNum=CarrierTC.GetCarrierNumById("555555");
			plan.GroupNum="44C99";
			plan.DivisionNo="9914";
			plan.DentaideCardSequence=0;
			plan.CanadianPlanFlag="";
			plan.ClaimFormNum=7;//Canadian claim form
			InsPlans.Insert(plan);
			sub=new InsSub();
			sub.PlanNum=plan.PlanNum;
			sub.Subscriber=pat.PatNum;
			sub.SubscriberID="344941";
			InsSubs.Insert(sub);
			patplan=new PatPlan();
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;//1
			patplan.PatID="";
			patplan.Ordinal=1;
			PatPlans.Insert(patplan);
			return "Patient objects set.\r\nInsPlan objects set.\r\n";
		}
Пример #12
0
		/// <summary></summary>
		public static void SendData(Program ProgramCur,Patient pat) {
			if(pat==null) {
				MsgBox.Show("Guru","Please select a patient first.");
				return;
			}
			int errorNum=MVStart();
			if(errorNum != 0) {
				MsgBox.Show("Guru","An error has occured.");
				return;
			}
			MVPatient mvPatient = new MVPatient();
			mvPatient.LastName = Tidy(pat.LName,64);
			mvPatient.FirstName = Tidy(pat.FName,64);
			if(pat.Gender == PatientGender.Male) {
				mvPatient.Sex = Tidy("M",1);
			}
			else if(pat.Gender == PatientGender.Female) {
				mvPatient.Sex = Tidy("F",1);
			}
			else if(pat.Gender == PatientGender.Unknown) {
				mvPatient.Sex = Tidy("0",1);
			}
			mvPatient.BirthDate = Tidy(pat.Birthdate.ToString("MMddyyyy"),8);
			if(ProgramProperties.GetPropVal(ProgramCur.ProgramNum,"Enter 0 to use PatientNum, or 1 to use ChartNum")=="0") {
				mvPatient.ID=Tidy(pat.PatNum.ToString(),64);
			}
			else {
				mvPatient.ID=Tidy(pat.ChartNumber.ToString(),64);
			}
			if(pat.ImageFolder=="") {//Could happen if the images module has not been visited for a new patient.
				Patient patOld=pat.Copy();
				pat.ImageFolder=pat.LName+pat.FName+pat.PatNum;
				Patients.Update(pat,patOld);
			}
			string imagePath=CodeBase.ODFileUtils.CombinePaths(ProgramProperties.GetPropVal(ProgramCur.ProgramNum,"Guru image path"),pat.ImageFolder);
			mvPatient.Directory = Tidy(imagePath,259);
			if(MVSendPatient(mvPatient) != 0) {
				MsgBox.Show("Guru","An error has occured.");
			}
		}
Пример #13
0
		private void FormSheetImport_Load(object sender,EventArgs e) {
			if(SheetCur!=null) {
				PatCur=Patients.GetPat(SheetCur.PatNum);
				PatOld=PatCur.Copy();
			}
			else {
				#region Acro
				throw new NotImplementedException();//js this broke with the move to dot net 4.0.
				/*
				pat=Patients.GetPat(DocCur.PatNum);
				CAcroApp acroApp=null;
				try {
					acroApp=new AcroAppClass();//Initialize Acrobat by creating App object
				}
				catch {
					MsgBox.Show(this,"Requires Acrobat 9 Pro to be installed on this computer.");
					DialogResult=DialogResult.Cancel;
					return;
				}
				//acroApp.Show();// Show Acrobat Viewer
				//acroApp.Hide();//This is annoying if Acrobat is already open for some other reason.
				CAcroAVDoc avDoc=new AcroAVDocClass();
				string pathToPdf=CodeBase.ODFileUtils.CombinePaths(ImageStore.GetPatientFolder(pat),DocCur.FileName);
				if(!avDoc.Open(pathToPdf,"")){
					MessageBox.Show(Lan.g(this,"Could not open")+" "+pathToPdf);
					DialogResult=DialogResult.Cancel;
					return;
				}
				IAFormApp formApp=new AFormAppClass();//Create a IAFormApp object so we can access the form fields in the open document
				IFields myFields=(IFields)formApp.Fields;// Get the IFields object associated with the form
				IEnumerator myEnumerator = myFields.GetEnumerator();// Get the IEnumerator object for myFields
				dictAcrobatFields=new Dictionary<string,string>();
				IField myField;
				string nameClean;
				string valClean;
				while(myEnumerator.MoveNext()) {
					myField=(IField)myEnumerator.Current;// Get the IField object
					if(myField.Value==null){
						continue;
					}
					//if the form was designed in LiveCycle, the names will look like this: topmostSubform[0].page1[0].SSN[0]
					//Whereas, if it was designed in Acrobat, the names will look like this: SSN
					//So...
					nameClean=myField.Name;
					if(nameClean.Contains("[") && nameClean.Contains(".")) {
						nameClean=nameClean.Substring(nameClean.LastIndexOf(".")+1);
						nameClean=nameClean.Substring(0,nameClean.IndexOf("["));
					}
					if(nameClean=="misc") {
						int suffix=1;
						nameClean=nameClean+suffix.ToString();
						while(dictAcrobatFields.ContainsKey(nameClean)) {//untested.
							suffix++;
							nameClean=nameClean+suffix.ToString();
						}
					}
					valClean=myField.Value;
					if(valClean=="Off") {
						valClean="";
					}
					//myField.Type//possible values include text,radiobutton,checkbox
					//MessageBox.Show("Raw:"+myField.Name+"  Name:"+nameClean+"  Value:"+myField.Value);
					if(dictAcrobatFields.ContainsKey(nameClean)) {
						continue;
					}
					dictAcrobatFields.Add(nameClean,valClean);
					//name:topmostSubform[0].page1[0].SSN[0]
				}
				//acroApp.Hide();//Doesn't work well enough
				//this.BringToFront();//Doesn't work
				//acroApp.Minimize();
				acroApp.Exit();
				acroApp=null;
				*/
				#endregion
			}
			Fam=Patients.GetFamily(PatCur.PatNum);
			AddressSameForFam=true;
			for(int i=0;i<Fam.ListPats.Length;i++) {
				if(PatCur.HmPhone!=Fam.ListPats[i].HmPhone
					|| PatCur.Address!=Fam.ListPats[i].Address
					|| PatCur.Address2!=Fam.ListPats[i].Address2
					|| PatCur.City!=Fam.ListPats[i].City
					|| PatCur.State!=Fam.ListPats[i].State
					|| PatCur.Zip!=Fam.ListPats[i].Zip) 
				{
					AddressSameForFam=false;
					break;
				}
			}
			PatPlanList=PatPlans.Refresh(PatCur.PatNum);
			SubList=InsSubs.RefreshForFam(Fam);
			PlanList=InsPlans.RefreshForSubList(SubList);
			if(PatPlanList.Count==0) {
				PatPlan1=null;
				Plan1=null;
				Sub1=null;
				Ins1Relat=null;
				Carrier1=null;
			}
			else {
				PatPlan1=PatPlanList[0];
				Sub1=InsSubs.GetSub(PatPlan1.InsSubNum,SubList);
				Plan1=InsPlans.GetPlan(Sub1.PlanNum,PlanList);
				Ins1Relat=PatPlan1.Relationship;
				Carrier1=Carriers.GetCarrier(Plan1.CarrierNum);
			}
			if(PatPlanList.Count<2) {
				PatPlan2=null;
				Plan2=null;
				Sub2=null;
				Ins2Relat=null;
				Carrier2=null;
			}
			else {
				PatPlan2=PatPlanList[1];
				Sub2=InsSubs.GetSub(PatPlan2.InsSubNum,SubList);
				Plan2=InsPlans.GetPlan(Sub2.PlanNum,PlanList);
				Ins2Relat=PatPlan2.Relationship;
				Carrier2=Carriers.GetCarrier(Plan2.CarrierNum);
			}
			FillRows();
			FillGrid();
			//All the fields have been loaded on the sheet at this point.  Set the required insurance boolean if this is a patient form.
			if(SheetCur.SheetType==SheetTypeEnum.PatientForm) {
				SetHasRequiredInsFields();
			}
		}
Пример #14
0
		///<summary>Finds any patients with the same first name, last name, and birthdate.  The birthdate must be a valid date, not 0001-01-01.
		///<para>If patCur has all-caps first and last names and there is exactly one matching patient who does not have all-caps first and last names, then patClone is set to patCur, patNonClone is set to the matching patient, and listAmbiguousMatches will be an empty list.</para>
		///<para>If the matching patient has an all-caps first and last name and patCur does not, then patClone will be set to the matching patient, patNonClone will be set to patCur, and listAmbiguousMatches will be an empty list.</para>
		///<para>If there are no matching patients, patClone and patNonClone will be null and listAmbiguousMatches will be an empty list.</para>
		///<para>If more than one patient has the same first and last name and birthdate, patClone and patNonClone will be null and listAmbiguousMatches will contain all the matching patients.</para>
		///<para>If there is one match, but there is not an all-caps to not all-caps relationship (meaning both are all-caps or both are mixed case or both are lower), patClone and patNonClone will be null and listAmbiguousMatches will contain the matching patient.</para></summary>
		public static void GetCloneAndNonClone(Patient patCur,out Patient patClone,out Patient patNonClone,out List<Patient> listAmbiguousMatches) {
			//No need to check RemotingRole; no call to db.
			//if niether patClone or patNonClone is set after this method, the patient does not have a clone and is also not a clone
			patClone=null;
			patNonClone=null;
			listAmbiguousMatches=new List<Patient>();
			if(patCur==null) {
				return;
			}
			if(patCur.Birthdate.Year<1880) {
				return;//in order to clone a patient or synch two patients, the birthdate for the patients must be a valid date
			}
			//listAllMatches should only contain 0 or 1 patient
			//if more than 1 other patient has the same first and last name and birthdate, then there is ambiguity that has to be fixed manually
			List<Patient> listAllMatches=GetListByNameAndBirthdate(patCur.PatNum,patCur.LName,patCur.FName,patCur.Birthdate);
			if(listAllMatches.Count==0) {
				return;//no matches, not a clone and does not have a clone
			}
			if(listAllMatches.Count>1) {
				for(int i=0;i<listAllMatches.Count;i++) {
					listAmbiguousMatches.Add(listAllMatches[i]);
				}
				return;//more than one match, cannot determine which is supposed to be linked, return the list of patients to notify the user that there is ambiguity and to fix manually
			}
			//there must be one and only one match, so determine if patCur is the clone or the non-clone
			//if patCur has all-caps first and last name, and the patient found does not, then patCur is the clone and the patient found is the non-clone
			if(patCur.LName.ToUpper()==patCur.LName
				&& patCur.FName.ToUpper()==patCur.FName
				&& (listAllMatches[0].LName.ToUpper()!=listAllMatches[0].LName || listAllMatches[0].FName.ToUpper()!=listAllMatches[0].FName))//using an or here so a patient name A Smith can be cloned to A SMITH and found based on first names both being upper case, but last names not or vice versa
			{
				patClone=patCur.Copy();
				patNonClone=listAllMatches[0].Copy();
			}
			//if patCur does not have all-caps first and last name, but the patient found does, then the patient found is the clone and patCur is the non-clone
			else if((patCur.LName.ToUpper()!=patCur.LName || patCur.FName.ToUpper()!=patCur.FName)//using an or here so original can have all uppercase first or last name but not both.  So A Smith can be cloned to A SMITH and both uppercase A first names will be ok.
				&& listAllMatches[0].LName.ToUpper()==listAllMatches[0].LName
				&& listAllMatches[0].FName.ToUpper()==listAllMatches[0].FName)
			{
				patNonClone=patCur.Copy();
				patClone=listAllMatches[0].Copy();
			}
			else {
				//either both patCur and the patient found have all-caps first and last names or both have mixed case or all lower case first and last names
				//either way, we do not know if patCur is a clone or has a clone, there is ambiguity
				//populate the ambiguous list with the patient found to notify user to fix manually if it is supposed to be linked
				listAmbiguousMatches.Add(listAllMatches[0]);
			}
		}
Пример #15
0
		///<summary>Remember, this button is not even visible if SelectionModeOnly.</summary>
		private void butAddPt_Click(object sender, System.EventArgs e){
			#if(TRIALONLY)
				MsgBox.Show(this,"Trial version.  Maximum 30 patients");
				if(Patients.GetNumberPatients()>30){
					MsgBox.Show(this,"Maximum reached");
					return;
				}
			#endif
			if(textLName.Text=="" && textFName.Text=="" && textChartNumber.Text==""){
				MessageBox.Show(Lan.g(this,"Not allowed to add a new patient until you have done a search to see if that patient already exists. Hint: just type a few letters into the Last Name box above.")); 
				return;
			}
			Patient PatCur=new Patient();
			if(textLName.Text.Length>1){//eg Sp
				PatCur.LName=textLName.Text.Substring(0,1).ToUpper()+textLName.Text.Substring(1);
			}
			if(textFName.Text.Length>1){
				PatCur.FName=textFName.Text.Substring(0,1).ToUpper()+textFName.Text.Substring(1);
			}
			PatCur.PatStatus=PatientStatus.Patient;
			PatCur.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
			//Explicitly use the combo clinic instead of FormOpenDental.ClinicNum becuase the combo box should default to that clinic unless manually changed by the user.
			if(!PrefC.GetBool(PrefName.EasyNoClinics) && comboClinic.SelectedIndex!=0) {//not no clinics and all isn't selected
				//Set the patients primary provider to the clinic default provider.
				PatCur.PriProv=Providers.GetDefaultProvider(_listClinics[comboClinic.SelectedIndex-1].ClinicNum).ProvNum;
			}
			else {
				//Set the patients primary provider to the practice default provider.
				PatCur.PriProv=Providers.GetDefaultProvider().ProvNum;
			}
			if(PrefC.GetBool(PrefName.ShowFeatureEhr)) {
				PatCur.Gender=PatientGender.Unknown;
			}
			PatCur.ClinicNum=FormOpenDental.ClinicNum;
			Patients.Insert(PatCur,false);
			CustReference custRef=new CustReference();
			custRef.PatNum=PatCur.PatNum;
			CustReferences.Insert(custRef);
			Patient PatOld=PatCur.Copy();
			PatCur.Guarantor=PatCur.PatNum;
			Patients.Update(PatCur,PatOld);
			Family FamCur=Patients.GetFamily(PatCur.PatNum);
			FormPatientEdit FormPE=new FormPatientEdit(PatCur,FamCur);
			FormPE.IsNew=true;
			FormPE.ShowDialog();
			if(FormPE.DialogResult==DialogResult.OK){
				NewPatientAdded=true;
				SelectedPatNum=PatCur.PatNum;
				DialogResult=DialogResult.OK;
			}
		}
Пример #16
0
		/// <summary>Only Called only from FormPayment.butOK click.  Only called if the user did not enter any splits.  Usually just adds one split for the current patient.  But if that would take the balance negative, then it loops through all other family members and creates splits for them.  It might still take the current patient negative once all other family members are zeroed out.</summary>
		public static List<PaySplit> Allocate(Payment pay){//double amtTot,int patNum,Payment payNum){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<List<PaySplit>>(MethodBase.GetCurrentMethod(),pay);
			}
			string command= 
				"SELECT Guarantor FROM patient "
				+"WHERE PatNum = "+POut.Long(pay.PatNum);
 			DataTable table=Db.GetTable(command);
			if(table.Rows.Count==0){
				return new List<PaySplit>();
			}
			command= 
				"SELECT patient.PatNum,EstBalance,PriProv,SUM(InsPayEst)+SUM(Writeoff) insEst_ "
				+"FROM patient "
				+"LEFT JOIN claimproc ON patient.PatNum=claimproc.PatNum "
				+"AND Status=0 "//NotReceived
				+"WHERE Guarantor = "+table.Rows[0][0].ToString()+" "
				+"GROUP BY  patient.PatNum,EstBalance,PriProv";
				//+" ORDER BY PatNum!="+POut.PInt(pay.PatNum);//puts current patient in position 0 //Oracle does not allow
 			table=Db.GetTable(command);
			List<Patient> pats=new List<Patient>();
			Patient pat;
			//first, put the current patient at position 0.
			for(int i=0;i<table.Rows.Count;i++) {
				if(table.Rows[i]["PatNum"].ToString()==pay.PatNum.ToString()){
					pat=new Patient();
					pat.PatNum    = PIn.Long(table.Rows[i][0].ToString());
					pat.EstBalance= PIn.Double(table.Rows[i][1].ToString());
					if(!PrefC.GetBool(PrefName.BalancesDontSubtractIns)){
						pat.EstBalance-=PIn.Double(table.Rows[i]["insEst_"].ToString());
					}
					pat.PriProv   = PIn.Long(table.Rows[i][2].ToString());
					pats.Add(pat.Copy());
				}
			}
			//then, do all the rest of the patients.
			for(int i=0;i<table.Rows.Count;i++){
				if(table.Rows[i]["PatNum"].ToString()==pay.PatNum.ToString()){
					continue;
				}
				pat=new Patient();
				pat.PatNum    = PIn.Long   (table.Rows[i][0].ToString());
				pat.EstBalance= PIn.Double(table.Rows[i][1].ToString());
				if(!PrefC.GetBool(PrefName.BalancesDontSubtractIns)){
					pat.EstBalance-=PIn.Double(table.Rows[i]["insEst_"].ToString());
				}
				pat.PriProv   = PIn.Long   (table.Rows[i][2].ToString());
				pats.Add(pat.Copy());
			}
			//first calculate all the amounts
			double amtRemain=pay.PayAmt;//start off with the full amount
			double[] amtSplits=new double[pats.Count];
			//loop through each family member, starting with current
			for(int i=0;i<pats.Count;i++){
				if(pats[i].EstBalance==0 || pats[i].EstBalance<0){
					continue;//don't apply paysplits to anyone with a negative balance
				}
				if(amtRemain<pats[i].EstBalance){//entire remainder can be allocated to this patient
					amtSplits[i]=amtRemain;
					amtRemain=0;
					break;
				}
				else{//amount remaining is more than or equal to the estBal for this family member
					amtSplits[i]=pats[i].EstBalance;
					amtRemain-=pats[i].EstBalance;
				}
			}
			//add any remainder to the split for this patient
			amtSplits[0]+=amtRemain;
			//now create a split for each non-zero amount
			PaySplit PaySplitCur;
			List<PaySplit> retVal=new List<PaySplit>();
			for(int i=0;i<pats.Count;i++){
				if(amtSplits[i]==0){
					continue;
				}
				PaySplitCur=new PaySplit();
				PaySplitCur.PatNum=pats[i].PatNum;
				PaySplitCur.PayNum=pay.PayNum;
				PaySplitCur.ProcDate=pay.PayDate;
				PaySplitCur.DatePay=pay.PayDate;
				PaySplitCur.ClinicNum=pay.ClinicNum;
				PaySplitCur.ProvNum=Patients.GetProvNum(pats[i]);
				PaySplitCur.SplitAmt=Math.Round(amtSplits[i],CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits);
				//PaySplitCur.InsertOrUpdate(true);
				retVal.Add(PaySplitCur);
			}
			//finally, adjust each EstBalance, but no need to do current patient
			//This no longer works here.  Must do it when closing payment window somehow
			/*for(int i=1;i<pats.Length;i++){
				if(amtSplits[i]==0){
					continue;
				}
				command="UPDATE patient SET EstBalance=EstBalance-"+POut.PDouble(amtSplits[i])
					+" WHERE PatNum="+POut.PInt(pats[i].PatNum);
				Db.NonQ(command);
			}*/
			return retVal;
		}
Пример #17
0
		/*
		///<summary>Only used in GetSearchResults.  All times between start and stop get set to true in provBarSched.</summary>
		private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){
			int startI=GetProvBarIndex(timeStart);
			int stopI=GetProvBarIndex(timeStop);
			for(int i=startI;i<=stopI;i++){
				provBarSched[i]=true;
			}
		}

		private static int GetProvBarIndex(TimeSpan time) {
			return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr
				+(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement))
				*(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr)
				/ApptDrawing.LineH;//rounds down
		}*/

		///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule.  This method creates the appointment and attaches all appropriate procedures.  It's up to the calling class to then place the appointment on the pinboard.  If the appointment doesn't get scheduled, it's important to delete it.  If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary>
		public static Appointment CreateRecallApt(Patient patCur,List<Procedure> procList,List<InsPlan> planList,long recallNum,List<InsSub> subList){
			List<Recall> recallList=Recalls.GetList(patCur.PatNum);
			Recall recallCur=null;
			if(recallNum>0) {
				recallCur=Recalls.GetRecall(recallNum);
			}
			else{
				for(int i=0;i<recallList.Count;i++){
					if(recallList[i].RecallTypeNum==RecallTypes.PerioType || recallList[i].RecallTypeNum==RecallTypes.ProphyType){
						if(!recallList[i].IsDisabled){
							recallCur=recallList[i];
						}
						break;
					}
				}
			}
			if(recallCur==null){// || recallCur.DateDue.Year<1880){
				throw new ApplicationException(Lan.g("AppointmentL","No special type recall is due."));//Typically never happens because everyone has a recall.  However, it can happen when patients have custom recalls due
			}
			if(recallCur.DateScheduled.Date>DateTime.Today) {
				throw new ApplicationException(Lan.g("AppointmentL","Recall has already been scheduled for ")+recallCur.DateScheduled.ToShortDateString());
			}
			Appointment AptCur=new Appointment();
			AptCur.PatNum=patCur.PatNum;
			AptCur.AptStatus=ApptStatus.UnschedList;//In all places where this is used, the unsched status with no aptDateTime will cause the appt to be deleted when the pinboard is cleared.
			if(patCur.PriProv==0){
				AptCur.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
			}
			else{
				AptCur.ProvNum=patCur.PriProv;
			}
			AptCur.ProvHyg=patCur.SecProv;
			if(AptCur.ProvHyg!=0){
				AptCur.IsHygiene=true;
			}
			AptCur.ClinicNum=patCur.ClinicNum;
			//whether perio or prophy:
			List<string> procs=RecallTypes.GetProcs(recallCur.RecallTypeNum);
			string recallPattern=RecallTypes.GetTimePattern(recallCur.RecallTypeNum);
			if(RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)
				&& patCur.Birthdate.AddYears(PrefC.GetInt(PrefName.RecallAgeAdult)) > ((recallCur.DateDue>DateTime.Today)?recallCur.DateDue:DateTime.Today)) //For example, if pt's 12th birthday falls after recall date.
			{
				for(int i=0;i<RecallTypeC.Listt.Count;i++) {
					if(RecallTypeC.Listt[i].RecallTypeNum==RecallTypes.ChildProphyType) {
						List<string> childprocs=RecallTypes.GetProcs(RecallTypeC.Listt[i].RecallTypeNum);
						if(childprocs.Count>0) {
							procs=childprocs;//overrides adult procs.
						}
						string childpattern=RecallTypes.GetTimePattern(RecallTypeC.Listt[i].RecallTypeNum);
						if(childpattern!="") {
							recallPattern=childpattern;//overrides adult pattern.
						}
					}
				}
			}
			//convert time pattern to 5 minute increment
			StringBuilder savePattern=new StringBuilder();
			for(int i=0;i<recallPattern.Length;i++){
				savePattern.Append(recallPattern.Substring(i,1));
				if(PrefC.GetLong(PrefName.AppointmentTimeIncrement)==10) {
					savePattern.Append(recallPattern.Substring(i,1));
				}
				if(PrefC.GetLong(PrefName.AppointmentTimeIncrement)==15){
					savePattern.Append(recallPattern.Substring(i,1));
					savePattern.Append(recallPattern.Substring(i,1));
				}
			}
			if(savePattern.ToString()==""){
				if(PrefC.GetLong(PrefName.AppointmentTimeIncrement)==15){
					savePattern.Append("///XXX///");
				}
				else{
					savePattern.Append("//XX//");
				}
			}
			AptCur.Pattern=savePattern.ToString();
			//Add films------------------------------------------------------------------------------------------------------
			if(RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)){//if this is a prophy or perio
				for(int i=0;i<recallList.Count;i++){
					if(recallCur.RecallNum==recallList[i].RecallNum){
						continue;//already handled.
					}
					if(recallList[i].IsDisabled){
						continue;
					}
					if(recallList[i].DateDue.Year<1880){
						continue;
					}
					if(recallList[i].DateDue>recallCur.DateDue//if film due date is after prophy due date
						&& recallList[i].DateDue>DateTime.Today)//and not overdue
					{
						continue;
					}
					//incomplete: exclude manual recall types
					procs.AddRange(RecallTypes.GetProcs(recallList[i].RecallTypeNum));
				}
			}
			AptCur.ProcDescript="";
			AptCur.ProcsColored="";
			for(int i=0;i<procs.Count;i++) {
				string procDescOne="";
				if(i>0){
					AptCur.ProcDescript+=", ";
				}
				procDescOne+=ProcedureCodes.GetProcCode(procs[i]).AbbrDesc;
				AptCur.ProcDescript+=procDescOne;
				//Color and previous date are determined by ProcApptColor object
				ProcApptColor pac=ProcApptColors.GetMatch(procs[i]);
				System.Drawing.Color pColor=System.Drawing.Color.Black;
				string prevDateString="";
				if(pac!=null){
					pColor=pac.ColorText;
					if(pac.ShowPreviousDate) {
						prevDateString=Procedures.GetRecentProcDateString(AptCur.PatNum,AptCur.AptDateTime,pac.CodeRange);
						if(prevDateString!="") {
							prevDateString=" ("+prevDateString+")";
						}
					}
				}
				AptCur.ProcsColored+="<span color=\""+pColor.ToArgb().ToString()+"\">"+procDescOne+prevDateString+"</span>";
			}
			AptCur.TimeLocked=PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
			Appointments.Insert(AptCur);
			Procedure ProcCur;
			List <PatPlan> patPlanList=PatPlans.Refresh(patCur.PatNum);
			List <Benefit> benefitList=Benefits.Refresh(patPlanList,subList);
			InsPlan priplan=null;
			InsSub prisub=null;
			if(patPlanList.Count>0) {
				prisub=InsSubs.GetSub(patPlanList[0].InsSubNum,subList);
				priplan=InsPlans.GetPlan(prisub.PlanNum,planList);
			}
			double insfee;
			double standardfee;
			for(int i=0;i<procs.Count;i++){
				ProcCur=new Procedure();//this will be an insert
				//procnum
				ProcCur.PatNum=patCur.PatNum;
				ProcCur.AptNum=AptCur.AptNum;
				ProcCur.CodeNum=ProcedureCodes.GetCodeNum(procs[i]);
				ProcCur.ProcDate=DateTime.Now;
				ProcCur.DateTP=DateTime.Now;
				//Check if it's a medical procedure.
				bool isMed = false;
				ProcCur.MedicalCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode;
				if(ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") {
					isMed = true;
				}
				//Get fee schedule for medical or dental.
				long feeSch;
				if(isMed) {
					feeSch=Fees.GetMedFeeSched(patCur,planList,patPlanList,subList);
				}
				else {
					feeSch=Fees.GetFeeSched(patCur,planList,patPlanList,subList);
				}
				//Get the fee amount for medical or dental.
				if(PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) {
					insfee=Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum,feeSch);
				}
				else {
					insfee=Fees.GetAmount0(ProcCur.CodeNum,feeSch);
				}
				if(priplan!=null && priplan.PlanType=="p") {//PPO
					standardfee=Fees.GetAmount0(ProcCur.CodeNum,Providers.GetProv(Patients.GetProvNum(patCur)).FeeSched);
					if(standardfee>insfee) {
						ProcCur.ProcFee=standardfee;
					}
					else {
						ProcCur.ProcFee=insfee;
					}
				}
				else {
					ProcCur.ProcFee=insfee;
				}
				//surf
				//toothnum
				//Procedures.Cur.ToothRange="";
				//ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.CodeNum).NoBillIns;
				//priority
				ProcCur.ProcStatus=ProcStat.TP;
				ProcCur.Note="";
				//Procedures.Cur.PriEstim=
				//Procedures.Cur.SecEstim=
				//claimnum
				ProcCur.ProvNum=patCur.PriProv;
				//Procedures.Cur.Dx=
				ProcCur.ClinicNum=patCur.ClinicNum;
				//nextaptnum
				ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits;
				ProcCur.DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
				Procedures.Insert(ProcCur);//no recall synch required
				Procedures.ComputeEstimates(ProcCur,patCur.PatNum,new List<ClaimProc>(),false,planList,patPlanList,benefitList,patCur.Age,subList);
				if(Programs.UsingOrion){
					FormProcEdit FormP=new FormProcEdit(ProcCur,patCur.Copy(),Patients.GetFamily(patCur.PatNum));
					FormP.IsNew=true;
					FormP.ShowDialog();
					if(FormP.DialogResult==DialogResult.Cancel){
						//any created claimprocs are automatically deleted from within procEdit window.
						try{
							Procedures.Delete(ProcCur.ProcNum);//also deletes the claimprocs
						}
						catch(Exception ex){
							MessageBox.Show(ex.Message);
						}
					}
					else{
						//Do not synch. Recalls based on ScheduleByDate reports in Orion mode.
						//Recalls.Synch(PatCur.PatNum);
					}
				}
			}
			return AptCur;
		}
Пример #18
0
 ///<summary>The supplied payment plan should already have been saved in the database.</summary>
 public FormPayPlan(Patient patCur,PayPlan payPlanCur)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     PatCur=patCur.Copy();
     PayPlanCur=payPlanCur.Copy();
     FamCur=Patients.GetFamily(PatCur.PatNum);
     SubList=InsSubs.RefreshForFam(FamCur);
     InsPlanList=InsPlans.RefreshForSubList(SubList);
     Lan.F(this);
 }
Пример #19
0
        /// <summary>Only Called only from FormPayment.butOK click.  Only called if the user did not enter any splits.  Usually just adds one split for the current patient.  But if that would take the balance negative, then it loops through all other family members and creates splits for them.  It might still take the current patient negative once all other family members are zeroed out.</summary>
        public static List <PaySplit> Allocate(Payment pay)        //double amtTot,int patNum,Payment payNum){
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <PaySplit> >(MethodBase.GetCurrentMethod(), pay));
            }
            string command =
                "SELECT Guarantor FROM patient "
                + "WHERE PatNum = " + POut.Long(pay.PatNum);
            DataTable table = Db.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return(new List <PaySplit>());
            }
            command =
                "SELECT patient.PatNum,EstBalance,PriProv,SUM(InsPayEst)+SUM(Writeoff) insEst_ "
                + "FROM patient "
                + "LEFT JOIN claimproc ON patient.PatNum=claimproc.PatNum "
                + "AND Status=0 "               //NotReceived
                + "WHERE Guarantor = " + table.Rows[0][0].ToString() + " "
                + "GROUP BY  patient.PatNum,EstBalance,PriProv";
            //+" ORDER BY PatNum!="+POut.PInt(pay.PatNum);//puts current patient in position 0 //Oracle does not allow
            table = Db.GetTable(command);
            List <Patient> pats = new List <Patient>();
            Patient        pat;

            //first, put the current patient at position 0.
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["PatNum"].ToString() == pay.PatNum.ToString())
                {
                    pat            = new Patient();
                    pat.PatNum     = PIn.Long(table.Rows[i][0].ToString());
                    pat.EstBalance = PIn.Double(table.Rows[i][1].ToString());
                    if (!PrefC.GetBool(PrefName.BalancesDontSubtractIns))
                    {
                        pat.EstBalance -= PIn.Double(table.Rows[i]["insEst_"].ToString());
                    }
                    pat.PriProv = PIn.Long(table.Rows[i][2].ToString());
                    pats.Add(pat.Copy());
                }
            }
            //then, do all the rest of the patients.
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["PatNum"].ToString() == pay.PatNum.ToString())
                {
                    continue;
                }
                pat            = new Patient();
                pat.PatNum     = PIn.Long(table.Rows[i][0].ToString());
                pat.EstBalance = PIn.Double(table.Rows[i][1].ToString());
                if (!PrefC.GetBool(PrefName.BalancesDontSubtractIns))
                {
                    pat.EstBalance -= PIn.Double(table.Rows[i]["insEst_"].ToString());
                }
                pat.PriProv = PIn.Long(table.Rows[i][2].ToString());
                pats.Add(pat.Copy());
            }
            //first calculate all the amounts
            double amtRemain = pay.PayAmt;          //start off with the full amount

            double[] amtSplits = new double[pats.Count];
            //loop through each family member, starting with current
            for (int i = 0; i < pats.Count; i++)
            {
                if (pats[i].EstBalance == 0 || pats[i].EstBalance < 0)
                {
                    continue;                       //don't apply paysplits to anyone with a negative balance
                }
                if (amtRemain < pats[i].EstBalance) //entire remainder can be allocated to this patient
                {
                    amtSplits[i] = amtRemain;
                    amtRemain    = 0;
                    break;
                }
                else                 //amount remaining is more than or equal to the estBal for this family member
                {
                    amtSplits[i] = pats[i].EstBalance;
                    amtRemain   -= pats[i].EstBalance;
                }
            }
            //add any remainder to the split for this patient
            amtSplits[0] += amtRemain;
            //now create a split for each non-zero amount
            PaySplit        PaySplitCur;
            List <PaySplit> retVal = new List <PaySplit>();

            for (int i = 0; i < pats.Count; i++)
            {
                if (amtSplits[i] == 0)
                {
                    continue;
                }
                PaySplitCur           = new PaySplit();
                PaySplitCur.PatNum    = pats[i].PatNum;
                PaySplitCur.PayNum    = pay.PayNum;
                PaySplitCur.DatePay   = pay.PayDate;
                PaySplitCur.ClinicNum = pay.ClinicNum;
                PaySplitCur.ProvNum   = Patients.GetProvNum(pats[i]);
                PaySplitCur.SplitAmt  = Math.Round(amtSplits[i], CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalDigits);
                //PaySplitCur.InsertOrUpdate(true);
                retVal.Add(PaySplitCur);
            }
            //finally, adjust each EstBalance, but no need to do current patient
            //This no longer works here.  Must do it when closing payment window somehow

            /*for(int i=1;i<pats.Length;i++){
             *      if(amtSplits[i]==0){
             *              continue;
             *      }
             *      command="UPDATE patient SET EstBalance=EstBalance-"+POut.PDouble(amtSplits[i])
             +" WHERE PatNum="+POut.PInt(pats[i].PatNum);
             *      Db.NonQ(command);
             * }*/
            return(retVal);
        }
Пример #20
0
		///<summary></summary>
		private void butOK_Click(object sender, System.EventArgs e) {
			if(textMain.Text==""){
				MsgBox.Show(this,"Please paste the text generated by the other program into the large box first.");
				return;
			}
			pat=new Patient();
			pat.PriProv=PrefC.GetLong(PrefName.PracticeDefaultProv);
			pat.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
			guar=new Patient();
			guar.PriProv=PrefC.GetLong(PrefName.PracticeDefaultProv);
			guar.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
			subsc=new Patient();
			subsc.PriProv=PrefC.GetLong(PrefName.PracticeDefaultProv);
			subsc.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
			sub=new InsSub();
			sub.ReleaseInfo=true;
			sub.AssignBen=true;
			plan=new InsPlan();
			carrier=new Carrier();
			insRelat="self";//this is the default if not included
			guarRelat="self";
			InsEmp="";
			GuarEmp="";
			NoteMedicalComp="";
			insPresent=false;
			annualMax=-1;
			deductible=-1;
			XmlTextReader reader=new XmlTextReader(new StringReader(textMain.Text));
			reader.WhitespaceHandling=WhitespaceHandling.None;
			string element="";
			string textValue="";
			string rootElement="";
			string segment="";//eg PatientIdentification
			string field="";//eg NameLast
			string endelement="";
			warnings="";
			try{
				while(reader.Read()){
					switch(reader.NodeType){
						case XmlNodeType.Element:
							element=reader.Name;
							if(rootElement==""){//should be the first node
								if(element=="Message"){
									rootElement="Message";
								}
								else{
									throw new Exception(element+" should not be the first element.");
								}
							}
							else if(segment==""){//expecting a new segment
								segment=element;
								if(segment!="MessageHeader"
									&& segment!="PatientIdentification"
									&& segment!="Guarantor"
									&& segment!="Insurance")
								{
									throw new Exception(segment+" is not a recognized segment.");							
								}
							}
							else{//expecting a new field
								field=element;
							}
							if(segment=="Insurance"){
								insPresent=true;
							}
							break;
						case XmlNodeType.Text:
							textValue=reader.Value;
							if(field==""){
								throw new Exception("Unexpected text: "+textValue);	
							}
							break;
						case XmlNodeType.EndElement:
							endelement=reader.Name;
							if(field==""){//we're not in a field, so we must be closing a segment or rootelement
								if(segment==""){//we're not in a segment, so we must be closing the rootelement
									if(rootElement=="Message"){
										rootElement="";
									}
									else{
										throw new Exception("Message closing element expected.");
									}
								}
								else{//must be closing a segment
									segment="";
								}
							}
							else{//closing a field
								field="";
								textValue="";
							}
							break;
					}//switch 
					if(rootElement==""){
						break;//this will ignore anything after the message endelement
					}
					if(field!="" && textValue!=""){
						if(segment=="MessageHeader"){
							ProcessMSH(field,textValue);
						}
						else if(segment=="PatientIdentification"){
							ProcessPID(field,textValue);
						}
						else if(segment=="Guarantor"){
							ProcessGT(field,textValue);
						}
						else if(segment=="Insurance"){
							ProcessINS(field,textValue);
						}
					}
				}//while
			}
			catch(Exception ex){
				MessageBox.Show(ex.Message);
				//MsgBox.Show(this,"Error in the XML format.");
				reader.Close();
				return;
			}
			finally{
				reader.Close();
			}
			//Warnings and errors-----------------------------------------------------------------------------
			if(pat.LName=="" || pat.FName=="" || pat.Birthdate.Year<1880){
				MsgBox.Show(this,"Patient first and last name and birthdate are required.  Could not import.");
				return;
			}
			//if guarRelat is not self, and name and birthdate not supplied, no error.  Just make guar self.
			if(guarRelat!="self"){
				if(guar.LName=="" || guar.FName=="" || guar.Birthdate.Year<1880){
					warnings+="Guarantor information incomplete.  Guarantor will be self.\r\n";
					guarRelat="self";
				}
			}
			if(insPresent){
				if(carrier.CarrierName==""){
					warnings+="Insurance CompanyName is missing. No insurance info will be imported.\r\n";
					insPresent=false;
				}
				else if(insRelat!="self"){
					if(subsc.LName=="" || subsc.FName=="" || subsc.Birthdate.Year<1880){
						warnings+="Subscriber name or birthdate is missing. No insurance info will be imported.\r\n";
						insPresent=false;
					}
				}
				else if(sub.SubscriberID==""){
					warnings+="PolicyNumber/SubscriberID missing.\r\n";
					sub.SubscriberID=" ";
				}
			}
			if(warnings!=""){
				if(MessageBox.Show("It's safe to import, but you should be aware of the following issues:\r\n"+warnings+"\r\nContinue with Import?","Warnings",MessageBoxButtons.OKCancel)!=DialogResult.OK){
					return;
				}
			}
			
			//Patient-------------------------------------------------------------------------------------
			//DataTable table;
			long patNum=Patients.GetPatNumByNameAndBirthday(pat.LName,pat.FName,pat.Birthdate);
			Patient existingPat=null;
			existingPatOld=null;//we will need this to do an update.
			if(patNum != 0){//a patient already exists, so only add missing fields
				existingPat=Patients.GetPat(patNum);
				existingPatOld=existingPat.Copy();
				if(existingPat.MiddleI==""){//only alter existing if blank
					existingPat.MiddleI=pat.MiddleI;
				}
				if(pat.Gender!=PatientGender.Unknown){
					existingPat.Gender=pat.Gender;
				}
				if(existingPat.Preferred==""){
					existingPat.Preferred=pat.Preferred;
				}
				if(existingPat.Address==""){
					existingPat.Address=pat.Address;
				}
				if(existingPat.Address2==""){
					existingPat.Address2=pat.Address2;
				}
				if(existingPat.City==""){
					existingPat.City=pat.City;
				}
				if(existingPat.State==""){
					existingPat.State=pat.State;
				}
				if(existingPat.Zip==""){
					existingPat.Zip=pat.Zip;
				}
				if(existingPat.HmPhone==""){
					existingPat.HmPhone=pat.HmPhone;
				}
				if(existingPat.Email==""){
					existingPat.Email=pat.Email;
				}
				if(existingPat.WkPhone==""){
					existingPat.WkPhone=pat.WkPhone;
				}
				if(existingPat.Position==PatientPosition.Single){
					existingPat.Position=pat.Position;
				}
				if(existingPat.SSN==""){
					existingPat.SSN=pat.SSN;
				}
				existingPat.AddrNote+=pat.AddrNote;//concat
				Patients.Update(existingPat,existingPatOld);
				PatientNote PatientNoteCur=PatientNotes.Refresh(existingPat.PatNum,existingPat.Guarantor);
				PatientNoteCur.MedicalComp+=NoteMedicalComp;
				PatientNotes.Update(PatientNoteCur,existingPat.Guarantor);
				//guarantor will not be altered in any way
			}//if patient already exists
			else{//patient is new, so insert
				Patients.Insert(pat,false);
				existingPatOld=pat.Copy();
				pat.Guarantor=pat.PatNum;//this can be changed later.
				Patients.Update(pat,existingPatOld);
				PatientNote PatientNoteCur=PatientNotes.Refresh(pat.PatNum,pat.Guarantor);
				PatientNoteCur.MedicalComp+=NoteMedicalComp;
				PatientNotes.Update(PatientNoteCur,pat.Guarantor);
			}
			//guar-----------------------------------------------------------------------------------------------------
			if(existingPat==null){//only add or alter guarantor for new patients
				if(guarRelat=="self"){
					//pat is already set with guar as self
					//ignore all guar fields except EmployerName
					existingPatOld=pat.Copy();
					pat.EmployerNum=Employers.GetEmployerNum(GuarEmp);
					Patients.Update(pat,existingPatOld);
				}
				else{
					//if guarRelat is not self, and name and birthdate not supplied, a warning was issued, and relat was changed to self.
					//add guarantor or attach to an existing guarantor
					long guarNum=Patients.GetPatNumByNameAndBirthday(guar.LName,guar.FName,guar.Birthdate);
					if(guarNum != 0){//a guar already exists, so simply attach. Make no other changes
						existingPatOld=pat.Copy();
						pat.Guarantor=guarNum;
						if(guarRelat=="parent"){
							pat.Position=PatientPosition.Child;
						}
						Patients.Update(pat,existingPatOld);
					}
					else{//we need to completely create guar, then attach
						Patients.Insert(guar,false);
						//set guar for guar
						existingPatOld=guar.Copy();
						guar.Guarantor=guar.PatNum;
						guar.EmployerNum=Employers.GetEmployerNum(GuarEmp);
						Patients.Update(guar,existingPatOld);
						//set guar for pat
						existingPatOld=pat.Copy();
						pat.Guarantor=guar.PatNum;
						if(guarRelat=="parent"){
							pat.Position=PatientPosition.Child;
						}
						Patients.Update(pat,existingPatOld);
					}
				}
			}
			//subsc--------------------------------------------------------------------------------------------------
			if(!insPresent){
				//this takes care of missing carrier name or subscriber info.
				MsgBox.Show(this,"Done");
				DialogResult=DialogResult.OK;
			}
			if(insRelat=="self"){
				sub.Subscriber=pat.PatNum;
			}
			else{//we need to find or add the subscriber
				patNum=Patients.GetPatNumByNameAndBirthday(subsc.LName,subsc.FName,subsc.Birthdate);
				if(patNum != 0){//a subsc already exists, so simply attach. Make no other changes
					sub.Subscriber=patNum;
				}
				else{//need to create and attach a subscriber
					Patients.Insert(subsc,false);
					//set guar to same guar as patient
					existingPatOld=subsc.Copy();
					subsc.Guarantor=pat.Guarantor;
					Patients.Update(subsc,existingPatOld);
					sub.Subscriber=subsc.PatNum;
				}
			}
			//carrier-------------------------------------------------------------------------------------------------
			//Carriers.Cur=carrier;
			carrier=Carriers.GetIndentical(carrier);//this automatically finds or creates a carrier
			//plan------------------------------------------------------------------------------------------------------			
			plan.EmployerNum=Employers.GetEmployerNum(InsEmp);
			plan.CarrierNum=carrier.CarrierNum;
			InsPlans.Insert(plan);
			//Attach plan to subscriber
			sub.PlanNum=plan.PlanNum;
			InsSubs.Insert(sub);
			//Then attach plan
			List <PatPlan> PatPlanList=PatPlans.Refresh(pat.PatNum);
			PatPlan patplan=new PatPlan();
			patplan.Ordinal=(byte)(PatPlanList.Count+1);//so the ordinal of the first entry will be 1, NOT 0.
			patplan.PatNum=pat.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			switch(insRelat){
			  case "self":
					patplan.Relationship=Relat.Self;
					break;
				case "parent":
					patplan.Relationship=Relat.Child;
					break;
				case "spouse":
					patplan.Relationship=Relat.Spouse;
					break;
				case "guardian":
					patplan.Relationship=Relat.Dependent;
					break;
			}
			PatPlans.Insert(patplan);
			//benefits
			if(annualMax!=-1 && CovCatC.ListShort.Count>0){
				Benefit ben=new Benefit();
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=CovCatC.ListShort[0].CovCatNum;
				ben.MonetaryAmt=annualMax;
				ben.PlanNum=plan.PlanNum;
				ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				Benefits.Insert(ben);
			}
			if(deductible!=-1 && CovCatC.ListShort.Count>0) {
				Benefit ben=new Benefit();
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCatC.ListShort[0].CovCatNum;
				ben.MonetaryAmt=deductible;
				ben.PlanNum=plan.PlanNum;
				ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				Benefits.Insert(ben);
			}
			MsgBox.Show(this,"Done");
			DialogResult=DialogResult.OK;
		}
Пример #21
0
		///<summary>Guaranteed to always return a valid foldername unless major error or user chooses to exit.  This also saves the TrophyFolder value to this patient in the db and creates the new folder.</summary>
		private static string AutomaticallyGetTrophyFolderNumbered(Patient pat,string trophyPath) {
			//if this a patient with existing images in a trophy folder, find that folder
			//Different Trophy might? be organized differently.
			//But our logic will only cover the one situation that we are aware of.
			//In numbered mode, the folder numbering scheme is [trophyImageDir]\XX\PatNum.  The two digits XX are obtained by retrieving the 5th and 6th (indexes 4 and 5) digits of the patient's PatNum, left padded with 0's to ensure the PatNum is at least 6 digits long.  Examples: PatNum=103, left pad to 000103, substring to 03, patient's folder location is [trophyDirectory]\03\103.  PatNum=1003457, no need to left pad, substring to 45, pat folder is [trophyDirectory]\45\1003457.
			string retVal=ODFileUtils.CombinePaths(pat.PatNum.ToString().PadLeft(6,'0').Substring(4,2),pat.PatNum.ToString());//this is our default return value
			string fullPath=ODFileUtils.CombinePaths(trophyPath,retVal);
			if(!Directory.Exists(fullPath)) {
				try {
					Directory.CreateDirectory(fullPath);
				}
				catch {
					throw new Exception("Error.  Could not create folder: "+fullPath);
				}
			}
			//folder either existed before we got here, or we successfully created it
			Patient PatOld=pat.Copy();
			pat.TrophyFolder=retVal;
			Patients.Update(pat,PatOld);
			return retVal;
		}
Пример #22
0
		/// <summary>
		/// </summary>
		private Patient CreatePatient(String LastName,String FirstName,DateTime birthDate,WebSheets.SheetAndSheetField sAnds) {
			Patient newPat=new Patient();
			newPat.LName=LastName;
			newPat.FName=FirstName;
			newPat.Birthdate=birthDate;
			newPat.ClinicNum=Security.CurUser.ClinicNum;
			Type t=newPat.GetType();
			FieldInfo[] fi=t.GetFields();
			foreach(FieldInfo field in fi) {
				// find match for fields in Patients in the web_sheetfieldlist
				var WebSheetFieldList=sAnds.web_sheetfieldlist.Where(sf=>sf.FieldName.ToLower()==field.Name.ToLower());
				if(WebSheetFieldList.Count()>0) {
					// this loop is used to fill a field that may generate mutiple values for a single field in the patient.
					//for example the field gender has 2 eqivalent sheet fields in the web_sheetfieldlist
					for(int i=0;i<WebSheetFieldList.Count();i++) {
						WebSheets.webforms_sheetfield sf=WebSheetFieldList.ElementAt(i);
						String SheetWebFieldValue=sf.FieldValue;
						String RadioButtonValue=sf.RadioButtonValue;
						FillPatientFields(newPat,field,SheetWebFieldValue,RadioButtonValue);
					}
				}
			}
			try{
				Patients.Insert(newPat,false);
				//set Guarantor field the same as PatNum
				Patient patOld=newPat.Copy();
				newPat.Guarantor=newPat.PatNum;
				Patients.Update(newPat,patOld);
				//If there is an existing HL7 def enabled, send an ADT message if there is an outbound ADT message defined
				if(HL7Defs.IsExistingHL7Enabled()) {
					MessageHL7 messageHL7=MessageConstructor.GenerateADT(newPat,newPat,EventTypeHL7.A04);//patient is guarantor
					//Will be null if there is no outbound ADT message defined, so do nothing
					if(messageHL7!=null) {
						HL7Msg hl7Msg=new HL7Msg();
						hl7Msg.AptNum=0;
						hl7Msg.HL7Status=HL7MessageStatus.OutPending;//it will be marked outSent by the HL7 service.
						hl7Msg.MsgText=messageHL7.ToString();
						hl7Msg.PatNum=newPat.PatNum;
						HL7Msgs.Insert(hl7Msg);
#if DEBUG
						MessageBox.Show(this,messageHL7.ToString());
#endif
					}
				}
			}
			catch(Exception e) {
				gridMain.EndUpdate();
				MessageBox.Show(e.Message);
			}
			return newPat;
		}
Пример #23
0
 /// <summary>
 /// </summary>
 private Patient CreatePatient(String LastName,String FirstName,DateTime birthDate,WebSheets.SheetAndSheetField sAnds)
 {
     Patient newPat=new Patient();
     newPat.LName=LastName;
     newPat.FName=FirstName;
     newPat.Birthdate=birthDate;
     newPat.ClinicNum=Security.CurUser.ClinicNum;
     Type t=newPat.GetType();
     FieldInfo[] fi=t.GetFields();
     foreach(FieldInfo field in fi) {
         // find match for fields in Patients in the web_sheetfieldlist
         var WebSheetFieldList=sAnds.web_sheetfieldlist.Where(sf=>sf.FieldName.ToLower()==field.Name.ToLower());
         if(WebSheetFieldList.Count()>0) {
             // this loop is used to fill a field that may generate mutiple values for a single field in the patient.
             //for example the field gender has 2 eqivalent sheet fields in the web_sheetfieldlist
             for(int i=0;i<WebSheetFieldList.Count();i++) {
                 WebSheets.webforms_sheetfield sf=WebSheetFieldList.ElementAt(i);
                 String SheetWebFieldValue=sf.FieldValue;
                 String RadioButtonValue=sf.RadioButtonValue;
                 FillPatientFields(newPat,field,SheetWebFieldValue,RadioButtonValue);
             }
         }
     }
     try{
         Patients.Insert(newPat,false);
         //set Guarantor field the same as PatNum
         Patient patOld=newPat.Copy();
         newPat.Guarantor=newPat.PatNum;
         Patients.Update(newPat,patOld);
     }
     catch(Exception e) {
         gridMain.EndUpdate();
         MessageBox.Show(e.Message);
     }
     return newPat;
 }
Пример #24
0
 public static string AppointmentsNoPatients(bool verbose,bool isCheck)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         return Meth.GetString(MethodBase.GetCurrentMethod(),verbose,isCheck);
     }
     string log="";
     command="SELECT Count(*) FROM appointment WHERE PatNum NOT IN(SELECT PatNum FROM patient)";
     int count=PIn.Int(Db.GetCount(command));
     if(isCheck){
         if(count>0 || verbose){
             log+=Lans.g("FormDatabaseMaintenance","Appointments found abandoned: ")+count.ToString()+"\r\n";
         }
     }
     else{//Fix is safe because we are not deleting data, we are just attaching abandoned appointments to a dummy patient.
         if(count!=0) {
             Patient dummyPatient=new Patient();
             dummyPatient.FName="MISSING";
             dummyPatient.LName="PATIENT";
             dummyPatient.AddrNote="Appointments with missing patients were assigned to this patient on "+DateTime.Now.ToShortDateString()+" while doing database maintenance.";
             dummyPatient.Birthdate=DateTime.MinValue;
             dummyPatient.BillingType=PrefC.GetLong(PrefName.PracticeDefaultBillType);
             dummyPatient.PatStatus=PatientStatus.Archived;
             dummyPatient.PriProv=PrefC.GetLong(PrefName.PracticeDefaultProv);
             long dummyPatNum=Patients.Insert(dummyPatient,false);
             Patient oldDummyPatient=dummyPatient.Copy();
             dummyPatient.Guarantor=dummyPatNum;
             Patients.Update(dummyPatient,oldDummyPatient);
             command="UPDATE appointment SET PatNum="+POut.Long(dummyPatNum)+" WHERE PatNum NOT IN(SELECT PatNum FROM patient)";
             count=Db.NonQ32(command);
         }
         if(count!=0 || verbose) {
             log+=Lans.g("FormDatabaseMaintenance","Appointments altered due to no patient: ")+count.ToString()+"\r\n";
         }
     }
     return log;
 }
Пример #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;
 }
Пример #26
0
		public static void SetGuarantor(Patient pat,long guarantorNum){
			Patient oldPatient=pat.Copy();
			pat.Guarantor=guarantorNum;
			Patients.Update(pat,oldPatient);
		}