Ejemplo n.º 1
0
        ///<summary></summary>
        int IComparer.Compare(Object x, Object y)
        {
            Benefit[] array1 = (Benefit[])x;
            Benefit   ben1   = null;

            for (long i = 0; i < array1.Length; i++)
            {
                if (array1[i] == null)
                {
                    continue;
                }
                ben1 = array1[i].Copy();
                break;
            }
            Benefit[] array2 = (Benefit[])y;
            Benefit   ben2   = null;

            for (int i = 0; i < array2.Length; i++)
            {
                if (array2[i] == null)
                {
                    continue;
                }
                ben2 = array2[i].Copy();
                break;
            }
            return(ben1.CompareTo(ben2));
        }
Ejemplo n.º 2
0
 ///<summary></summary>
 public static void Delete(Benefit ben)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),ben);
         return;
     }
     string command="DELETE FROM benefit WHERE BenefitNum ="+POut.Long(ben.BenefitNum);
     Db.NonQ(command);
 }
Ejemplo n.º 3
0
        ///<summary>IComparable.CompareTo implementation.  This is used to order benefit lists as well as to group benefits if the type is essentially equal.  It doesn't compare values such as percentages or amounts.  It only compares types.</summary>
        public int CompareTo(object obj)
        {
            if (!(obj is Benefit))
            {
                throw new ArgumentException("object is not a Benefit");
            }
            Benefit ben = (Benefit)obj;

            //first by fam
            if (CoverageLevel != ben.CoverageLevel)
            {
                return(CoverageLevel.CompareTo(ben.CoverageLevel));
            }
            //then by type
            if (BenefitType != ben.BenefitType)           //if types are different
            {
                return(BenefitType.CompareTo(ben.BenefitType));
            }
            //types are the same, so check covCat. This is a loose comparison, ignored if either is 0.
            if (CovCatNum != 0 && ben.CovCatNum != 0 &&    //if both covcats have values
                CovCatNum != ben.CovCatNum)                   //and they are different
            //return CovCats.GetOrderShort(CovCatNum).CompareTo(CovCats.GetOrderShort(ben.CovCatNum));
            //this line was changed because we really do need to know if they have different covcats.
            {
                return(CovCatB.GetOrderLong(CovCatNum).CompareTo(CovCatB.GetOrderLong(ben.CovCatNum)));
            }
            //ProcCode
//THIS IS WRONG! NEED TO COMPARE THE PROCCODES, NOT THE CODENUMS.
            if (CodeNum != ben.CodeNum)
            {
                return(CodeNum.CompareTo(ben.CodeNum));
            }
            //TimePeriod-ServiceYear and CalendarYear are treated as the same.
            //if either are not serviceYear or CalendarYear
            if ((TimePeriod != BenefitTimePeriod.CalendarYear && TimePeriod != BenefitTimePeriod.ServiceYear) ||
                (ben.TimePeriod != BenefitTimePeriod.CalendarYear && ben.TimePeriod != BenefitTimePeriod.ServiceYear))
            {
                return(TimePeriod.CompareTo(ben.TimePeriod));
            }
            //QuantityQualifier
            if (QuantityQualifier != ben.QuantityQualifier)           //if different
            {
                return(QuantityQualifier.CompareTo(ben.QuantityQualifier));
            }
            //always different if plan vs. pat override
            if (PatPlanNum == 0 && ben.PatPlanNum != 0)
            {
                return(-1);
            }
            if (PlanNum == 0 && ben.PlanNum != 0)
            {
                return(1);
            }
            //Last resort.  Can't find any significant differencesin the type, so:
            return(0);           //then values are the same.
        }
Ejemplo n.º 4
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateAnnualMaxFamily(long planNum,double amt){
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Limitations;
			ben.CovCatNum=0;
			ben.CoverageLevel=BenefitCoverageLevel.Family;
			ben.MonetaryAmt=amt;
			ben.TimePeriod=BenefitTimePeriod.CalendarYear;
			Benefits.Insert(ben);
		}
Ejemplo n.º 5
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateLimitationProc(long planNum,string procCodeStr,double amt) {
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Limitations;
			ben.CodeNum=ProcedureCodes.GetCodeNum(procCodeStr);
			ben.CoverageLevel=BenefitCoverageLevel.Individual;
			ben.MonetaryAmt=amt;
			ben.TimePeriod=BenefitTimePeriod.CalendarYear;
			Benefits.Insert(ben);
		}
Ejemplo n.º 6
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateDeductibleGeneral(long planNum,BenefitCoverageLevel coverageLevel,double amt){
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Deductible;
			ben.CovCatNum=0;
			ben.CoverageLevel=coverageLevel;
			ben.MonetaryAmt=amt;
			ben.TimePeriod=BenefitTimePeriod.CalendarYear;
			Benefits.Insert(ben);
		}
Ejemplo n.º 7
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateLimitation(long planNum,EbenefitCategory category,double amt){
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Limitations;
			ben.CovCatNum=CovCats.GetForEbenCat(category).CovCatNum;
			ben.CoverageLevel=BenefitCoverageLevel.Individual;
			ben.MonetaryAmt=amt;
			ben.TimePeriod=BenefitTimePeriod.CalendarYear;
			Benefits.Insert(ben);
		}
Ejemplo n.º 8
0
        ///<summary></summary>
        public Benefit Copy()
        {
            Benefit b = new Benefit();

            b.BenefitNum        = BenefitNum;
            b.PlanNum           = PlanNum;
            b.PatPlanNum        = PatPlanNum;
            b.CovCatNum         = CovCatNum;
            b.ADACode           = ADACode;
            b.BenefitType       = BenefitType;
            b.Percent           = Percent;
            b.MonetaryAmt       = MonetaryAmt;
            b.TimePeriod        = TimePeriod;
            b.QuantityQualifier = QuantityQualifier;
            b.Quantity          = Quantity;
            return(b);
        }
