Example #1
0
		///<summary>Updates only the changed columns.</summary>
		public static bool Update(Procedure procedure,Procedure oldProcedure) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				return Meth.GetBool(MethodBase.GetCurrentMethod(),procedure,oldProcedure);
			}
			if(oldProcedure.ProcStatus!=ProcStat.C && procedure.ProcStatus==ProcStat.C && procedure.Discount!=0) {//Setting the procedure to complete
				Adjustments.CreateAdjustmentForDiscount(procedure);
			}
			if(oldProcedure.ProcStatus==ProcStat.C && procedure.ProcStatus!=ProcStat.C) {//Setting a completed procedure to TP
				Adjustments.DeleteForProcedure(procedure.ProcNum);
			}
			bool result=Crud.ProcedureCrud.Update(procedure,oldProcedure);
			if(procedure.Note!=oldProcedure.Note
				|| procedure.UserNum!=oldProcedure.UserNum
				|| procedure.SigIsTopaz!=oldProcedure.SigIsTopaz
				|| procedure.Signature!=oldProcedure.Signature) 
			{
				ProcNote note=new ProcNote();
				note.PatNum=procedure.PatNum;
				note.ProcNum=procedure.ProcNum;
				note.UserNum=procedure.UserNum;
				note.Note=procedure.Note;
				note.SigIsTopaz=procedure.SigIsTopaz;
				note.Signature=procedure.Signature;
				ProcNotes.Insert(note);
			}
			return result;
		}
Example #2
0
		public static void SetComplete(Procedure proc,Patient pat,List<InsPlan> planList,List<PatPlan> patPlanList,List<ClaimProc> claimProcList,List<Benefit> benefitList,List<InsSub> subList) {
			Procedure procOld=proc.Copy();
			ProcedureCode procCode=ProcedureCodes.GetProcCode(proc.CodeNum);
			proc.DateEntryC=DateTime.Now;
			proc.ProcStatus=ProcStat.C;
			Procedures.Update(proc,procOld);
			Procedures.ComputeEstimates(proc,proc.PatNum,claimProcList,false,planList,patPlanList,benefitList,pat.Age,subList);

		}
Example #3
0
File: ProcTC.cs Project: mnisl/OD
		///<summary>The tooth number passed in should be in international format.</summary>
		public static void SetExtracted(string toothNumInternat, DateTime procDate,long patNum) {
			Procedure proc=new Procedure();
			proc.CodeNum=ProcedureCodes.GetCodeNum("71101");
			proc.PatNum=patNum;
			proc.ProcDate=procDate;
			proc.ToothNum=Tooth.FromInternat(toothNumInternat);
			proc.ProcStatus=ProcStat.EO;
			Procedures.Insert(proc);
			ToothInitialTC.SetMissing(toothNumInternat,patNum);
		}
Example #4
0
File: ProcTC.cs Project: mnisl/OD
		///<summary>Procedure will have a completed status.  For surfaces, since the scripts are faulty, pass in the exact surfaces that should be in the db, no validation will be done, and those exact same surfaces are what will go out on claim.</summary>
		public static Procedure AddProc(string procCode,long patNum,DateTime procDate,string toothNum,string surf,double fee,string typeCodes,long provNum) {
			Procedure proc=new Procedure();
			ProcedureCode procedureCode=ProcedureCodes.GetProcCode(procCode);
			//procnum
			proc.PatNum=patNum;
			//aptnum
			proc.CodeNum=procedureCode.CodeNum;
			proc.ProcDate=procDate;
			proc.DateTP=proc.ProcDate;
			proc.ProcFee=fee;
			switch(toothNum) {
				case "":
					proc.ToothNum="";
					proc.Surf=surf;
					break;
				case "10":
					proc.ToothNum="";
					proc.Surf="UR";
					break;
				case "20":
					proc.ToothNum="";
					proc.Surf="UL";
					break;
				case "30":
					proc.ToothNum="";
					proc.Surf="LL";
					break;
				case "40":
					proc.ToothNum="";
					proc.Surf="LR";
					break;
				default:
					proc.ToothNum=Tooth.FromInternat(toothNum);
					proc.Surf=surf;//Tooth.SurfTidyFromDisplayToDb(surf,proc.ToothNum);
					break;
			}
			//ToothRange
			proc.Priority=0;
			proc.ProcStatus=ProcStat.C;
			proc.ProvNum=provNum;
			proc.Note="";
			proc.ClinicNum=0;
			//proc.Dx
			proc.MedicalCode="";
			proc.BaseUnits=0;
			proc.SiteNum=0;
			//nextaptnum
			proc.CanadianTypeCodes=typeCodes;
			Procedures.Insert(proc);
			//if an extraction, then mark previous procs hidden.  Skip.
			//Recalls.Synch(PatCur.PatNum);//skip
			//Procedures.ComputeEstimates(proc,patNum,new List<ClaimProc>(),true,planList,patPlanList,benefitList,age);
			return proc;
		}
Example #5
0
		/// <summary>Returns the proc</summary>
		public static Procedure CreateProcedure(Patient pat,string procCodeStr,ProcStat procStatus,string toothNum,double procFee){
			Procedure proc=new Procedure();
			proc.CodeNum=ProcedureCodes.GetCodeNum(procCodeStr);
			proc.PatNum=pat.PatNum;
			proc.ProcDate=DateTime.Today;
			proc.ProcStatus=procStatus;
			proc.ProvNum=pat.PriProv;
			proc.ProcFee=procFee;
			proc.ToothNum=toothNum;
			proc.Prosthesis="I";
			Procedures.Insert(proc);
			return proc;
		}
Example #6
0
		///<summary>Creates securitylog entry for a completed procedure.  Set toothNum to empty string and it will be omitted from the log entry. toothNums can be null or empty.</summary>
		public static void LogProcComplCreate(long patNum,Procedure procCur,string toothNums) {
			//No need to check RemotingRole; no call to db.
			if(procCur==null) {
				return;//Nothing to do.  Should never happen.
			}
			ProcedureCode procCode=ProcedureCodes.GetProcCode(procCur.CodeNum);
			string logText=procCode.ProcCode+", ";
			if(toothNums!=null && toothNums.Trim()!="") {
				logText+=Lans.g("Procedures","Teeth")+": "+toothNums+", ";
			}
			logText+=Lans.g("Procedures","Fee")+": "+procCur.ProcFee.ToString("F")+", "+procCode.Descript;
			SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate,patNum,logText);
		}
Example #7
0
		///<summary></summary>
		public static long Insert(Procedure procedure){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				procedure.ProcNum=Meth.GetLong(MethodBase.GetCurrentMethod(),procedure);
				return procedure.ProcNum;
			}
			Crud.ProcedureCrud.Insert(procedure);
			if(procedure.Note!="") {
				ProcNote note=new ProcNote();
				note.PatNum=procedure.PatNum;
				note.ProcNum=procedure.ProcNum;
				note.UserNum=procedure.UserNum;
				note.Note=procedure.Note;
				ProcNotes.Insert(note);
			}
			return procedure.ProcNum;
		}
Example #8
0
		///<summary>Updates only the changed columns.</summary>
		public static void Update(Procedure procedure,Procedure oldProcedure) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),procedure,oldProcedure);
				return;
			}
			Crud.ProcedureCrud.Update(procedure,oldProcedure);
			if(procedure.Note!=oldProcedure.Note
				|| procedure.UserNum!=oldProcedure.UserNum
				|| procedure.SigIsTopaz!=oldProcedure.SigIsTopaz
				|| procedure.Signature!=oldProcedure.Signature) 
			{
				ProcNote note=new ProcNote();
				note.PatNum=procedure.PatNum;
				note.ProcNum=procedure.ProcNum;
				note.UserNum=procedure.UserNum;
				note.Note=procedure.Note;
				note.SigIsTopaz=procedure.SigIsTopaz;
				note.Signature=procedure.Signature;
				ProcNotes.Insert(note);
			}
		}
Example #9
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     RepeatCharge[] chargeList=RepeatCharges.Refresh(0);
     int countAdded=0;
     DateTime possibleDate;
     Procedure proc;
     for(int i=0;i<chargeList.Length;i++){
         if(chargeList[i].DateStart>DateTime.Today){//not started yet
             continue;
         }
         //if(chargeList[i].DateStop.Year>1880//not blank
         //	&& chargeList[i].DateStop<DateTime.Today)//but already ended
         //{
         //	continue;
         //}
         //get a list dates of all completed procedures with this Code and patNum
         ArrayList ALdates=RepeatCharges.GetDates(ProcedureCodes.GetCodeNum(chargeList[i].ProcCode),chargeList[i].PatNum);
         possibleDate=chargeList[i].DateStart;
         //start looping through possible dates, beginning with the start date of the repeating charge
         while(possibleDate<=DateTime.Today){
             if(possibleDate<DateTime.Today.AddMonths(-3)){
                 possibleDate=possibleDate.AddMonths(1);
                 continue;//don't go back more than three months
             }
             //check to see if the possible date is present in the list
             if(ALdates.Contains(possibleDate)){
                 possibleDate=possibleDate.AddMonths(1);
                 continue;
             }
             if(chargeList[i].DateStop.Year>1880//not blank
                 && chargeList[i].DateStop < possibleDate)//but already ended
             {
                 break;
             }
             //otherwise, insert a procedure to db
             proc=new Procedure();
             proc.CodeNum=ProcedureCodes.GetCodeNum(chargeList[i].ProcCode);
             proc.DateEntryC=DateTime.Today;
             proc.PatNum=chargeList[i].PatNum;
             proc.ProcDate=possibleDate;
             proc.DateTP=possibleDate;
             proc.ProcFee=chargeList[i].ChargeAmt;
             proc.ProcStatus=ProcStat.C;
             proc.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
             proc.MedicalCode=ProcedureCodes.GetProcCode(proc.CodeNum).MedicalCode;
             proc.BaseUnits = ProcedureCodes.GetProcCode(proc.CodeNum).BaseUnits;
             Procedures.Insert(proc);//no recall synch needed because dental offices don't use this feature
             countAdded++;
             possibleDate=possibleDate.AddMonths(1);
         }
     }
     MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added."));
     DialogResult=DialogResult.OK;
 }
Example #10
0
		///<summary>Tests to see if this appointment will create a double booking. Returns arrayList with no items in it if no double bookings for this appt.  But if double booking, then it returns an arrayList of codes which would be double booked.  You must supply the appointment being scheduled as well as a list of all appointments for that day.  The list can include the appointment being tested if user is moving it to a different time on the same day.  The ProcsForOne list of procedures needs to contain the procedures for the apt becauese procsMultApts won't necessarily, especially if it's a planned appt on the pinboard.</summary>
		public static ArrayList GetDoubleBookedCodes(Appointment apt,DataTable dayTable,List<Procedure> procsMultApts,Procedure[] procsForOne) {
			ArrayList retVal=new ArrayList();//codes
			//figure out which provider we are testing for
			long provNum;
			if(apt.IsHygiene){
				provNum=apt.ProvHyg;
			}
			else{
				provNum=apt.ProvNum;
			}
			//compute the starting row of this appt
			int convertToY=(int)(((double)apt.AptDateTime.Hour*(double)60
				/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)
				+(double)apt.AptDateTime.Minute
				/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)
				)*(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr);
			int startIndex=convertToY/ApptDrawing.LineH;//rounds down
			string pattern=ApptSingleDrawing.GetPatternShowing(apt.Pattern);
			//keep track of which rows in the entire day would be occupied by provider time for this appt
			ArrayList aptProvTime=new ArrayList();
			for(int k=0;k<pattern.Length;k++){
				if(pattern.Substring(k,1)=="X"){
					aptProvTime.Add(startIndex+k);//even if it extends past midnight, we don't care
				}
			}
			//Now, loop through all the other appointments for the day, and see if any would overlap this one
			bool overlaps;
			Procedure[] procs;
			bool doubleBooked=false;//applies to all appts, not just one at a time.
			DateTime aptDateTime;
			for(int i=0;i<dayTable.Rows.Count;i++){
				if(dayTable.Rows[i]["AptNum"].ToString()==apt.AptNum.ToString()){//ignore current apt in its old location
					continue;
				}
				//ignore other providers
				if(dayTable.Rows[i]["IsHygiene"].ToString()=="1" && dayTable.Rows[i]["ProvHyg"].ToString()!=provNum.ToString()){
					continue;
				}
				if(dayTable.Rows[i]["IsHygiene"].ToString()=="0" && dayTable.Rows[i]["ProvNum"].ToString()!=provNum.ToString()){
					continue;
				}
				if(dayTable.Rows[i]["AptStatus"].ToString()==((int)ApptStatus.Broken).ToString()){//ignore broken appts
					continue;
				}
				aptDateTime=PIn.DateT(dayTable.Rows[i]["AptDateTime"].ToString());
				if(ApptDrawing.IsWeeklyView && aptDateTime.Date==apt.AptDateTime.Date){
					continue;
				}
				//calculate starting row
				//this math is copied from another section of the program, so it's sloppy. Safer than trying to rewrite it:
				convertToY=(int)(((double)aptDateTime.Hour*(double)60
					/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)
					+(double)aptDateTime.Minute
					/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)
					)*(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr);
				startIndex=convertToY/ApptDrawing.LineH;//rounds down
				pattern=ApptSingleDrawing.GetPatternShowing(dayTable.Rows[i]["Pattern"].ToString());
				//now compare it to apt
				overlaps=false;
				for(int k=0;k<pattern.Length;k++){
					if(pattern.Substring(k,1)=="X"){
						if(aptProvTime.Contains(startIndex+k)){
							overlaps=true;
							doubleBooked=true;
						}
					}
				}
				if(overlaps){
					//we need to add all codes for this appt to retVal
					procs=Procedures.GetProcsOneApt(PIn.Long(dayTable.Rows[i]["AptNum"].ToString()),procsMultApts);
					for(int j=0;j<procs.Length;j++){
						retVal.Add(ProcedureCodes.GetStringProcCode(procs[j].CodeNum));
					}
				}
			}
			//now, retVal contains all double booked procs except for this appt
			//need to all procs for this appt.
			if(doubleBooked){
				for(int j=0;j<procsForOne.Length;j++) {
					retVal.Add(ProcedureCodes.GetStringProcCode(procsForOne[j].CodeNum));
				}
			}
			return retVal;
		}
