Example #1
0
		///<summary></summary>
		public static long Insert(PatPlan patPlan) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				patPlan.PatPlanNum=Meth.GetLong(MethodBase.GetCurrentMethod(),patPlan);
				return patPlan.PatPlanNum;
			}
			return Crud.PatPlanCrud.Insert(patPlan);
		}
Example #2
0
 ///<summary>Returns the data needed for ProcFeeHelper. Does not get ListFees.</summary>
 public static ProcFeeHelper GetData(long patNum, ProcFeeHelper procFeeHelper)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         //Not passing procFeeHelper because the null lists will get turned into empty lists which messes things up.
         return(Meth.GetObject <ProcFeeHelper>(MethodBase.GetCurrentMethod(), patNum, null));
     }
     procFeeHelper              = procFeeHelper ?? new ProcFeeHelper(patNum);
     procFeeHelper.Pat          = procFeeHelper.Pat ?? Patients.GetPat(patNum);
     procFeeHelper.ListPatPlans = procFeeHelper.ListPatPlans ?? PatPlans.GetPatPlansForPat(patNum);
     procFeeHelper.ListInsSubs  = procFeeHelper.ListInsSubs ?? InsSubs.GetMany(procFeeHelper.ListPatPlans.Select(x => x.InsSubNum).ToList());
     procFeeHelper.ListInsPlans = procFeeHelper.ListInsPlans ?? InsPlans.GetPlans(procFeeHelper.ListInsSubs.Select(x => x.PlanNum).ToList());
     if (procFeeHelper.ListPatPlans.Count > 0)
     {
         PatPlan priPatPlan = procFeeHelper.ListPatPlans[0];
         InsSub  priInsSub  = InsSubs.GetSub(priPatPlan.InsSubNum, procFeeHelper.ListInsSubs);
         InsPlan priInsPlan = InsPlans.GetPlan(priInsSub.PlanNum, procFeeHelper.ListInsPlans);
         procFeeHelper.ListBenefitsPrimary = procFeeHelper.ListBenefitsPrimary ?? Benefits.RefreshForPlan(priInsPlan.PlanNum, priPatPlan.PatPlanNum);
     }
     else
     {
         procFeeHelper.ListBenefitsPrimary = new List <Benefit>();
     }
     return(procFeeHelper);
 }
Example #3
0
        ///<summary>Removes the assigned user from the InsVerify of the InsPlan that is associated to the PatPlan passed in.
        ///Will only unassign if the user assigned to the patplan matches the user assigned to the insplan.</summary>
        private static void RemoveAssignedUser(PatPlan patPlanCur)
        {
            //No Remoting check; no call to db.
            //Get the insurance verified assigned to the PatPlan.
            InsVerify insVerifyForPatPlan = InsVerifies.GetOneByFKey(patPlanCur.PatPlanNum, VerifyTypes.PatientEnrollment);

            if (insVerifyForPatPlan != null && insVerifyForPatPlan.UserNum > 0)
            {
                //Get the insplan associated to the PatPlan.
                InsSub inssub = null;
                if (patPlanCur != null)
                {
                    inssub = InsSubs.GetOne(patPlanCur.InsSubNum);
                }
                InsPlan insPlan = null;
                if (inssub != null)
                {
                    insPlan = InsPlans.RefreshOne(inssub.PlanNum);
                }
                if (insPlan != null)
                {
                    //Get the insVerify for the insplan associated to the patplan we are about to delete.
                    InsVerify insVerifyForInsPlan = InsVerifies.GetOneByFKey(insPlan.PlanNum, VerifyTypes.InsuranceBenefit);
                    //Only unassign the user for the insplan if it matches the user for the patplan being dropped
                    if (insVerifyForInsPlan != null && insVerifyForInsPlan.UserNum == insVerifyForPatPlan.UserNum)
                    {
                        //Remove user and set DateLastVerified to MinValue.
                        insVerifyForInsPlan.UserNum          = 0;
                        insVerifyForInsPlan.DateLastVerified = DateTime.MinValue;
                        InsVerifies.Update(insVerifyForInsPlan);
                    }
                }
            }
        }
Example #4
0
		///<summary></summary>
		public static void Update(PatPlan patPlan) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),patPlan);
				return;
			}
			//ordinal was already set using SetOrdinal, but it's harmless to set it again.
			Crud.PatPlanCrud.Update(patPlan);
		}
Example #5
0
		public static PatPlan CreatePatPlan(byte ordinal,long patNum,long subNum){
			PatPlan patPlan=new PatPlan();
			patPlan.Ordinal=ordinal;
			patPlan.PatNum=patNum;
			patPlan.InsSubNum=subNum;
			PatPlans.Insert(patPlan);
			return patPlan;
		}
Example #6
0
File: PatPlans.cs Project: mnisl/OD
		///<summary></summary>
		public static long Insert(PatPlan patPlan) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				patPlan.PatPlanNum=Meth.GetLong(MethodBase.GetCurrentMethod(),patPlan);
				return patPlan.PatPlanNum;
			}
//Cameron_ Possibly create outbound ADT message to update insurance info
			return Crud.PatPlanCrud.Insert(patPlan);
		}
Example #7
0
 ///<summary></summary>
 public static long Insert(PatPlan patPlan)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         patPlan.PatPlanNum = Meth.GetLong(MethodBase.GetCurrentMethod(), patPlan);
         return(patPlan.PatPlanNum);
     }
     return(Crud.PatPlanCrud.Insert(patPlan));
 }
Example #8
0
 ///<summary></summary>
 public static void Update(PatPlan patPlan)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlan);
         return;
     }
     //ordinal was already set using SetOrdinal, but it's harmless to set it again.
     Crud.PatPlanCrud.Update(patPlan);
 }