Ejemplo n.º 9
0
 ///<summary>Returns true if most of the fields match except BenefitNum</summary>
 public bool IsSimilar(Benefit ben)
 {
     if (           //PlanNum             != oldBenefitList[i].PlanNum
         //|| PatPlanNum        != oldBenefitList[i].PatPlanNum
         CovCatNum != ben.CovCatNum ||
         BenefitType != ben.BenefitType ||
         Percent != ben.Percent ||
         MonetaryAmt != ben.MonetaryAmt ||
         TimePeriod != ben.TimePeriod ||
         QuantityQualifier != ben.QuantityQualifier ||
         Quantity != ben.Quantity ||
         CodeNum != ben.CodeNum ||
         CoverageLevel != ben.CoverageLevel)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 10
0
 /*
 ///<summary>Was used in FormInsPlan when applying changes to all identical plans.  Needs to be removed. 1. Deletes any benefits where the benefitNum is not found in the new list.  2. Adds any new Benefits (BenefitNum=0) found in the new list.  It does not test to see whether any benefits with the same BenefitNum have changed, because FormInsBenefits never changes existing benefits.</summary>
 public static void UpdateListForIdentical(List<Benefit> oldBenefitList,List<Benefit> newBenefitList,List<long> planNums) {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),oldBenefitList,newBenefitList,planNums);
         return;
     }
     string command;
     Benefit newBenefit;
     string plansInString="";//comma delimited
     for(int p=0;p<planNums.Count;p++){
         if(p>0){
             plansInString+=",";
         }
         plansInString+=planNums[p].ToString();
     }
     //1. Delete any benefits where the benefitNum is not found in the new list.--------------------------------------------
     for(int i=0;i<oldBenefitList.Count;i++) {//loop through the old list
         newBenefit=null;
         for(int j=0;j<newBenefitList.Count;j++) {
             if(newBenefitList[j]==null || newBenefitList[j].BenefitNum==0) {
                 continue;
             }
             if(oldBenefitList[i].BenefitNum==newBenefitList[j].BenefitNum) {
                 newBenefit=newBenefitList[j];//a matching benefitNum was found in the new list
                 break;
             }
         }
         if(newBenefit==null) {
             //benefit with matching benefitNum was not found, so it must have been deleted
             //delete all identical benefits from other plans and this plan
             command="DELETE FROM benefit WHERE PlanNum IN("+plansInString+") "
                 +"AND CovCatNum="+POut.Long(oldBenefitList[i].CovCatNum)+" "
                 +"AND BenefitType="+POut.Int((int)oldBenefitList[i].BenefitType)+" "
                 +"AND Percent="+POut.Int(oldBenefitList[i].Percent)+" "
                 +"AND MonetaryAmt="+POut.Double(oldBenefitList[i].MonetaryAmt)+" "
                 +"AND TimePeriod="+POut.Int((int)oldBenefitList[i].TimePeriod)+" "
                 +"AND QuantityQualifier="+POut.Int((int)oldBenefitList[i].QuantityQualifier)+" "
                 +"AND Quantity="+POut.Int(oldBenefitList[i].Quantity)+" "
                 +"AND CodeNum="+POut.Long(oldBenefitList[i].CodeNum)+" "
                 +"AND CoverageLevel="+POut.Int((int)oldBenefitList[i].CoverageLevel);
             Db.NonQ(command);
         }
     }
     //2. Add any new Benefits (BenefitNum=0) found in the new list.-------------------------------------------------------
     for(int i=0;i<newBenefitList.Count;i++) {//loop through the new list
         if(newBenefitList[i].BenefitNum==0 && newBenefitList[i].PlanNum!=0) {//the benefit is new, and it is a plan benefit rather than a patient benefit.
             for(int p=0;p<planNums.Count;p++){//loop through each plan
                 newBenefit=newBenefitList[i].Copy();//we need to leave the one in the list with BenefitNum=0 for testing further down.
                 newBenefit.PlanNum=planNums[p];
                 Insert(newBenefit);
             }
         }
     }
     //3. Alter any changed benefits.----------------------------------------------------------------------------------------
     //These will only be from the Other Benefits list, because the normal benefits are changed by using a delete and insert.
     for(int i=0;i<oldBenefitList.Count;i++) {//loop through the old list
         newBenefit=null;
         for(int j=0;j<newBenefitList.Count;j++) {
             if(newBenefitList[j]==null || newBenefitList[j].BenefitNum==0) {
                 continue;
             }
             if(oldBenefitList[i].BenefitNum==newBenefitList[j].BenefitNum) {
                 newBenefit=newBenefitList[j];//a matching benefitNum was found in the new list
                 break;
             }
         }
         if(newBenefit==null){
             continue;//no match found
         }
         if(//newBenefit.PlanNum             != oldBenefitList[i].PlanNum
             //|| newBenefit.PatPlanNum        != oldBenefitList[i].PatPlanNum
                  newBenefit.CovCatNum         != oldBenefitList[i].CovCatNum
             || newBenefit.BenefitType       != oldBenefitList[i].BenefitType
             || newBenefit.Percent           != oldBenefitList[i].Percent
             || newBenefit.MonetaryAmt       != oldBenefitList[i].MonetaryAmt
             || newBenefit.TimePeriod        != oldBenefitList[i].TimePeriod
             || newBenefit.QuantityQualifier != oldBenefitList[i].QuantityQualifier
             || newBenefit.Quantity          != oldBenefitList[i].Quantity
             || newBenefit.CodeNum           != oldBenefitList[i].CodeNum
             || newBenefit.CoverageLevel     != oldBenefitList[i].CoverageLevel)
         {
             //changed=true;
             //break;
             //change the identical benefit for all other plans
             command="UPDATE benefit SET "
                 //+"PlanNum = '"          +POut.Long   (ben.PlanNum)+"'"
                 //+",PatPlanNum = '"      +POut.Long   (ben.PatPlanNum)+"'"
                 +"CovCatNum = '"        +POut.Long   (newBenefit.CovCatNum)+"'"
                 +",BenefitType = '"     +POut.Long   ((int)newBenefit.BenefitType)+"'"
                 +",Percent = '"         +POut.Long   (newBenefit.Percent)+"'"
                 +",MonetaryAmt = '"     +POut.Double (newBenefit.MonetaryAmt)+"'"
                 +",TimePeriod = '"      +POut.Long   ((int)newBenefit.TimePeriod)+"'"
                 +",QuantityQualifier ='"+POut.Long   ((int)newBenefit.QuantityQualifier)+"'"
                 +",Quantity = '"        +POut.Long   (newBenefit.Quantity)+"'"
                 +",CodeNum = '"         +POut.Long   (newBenefit.CodeNum)+"'"
                 +",CoverageLevel = '"   +POut.Long   ((int)newBenefit.CoverageLevel)+"' "
                 +"WHERE PlanNum IN("+plansInString+") "
                 +"AND CovCatNum="+POut.Long(oldBenefitList[i].CovCatNum)+" "
                 +"AND BenefitType="+POut.Int((int)oldBenefitList[i].BenefitType)+" "
                 +"AND Percent="+POut.Int(oldBenefitList[i].Percent)+" "
                 +"AND MonetaryAmt="+POut.Double(oldBenefitList[i].MonetaryAmt)+" "
                 +"AND TimePeriod="+POut.Int((int)oldBenefitList[i].TimePeriod)+" "
                 +"AND QuantityQualifier="+POut.Int((int)oldBenefitList[i].QuantityQualifier)+" "
                 +"AND Quantity="+POut.Int(oldBenefitList[i].Quantity)+" "
                 +"AND CodeNum="+POut.Long(oldBenefitList[i].CodeNum)+" "
                 +"AND CoverageLevel="+POut.Int((int)oldBenefitList[i].CoverageLevel);
             Db.NonQ(command);
         }
     }
     //might be a good idea to compute estimates for each plan now.
 }*/
 ///<summary>Used in family module display to get a list of benefits.  The main purpose of this function is to group similar benefits for each plan on the same row, making it easier to display in a simple grid.  Supply a list of all benefits for the patient, and the patPlans for the patient.</summary>
 public static Benefit[,] GetDisplayMatrix(List <Benefit> bensForPat,List<PatPlan> patPlanList,List<InsSub> subList)
 {
     //No need to check RemotingRole; no call to db.
     ArrayList AL=new ArrayList();//each object is a Benefit[]
     Benefit[] row;
     ArrayList refAL=new ArrayList();//each object is a Benefit from any random column. Used when searching for a type.
     int col;
     InsSub sub;
     for(int i=0;i<bensForPat.Count;i++){
         //determine the column
         col=-1;
         for(int j=0;j<patPlanList.Count;j++){
             sub=InsSubs.GetSub(patPlanList[j].InsSubNum,subList);
             if(patPlanList[j].PatPlanNum==bensForPat[i].PatPlanNum
                 || sub.PlanNum==bensForPat[i].PlanNum)
             {
                 col=j;
                 break;
             }
         }
         if(col==-1){
             throw new Exception("col not found");//should never happen
         }
         //search refAL for a matching type that already exists
         row=null;
         for(int j=0;j<refAL.Count;j++){
             if(((Benefit)refAL[j]).CompareTo(bensForPat[i])==0){//if the type is equivalent
                 row=(Benefit[])AL[j];
                 break;
             }
         }
         //if no matching type found, add a row, and use that row
         if(row==null){
             refAL.Add(bensForPat[i].Copy());
             row=new Benefit[patPlanList.Count];
             row[col]=bensForPat[i].Copy();
             AL.Add(row);
             continue;
         }
         //if the column for the matching row is null, then use that row
         if(row[col]==null){
             row[col]=bensForPat[i].Copy();
             continue;
         }
         //if not null, then add another row.
         refAL.Add(bensForPat[i].Copy());
         row=new Benefit[patPlanList.Count];
         row[col]=bensForPat[i].Copy();
         AL.Add(row);
     }
     IComparer myComparer = new BenefitArraySorter();
     AL.Sort(myComparer);
     Benefit[,] retVal=new Benefit[patPlanList.Count,AL.Count];
     for(int y=0;y<AL.Count;y++){
         for(int x=0;x<patPlanList.Count;x++){
             if(((Benefit[])AL[y])[x]!=null){
                 retVal[x,y]=((Benefit[])AL[y])[x].Copy();
             }
         }
     }
     return retVal;
 }
Ejemplo n.º 11
0
Archivo: Benefits.cs Proyecto: mnisl/OD
		/*
		///<summary>Used in the Plan edit window to get a typical list of benefits for all identical plans.  It used to exclude the supplied plan from the benefits, but no longer does that.  This behavior needs to be watched closely for possible bugs.</summary>
		public static List<Benefit> RefreshForAll(InsPlan like) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetObject<List<Benefit>>(MethodBase.GetCurrentMethod(),like);
			}
			if(like.CarrierNum==0){
				return new List<Benefit>();
			}
			//We might try creating a temporary table out of the matched insurance plans, then join with
			//the benefits table so that the query could be sped up.
			//Get benefits for all identical plans
			string command="SELECT b.BenefitNum,b.PlanNum,b.PatPlanNum,b.CovCatNum,b.BenefitType,"
				+"b.Percent,b.MonetaryAmt,b.TimePeriod,b.QuantityQualifier,b.Quantity,b.CodeNum,b.CoverageLevel "
				+"FROM insplan i,benefit b "
				//+"WHERE PlanNum != "   +POut.PInt(like.PlanNum)+" "
				+"WHERE i.PlanNum=b.PlanNum "
				+"AND i.EmployerNum = '"+POut.Long(like.EmployerNum)+"' "
				+"AND i.GroupName = '"+POut.String(like.GroupName)+"' "
				+"AND i.GroupNum = '"+POut.String(like.GroupNum)+"' "
				+"AND i.DivisionNo = '"+POut.String(like.DivisionNo)+"'"
				+"AND i.CarrierNum = '"+POut.Long(like.CarrierNum)+"' "
				+"AND i.IsMedical = '"+POut.Bool(like.IsMedical)+"' ";
			Benefit[] benList=Crud.BenefitCrud.SelectMany(command).ToArray();
			////Get planNums for all identical plans
			//string command="SELECT PlanNum FROM insplan "
			//  //+"WHERE PlanNum != "   +POut.PInt(like.PlanNum)+" "
			//  +"WHERE EmployerNum = '" +POut.PLong(like.EmployerNum)+"' "
			//  +"AND GroupName = '"   +POut.PString(like.GroupName)+"' "
			//  +"AND GroupNum = '"    +POut.PString(like.GroupNum)+"' "
			//  +"AND DivisionNo = '"  +POut.PString(like.DivisionNo)+"'"
			//  +"AND CarrierNum = '"  +POut.PLong(like.CarrierNum)+"' "
			//  +"AND IsMedical = '"   +POut.PBool(like.IsMedical)+"' ";
			//DataTable table=Db.GetTable(command);
			//string planNums="";
			//for(int i=0;i<table.Rows.Count;i++) {
			//  if(i>0) {
			//    planNums+=" OR";
			//  }
			//  planNums+=" PlanNum="+table.Rows[i][0].ToString();
			//}
			//Benefit[] benList=new Benefit[0];
			//if(table.Rows.Count>0){
			//  //Get all benefits for all those plans
			//  command="SELECT * FROM benefit WHERE"+planNums;
			//  table=Db.GetTable(command);
			//  benList=new Benefit[table.Rows.Count];
			//  for(int i=0;i<table.Rows.Count;i++) {
			//    benList[i]=new Benefit();
			//    benList[i].BenefitNum       = PIn.PLong(table.Rows[i][0].ToString());
			//    benList[i].PlanNum          = PIn.PLong(table.Rows[i][1].ToString());
			//    benList[i].PatPlanNum       = PIn.PLong(table.Rows[i][2].ToString());
			//    benList[i].CovCatNum        = PIn.PLong(table.Rows[i][3].ToString());
			//    benList[i].BenefitType      = (InsBenefitType)PIn.PLong(table.Rows[i][4].ToString());
			//    benList[i].Percent          = PIn.PInt(table.Rows[i][5].ToString());
			//    benList[i].MonetaryAmt      = PIn.PDouble(table.Rows[i][6].ToString());
			//    benList[i].TimePeriod       = (BenefitTimePeriod)PIn.PLong(table.Rows[i][7].ToString());
			//    benList[i].QuantityQualifier= (BenefitQuantity)PIn.PLong(table.Rows[i][8].ToString());
			//    benList[i].Quantity         = PIn.PInt(table.Rows[i][9].ToString());
			//    benList[i].CodeNum          = PIn.PLong(table.Rows[i][10].ToString());
			//    benList[i].CoverageLevel    = (BenefitCoverageLevel)PIn.PLong(table.Rows[i][11].ToString());
			//  }
			//}
			//We could probably turn this last part into a group by within the query above in order to make this portion faster.
			List<Benefit> retVal=new List<Benefit>();
			//Loop through all benefits
			bool matchFound;
			for(int i=0;i<benList.Length;i++) {
				//For each benefit, loop through retVal and compare.
				matchFound=false;
				for(int j=0;j<retVal.Count;j++) {
					if(benList[i].CompareTo(retVal[j])==0) {//if the type is equal
						matchFound=true;
						break;
					}
				}
				if(matchFound) {
					continue;
				}
				//If no match found, then add it to the return list
				retVal.Add(benList[i]);
			}
			for(int i=0;i<retVal.Count;i++) {
				retVal[i].PlanNum=like.PlanNum;//change all the planNums to match the current plan
				//all set to 0 if the plan IsForIdentical.
			}
			return retVal;
		}*/
	

		///<summary></summary>
		public static void Update(Benefit ben) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),ben);
				return;
			}
			Crud.BenefitCrud.Update(ben);
		}
Ejemplo n.º 12
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateFrequencyCategory(long planNum,EbenefitCategory category,BenefitQuantity quantityQualifier,Byte quantity) {
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Limitations;
			ben.CovCatNum=CovCats.GetForEbenCat(category).CovCatNum;
			ben.CoverageLevel=BenefitCoverageLevel.None;
			ben.TimePeriod=BenefitTimePeriod.None;
			ben.Quantity=quantity;
			ben.QuantityQualifier=quantityQualifier;
			Benefits.Insert(ben);
		}
Ejemplo n.º 13
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateOrthoMax(long planNum,double amt) {
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Limitations;
			ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
			ben.CoverageLevel=BenefitCoverageLevel.Individual;
			ben.MonetaryAmt=amt;
			ben.TimePeriod=BenefitTimePeriod.Lifetime;
			Benefits.Insert(ben);
		}
Ejemplo n.º 14
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;
 }
Ejemplo n.º 15
0
		private void butCancel_Click(object sender, System.EventArgs e) {
			if(IsNew){
				BenCur=null;
			}
			DialogResult=DialogResult.Cancel;
		}