Example #11
0
		/*
		///<summary>Only used in GetSearchResults.  All times between start and stop get set to true in provBarSched.</summary>
		private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){
			int startI=GetProvBarIndex(timeStart);
			int stopI=GetProvBarIndex(timeStop);
			for(int i=startI;i<=stopI;i++){
				provBarSched[i]=true;
			}
		}

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

		///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule.  This method creates the appointment and attaches all appropriate procedures.  It's up to the calling class to then place the appointment on the pinboard.  If the appointment doesn't get scheduled, it's important to delete it.  If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary>
		public static Appointment CreateRecallApt(Patient patCur,List<Procedure> procList,List<InsPlan> planList,long recallNum,List<InsSub> subList){
			List<Recall> recallList=Recalls.GetList(patCur.PatNum);
			Recall recallCur=null;
			if(recallNum>0) {
				recallCur=Recalls.GetRecall(recallNum);
			}
			else{
				for(int i=0;i<recallList.Count;i++){
					if(recallList[i].RecallTypeNum==RecallTypes.PerioType || recallList[i].RecallTypeNum==RecallTypes.ProphyType){
						if(!recallList[i].IsDisabled){
							recallCur=recallList[i];
						}
						break;
					}
				}
			}
			if(recallCur==null){// || recallCur.DateDue.Year<1880){
				throw new ApplicationException(Lan.g("AppointmentL","No special type recall is due."));//Typically never happens because everyone has a recall.  However, it can happen when patients have custom recalls due
			}
			if(recallCur.DateScheduled.Date>DateTime.Today) {
				throw new ApplicationException(Lan.g("AppointmentL","Recall has already been scheduled for ")+recallCur.DateScheduled.ToShortDateString());
			}
			Appointment AptCur=new Appointment();
			AptCur.PatNum=patCur.PatNum;
			AptCur.AptStatus=ApptStatus.UnschedList;//In all places where this is used, the unsched status with no aptDateTime will cause the appt to be deleted when the pinboard is cleared.
			if(patCur.PriProv==0){
				AptCur.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
			}
			else{
				AptCur.ProvNum=patCur.PriProv;
			}
			AptCur.ProvHyg=patCur.SecProv;
			if(AptCur.ProvHyg!=0){
				AptCur.IsHygiene=true;
			}
			AptCur.ClinicNum=patCur.ClinicNum;
			//whether perio or prophy:
			List<string> procs=RecallTypes.GetProcs(recallCur.RecallTypeNum);
			string recallPattern=RecallTypes.GetTimePattern(recallCur.RecallTypeNum);
			if(RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)
				&& patCur.Birthdate.AddYears(PrefC.GetInt(PrefName.RecallAgeAdult)) > ((recallCur.DateDue>DateTime.Today)?recallCur.DateDue:DateTime.Today)) //For example, if pt's 12th birthday falls after recall date.
			{
				for(int i=0;i<RecallTypeC.Listt.Count;i++) {
					if(RecallTypeC.Listt[i].RecallTypeNum==RecallTypes.ChildProphyType) {
						List<string> childprocs=RecallTypes.GetProcs(RecallTypeC.Listt[i].RecallTypeNum);
						if(childprocs.Count>0) {
							procs=childprocs;//overrides adult procs.
						}
						string childpattern=RecallTypes.GetTimePattern(RecallTypeC.Listt[i].RecallTypeNum);
						if(childpattern!="") {
							recallPattern=childpattern;//overrides adult pattern.
						}
					}
				}
			}
			//convert time pattern to 5 minute increment
			StringBuilder savePattern=new StringBuilder();
			for(int i=0;i<recallPattern.Length;i++){
				savePattern.Append(recallPattern.Substring(i,1));
				if(PrefC.GetLong(PrefName.AppointmentTimeIncrement)==10) {
					savePattern.Append(recallPattern.Substring(i,1));
				}
				if(PrefC.GetLong(PrefName.AppointmentTimeIncrement)==15){
					savePattern.Append(recallPattern.Substring(i,1));
					savePattern.Append(recallPattern.Substring(i,1));
				}
			}
			if(savePattern.ToString()==""){
				if(PrefC.GetLong(PrefName.AppointmentTimeIncrement)==15){
					savePattern.Append("///XXX///");
				}
				else{
					savePattern.Append("//XX//");
				}
			}
			AptCur.Pattern=savePattern.ToString();
			//Add films------------------------------------------------------------------------------------------------------
			if(RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)){//if this is a prophy or perio
				for(int i=0;i<recallList.Count;i++){
					if(recallCur.RecallNum==recallList[i].RecallNum){
						continue;//already handled.
					}
					if(recallList[i].IsDisabled){
						continue;
					}
					if(recallList[i].DateDue.Year<1880){
						continue;
					}
					if(recallList[i].DateDue>recallCur.DateDue//if film due date is after prophy due date
						&& recallList[i].DateDue>DateTime.Today)//and not overdue
					{
						continue;
					}
					//incomplete: exclude manual recall types
					procs.AddRange(RecallTypes.GetProcs(recallList[i].RecallTypeNum));
				}
			}
			AptCur.ProcDescript="";
			AptCur.ProcsColored="";
			for(int i=0;i<procs.Count;i++) {
				string procDescOne="";
				if(i>0){
					AptCur.ProcDescript+=", ";
				}
				procDescOne+=ProcedureCodes.GetProcCode(procs[i]).AbbrDesc;
				AptCur.ProcDescript+=procDescOne;
				//Color and previous date are determined by ProcApptColor object
				ProcApptColor pac=ProcApptColors.GetMatch(procs[i]);
				System.Drawing.Color pColor=System.Drawing.Color.Black;
				string prevDateString="";
				if(pac!=null){
					pColor=pac.ColorText;
					if(pac.ShowPreviousDate) {
						prevDateString=Procedures.GetRecentProcDateString(AptCur.PatNum,AptCur.AptDateTime,pac.CodeRange);
						if(prevDateString!="") {
							prevDateString=" ("+prevDateString+")";
						}
					}
				}
				AptCur.ProcsColored+="<span color=\""+pColor.ToArgb().ToString()+"\">"+procDescOne+prevDateString+"</span>";
			}
			AptCur.TimeLocked=PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
			Appointments.Insert(AptCur);
			Procedure ProcCur;
			List <PatPlan> patPlanList=PatPlans.Refresh(patCur.PatNum);
			List <Benefit> benefitList=Benefits.Refresh(patPlanList,subList);
			InsPlan priplan=null;
			InsSub prisub=null;
			if(patPlanList.Count>0) {
				prisub=InsSubs.GetSub(patPlanList[0].InsSubNum,subList);
				priplan=InsPlans.GetPlan(prisub.PlanNum,planList);
			}
			double insfee;
			double standardfee;
			for(int i=0;i<procs.Count;i++){
				ProcCur=new Procedure();//this will be an insert
				//procnum
				ProcCur.PatNum=patCur.PatNum;
				ProcCur.AptNum=AptCur.AptNum;
				ProcCur.CodeNum=ProcedureCodes.GetCodeNum(procs[i]);
				ProcCur.ProcDate=DateTime.Now;
				ProcCur.DateTP=DateTime.Now;
				//Check if it's a medical procedure.
				bool isMed = false;
				ProcCur.MedicalCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode;
				if(ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") {
					isMed = true;
				}
				//Get fee schedule for medical or dental.
				long feeSch;
				if(isMed) {
					feeSch=Fees.GetMedFeeSched(patCur,planList,patPlanList,subList);
				}
				else {
					feeSch=Fees.GetFeeSched(patCur,planList,patPlanList,subList);
				}
				//Get the fee amount for medical or dental.
				if(PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) {
					insfee=Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum,feeSch);
				}
				else {
					insfee=Fees.GetAmount0(ProcCur.CodeNum,feeSch);
				}
				if(priplan!=null && priplan.PlanType=="p") {//PPO
					standardfee=Fees.GetAmount0(ProcCur.CodeNum,Providers.GetProv(Patients.GetProvNum(patCur)).FeeSched);
					if(standardfee>insfee) {
						ProcCur.ProcFee=standardfee;
					}
					else {
						ProcCur.ProcFee=insfee;
					}
				}
				else {
					ProcCur.ProcFee=insfee;
				}
				//surf
				//toothnum
				//Procedures.Cur.ToothRange="";
				//ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.CodeNum).NoBillIns;
				//priority
				ProcCur.ProcStatus=ProcStat.TP;
				ProcCur.Note="";
				//Procedures.Cur.PriEstim=
				//Procedures.Cur.SecEstim=
				//claimnum
				ProcCur.ProvNum=patCur.PriProv;
				//Procedures.Cur.Dx=
				ProcCur.ClinicNum=patCur.ClinicNum;
				//nextaptnum
				ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits;
				ProcCur.DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
				Procedures.Insert(ProcCur);//no recall synch required
				Procedures.ComputeEstimates(ProcCur,patCur.PatNum,new List<ClaimProc>(),false,planList,patPlanList,benefitList,patCur.Age,subList);
				if(Programs.UsingOrion){
					FormProcEdit FormP=new FormProcEdit(ProcCur,patCur.Copy(),Patients.GetFamily(patCur.PatNum));
					FormP.IsNew=true;
					FormP.ShowDialog();
					if(FormP.DialogResult==DialogResult.Cancel){
						//any created claimprocs are automatically deleted from within procEdit window.
						try{
							Procedures.Delete(ProcCur.ProcNum);//also deletes the claimprocs
						}
						catch(Exception ex){
							MessageBox.Show(ex.Message);
						}
					}
					else{
						//Do not synch. Recalls based on ScheduleByDate reports in Orion mode.
						//Recalls.Synch(PatCur.PatNum);
					}
				}
			}
			return AptCur;
		}
Example #12
0
		private void listQuickAdd_MouseDown(object sender,System.Windows.Forms.MouseEventArgs e) {
			if(comboProvNum.SelectedIndex==-1){
				MsgBox.Show(this,"Please select a dentist.");
				return;
			}
			if(listQuickAdd.IndexFromPoint(e.X,e.Y)==-1) {
				return;
			}
			if(AptCur.AptStatus==ApptStatus.Complete) {
				//added procedures would be marked complete when form closes. We'll just stop it here.
				if(!Security.IsAuthorized(Permissions.ProcComplCreate)) {
					return;
				}
			}
			Procedures.SetDateFirstVisit(AptCur.AptDateTime.Date,1,pat);
			List<PatPlan> PatPlanList=PatPlans.Refresh(AptCur.PatNum);
			List<Benefit> benefitList=Benefits.Refresh(PatPlanList,SubList);
			List<ClaimProc> ClaimProcList=ClaimProcs.Refresh(AptCur.PatNum);
			string[] codes=DefC.Short[(int)DefCat.ApptProcsQuickAdd][listQuickAdd.IndexFromPoint(e.X,e.Y)].ItemValue.Split(',');
			for(int i=0;i<codes.Length;i++) {
				if(!ProcedureCodeC.HList.ContainsKey(codes[i])) {
					MsgBox.Show(this,"Definition contains invalid code.");
					return;
				}
			}
			for(int i=0;i<codes.Length;i++) {
				Procedure ProcCur=new Procedure();
				ProcCur.PatNum=AptCur.PatNum;
				if(AptCur.AptStatus!=ApptStatus.Planned) {
					ProcCur.AptNum=AptCur.AptNum;
				}
				ProcCur.CodeNum=ProcedureCodes.GetProcCode(codes[i]).CodeNum;
				ProcCur.ProcDate=AptCur.AptDateTime.Date;
				ProcCur.DateTP=DateTimeOD.Today;
				InsPlan priplan=null;
				InsSub prisub=null;
				if(PatPlanList.Count>0) {
					prisub=InsSubs.GetSub(PatPlanList[0].InsSubNum,SubList);
					priplan=InsPlans.GetPlan(prisub.PlanNum,PlanList);
				}
				//Check if it's a medical procedure.
				double insfee;
				bool isMed = false;
				ProcCur.MedicalCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode;
				if(ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") {
					isMed = true;
				}
				//Get fee schedule for medical or dental.
				long feeSch;
				if(isMed) {
					feeSch=Fees.GetMedFeeSched(pat,PlanList,PatPlanList,SubList);
				}
				else {
					feeSch=Fees.GetFeeSched(pat,PlanList,PatPlanList,SubList);
				}
				//Get the fee amount for medical or dental.
				if(PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) {
					insfee=Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum,feeSch);
				}
				else {
					insfee=Fees.GetAmount0(ProcCur.CodeNum,feeSch);
				}
				if(priplan!=null && priplan.PlanType=="p") {//PPO
					double standardfee=Fees.GetAmount0(ProcCur.CodeNum,Providers.GetProv(Patients.GetProvNum(pat)).FeeSched);
					if(standardfee>insfee) {
						ProcCur.ProcFee=standardfee;
					}
					else {
						ProcCur.ProcFee=insfee;
					}
				}
				else {
					ProcCur.ProcFee=insfee;
				}
				//surf
				//toothnum
				//toothrange
				//priority
				ProcCur.ProcStatus=ProcStat.TP;
				//procnote
				if(ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProvNumDefault==0) {//Override ProvNum if there is a default provider for this proc
					ProcCur.ProvNum=ProviderC.ListShort[comboProvNum.SelectedIndex].ProvNum;//Normal behavior
				}
				else {
					ProcCur.ProvNum=ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProvNumDefault;//New behavior for procs with default provider
				}
				//Dx
				ProcCur.ClinicNum=AptCur.ClinicNum;
				ProcCur.SiteNum=pat.SiteNum;
				ProcCur.RevCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum).RevenueCodeDefault;
				if(AptCur.AptStatus==ApptStatus.Planned) {
					ProcCur.PlannedAptNum=AptCur.AptNum;
				}
				ProcCur.BaseUnits=ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits;
				ProcCur.DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
				Procedures.Insert(ProcCur);//recall synch not required
				if(Programs.UsingOrion){//Orion requires a DPC for every procedure. Force proc edit window open.
					FormProcEdit FormP=new FormProcEdit(ProcCur,pat.Copy(),fam);
					FormP.IsNew=true;
					FormP.OrionDentist=true;
					FormP.ShowDialog();
					if(FormP.DialogResult==DialogResult.Cancel) {
						try {
							Procedures.Delete(ProcCur.ProcNum);//also deletes the claimprocs
						}
						catch(Exception ex) {
							MessageBox.Show(ex.Message);
						}
					}
				}
				Procedures.ComputeEstimates(ProcCur,pat.PatNum,ClaimProcList,false,PlanList,PatPlanList,benefitList,pat.Age,SubList);
			}
			listQuickAdd.SelectedIndex=-1;
			string[] selectedProcs=new string[gridProc.SelectedIndices.Length];
			for(int i=0;i<selectedProcs.Length;i++) {
				selectedProcs[i]=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ProcNum"].ToString();
			}
			DS.Tables.Remove("Procedure");
			DS.Tables.Add(Appointments.GetApptEdit(AptCur.AptNum).Tables["Procedure"].Copy());
			FillProcedures();
			for(int i=0;i<gridProc.Rows.Count;i++) {
				for(int j=0;j<selectedProcs.Length;j++) {
					if(selectedProcs[j]==DS.Tables["Procedure"].Rows[i]["ProcNum"].ToString()) {
						gridProc.SetSelected(i,true);
					}
				}
			}
			CalculateTime();
			FillTime();
			CalcPatientFeeThisAppt();
		}
Example #13
0
 ///<summary>Used when creating a claim to create any missing claimProcs. Also used in FormProcEdit if click button to add Estimate.  Inserts it into db. It will still be altered after this to fill in the fields that actually attach it to the claim.</summary>
 public static void CreateEst(ClaimProc cp, Procedure proc, InsPlan plan,InsSub sub)
 {
     //No need to check RemotingRole; no call to db.
     cp.ProcNum=proc.ProcNum;
     //claimnum
     cp.PatNum=proc.PatNum;
     cp.ProvNum=proc.ProvNum;
     if(plan.PlanType=="c") {//capitation
         if(proc.ProcStatus==ProcStat.C) {//complete
             cp.Status=ClaimProcStatus.CapComplete;//in this case, a copy will be made later.
         }
         else {//usually TP status
             cp.Status=ClaimProcStatus.CapEstimate;
         }
     }
     else {
         cp.Status=ClaimProcStatus.Estimate;
     }
     cp.PlanNum=plan.PlanNum;
     cp.InsSubNum=sub.InsSubNum;
     cp.DateCP=proc.ProcDate;
     //Writeoff=0
     cp.AllowedOverride=-1;
     cp.Percentage=-1;
     cp.PercentOverride=-1;
     cp.CopayAmt=-1;
     cp.NoBillIns=false;
     cp.PaidOtherIns=-1;
     cp.BaseEst=0;
     cp.DedEst=-1;
     cp.DedEstOverride=-1;
     cp.InsEstTotal=0;
     cp.InsEstTotalOverride=-1;
     cp.CopayOverride=-1;
     cp.PaidOtherInsOverride=-1;
     cp.ProcDate=proc.ProcDate;
     cp.WriteOffEst=-1;
     cp.WriteOffEstOverride=-1;
     cp.ClinicNum=proc.ClinicNum;
     Insert(cp);
 }
Example #14
0
File: Dutch.cs Project: mnisl/OD
		/// <summary>Returns either 0,1,or 2</summary>
		public static string GetUL(Procedure proc,ProcedureCode procCode) {
			if(procCode.TreatArea==TreatmentArea.Arch) {
				if(proc.Surf=="U") {
					return "1";
				}
				if(proc.Surf=="L") {
					return "2";
				}
				return "0";//should never happen
			}
			else {
				return "0";
			}
		}
Example #15
0
		private void FormProcGroup_Load(object sender, System.EventArgs e){
			IsOpen=true;
			IsStartingUp=true;
			//ProcList gets set in ContrChart where this form is created.
			PatCur=Patients.GetPat(GroupCur.PatNum);
			FamCur=Patients.GetFamily(GroupCur.PatNum);
			GroupOld=GroupCur.Copy();
			ProcListOld=new List<Procedure>();
			for(int i=0;i<ProcList.Count;i++){
				ProcListOld.Add(ProcList[i].Copy());
			}
			ModifyForOrionMode();
			textProcDate.Text=GroupCur.ProcDate.ToShortDateString();
			textDateEntry.Text=GroupCur.DateEntryC.ToShortDateString();
			textUser.Text=Userods.GetName(GroupCur.UserNum);//might be blank. Will change automatically if user changes note or alters sig.
			textNotes.Text=GroupCur.Note;
			if(GroupCur.ProcStatus==ProcStat.EC && PrefC.GetBool(PrefName.ProcLockingIsAllowed) && !GroupCur.IsLocked) {
				butLock.Visible=true;
			}
			else {
				butLock.Visible=false;
			}
			if(GroupCur.IsLocked) {//Whether locking is currently allowed, this proc group may have been locked previously.
				butOK.Enabled=false;
				butDelete.Enabled=false;
				labelLocked.Visible=true;
				butAppend.Visible=true;
				textNotes.ReadOnly=true;//just for visual cue.  No way to save changes, anyway.
				textNotes.BackColor=SystemColors.Control;
				butInvalidate.Visible=true;
				butInvalidate.Location=butLock.Location;
			}
			else {
				butInvalidate.Visible=false;
				//because islocked overrides security:
				if(!Security.IsAuthorized(Permissions.ProcComplEdit,GroupCur.DateEntryC)) {
					butOK.Enabled=false;
					butDelete.Enabled=false;
				}
			}
			if(GroupCur.ProcStatus==ProcStat.D) {//an invalidated proc
				labelInvalid.Visible=true;
				butInvalidate.Visible=false;
				labelLocked.Visible=false;
				butAppend.Visible=false;
				butOK.Enabled=false;
				butDelete.Enabled=false;
			}
			FillProcedures();
			textNotes.Select();
			string keyData=GetSignatureKey();
			signatureBoxWrapper.FillSignature(GroupCur.SigIsTopaz,keyData,GroupCur.Signature);
			signatureBoxWrapper.BringToFront();
			FillPatientData();
			FillPlanned();
			textNotes.Select(textNotes.Text.Length,0);
			IsStartingUp=false;
			//string retVal=GroupCur.Note+GroupCur.UserNum.ToString();
			//MsgBoxCopyPaste msgb=new MsgBoxCopyPaste(retVal);
			//msgb.ShowDialog();
		}
Example #16
0
		///<summary>Calculates the Base estimate, InsEstTotal, and all the other insurance numbers for a single claimproc.  This is is not done on the fly.  Use Procedure.GetEst to later retrieve the estimate. This function replaces all of the upper estimating logic that was within FormClaimProc.  BaseEst=((fee or allowedOverride)-Copay) x (percentage or percentOverride).  The calling class must have already created the claimProc, and this function simply updates the BaseEst field of that claimproc. pst.Tot not used.  For Estimate and CapEstimate, all the estimate fields will be recalculated except the overrides.  histList and loopList can be null.  If so, then deductible and annual max will not be recalculated.  histList and loopList may only make sense in TP module and claimEdit.  loopList contains all claimprocs in the current list (TP or claim) that come before this procedure.  PaidOtherInsTot should only contain sum of InsEstTotal/Override, or paid, depending on the status.  PaidOtherInsBase also includes actual payments.</summary>
		public static void ComputeBaseEst(ClaimProc cp,Procedure proc,InsPlan plan,long patPlanNum,List<Benefit> benList,List<ClaimProcHist> histList,List<ClaimProcHist> loopList,List<PatPlan> patPlanList,double paidOtherInsTot,double paidOtherInsBase,int patientAge,double writeOffOtherIns) {
			//No need to check RemotingRole; no call to db.
			double procFee=proc.ProcFee*Math.Max(1,proc.BaseUnits+proc.UnitQty);
			string toothNum=proc.ToothNum;
			long codeNum=proc.CodeNum;
			if(cp.Status==ClaimProcStatus.CapClaim
				|| cp.Status==ClaimProcStatus.CapComplete
				|| cp.Status==ClaimProcStatus.Preauth
				|| cp.Status==ClaimProcStatus.Supplemental) {
				return;//never compute estimates for those types listed above.
			}
			if(plan.PlanType=="c"//if capitation plan
				&& cp.Status==ClaimProcStatus.Estimate)//and ordinary estimate
			{
				cp.Status=ClaimProcStatus.CapEstimate;
			}
			if(plan.PlanType!="c"//if not capitation plan
				&& cp.Status==ClaimProcStatus.CapEstimate)//and estimate is a capitation estimate
			{
				cp.Status=ClaimProcStatus.Estimate;
			}
			//NoBillIns is only calculated when creating the claimproc, even if resetAll is true.
			//If user then changes a procCode, it does not cause an update of all procedures with that code.
			if(cp.NoBillIns) {
				cp.AllowedOverride=-1;
				cp.CopayAmt=0;
				cp.CopayOverride=-1;
				cp.Percentage=-1;
				cp.PercentOverride=-1;
				cp.DedEst=-1;
				cp.DedEstOverride=-1;
				cp.PaidOtherIns=-1;
				cp.BaseEst=0;
				cp.InsEstTotal=0;
				cp.InsEstTotalOverride=-1;
				cp.WriteOff=0;
				cp.PaidOtherInsOverride=-1;
				cp.WriteOffEst=-1;
				cp.WriteOffEstOverride=-1;
				return;
			}
			cp.EstimateNote="";
			//This function is called every time a ProcFee is changed,
			//so the BaseEst does reflect the new ProcFee.
			//ProcFee----------------------------------------------------------------------------------------------
			cp.BaseEst=procFee;
			cp.InsEstTotal=procFee;
			//Allowed----------------------------------------------------------------------------------------------
			double allowed=procFee;//could be fee, or could be a little less.  Used further down in paidOtherIns.
			if(cp.AllowedOverride!=-1) {
				if(cp.AllowedOverride > procFee){
					cp.AllowedOverride=procFee;
				}
				allowed=cp.AllowedOverride;
				cp.BaseEst=cp.AllowedOverride;
				cp.InsEstTotal=cp.AllowedOverride;
			}
			else if(plan.PlanType=="c"){//capitation estimate.  No allowed fee sched.  No substitute codes.
				allowed=procFee;
				cp.BaseEst=procFee;
				cp.InsEstTotal=procFee;
			}
			else {
				//no point in wasting time calculating this unless it's needed.
				double carrierAllowed=InsPlans.GetAllowed(ProcedureCodes.GetProcCode(codeNum).ProcCode,plan.FeeSched,plan.AllowedFeeSched,
					plan.CodeSubstNone,plan.PlanType,toothNum,cp.ProvNum);
				if(carrierAllowed != -1) {
					carrierAllowed=carrierAllowed*Math.Max(1,proc.BaseUnits+proc.UnitQty);
					if(carrierAllowed > procFee) {
						allowed=procFee;
						cp.BaseEst=procFee;
						cp.InsEstTotal=procFee;
					}
					else {
						allowed=carrierAllowed;
						cp.BaseEst=carrierAllowed;
						cp.InsEstTotal=carrierAllowed;
					}
				}
			}
			//Copay----------------------------------------------------------------------------------------------
			cp.CopayAmt=InsPlans.GetCopay(codeNum,plan.FeeSched,plan.CopayFeeSched,plan.CodeSubstNone,toothNum);
			if(cp.CopayAmt!=-1) {
				cp.CopayAmt=cp.CopayAmt*Math.Max(1,proc.BaseUnits+proc.UnitQty);
			}
			if(cp.CopayAmt > allowed) {//if the copay is greater than the allowed fee calculated above
				cp.CopayAmt=allowed;//reduce the copay
			}
			if(cp.CopayOverride > allowed) {//or if the copay override is greater than the allowed fee calculated above
				cp.CopayOverride=allowed;//reduce the override
			}
			if(cp.Status==ClaimProcStatus.CapEstimate) {
				//this does automate the Writeoff. If user does not want writeoff automated,
				//then they will have to complete the procedure first. (very rare)
				if(cp.CopayAmt==-1) {
					cp.CopayAmt=0;
				}
				if(cp.CopayOverride != -1) {//override the copay
					cp.WriteOffEst=cp.BaseEst-cp.CopayOverride;
				}
				else if(cp.CopayAmt!=-1) {//use the calculated copay
					cp.WriteOffEst=cp.BaseEst-cp.CopayAmt;
				}
				if(cp.WriteOffEst<0) {
					cp.WriteOffEst=0;
				}
				cp.WriteOff=cp.WriteOffEst;
				cp.DedApplied=0;
				cp.DedEst=0;
				cp.Percentage=-1;
				cp.PercentOverride=-1;
				cp.BaseEst=0;
				cp.InsEstTotal=0;
				return;
			}
			if(cp.CopayOverride != -1) {//subtract copay if override
				cp.BaseEst-=cp.CopayOverride;
				cp.InsEstTotal-=cp.CopayOverride;
			}
			else if(cp.CopayAmt != -1) {//otherwise subtract calculated copay
				cp.BaseEst-=cp.CopayAmt;
				cp.InsEstTotal-=cp.CopayAmt;
			}
			//Deductible----------------------------------------------------------------------------------------
			//The code below handles partial usage of available deductible. 
			DateTime procDate;
			if(cp.Status==ClaimProcStatus.Estimate) {
				procDate=DateTime.Today;
			}
			else {
				procDate=cp.ProcDate;
			}
			if(loopList!=null && histList!=null) {
				cp.DedEst=Benefits.GetDeductibleByCode(benList,plan.PlanNum,patPlanNum,procDate,ProcedureCodes.GetStringProcCode(codeNum),histList,loopList,plan,cp.PatNum);
			}
			if(Benefits.GetPercent(ProcedureCodes.GetProcCode(codeNum).ProcCode,plan.PlanType,plan.PlanNum,patPlanNum,benList)==0) {//this is binary
				cp.DedEst=0;//Procedure is not covered. Do not apply deductible. This does not take into account percent override.
			}
			if(cp.DedEst > cp.InsEstTotal){//if the deductible is more than the fee
				cp.DedEst=cp.InsEstTotal;//reduce the deductible
			}
			if(cp.DedEstOverride > cp.InsEstTotal) {//if the deductible override is more than the fee
				cp.DedEstOverride=cp.InsEstTotal;//reduce the override.
			}
			if(cp.DedEstOverride != -1) {//use the override
				cp.InsEstTotal-=cp.DedEstOverride;//subtract
			}
			else if(cp.DedEst != -1){//use the calculated deductible
				cp.InsEstTotal-=cp.DedEst;
			}
			//Percentage----------------------------------------------------------------------------------------
			cp.Percentage=Benefits.GetPercent(ProcedureCodes.GetProcCode(codeNum).ProcCode,plan.PlanType,plan.PlanNum,patPlanNum,benList);//will never =-1
			if(cp.PercentOverride != -1) {//override, so use PercentOverride
				cp.BaseEst=cp.BaseEst*(double)cp.PercentOverride/100d;
				cp.InsEstTotal=cp.InsEstTotal*(double)cp.PercentOverride/100d;
			}
			else if(cp.Percentage != -1) {//use calculated Percentage
				cp.BaseEst=cp.BaseEst*(double)cp.Percentage/100d;
				cp.InsEstTotal=cp.InsEstTotal*(double)cp.Percentage/100d;
			}
			//PaidOtherIns----------------------------------------------------------------------------------------
			//double paidOtherInsActual=GetPaidOtherIns(cp,patPlanList,patPlanNum,histList);//can return -1 for primary
			PatPlan pp=PatPlans.GetFromList(patPlanList.ToArray(),patPlanNum);
			//if -1, that indicates primary ins, not a proc, or no histlist.  We should not alter it in this case.
			//if(paidOtherInsActual!=-1) {
			//An older restriction was that histList must not be null.  But since this is now straight from db, that's not restriction.
			if(pp==null) {
				//corruption.  Do nothing.
			}
			else if(pp.Ordinal==1 || cp.ProcNum==0){
				cp.PaidOtherIns=0;
			}
			else{//if secondary or greater
				//The normal calculation uses the InsEstTotal from the primary ins.
				//But in TP module, if not using max and deduct, then the amount estimated to be paid by primary will be different.
				//It will use the primary BaseEst instead of the primary InsEstTotal.
				//Since the only use of BaseEst here is to handle this alternate viewing in the TP,
				//the secondary BaseEst should use the primary BaseEst when calculating paidOtherIns.
				//The BaseEst will, however, use PaidOtherInsOverride, if user has entered one.
				//This calculation doesn't need to be accurate unless viewing TP,
				//so it's ok to pass in a dummy value, like paidOtherInsTotal.
				//We do InsEstTotal first
				//cp.PaidOtherIns=paidOtherInsActual+paidOtherInsEstTotal;
				cp.PaidOtherIns=paidOtherInsTot;
				double paidOtherInsTotTemp=cp.PaidOtherIns;
				if(cp.PaidOtherInsOverride != -1) {//use the override
					paidOtherInsTotTemp=cp.PaidOtherInsOverride;
				}
				//example: Fee:200, InsEstT:80, BaseEst:100, PaidOI:110.
				//So... MaxPtP:90.
				//Since InsEstT is not greater than MaxPtoP, no change.
				//Since BaseEst is greater than MaxPtoP, BaseEst changed to 90.
				if(paidOtherInsTotTemp != -1) {
					double maxPossibleToPay=0;
					if(plan.CobRule==EnumCobRule.Basic) {
						maxPossibleToPay=allowed-paidOtherInsTotTemp;
					}
					else if(plan.CobRule==EnumCobRule.Standard) {
						double patPortionTot=procFee - paidOtherInsTotTemp - writeOffOtherIns;//patPortion for InsEstTotal
						maxPossibleToPay=Math.Min(cp.BaseEst,patPortionTot);//The lesser of what insurance would pay if they were primary, and the patient portion.
					}
					else{//plan.CobRule==EnumCobRule.CarveOut
						maxPossibleToPay=cp.BaseEst - paidOtherInsTotTemp;
					}
					if(maxPossibleToPay<0) {
						maxPossibleToPay=0;
					}
					if(cp.InsEstTotal > maxPossibleToPay) {
						cp.InsEstTotal=maxPossibleToPay;//reduce the estimate
					}
				}
				//Then, we do BaseEst
				double paidOtherInsBaseTemp=paidOtherInsBase;//paidOtherInsActual+paidOtherInsBaseEst;
				if(cp.PaidOtherInsOverride != -1) {//use the override
					paidOtherInsBaseTemp=cp.PaidOtherInsOverride;
				}
				if(paidOtherInsBaseTemp != -1) {
					double maxPossibleToPay=0;
					if(plan.CobRule==EnumCobRule.Basic) {
						maxPossibleToPay=allowed-paidOtherInsBaseTemp;
					}
					else if(plan.CobRule==EnumCobRule.Standard) {
						double patPortionBase=procFee - paidOtherInsBaseTemp - writeOffOtherIns;//patPortion for BaseEst
						maxPossibleToPay=Math.Min(cp.BaseEst,patPortionBase);
					}
					else {//plan.CobRule==EnumCobRule.CarveOut
						maxPossibleToPay=cp.BaseEst - paidOtherInsBaseTemp;
					}
					if(maxPossibleToPay<0) {
						maxPossibleToPay=0;
					}
					if(cp.BaseEst > maxPossibleToPay) {
						cp.BaseEst=maxPossibleToPay;//reduce the base est
					}
				}
			}
			//Exclusions---------------------------------------------------------------------------------------
			//We are not going to consider date of proc.  Just simple exclusions
			if(Benefits.IsExcluded(ProcedureCodes.GetStringProcCode(codeNum),benList,plan.PlanNum,patPlanNum)) {
				cp.BaseEst=0;
				cp.InsEstTotal=0;
				if(cp.EstimateNote!="") {
					cp.EstimateNote+=", ";
				}
				cp.EstimateNote+=Lans.g("ClaimProcs","Exclusion");
			}
			//base estimate is now done and will not be altered further.  From here out, we are only altering insEstTotal
			//annual max and other limitations--------------------------------------------------------------------------------
			if(loopList!=null && histList!=null) {
				string note="";
				cp.InsEstTotal=Benefits.GetLimitationByCode(benList,plan.PlanNum,patPlanNum,procDate,ProcedureCodes.GetStringProcCode(codeNum),histList,loopList,plan,cp.PatNum,out note,cp.InsEstTotal,patientAge,cp.InsSubNum);
				if(note != "") {
					if(cp.EstimateNote != "") {
						cp.EstimateNote+=", ";
					}
					cp.EstimateNote+=note;
				}
			}
			//procDate;//was already calculated in the deductible section.
			//Writeoff Estimate------------------------------------------------------------------------------------------
			if(plan.PlanType=="p") {//PPO
				//we can't use the allowed previously calculated, because it might be the allowed of a substituted code.
				//so we will calculate the allowed all over again, but this time, without using a substitution code.
				//AllowedFeeSched and toothNum do not need to be passed in.  codeSubstNone is set to true to not subst.
				double carrierAllowedNoSubst=InsPlans.GetAllowed(ProcedureCodes.GetProcCode(codeNum).ProcCode,plan.FeeSched,0,
					true,"p","",cp.ProvNum);
				double allowedNoSubst=procFee;
				if(carrierAllowedNoSubst != -1) {
					carrierAllowedNoSubst=carrierAllowedNoSubst*Math.Max(1,proc.BaseUnits+proc.UnitQty);
					if(carrierAllowedNoSubst > procFee) {
						allowedNoSubst=procFee;
					}
					else {
						allowedNoSubst=carrierAllowedNoSubst;
					}
				}
				double normalWriteOff=procFee-allowedNoSubst;//This is what the normal writeoff would be if no other insurance was involved.
				if(normalWriteOff<0) {
					normalWriteOff=0;
				}
				double remainingWriteOff=procFee-paidOtherInsTot-writeOffOtherIns;//This is the fee minus whatever other ins has already paid or written off.
				if(remainingWriteOff<0) {
					remainingWriteOff=0;
				}
				if((!PrefC.GetBool(PrefName.InsPPOsecWriteoffs) && paidOtherInsTot>0) || writeOffOtherIns>0) {
					//This pref solves a conflict between two customers.  One customer paid for a past feature request.
					//They need this new preference because they have a non-PPO as primary and a pseudo-PPO (Medicaid flagged as PPO) as secondary.
					//When the pref is true, then secondary writeoffs are only included if other insurance has no writeoffs already.  This is how we used to calculate secondary writeoffs for everyone.
					//When the pref is false (default), then no secondary writeoff estimates allowed.  Only primary may have writeoffs.  If no other insurance payments/estimates/writeoffs, then the current writeoff is calculated as primary.
					cp.WriteOffEst=0;//The reasoning for this is covered in the manual under Unit Test #1 and COB.
				}
				//We can't go over either number.  We must use the smaller of the two.  If one of them is zero, then the writeoff is zero.
				else if(remainingWriteOff==0 || normalWriteOff==0) {
					cp.WriteOffEst=0;
				}
				else if(remainingWriteOff<=normalWriteOff) {
					cp.WriteOffEst=remainingWriteOff;
				}
				else {
					cp.WriteOffEst=normalWriteOff;
				}
			}
			//capitation calculation never makes it this far:
			//else if(plan.PlanType=="c") {//capitation
			//	cp.WriteOffEst=cp.WriteOff;//this probably needs to change
			//}
			else {
				cp.WriteOffEst=-1;
			}
		}
Example #17
0
		///<summary>Gets the patient portion due of this procedure.  It is many times different than the proc fee.</summary>
		public static double GetPatPortion(Procedure proc,List<ClaimProc> listClaimProcs) {
			//No need to check RemotingRole; no call to db.
			//The following code is designed to duplicate the Procedures section of the GetAccount method in AccountModules.cs
			//We believe that Capitation Writeoffs are being counted twice due to the way the query gets and uses each column.
			//In the future we should evaluate and test if this is correct behavior.
			List<ClaimProc> listClaimProcsForProc=ClaimProcs.GetForProc(listClaimProcs,proc.ProcNum);
			double capWriteoff=0;
			double insPayAmt=0;
			double insPayEst=0;
			double writeOff=0;
			for(int i=0;i<listClaimProcsForProc.Count;i++) {
				ClaimProc claimProc=listClaimProcsForProc[i];
				if(claimProc.Status==ClaimProcStatus.CapComplete) {
					capWriteoff+=claimProc.WriteOff;
				}
				if(claimProc.Status==ClaimProcStatus.NotReceived) {
					insPayEst+=claimProc.InsPayEst;
				}
				insPayAmt+=claimProc.InsPayAmt;
				writeOff+=claimProc.WriteOff;
			}
			return proc.ProcFee*Math.Max(1,proc.BaseUnits+proc.UnitQty)-capWriteoff-insPayAmt-insPayEst-writeOff;
		}
Example #18
0
		///<summary>MUST call EntriesAreValid first.  Used from OK_Click and from butSetComplete_Click</summary>
		private void SaveAndClose(){
			if(textProcFee.Text==""){
				textProcFee.Text="0";
			}
			ProcCur.PatNum=PatCur.PatNum;
			//ProcCur.Code=this.textProc.Text;
			ProcedureCode2=ProcedureCodes.GetProcCode(textProc.Text);
			ProcCur.CodeNum=ProcedureCode2.CodeNum;
			ProcCur.MedicalCode=textMedicalCode.Text;
			if(_snomedBodySite==null) {
				ProcCur.SnomedBodySite="";
			}
			else {
				ProcCur.SnomedBodySite=_snomedBodySite.SnomedCode;
			}
			ProcCur.DiagnosticCode=textDiagnosticCode.Text;
			ProcCur.IsPrincDiag=checkIsPrincDiag.Checked;
			ProcCur.CodeMod1 = textCodeMod1.Text;
			ProcCur.CodeMod2 = textCodeMod2.Text;
			ProcCur.CodeMod3 = textCodeMod3.Text;
			ProcCur.CodeMod4 = textCodeMod4.Text;
			ProcCur.UnitQty = PIn.Int(textUnitQty.Text);
			ProcCur.UnitQtyType=(ProcUnitQtyType)comboUnitType.SelectedIndex;
			ProcCur.RevCode = textRevCode.Text;
			ProcCur.DrugUnit=(EnumProcDrugUnit)comboDrugUnit.SelectedIndex;
			ProcCur.DrugQty=PIn.Float(textDrugQty.Text);
			if(ProcOld.ProcStatus!=ProcStat.C && ProcCur.ProcStatus==ProcStat.C){//Proc set complete.
				ProcCur.DateEntryC=DateTime.Now;//this triggers it to set to server time NOW().
				if(ProcCur.DiagnosticCode=="") {
					ProcCur.DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
				}
			}
			ProcCur.DateTP=PIn.Date(this.textDateTP.Text);
			ProcCur.ProcDate=PIn.Date(this.textDate.Text);
			DateTime dateT=PIn.DateT(this.textTimeStart.Text);
			ProcCur.ProcTime=new TimeSpan(dateT.Hour,dateT.Minute,0);
			if(Programs.UsingOrion || PrefC.GetBool(PrefName.ShowFeatureMedicalInsurance)) {
				dateT=ParseTime(textTimeStart.Text);
				ProcCur.ProcTime=new TimeSpan(dateT.Hour,dateT.Minute,0);
				dateT=ParseTime(textTimeEnd.Text);
				ProcCur.ProcTimeEnd=new TimeSpan(dateT.Hour,dateT.Minute,0);
			}
			ProcCur.ProcFee=PIn.Double(textProcFee.Text);
			//ProcCur.LabFee=PIn.PDouble(textLabFee.Text);
			//ProcCur.LabProcCode=textLabCode.Text;
			//MessageBox.Show(ProcCur.ProcFee.ToString());
			//Dx taken care of when radio pushed
			switch(ProcedureCode2.TreatArea){
				case TreatmentArea.Surf:
					ProcCur.ToothNum=Tooth.FromInternat(textTooth.Text);
					ProcCur.Surf=Tooth.SurfTidyFromDisplayToDb(textSurfaces.Text,ProcCur.ToothNum);
					break;
				case TreatmentArea.Tooth:
					ProcCur.Surf="";
					ProcCur.ToothNum=Tooth.FromInternat(textTooth.Text);
					break;
				case TreatmentArea.Mouth:
					ProcCur.Surf="";
					ProcCur.ToothNum="";	
					break;
				case TreatmentArea.Quad:
					//surf set when radio pushed
					ProcCur.ToothNum="";	
					break;
				case TreatmentArea.Sextant:
					//surf taken care of when radio pushed
					ProcCur.ToothNum="";	
					break;
				case TreatmentArea.Arch:
					//don't HAVE to select arch
					//taken care of when radio pushed
					ProcCur.ToothNum="";	
					break;
				case TreatmentArea.ToothRange:
					if (listBoxTeeth.SelectedItems.Count<1 && listBoxTeeth2.SelectedItems.Count<1) {
						MessageBox.Show(Lan.g(this,"Must pick at least 1 tooth"));
						return;
					}
          string range="";
					int idxAmer;
					for(int j=0;j<listBoxTeeth.SelectedIndices.Count;j++){
						idxAmer=listBoxTeeth.SelectedIndices[j];
						if(j!=0){
							range+=",";
						}
            range+=Tooth.labelsUniversal[idxAmer];
					}
					for(int j=0;j<listBoxTeeth2.SelectedIndices.Count;j++){
						idxAmer=listBoxTeeth2.SelectedIndices[j]+16;
						if(j!=0){
							range+=",";
						}
            range+=Tooth.labelsUniversal[idxAmer];
          }
			    ProcCur.ToothRange=range;
					ProcCur.Surf="";
					ProcCur.ToothNum="";	
					break;
			}
			//Status taken care of when list pushed
			ProcCur.Note=this.textNotes.Text;
			try {
				SaveSignature();
			}
			catch(Exception ex){
				MessageBox.Show(Lan.g(this,"Error saving signature.")+"\r\n"+ex.Message);
				//and continue with the rest of this method
			}
			ProcCur.HideGraphics=checkHideGraphics.Checked;
			//provnum already handled.
			//if(comboProvNum.SelectedIndex!=-1) {
			//	ProcCur.ProvNum=ProviderC.List[comboProvNum.SelectedIndex].ProvNum;
			//}
			//clinicNum already handled.
			if(comboDx.SelectedIndex!=-1) {
				ProcCur.Dx=DefC.Short[(int)DefCat.Diagnosis][comboDx.SelectedIndex].DefNum;
			}
			if(comboPrognosis.SelectedIndex==0) {
				ProcCur.Prognosis=0;
			}
			else {
				ProcCur.Prognosis=DefC.Short[(int)DefCat.Prognosis][comboPrognosis.SelectedIndex-1].DefNum;
			}
			if(comboPriority.SelectedIndex==0) {
				ProcCur.Priority=0;
			}
			else {
				ProcCur.Priority=DefC.Short[(int)DefCat.TxPriorities][comboPriority.SelectedIndex-1].DefNum;
			}
			ProcCur.PlaceService=(PlaceOfService)comboPlaceService.SelectedIndex;
			//if(comboClinic.SelectedIndex==0){
			//	ProcCur.ClinicNum=0;
			//}
			//else{
			//	ProcCur.ClinicNum=Clinics.List[comboClinic.SelectedIndex-1].ClinicNum;
			//}
			//site set when user picks from list.
			if(comboBillingTypeOne.SelectedIndex==0){
				ProcCur.BillingTypeOne=0;
			}
			else{
				ProcCur.BillingTypeOne=DefC.Short[(int)DefCat.BillingTypes][comboBillingTypeOne.SelectedIndex-1].DefNum;
			}
			if(comboBillingTypeTwo.SelectedIndex==0) {
				ProcCur.BillingTypeTwo=0;
			}
			else {
				ProcCur.BillingTypeTwo=DefC.Short[(int)DefCat.BillingTypes][comboBillingTypeTwo.SelectedIndex-1].DefNum;
			}
			ProcCur.BillingNote=textBillingNote.Text;
			//ProcCur.HideGraphical=checkHideGraphical.Checked;
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
				ProcCur.CanadianTypeCodes="";
				if(checkTypeCodeA.Checked) {
					ProcCur.CanadianTypeCodes+="A";
				}
				if(checkTypeCodeB.Checked) {
					ProcCur.CanadianTypeCodes+="B";
				}
				if(checkTypeCodeC.Checked) {
					ProcCur.CanadianTypeCodes+="C";
				}
				if(checkTypeCodeE.Checked) {
					ProcCur.CanadianTypeCodes+="E";
				}
				if(checkTypeCodeL.Checked) {
					ProcCur.CanadianTypeCodes+="L";
				}
				if(checkTypeCodeS.Checked) {
					ProcCur.CanadianTypeCodes+="S";
				}
				if(checkTypeCodeX.Checked) {
					ProcCur.CanadianTypeCodes+="X";
				}
				double canadaLabFee1=0;
				if(textCanadaLabFee1.Text!="") {
					canadaLabFee1=PIn.Double(textCanadaLabFee1.Text);
				}
				if(canadaLabFee1==0) {
					if(textCanadaLabFee1.Visible && canadaLabFees.Count>0) { //Don't worry about deleting child lab fees if we are editing a lab fee. No such concept.
						Procedures.Delete(canadaLabFees[0].ProcNum);
					}
				}
				else { //canadaLabFee1!=0
					if(canadaLabFees.Count>0) { //Retain the old lab code if present.
						Procedure labFee1Old=canadaLabFees[0].Copy();
						canadaLabFees[0].ProcFee=canadaLabFee1;
						Procedures.Update(canadaLabFees[0],labFee1Old);
					}
					else {
						Procedure labFee1=new Procedure();
						labFee1.PatNum=ProcCur.PatNum;
						labFee1.ProcDate=ProcCur.ProcDate;
						labFee1.ProcFee=canadaLabFee1;
						labFee1.ProcStatus=ProcCur.ProcStatus;
						labFee1.ProvNum=ProcCur.ProvNum;
						labFee1.DateEntryC=DateTime.Now;
						labFee1.ClinicNum=ProcCur.ClinicNum;
						labFee1.ProcNumLab=ProcCur.ProcNum;
						labFee1.CodeNum=ProcedureCodes.GetCodeNum("99111");
						if(labFee1.CodeNum==0) { //Code does not exist.
							ProcedureCode code99111=new ProcedureCode();
							code99111.ProcCode="99111";
							code99111.Descript="+L Commercial Laboratory Procedures";
							code99111.AbbrDesc="Lab Fee";
							code99111.ProcCat=DefC.GetByExactNameNeverZero(DefCat.ProcCodeCats,"Adjunctive General Services");
							ProcedureCodes.Insert(code99111);
							labFee1.CodeNum=code99111.CodeNum;
						}
						Procedures.Insert(labFee1);
					}
				}
				double canadaLabFee2=0;
				if(textCanadaLabFee2.Text!="") {
					canadaLabFee2=PIn.Double(textCanadaLabFee2.Text);
				}
				if(canadaLabFee2==0) {
					if(textCanadaLabFee2.Visible && canadaLabFees.Count>1) { //Don't worry about deleting child lab fees if we are editing a lab fee. No such concept.
						Procedures.Delete(canadaLabFees[1].ProcNum);
					}
				}
				else { //canadaLabFee2!=0
					if(canadaLabFees.Count>1) { //Retain the old lab code if present.
						Procedure labFee2Old=canadaLabFees[1].Copy();
						canadaLabFees[1].ProcFee=canadaLabFee2;
						Procedures.Update(canadaLabFees[1],labFee2Old);
					}
					else {
						Procedure labFee2=new Procedure();
						labFee2.PatNum=ProcCur.PatNum;
						labFee2.ProcDate=ProcCur.ProcDate;
						labFee2.ProcFee=canadaLabFee2;
						labFee2.ProcStatus=ProcCur.ProcStatus;
						labFee2.ProvNum=ProcCur.ProvNum;
						labFee2.DateEntryC=DateTime.Now;
						labFee2.ClinicNum=ProcCur.ClinicNum;
						labFee2.ProcNumLab=ProcCur.ProcNum;
						labFee2.CodeNum=ProcedureCodes.GetCodeNum("99111");
						if(labFee2.CodeNum==0) { //Code does not exist.
							ProcedureCode code99111=new ProcedureCode();
							code99111.ProcCode="99111";
							code99111.Descript="+L Commercial Laboratory Procedures";
							code99111.AbbrDesc="Lab Fee";
							code99111.ProcCat=DefC.GetByExactNameNeverZero(DefCat.ProcCodeCats,"Adjunctive General Services");
							ProcedureCodes.Insert(code99111);
							labFee2.CodeNum=code99111.CodeNum;
						}
						Procedures.Insert(labFee2);
					}
				}
			}
			else {
				if(ProcedureCode2.IsProsth) {
					switch(listProsth.SelectedIndex) {
						case 0:
							ProcCur.Prosthesis="";
							break;
						case 1:
							ProcCur.Prosthesis="I";
							break;
						case 2:
							ProcCur.Prosthesis="R";
							break;
					}
					ProcCur.DateOriginalProsth=PIn.Date(textDateOriginalProsth.Text);
				}
				else {
					ProcCur.Prosthesis="";
					ProcCur.DateOriginalProsth=DateTime.MinValue;
				}
			}
			ProcCur.ClaimNote=textClaimNote.Text;
			//Last chance to run this code before Proc gets updated.
			if(Programs.UsingOrion){//Ask for an explanation. If they hit cancel here, return and don't save.
				OrionProcCur.DPC=(OrionDPC)comboDPC.SelectedIndex;
				OrionProcCur.DPCpost=(OrionDPC)comboDPCpost.SelectedIndex;
				OrionProcCur.DateScheduleBy=PIn.Date(textDateScheduled.Text);
				OrionProcCur.DateStopClock=PIn.Date(textDateStop.Text);
				OrionProcCur.IsOnCall=checkIsOnCall.Checked;
				OrionProcCur.IsEffectiveComm=checkIsEffComm.Checked;
				OrionProcCur.IsRepair=checkIsRepair.Checked;
				if(IsNew) {
					OrionProcs.Insert(OrionProcCur);
				}
				else {//Is not new.
					if(FormProcEditExplain.GetChanges(ProcCur,ProcOld,OrionProcCur,OrionProcOld)!="") {//Checks if any changes were made. Also sets static variable Changes.
						//If a day old and the orion procedure status did not go from TP to C, CS or CR, then show explaination window.
						if((ProcOld.DateTP.Date<MiscData.GetNowDateTime().Date &&
							(OrionProcOld.Status2!=OrionStatus.TP || (OrionProcCur.Status2!=OrionStatus.C && OrionProcCur.Status2!=OrionStatus.CS && OrionProcCur.Status2!=OrionStatus.CR))))
						{
							FormProcEditExplain FormP=new FormProcEditExplain();
							FormP.dpcChange=((int)OrionProcOld.DPC!=(int)OrionProcCur.DPC);
							if(FormP.ShowDialog()!=DialogResult.OK) {
								return;
							}
							Procedure ProcPreExplain=ProcOld.Copy();
							ProcOld.Note=FormProcEditExplain.Explanation;
							Procedures.Update(ProcOld,ProcPreExplain);
							Thread.Sleep(1100);
						}
					}
					OrionProcs.Update(OrionProcCur);
					//Date entry needs to be updated when status changes to cancelled or refused and at least a day old.
					if(ProcOld.DateTP.Date<MiscData.GetNowDateTime().Date &&
						OrionProcCur.Status2==OrionStatus.CA_EPRD ||
						OrionProcCur.Status2==OrionStatus.CA_PD ||
						OrionProcCur.Status2==OrionStatus.CA_Tx ||
						OrionProcCur.Status2==OrionStatus.R) 
					{
						ProcCur.DateEntryC=MiscData.GetNowDateTime().Date;
					}
				}//End of "is not new."
			}
			//The actual update----------------------------------------------------------------------------------------------------------------------------------
			Procedures.Update(ProcCur,ProcOld);
			if(ProcCur.AptNum>0 || ProcCur.PlannedAptNum>0) {
				//Update the ProcDescript on the appointment if procedure is attached to one.
				//The ApptProcDescript region is also in FormApptEdit.UpdateToDB() and FormDatabaseMaintenance.butApptProcs_Click()  Make any changes there as well.
				#region ApptProcDescript
				Appointment apt;
				DataTable procTable;
				if(ProcCur.AptNum>0) {
					apt=Appointments.GetOneApt(ProcCur.AptNum);
					procTable=Appointments.GetProcTable(ProcCur.PatNum.ToString(),apt.AptNum.ToString(),((int)apt.AptStatus).ToString(),apt.AptDateTime.ToString());
				}
				else {
					apt=Appointments.GetOneApt(ProcCur.PlannedAptNum);
					procTable=Appointments.GetProcTable(ProcCur.PatNum.ToString(),ProcCur.PlannedAptNum.ToString(),((int)apt.AptStatus).ToString(),apt.AptDateTime.ToString());
				}
				Appointment aptOld=apt.Clone();
				apt.ProcDescript="";
				apt.ProcsColored="";
				int count=0;
				for(int i=0;i<procTable.Rows.Count;i++) {
					if(procTable.Rows[i]["attached"].ToString()!="1") {
						continue;
					}
					string procDescOne="";
					string procCode=procTable.Rows[i]["ProcCode"].ToString();
					if(count>0) {
						apt.ProcDescript+=", ";
					}
					switch(procTable.Rows[i]["TreatArea"].ToString()) {
						case "1"://TreatmentArea.Surf:
							procDescOne+="#"+Tooth.GetToothLabel(procTable.Rows[i]["ToothNum"].ToString())+"-"
								+procTable.Rows[i]["Surf"].ToString()+"-";//""#12-MOD-"
							break;
						case "2"://TreatmentArea.Tooth:
							procDescOne+="#"+Tooth.GetToothLabel(procTable.Rows[i]["ToothNum"].ToString())+"-";//"#12-"
							break;
						default://area 3 or 0 (mouth)
							break;
						case "4"://TreatmentArea.Quad:
							procDescOne+=procTable.Rows[i]["Surf"].ToString()+"-";//"UL-"
							break;
						case "5"://TreatmentArea.Sextant:
							procDescOne+="S"+procTable.Rows[i]["Surf"].ToString()+"-";//"S2-"
							break;
						case "6"://TreatmentArea.Arch:
							procDescOne+=procTable.Rows[i]["Surf"].ToString()+"-";//"U-"
							break;
						case "7"://TreatmentArea.ToothRange:
							//strLine+=table.Rows[j][13].ToString()+" ";//don't show range
							break;
					}
					procDescOne+=procTable.Rows[i]["AbbrDesc"].ToString();
					apt.ProcDescript+=procDescOne;
					//Color and previous date are determined by ProcApptColor object
					ProcApptColor pac=ProcApptColors.GetMatch(procCode);
					System.Drawing.Color pColor=System.Drawing.Color.Black;
					string prevDateString="";
					if(pac!=null) {
						pColor=pac.ColorText;
						if(pac.ShowPreviousDate) {
							prevDateString=Procedures.GetRecentProcDateString(apt.PatNum,apt.AptDateTime,pac.CodeRange);
							if(prevDateString!="") {
								prevDateString=" ("+prevDateString+")";
							}
						}
					}
					apt.ProcsColored+="<span color=\""+pColor.ToArgb().ToString()+"\">"+procDescOne+prevDateString+"</span>";
					count++;
				}
				#endregion
				Appointments.Update(apt,aptOld);
			}
			for(int i=0;i<ClaimProcsForProc.Count;i++) {
				ClaimProcsForProc[i].ClinicNum=ProcCur.ClinicNum;
			}
			//Recall synch--------------------------------------------------------------------------------------------------------------------------------------
			Recalls.Synch(ProcCur.PatNum);
			//Auto-insert default encounter ---------------------------------------------------------------------------------------------------------------------------
			if(ProcOld.ProcStatus!=ProcStat.C && ProcCur.ProcStatus==ProcStat.C) {
				Encounters.InsertDefaultEncounter(ProcCur.PatNum,ProcCur.ProvNum,ProcCur.ProcDate);
			}
			//Security logs------------------------------------------------------------------------------------------------------------------------------------
			if(ProcOld.ProcStatus!=ProcStat.C && ProcCur.ProcStatus==ProcStat.C){
				//if status was changed to complete
				SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate,PatCur.PatNum,
					ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode+", "
					+ProcCur.ProcFee.ToString("c"));
				List<string> procCodeList=new List<string>();
				procCodeList.Add(ProcedureCodes.GetStringProcCode(ProcCur.CodeNum));
				AutomationL.Trigger(AutomationTrigger.CompleteProcedure,procCodeList,ProcCur.PatNum);
			}
			else if(IsNew && ProcCur.ProcStatus==ProcStat.C){
				//if new procedure is complete
				SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate,PatCur.PatNum,
					ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode+", "
					+ProcCur.ProcFee.ToString("c"));
			}
			else if(!IsNew){
				if(ProcOld.ProcStatus==ProcStat.C){
					SecurityLogs.MakeLogEntry(Permissions.ProcComplEdit,PatCur.PatNum,
						ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode+", "
						+ProcCur.ProcFee.ToString("c"));
				}
			}
			if((ProcCur.ProcStatus==ProcStat.C || ProcCur.ProcStatus==ProcStat.EC || ProcCur.ProcStatus==ProcStat.EO)
				&& ProcedureCodes.GetProcCode(ProcCur.CodeNum).PaintType==ToothPaintingType.Extraction) {
				//if an extraction, then mark previous procs hidden
				//Procedures.SetHideGraphical(ProcCur);//might not matter anymore
				ToothInitials.SetValue(ProcCur.PatNum,ProcCur.ToothNum,ToothInitialType.Missing);
			}
			//Canadian lab fees complete-----------------------------------------------------------------------------------------------------------------------
			if(CultureInfo.CurrentCulture.Name.EndsWith("CA") && ProcCur.ProcStatus==ProcStat.C) {//Canada
				Procedures.SetCanadianLabFeesCompleteForProc(ProcCur);
			}
			//Autocodes----------------------------------------------------------------------------------------------------------------------------------------
			ProcOld=ProcCur.Copy();//in case we now make more changes.
			//these areas have no autocodes
			if(ProcedureCode2.TreatArea==TreatmentArea.Mouth
				|| ProcedureCode2.TreatArea==TreatmentArea.Quad
				|| ProcedureCode2.TreatArea==TreatmentArea.Sextant)
			{
				DialogResult=DialogResult.OK;
				return;
			}
			//this represents the suggested code based on the autocodes set up.
			long verifyCode;
			AutoCode AutoCodeCur=null;
			if(ProcedureCode2.TreatArea==TreatmentArea.Arch){
				if(ProcCur.Surf==""){
					DialogResult=DialogResult.OK;
					return;
				}
				if(ProcCur.Surf=="U"){
					verifyCode=AutoCodeItems.VerifyCode
						(ProcedureCode2.CodeNum,"1","",false,PatCur.PatNum,PatCur.Age,out AutoCodeCur);//max
				}
				else{
					verifyCode=AutoCodeItems.VerifyCode
						(ProcedureCode2.CodeNum,"32","",false,PatCur.PatNum,PatCur.Age,out AutoCodeCur);//mand
				}
			}
			else if(ProcedureCode2.TreatArea==TreatmentArea.ToothRange){
				//test for max or mand.
				if(listBoxTeeth.SelectedItems.Count<1)
					verifyCode=AutoCodeItems.VerifyCode
						(ProcedureCode2.CodeNum,"32","",false,PatCur.PatNum,PatCur.Age,out AutoCodeCur);//mand
				else
					verifyCode=AutoCodeItems.VerifyCode
						(ProcedureCode2.CodeNum,"1","",false,PatCur.PatNum,PatCur.Age,out AutoCodeCur);//max
			}
			else{//surf or tooth
				verifyCode=AutoCodeItems.VerifyCode
					(ProcedureCode2.CodeNum,ProcCur.ToothNum,ProcCur.Surf,false,PatCur.PatNum,PatCur.Age,out AutoCodeCur);
			}
			if(ProcedureCode2.CodeNum!=verifyCode){
				string desc=ProcedureCodes.GetProcCode(verifyCode).Descript;
				FormAutoCodeLessIntrusive FormA=new FormAutoCodeLessIntrusive();
				FormA.mainText=ProcedureCodes.GetProcCode(verifyCode).ProcCode
					+" ("+desc+") "+Lan.g(this,"is the recommended procedure code for this procedure.  Change procedure code and fee?");
				FormA.ShowDialog();
				if(FormA.DialogResult!=DialogResult.OK){
					DialogResult=DialogResult.OK;
					return;
				}
				//No longer allow users to hide auto code reminders from the procedure edit window.  A label lets them know to change it via Auto Codes.
				//if(FormA.CheckedBox){
				//  AutoCodeCur.LessIntrusive=true;
				//  AutoCodes.Update(AutoCodeCur);
				//  DataValid.SetInvalid(InvalidType.AutoCodes);
				//}
				ProcCur.CodeNum=verifyCode;
				//ProcedureCode2=ProcedureCodes.GetProcCode(ProcCur.CodeNum);
				//ProcCur.Code=verifyCode;
				InsSub prisub=null;
				InsPlan priplan=null;
				if(PatPlanList.Count>0) {
					prisub=InsSubs.GetSub(PatPlanList[0].InsSubNum,SubList);
					priplan=InsPlans.GetPlan(prisub.PlanNum,PlanList);
				}
				double insfee=Fees.GetAmount0(ProcCur.CodeNum,Fees.GetFeeSched(PatCur,PlanList,PatPlanList,SubList));
				if(priplan!=null && priplan.PlanType=="p") {//PPO
					double standardfee=Fees.GetAmount0(ProcCur.CodeNum,Providers.GetProv(Patients.GetProvNum(PatCur)).FeeSched);
					if(standardfee>insfee) {
						ProcCur.ProcFee=standardfee;
					}
					else {
						ProcCur.ProcFee=insfee;
					}
				}
				else {
					ProcCur.ProcFee=insfee;
				}
				//ProcCur.ProcFee=Fees.GetAmount0(ProcedureCode2.CodeNum,Fees.GetFeeSched(PatCur,PlanList,PatPlanList));
				Procedures.Update(ProcCur,ProcOld);
				Recalls.Synch(ProcCur.PatNum);
				if(ProcCur.ProcStatus==ProcStat.C){
					SecurityLogs.MakeLogEntry(Permissions.ProcComplEdit,PatCur.PatNum,
						PatCur.GetNameLF()+", "+ProcedureCode2.ProcCode+", "
						+ProcCur.ProcFee.ToString("c"));
				}
			}
      DialogResult=DialogResult.OK;
			//it is assumed that we will do an immediate refresh after closing this window.
		}
Example #19
0
		///<summary>Inserts are not done within this dialog, but must be done ahead of time from outside.  You must specify a procedure to edit, and only the changes that are made in this dialog get saved.  Only used when double click in Account, Chart, TP, and in ContrChart.AddProcedure().  The procedure may be deleted if new, and user hits Cancel.</summary>
		public FormProcEdit(Procedure proc,Patient patCur,Family famCur){
			ProcCur=proc;
			ProcOld=proc.Copy();
			PatCur=patCur;
			FamCur=famCur;
			SubList=InsSubs.RefreshForFam(FamCur);
			PlanList=InsPlans.RefreshForSubList(SubList);
			//HistList=null;
			//LoopList=null;
			InitializeComponent();
			Lan.F(this);
			//allowTopaz=(Environment.OSVersion.Platform!=PlatformID.Unix && !CodeBase.ODEnvironment.Is64BitOperatingSystem());
			sigBox.SetTabletState(1);
			//if(!allowTopaz) {
			//	butTopazSign.Visible=false;
			//	sigBox.Visible=true;
			//}
			//else{
				//Add signature box for Topaz signatures.
				sigBoxTopaz=CodeBase.TopazWrapper.GetTopaz();
				sigBoxTopaz.Location=sigBox.Location;//this puts both boxes in the same spot.
				sigBoxTopaz.Name="sigBoxTopaz";
				sigBoxTopaz.Size=new System.Drawing.Size(362,79);
				sigBoxTopaz.TabIndex=92;
				sigBoxTopaz.Text="sigPlusNET1";
				sigBoxTopaz.Visible=false;
				Controls.Add(sigBoxTopaz);
				//It starts out accepting input. It will be set to 0 if a sig is already present.  It will be set back to 1 if note changes or if user clicks Clear.
				CodeBase.TopazWrapper.SetTopazState(sigBoxTopaz,1);
			//}
			if(!PrefC.GetBool(PrefName.ShowFeatureMedicalInsurance)) {
				tabControl.TabPages.Remove(tabPageMedical);
				//groupMedical.Visible=false;
			}
		}
Example #20
0
File: EhrCCD.cs Project: mnisl/OD
		///<summary>Helper for GenerateCCD().</summary>
		private void GenerateCcdSectionProcedures(bool hasProcedure) {
			_w.WriteComment(@"
=====================================================================================================
Procedures
=====================================================================================================");
			List<Procedure> listProcsFiltered;
			if(!hasProcedure) {
				listProcsFiltered=new List<Procedure>();
			}
			else {
				listProcsFiltered=_listProcsFiltered;
			}
			Start("component");
			Start("section");
			TemplateId("2.16.840.1.113883.10.20.22.2.7.1");//Procedures section with coded entries required (Page 285).
			_w.WriteComment("Procedures section template");
			StartAndEnd("code","code","47519-4","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","History of procedures");
			_w.WriteElementString("title","Procedures");
			Start("text");//The following text will be parsed as html with a style sheet to be human readable.
			if(listProcsFiltered.Count>0 && hasProcedure) {
				bool hasBodySite=false;
				for(int i=0;i<listProcsFiltered.Count;i++) {
					Snomed snomedBodySite=Snomeds.GetByCode(listProcsFiltered[i].SnomedBodySite);//snomedBodySite can be null if procCode.SnomedBodySite is blank or invalid.
					if(snomedBodySite!=null) {
						hasBodySite=true;
						break;
					}
				}
				Start("table","width","100%","border","1");
				Start("thead");
				Start("tr");
				_w.WriteElementString("th","Procedure");
				if(hasBodySite) {
					_w.WriteElementString("th","Body Site");
				}
				_w.WriteElementString("th","Date");
				End("tr");
				End("thead");
				Start("tbody");
				for(int i=0;i<listProcsFiltered.Count;i++) {
					ProcedureCode procCode=ProcedureCodes.GetProcCode(listProcsFiltered[i].CodeNum);
					Start("tr");
					if(Regex.IsMatch(procCode.ProcCode,"^D[0-9]{4}$")) {//CDT code (ADA code)
						_w.WriteElementString("td",procCode.ProcCode+" - "+procCode.Descript);
					}
					else if(Regex.IsMatch(procCode.ProcCode,"^[0-9]{5}$")) {//CPT-4 code (medical code)
						_w.WriteElementString("td",procCode.ProcCode+" - "+procCode.Descript);
					}
					else if(Snomeds.CodeExists(procCode.ProcCode)) {//The SNOMED CT code system contains numerical codes which are between 6 and 18 digits in length as far as we know. Should not overlap CPT codes.
						Snomed snomed=Snomeds.GetByCode(procCode.ProcCode);
						_w.WriteElementString("td",snomed.SnomedCode+" - "+snomed.Description);
					}
					else {//Unknown code.  Output a "blank" procedure row as required by CCD standard.
						_w.WriteElementString("td","");
					}
					if(hasBodySite) {
						Snomed snomedBodySite=Snomeds.GetByCode(listProcsFiltered[i].SnomedBodySite);//snomedBodySite can be null if procCode.SnomedBodySite is blank or invalid.
						if(snomedBodySite==null) {
							_w.WriteElementString("td","");
						}
						else {
							_w.WriteElementString("td",snomedBodySite.SnomedCode+" - "+snomedBodySite.Description);
						}
					}
					if(listProcsFiltered[i].ProcDate.Year<1880) {
						_w.WriteElementString("td","");
					}
					else {
						DateText("td",listProcsFiltered[i].ProcDate);
					}
					End("tr");
				}
				End("tbody");
				End("table");
			}
			else {
				_w.WriteString("None");
			}
			End("text");
			if(listProcsFiltered.Count==0) {//If there are no entries in the filtered list, then we want to add a dummy entry since at least one is required.
				Procedure proc=new Procedure();
				listProcsFiltered.Add(proc);
			}
			for(int i=0;i<listProcsFiltered.Count;i++) {
				ProcedureCode procCode=ProcedureCodes.GetProcCode(listProcsFiltered[i].CodeNum);
				Start("entry","typeCode","DRIV");
				Start("procedure","classCode","PROC","moodCode","EVN");
				TemplateId("2.16.840.1.113883.10.20.22.4.14");//Procedure Activity Section (Page 487).
				_w.WriteComment("Procedure Activity Template");
				Guid();
				//"This code in a procedure activity SHOULD be selected from LOINC (codeSystem 2.16.840.1.113883.6.1) or SNOMED CT (CodeSystem: 2.16.840.1.113883.6.96),
				//and MAY be selected from CPT-4 (CodeSystem: 2.16.840.1.113883.6.12), ICD9 Procedures (CodeSystem: 2.16.840.1.113883.6.104),
				//ICD10 Procedure Coding System (CodeSystem: 2.16.840.1.113883.6.4) (CONF:7657)."
				//In November of 2013, ONC addopted CDT into EHR certification. http://ehrintelligence.com/2013/11/05/ehr-adoption-may-be-easier-for-dentists-with-new-onc-ruling/
				//The CDT OID is 2.16.840.1.113883.6.13 and the code system description is cdt-ADAcodes.
				if(procCode.ProcCode==null) {//Happens when listProcsFiltered[i].CodeNum is invalid or 0 (we create a procedure with CodeNum=0 above this loop if the procedure list is empty).
					StartAndEnd("code","nullFlavor","UNK");//Unknown code.  Output a "blank" procedure row as required by CCD standard.
				}
				else if(Regex.IsMatch(procCode.ProcCode,"^D[0-9]{4}$")) {//CDT code (ADA code)
					StartAndEnd("code","code",procCode.ProcCode,"codeSystem",strCodeSystemCdt,"displayName",procCode.Descript,"codeSystemName",strCodeSystemNameCdt);
				}
				else if(Regex.IsMatch(procCode.ProcCode,"^[0-9]{5}$")) {//CPT-4 code (medical code)
					StartAndEnd("code","code",procCode.ProcCode,"codeSystem",strCodeSystemCpt4,"displayName",procCode.Descript,"codeSystemName",strCodeSystemNameCpt4);
				}
				else if(Snomeds.CodeExists(procCode.ProcCode)) {//The SNOMED CT code system contains numerical codes which are between 6 and 18 digits in length as far as we know. Should not overlap CPT codes.
					Snomed snomed=Snomeds.GetByCode(procCode.ProcCode);
					StartAndEnd("code","code",snomed.SnomedCode,"codeSystem",strCodeSystemSnomed,"displayName",snomed.Description,"codeSystemName",strCodeSystemNameSnomed);
				}
				else {//Unknown code.  Output a "blank" procedure row as required by CCD standard.
					StartAndEnd("code","nullFlavor","UNK");
				}
				StartAndEnd("statusCode","code","completed");//Allowed values: completed, active, aborted, cancelled.
				if(listProcsFiltered[i].ProcDate.Year<1880) {
					StartAndEnd("effectiveTime","nullFlavor","UNK");
				}
				else {
					DateElement("effectiveTime",listProcsFiltered[i].ProcDate);
				}
				End("procedure");
				End("entry");
			}
			End("section");
			End("component");
		}
Example #21
0
File: Canadian.cs Project: mnisl/OD
		private static string GetToothQuadOrArch(Procedure proc,ProcedureCode procCode){
			switch(procCode.TreatArea){
				case TreatmentArea.Arch:
					//if(proc.Surf=="U"){
					return "00";
					//}
					//else{
					//	return "01";
					//}
				case TreatmentArea.Mouth:
				case TreatmentArea.None:
					return "00";
				case TreatmentArea.Quad:
					if(proc.Surf=="UR"){
						return "10";
					}
					else if(proc.Surf=="UL") {
						return "20";
					}
					else if(proc.Surf=="LR") {
						return "40";
					}
					else{//LL
						return "30";
					}
				case TreatmentArea.Sextant:
					if(proc.Surf=="1") {//Upper Right
						return "03";
					}
					else if(proc.Surf=="2") {//Upper Anterior
						return "04";
					}
					else if(proc.Surf=="3") {//Upper Left
						return "05";
					}
					else if(proc.Surf=="4") {//Lower Left
						return "06";
					}
					else if(proc.Surf=="5") {//Lower Anterior
						return "07";
					}
					else if(proc.Surf=="6") {//Lower Right
						return "08";
					}
					return "00";//Invalid or unspecified sextant.  This is also the number that represents "whole mouth" in Canada.
				case TreatmentArea.Surf:
				case TreatmentArea.Tooth:
					return Tooth.ToInternat(proc.ToothNum);
				case TreatmentArea.ToothRange:
					string[] range=proc.ToothRange.Split(',');
					if(range.Length==0 || !Tooth.IsValidDB(range[0])){
						return "00";
					}
					else if(Tooth.IsMaxillary(range[0])){
						return "00";
					}
					return "00";
			}
			return "00";//will never happen
		}
Example #22
0
		private static string GetArea(Procedure proc,ProcedureCode procCode) {
			if(procCode.TreatArea==TreatmentArea.Arch) {
				if(proc.Surf=="U") {
					return "01";
				}
				if(proc.Surf=="L") {
					return "02";
				}
			}
			if(procCode.TreatArea==TreatmentArea.Mouth) {
				return "";
			}
			if(procCode.TreatArea==TreatmentArea.Quad) {
				if(proc.Surf=="UR") {
					return "10";
				}
				if(proc.Surf=="UL") {
					return "20";
				}
				if(proc.Surf=="LR") {
					return "40";
				}
				if(proc.Surf=="LL") {
					return "30";
				}
			}
			if(procCode.TreatArea==TreatmentArea.Sextant) {
				//we will assume that these are very rarely billed to ins
				return "";
			}
			if(procCode.TreatArea==TreatmentArea.Surf) {
				return "";//might need to enhance this
			}
			if(procCode.TreatArea==TreatmentArea.Tooth) {
				return "";//might need to enhance this
			}
			if(procCode.TreatArea==TreatmentArea.ToothRange) {
				//already checked for blank tooth range
				if(Tooth.IsMaxillary(proc.ToothRange.Split(',')[0])) {
					return "01";
				}
				else {
					return "02";
				}
			}
			return "";
		}
Example #23
0
 ///<summary>Does not make call to db unless necessary.</summary>
 public static void SetProvForProc(Procedure proc,List<ClaimProc> ClaimProcList)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),proc,ClaimProcList);
         return;
     }
     for(int i=0;i<ClaimProcList.Count;i++) {
         if(ClaimProcList[i].ProcNum!=proc.ProcNum) {
             continue;
         }
         if(ClaimProcList[i].ProvNum==proc.ProvNum) {
             continue;//no change needed
         }
         ClaimProcList[i].ProvNum=proc.ProvNum;
         Update(ClaimProcList[i]);
     }
 }
Example #24
0
File: ProcTC.cs Project: mnisl/OD
		public static void AttachLabProc(long procNum,Procedure procLab) {
			Procedure oldProc=procLab.Copy();
			procLab.ProcNumLab=procNum;
			Procedures.Update(procLab,oldProc);
		}
Example #25
0
		private void butAdd_Click(object sender,EventArgs e) {
			if(comboProvNum.SelectedIndex==-1) {
				MsgBox.Show(this,"Please select a dentist.");
				return;
			}
			FormProcCodes FormP=new FormProcCodes();
			FormP.IsSelectionMode=true;
			FormP.ShowDialog();
			if(FormP.DialogResult!=DialogResult.OK) {
				return;
			}
			Procedure ProcCur;
			ProcCur=new Procedure();//going to be an insert, so no need to set Procedures.CurOld
			ProcCur.CodeNum = FormP.SelectedCodeNum;
			//procnum
			ProcCur.PatNum=AptCur.PatNum;
			//aptnum
			//proccode
			//ProcCur.CodeNum=ProcedureCodes.GetProcCode(ProcCur.OldCode).CodeNum;//already set
			ProcCur.ProcDate=DateTimeOD.Today;
			ProcCur.DateTP=ProcCur.ProcDate;
			//int totUnits = ProcCur.BaseUnits + ProcCur.UnitQty;
			InsPlan priplan=null;
			InsSub prisub=null;
			//Family fam=Patients.GetFamily(AptCur.PatNum);
			//Patient pat=fam.GetPatient(AptCur.PatNum);
			//InsPlan[] planList=InsPlans.Refresh(fam);
			List<PatPlan> patPlanList=PatPlans.Refresh(pat.PatNum);
			if(patPlanList.Count>0) {
				prisub=InsSubs.GetSub(patPlanList[0].InsSubNum,SubList);
				priplan=InsPlans.GetPlan(prisub.PlanNum,PlanList);
			}
			//Check if it's a medical procedure.
			double insfee;
			bool isMed = false;
			ProcCur.MedicalCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode;
			if(ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") {
				isMed = true;
			}
			//Get fee schedule for medical or dental.
			long feeSch;
			if(isMed) {
				feeSch=Fees.GetMedFeeSched(pat,PlanList,patPlanList,SubList);
			}
			else {
				feeSch=Fees.GetFeeSched(pat,PlanList,patPlanList,SubList);
			}
			//Get the fee amount for medical or dental.
			if(PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) {
				insfee=Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum,feeSch);
			}
			else {
				insfee=Fees.GetAmount0(ProcCur.CodeNum,feeSch);
			}
			if(priplan!=null && priplan.PlanType=="p") {//PPO
				double standardfee=Fees.GetAmount0(ProcCur.CodeNum,Providers.GetProv(Patients.GetProvNum(pat)).FeeSched);
				if(standardfee>insfee) {
					ProcCur.ProcFee=standardfee;
				}
				else {
					ProcCur.ProcFee=insfee;
				}
			}
			else {
				ProcCur.ProcFee=insfee;
			}
			//surf
			//ToothNum
			//Procedures.Cur.ToothRange
			//ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ProcCode).NoBillIns;
			ProcCur.Priority=0;
			ProcCur.ProcStatus=ProcStat.TP;
			long aptProvNum=ProviderC.ListShort[0].ProvNum;
			if(comboProvNum.SelectedIndex!=-1) {
				aptProvNum=ProviderC.ListShort[comboProvNum.SelectedIndex].ProvNum;
			}
			long aptProvHyg=0;
			if(comboProvHyg.SelectedIndex>0) {
				aptProvHyg=ProviderC.ListShort[comboProvHyg.SelectedIndex-1].ProvNum;
			}
			if(ProcedureCodes.GetProcCode(ProcCur.CodeNum).IsHygiene
				&& aptProvHyg != 0) {
				ProcCur.ProvNum=aptProvHyg;
			}
			else {
				ProcCur.ProvNum=aptProvNum;
			}
			if(ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProvNumDefault!=0) {//Override provider for procedures with a default provider
				ProcCur.ProvNum=ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProvNumDefault;
			}
			ProcCur.Note="";
			ProcCur.ClinicNum=pat.ClinicNum;
			//dx
			//nextaptnum
			ProcCur.DateEntryC=DateTime.Now;
			ProcCur.BaseUnits=ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits;
			ProcCur.SiteNum=pat.SiteNum;
			ProcCur.RevCode=ProcedureCodes.GetProcCode(ProcCur.CodeNum).RevenueCodeDefault;
			ProcCur.DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
			Procedures.Insert(ProcCur);
			List<Benefit> benefitList=Benefits.Refresh(patPlanList,SubList);
			Procedures.ComputeEstimates(ProcCur,pat.PatNum,new List<ClaimProc>(),true,PlanList,patPlanList,benefitList,pat.Age,SubList);
			FormProcEdit FormPE=new FormProcEdit(ProcCur,pat.Copy(),fam);
			FormPE.IsNew=true;
			if(Programs.UsingOrion) {
				FormPE.OrionProvNum=ProviderC.ListShort[comboProvNum.SelectedIndex].ProvNum;
				FormPE.OrionDentist=true;
			}
			FormPE.ShowDialog();
			if(FormPE.DialogResult==DialogResult.Cancel) {
				//any created claimprocs are automatically deleted from within procEdit window.
				try {
					Procedures.Delete(ProcCur.ProcNum);//also deletes the claimprocs
				}
				catch(Exception ex) {
					MessageBox.Show(ex.Message);
				}
				return;
			}
			else if(Programs.UsingOrion) {
				//No need to synch with Orion mode.
			}
			else {
				//Default is set to TP, so Synch is usually not needed.
				if(ProcCur.ProcStatus==ProcStat.C||ProcCur.ProcStatus==ProcStat.EC||ProcCur.ProcStatus==ProcStat.EO) {
					Recalls.Synch(pat.PatNum);
				}
			}
			/*
			FormApptProcs FormAP=new FormApptProcs();
			FormAP.AptCur=AptCur.Clone();
			//but we do need the status to be accurate:
			if (AptCur.AptStatus == ApptStatus.Planned) {
				;
			}
			else if(comboStatus.SelectedIndex==-1) {
				FormAP.AptCur.AptStatus=ApptStatus.Scheduled;
			}
			else if (AptCur.AptStatus == ApptStatus.PtNote | AptCur.AptStatus == ApptStatus.PtNoteCompleted){
				FormAP.AptCur.AptStatus = (ApptStatus)comboStatus.SelectedIndex + 7;
			}
			else {
				FormAP.AptCur.AptStatus=(ApptStatus)comboStatus.SelectedIndex+1;
			}
			FormAP.ShowDialog();
			if(FormAP.DialogResult!=DialogResult.OK){
				return;
			}*/
			bool isPlanned=AptCur.AptStatus==ApptStatus.Planned;
			Procedures.AttachToApt(ProcCur.ProcNum,AptCur.AptNum,isPlanned);
			Recalls.Synch(AptCur.PatNum);//might not be needed because TP?
			DS.Tables.Remove("Procedure");
			DS.Tables.Add(Appointments.GetApptEdit(AptCur.AptNum).Tables["Procedure"].Copy());
			FillProcedures();
			CalculateTime();
			FillTime();
		}