Example #9
0
        ///<summary></summary>
        public PatPlan Copy()
        {
            PatPlan p = new PatPlan();

            p.PatPlanNum   = PatPlanNum;
            p.PatNum       = PatNum;
            p.PlanNum      = PlanNum;
            p.Ordinal      = Ordinal;
            p.IsPending    = IsPending;
            p.Relationship = Relationship;
            p.PatID        = PatID;
            return(p);
        }
Example #10
0
        ///<summary></summary>
        public static long Insert(PatPlan patPlan)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                patPlan.PatPlanNum = Meth.GetLong(MethodBase.GetCurrentMethod(), patPlan);
                return(patPlan.PatPlanNum);
            }
            //Cameron_ Possibly create outbound ADT message to update insurance info
            long patPlanNum = Crud.PatPlanCrud.Insert(patPlan);

            //Insert an InsVerify for the patplan to ensure that the patplan can be verified.
            InsVerifies.InsertForPatPlanNum(patPlanNum);
            return(patPlanNum);
        }
Example #11
0
 public static void Update(PatPlan patPlanNew, PatPlan patPlanOld)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), patPlanNew, patPlanOld);
         return;
     }
     if (patPlanOld == null)
     {
         Update(patPlanNew);
         return;
     }
     Crud.PatPlanCrud.Update(patPlanNew, patPlanOld);
 }
Example #12
0
        ///<summary>Gets the fee sched from the first insplan, the patient, or the provider in that order.  Uses procProvNum if>0, otherwise pat.PriProv.
        ///Either returns a fee schedule (fk to definition.DefNum) or 0.</summary>
        public static long GetFeeSched(Patient pat, List <InsPlan> planList, List <PatPlan> patPlans, List <InsSub> subList, long procProvNum)
        {
            //No need to check RemotingRole; no call to db.
            //there's not really a good place to put this function, so it's here.
            long    priPlanFeeSched = 0;
            PatPlan patPlanPri      = patPlans.FirstOrDefault(x => x.Ordinal == 1);

            if (patPlanPri != null)
            {
                InsPlan planCur = InsPlans.GetPlan(InsSubs.GetSub(patPlanPri.InsSubNum, subList).PlanNum, planList);
                if (planCur != null)
                {
                    priPlanFeeSched = planCur.FeeSched;
                }
            }
            return(GetFeeSched(priPlanFeeSched, pat.FeeSched, procProvNum != 0?procProvNum:pat.PriProv));       //use procProvNum, but if 0 then default to pat.PriProv
        }
Example #13
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;
		}
Example #14
0
		//<summary>This is a field that is accessed only by clicking on the button because there's not room for it otherwise.  This variable should be treated just as if it was a visible textBox.</summary>
		//private string BenefitNotes;

		///<summary>Called from ContrFamily and FormInsPlans. Must pass in the plan, patPlan, and sub, although patPlan and sub can be null.</summary>
		public FormInsPlan(InsPlan planCur,PatPlan patPlanCur,InsSub subCur){
			Cursor=Cursors.WaitCursor;
			InitializeComponent();
			PlanCur=planCur;
			PatPlanCur=patPlanCur;
			SubCur=subCur;
			listEmps=new ListBox();
			listEmps.Location=new Point(panelPlan.Left+groupPlan.Left+textEmployer.Left,
				panelPlan.Top+groupPlan.Top+textEmployer.Bottom);
			listEmps.Size=new Size(231,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();
			listCars=new ListBox();
			listCars.Location=new Point(panelPlan.Left+groupPlan.Left+groupCarrier.Left+textCarrier.Left,
				panelPlan.Top+groupPlan.Top+groupCarrier.Top+textCarrier.Bottom);
			listCars.Size=new Size(700,100);
			listCars.HorizontalScrollbar=true;
			listCars.Visible=false;
			listCars.Click += new System.EventHandler(listCars_Click);
			listCars.DoubleClick += new System.EventHandler(listCars_DoubleClick);
			listCars.MouseEnter += new System.EventHandler(listCars_MouseEnter);
			listCars.MouseLeave += new System.EventHandler(listCars_MouseLeave);
			Controls.Add(listCars);
			listCars.BringToFront();
			//tbPercentPlan.CellClicked += new OpenDental.ContrTable.CellEventHandler(tbPercentPlan_CellClicked);
			//tbPercentPat.CellClicked += new OpenDental.ContrTable.CellEventHandler(tbPercentPat_CellClicked);
			Lan.F(this);
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
				labelPatID.Text=Lan.g(this,"Dependant Code");
				labelCitySTZip.Text=Lan.g(this,"City,Prov,Post");   //Postal Code";
				butSearch.Visible=false;
				labelElectronicID.Text="EDI Code";
				comboElectIDdescript.Visible=false;
				labelGroupNum.Text=Lan.g(this,"Plan Number");
				checkIsPMP.Checked=(planCur.CanadianPlanFlag!=null && planCur.CanadianPlanFlag!="");
			}
			else{
				labelDivisionDash.Visible=false;
				textDivisionNo.Visible=false;
				groupCanadian.Visible=false;
			}
			if(CultureInfo.CurrentCulture.Name.Length>=4 && CultureInfo.CurrentCulture.Name.Substring(3)=="GB"){//en-GB
				labelCitySTZip.Text=Lan.g(this,"City,Postcode");
			}
			panelPat.BackColor=DefC.Long[(int)DefCat.MiscColors][0].ItemColor;
			//labelViewRequestDocument.Text="         ";
			//if(!PrefC.GetBool(PrefName.CustomizedForPracticeWeb")) {
			//	butEligibility.Visible=false;
			//	labelViewRequestDocument.Visible=false;
			//}
			Cursor=Cursors.Default;
		}