Ejemplo n.º 16
0
        public EB271(X12Segment segment, bool isInNetwork)
        {
            if (eb01 == null)
            {
                FillDictionaries();
            }
            Segment = segment;
            SupplementalSegments = new List <X12Segment>();
            //start pattern matching to generate closest Benefit
            EB01          eb01val  = eb01.Find(EB01MatchesCode);
            EB02          eb02val  = eb02.Find(EB02MatchesCode);
            EB03          eb03val  = eb03.Find(EB03MatchesCode);
            EB06          eb06val  = eb06.Find(EB06MatchesCode);
            EB09          eb09val  = eb09.Find(EB09MatchesCode);
            ProcedureCode proccode = null;

            if (ProcedureCodes.IsValidCode(Segment.Get(13, 2)))
            {
                proccode = ProcedureCodes.GetProcCode(Segment.Get(13, 2));
            }
            if (!eb01val.IsSupported ||
                (eb02val != null && !eb02val.IsSupported) ||
                (eb03val != null && !eb03val.IsSupported) ||
                (eb06val != null && !eb06val.IsSupported) ||
                (eb09val != null && !eb09val.IsSupported))
            {
                Benefitt = null;
                return;
            }
            if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && Segment.Get(3) == "30")
            {
                Benefitt = null;
                return;
            }
            if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && proccode != null)
            {
                //A code is covered.  Informational only.
                Benefitt = null;
                return;
            }
            if (Segment.Get(8) != "")           //if percentage
            //must have either a category or a proc code
            {
                if (proccode == null)                                                                                                       //if no proc code is specified
                {
                    if (eb03val == null || eb03val.ServiceType == EbenefitCategory.None || eb03val.ServiceType == EbenefitCategory.General) //and no category specified
                    {
                        Benefitt = null;
                        return;
                    }
                }
            }
            //coinsurance amounts are handled with fee schedules rather than benefits
            if (eb01val.BenefitType == InsBenefitType.CoPayment || eb01val.BenefitType == InsBenefitType.CoInsurance)
            {
                if (Segment.Get(7) != "")               //and a monetary amount specified
                {
                    Benefitt = null;
                    return;
                }
            }
            //a limitation without an amount is meaningless
            if (eb01val.BenefitType == InsBenefitType.Limitations)
            {
                if (Segment.Get(7) == "")               //no monetary amount specified
                {
                    Benefitt = null;
                    return;
                }
            }
            if (isInNetwork && Segment.Get(12) == "N")
            {
                Benefitt = null;
                return;
            }
            if (!isInNetwork && Segment.Get(12) == "Y")
            {
                Benefitt = null;
                return;
            }
            //if only a quantity is specified with no qualifier, it's meaningless
            if (Segment.Get(10) != "" && eb09val == null)
            {
                Benefitt = null;
                return;
            }
            //if only a qualifier is specified with no quantity, it's meaningless
            if (eb09val != null && Segment.Get(10) == "")
            {
                Benefitt = null;
                return;
            }
            Benefitt = new Benefit();
            //1
            Benefitt.BenefitType = eb01val.BenefitType;
            //2
            if (eb02val != null)
            {
                Benefitt.CoverageLevel = eb02val.CoverageLevel;
            }
            //3
            if (eb03val != null)
            {
                Benefitt.CovCatNum = CovCats.GetForEbenCat(eb03val.ServiceType).CovCatNum;
            }
            //4-Insurance type - we ignore.
            //5-Plan description - we ignore.
            //6
            if (eb06val != null)
            {
                Benefitt.TimePeriod = eb06val.TimePeriod;
            }
            //7
            if (Segment.Get(7) != "")
            {
                Benefitt.MonetaryAmt = PIn.Double(Segment.Get(7));              //Monetary amount. Situational
            }
            //8
            if (Segment.Get(8) != "")
            {
                Benefitt.Percent       = 100 - (int)(PIn.Double(Segment.Get(8)) * 100);    //Percent. Situational
                Benefitt.CoverageLevel = BenefitCoverageLevel.None;
            }
            //9-Quantity qualifier
            if (eb09val != null)
            {
                Benefitt.QuantityQualifier = eb09val.QuantityQualifier;
            }
            //10-Quantity
            if (Segment.Get(10) != "")
            {
                Benefitt.Quantity = (byte)PIn.Double(Segment.Get(10));              //Example: "19.0" with Quantity qualifier "S7" (age).
            }
            //11-Authorization. Ignored.
            //12-In network. Ignored.
            //13-proc
            if (proccode != null)
            {
                Benefitt.CodeNum = proccode.CodeNum;              //element 13,2
            }
        }
Ejemplo n.º 17
0
Archivo: Benefits.cs Proyecto: mnisl/OD
		///<summary></summary>
		public static long Insert(Benefit ben) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				ben.BenefitNum=Meth.GetLong(MethodBase.GetCurrentMethod(),ben);
				return ben.BenefitNum;
			}
			return Crud.BenefitCrud.Insert(ben);
		}
Ejemplo n.º 18
0
        ///<summary>IComparable.CompareTo implementation.  This is used to order benefit lists as well as to group benefits if the type is essentially equal.  It doesn't compare values such as percentages or amounts.  It only compares types.</summary>
        public int CompareTo(object obj)
        {
            if (!(obj is Benefit))
            {
                throw new ArgumentException("object is not a Benefit");
            }
            Benefit ben = (Benefit)obj;

            //first by fam
            if (CoverageLevel != ben.CoverageLevel)
            {
                return(CoverageLevel.CompareTo(ben.CoverageLevel));
            }
            //then by type
            if (BenefitType != ben.BenefitType)           //if types are different
            {
                return(BenefitType.CompareTo(ben.BenefitType));
            }
            //types are the same, so check covCat. This is a loose comparison, ignored if either is 0.
            if (CovCatNum != 0 && ben.CovCatNum != 0 &&    //if both covcats have values
                CovCatNum != ben.CovCatNum)                   //and they are different
            //return CovCats.GetOrderShort(CovCatNum).CompareTo(CovCats.GetOrderShort(ben.CovCatNum));
            //this line was changed because we really do need to know if they have different covcats.
            {
                return(CovCats.GetFindIndex(x => x.CovCatNum == CovCatNum).CompareTo(CovCats.GetFindIndex(x => x.CovCatNum == ben.CovCatNum)));
            }
            //ProcCode
            if (CodeNum != ben.CodeNum)
            {
                if (CovCatNum != 0 && CovCatNum == ben.CovCatNum)             //Both benefits are for same custom frequency group or the exam group.
                {
                    return(ProcedureCodes.GetStringProcCode(CodeNum).CompareTo(ProcedureCodes.GetStringProcCode(ben.CodeNum)));
                }
                int frequencyGroup1 = GetFrequencyGroupNum();
                int frequencyGroup2 = ben.GetFrequencyGroupNum();
                if (frequencyGroup1 == frequencyGroup2)
                {
                    return(ProcedureCodes.GetStringProcCode(CodeNum)
                           .CompareTo(ProcedureCodes.GetStringProcCode(ben.CodeNum)));
                }
                return(frequencyGroup1.CompareTo(frequencyGroup2));
            }
            //TimePeriod-ServiceYear and CalendarYear are treated as the same.
            //if either are not serviceYear or CalendarYear
            List <BenefitTimePeriod> listTimePeriods = new List <BenefitTimePeriod>()
            {
                BenefitTimePeriod.CalendarYear, BenefitTimePeriod.ServiceYear
            };

            if ((!TimePeriod.In(listTimePeriods) && !ben.TimePeriod.In(listTimePeriods) && TimePeriod != ben.TimePeriod) ||
                (TimePeriod.In(listTimePeriods) != ben.TimePeriod.In(listTimePeriods)))
            {
                return(TimePeriod.CompareTo(ben.TimePeriod));
            }
            //QuantityQualifier
            if (QuantityQualifier != ben.QuantityQualifier)           //if different
            {
                return(QuantityQualifier.CompareTo(ben.QuantityQualifier));
            }
            //always different if plan vs. pat override
            if (PatPlanNum == 0 && ben.PatPlanNum != 0)
            {
                return(-1);
            }
            if (PlanNum == 0 && ben.PlanNum != 0)
            {
                return(1);
            }
            //Last resort.  Can't find any significant differences in the type, so:
            return(0);           //then values are the same.
        }
Ejemplo n.º 19
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateCategoryPercent(long planNum,EbenefitCategory category,int percent){
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.CoInsurance;
			ben.CovCatNum=CovCats.GetForEbenCat(category).CovCatNum;
			ben.CoverageLevel=BenefitCoverageLevel.None;
			ben.Percent=percent;
			ben.TimePeriod=BenefitTimePeriod.CalendarYear;
			Benefits.Insert(ben);
		}
Ejemplo n.º 20
0
		///<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;
		}