Example #26
0
 ///<summary>procCur can be null if not editing from within an actual procedure.  If the save is to happen within this window, then set saveToDb true.  If the object is to be altered here, but saved in a different window, then saveToDb=false.</summary>
 public FormClaimProc(ClaimProc claimProcCur,Procedure procCur,Family famCur,Patient patCur,List<InsPlan> planList,List<ClaimProcHist> histList,ref List<ClaimProcHist> loopList,List<PatPlan> patPlanList,bool saveToDb,List<InsSub> subList)
 {
     ClaimProcCur=claimProcCur;//always work directly with the original object.  Revert if we change our mind.
     ClaimProcOld=ClaimProcCur.Copy();
     proc=procCur;
     FamCur=famCur;
     PatCur=patCur;
     PlanList=planList;
     SubList=subList;
     HistList=histList;
     LoopList=loopList;
     PatPlanList=patPlanList;
     SaveToDb=saveToDb;
     InitializeComponent();// Required for Windows Form Designer support
     //can't use Lan.F because of complexity of label use
     Lan.C(this, new System.Windows.Forms.Control[]
         {
             this,
             this.label1,
             this.label9,
             this.label30,
             this.labelProcDate,
             this.label28,
             this.label29,
             this.groupClaim,
             this.radioEstimate,
             this.radioClaim,
             this.labelCodeSent,
             this.labelFeeBilled,
             this.labelRemarks,
             this.labelNotInClaim,
             this.checkNoBillIns,
             this.labelFee,
             this.labelCopayAmt,
             this.label4,
             this.groupClaimInfo,
             this.labelDedApplied,
             this.labelPaidOtherIns,
             this.labelInsPayEst,
             this.labelInsPayAmt,
             this.labelWriteOff,
             this.labelDateEntry
             //this.butRecalc
     });
     Lan.C("All", new System.Windows.Forms.Control[] {
         butOK,
         butCancel,
         butDelete,
     });
 }
		public static string GetChanges(Procedure procCur, Procedure procOld, OrionProc orionProcCur, OrionProc orionProcOld){
			Changes="";
			if(orionProcOld.DPC != orionProcCur.DPC) {
				if(Changes!="") { Changes+="\r\n"; }
				Changes+="DPC changed from "+POut.String(orionProcOld.DPC.ToString())+" to "+POut.String(orionProcCur.DPC.ToString())+".";
			}
			if(orionProcOld.DPCpost != orionProcCur.DPCpost) {
				if(Changes!=""){ Changes+="\r\n";}
		    Changes+="DPC Post Visit changed from "+POut.String(orionProcOld.DPCpost.ToString())+" to "+POut.String(orionProcCur.DPCpost.ToString())+".";
			}
			//PatNum, AptNum, PlannedAptNum should never change---------------------------------------------------------------------------------------------
			if(procOld.PatNum != procCur.PatNum) {
				if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Patient Num changed from "+procOld.PatNum+" to "+procCur.PatNum+".";
		  }
		  if(procOld.AptNum != procCur.AptNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Apt Num changed from "+procOld.AptNum+" to "+procCur.AptNum+".";
		  }
		  if(procOld.PlannedAptNum != procCur.PlannedAptNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Planned Apt Num changed from "+procOld.PlannedAptNum+" to "+procCur.PlannedAptNum+".";
			}
			//Date and time related fields------------------------------------------------------------------------------------------------------------------
		  if(procOld.DateEntryC.Date != procCur.DateEntryC.Date) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Date Entry changed from "+procOld.DateEntryC.ToShortDateString()+" to "+procCur.DateEntryC.ToShortDateString()+".";
		  }
		  if(procOld.ProcDate.Date != procCur.ProcDate.Date) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Proc Date changed from "+procOld.ProcDate.ToShortDateString()+" to "+procCur.ProcDate.ToShortDateString()+".";
		  }
		  //if(procOld.StartTime != procCur.StartTime) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Start Time changed from "+procOld.StartTime+" to "+procCur.StartTime+".";
		  //}
		  //if(procOld.StopTime != procCur.StopTime) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Stop Time changed from "+procOld.StopTime+" to "+procCur.StopTime+".";
		  //}
		  if(procOld.ProcTime != procCur.ProcTime) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Procedure Time changed from "
					+(PIn.DateT(procOld.ProcTime.ToString()).ToShortTimeString()=="12:00 AM"?"none":PIn.DateT(procOld.ProcTime.ToString()).ToShortTimeString())
					+" to "+(PIn.DateT(procCur.ProcTime.ToString()).ToShortTimeString()=="12:00 AM"?"none":PIn.DateT(procCur.ProcTime.ToString()).ToShortTimeString())+".";
		  }
		  if(procOld.ProcTimeEnd != procCur.ProcTimeEnd) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Procedure End Time changed from "
					+(PIn.DateT(procOld.ProcTimeEnd.ToString()).ToShortTimeString()=="12:00 AM"?"none":PIn.DateT(procOld.ProcTimeEnd.ToString()).ToShortTimeString())
					+" to "+(PIn.DateT(procCur.ProcTimeEnd.ToString()).ToShortTimeString()=="12:00 AM"?"none":PIn.DateT(procCur.ProcTimeEnd.ToString()).ToShortTimeString())+".";
		  }
			//Procedure, related areas, amount, hide graphics, etc.-----------------------------------------------------------------------------------------
		  if(procOld.CodeNum != procCur.CodeNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Procedure changed from "+ProcedureCodes.GetLaymanTerm(procOld.CodeNum)+" to "+ProcedureCodes.GetLaymanTerm(procCur.CodeNum)+".";
		  }
		  if(procOld.ProcFee != procCur.ProcFee) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Proc Fee changed from $"+procOld.ProcFee.ToString("F")+" to $"+procCur.ProcFee.ToString("F")+".";
		  }
		  if(procOld.ToothNum != procCur.ToothNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Tooth Num changed from "+procOld.ToothNum+" to "+procCur.ToothNum+".";
		  }
		  if(procOld.Surf != procCur.Surf) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Surface changed from "+procOld.Surf+" to "+procCur.Surf+".";
		  }
		  if(procOld.ToothRange != procCur.ToothRange) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Tooth Range changed from "+procOld.ToothRange+" to "+procCur.ToothRange+".";
		  }
			if(procOld.HideGraphics != procCur.HideGraphics) {
				if(Changes!=""){ Changes+="\r\n";}
				Changes+="Hide Graphics changed from "+(procOld.HideGraphics?"Hide Graphics":"Do Not Hide Graphics")
					+" to "+(procCur.HideGraphics?"Hide Graphics":"Do Not Hide Graphics")+".";
			}
			//Provider, Diagnosis, Priority, Place of Service, Clinic, Site---------------------------------------------------------------------------------
		  if(procOld.ProvNum != procCur.ProvNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Provider changed from "+Providers.GetAbbr(procOld.ProvNum)+" to "+Providers.GetAbbr(procCur.ProvNum)+".";
		  }
		  if(procOld.Dx != procCur.Dx) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Diagnosis changed from "+DefC.GetDef(DefCat.Diagnosis,procOld.Dx).ItemName
					+" to "+DefC.GetDef(DefCat.Diagnosis,procCur.Dx).ItemName+".";
		  }
		  if(procOld.Priority != procCur.Priority) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Priority changed from "+((procOld.Priority!=0)?DefC.GetDef(DefCat.TxPriorities,procOld.Priority).ItemName:"no priority")
					+" to "+((procCur.Priority!=0)?DefC.GetDef(DefCat.TxPriorities,procCur.Priority).ItemName:"no priority")+".";
		  }
		  if(procOld.PlaceService != procCur.PlaceService) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Place of Service changed from "+procOld.PlaceService.ToString()+" to "+procCur.PlaceService.ToString()+".";
		  }
		  if(procOld.ClinicNum != procCur.ClinicNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Clinic changed from "+Clinics.GetDesc(procOld.ClinicNum)+" to "+Clinics.GetDesc(procCur.ClinicNum)+".";
		  }
		  if(procOld.SiteNum != procCur.SiteNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Site changed from "+(procOld.SiteNum==0?"none":Sites.GetDescription(procOld.SiteNum))
					+" to "+(procCur.SiteNum==0?"none":Sites.GetDescription(procCur.SiteNum))+".";
		  }
			//Prosthesis reverse lookup---------------------------------------------------------------------------------------------------------------------
		  if(procOld.Prosthesis != procCur.Prosthesis) {
		    if(Changes!=""){ Changes+="\r\n";}
				string prosthesisOld;
				switch(procOld.Prosthesis.ToString()){
					case "": prosthesisOld="no"; break;
					case "I":	prosthesisOld="Initial"; break;
					case "R": prosthesisOld="Replacement"; break;
					default: prosthesisOld="error"; break;
				}
				string prosthesisCur;
				switch(procCur.Prosthesis.ToString()){
					case "": prosthesisCur="no"; break;
					case "I": prosthesisCur="Initial"; break;
					case "R": prosthesisCur="Replacement"; break;
					default: prosthesisCur="error"; break;
				}
		    Changes+="Prosthesis changed from "+prosthesisOld+" to "+prosthesisCur+".";
		  }
		  if(procOld.DateOriginalProsth.Date != procCur.DateOriginalProsth.Date) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Date of Original Prosthesis changed from "+procOld.DateOriginalProsth.ToShortDateString()
					+" to "+procCur.DateOriginalProsth.ToShortDateString()+".";
		  }
			//Claim Note & Orion Proc Fields----------------------------------------------------------------------------------------------------------------
		  if(procOld.ClaimNote != procCur.ClaimNote) {
		    if(Changes!=""){ Changes+="\r\n";}
				Changes+="Claim Note changed from "+(procOld.ClaimNote==""?"none":"'"+procOld.ClaimNote+"'")
					+" to "+(procCur.ClaimNote==""?"none":"'"+procCur.ClaimNote+"'");
		  }
			if(orionProcOld.OrionProcNum != orionProcCur.OrionProcNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Orion Proc Num changed from "+POut.Long(orionProcOld.OrionProcNum)+" to "+POut.Long(orionProcCur.OrionProcNum)+".";
		  }
			if(orionProcOld.ProcNum != orionProcCur.ProcNum) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Proc Num changed from "+POut.Long(orionProcOld.ProcNum)+" to "+POut.Long(orionProcCur.ProcNum)+".";
		  }
			//Orion Status Reverse Lookup for Description----------------------------------//None is equivalent to TP---------------------------------------
			if(orionProcOld.Status2 != orionProcCur.Status2 && !(orionProcOld.Status2==OrionStatus.None && orionProcCur.Status2==OrionStatus.TP)) {
		    if(Changes!=""){ Changes+="\r\n";}
				string[] status2=new string[2];
				string[] status2Desc=new string[2];
				status2[0]=orionProcOld.Status2.ToString();
				status2[1]=orionProcCur.Status2.ToString();
				for(int i=0;i<2;i++){
					switch(status2[i]){
						case "None":		status2Desc[i]="TP-treatment planned"; break;
						case "TP":			status2Desc[i]="TP-treatment planned"; break;
						case "C":				status2Desc[i]="C-completed";	break;
						case "E":				status2Desc[i]="E-existing prior to incarceration"; break;
						case "R":				status2Desc[i]="R-refused treatment"; break;
						case "RO":			status2Desc[i]="RO-referred out to specialist"; break;
						case "CS":			status2Desc[i]="CS-completed by specialist"; break;
						case "CR":			status2Desc[i]="CR-completed by registry"; break;
						case "CA_Tx":		status2Desc[i]="CA_Tx-cancelled, tx plan changed"; break;
						case "CA_EPRD": status2Desc[i]="CA_EPRD-cancelled, eligible parole"; break;
						case "CA_P/D":	status2Desc[i]="CA_P/D--cancelled, parole/discharge"; break;
						case "S":				status2Desc[i]="S-suspended, unacceptable plaque"; break;
						case "ST":			status2Desc[i]="ST-stop clock, multi visit"; break;
						case "W":				status2Desc[i]="W-watch"; break;
						case "A":				status2Desc[i]="A-alternative"; break;
						default:				status2Desc[i]="error"; break;
					}
				}
		    Changes+="Orion Procedure Status changed from "+status2Desc[0]+" to "+status2Desc[1]+".";
		  }
			//Other orion fields----------------------------------------------------------------------------------------------------------------------------
			if(orionProcOld.DateScheduleBy.Date != orionProcCur.DateScheduleBy.Date) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Date Schedule By changed from "+orionProcOld.DateScheduleBy.ToShortDateString()
					+" to "+orionProcCur.DateScheduleBy.ToShortDateString()+".";
		  }
			if(orionProcOld.DateStopClock.Date != orionProcCur.DateStopClock.Date) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Date Stop Clock changed from "+orionProcOld.DateStopClock.ToShortDateString()
					+" to "+orionProcCur.DateStopClock.ToShortDateString()+".";
		  }
			if(orionProcOld.IsOnCall != orionProcCur.IsOnCall) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Is On Call changed from "+(orionProcOld.IsOnCall?"Is On Call":"Is Not On Call")
					+" to "+(orionProcCur.IsOnCall?"Is On Call":"Is Not On Call")+".";
		  }
			if(orionProcOld.IsEffectiveComm != orionProcCur.IsEffectiveComm) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Is Effective Comm changed from "+(orionProcOld.IsEffectiveComm?"Is an Effective Communicator":"Is Not an Effective Communicator")
					+" to "+(orionProcCur.IsEffectiveComm?"Is an Effective Communicator":"Is Not an Effective Communicator")+".";
		  }
			if(orionProcOld.IsRepair != orionProcCur.IsRepair) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Is Repair changed from "+(orionProcOld.IsRepair?"Is a Repair":"Is Not a Repair")
					+" to "+(orionProcCur.IsRepair?"Is a Repair":"Is Not a Repair")+".";
		  }
			//Medical fields--------------------------------------------------------------------------------------------------------------------------------
		  if(procOld.MedicalCode != procCur.MedicalCode) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Medical Code changed from "+(procOld.MedicalCode==""?"none":procOld.MedicalCode)
					+" to "+(procCur.MedicalCode==""?"none":procCur.MedicalCode)+".";
		  }
		  if(procOld.DiagnosticCode != procCur.DiagnosticCode) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Diagnostic Code changed from "+(procOld.DiagnosticCode==""?"none":procOld.DiagnosticCode)
					+" to "+(procCur.DiagnosticCode==""?"none":procCur.DiagnosticCode)+".";
			}
		  if(procOld.IsPrincDiag != procCur.IsPrincDiag) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Is Princ Diag changed from "+(procOld.IsPrincDiag?"Principal Diagnosis":"Not Principal Diagnosis")
					+" to "+(procCur.IsPrincDiag?"Principal Diagnosis":"Not Principal Diagnosis")+".";
		  }
		  //if(procOld.RevCode != procCur.RevCode) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Rev Code changed from "+POut.String(procOld.RevCode)+"' to '"+POut.String(procCur.RevCode)+".";
		  //}
			//Proc status and billing fields----------------------------------------------------------------------------------------------------------------
		  if(procOld.ProcStatus != procCur.ProcStatus) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Procedure Status changed from "+procOld.ProcStatus.ToString()+" to "+procCur.ProcStatus.ToString()+".";
		  }
		  if(procOld.DateTP.Date != procCur.DateTP.Date && procOld.DateTP.Date!=DateTime.MinValue.Date) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Date TP changed from "+procOld.DateTP.ToShortDateString()+" to "+procCur.DateTP.ToShortDateString()+".";
		  }
		  //if(procOld.BillingTypeOne != procCur.BillingTypeOne) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Billing Type One changed from "+(procOld.BillingTypeOne!=0?DefC.GetDef(DefCat.BillingTypes,procOld.BillingTypeOne).ItemName:"none")
			//		+" to "+(procCur.BillingTypeOne!=0?DefC.GetDef(DefCat.BillingTypes,procCur.BillingTypeOne).ItemName:"none")+".";
		  //}
		  //if(procOld.BillingTypeTwo != procCur.BillingTypeTwo) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Billing Type Two changed from "+(procOld.BillingTypeTwo!=0?DefC.GetDef(DefCat.BillingTypes,procOld.BillingTypeTwo).ItemName:"none")
			//		+" to "+(procCur.BillingTypeTwo!=0?DefC.GetDef(DefCat.BillingTypes,procCur.BillingTypeTwo).ItemName:"none")+".";
		  //}
		  if(procOld.ProcNumLab != procCur.ProcNumLab) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Proc Num Lab changed from "+POut.Long(procOld.ProcNumLab)+" to "+POut.Long(procCur.ProcNumLab)+".";
		  }
		  //if(procOld.UnitCode != procCur.UnitCode) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Unit Code changed from "+POut.String(procOld.UnitCode)+" to "+POut.String(procCur.UnitCode)+".";
		  //}
			//UnitQty, Canadian Type Codes, and Note--------------------------------------------------------------------------------------------------------
		  if(procOld.UnitQty != procCur.UnitQty) {
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Unit Quantity changed from "+POut.Int(procOld.UnitQty)+" to "+POut.Int(procCur.UnitQty)+".";
		  }
		  //if(procOld.CanadianTypeCodes != procCur.CanadianTypeCodes) {
		  //  if(Changes!=""){ Changes+="\r\n";}
		  //  Changes+="Canadian Code Type changed from "+POut.String(procOld.CanadianTypeCodes)+" to "+POut.String(procCur.CanadianTypeCodes)+".";
		 // }
			if(procOld.Note != procCur.Note && !(procOld.Note==null && procCur.Note=="")) {//Null note is equivalent to an empty note string.
		    if(Changes!=""){ Changes+="\r\n";}
		    Changes+="Note changed from "+(procOld.Note==""?"none":"'"+procOld.Note+"'")
					+" to "+(procCur.Note==""?"none":"'"+procCur.Note+"'");
		  }
			return Changes;
		}