Example #15
0
		private void Init(){
			InitializeComponent();
			breakLinePen.Width=2;
			if(etrans.PatNum!=0) { //Some transactions are not patient specific.
				patient=Patients.GetPat(etrans.PatNum);
				patPlansForPat=PatPlans.Refresh(etrans.PatNum);
				claim=Claims.GetClaim(etrans.ClaimNum);
				primaryCarrier=Carriers.GetCarrier(etrans.CarrierNum);
				if(claim==null) {//for eligibility
					//Get primary info
					insSub=InsSubs.GetSub(etrans.InsSubNum,new List<InsSub>());
					subscriber=Patients.GetPat(insSub.Subscriber);
					insplan=InsPlans.GetPlan(etrans.PlanNum,new List<InsPlan>());
					patPlanPri=PatPlans.GetFromList(patPlansForPat,insSub.InsSubNum);
				}
				else {
					//Get primary info
					insSub=InsSubs.GetSub(claim.InsSubNum,new List<InsSub>());
					subscriber=Patients.GetPat(insSub.Subscriber);
					insplan=InsPlans.GetPlan(claim.PlanNum,new List<InsPlan>());
					patPlanPri=PatPlans.GetFromList(patPlansForPat,insSub.InsSubNum);
					//Get secondary info
					if(claim.InsSubNum2!=0) {
						patPlanSec=PatPlans.GetFromList(patPlansForPat,claim.InsSubNum2);
						insSub2=InsSubs.GetSub(claim.InsSubNum2,new List<InsSub>());
						subscriber2=Patients.GetPat(insSub2.Subscriber);
						insplan2=InsPlans.GetPlan(claim.PlanNum2,new List<InsPlan>());
						secondaryCarrier=Carriers.GetCarrier(insplan2.CarrierNum);
					}
					//Provider info
					provTreat=Providers.GetProv(claim.ProvTreat);
					provBill=Providers.GetProv(claim.ProvBill);
					//Claim related info
					claimprocs=ClaimProcs.RefreshForClaim(claim.ClaimNum);
					long clinicNum=0;
					for(int i=0;i<claimprocs.Count;i++) {
						if(claimprocs[i].ClinicNum!=0) {
							clinicNum=claimprocs[i].ClinicNum;
							break;
						}
					}
					if(clinicNum!=0) {
						clinic=Clinics.GetClinic(clinicNum);
					}
					else if(!PrefC.GetBool(PrefName.EasyNoClinics) && Clinics.List.Length>0) {
						clinic=Clinics.List[0];
					}
				}
				if(provTreat==null) {
					provTreat=Providers.GetProv(Patients.GetProvNum(patient));
				}
				if(provBill==null) {
					provBill=Providers.GetProv(Patients.GetProvNum(patient));
				}
				List<Procedure> procsAll=Procedures.Refresh(etrans.PatNum);
				extracted=Procedures.GetCanadianExtractedTeeth(procsAll);
			}
			if(MessageText==null || MessageText.Length<23) {
				throw new Exception("CCD message format too short: "+MessageText);
			}
			formData=new CCDFieldInputter(MessageText);//Input the fields of the given message.
			CCDField languageOfInsured=formData.GetFieldById("G27");
			if(languageOfInsured!=null) {
				if(languageOfInsured.valuestr=="F") {
					isFrench=true;
				}
			}
			else if(subscriber!=null && subscriber.Language=="fr") {
				isFrench=true;
			}
			formatVersionNumber=formData.GetFieldById("A03").valuestr;//Must always exist so no error checking here.
			transactionCode=formData.GetFieldById("A04").valuestr;//Must always exist so no error checking here.
			if(formatVersionNumber=="04") {//FormId field does not exist in version 02 in any of the message texts.
				CCDField formIdField=formData.GetFieldById("G42");//Usually exists in version 04 response messages.
				//Only a few response transactions don't define field G42. So far, those are transactions 15 (Summary Reconciliation), 16 (Payment Reconciliation) and 24 (Email).
				//In these cases, we simply do not use the formId field later on in the display code.
				if(formIdField!=null) {
					formId=formIdField.valuestr;
				}
			}
			else {//Version 02
				//Since there is no FormID field in version 02, we figure out what the formId should be based on the transaction type.
				if(transactionCode=="10") {//Eligibility Response.
					formId="08";//Eligibility Form
				}
				else if(transactionCode=="11") {//Claim Response.
					formId="03";//Claim Acknowledgement Form
				}
				else if(transactionCode=="21") {//EOB
					formId="01";//EOB Form
					CCDField g02=formData.GetFieldById("G02");
					if(g02!=null && g02.valuestr=="Y") {
						formId="04";//Employer Certified.
					}
				}
				else if(transactionCode=="13") {//Response to Pre-Determination.
					formId="06";//Pre-Determination Acknowledgement Form
				}
				else if(transactionCode=="12") { //Reversal response
					//There is no standard form for a reversal response, but we print the reversal response later on based on the transactioncode so we don't need to do anything here.
				}
				else {
					throw new Exception("Unhandled transactionCode '"+transactionCode+"' for version 02 message.");
				}
			}
			CCDField status=formData.GetFieldById("G05");
			if(status!=null && status.valuestr!=null) {
				responseStatus=status.valuestr.ToUpper();
			}
			transactionCode=formData.GetFieldById("A04").valuestr;
			predetermination=(transactionCode=="23"||transactionCode=="13");//Be sure to list all predetermination response types here!
			if(copiesToPrint<=0) { //Show the form on screen if there are no copies to print.
				ShowDisplayMessages();
				CCDField fieldPayTo=formData.GetFieldById("F01");
				if(fieldPayTo!=null) {
					bool paySubscriber=(fieldPayTo.valuestr=="1");//same for version 02 and version 04
					//Typically, insurance companies in Canada prefer to pay the subscriber instead of the dentist.
					if(AssignmentOfBenefits()) {//The insurance plan is set to pay the dentist
						if(paySubscriber) {//The carrier has decided to pay the subscriber.
							MsgBox.Show("Canadian","INFORMATION: The carrier changed the payee from the dentist to the subscriber.");//This check was required for certification.
						}
					}
					else {//The insurance plan is set to pay the subscriber
						if(!paySubscriber) {//The carrier has decided to pay the dentist.
							MsgBox.Show("Canadian","INFORMATION: The carrier changed the payee from the subscriber to the dentist.");//This check was required for certification.
						}
					}
				}
				CCDField paymentAdjustmentAmount=formData.GetFieldById("G33");
				if(paymentAdjustmentAmount!=null) {
					if(paymentAdjustmentAmount.valuestr.Substring(1)!="000000") {
						MessageBox.Show(Lan.g(this,"Payment adjustment amount")+": "+RawMoneyStrToDisplayMoney(paymentAdjustmentAmount.valuestr));
					}
				}
				if(autoPrint) {
					if(responseStatus!="R") { //We are not required to automatically print rejection notices.
						//Automatically print a patient copy only. We are never required to autoprint a dentist copy, but it can be done manually instead.
						new FormCCDPrint(etrans.Copy(),MessageText,1,false,true);
					}
				}
				if(formId=="05") { //Manual claim form
					Canadian.ShowManualClaimForm(claim);
					Close();
				}
				else {
					pd=CreatePrintDocument();
					printPreviewControl1.Document=pd;//Setting the document causes system to call pd_PrintPage, which will print the document in the preview window.
					ShowDialog();
				}
			}
			else {
				pd=CreatePrintDocument();
				if(formId=="05") { //Manual claim form
#if DEBUG
					Canadian.ShowManualClaimForm(claim);
#else
					Canadian.PrintManualClaimForm(claim);//Send the print job to the physical printer.
#endif
				}
				else {
#if DEBUG
					new FormCCDPrint(etrans.Copy(),MessageText,0,false,patientCopy);//Show the form on the screen.
#else
					pd.Print();//Send the print job to the physical printer.
#endif
				}
				//Print the remaining copies recursively.
				if(copiesToPrint>=2) {
					new FormCCDPrint(etrans.Copy(),MessageText,copiesToPrint-1,false,patientCopy);
				}
			}
			CCDField embeddedTransaction=formData.GetFieldById("G40");
			if(embeddedTransaction!=null) {
				new FormCCDPrint(etrans.Copy(),embeddedTransaction.valuestr,copiesToPrint,autoPrint,patientCopy);
			}
		}