Ejemplo n.º 21
0
		private void butIapFind_Click(object sender,System.EventArgs e) {
			//If SubCur is null, this button is not visible to click.
			FormIap FormI=new FormIap();
			FormI.ShowDialog();
			if(FormI.DialogResult==DialogResult.Cancel) {
				return;
			}
			Benefit ben;
			//clear exising benefits from screen, not db:
			benefitList=new List<Benefit>();
			string plan=FormI.selectedPlan;
			string field=null;
			string[] splitField;//if a field is a sentence with more than one word, we can split it for analysis
			int percent;
			try {
				Iap.ReadRecord(plan);
				for(int i=1;i<122;i++) {
					field=Iap.ReadField(i);
					if(field==null){
						field="";
					}
					switch(i) {
						default:
							//do nothing
							break;
						case Iap.Employer:
							if(SubCur.BenefitNotes!="") {
								SubCur.BenefitNotes+="\r\n";
							}
							SubCur.BenefitNotes+="Employer: "+field;
							textEmployer.Text=field;
							break;
						case Iap.Phone:
							SubCur.BenefitNotes+="\r\n"+"Phone: "+field;
							break;
						case Iap.InsUnder:
							SubCur.BenefitNotes+="\r\n"+"InsUnder: "+field;
							break;
						case Iap.Carrier:
							SubCur.BenefitNotes+="\r\n"+"Carrier: "+field;
							textCarrier.Text=field;
							break;
						case Iap.CarrierPh:
							SubCur.BenefitNotes+="\r\n"+"CarrierPh: "+field;
							textPhone.Text=field;
							break;
						case Iap.Group://seems to be used as groupnum
							SubCur.BenefitNotes+="\r\n"+"Group: "+field;
							textGroupNum.Text=field;
							break;
						case Iap.MailTo://the carrier name again
							SubCur.BenefitNotes+="\r\n"+"MailTo: "+field;
							break;
						case Iap.MailTo2://address
							SubCur.BenefitNotes+="\r\n"+"MailTo2: "+field;
							textAddress.Text=field;
							break;
						case Iap.MailTo3://address2
							SubCur.BenefitNotes+="\r\n"+"MailTo3: "+field;
							textAddress2.Text=field;
							break;
						case Iap.EClaims:
							SubCur.BenefitNotes+="\r\n"+"EClaims: "+field;//this contains the PayorID at the end, but also a bunch of other drivel.
							int payorIDloc=field.LastIndexOf("Payor ID#:");
							if(payorIDloc!=-1 && field.Length>payorIDloc+10) {
								textElectID.Text=field.Substring(payorIDloc+10);
							}
							break;
						case Iap.FAXClaims:
							SubCur.BenefitNotes+="\r\n"+"FAXClaims: "+field;
							break;
						case Iap.DMOOption:
							SubCur.BenefitNotes+="\r\n"+"DMOOption: "+field;
							break;
						case Iap.Medical:
							SubCur.BenefitNotes+="\r\n"+"Medical: "+field;
							break;
						case Iap.GroupNum://not used.  They seem to use the group field instead
							SubCur.BenefitNotes+="\r\n"+"GroupNum: "+field;
							break;
						case Iap.Phone2://?
							SubCur.BenefitNotes+="\r\n"+"Phone2: "+field;
							break;
						case Iap.Deductible:
							SubCur.BenefitNotes+="\r\n"+"Deductible: "+field;
							if(field.StartsWith("$")) {
								splitField=field.Split(new char[] { ' ' });
								ben=new Benefit();
								ben.BenefitType=InsBenefitType.Deductible;
								ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
								ben.PlanNum=PlanCur.PlanNum;
								ben.TimePeriod=BenefitTimePeriod.CalendarYear;
								ben.MonetaryAmt=PIn.Double(splitField[0].Remove(0,1));//removes the $
								benefitList.Add(ben.Copy());
							}
							break;
						case Iap.FamilyDed:
							SubCur.BenefitNotes+="\r\n"+"FamilyDed: "+field;
							break;
						case Iap.Maximum:
							SubCur.BenefitNotes+="\r\n"+"Maximum: "+field;
							if(field.StartsWith("$")) {
								splitField=field.Split(new char[] { ' ' });
								ben=new Benefit();
								ben.BenefitType=InsBenefitType.Limitations;
								ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
								ben.PlanNum=PlanCur.PlanNum;
								ben.TimePeriod=BenefitTimePeriod.CalendarYear;
								ben.MonetaryAmt=PIn.Double(splitField[0].Remove(0,1));//removes the $
								benefitList.Add(ben.Copy());
							}
							break;
						case Iap.BenefitYear://text is too complex to parse
							SubCur.BenefitNotes+="\r\n"+"BenefitYear: "+field;
							break;
						case Iap.DependentAge://too complex to parse
							SubCur.BenefitNotes+="\r\n"+"DependentAge: "+field;
							break;
						case Iap.Preventive:
							SubCur.BenefitNotes+="\r\n"+"Preventive: "+field;
							splitField=field.Split(new char[] { ' ' });
							if(splitField.Length==0 || !splitField[0].EndsWith("%")) {
								break;
							}
							splitField[0]=splitField[0].Remove(splitField[0].Length-1,1);//remove %
							percent=PIn.Int(splitField[0]);
							if(percent<0 || percent>100) {
								break;
							}
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							break;
						case Iap.Basic:
							SubCur.BenefitNotes+="\r\n"+"Basic: "+field;
							splitField=field.Split(new char[] { ' ' });
							if(splitField.Length==0 || !splitField[0].EndsWith("%")) {
								break;
							}
							splitField[0]=splitField[0].Remove(splitField[0].Length-1,1);//remove %
							percent=PIn.Int(splitField[0]);
							if(percent<0 || percent>100) {
								break;
							}
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Restorative).CovCatNum;
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Endodontics).CovCatNum;
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Periodontics).CovCatNum;
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.OralSurgery).CovCatNum;
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							break;
						case Iap.Major:
							SubCur.BenefitNotes+="\r\n"+"Major: "+field;
							splitField=field.Split(new char[] { ' ' });
							if(splitField.Length==0 || !splitField[0].EndsWith("%")) {
								break;
							}
							splitField[0]=splitField[0].Remove(splitField[0].Length-1,1);//remove %
							percent=PIn.Int(splitField[0]);
							if(percent<0 || percent>100) {
								break;
							}
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Prosthodontics).CovCatNum;//includes crowns?
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							break;
						case Iap.InitialPlacement:
							SubCur.BenefitNotes+="\r\n"+"InitialPlacement: "+field;
							break;
						case Iap.ExtractionClause:
							SubCur.BenefitNotes+="\r\n"+"ExtractionClause: "+field;
							break;
						case Iap.Replacement:
							SubCur.BenefitNotes+="\r\n"+"Replacement: "+field;
							break;
						case Iap.Other:
							SubCur.BenefitNotes+="\r\n"+"Other: "+field;
							break;
						case Iap.Orthodontics:
							SubCur.BenefitNotes+="\r\n"+"Orthodontics: "+field;
							splitField=field.Split(new char[] { ' ' });
							if(splitField.Length==0 || !splitField[0].EndsWith("%")) {
								break;
							}
							splitField[0]=splitField[0].Remove(splitField[0].Length-1,1);//remove %
							percent=PIn.Int(splitField[0]);
							if(percent<0 || percent>100) {
								break;
							}
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.CoInsurance;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
							ben.PlanNum=PlanCur.PlanNum;
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.Percent=percent;
							benefitList.Add(ben.Copy());
							break;
						case Iap.Deductible2:
							SubCur.BenefitNotes+="\r\n"+"Deductible2: "+field;
							break;
						case Iap.Maximum2://ortho Max
							SubCur.BenefitNotes+="\r\n"+"Maximum2: "+field;
							if(field.StartsWith("$")) {
								splitField=field.Split(new char[] { ' ' });
								ben=new Benefit();
								ben.BenefitType=InsBenefitType.Limitations;
								ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
								ben.PlanNum=PlanCur.PlanNum;
								ben.TimePeriod=BenefitTimePeriod.CalendarYear;
								ben.MonetaryAmt=PIn.Double(splitField[0].Remove(0,1));//removes the $
								benefitList.Add(ben.Copy());
							}
							break;
						case Iap.PymtSchedule:
							SubCur.BenefitNotes+="\r\n"+"PymtSchedule: "+field;
							break;
						case Iap.AgeLimit:
							SubCur.BenefitNotes+="\r\n"+"AgeLimit: "+field;
							break;
						case Iap.SignatureonFile:
							SubCur.BenefitNotes+="\r\n"+"SignatureonFile: "+field;
							break;
						case Iap.StandardADAForm:
							SubCur.BenefitNotes+="\r\n"+"StandardADAForm: "+field;
							break;
						case Iap.CoordinationRule:
							SubCur.BenefitNotes+="\r\n"+"CoordinationRule: "+field;
							break;
						case Iap.CoordinationCOB:
							SubCur.BenefitNotes+="\r\n"+"CoordinationCOB: "+field;
							break;
						case Iap.NightguardsforBruxism:
							SubCur.BenefitNotes+="\r\n"+"NightguardsforBruxism: "+field;
							break;
						case Iap.OcclusalAdjustments:
							SubCur.BenefitNotes+="\r\n"+"OcclusalAdjustments: "+field;
							break;
						case Iap.XXXXXX:
							SubCur.BenefitNotes+="\r\n"+"XXXXXX: "+field;
							break;
						case Iap.TMJNonSurgical:
							SubCur.BenefitNotes+="\r\n"+"TMJNonSurgical: "+field;
							break;
						case Iap.Implants:
							SubCur.BenefitNotes+="\r\n"+"Implants: "+field;
							break;
						case Iap.InfectionControl:
							SubCur.BenefitNotes+="\r\n"+"InfectionControl: "+field;
							break;
						case Iap.Cleanings:
							SubCur.BenefitNotes+="\r\n"+"Cleanings: "+field;
							break;
						case Iap.OralEvaluation:
							SubCur.BenefitNotes+="\r\n"+"OralEvaluation: "+field;
							break;
						case Iap.Fluoride1200s:
							SubCur.BenefitNotes+="\r\n"+"Fluoride1200s: "+field;
							break;
						case Iap.Code0220:
							SubCur.BenefitNotes+="\r\n"+"Code0220: "+field;
							break;
						case Iap.Code0272_0274:
							SubCur.BenefitNotes+="\r\n"+"Code0272_0274: "+field;
							break;
						case Iap.Code0210:
							SubCur.BenefitNotes+="\r\n"+"Code0210: "+field;
							break;
						case Iap.Code0330:
							SubCur.BenefitNotes+="\r\n"+"Code0330: "+field;
							break;
						case Iap.SpaceMaintainers:
							SubCur.BenefitNotes+="\r\n"+"SpaceMaintainers: "+field;
							break;
						case Iap.EmergencyExams:
							SubCur.BenefitNotes+="\r\n"+"EmergencyExams: "+field;
							break;
						case Iap.EmergencyTreatment:
							SubCur.BenefitNotes+="\r\n"+"EmergencyTreatment: "+field;
							break;
						case Iap.Sealants1351:
							SubCur.BenefitNotes+="\r\n"+"Sealants1351: "+field;
							break;
						case Iap.Fillings2100:
							SubCur.BenefitNotes+="\r\n"+"Fillings2100: "+field;
							break;
						case Iap.Extractions:
							SubCur.BenefitNotes+="\r\n"+"Extractions: "+field;
							break;
						case Iap.RootCanals:
							SubCur.BenefitNotes+="\r\n"+"RootCanals: "+field;
							break;
						case Iap.MolarRootCanal:
							SubCur.BenefitNotes+="\r\n"+"MolarRootCanal: "+field;
							break;
						case Iap.OralSurgery:
							SubCur.BenefitNotes+="\r\n"+"OralSurgery: "+field;
							break;
						case Iap.ImpactionSoftTissue:
							SubCur.BenefitNotes+="\r\n"+"ImpactionSoftTissue: "+field;
							break;
						case Iap.ImpactionPartialBony:
							SubCur.BenefitNotes+="\r\n"+"ImpactionPartialBony: "+field;
							break;
						case Iap.ImpactionCompleteBony:
							SubCur.BenefitNotes+="\r\n"+"ImpactionCompleteBony: "+field;
							break;
						case Iap.SurgicalProceduresGeneral:
							SubCur.BenefitNotes+="\r\n"+"SurgicalProceduresGeneral: "+field;
							break;
						case Iap.PerioSurgicalPerioOsseous:
							SubCur.BenefitNotes+="\r\n"+"PerioSurgicalPerioOsseous: "+field;
							break;
						case Iap.SurgicalPerioOther:
							SubCur.BenefitNotes+="\r\n"+"SurgicalPerioOther: "+field;
							break;
						case Iap.RootPlaning:
							SubCur.BenefitNotes+="\r\n"+"RootPlaning: "+field;
							break;
						case Iap.Scaling4345:
							SubCur.BenefitNotes+="\r\n"+"Scaling4345: "+field;
							break;
						case Iap.PerioPx:
							SubCur.BenefitNotes+="\r\n"+"PerioPx: "+field;
							break;
						case Iap.PerioComment:
							SubCur.BenefitNotes+="\r\n"+"PerioComment: "+field;
							break;
						case Iap.IVSedation:
							SubCur.BenefitNotes+="\r\n"+"IVSedation: "+field;
							break;
						case Iap.General9220:
							SubCur.BenefitNotes+="\r\n"+"General9220: "+field;
							break;
						case Iap.Relines5700s:
							SubCur.BenefitNotes+="\r\n"+"Relines5700s: "+field;
							break;
						case Iap.StainlessSteelCrowns:
							SubCur.BenefitNotes+="\r\n"+"StainlessSteelCrowns: "+field;
							break;
						case Iap.Crowns2700s:
							SubCur.BenefitNotes+="\r\n"+"Crowns2700s: "+field;
							break;
						case Iap.Bridges6200:
							SubCur.BenefitNotes+="\r\n"+"Bridges6200: "+field;
							break;
						case Iap.Partials5200s:
							SubCur.BenefitNotes+="\r\n"+"Partials5200s: "+field;
							break;
						case Iap.Dentures5100s:
							SubCur.BenefitNotes+="\r\n"+"Dentures5100s: "+field;
							break;
						case Iap.EmpNumberXXX:
							SubCur.BenefitNotes+="\r\n"+"EmpNumberXXX: "+field;
							break;
						case Iap.DateXXX:
							SubCur.BenefitNotes+="\r\n"+"DateXXX: "+field;
							break;
						case Iap.Line4://city state
							SubCur.BenefitNotes+="\r\n"+"Line4: "+field;
							field=field.Replace("  "," ");//get rid of double space before zip
							splitField=field.Split(new char[] { ' ' });
							if(splitField.Length<3) {
								break;
							}
							textCity.Text=splitField[0].Replace(",","");//gets rid of the comma on the end of city
							textState.Text=splitField[1];
							textZip.Text=splitField[2];
							break;
						case Iap.Note:
							SubCur.BenefitNotes+="\r\n"+"Note: "+field;
							break;
						case Iap.Plan://?
							SubCur.BenefitNotes+="\r\n"+"Plan: "+field;
							break;
						case Iap.BuildUps:
							SubCur.BenefitNotes+="\r\n"+"BuildUps: "+field;
							break;
						case Iap.PosteriorComposites:
							SubCur.BenefitNotes+="\r\n"+"PosteriorComposites: "+field;
							break;
					}
				}
				Iap.CloseDatabase();
				butBenefitNotes.Enabled=true;
			}
			catch(ApplicationException ex) {
				Iap.CloseDatabase();
				MessageBox.Show(ex.Message);
			}
			catch(Exception ex) {
				Iap.CloseDatabase();
				MessageBox.Show("Error: "+ex.Message);
			}
			FillBenefits();
		}