Example #28
0
        public static int Insert(Procedure proc)
        {
            if (PrefB.RandomKeys)
            {
                proc.ProcNum = MiscDataB.GetKey("procedurelog", "ProcNum");
            }
            string command = "INSERT INTO procedurelog (";

            if (PrefB.RandomKeys)
            {
                command += "ProcNum,";
            }
            command += "PatNum, AptNum, ADACode, ProcDate,ProcFee,Surf,"
                       + "ToothNum,ToothRange,Priority,ProcStatus,ProvNum,"
                       + "Dx,PlannedAptNum,PlaceService,Prosthesis,DateOriginalProsth,ClaimNote,"
                       + "DateEntryC,ClinicNum,MedicalCode,DiagnosticCode,IsPrincDiag,ProcNumLab) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(proc.ProcNum) + "', ";
            }
            command +=
                "'" + POut.PInt(proc.PatNum) + "', "
                + "'" + POut.PInt(proc.AptNum) + "', "
                + "'" + POut.PString(proc.ADACode) + "', "
                + POut.PDate(proc.ProcDate) + ", "
                + "'" + POut.PDouble(proc.ProcFee) + "', "
                + "'" + POut.PString(proc.Surf) + "', "
                + "'" + POut.PString(proc.ToothNum) + "', "
                + "'" + POut.PString(proc.ToothRange) + "', "
                + "'" + POut.PInt(proc.Priority) + "', "
                + "'" + POut.PInt((int)proc.ProcStatus) + "', "
                + "'" + POut.PInt(proc.ProvNum) + "', "
                + "'" + POut.PInt(proc.Dx) + "', "
                + "'" + POut.PInt(proc.PlannedAptNum) + "', "
                + "'" + POut.PInt((int)proc.PlaceService) + "', "
                + "'" + POut.PString(proc.Prosthesis) + "', "
                + POut.PDate(proc.DateOriginalProsth) + ", "
                + "'" + POut.PString(proc.ClaimNote) + "', ";
            if (DataConnection.DBtype == DatabaseType.Oracle)
            {
                command += POut.PDateT(MiscDataB.GetNowDateTime());
            }
            else              //Assume MySQL
            {
                command += "NOW()";
            }
            command += ", "          //DateEntryC
                       + "'" + POut.PInt(proc.ClinicNum) + "', "
                       + "'" + POut.PString(proc.MedicalCode) + "', "
                       + "'" + POut.PString(proc.DiagnosticCode) + "', "
                       + "'" + POut.PBool(proc.IsPrincDiag) + "', "
                       + "'" + POut.PInt(proc.ProcNumLab) + "')";
            //MessageBox.Show(cmd.CommandText);
            DataConnection dcon = new DataConnection();

            if (PrefB.RandomKeys)
            {
                dcon.NonQ(command);
            }
            else
            {
                dcon.NonQ(command, true);
                proc.ProcNum = dcon.InsertID;
            }
            if (proc.Note != "")
            {
                ProcNote note = new ProcNote();
                note.PatNum  = proc.PatNum;
                note.ProcNum = proc.ProcNum;
                note.UserNum = proc.UserNum;
                note.Note    = proc.Note;
                ProcNoteB.Insert(note);
            }
            return(proc.ProcNum);
        }