Example #16
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;
 }
Example #17
0
        ///<summary>Returns the number of subscribers moved.
        ///No need to pass in userNum, it's set before remoting role check and passed to the server if necessary.</summary>
        public static long MoveSubscribers(long insPlanNumFrom, long insPlanNumTo, long userNum = 0)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
            {
                userNum = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod(), insPlanNumFrom, insPlanNumTo, userNum));
            }
            List <InsSub> listInsSubsFrom    = GetListForPlanNum(insPlanNumFrom);
            List <long>   listBlockedPatNums = new List <long>();

            //Perform the same validation as when the user manually drops insplans from FormInsPlan using the Drop button.
            for (int i = 0; i < listInsSubsFrom.Count; i++)
            {
                InsSub         insSubFrom      = listInsSubsFrom[i];
                List <PatPlan> listPatPlanFrom = PatPlans.Refresh(insSubFrom.Subscriber);
                for (int j = 0; j < listPatPlanFrom.Count; j++)
                {
                    PatPlan patPlanFrom = listPatPlanFrom[j];
                    //The following comments and logic are copied from the FormInsPlan Drop button...
                    //If they have a claim for this ins with today's date, don't let them drop.
                    //We already have code in place to delete claimprocs when we drop ins, but the claimprocs attached to claims are protected.
                    //The claim clearly needs to be deleted if they are dropping.  We need the user to delete the claim before they drop the plan.
                    //We also have code in place to add new claimprocs when they add the correct insurance.
                    List <Claim> listClaims = Claims.Refresh(patPlanFrom.PatNum);                 //Get all claims for patient.
                    for (int k = 0; k < listClaims.Count; k++)
                    {
                        if (listClaims[k].PlanNum != insPlanNumFrom)                       //Make sure the claim is for the insurance plan we are about to change, not any other plans the patient might have.
                        {
                            continue;
                        }
                        if (listClaims[k].DateService != DateTime.Today)                       //not today
                        {
                            continue;
                        }
                        //Patient currently has a claim for the insplan they are trying to drop.
                        if (!listBlockedPatNums.Contains(patPlanFrom.PatNum))
                        {
                            listBlockedPatNums.Add(patPlanFrom.PatNum);
                        }
                    }
                }
            }
            if (listBlockedPatNums.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < listBlockedPatNums.Count; i++)
                {
                    sb.Append("\r\n");
                    Patient pat = Patients.GetPat(listBlockedPatNums[i]);
                    sb.Append("#" + listBlockedPatNums[i] + " " + pat.GetNameFLFormal());
                }
                throw new ApplicationException(Lans.g("InsSubs", "Before changing the subscribers on the insurance plan being moved from, please delete all of today's claims related to the insurance plan being moved from for the following patients") + ":" + sb.ToString());
            }
            //This loop mimics some of the logic in PatPlans.Delete().
            int insSubMovedCount = 0;

            for (int i = 0; i < listInsSubsFrom.Count; i++)
            {
                InsSub inssub       = listInsSubsFrom[i];
                long   oldInsSubNum = inssub.InsSubNum;
                inssub.InsSubNum       = 0;        //This will allow us to insert a new record.
                inssub.PlanNum         = insPlanNumTo;
                inssub.DateEffective   = DateTime.MinValue;
                inssub.BenefitNotes    = "";
                inssub.SubscNote       = "";
                inssub.SecUserNumEntry = userNum;
                long      insSubNumNew       = InsSubs.Insert(inssub);
                string    command            = "SELECT PatNum FROM patplan WHERE InsSubNum=" + POut.Long(oldInsSubNum);
                DataTable tablePatsForInsSub = Db.GetTable(command);
                if (tablePatsForInsSub.Rows.Count == 0)
                {
                    continue;
                }
                insSubMovedCount++;
                for (int j = 0; j < tablePatsForInsSub.Rows.Count; j++)
                {
                    long           patNum       = PIn.Long(tablePatsForInsSub.Rows[j]["PatNum"].ToString());
                    List <PatPlan> listPatPlans = PatPlans.Refresh(patNum);
                    for (int k = 0; k < listPatPlans.Count; k++)
                    {
                        PatPlan patPlan = listPatPlans[k];
                        if (patPlan.InsSubNum == oldInsSubNum)
                        {
                            command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.Long(patPlan.PatPlanNum);                         //Delete patient specific benefits (rare).
                            Db.NonQ(command);
                            patPlan.InsSubNum = insSubNumNew;
                            PatPlans.Update(patPlan);
                        }
                    }
                    //Now that the plan has changed for the current subscriber, recalculate estimates.
                    bool prefChanged = false;
                    //Forcefully set pref false to prevent creating new estimates for all procs (including completed, sent procs)
                    if (Prefs.UpdateBool(PrefName.ClaimProcsAllowedToBackdate, false))
                    {
                        prefChanged = true;                      //We will turn the preference back on for the user after we finish our computations.
                    }
                    Family           fam            = Patients.GetFamily(patNum);
                    Patient          pat            = fam.GetPatient(patNum);
                    List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(patNum);
                    List <Procedure> listProcs      = Procedures.Refresh(patNum);
                    listPatPlans = PatPlans.Refresh(patNum);
                    List <InsSub>  listInsSubs  = InsSubs.RefreshForFam(fam);
                    List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs);
                    List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs);
                    Procedures.ComputeEstimatesForAll(patNum, listClaimProcs, listProcs, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs);
                    if (prefChanged)
                    {
                        Prefs.UpdateBool(PrefName.ClaimProcsAllowedToBackdate, true);                       //set back to original value if changed.
                    }
                }
            }
            InsPlan insPlanFrom = InsPlans.RefreshOne(insPlanNumFrom);
            InsPlan planOld     = insPlanFrom.Copy();

            insPlanFrom.IsHidden = true;
            InsPlans.Update(insPlanFrom, planOld);
            return(insSubMovedCount);
        }