Ejemplo n.º 22
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;
		}
Ejemplo n.º 23
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);
		}
Ejemplo n.º 24
0
        public EB271(X12Segment segment, bool isInNetwork, bool isCoinsuranceInverted, X12Segment segHsd = null)
        {
            if (eb01 == null)
            {
                FillDictionaries();
            }
            Segment = segment;
            SupplementalSegments = new List <X12Segment>();
            //start pattern matching to generate closest Benefit
            EB01          eb01val  = eb01.Find(EB01MatchesCode);
            EB02          eb02val  = eb02.Find(EB02MatchesCode);
            EB03          eb03val  = eb03.Find(EB03MatchesCode);
            EB06          eb06val  = eb06.Find(EB06MatchesCode);
            EB09          eb09val  = eb09.Find(EB09MatchesCode);
            ProcedureCode proccode = null;

            if (ProcedureCodes.IsValidCode(Segment.Get(13, 2)))
            {
                proccode = ProcedureCodes.GetProcCode(Segment.Get(13, 2));
            }
            if (!eb01val.IsSupported ||
                (eb02val != null && !eb02val.IsSupported) ||
                (eb03val != null && !eb03val.IsSupported) ||
                (eb06val != null && !eb06val.IsSupported) ||
                (eb09val != null && !eb09val.IsSupported))
            {
                Benefitt = null;
                return;
            }
            if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && Segment.Get(3) == "30")
            {
                Benefitt = null;
                return;
            }
            if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && proccode != null)
            {
                //A code is covered.  Informational only.
                Benefitt = null;
                return;
            }
            if (Segment.Get(8) != "")           //if percentage
            //must have either a category or a proc code
            {
                if (proccode == null)                                                                                                       //if no proc code is specified
                {
                    if (eb03val == null || eb03val.ServiceType == EbenefitCategory.None || eb03val.ServiceType == EbenefitCategory.General) //and no category specified
                    {
                        Benefitt = null;
                        return;
                    }
                }
            }
            //coinsurance amounts are handled with fee schedules rather than benefits
            if (eb01val.BenefitType == InsBenefitType.CoPayment || eb01val.BenefitType == InsBenefitType.CoInsurance)
            {
                if (Segment.Get(7) != "")               //and a monetary amount specified
                {
                    Benefitt = null;
                    return;
                }
            }
            //a limitation without an amount is meaningless
            if (eb01val.BenefitType == InsBenefitType.Limitations &&
                segHsd == null)                 //Some benefits do not have monetary value but limit service in a time period.  Originally done for customer 27936.
            {
                if (Segment.Get(7) == "")       //no monetary amount specified
                {
                    Benefitt = null;
                    return;
                }
            }
            if (isInNetwork && (Segment.Get(12) == "N" || Segment.Get(12) == "U"))
            {
                Benefitt = null;
                return;
            }
            if (!isInNetwork && Segment.Get(12) == "Y")
            {
                Benefitt = null;
                return;
            }
            //if only a quantity is specified with no qualifier, it's meaningless
            if (Segment.Get(10) != "" && eb09val == null)
            {
                Benefitt = null;
                return;
            }
            //if only a qualifier is specified with no quantity, it's meaningless
            if (eb09val != null && Segment.Get(10) == "")
            {
                Benefitt = null;
                return;
            }
            Benefitt = new Benefit();
            //1
            Benefitt.BenefitType = eb01val.BenefitType;
            //2
            if (eb02val != null)
            {
                Benefitt.CoverageLevel = eb02val.CoverageLevel;
            }
            //3
            if (eb03val != null)
            {
                Benefitt.CovCatNum = CovCats.GetForEbenCat(eb03val.ServiceType).CovCatNum;
            }
            //4-Insurance type - we ignore.
            //5-Plan description - we ignore.
            //6
            if (eb06val != null)
            {
                Benefitt.TimePeriod = eb06val.TimePeriod;
            }
            //7
            if (Segment.Get(7) != "")
            {
                Benefitt.MonetaryAmt = PIn.Double(Segment.Get(7));              //Monetary amount. Situational
            }
            //8
            if (Segment.Get(8) != "")
            {
                if (isCoinsuranceInverted && Benefitt.BenefitType == InsBenefitType.CoInsurance) //Some carriers incorrectly send insurance percentage.
                {
                    Benefitt.Percent = (int)(PIn.Double(Segment.Get(8)) * 100);                  //Percent. Came to us inverted, do Not Invert.
                }
                else
                {
                    //OD shows the percentage paid by Insurance by default.
                    //Some carriers submit 271s to us showing percentage paid by Patient, so we need to invert this case to match OD expectations.
                    Benefitt.Percent = 100 - (int)(PIn.Double(Segment.Get(8)) * 100);              //Percent. Invert.
                }
                Benefitt.CoverageLevel = BenefitCoverageLevel.None;
            }
            //9-Quantity qualifier
            if (eb09val != null)
            {
                Benefitt.QuantityQualifier = eb09val.QuantityQualifier;
            }
            //10-Quantity
            if (Segment.Get(10) != "")
            {
                Benefitt.Quantity = (byte)PIn.Double(Segment.Get(10));              //Example: "19.0" with Quantity qualifier "S7" (age).
            }
            //11-Authorization. Ignored.
            //12-In network. Ignored.
            //13-proc
            if (proccode != null)
            {
                Benefitt.CodeNum = proccode.CodeNum;              //element 13,2
            }
            if (Benefitt.BenefitType == InsBenefitType.Limitations &&
                proccode != null &&               //Valid ADA code.
                segHsd != null)
            {
                if (segHsd.Elements.Length < 6 || segHsd.Elements[2] == "" || segHsd.Elements[5] == "")
                {
                    Benefitt = null;
                    return;
                }
                Benefitt.Quantity   = PIn.Byte(segHsd.Elements[2]);                                      //HSD02: Quantity.
                Benefitt.TimePeriod = eb06.FirstOrDefault(x => x.Code == segHsd.Elements[5]).TimePeriod; //HSD05: Frequency.
            }
        }
Ejemplo n.º 25
0
Archivo: BenefitT.cs Proyecto: mnisl/OD
		public static void CreateFrequencyProc(long planNum,string procCodeStr,BenefitQuantity quantityQualifier,Byte quantity){
			Benefit ben=new Benefit();
			ben.PlanNum=planNum;
			ben.BenefitType=InsBenefitType.Limitations;
			ben.CovCatNum=0;
			ben.CodeNum=ProcedureCodes.GetCodeNum(procCodeStr);
			ben.CoverageLevel=BenefitCoverageLevel.None;
			ben.TimePeriod=BenefitTimePeriod.None;
			ben.Quantity=quantity;
			ben.QuantityQualifier=quantityQualifier;
			Benefits.Insert(ben);
		}
Ejemplo n.º 26
0
		private void butAdd_Click(object sender,EventArgs e) {
			Benefit ben=new Benefit();
			ben.PlanNum=PlanNum;
			if(checkCalendarYear.CheckState==CheckState.Checked) {
				ben.TimePeriod=BenefitTimePeriod.CalendarYear;
			}
			if(checkCalendarYear.CheckState==CheckState.Unchecked) {
				ben.TimePeriod=BenefitTimePeriod.ServiceYear;
			}
			if(CovCatC.ListShort.Count>0){
				ben.CovCatNum=CovCatC.ListShort[0].CovCatNum;
			}
			ben.BenefitType=InsBenefitType.CoInsurance;
			FormBenefitEdit FormB=new FormBenefitEdit(PatPlanNum,PlanNum);
			FormB.IsNew=true;
			FormB.BenCur=ben;
			FormB.ShowDialog();
			if(FormB.DialogResult==DialogResult.OK){
				benefitList.Add(FormB.BenCur);
				benefitListAll.Add(FormB.BenCur);
			}
			FillGrid();
		}
Ejemplo n.º 27
0
Archivo: Benefits.cs Proyecto: mnisl/OD
		private static bool TighterLimitExists(List<Benefit> listShort,Benefit benefit,ClaimProcHist claimProcHist){
			if(claimProcHist.StrProcCode=="") {//If this was a 'total' payment that was not attached to a procedure
				//there won't be anything more restrictive.
				return false;
			}
			//The list is not in order by restrictive/broad, so tests will need to be done.
			if(benefit.CodeNum!=0) {//The benefit is already restrictive.  There isn't currently a way to have a more restrictive benefit, although in the future when code ranges are supported, a tighter code range would be more restrictive.
				return false;
			}
			for(int b=0;b<listShort.Count;b++) {
				if(listShort[b].BenefitNum==benefit.BenefitNum) {
					continue;//skip self.
				}
				if(listShort[b].QuantityQualifier!=BenefitQuantity.None) {
					continue;//it must be some other kind of limitation other than an amount limit.  For example, BW frequency.
				}
				if(listShort[b].CodeNum != 0) {
					if(listShort[b].CodeNum==ProcedureCodes.GetCodeNum(claimProcHist.StrProcCode)) {//Enhance later for code ranges when supported by program
						return true;//a tighter limitation benefit exists for this specific procedure code.
					}
				}
				else if(listShort[b].CovCatNum!=0) {//specific category
					if(benefit.CovCatNum!=0) {//If benefit is a category limitation,
						//then we can only consider categories that are more restrictive (further down on list).
						//either of these could be -1 if isHidden
						int orderBenefit=CovCats.GetOrderShort(benefit.CovCatNum);
						int orderTest=CovCats.GetOrderShort(listShort[b].CovCatNum);
						if(orderBenefit==-1) {
							//nothing to do here.  Treat it like a general limitation 
						}
						else if(orderTest<orderBenefit) {//the CovCat of listShort is further up in the list and less restrictive, so should not be considered.
							//this handles orderTest=-1, skipping the hidden category
							continue;
						}
					}
					else {//But if this is a general limitation,
						//then we don't need to do the above check because any match can be considered more restrictive.
					}
					//see if the claimProcHist is in this more restrictive category
					CovSpan[] spansForCat=CovSpans.GetForCat(listShort[b].CovCatNum);//get the spans 
					//This must be a payment that was attached to a proc, so test the proc to be in the coderange of this annual max benefit
					for(int j=0;j<spansForCat.Length;j++) {
						if(String.Compare(claimProcHist.StrProcCode,spansForCat[j].FromCode)>=0 
							&& String.Compare(claimProcHist.StrProcCode,spansForCat[j].ToCode)<=0) 
						{
							return true;
						}
					}
				}
			}
			return false;
		}