Example #29
0
		private Claim CreateClaim(string claimType,List<PatPlan> patPlanList,List<InsPlan> planList,List<ClaimProc> claimProcList,Procedure proc,List<InsSub> subList) {
			long claimFormNum=0;
			InsPlan planCur=new InsPlan();
			InsSub subCur=new InsSub();
			Relat relatOther=Relat.Self;
			long clinicNum=proc.ClinicNum;
			PlaceOfService placeService=proc.PlaceService;
			switch(claimType) {
				case "P":
					subCur=InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList,PatPlans.GetOrdinal(PriSecMed.Primary,patPlanList,planList,subList)),subList);
					planCur=InsPlans.GetPlan(subCur.PlanNum,planList);
					break;
				case "S":
					subCur=InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList,PatPlans.GetOrdinal(PriSecMed.Secondary,patPlanList,planList,subList)),subList);
					planCur=InsPlans.GetPlan(subCur.PlanNum,planList);
					break;
				case "Med":
					//It's already been verified that a med plan exists
					subCur=InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList,PatPlans.GetOrdinal(PriSecMed.Medical,patPlanList,planList,subList)),subList);
					planCur=InsPlans.GetPlan(subCur.PlanNum,planList);
					break;
			}
			ClaimProc claimProcCur=Procedures.GetClaimProcEstimate(proc.ProcNum,claimProcList,planCur,subCur.InsSubNum);
			if(claimProcCur==null) {
				claimProcCur=new ClaimProc();
				ClaimProcs.CreateEst(claimProcCur,proc,planCur,subCur);
			}
			Claim claimCur=new Claim();
			claimCur.PatNum=proc.PatNum;
			claimCur.DateService=proc.ProcDate;
			claimCur.ClinicNum=proc.ClinicNum;
			claimCur.PlaceService=proc.PlaceService;
			claimCur.ClaimStatus="W";
			claimCur.DateSent=DateTimeOD.Today;
			claimCur.PlanNum=planCur.PlanNum;
			claimCur.InsSubNum=subCur.InsSubNum;
			InsSub sub;
			switch(claimType) {
				case "P":
					claimCur.PatRelat=PatPlans.GetRelat(patPlanList,PatPlans.GetOrdinal(PriSecMed.Primary,patPlanList,planList,subList));
					claimCur.ClaimType="P";
					claimCur.InsSubNum2=PatPlans.GetInsSubNum(patPlanList,PatPlans.GetOrdinal(PriSecMed.Secondary,patPlanList,planList,subList));
					sub=InsSubs.GetSub(claimCur.InsSubNum2,subList);
					if(sub.PlanNum>0 && InsPlans.RefreshOne(sub.PlanNum).IsMedical) {
						claimCur.PlanNum2=0;//no sec ins
						claimCur.PatRelat2=Relat.Self;
					}
					else {
						claimCur.PlanNum2=sub.PlanNum;//might be 0 if no sec ins
						claimCur.PatRelat2=PatPlans.GetRelat(patPlanList,PatPlans.GetOrdinal(PriSecMed.Secondary,patPlanList,planList,subList));
					}
					break;
				case "S":
					claimCur.PatRelat=PatPlans.GetRelat(patPlanList,PatPlans.GetOrdinal(PriSecMed.Secondary,patPlanList,planList,subList));
					claimCur.ClaimType="S";
					claimCur.InsSubNum2=PatPlans.GetInsSubNum(patPlanList,PatPlans.GetOrdinal(PriSecMed.Primary,patPlanList,planList,subList));
					sub=InsSubs.GetSub(claimCur.InsSubNum2,subList);
					claimCur.PlanNum2=sub.PlanNum;
					claimCur.PatRelat2=PatPlans.GetRelat(patPlanList,PatPlans.GetOrdinal(PriSecMed.Primary,patPlanList,planList,subList));
					break;
				case "Med":
					claimCur.PatRelat=PatPlans.GetFromList(patPlanList,subCur.InsSubNum).Relationship;
					claimCur.ClaimType="Other";
					if(PrefC.GetBool(PrefName.ClaimMedTypeIsInstWhenInsPlanIsMedical)){
						claimCur.MedType=EnumClaimMedType.Institutional;
					}
					else{
						claimCur.MedType=EnumClaimMedType.Medical;
					}
					break;
				case "Other":
					claimCur.PatRelat=relatOther;
					claimCur.ClaimType="Other";
					//plannum2 is not automatically filled in.
					claimCur.ClaimForm=claimFormNum;
					if(planCur.IsMedical){
						if(PrefC.GetBool(PrefName.ClaimMedTypeIsInstWhenInsPlanIsMedical)){
							claimCur.MedType=EnumClaimMedType.Institutional;
						}
						else{
							claimCur.MedType=EnumClaimMedType.Medical;
						}
					}
					break;
			}
			if(planCur.PlanType=="c"){//if capitation
				claimCur.ClaimType="Cap";
			}
			claimCur.ProvTreat=proc.ProvNum;
			if(Providers.GetIsSec(proc.ProvNum)) {
				claimCur.ProvTreat=Patients.GetPat(proc.PatNum).PriProv;
				//OK if zero, because auto select first in list when open claim
			}
			claimCur.IsProsthesis="N";
			claimCur.ProvBill=Providers.GetBillingProvNum(claimCur.ProvTreat,claimCur.ClinicNum);//OK if zero, because it will get fixed in claim
			claimCur.EmployRelated=YN.No;
			claimCur.ClaimForm=planCur.ClaimFormNum;
			Claims.Insert(claimCur);
			//attach procedure
			claimProcCur.ClaimNum=claimCur.ClaimNum;
			if(planCur.PlanType=="c") {//if capitation
				claimProcCur.Status=ClaimProcStatus.CapClaim;
			}
			else {
				claimProcCur.Status=ClaimProcStatus.NotReceived;
			}
			if(planCur.UseAltCode && (ProcedureCodes.GetProcCode(proc.CodeNum).AlternateCode1!="")) {
				claimProcCur.CodeSent=ProcedureCodes.GetProcCode(proc.CodeNum).AlternateCode1;
			}
			else if(planCur.IsMedical && proc.MedicalCode!="") {
				claimProcCur.CodeSent=proc.MedicalCode;
			}
			else {
				claimProcCur.CodeSent=ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode;
				if(claimProcCur.CodeSent.Length>5 && claimProcCur.CodeSent.Substring(0,1)=="D") {
					claimProcCur.CodeSent=claimProcCur.CodeSent.Substring(0,5);
				}
				if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canadian. en-CA or fr-CA
					if(claimProcCur.CodeSent.Length>5) {//In Canadian e-claims, codes can contain letters or numbers and cannot be longer than 5 characters.
						claimProcCur.CodeSent=claimProcCur.CodeSent.Substring(0,5);
					}
				}
			}
			claimProcCur.LineNumber=(byte)1;
			ClaimProcs.Update(claimProcCur);
			return claimCur;
		}
