예제 #1
0
파일: Benefits.cs 프로젝트: 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;
		}
예제 #2
0
파일: Benefits.cs 프로젝트: nampn/ODental
 /*
 ///<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;
 }