Example #18
0
File: Canadian.cs Project: mnisl/OD
		///<summary>Only call this function for a patPlan such that the carrier has an electid of 000064, which signified that it is for Pacific Blue Cross (PBC).</summary>
		private static string GetMissingDataForPatPlanPacificBlueCross(PatPlan patPlan,InsPlan insPlan) {
			string retVal="";
			string dependantCode=patPlan.PatID;//C17
			int dependantNum=-1;
			if(dependantCode!="") {
				try {
					dependantNum=PIn.Int(dependantCode);
				}
				catch {
				}
			}
			string relationshipCode=GetRelationshipCode(patPlan.Relationship);//C03
			if(relationshipCode=="1") {//self
				if(dependantCode!="00") {
					if(retVal!="")
						retVal+=", ";
					retVal+="Dependant code must be 00 for Self with Pacific Blue Cross";
				}
			}
			else if(relationshipCode=="2") {//spouse
				if(dependantCode!="01" && !(dependantNum>=90 && dependantNum<=99)) {
					if(retVal!="")
						retVal+=", ";
					retVal+="Dependant code must be 01, or between 90 and 99 for Spouse with Pacific Blue Cross";
				}
			}
			else if(relationshipCode=="3") {//child
				if(dependantNum<2 || dependantNum>89 || dependantCode.Length!=2) {
					retVal+="Dependant code must be between 02 and 89 for Child with Pacific Blue Cross";
				}
			}
			else if(relationshipCode=="4") {//common law spouse
				if(dependantCode!="01" && !(dependantNum>=90 && dependantNum<=99)) {
					if(retVal!="")
						retVal+=", ";
					retVal+="Dependant code must be 01, or between 90 and 99 for Common-law with Pacific Blue Cross";
				}
			}
			else {
				retVal+="Relationship code must be Self, Spouse, Child, LifePartner, or SignifOther with Pacific Blue Cross";
			}
			return retVal;
		}
Example #19
0
 private void FormSheetImport_Load(object sender,EventArgs e)
 {
     if(SheetCur!=null) {
         pat=Patients.GetPat(SheetCur.PatNum);
     }
     else {
         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;
         */
     }
     fam=Patients.GetFamily(pat.PatNum);
     AddressSameForFam=true;
     for(int i=0;i<fam.ListPats.Length;i++) {
         if(pat.HmPhone!=fam.ListPats[i].HmPhone
             || pat.Address!=fam.ListPats[i].Address
             || pat.Address2!=fam.ListPats[i].Address2
             || pat.City!=fam.ListPats[i].City
             || pat.State!=fam.ListPats[i].State
             || pat.Zip!=fam.ListPats[i].Zip)
         {
             AddressSameForFam=false;
             break;
         }
     }
     patPlanList=PatPlans.Refresh(pat.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();
 }
Example #20
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";
		}