Example #30
0
		private void butOK_Click(object sender, System.EventArgs e) {
			RepeatCharge[] chargeList=RepeatCharges.Refresh(0);//Gets all repeating charges for all patients, they may be disabled
			int countAdded=0;
			int claimsAdded=0;
			DateTime startDate;
			Procedure proc;
			for(int i=0;i<chargeList.Length;i++){
				if(!chargeList[i].IsEnabled) {//first make sure it is not disabled
					continue;
				}
				if(chargeList[i].DateStart>DateTime.Today){//not started yet
					continue;
				}
				//if(chargeList[i].DateStop.Year>1880//not blank
				//	&& chargeList[i].DateStop<DateTime.Today)//but already ended
				//{
				//	continue;
				//}
				//get a list dates of all completed procedures with this Code and patNum
				ArrayList ALdates=RepeatCharges.GetDates(ProcedureCodes.GetCodeNum(chargeList[i].ProcCode),chargeList[i].PatNum);
				startDate=chargeList[i].DateStart;
				//This is the repeating date using the old methodology.  It is necessary for checking if the repeating procedure was already added using the old methodology.
				DateTime possibleDateOld=startDate;
				//This is a more accurate repeating date which will allow procedures to be added on the 28th and later.
				DateTime possibleDateNew=startDate;
				int countMonths=0;
				//start looping through possible dates, beginning with the start date of the repeating charge
				while(possibleDateNew<=DateTime.Today) {
					//Only allow back dating up to one month and 20 days.
					if(possibleDateNew<DateTime.Today.AddDays(-50)) {
						possibleDateOld=possibleDateOld.AddMonths(1);
						countMonths++;
						possibleDateNew=startDate.AddMonths(countMonths);
						continue;//don't go back more than one month and 20 days
					}
					//check to see if the possible date is present in the list
					if(ALdates.Contains(possibleDateNew)
						|| ALdates.Contains(possibleDateOld))
					{
						possibleDateOld=possibleDateOld.AddMonths(1);
						countMonths++;
						possibleDateNew=startDate.AddMonths(countMonths);
						continue;
					}
					if(chargeList[i].DateStop.Year>1880//not blank
						&& chargeList[i].DateStop < possibleDateNew)//but already ended
					{
						break;
					}
					//otherwise, insert a procedure to db
					proc=new Procedure();
					proc.CodeNum=ProcedureCodes.GetCodeNum(chargeList[i].ProcCode);
					proc.DateEntryC=DateTimeOD.Today;
					proc.PatNum=chargeList[i].PatNum;
					proc.ProcDate=possibleDateNew;
					proc.DateTP=possibleDateNew;
					proc.ProcFee=chargeList[i].ChargeAmt;
					proc.ProcStatus=ProcStat.C;
					proc.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
					proc.MedicalCode=ProcedureCodes.GetProcCode(proc.CodeNum).MedicalCode;
					proc.BaseUnits = ProcedureCodes.GetProcCode(proc.CodeNum).BaseUnits;
					proc.DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
					//Check if the repeating charge has been flagged to copy it's note into the billing note of the procedure.
					if(chargeList[i].CopyNoteToProc) {
						proc.BillingNote=chargeList[i].Note;
					}
					Procedures.Insert(proc);//no recall synch needed because dental offices don't use this feature
					countAdded++;
					possibleDateOld=possibleDateOld.AddMonths(1);
					countMonths++;
					possibleDateNew=startDate.AddMonths(countMonths);
					if(chargeList[i].CreatesClaim && !ProcedureCodes.GetProcCode(chargeList[i].ProcCode).NoBillIns) {
						List<PatPlan> patPlanList=PatPlans.Refresh(chargeList[i].PatNum);
						List<InsSub> subList=InsSubs.RefreshForFam(Patients.GetFamily(chargeList[i].PatNum));
						List<InsPlan> insPlanList=InsPlans.RefreshForSubList(subList);;
						List<Benefit> benefitList=Benefits.Refresh(patPlanList,subList);
						Claim claimCur;
						List<Procedure> procCurList=new List<Procedure>();
						procCurList.Add(proc);
						if(patPlanList.Count==0) {//no current insurance, do not create a claim
							continue;
						}
						//create the claimprocs
						Procedures.ComputeEstimates(proc,proc.PatNum,new List<ClaimProc>(),true,insPlanList,patPlanList,benefitList,Patients.GetPat(proc.PatNum).Age,subList);
						//get claimprocs for this proc, may be more than one
						List<ClaimProc> claimProcList=ClaimProcs.GetForProc(ClaimProcs.Refresh(proc.PatNum),proc.ProcNum);
						string claimType="P";
						if(patPlanList.Count==1 && PatPlans.GetOrdinal(PriSecMed.Medical,patPlanList,insPlanList,subList)>0) {//if there's exactly one medical plan
							claimType="Med";
						}
						claimCur=CreateClaim(claimType,patPlanList,insPlanList,claimProcList,proc,subList);
						claimProcList=ClaimProcs.Refresh(proc.PatNum);
						if(claimCur.ClaimNum==0) {
							continue;
						}
						claimsAdded++;
						ClaimL.CalculateAndUpdate(procCurList,insPlanList,claimCur,patPlanList,benefitList,Patients.GetPat(proc.PatNum).Age,subList);
						if(PatPlans.GetOrdinal(PriSecMed.Secondary,patPlanList,insPlanList,subList)>0 //if there exists a secondary plan
							&& !CultureInfo.CurrentCulture.Name.EndsWith("CA"))//and not canada (don't create secondary claim for canada)
						{
							claimCur=CreateClaim("S",patPlanList,insPlanList,claimProcList,proc,subList);
							if(claimCur.ClaimNum==0) {
								continue;
							}
							claimsAdded++;
							claimProcList=ClaimProcs.Refresh(proc.PatNum);
							claimCur.ClaimStatus="H";
							ClaimL.CalculateAndUpdate(procCurList,insPlanList,claimCur,patPlanList,benefitList,Patients.GetPat(proc.PatNum).Age,subList);
						}
					}
				}
			}
			//MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added."));
			MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added.")+"\r\n"+claimsAdded.ToString()+" "+Lan.g(this,"claims added."));
			DialogResult=DialogResult.OK;
		}