Ejemplo n.º 28
0
		///<summary>Only called if in simple view.  This takes all the data on the form and converts it to benefit items.  A new benefitListAll is created based on a combination of benefitList and the new items from the form.  This is used when clicking OK from simple view, or when switching from simple view to complex view.</summary>
		private bool ConvertFormToBenefits(){
			if(textAnnualMax.errorProvider1.GetError(textAnnualMax) != ""
				|| textDeductible.errorProvider1.GetError(textDeductible) != ""
				|| textAnnualMaxFam.errorProvider1.GetError(textAnnualMaxFam) != ""
				|| textDeductibleFam.errorProvider1.GetError(textDeductibleFam) != ""
				|| textFlo.errorProvider1.GetError(textFlo) != ""
				|| textBW.errorProvider1.GetError(textBW) != ""
				|| textPano.errorProvider1.GetError(textPano) != ""
				|| textExams.errorProvider1.GetError(textExams) != ""
				|| textOrthoMax.errorProvider1.GetError(textOrthoMax) != ""
				|| textOrthoPercent.errorProvider1.GetError(textOrthoPercent) != ""
				|| textDeductDiag.errorProvider1.GetError(textDeductDiag) != ""
				|| textDeductXray.errorProvider1.GetError(textDeductXray) != ""
				|| textDeductPrevent.errorProvider1.GetError(textDeductPrevent) != ""
				|| textDeductDiagFam.errorProvider1.GetError(textDeductDiagFam) != ""
				|| textDeductXrayFam.errorProvider1.GetError(textDeductXrayFam) != ""
				|| textDeductPreventFam.errorProvider1.GetError(textDeductPreventFam) != ""
				|| textStand1.errorProvider1.GetError(textStand1) != ""
				|| textStand2.errorProvider1.GetError(textStand2) != ""
				|| textStand4.errorProvider1.GetError(textStand4) != ""
				|| textDiagnostic.errorProvider1.GetError(textDiagnostic) != ""
				|| textXray.errorProvider1.GetError(textXray) != ""
				|| textRoutinePrev.errorProvider1.GetError(textRoutinePrev) != ""
				|| textRestorative.errorProvider1.GetError(textRestorative) != ""
				|| textEndo.errorProvider1.GetError(textEndo) != ""
				|| textPerio.errorProvider1.GetError(textPerio) != ""
				|| textOralSurg.errorProvider1.GetError(textOralSurg) != ""
				|| textCrowns.errorProvider1.GetError(textCrowns) != ""
				|| textProsth.errorProvider1.GetError(textProsth) != ""
				|| textMaxProsth.errorProvider1.GetError(textMaxProsth) != ""
				|| textAccident.errorProvider1.GetError(textAccident) != ""
				|| textMonth.errorProvider1.GetError(textMonth) != ""
				)
			{
				MsgBox.Show(this,"Please fix data entry errors first.");
				return false;
			}
			if(!checkCalendarYear.Checked && textMonth.Text=="") {
				MsgBox.Show(this,"Please enter a starting month for the benefit year.");
				return false;
			}
			/*bool hasIndivid=false;
			if(textAnnualMax.Text != "" || textDeductible.Text != "" || textDeductPrev.Text != "") {
				hasIndivid=true;
			}
			bool hasFam=false;
			if(textAnnualMaxFam.Text != "" || textDeductibleFam.Text != "" || textDeductPrevFam.Text != "") {
				hasFam=true;
			}
			if(hasIndivid && hasFam) {
				MsgBox.Show(this,"You can enter either Individual or Family benefits, but not both.");
				return false;
			}*/
			benefitListAll=new List<Benefit>(benefitList);
			Benefit ben;
			//annual max individual
			if(textAnnualMax.Text !=""){
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked){
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else{
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;					
				}
				ben.MonetaryAmt=PIn.Double(textAnnualMax.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Individual;
				benefitListAll.Add(ben);
			}
			//annual max family
			if(textAnnualMaxFam.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textAnnualMaxFam.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Family;
				benefitListAll.Add(ben);
			}
			//deductible individual
			if(textDeductible.Text !=""){
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else{
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;					
				}
				ben.MonetaryAmt=PIn.Double(textDeductible.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Individual;
				benefitListAll.Add(ben);
			}
			//deductible family
			if(textDeductibleFam.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductibleFam.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Family;
				benefitListAll.Add(ben);
			}
			//Flo
			if(textFlo.Text !=""){
				ben=new Benefit();
				ben.CodeNum=ProcedureCodes.GetCodeNum("D1208");
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				ben.QuantityQualifier=BenefitQuantity.AgeLimit;
				ben.Quantity=PIn.Byte(textFlo.Text);
				benefitListAll.Add(ben);
			}
			//frequency BW
			if(textBW.Text !="") {
				ben=new Benefit();
				ben.CodeNum=ProcedureCodes.GetCodeNum("D0274");//4BW
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				if(comboBW.SelectedIndex==0){
					ben.QuantityQualifier=BenefitQuantity.Years;
				}
				else if(comboBW.SelectedIndex==1){
					ben.QuantityQualifier=BenefitQuantity.NumberOfServices;
					if(checkCalendarYear.Checked) {
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					}
					else {
						ben.TimePeriod=BenefitTimePeriod.ServiceYear;
					}
				}
				else if(comboBW.SelectedIndex==2){
					ben.QuantityQualifier=BenefitQuantity.Months;
				}
				ben.Quantity=PIn.Byte(textBW.Text);
				//ben.TimePeriod is none for years or months, although calYear, or ServiceYear, or Years might work too
				benefitListAll.Add(ben);
			}
			//Frequency pano
			if(textPano.Text !="") {
				ben=new Benefit();
				ben.CodeNum=ProcedureCodes.GetCodeNum("D0330");//Pano
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=0;
				ben.PlanNum=PlanNum;
				if(comboPano.SelectedIndex==0) {
					ben.QuantityQualifier=BenefitQuantity.Years;
				}
				else if(comboPano.SelectedIndex==1) {
					ben.QuantityQualifier=BenefitQuantity.NumberOfServices;
					if(checkCalendarYear.Checked) {
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					}
					else {
						ben.TimePeriod=BenefitTimePeriod.ServiceYear;
					}
				}
				else if(comboPano.SelectedIndex==2) {
					ben.QuantityQualifier=BenefitQuantity.Months;
				}
				ben.Quantity=PIn.Byte(textPano.Text);
				//ben.TimePeriod is none for years or months, although calYear, or ServiceYear, or Years might work too
				benefitListAll.Add(ben);
			}
			//Frequency exam
			if(textExams.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
				ben.PlanNum=PlanNum;
				if(comboExams.SelectedIndex==0) {
					ben.QuantityQualifier=BenefitQuantity.Years;
				}
				else if(comboExams.SelectedIndex==1) {
					ben.QuantityQualifier=BenefitQuantity.NumberOfServices;
					if(checkCalendarYear.Checked) {
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
					}
					else {
						ben.TimePeriod=BenefitTimePeriod.ServiceYear;
					}
				}
				else if(comboExams.SelectedIndex==2) {
					ben.QuantityQualifier=BenefitQuantity.Months;
				}
				ben.Quantity=PIn.Byte(textExams.Text);
				//ben.TimePeriod is none for years or months, although calYear, or ServiceYear, or Years might work too
				benefitListAll.Add(ben);
			}
			//ortho max
			if(textOrthoMax.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Limitations;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
				ben.PlanNum=PlanNum;
				ben.TimePeriod=BenefitTimePeriod.Lifetime;
				ben.MonetaryAmt=PIn.Double(textOrthoMax.Text);
				benefitListAll.Add(ben);
			}
			//ortho percent
			if(textOrthoPercent.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
				ben.Percent=PIn.Int(textOrthoPercent.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//deductible diagnostic individual
			if(textDeductDiag.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductDiag.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Individual;
				benefitListAll.Add(ben);
			}
			//deductible diagnostic family
			if(textDeductDiagFam.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductDiagFam.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Family;
				benefitListAll.Add(ben);
			}
			//deductible xray individual
			if(textDeductXray.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.DiagnosticXRay).CovCatNum;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductXray.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Individual;
				benefitListAll.Add(ben);
			}
			//deductible xray family
			if(textDeductXrayFam.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.DiagnosticXRay).CovCatNum;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductXrayFam.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Family;
				benefitListAll.Add(ben);
			}
			//deductible preventive individual
			if(textDeductPrevent.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductPrevent.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Individual;
				benefitListAll.Add(ben);
			}
			//deductible preventive family
			if(textDeductPreventFam.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.Deductible;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				ben.MonetaryAmt=PIn.Double(textDeductPreventFam.Text);
				ben.CoverageLevel=BenefitCoverageLevel.Family;
				benefitListAll.Add(ben);
			}
			//Diagnostic
			if(textDiagnostic.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
				ben.Percent=PIn.Int(textDiagnostic.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//X-Ray
			if(textXray.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.DiagnosticXRay).CovCatNum;
				ben.Percent=PIn.Int(textXray.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//RoutinePreventive
			if(textRoutinePrev.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
				ben.Percent=PIn.Int(textRoutinePrev.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//Restorative
			if(textRestorative.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Restorative).CovCatNum;
				ben.Percent=PIn.Int(textRestorative.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//Endo
			if(textEndo.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Endodontics).CovCatNum;
				ben.Percent=PIn.Int(textEndo.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//Perio
			if(textPerio.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Periodontics).CovCatNum;
				ben.Percent=PIn.Int(textPerio.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//OralSurg
			if(textOralSurg.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.OralSurgery).CovCatNum;
				ben.Percent=PIn.Int(textOralSurg.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//Crowns
			if(textCrowns.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Crowns).CovCatNum;
				ben.Percent=PIn.Int(textCrowns.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//Prosth
			if(textProsth.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Prosthodontics).CovCatNum;
				ben.Percent=PIn.Int(textProsth.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//MaxProsth
			if(textMaxProsth.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.MaxillofacialProsth).CovCatNum;
				ben.Percent=PIn.Int(textMaxProsth.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			//Accident
			if(textAccident.Text !="") {
				ben=new Benefit();
				ben.CodeNum=0;
				ben.BenefitType=InsBenefitType.CoInsurance;
				ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Accident).CovCatNum;
				ben.Percent=PIn.Int(textAccident.Text);
				ben.PlanNum=PlanNum;
				if(checkCalendarYear.Checked) {
					ben.TimePeriod=BenefitTimePeriod.CalendarYear;
				}
				else {
					ben.TimePeriod=BenefitTimePeriod.ServiceYear;
				}
				benefitListAll.Add(ben);
			}
			return true;
		}
Ejemplo n.º 29
0
Archivo: Benefits.cs Proyecto: mnisl/OD
		/*
		///<summary>Was used in FormInsPlan when applying changes to all identical plans.  Needs to be removed. 1. Deletes any benefits where the benefitNum is not found in the new list.  2. Adds any new Benefits (BenefitNum=0) found in the new list.  It does not test to see whether any benefits with the same BenefitNum have changed, because FormInsBenefits never changes existing benefits.</summary>
		public static void UpdateListForIdentical(List<Benefit> oldBenefitList,List<Benefit> newBenefitList,List<long> planNums) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),oldBenefitList,newBenefitList,planNums);
				return;
			}
			string command;
			Benefit newBenefit;
			string plansInString="";//comma delimited
			for(int p=0;p<planNums.Count;p++){
				if(p>0){
					plansInString+=",";
				}
				plansInString+=planNums[p].ToString();
			}
			//1. Delete any benefits where the benefitNum is not found in the new list.--------------------------------------------
			for(int i=0;i<oldBenefitList.Count;i++) {//loop through the old list
				newBenefit=null;
				for(int j=0;j<newBenefitList.Count;j++) {
					if(newBenefitList[j]==null || newBenefitList[j].BenefitNum==0) {
						continue;
					}
					if(oldBenefitList[i].BenefitNum==newBenefitList[j].BenefitNum) {
						newBenefit=newBenefitList[j];//a matching benefitNum was found in the new list
						break;
					}
				}
				if(newBenefit==null) {
					//benefit with matching benefitNum was not found, so it must have been deleted
					//delete all identical benefits from other plans and this plan
					command="DELETE FROM benefit WHERE PlanNum IN("+plansInString+") "
						+"AND CovCatNum="+POut.Long(oldBenefitList[i].CovCatNum)+" "
						+"AND BenefitType="+POut.Int((int)oldBenefitList[i].BenefitType)+" "
						+"AND Percent="+POut.Int(oldBenefitList[i].Percent)+" "
						+"AND MonetaryAmt="+POut.Double(oldBenefitList[i].MonetaryAmt)+" "
						+"AND TimePeriod="+POut.Int((int)oldBenefitList[i].TimePeriod)+" "
						+"AND QuantityQualifier="+POut.Int((int)oldBenefitList[i].QuantityQualifier)+" "
						+"AND Quantity="+POut.Int(oldBenefitList[i].Quantity)+" "
						+"AND CodeNum="+POut.Long(oldBenefitList[i].CodeNum)+" "
						+"AND CoverageLevel="+POut.Int((int)oldBenefitList[i].CoverageLevel);
					Db.NonQ(command);
				}
			}
			//2. Add any new Benefits (BenefitNum=0) found in the new list.-------------------------------------------------------
			for(int i=0;i<newBenefitList.Count;i++) {//loop through the new list
				if(newBenefitList[i].BenefitNum==0 && newBenefitList[i].PlanNum!=0) {//the benefit is new, and it is a plan benefit rather than a patient benefit.
					for(int p=0;p<planNums.Count;p++){//loop through each plan
						newBenefit=newBenefitList[i].Copy();//we need to leave the one in the list with BenefitNum=0 for testing further down.
						newBenefit.PlanNum=planNums[p];
						Insert(newBenefit);
					}
				}
			}
			//3. Alter any changed benefits.----------------------------------------------------------------------------------------
			//These will only be from the Other Benefits list, because the normal benefits are changed by using a delete and insert.
			for(int i=0;i<oldBenefitList.Count;i++) {//loop through the old list
				newBenefit=null;
				for(int j=0;j<newBenefitList.Count;j++) {
					if(newBenefitList[j]==null || newBenefitList[j].BenefitNum==0) {
						continue;
					}
					if(oldBenefitList[i].BenefitNum==newBenefitList[j].BenefitNum) {
						newBenefit=newBenefitList[j];//a matching benefitNum was found in the new list
						break;
					}
				}
				if(newBenefit==null){
					continue;//no match found
				}
				if(//newBenefit.PlanNum             != oldBenefitList[i].PlanNum
					//|| newBenefit.PatPlanNum        != oldBenefitList[i].PatPlanNum
						 newBenefit.CovCatNum         != oldBenefitList[i].CovCatNum
					|| newBenefit.BenefitType       != oldBenefitList[i].BenefitType
					|| newBenefit.Percent           != oldBenefitList[i].Percent
					|| newBenefit.MonetaryAmt       != oldBenefitList[i].MonetaryAmt
					|| newBenefit.TimePeriod        != oldBenefitList[i].TimePeriod
					|| newBenefit.QuantityQualifier != oldBenefitList[i].QuantityQualifier
					|| newBenefit.Quantity          != oldBenefitList[i].Quantity
					|| newBenefit.CodeNum           != oldBenefitList[i].CodeNum 
					|| newBenefit.CoverageLevel     != oldBenefitList[i].CoverageLevel) 
				{
					//changed=true;
					//break;
					//change the identical benefit for all other plans
					command="UPDATE benefit SET " 
						//+"PlanNum = '"          +POut.Long   (ben.PlanNum)+"'"
						//+",PatPlanNum = '"      +POut.Long   (ben.PatPlanNum)+"'"
						+"CovCatNum = '"        +POut.Long   (newBenefit.CovCatNum)+"'"
						+",BenefitType = '"     +POut.Long   ((int)newBenefit.BenefitType)+"'"
						+",Percent = '"         +POut.Long   (newBenefit.Percent)+"'"
						+",MonetaryAmt = '"     +POut.Double (newBenefit.MonetaryAmt)+"'"
						+",TimePeriod = '"      +POut.Long   ((int)newBenefit.TimePeriod)+"'"
						+",QuantityQualifier ='"+POut.Long   ((int)newBenefit.QuantityQualifier)+"'"
						+",Quantity = '"        +POut.Long   (newBenefit.Quantity)+"'"
						+",CodeNum = '"         +POut.Long   (newBenefit.CodeNum)+"'"
						+",CoverageLevel = '"   +POut.Long   ((int)newBenefit.CoverageLevel)+"' "
						+"WHERE PlanNum IN("+plansInString+") "
						+"AND CovCatNum="+POut.Long(oldBenefitList[i].CovCatNum)+" "
						+"AND BenefitType="+POut.Int((int)oldBenefitList[i].BenefitType)+" "
						+"AND Percent="+POut.Int(oldBenefitList[i].Percent)+" "
						+"AND MonetaryAmt="+POut.Double(oldBenefitList[i].MonetaryAmt)+" "
						+"AND TimePeriod="+POut.Int((int)oldBenefitList[i].TimePeriod)+" "
						+"AND QuantityQualifier="+POut.Int((int)oldBenefitList[i].QuantityQualifier)+" "
						+"AND Quantity="+POut.Int(oldBenefitList[i].Quantity)+" "
						+"AND CodeNum="+POut.Long(oldBenefitList[i].CodeNum)+" "
						+"AND CoverageLevel="+POut.Int((int)oldBenefitList[i].CoverageLevel);
					Db.NonQ(command);
				}
			}
			//might be a good idea to compute estimates for each plan now.
		}*/

		///<summary>Used in family module display to get a list of benefits.  The main purpose of this function is to group similar benefits for each plan on the same row, making it easier to display in a simple grid.  Supply a list of all benefits for the patient, and the patPlans for the patient.</summary>
		public static Benefit[,] GetDisplayMatrix(List <Benefit> bensForPat,List<PatPlan> patPlanList,List<InsSub> subList){
			//No need to check RemotingRole; no call to db.
			ArrayList AL=new ArrayList();//each object is a Benefit[]
			Benefit[] row;
			ArrayList refAL=new ArrayList();//each object is a Benefit from any random column. Used when searching for a type.
			InsSub sub;
			for(int i=0;i<bensForPat.Count;i++) {
				for(int j=0;j<patPlanList.Count;j++) {//loop through columns
					sub=InsSubs.GetSub(patPlanList[j].InsSubNum,subList);
					if(patPlanList[j].PatPlanNum!=bensForPat[i].PatPlanNum
						&& sub.PlanNum!=bensForPat[i].PlanNum) 
					{
						continue;//Benefit doesn't apply to this column
					}
					//search refAL for a matching type that already exists
					row=null;
					for(int k=0;k<refAL.Count;k++) {
						if(((Benefit)refAL[k]).CompareTo(bensForPat[i])==0) {//if the type is equivalent
							row=(Benefit[])AL[k];
							break;
						}
					}
					//if no matching type found, add a row, and use that row
					if(row==null) {
						refAL.Add(bensForPat[i].Copy());
						row=new Benefit[patPlanList.Count];
						row[j]=bensForPat[i].Copy();
						AL.Add(row);
						continue;
					}
					//if the column for the matching row is null, then use that row
					if(row[j]==null) {
						row[j]=bensForPat[i].Copy();
						continue;
					}
					//if not null, then add another row.
					refAL.Add(bensForPat[i].Copy());
					row=new Benefit[patPlanList.Count];
					row[j]=bensForPat[i].Copy();
					AL.Add(row);
				}
			}
			IComparer myComparer = new BenefitArraySorter();
			AL.Sort(myComparer);
			Benefit[,] retVal=new Benefit[patPlanList.Count,AL.Count];
			for(int y=0;y<AL.Count;y++){
				for(int x=0;x<patPlanList.Count;x++){
					if(((Benefit[])AL[y])[x]!=null){
						retVal[x,y]=((Benefit[])AL[y])[x].Copy();
					}
				}
			}
			return retVal;
		}
Ejemplo n.º 30
0
Archivo: EB271.cs Proyecto: mnisl/OD
		public EB271(X12Segment segment,bool isInNetwork) {
			if(eb01==null) {
				FillDictionaries();
			}
			Segment=segment;
			SupplementalSegments=new List<X12Segment>();
			//start pattern matching to generate closest Benefit
			EB01 eb01val=eb01.Find(EB01MatchesCode);
			EB02 eb02val=eb02.Find(EB02MatchesCode);
			EB03 eb03val=eb03.Find(EB03MatchesCode);
			EB06 eb06val=eb06.Find(EB06MatchesCode);
			EB09 eb09val=eb09.Find(EB09MatchesCode);
			ProcedureCode proccode=null;
			if(ProcedureCodes.IsValidCode(Segment.Get(13,2))) {
				proccode=ProcedureCodes.GetProcCode(Segment.Get(13,2));
			}
			if(!eb01val.IsSupported
				|| (eb02val!=null && !eb02val.IsSupported)
				|| (eb03val!=null && !eb03val.IsSupported)
				|| (eb06val!=null && !eb06val.IsSupported)
				|| (eb09val!=null && !eb09val.IsSupported)) 
			{
				Benefitt=null;
				return;
			}
			if(eb01val.BenefitType==InsBenefitType.ActiveCoverage	&& Segment.Get(3)=="30") {
				Benefitt=null;
				return;
			}
			if(eb01val.BenefitType==InsBenefitType.ActiveCoverage && proccode!=null) {
				//A code is covered.  Informational only.
				Benefitt=null;
				return;
			}
			if(Segment.Get(8)!="") {//if percentage
				//must have either a category or a proc code
				if(proccode==null) {//if no proc code is specified
					if(eb03val==null || eb03val.ServiceType==EbenefitCategory.None || eb03val.ServiceType==EbenefitCategory.General) {//and no category specified
						Benefitt=null;
						return;
					}
				}
			}
			//coinsurance amounts are handled with fee schedules rather than benefits
			if(eb01val.BenefitType==InsBenefitType.CoPayment || eb01val.BenefitType==InsBenefitType.CoInsurance) {
				if(Segment.Get(7)!="") {//and a monetary amount specified
					Benefitt=null;
					return;
				}
			}
			//a limitation without an amount is meaningless
			if(eb01val.BenefitType==InsBenefitType.Limitations) {
				if(Segment.Get(7)=="") {//no monetary amount specified
					Benefitt=null;
					return;
				}
			}
			if(isInNetwork && Segment.Get(12)=="N") {
				Benefitt=null;
				return;
			}
			if(!isInNetwork && Segment.Get(12)=="Y") {
				Benefitt=null;
				return;
			}
			//if only a quantity is specified with no qualifier, it's meaningless
			if(Segment.Get(10)!="" && eb09val==null) {
				Benefitt=null;
				return;
			}
			//if only a qualifier is specified with no quantity, it's meaningless
			if(eb09val!=null && Segment.Get(10)=="") {
				Benefitt=null;
				return;
			}
			Benefitt=new Benefit();
			//1
			Benefitt.BenefitType=eb01val.BenefitType;
			//2
			if(eb02val!=null) {
				Benefitt.CoverageLevel=eb02val.CoverageLevel;
			}
			//3
			if(eb03val!=null) {
				Benefitt.CovCatNum=CovCats.GetForEbenCat(eb03val.ServiceType).CovCatNum;
			}
			//4-Insurance type - we ignore.
			//5-Plan description - we ignore.
			//6
			if(eb06val!=null) {
				Benefitt.TimePeriod=eb06val.TimePeriod;
			}
			//7
			if(Segment.Get(7)!="") {
				Benefitt.MonetaryAmt=PIn.Double(Segment.Get(7));//Monetary amount. Situational
			}
			//8
			if(Segment.Get(8)!="") {
				Benefitt.Percent=100-(int)(PIn.Double(Segment.Get(8))*100);//Percent. Situational
				Benefitt.CoverageLevel=BenefitCoverageLevel.None;
			}
			//9-Quantity qualifier
			if(eb09val!=null) {
				Benefitt.QuantityQualifier=eb09val.QuantityQualifier;
			}
			//10-Quantity
			if(Segment.Get(10)!="") {
				Benefitt.Quantity=(byte)PIn.Double(Segment.Get(10));//Example: "19.0" with Quantity qualifier "S7" (age).
			}
			//11-Authorization. Ignored.
			//12-In network. Ignored.
			//13-proc
			if(proccode!=null) {
				Benefitt.CodeNum=proccode.CodeNum;//element 13,2
			}
		}
Ejemplo n.º 31
0
Archivo: Benefits.cs Proyecto: mnisl/OD
		public static int SortBenefits(Benefit b1,Benefit b2){
			return b1.ToString().CompareTo(b2.ToString());
		}
Ejemplo n.º 32
0
		///<summary>Converts the text for one plan into an object which will then be processed as needed.</summary>
		public static TrojanObject ProcessTextToObject(string text){
			string[] lines=text.Split(new string[] { "\r\n" },StringSplitOptions.RemoveEmptyEntries);
			string line;
			string[] fields;
			int percent;
			double amt;
			string rowVal;
			TrojanObject troj=new TrojanObject();
			troj.BenefitList=new List<Benefit>();
			troj.BenefitNotes="";
			bool usesAnnivers=false;
			Benefit ben;
			Benefit benCrownMajor=null;
			Benefit benCrownOnly=null;
      for(int i=0;i<lines.Length;i++){
				line=lines[i];
				fields=line.Split(new char[] {'\t'});
				if(fields.Length!=3){
					continue;
				}
				//remove any trailing or leading spaces:
				fields[0]=fields[0].Trim();
				fields[1]=fields[1].Trim();
				fields[2]=fields[2].Trim();
				rowVal=fields[2].Trim();
				if(fields[2]==""){
					continue;
				}
				else{//as long as there is data, add it to the notes
					if(troj.BenefitNotes!="") {
						troj.BenefitNotes+="\r\n";
					}
					troj.BenefitNotes+=fields[1]+": "+fields[2];
					if(fields.Length==4) {
						troj.BenefitNotes+=" "+fields[3];
					}
				}
				switch(fields[0]){
					//default://for all rows that are not handled below
					case "TROJANID":
						troj.TROJANID=fields[2];
						break;
					case "ENAME":
						troj.ENAME=fields[2];
						break;
					case "PLANDESC":
						troj.PLANDESC=fields[2];
						break;
					case "ELIGPHONE":
						troj.ELIGPHONE=fields[2];
						break;
					case "POLICYNO":
						troj.POLICYNO=fields[2];
						break;
					case "ECLAIMS":
						if(fields[2]=="YES") {//accepts eclaims
							troj.ECLAIMS=true;
						}
						else {
							troj.ECLAIMS=false;
						}
						break;
					case "PAYERID":
						troj.PAYERID=fields[2];
						break;
					case "MAILTO":
						troj.MAILTO=fields[2];
						break;
					case "MAILTOST":
						troj.MAILTOST=fields[2];
						break;
					case "MAILCITYONLY":
						troj.MAILCITYONLY=fields[2];
						break;
					case "MAILSTATEONLY":
						troj.MAILSTATEONLY=fields[2];
						break;
					case "MAILZIPONLY":
						troj.MAILZIPONLY=fields[2];
						break;
					case "PLANMAX"://eg $3000 per person per year
						if(!fields[2].StartsWith("$"))
							break;
						fields[2]=fields[2].Remove(0,1);
						fields[2]=fields[2].Split(new char[] { ' ' })[0];
						if(CovCatC.ListShort.Count>0) {
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.Limitations;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
							ben.MonetaryAmt=PIn.Double(fields[2]);
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							ben.CoverageLevel=BenefitCoverageLevel.Individual;
							troj.BenefitList.Add(ben.Copy());
						}
						break;
					case "PLANYR"://eg Calendar year or Anniversary year
						if(fields[2]!="Calendar year") {
							usesAnnivers=true;
							//MessageBox.Show("Warning.  Plan uses Anniversary year rather than Calendar year.  Please verify the Plan Start Date.");
						}
						break;
					case "DEDUCT"://eg There is no deductible
						if(!fields[2].StartsWith("$")) {
							amt=0;
						}
						else {
							fields[2]=fields[2].Remove(0,1);
							fields[2]=fields[2].Split(new char[] { ' ' })[0];
							amt=PIn.Double(fields[2]);
						}
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.Deductible;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.General).CovCatNum;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						ben.MonetaryAmt=amt;
						ben.CoverageLevel=BenefitCoverageLevel.Individual;
						troj.BenefitList.Add(ben.Copy());
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.Deductible;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						ben.MonetaryAmt=0;//amt;
						ben.CoverageLevel=BenefitCoverageLevel.Individual;
						troj.BenefitList.Add(ben.Copy());
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.Deductible;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						ben.MonetaryAmt=0;//amt;
						ben.CoverageLevel=BenefitCoverageLevel.Individual;
						troj.BenefitList.Add(ben.Copy());
						break;
					case "PREV"://eg 100% or 'Incentive begins at 70%' or '80% Endo Major see notes'
						if(rowVal.ToLower()=="not covered") {
							percent=0;
						}
						else {
							percent=ConvertPercentToInt(rowVal);//remove %
						}
						if(percent<0 || percent>100) {
							break;
						}
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Diagnostic).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.RoutinePreventive).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						break;
					case "BASIC":
						if(rowVal.ToLower()=="not covered") {
							percent=0;
						}
						else {
							percent=ConvertPercentToInt(rowVal);//remove %
						}
						if(percent<0 || percent>100) {
							break;
						}
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Restorative).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Endodontics).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Periodontics).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.OralSurgery).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						break;
					case "MAJOR":
						if(rowVal.ToLower()=="not covered") {
							percent=0;
						}
						else {
							percent=ConvertPercentToInt(rowVal);//remove %
						}
						if(percent<0 || percent>100) {
							break;
						}
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Prosthodontics).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						benCrownMajor=new Benefit();
						benCrownMajor.BenefitType=InsBenefitType.CoInsurance;
						benCrownMajor.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Crowns).CovCatNum;
						benCrownMajor.Percent=percent;
						benCrownMajor.TimePeriod=BenefitTimePeriod.CalendarYear;
						//troj.BenefitList.Add(ben.Copy());//later
						break;
					case "CROWNS"://Examples: Paid Major, or 80%.  We will only process percentages.
						if(rowVal.ToLower()=="not covered") {
							percent=0;
						}
						else {
							percent=ConvertPercentToInt(rowVal);//remove %
						}
						if(percent<0 || percent>100) {
							break;
						}
						benCrownOnly=new Benefit();
						benCrownOnly.BenefitType=InsBenefitType.CoInsurance;
						benCrownOnly.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Crowns).CovCatNum;
						benCrownOnly.Percent=percent;
						benCrownOnly.TimePeriod=BenefitTimePeriod.CalendarYear;
						//troj.BenefitList.Add(ben.Copy());
						break;
					case "ORMAX"://eg $3500 lifetime
						if(!fields[2].StartsWith("$")) {
							break;
						}
						fields[2]=fields[2].Remove(0,1);
						fields[2]=fields[2].Split(new char[] { ' ' })[0];
						if(CovCatC.ListShort.Count>0) {
							ben=new Benefit();
							ben.BenefitType=InsBenefitType.Limitations;
							ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
							ben.MonetaryAmt=PIn.Double(fields[2]);
							ben.TimePeriod=BenefitTimePeriod.CalendarYear;
							troj.BenefitList.Add(ben.Copy());
						}
						break;
					case "ORPCT":
						if(rowVal.ToLower()=="not covered") {
							percent=0;
						}
						else {
							percent=ConvertPercentToInt(rowVal);//remove %
						}
						if(percent<0 || percent>100) {
							break;
						}
						ben=new Benefit();
						ben.BenefitType=InsBenefitType.CoInsurance;
						ben.CovCatNum=CovCats.GetForEbenCat(EbenefitCategory.Orthodontics).CovCatNum;
						ben.Percent=percent;
						ben.TimePeriod=BenefitTimePeriod.CalendarYear;
						troj.BenefitList.Add(ben.Copy());
						break;
					/*case "FEE":
						if(!ProcedureCodes.IsValidCode(fields[1])) {
							break;//skip
						}
						if(textTrojanID.Text==""){
							break;
						}
						feeSchedNum=Fees.ImportTrojan(fields[1],PIn.PDouble(fields[3]),textTrojanID.Text);
						//the step above probably created a new feeschedule, requiring a reset of the three listboxes.
						resetFeeSched=true;
						break;*/
					case "NOTES"://typically multiple instances
						if(troj.PlanNote!=null && troj.PlanNote!="") {
							troj.PlanNote+="\r\n";
						}
						troj.PlanNote+=fields[2];
						break;
				}//switch
			}//for
			//Set crowns
			if(benCrownOnly!=null){
				troj.BenefitList.Add(benCrownOnly.Copy());
			}
			else if(benCrownMajor!=null){
				troj.BenefitList.Add(benCrownMajor.Copy());
			}
			//set calendar vs serviceyear
			if(usesAnnivers) {
				for(int i=0;i<troj.BenefitList.Count;i++) {
					troj.BenefitList[i].TimePeriod=BenefitTimePeriod.ServiceYear;
				}
			}
			return troj;
		}
Ejemplo n.º 33
0
 ///<summary>Returns true if most of the fields match except BenefitNum</summary>
 public bool IsSimilar(Benefit ben)
 {
     if(//PlanNum             != oldBenefitList[i].PlanNum
         //|| PatPlanNum        != oldBenefitList[i].PatPlanNum
              CovCatNum         != ben.CovCatNum
         || BenefitType       != ben.BenefitType
         || Percent           != ben.Percent
         || MonetaryAmt       != ben.MonetaryAmt
         || TimePeriod        != ben.TimePeriod
         || QuantityQualifier != ben.QuantityQualifier
         || Quantity          != ben.Quantity
         || CodeNum           != ben.CodeNum
         || CoverageLevel     != ben.CoverageLevel)
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 34
0
		private void butDelete_Click(object sender, System.EventArgs e) {
			BenCur=null;
			if(IsNew){
				DialogResult=DialogResult.Cancel;
				return;
			}
			DialogResult=DialogResult.OK;
		}