Example #21
0
 public static void IncrementOrthoNextClaimDates(PatPlan patPlan, InsPlan insPlan, int monthsTreat, PatientNote patNoteCur)
 {
     patPlan.OrthoAutoNextClaimDate = GetOrthoNextClaimDate(patPlan.OrthoAutoNextClaimDate, patNoteCur, insPlan.OrthoAutoProcFreq, monthsTreat);
     Update(patPlan);
 }
Example #22
0
		private void ToolButIns_Click(){
			DialogResult result=MessageBox.Show(Lan.g(this,"Is this patient the subscriber?"),"",MessageBoxButtons.YesNoCancel);
			if(result==DialogResult.Cancel){
				return;
			}
			//Pick a subscriber------------------------------------------------------------------------------------------------
			Patient subscriber;
			if(result==DialogResult.Yes){//current patient is subscriber
				subscriber=PatCur.Copy();
			}
			else{//patient is not subscriber
				//show list of patients in this family
				FormSubscriberSelect FormS=new FormSubscriberSelect(FamCur);
				FormS.ShowDialog();
				if(FormS.DialogResult==DialogResult.Cancel){
					return;
				}
				subscriber=Patients.GetPat(FormS.SelectedPatNum);
			}
			//Subscriber has been chosen. Now, pick a plan-------------------------------------------------------------------
			InsPlan plan=null;
			InsSub sub=null;
			bool planIsNew=false;
			List<InsSub> subList=InsSubs.GetListForSubscriber(subscriber.PatNum);
			if(subList.Count==0){
				planIsNew=true;
			}
			else{
				FormInsSelectSubscr FormISS=new FormInsSelectSubscr(subscriber.PatNum);
				FormISS.ShowDialog();
				if(FormISS.DialogResult==DialogResult.Cancel) {
					return;
				}
				if(FormISS.SelectedInsSubNum==0){//'New' option selected.
					planIsNew=true;
				}
				else{
					sub=InsSubs.GetSub(FormISS.SelectedInsSubNum,subList);
					plan=InsPlans.GetPlan(sub.PlanNum,new List<InsPlan>());
				}
			}
			//New plan was selected instead of an existing plan.  Create the plan--------------------------------------------
			if(planIsNew){
				plan=new InsPlan();
				plan.EmployerNum=subscriber.EmployerNum;
				plan.PlanType="";
				InsPlans.Insert(plan);
				sub=new InsSub();
				sub.PlanNum=plan.PlanNum;
				sub.Subscriber=subscriber.PatNum;
				if(subscriber.MedicaidID==""){
					sub.SubscriberID=subscriber.SSN;
				}
				else{
					sub.SubscriberID=subscriber.MedicaidID;
				}
				sub.ReleaseInfo=true;
				sub.AssignBen=true;
				InsSubs.Insert(sub);
				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=plan.PlanNum;
					ben.Percent=CovCatC.ListShort[i].DefaultPercent;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.CodeNum=0;
					Benefits.Insert(ben);
				}
				//Zero deductible diagnostic
				if(CovCats.GetForEbenCat(EbenefitCategory.Diagnostic)!=null) {
					ben=new Benefit();
					ben.CodeNum=0;
					ben.BenefitType=InsBenefitType.Deductible;
					ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.MonetaryAmt=0;
					ben.Percent=-1;
					ben.CoverageLevel=BenefitCoverageLevel.Individual;
					Benefits.Insert(ben);
				}
				//Zero deductible preventive
				if(CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive)!=null) {
					ben=new Benefit();
					ben.CodeNum=0;
					ben.BenefitType=InsBenefitType.Deductible;
					ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.MonetaryAmt=0;
					ben.Percent=-1;
					ben.CoverageLevel=BenefitCoverageLevel.Individual;
					Benefits.Insert(ben);
				}
			}
			//Then attach plan------------------------------------------------------------------------------------------------
			PatPlan patplan=new PatPlan();
			patplan.Ordinal=(byte)(PatPlanList.Count+1);//so the ordinal of the first entry will be 1, NOT 0.
			patplan.PatNum=PatCur.PatNum;
			patplan.InsSubNum=sub.InsSubNum;
			patplan.Relationship=Relat.Self;
			PatPlans.Insert(patplan);
			//Then, display insPlanEdit to user-------------------------------------------------------------------------------
			FormInsPlan FormI=new FormInsPlan(plan,patplan,sub);
			FormI.IsNewPlan=planIsNew;
			FormI.IsNewPatPlan=true;
			FormI.ShowDialog();//this updates estimates also.
			//if cancel, then patplan is deleted from within that dialog.
			//if cancel, and planIsNew, then plan and benefits are also deleted.
			ModuleSelected(PatCur.PatNum);
		}