Example #31
0
 private void FormClaimProcEdit_Load(object sender, System.EventArgs e)
 {
     if(NoPermissionProc){//blocks users with no permission to edit procedure
         butOK.Enabled=false;
         butDelete.Enabled=false;
     }
     else if(ClaimProcCur.ClaimNum>0){
         Claim claim=Claims.GetClaim(ClaimProcCur.ClaimNum);
         if(!Security.IsAuthorized(Permissions.ClaimSentEdit,claim.DateSent,true)) {//attached to claim, no permission for claims.
             butOK.Enabled=false;
             butDelete.Enabled=false;
         }
     }
     InsSub sub=InsSubs.GetSub(ClaimProcCur.InsSubNum,SubList);
     Plan=InsPlans.GetPlan(sub.PlanNum,PlanList);
     PatPlanNum=PatPlans.GetPatPlanNum(sub.InsSubNum,PatPlanList);
     BenefitList=null;//only fill it if proc
     PaidOtherInsTotal=ClaimProcs.GetPaidOtherInsTotal(ClaimProcCur,PatPlanList);
     PaidOtherInsBaseEst=ClaimProcs.GetPaidOtherInsBaseEst(ClaimProcCur,PatPlanList);
     WriteOffOtherIns=ClaimProcs.GetWriteOffOtherIns(ClaimProcCur,PatPlanList);
     List<InsSub> subList=InsSubs.RefreshForFam(FamCur);
     textInsPlan.Text=InsPlans.GetDescript(ClaimProcCur.PlanNum,FamCur,PlanList,ClaimProcCur.InsSubNum,subList);
     checkNoBillIns.Checked=ClaimProcCur.NoBillIns;
     if(ClaimProcCur.ClaimPaymentNum>0){//attached to ins check
         textDateCP.ReadOnly=true;//DateCP always the same as the payment date and can't be changed here
         if(!Security.IsAuthorized(Permissions.InsPayEdit,ClaimProcCur.DateCP)){
             butOK.Enabled=false;
         }
         textInsPayAmt.ReadOnly=true;
         labelAttachedToCheck.Visible=true;
         butDelete.Enabled=false;
     }
     //This new expanded security prevents editing completed claimprocs, even if not attached to an ins check.
     //For example, a zero payment with a writeoff amount.  Must prevent changing that date.
     else if((ClaimProcCur.Status==ClaimProcStatus.CapComplete
         || ClaimProcCur.Status==ClaimProcStatus.Received
         || ClaimProcCur.Status==ClaimProcStatus.Supplemental)
         && !Security.IsAuthorized(Permissions.InsPayEdit,ClaimProcCur.DateCP))//
     {
         textDateCP.ReadOnly=true;
         butOK.Enabled=false;
         textInsPayAmt.ReadOnly=true;
         labelAttachedToCheck.Visible=false;
         //listStatus.Enabled=false;//this is handled in the mousedown event
         butDelete.Enabled=false;
     }
     else{
         labelAttachedToCheck.Visible=false;
     }
     if(ClaimProcCur.ProcNum==0){//total payment for a claim
         IsProc=false;
         textDescription.Text="Total Payment";
         textProcDate.ReadOnly=false;
     }
     else{
         IsProc=true;
         BenefitList=Benefits.RefreshForPlan(ClaimProcCur.PlanNum,PatPlanNum);
         if(proc==null){
             proc=Procedures.GetOneProc(ClaimProcCur.ProcNum,false);
         }
         textDescription.Text=ProcedureCodes.GetProcCode(proc.CodeNum).Descript;
         textProcDate.ReadOnly=true;//user not allowed to edit ProcDate unless it's for a total payment
     }
     if(ClaimProcCur.ClaimNum>0){//attached to claim
         radioClaim.Checked=true;
         checkNoBillIns.Enabled=false;
         if(IsInClaim){//(not from the procedure window)
             labelNotInClaim.Visible=false;
         }
         else{//must be accessing it from the Procedure window
             textCodeSent.ReadOnly=true;
             textFeeBilled.ReadOnly=true;
             labelNotInClaim.Visible=true;
             textDedApplied.ReadOnly=true;
             textInsPayEst.ReadOnly=true;
             textInsPayAmt.ReadOnly=true;
             textWriteOff.ReadOnly=true;
         }
         groupClaimInfo.Visible=true;
         if(ClaimProcCur.ProcNum==0){//if a total entry rather than by proc
             panelEstimateInfo.Visible=false;
             //labelPatTotal.Visible=false;
             labelInsPayAmt.Font=new Font(labelInsPayAmt.Font,FontStyle.Bold);
             labelProcDate.Visible=false;
             textProcDate.Visible=false;
             labelCodeSent.Visible=false;
             textCodeSent.Visible=false;
             labelFeeBilled.Visible=false;
             textFeeBilled.Visible=false;
         }
         else if(ClaimProcCur.Status==ClaimProcStatus.Received){
             labelInsPayAmt.Font=new Font(labelInsPayAmt.Font,FontStyle.Bold);
         }
         //butOK.Enabled=false;
         //butDelete.Enabled=false;
         //MessageBox.Show(panelEstimateInfo.Visible.ToString());
     }
     else //not attached to a claim
         if(ClaimProcCur.PlanNum>0
         && (ClaimProcCur.Status==ClaimProcStatus.CapEstimate
         || ClaimProcCur.Status==ClaimProcStatus.CapComplete))
     {
         //InsPlans.Cur.PlanType=="c"){//capitation proc,whether Estimate or CapComplete,never billed to ins
         foreach(System.Windows.Forms.Control control in panelEstimateInfo.Controls){
             control.Visible=false;
         }
         foreach(System.Windows.Forms.Control control in groupClaimInfo.Controls){
             control.Visible=false;
         }
         groupClaimInfo.Text="";
         labelFee.Visible=true;
         textFee.Visible=true;
         labelCopayAmt.Visible=true;
         textCopayAmt.Visible=true;
         textCopayOverride.Visible=true;
         if(ClaimProcCur.Status==ClaimProcStatus.CapEstimate) {
             labelWriteOffEst.Visible=true;
             textWriteOffEst.Visible=true;
         }
         else {//capcomplete
             labelWriteOff.Visible=true;
             textWriteOff.Visible=true;
         }
         //labelPatTotal.Visible=true;
         groupClaim.Visible=false;
         labelNotInClaim.Visible=false;
     }
     else{//estimate
         groupClaimInfo.Visible=false;
         radioEstimate.Checked=true;
         labelNotInClaim.Visible=false;
         panelClaimExtras.Visible=false;
     }
     comboStatus.Items.Clear();
     comboStatus.Items.Add(Lan.g(this,"Estimate"));
     comboStatus.Items.Add(Lan.g(this,"Not Received"));
     comboStatus.Items.Add(Lan.g(this,"Received"));
     comboStatus.Items.Add(Lan.g(this,"PreAuthorization"));
     comboStatus.Items.Add(Lan.g(this,"Supplemental"));
     comboStatus.Items.Add(Lan.g(this,"CapClaim"));
     comboStatus.Items.Add(Lan.g(this,"CapEstimate"));
     comboStatus.Items.Add(Lan.g(this,"CapComplete"));
     SetComboStatus(ClaimProcCur.Status);
     if(ClaimProcCur.Status==ClaimProcStatus.Received || ClaimProcCur.Status==ClaimProcStatus.Supplemental){
         labelDateEntry.Visible=true;
         textDateEntry.Visible=true;
     }
     else{
         labelDateEntry.Visible=false;
         textDateEntry.Visible=false;
     }
     comboProvider.Items.Clear();
     for(int i=0;i<ProviderC.ListShort.Count;i++){
         comboProvider.Items.Add(ProviderC.ListShort[i].Abbr);
         if(ClaimProcCur.ProvNum==ProviderC.ListShort[i].ProvNum){
             comboProvider.SelectedIndex=i;
         }
     }
     //this is not used, because the provider might simply be hidden. See bottom of page.
     //if(listProv.SelectedIndex==-1){
     //	listProv.SelectedIndex=0;//there should always be a provider
     //}
     if(PrefC.GetBool(PrefName.EasyNoClinics)) {
         labelClinic.Visible=false;
         textClinic.Visible=false;
     }
     else {
         textClinic.Text=Clinics.GetDesc(ClaimProcCur.ClinicNum);
     }
     textDateEntry.Text=ClaimProcCur.DateEntry.ToShortDateString();
     if(ClaimProcCur.ProcDate.Year<1880){
         textProcDate.Text="";
     }
     else{
         textProcDate.Text=ClaimProcCur.ProcDate.ToShortDateString();
     }
     if(ClaimProcCur.DateCP.Year<1880){
         textDateCP.Text="";
     }
     else{
         textDateCP.Text=ClaimProcCur.DateCP.ToShortDateString();
     }
     textCodeSent.Text=ClaimProcCur.CodeSent;
     textFeeBilled.Text=ClaimProcCur.FeeBilled.ToString("n");
     textRemarks.Text=ClaimProcCur.Remarks;
     FillInitialAmounts();
     ComputeAmounts();
     //MessageBox.Show(panelEstimateInfo.Visible.ToString());
 }