Example #23
0
		///<summary>Loops through the supplied list to find the one patplan needed.</summary>
		public static PatPlan GetFromList(PatPlan[] patPlans,long patPlanNum) {
			//No need to check RemotingRole; no call to db.
			for(int i=0;i<patPlans.Length;i++){
				if(patPlans[i].PatPlanNum==patPlanNum){
					return patPlans[i].Copy();
				}
			}
			return null;
		}
		///<summary>Returns false if validation fails.  Returns true if all required insurance fields exist, import fields have valid values, and the insurance plan has been imported successfully.  The user will have the option to pick an existing ins plan.  If any fields on the selected plan do not exactly match the imported fields, they will be prompted to choose between the selected plan's values or to create a new ins plan with the import values.  After validating, the actual import of the new ins plan takes place.  That might consist of dropping the current plan and replacing it or simply inserting the new plan.</summary>
		private bool ValidateAndImportInsurance(bool isPrimary) {
			string insStr="";
			string insWarnStr="";
			byte ordinal;
			if(isPrimary) {
				insStr="ins1";
				insWarnStr="primary insurance";
				ordinal=1;
			}
			else {
				insStr="ins2";
				insWarnStr="secondary insurance";
				ordinal=2;
			}
			//Load up every insurance row related to the particular ins.
			SheetImportRow relationRow=GetImportRowByFieldName(insStr+"Relat");
			SheetImportRow subscriberRow=GetImportRowByFieldName(insStr+"Subscriber");
			SheetImportRow subscriberIdRow=GetImportRowByFieldName(insStr+"SubscriberID");
			SheetImportRow carrierNameRow=GetImportRowByFieldName(insStr+"CarrierName");
			SheetImportRow carrierPhoneRow=GetImportRowByFieldName(insStr+"CarrierPhone");
			SheetImportRow employerNameRow=GetImportRowByFieldName(insStr+"EmployerName");
			SheetImportRow groupNameRow=GetImportRowByFieldName(insStr+"GroupName");
			SheetImportRow groupNumRow=GetImportRowByFieldName(insStr+"GroupNum");
			//Check if the required insurance fields exist on this sheet.
			//NOTE: Employer, group name and group num are optional fields.
			//Checking for nulls in the required fields still needs to be here in this method in case the user has the required fields for one insurance plan but not enough for the other.  They will hit this code ONLY if they have flagged one of the fields on the "other" insurance plan for import that does not have all of the required fields.
			if(relationRow==null 
				|| subscriberRow==null
				|| subscriberIdRow==null
				|| carrierNameRow==null
				|| carrierPhoneRow==null) 
			{
				MessageBox.Show(Lan.g(this,"Required ")+insWarnStr+Lan.g(this," fields are missing on this sheet.  You cannot import ")+insWarnStr
					+Lan.g(this," with this sheet until it contains all of required fields.  Required fields: Relationship, Subscriber, SubscriberID, CarrierName, and CarrierPhone."));
				return false;
			}
			if(relationRow.ImpValObj==null 
				|| subscriberRow.ImpValObj==null
				|| (string)subscriberIdRow.ImpValObj==""
				|| carrierNameRow.ImpValObj==null
				|| carrierPhoneRow.ImpValObj==null) {
				MessageBox.Show(Lan.g(this,"Cannot import ")+insWarnStr+Lan.g(this," until all required fields have been set.  Required fields: Relationship, Subscriber, SubscriberID, CarrierName, and CarrierPhone."));
				return false;
			}
			InsPlan plan=null;
			InsSub sub=null;
			long insSubNum=0;
			long employerNum=0;
			//Get the employer from the db.  If no matching employer found, a new one will automatically get created.
			if(employerNameRow!=null && employerNameRow.ImpValDisplay.Trim()!="") {
				employerNum=Employers.GetEmployerNum(employerNameRow.ImpValDisplay);
			}
			Patient subscriber=(Patient)subscriberRow.ImpValObj;
			//Have user pick a plan------------------------------------------------------------------------------------------------------------
			bool planIsNew=false;
			List<InsSub> subList=InsSubs.GetListForSubscriber(subscriber.PatNum);
			FormInsPlans FormIP=new FormInsPlans();
			FormIP.carrierText=carrierNameRow.ImpValDisplay;
			if(employerNameRow!=null) {
				FormIP.empText=employerNameRow.ImpValDisplay;
			}
			if(groupNameRow!=null) {
				FormIP.groupNameText=groupNameRow.ImpValDisplay;
			}
			if(groupNumRow!=null) {
				FormIP.groupNumText=groupNumRow.ImpValDisplay;
			}
			FormIP.IsSelectMode=true;
			FormIP.ShowDialog();
			if(FormIP.DialogResult!=DialogResult.OK) {
				return false;
			}
			plan=FormIP.SelectedPlan;
			if(plan.PlanNum==0) {
				//User clicked blank plan, so a new plan will be created using the import values.
				planIsNew=true;
			}
			else {//An existing plan was selected so see if the plan is already subscribed to by the subscriber or create a new inssub.  Patplan will be taken care of later.
				for(int i=0;i<subList.Count;i++) {
					if(subList[i].PlanNum==plan.PlanNum) {
						sub=subList[i];
						insSubNum=sub.InsSubNum;
					}
				}
				if(sub==null) {//Create a new inssub if subscriber is not subscribed to this plan yet.
					sub=new InsSub();
					sub.PlanNum=plan.PlanNum;
					sub.Subscriber=subscriber.PatNum;
					sub.SubscriberID=subscriberIdRow.ImpValDisplay;
					sub.ReleaseInfo=true;
					sub.AssignBen=true;
					insSubNum=InsSubs.Insert(sub);
				}
			}
			//User picked a plan but the information they want to import might be different than the chosen plan.  Give them options to use current values or created a new plan.
			//It's still okay to let the user return at this point in order to change importing information.
			DialogResult result;
			//Carrier check-----------------------------------------------------------------------------------------
			if(!planIsNew && plan.CarrierNum!=((Carrier)carrierNameRow.ImpValObj).CarrierNum) {
				result=InsuranceImportQuestion("carrier",isPrimary);
				//Yes means the user wants to keep the information on the plan they picked, nothing to do.
				if(result==DialogResult.No) {
					planIsNew=true;
				}
				if(result==DialogResult.Cancel) {
					return false;
				}
			}
			//Employer check----------------------------------------------------------------------------------------
			if(!planIsNew && employerNum>0 && plan.EmployerNum!=employerNum) {
				result=InsuranceImportQuestion("employer",isPrimary);
				if(result==DialogResult.No) {
					planIsNew=true;
				}
				if(result==DialogResult.Cancel) {
					return false;
				}
			}
			//Subscriber check--------------------------------------------------------------------------------------
			if(!planIsNew && sub.Subscriber!=((Patient)subscriberRow.ImpValObj).PatNum) {
				result=InsuranceImportQuestion("subscriber",isPrimary);
				if(result==DialogResult.No) {
					planIsNew=true;
				}
				if(result==DialogResult.Cancel) {
					return false;
				}
			}
			if(!planIsNew && sub.SubscriberID!=subscriberIdRow.ImpValDisplay) {
				result=InsuranceImportQuestion("subscriber id",isPrimary);
				if(result==DialogResult.No) {
					planIsNew=true;
				}
				if(result==DialogResult.Cancel) {
					return false;
				}
			}
			//Group name check--------------------------------------------------------------------------------------
			if(groupNameRow!=null && !planIsNew && plan.GroupName!=groupNameRow.ImpValDisplay) {
				result=InsuranceImportQuestion("group name",isPrimary);
				if(result==DialogResult.No) {
					planIsNew=true;
				}
				if(result==DialogResult.Cancel) {
					return false;
				}
			}
			//Group num check---------------------------------------------------------------------------------------
			if(groupNumRow!=null && !planIsNew && plan.GroupNum!=groupNumRow.ImpValDisplay) {
				result=InsuranceImportQuestion("group num",isPrimary);
				if(result==DialogResult.No) {
					planIsNew=true;
				}
				if(result==DialogResult.Cancel) {
					return false;
				}
			}
			//Create a new plan-------------------------------------------------------------------------------------
			if(planIsNew) {
				plan=new InsPlan();
				if(employerNum>0) {
					plan.EmployerNum=employerNum;
				}
				plan.PlanType="";
				plan.CarrierNum=((Carrier)carrierNameRow.ImpValObj).CarrierNum;
				if(groupNameRow!=null) {
					plan.GroupName=groupNameRow.ImpValDisplay;
				}
				if(groupNumRow!=null) {
					plan.GroupNum=groupNumRow.ImpValDisplay;
				}
				InsPlans.Insert(plan);
				sub=new InsSub();
				sub.PlanNum=plan.PlanNum;
				sub.Subscriber=subscriber.PatNum;
				sub.SubscriberID=subscriberIdRow.ImpValDisplay;
				sub.ReleaseInfo=true;
				sub.AssignBen=true;
				insSubNum=InsSubs.Insert(sub);
				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=plan.PlanNum;
					ben.Percent=CovCatC.ListShort[i].DefaultPercent;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.CodeNum=0;
					Benefits.Insert(ben);
				}
				//Zero deductible diagnostic
				if(CovCats.GetForEbenCat(EbenefitCategory.Diagnostic)!=null) {
					ben=new Benefit();
					ben.CodeNum=0;
					ben.BenefitType=InsBenefitType.Deductible;
					ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.MonetaryAmt=0;
					ben.Percent=-1;
					ben.CoverageLevel=BenefitCoverageLevel.Individual;
					Benefits.Insert(ben);
				}
				//Zero deductible preventive
				if(CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive)!=null) {
					ben=new Benefit();
					ben.CodeNum=0;
					ben.BenefitType=InsBenefitType.Deductible;
					ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
					ben.PlanNum=plan.PlanNum;
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					ben.MonetaryAmt=0;
					ben.Percent=-1;
					ben.CoverageLevel=BenefitCoverageLevel.Individual;
					Benefits.Insert(ben);
				}
			}
			//Delete the old patplan-------------------------------------------------------------------------------------------------------------
			if(isPrimary && PatPlan1!=null) {//Importing primary and currently has primary ins.
				PatPlans.DeleteNonContiguous(PatPlan1.PatPlanNum);
			}
			if(!isPrimary && PatPlan2!=null) {//Importing secondary and currently has secondary ins.
				PatPlans.DeleteNonContiguous(PatPlan2.PatPlanNum);
			}
			//Then attach new patplan to the plan------------------------------------------------------------------------------------------------
			PatPlan patplan=new PatPlan();
			patplan.Ordinal=ordinal;//Not allowed to be 0.
			patplan.PatNum=PatCur.PatNum;
			patplan.InsSubNum=insSubNum;
			patplan.Relationship=((Relat)relationRow.ImpValObj);
			PatPlans.Insert(patplan);
			//After new plan has been imported, recompute all estimates for this patient because their coverage is now different.  Also set patient.HasIns to the correct value.
			List<ClaimProc> claimProcs=ClaimProcs.Refresh(PatCur.PatNum);
			List<Procedure> procs=Procedures.Refresh(PatCur.PatNum);
			List<PatPlan> patPlans=PatPlans.Refresh(PatCur.PatNum);
			subList=InsSubs.RefreshForFam(Fam);
			List<InsPlan> planList=InsPlans.RefreshForSubList(subList);
			List<Benefit> benList=Benefits.Refresh(patPlans,subList);
			Procedures.ComputeEstimatesForAll(PatCur.PatNum,claimProcs,procs,planList,patPlans,benList,PatCur.Age,subList);
			Patients.SetHasIns(PatCur.PatNum);
			return true;
		}