Example #32
0
        ///<summary>Updates only the changed columns.</summary>
        public static int Update(Procedure proc, Procedure oldProc)
        {
            bool   comma = false;
            string c     = "UPDATE procedurelog SET ";

            if (proc.PatNum != oldProc.PatNum)
            {
                c    += "PatNum = '" + POut.PInt(proc.PatNum) + "'";
                comma = true;
            }
            if (proc.AptNum != oldProc.AptNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "AptNum = '" + POut.PInt(proc.AptNum) + "'";
                comma = true;
            }
            if (proc.ADACode != oldProc.ADACode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ADACode = '" + POut.PString(proc.ADACode) + "'";
                comma = true;
            }
            if (proc.ProcDate != oldProc.ProcDate)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcDate = " + POut.PDate(proc.ProcDate);
                comma = true;
            }
            if (proc.ProcFee != oldProc.ProcFee)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcFee = '" + POut.PDouble(proc.ProcFee) + "'";
                comma = true;
            }
            if (proc.Surf != oldProc.Surf)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Surf = '" + POut.PString(proc.Surf) + "'";
                comma = true;
            }
            if (proc.ToothNum != oldProc.ToothNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ToothNum = '" + POut.PString(proc.ToothNum) + "'";
                comma = true;
            }
            if (proc.ToothRange != oldProc.ToothRange)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ToothRange = '" + POut.PString(proc.ToothRange) + "'";
                comma = true;
            }
            if (proc.Priority != oldProc.Priority)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Priority = '" + POut.PInt(proc.Priority) + "'";
                comma = true;
            }
            if (proc.ProcStatus != oldProc.ProcStatus)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcStatus = '" + POut.PInt((int)proc.ProcStatus) + "'";
                comma = true;
            }
            if (proc.ProvNum != oldProc.ProvNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProvNum = '" + POut.PInt(proc.ProvNum) + "'";
                comma = true;
            }
            if (proc.Dx != oldProc.Dx)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Dx = '" + POut.PInt(proc.Dx) + "'";
                comma = true;
            }
            if (proc.PlannedAptNum != oldProc.PlannedAptNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "PlannedAptNum = '" + POut.PInt(proc.PlannedAptNum) + "'";
                comma = true;
            }
            if (proc.PlaceService != oldProc.PlaceService)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "PlaceService = '" + POut.PInt((int)proc.PlaceService) + "'";
                comma = true;
            }
            if (proc.Prosthesis != oldProc.Prosthesis)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "Prosthesis = '" + POut.PString(proc.Prosthesis) + "'";
                comma = true;
            }
            if (proc.DateOriginalProsth != oldProc.DateOriginalProsth)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "DateOriginalProsth = " + POut.PDate(proc.DateOriginalProsth);
                comma = true;
            }
            if (proc.ClaimNote != oldProc.ClaimNote)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ClaimNote = '" + POut.PString(proc.ClaimNote) + "'";
                comma = true;
            }
            if (proc.DateEntryC != oldProc.DateEntryC)
            {
                if (comma)
                {
                    c += ",";
                }
                c += "DateEntryC = ";
                if (DataConnection.DBtype == DatabaseType.Oracle)
                {
                    c += POut.PDateT(MiscDataB.GetNowDateTime());
                }
                else                  //Assume MySQL
                {
                    c += "NOW()";
                }
                comma = true;
            }
            if (proc.ClinicNum != oldProc.ClinicNum)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ClinicNum = '" + POut.PInt(proc.ClinicNum) + "'";
                comma = true;
            }
            if (proc.MedicalCode != oldProc.MedicalCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "MedicalCode = '" + POut.PString(proc.MedicalCode) + "'";
                comma = true;
            }
            if (proc.DiagnosticCode != oldProc.DiagnosticCode)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "DiagnosticCode = '" + POut.PString(proc.DiagnosticCode) + "'";
                comma = true;
            }
            if (proc.IsPrincDiag != oldProc.IsPrincDiag)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "IsPrincDiag = '" + POut.PBool(proc.IsPrincDiag) + "'";
                comma = true;
            }
            if (proc.ProcNumLab != oldProc.ProcNumLab)
            {
                if (comma)
                {
                    c += ",";
                }
                c    += "ProcNumLab = '" + POut.PInt(proc.ProcNumLab) + "'";
                comma = true;
            }
            int rowsChanged = 0;

            if (comma)
            {
                c += " WHERE ProcNum = '" + POut.PInt(proc.ProcNum) + "'";
                DataConnection dcon = new DataConnection();
                rowsChanged = dcon.NonQ(c);
            }
            else
            {
                //rowsChanged=0;//this means no change is actually required.
            }
            if (proc.Note != oldProc.Note ||
                proc.UserNum != oldProc.UserNum ||
                proc.SigIsTopaz != oldProc.SigIsTopaz ||
                proc.Signature != oldProc.Signature)
            {
                ProcNote note = new ProcNote();
                note.PatNum     = proc.PatNum;
                note.ProcNum    = proc.ProcNum;
                note.UserNum    = proc.UserNum;
                note.Note       = proc.Note;
                note.SigIsTopaz = proc.SigIsTopaz;
                note.Signature  = proc.Signature;
                ProcNoteB.Insert(note);
            }
            return(rowsChanged);
        }