コード例 #1
0
		///<summary>Creates the Message object and fills it with data.</summary>
		public EhrADT_A01(Appointment appt) {
			string errors=Validate(appt);
			if(errors!="") {
				throw new Exception(errors);
			}
			_appt=appt;
			_pat=Patients.GetPat(appt.PatNum);
			InitializeVariables();
			BuildMessage();
		}
コード例 #2
0
ファイル: FormEhrAptObsEdit.cs プロジェクト: mnisl/OD
		private void FormEhrAptObsEdit_Load(object sender,EventArgs e) {
			_appt=Appointments.GetOneApt(_ehrAptObsCur.AptNum);
			comboObservationQuestion.Items.Clear();
			string[] arrayQuestionNames=Enum.GetNames(typeof(EhrAptObsIdentifier));
			for(int i=0;i<arrayQuestionNames.Length;i++) {
				comboObservationQuestion.Items.Add(arrayQuestionNames[i]);
				EhrAptObsIdentifier ehrAptObsIdentifier=(EhrAptObsIdentifier)i;
				if(_ehrAptObsCur.IdentifyingCode==ehrAptObsIdentifier) {
					comboObservationQuestion.SelectedIndex=i;
				}
			}
			listValueType.Items.Clear();
			string[] arrayValueTypeNames=Enum.GetNames(typeof(EhrAptObsType));
			for(int i=0;i<arrayValueTypeNames.Length;i++) {
				listValueType.Items.Add(arrayValueTypeNames[i]);
				EhrAptObsType ehrAptObsType=(EhrAptObsType)i;
				if(_ehrAptObsCur.ValType==ehrAptObsType) {
					listValueType.SelectedIndex=i;
				}
			}
			if(_ehrAptObsCur.ValType==EhrAptObsType.Coded) {
				_strValCodeSystem=_ehrAptObsCur.ValCodeSystem;
				if(_ehrAptObsCur.ValCodeSystem=="LOINC") {
					_loincValue=Loincs.GetByCode(_ehrAptObsCur.ValReported);
					textValue.Text=_loincValue.NameShort;
				}
				else if(_ehrAptObsCur.ValCodeSystem=="SNOMEDCT") {
					_snomedValue=Snomeds.GetByCode(_ehrAptObsCur.ValReported);
					textValue.Text=_snomedValue.Description;
				}
				else if(_ehrAptObsCur.ValCodeSystem=="ICD9") {
					_icd9Value=ICD9s.GetByCode(_ehrAptObsCur.ValReported);
					textValue.Text=_icd9Value.Description;
				}
				else if(_ehrAptObsCur.ValCodeSystem=="ICD10") {
					_icd10Value=Icd10s.GetByCode(_ehrAptObsCur.ValReported);
					textValue.Text=_icd10Value.Description;
				}
			}
			else {
				textValue.Text=_ehrAptObsCur.ValReported;
			}
			comboUnits.Items.Clear();
			comboUnits.Items.Add("none");
			comboUnits.SelectedIndex=0;
			List<string> listUcumCodes=Ucums.GetAllCodes();
			for(int i=0;i<listUcumCodes.Count;i++) {
				string ucumCode=listUcumCodes[i];
				comboUnits.Items.Add(ucumCode);
				if(ucumCode==_ehrAptObsCur.UcumCode) {
					comboUnits.SelectedIndex=i+1;
				}
			}
			SetFlags();
		}
コード例 #3
0
		public static void SetCompleteInAppt(Appointment apt,List<InsPlan> PlanList,List<PatPlan> patPlans,long siteNum,int patientAge,List<InsSub> subList) {
			List<Procedure> procsInAppt=Procedures.GetProcsForSingle(apt.AptNum,false);
			Procedures.SetCompleteInAppt(apt,PlanList,patPlans,siteNum,patientAge,procsInAppt,subList);
			if(Programs.UsingOrion) {
				OrionProcs.SetCompleteInAppt(procsInAppt);
			}
			//automation
			List<string> procCodes=new List<string>();
			for(int i=0;i<procsInAppt.Count;i++){
				procCodes.Add(ProcedureCodes.GetStringProcCode(procsInAppt[i].CodeNum));
			}
			AutomationL.Trigger(AutomationTrigger.CompleteProcedure,procCodes,apt.PatNum);
		}
コード例 #4
0
ファイル: Appointments.cs プロジェクト: nampn/ODental
 public static void Insert(Appointment appt)
 {
     if(DataConnection.DBtype==DatabaseType.MySql) {
         InsertIncludeAptNum(appt,false);
     }
     else {//Oracle must always have a valid PK.
         appt.AptNum=DbHelper.GetNextOracleKey("appointment","AptNum");
         InsertIncludeAptNum(appt,true);
     }
 }
コード例 #5
0
ファイル: ContrAppt.cs プロジェクト: romeroyonatan/opendental
		///<summary>Double click on appt sheet or on a single appointment.</summary>
		private void ContrApptSheet2_DoubleClick(object sender,System.EventArgs e) {
			mouseIsDown=false;
			//this logic is a little different than mouse down for now because on the first click of a 
			//double click, an appointment control is created under the mouse.
			if(ContrApptSingle.ClickedAptNum!=0) {//on appt
				long patnum=PIn.Long(TempApptSingle.DataRoww["PatNum"].ToString());
				TempApptSingle.Dispose();
				if(Appointments.GetOneApt(ContrApptSingle.ClickedAptNum)==null) {
					MsgBox.Show(this,"Selected appointment no longer exists.");
					RefreshModuleDataPeriod();
					RefreshModuleScreenPeriod();
					return;
				}
				//security handled inside the form
				FormApptEdit FormAE=new FormApptEdit(ContrApptSingle.ClickedAptNum);
				FormAE.ShowDialog();
				if(FormAE.DialogResult==DialogResult.OK) {
					Appointment apt=Appointments.GetOneApt(ContrApptSingle.ClickedAptNum);
					if(apt!=null && DoesOverlap(apt)) {
						Appointment aptOld=apt.Clone();
						MsgBox.Show(this,"Appointment is too long and would overlap another appointment.  Automatically shortened to fit.");
						while(DoesOverlap(apt)) {
							apt.Pattern=apt.Pattern.Substring(0,apt.Pattern.Length-1);
							if(apt.Pattern.Length==1) {
								break;
							}
						}
						try {
							Appointments.Update(apt,aptOld);
						}
						catch(ApplicationException ex) {
							MessageBox.Show(ex.Message);
						}
					}
					ModuleSelected(patnum);//apt.PatNum);//apt might be null if user deleted appt.
					SetInvalid();
				}
			}
			//not on apt, so trying to schedule an appointment---------------------------------------------------------------------
			else {
				if(!Security.IsAuthorized(Permissions.AppointmentCreate)) {
					return;
				}
				FormPatientSelect FormPS=new FormPatientSelect();
				if(PatCur!=null) {
					FormPS.InitialPatNum=PatCur.PatNum;
				}
				FormPS.ShowDialog();
				if(FormPS.DialogResult!=DialogResult.OK) {
					return;
				}
				if(PatCur==null || FormPS.SelectedPatNum!=PatCur.PatNum) {//if the patient was changed
					RefreshModuleDataPatient(FormPS.SelectedPatNum);
					OnPatientSelected(PatCur);
					//RefreshModulePatient(FormPS.SelectedPatNum);
				}
				Appointment apt;
				if(FormPS.NewPatientAdded) {
					//Patient pat=Patients.GetPat(PatCurNum);
					apt=new Appointment();
					apt.PatNum=PatCur.PatNum;
					apt.IsNewPatient=true;
					apt.Pattern="/X/";
					if(PatCur.PriProv==0) {
						apt.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
					}
					else {
						apt.ProvNum=PatCur.PriProv;
					}
					apt.ProvHyg=PatCur.SecProv;
					apt.AptStatus=ApptStatus.Scheduled;
					DateTime d=AppointmentL.DateSelected;
					if(ApptDrawing.IsWeeklyView) {
						d=WeekStartDate.AddDays(SheetClickedonDay);
					}
					//minutes always rounded down.
					int minutes=(int)(ContrAppt.SheetClickedonMin/ApptDrawing.MinPerIncr)*ApptDrawing.MinPerIncr;
					apt.AptDateTime=new DateTime(d.Year,d.Month,d.Day,ContrAppt.SheetClickedonHour,minutes,0);
					if(PatCur.AskToArriveEarly>0) {
						apt.DateTimeAskedToArrive=apt.AptDateTime.AddMinutes(-PatCur.AskToArriveEarly);
						MessageBox.Show(Lan.g(this,"Ask patient to arrive")+" "+PatCur.AskToArriveEarly
							+" "+Lan.g(this,"minutes early at")+" "+apt.DateTimeAskedToArrive.ToShortTimeString()+".");
					}
					apt.Op=SheetClickedonOp;
					Operatory curOp=Operatories.GetOperatory(apt.Op);
					//New patient. Set to prospective if operatory is set to set prospective.
					if(curOp.SetProspective) {
						if(MsgBox.Show(this,MsgBoxButtons.OKCancel,"Patient's status will be set to Prospective.")) {
							Patient patOld=PatCur.Copy();
							PatCur.PatStatus=PatientStatus.Prospective;
							Patients.Update(PatCur,patOld);
						}
					}
					//if(curOp.ProvDentist!=0) {//if no dentist is assigned to op, then keep the original dentist.  All appts must have prov.
					//  apt.ProvNum=curOp.ProvDentist;
					//}
					//apt.ProvHyg=curOp.ProvHygienist;
					long assignedDent=Schedules.GetAssignedProvNumForSpot(SchedListPeriod,curOp,false,apt.AptDateTime);
					long assignedHyg=Schedules.GetAssignedProvNumForSpot(SchedListPeriod,curOp,true,apt.AptDateTime);
					if(assignedDent!=0) {//if no dentist is assigned to op, then keep the original dentist.  All appts must have prov.
					  apt.ProvNum=assignedDent;
					}
					apt.ProvHyg=assignedHyg;
					apt.IsHygiene=curOp.IsHygiene;
					apt.TimeLocked=PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
					if(curOp.ClinicNum==0){
						apt.ClinicNum=PatCur.ClinicNum;
					}
					else{
						apt.ClinicNum=curOp.ClinicNum;
					}
					try {
						Appointments.Insert(apt);
					}
					catch(ApplicationException ex) {
						MessageBox.Show(ex.Message);
					}
					FormApptEdit FormAE=new FormApptEdit(apt.AptNum);//this is where security log entry is made
					FormAE.IsNew=true;
					FormAE.ShowDialog();
					if(apt.IsNewPatient) {
						AutomationL.Trigger(AutomationTrigger.CreateApptNewPat,null,apt.PatNum);
					}
					if(FormAE.DialogResult==DialogResult.OK) {
						RefreshModuleDataPatient(PatCur.PatNum);
						OnPatientSelected(PatCur);
						//RefreshModulePatient(PatCurNum);
						if(apt!=null && DoesOverlap(apt)) {
							Appointment aptOld=apt.Clone();
							MsgBox.Show(this,"Appointment is too long and would overlap another appointment.  Automatically shortened to fit.");
							while(DoesOverlap(apt)) {
								apt.Pattern=apt.Pattern.Substring(0,apt.Pattern.Length-1);
								if(apt.Pattern.Length==1) {
									break;
								}
							}
							try {
								Appointments.Update(apt,aptOld);
							}
							catch(ApplicationException ex) {
								MessageBox.Show(ex.Message);
							}
						}
						RefreshPeriod();
						SetInvalid();
					}
				}
				else {//new patient not added
					if(Appointments.HasPlannedEtc(PatCur.PatNum) | (Plugins.HookMethod(this,"ContrAppt.ContrApptSheet2_DoubleClick_apptOtherShow"))) {
						DisplayOtherDlg(true);
					}
					else {
						FormApptsOther FormAO=new FormApptsOther(PatCur.PatNum);//doesn't actually get shown
						CheckStatus();
						FormAO.InitialClick=true;
						FormAO.MakeAppointment();
						//if(FormAO.OResult==OtherResult.Cancel) {//this wasn't catching user hitting cancel from within appt edit window
						//	return;
						//}
						if(FormAO.AptNumsSelected.Count>0) {
							ContrApptSingle.SelectedAptNum=FormAO.AptNumsSelected[0];
						}
						//RefreshModuleDataPatient(FormAO.SelectedPatNum);//patient won't have changed
						//OnPatientSelected(PatCur.PatNum,PatCur.GetNameLF(),PatCur.Email!="",PatCur.ChartNumber);
						apt=Appointments.GetOneApt(ContrApptSingle.SelectedAptNum);
						if(apt!=null && DoesOverlap(apt)) {
							Appointment aptOld=apt.Clone();
							MsgBox.Show(this,"Appointment is too long and would overlap another appointment.  Automatically shortened to fit.");
							while(DoesOverlap(apt)) {
								apt.Pattern=apt.Pattern.Substring(0,apt.Pattern.Length-1);
								if(apt.Pattern.Length==1) {
									break;
								}
							}
							try {
								Appointments.Update(apt,aptOld);
							}
							catch(ApplicationException ex) {
								MessageBox.Show(ex.Message);
							}
						}
						RefreshPeriod();
						SetInvalid();
					}
				}
			}
		}
コード例 #6
0
		/// <summary>For testing only</summary>
		private static void CreateAppointments(int AppointmentCount) {
			long[] patNumArray=Patients.GetAllPatNums();
			DateTime appdate= DateTime.Now;
			for(int i=0;i<patNumArray.Length;i++) {
				appdate=appdate.AddMinutes(20);
				for(int j=0;j<AppointmentCount;j++) {
					Appointment apt=new Appointment();
					appdate=appdate.AddMinutes(20);
					apt.PatNum=patNumArray[i];
					apt.DateTimeArrived=appdate;
					apt.DateTimeAskedToArrive=appdate;
					apt.DateTimeDismissed=appdate;
					apt.DateTimeSeated=appdate;
					apt.AptDateTime=appdate;
					apt.Note="some notenote noten otenotenot enotenot enote"+j;
					apt.IsNewPatient=true;
					apt.ProvNum=3;
					apt.AptStatus=ApptStatus.Scheduled;
					apt.AptDateTime=appdate;
					apt.Op=2;
					apt.Pattern="//XX//////";
					apt.ProcDescript="4-BWX";
					apt.ProcsColored="<span color=\"-16777216\">4-BWX</span>";
					Appointments.Insert(apt);
				}
			}
		}
コード例 #7
0
ファイル: FormApptsOther.cs プロジェクト: nampn/ODental
 private void butNote_Click(object sender,EventArgs e)
 {
     Appointment AptCur=new Appointment();
     AptCur.PatNum=PatCur.PatNum;
     if(PatCur.DateFirstVisit.Year<1880
         && !Procedures.AreAnyComplete(PatCur.PatNum))//this only runs if firstVisit blank
     {
         AptCur.IsNewPatient=true;
     }
     AptCur.Pattern="/X/";
     if(PatCur.PriProv==0) {
         AptCur.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
     }
     else {
         AptCur.ProvNum=PatCur.PriProv;
     }
     AptCur.ProvHyg=PatCur.SecProv;
     AptCur.AptStatus=ApptStatus.PtNote;
     AptCur.ClinicNum=PatCur.ClinicNum;
     if(InitialClick) {//initially double clicked on appt module
         DateTime d;
         if(ApptDrawing.IsWeeklyView) {
             d=ContrAppt.WeekStartDate.AddDays(ContrAppt.SheetClickedonDay);
         }
         else {
             d=AppointmentL.DateSelected;
         }
         int minutes=(int)(ContrAppt.SheetClickedonMin/ApptDrawing.MinPerIncr)
             *ApptDrawing.MinPerIncr;
         AptCur.AptDateTime=new DateTime(d.Year,d.Month,d.Day
             ,ContrAppt.SheetClickedonHour,minutes,0);
         AptCur.Op=ContrAppt.SheetClickedonOp;
     }
     else {
         //new appt will be placed on pinboard instead of specific time
     }
     try {
         Appointments.Insert(AptCur);
     }
     catch(ApplicationException ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     FormApptEdit FormApptEdit2=new FormApptEdit(AptCur.AptNum);
     FormApptEdit2.IsNew=true;
     FormApptEdit2.ShowDialog();
     if(FormApptEdit2.DialogResult!=DialogResult.OK) {
         return;
     }
     AptNumsSelected.Add(AptCur.AptNum);
     if(InitialClick) {
         oResult=OtherResult.CreateNew;
     }
     else {
         oResult=OtherResult.NewToPinBoard;
     }
     DialogResult=DialogResult.OK;
 }
コード例 #8
0
		public FormEhrAptObses(Appointment appt) {
			InitializeComponent();
			Lan.F(this);
			_appt=appt;
		}
コード例 #9
0
ファイル: AppointmentL.cs プロジェクト: mnisl/OD
		/*
		///<summary>Only used in GetSearchResults.  All times between start and stop get set to true in provBarSched.</summary>
		private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){
			int startI=GetProvBarIndex(timeStart);
			int stopI=GetProvBarIndex(timeStop);
			for(int i=startI;i<=stopI;i++){
				provBarSched[i]=true;
			}
		}

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

		///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule.  This method creates the appointment and attaches all appropriate procedures.  It's up to the calling class to then place the appointment on the pinboard.  If the appointment doesn't get scheduled, it's important to delete it.  If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary>
		public static Appointment CreateRecallApt(Patient patCur,List<Procedure> procList,List<InsPlan> planList,long recallNum,List<InsSub> subList){
			List<Recall> recallList=Recalls.GetList(patCur.PatNum);
			Recall recallCur=null;
			if(recallNum>0) {
				recallCur=Recalls.GetRecall(recallNum);
			}
			else{
				for(int i=0;i<recallList.Count;i++){
					if(recallList[i].RecallTypeNum==RecallTypes.PerioType || recallList[i].RecallTypeNum==RecallTypes.ProphyType){
						if(!recallList[i].IsDisabled){
							recallCur=recallList[i];
						}
						break;
					}
				}
			}
			if(recallCur==null){// || recallCur.DateDue.Year<1880){
				throw new ApplicationException(Lan.g("AppointmentL","No special type recall is due."));//Typically never happens because everyone has a recall.  However, it can happen when patients have custom recalls due
			}
			if(recallCur.DateScheduled.Date>DateTime.Today) {
				throw new ApplicationException(Lan.g("AppointmentL","Recall has already been scheduled for ")+recallCur.DateScheduled.ToShortDateString());
			}
			Appointment aptCur=new Appointment();
			List<string> procs=RecallTypes.GetProcs(recallCur.RecallTypeNum);
			List<Procedure> listProcs=Appointments.FillAppointmentForRecall(aptCur,recallCur,recallList,patCur,procs,planList,subList);
			for(int i=0;i<listProcs.Count;i++) {
				if(Programs.UsingOrion) {
					FormProcEdit FormP=new FormProcEdit(listProcs[i],patCur.Copy(),Patients.GetFamily(patCur.PatNum));
					FormP.IsNew=true;
					FormP.ShowDialog();
					if(FormP.DialogResult==DialogResult.Cancel) {
						//any created claimprocs are automatically deleted from within procEdit window.
						try {
							Procedures.Delete(listProcs[i].ProcNum);//also deletes the claimprocs
						}
						catch(Exception ex) {
							MessageBox.Show(ex.Message);
						}
					}
					else {
						//Do not synch. Recalls based on ScheduleByDate reports in Orion mode.
						//Recalls.Synch(PatCur.PatNum);
					}
				}
			}
			return aptCur;
		}
コード例 #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;
		}
コード例 #11
0
ファイル: SheetFiller.cs プロジェクト: nampn/ODental
 private static void FillFieldsForLabelAppointment(Sheet sheet,Appointment appt,Patient pat)
 {
     foreach(SheetField field in sheet.SheetFields) {
         switch(field.FieldName) {
             case "nameFL":
                 field.FieldValue=pat.GetNameFirstOrPrefL();
                 break;
             case "nameLF":
                 field.FieldValue=pat.GetNameLF();
                 break;
             case "weekdayDateTime":
                 field.FieldValue=appt.AptDateTime.ToString("ddd")+"   "
                     +appt.AptDateTime.ToShortDateString()+"  "
                     +appt.AptDateTime.ToShortTimeString();//  h:mm tt");
                 break;
             case "length":
                 int minutesTotal=appt.Pattern.Length*5;
                 int hours=minutesTotal/60;//automatically rounds down
                 int minutes=minutesTotal-hours*60;
                 field.FieldValue="";
                 if(hours>0){
                     field.FieldValue=hours.ToString()+" hours, ";
                 }
                 field.FieldValue+=minutes.ToString()+" min";
                 break;
         }
     }
 }
コード例 #12
0
ファイル: SheetFiller.cs プロジェクト: nampn/ODental
 private static void FillFieldsForRoutingSlip(Sheet sheet,Patient pat,Appointment apt)
 {
     Family fam=Patients.GetFamily(apt.PatNum);
     string str;
     foreach(SheetField field in sheet.SheetFields) {
         switch(field.FieldName) {
             case "appt.timeDate":
                 field.FieldValue=apt.AptDateTime.ToShortTimeString()+"  "+apt.AptDateTime.ToShortDateString();
                 break;
             case "appt.length":
                 field.FieldValue=(apt.Pattern.Length*5).ToString()+" "+Lan.g("SheetRoutingSlip","minutes");
                 break;
             case "appt.providers":
                 str=Providers.GetLongDesc(apt.ProvNum);
                 if(apt.ProvHyg!=0){
                     str+="\r\n"+Providers.GetLongDesc(apt.ProvHyg);
                 }
                 field.FieldValue=str;
                 break;
             case "appt.procedures":
                 str="";
                 List<Procedure> procs=Procedures.GetProcsForSingle(apt.AptNum,false);
                 for(int i=0;i<procs.Count;i++) {
                     if(i>0){
                         str+="\r\n";
                     }
                     str+=Procedures.GetDescription(procs[i]);
                 }
                 field.FieldValue=str;
                 break;
             case "appt.Note":
                 field.FieldValue=apt.Note;
                 break;
             case "otherFamilyMembers":
                 str="";
                 for(int i=0;i<fam.ListPats.Length;i++) {
                     if(fam.ListPats[i].PatNum==pat.PatNum) {
                         continue;
                     }
                     if(fam.ListPats[i].PatStatus==PatientStatus.Archived
                         || fam.ListPats[i].PatStatus==PatientStatus.Deceased) {
                         //Prospective patients will show.
                         continue;
                     }
                     if(str!="") {
                         str+="\r\n";
                     }
                     str+=fam.ListPats[i].GetNameFL();
                     if(fam.ListPats[i].Age>0){
                         str+=",   "+fam.ListPats[i].Age.ToString();
                     }
                 }
                 field.FieldValue=str;
                 break;
         }
     }
 }
コード例 #13
0
ファイル: FormApptEditOld.cs プロジェクト: mnisl/OD
		///<summary></summary>
		public FormApptEditOld(Appointment aptCur){
			InitializeComponent();// Required for Windows Form Designer support
			tbTime.CellClicked += new OpenDental.ContrTable.CellEventHandler(tbTime_CellClicked);
			tbProc.CellClicked += new OpenDental.ContrTable.CellEventHandler(tbProc_CellClicked);
			tbCommlog.CellDoubleClicked+=new OpenDental.ContrTable.CellEventHandler(tbCommlog_CellDoubleClicked);
			Lan.F(this);
			AptCur=aptCur;
			AptOld=aptCur.Copy();
		}
コード例 #14
0
ファイル: FormApptEditOld.cs プロジェクト: mnisl/OD
		///<summary>Called from butOK_Click and butPin_Click</summary>
		private bool UpdateToDB(){
			if(textAddTime.errorProvider1.GetError(textAddTime)!=""
				//|| textDateTerm.errorProvider1.GetError(textDateTerm)!=""
				){
				MessageBox.Show(Lan.g(this,"Please fix data entry errors first."));
				return false;
			}
			if(textGradePoint.Text=="0" || textGradePoint.Text==""){
				AptCur.GradePoint=0;
			}
			else{
				try{
					AptCur.GradePoint=PIn.PFloat(textGradePoint.Text);
				}
				catch{
					MsgBox.Show(this,"Grade invalid");
					return false;
				}
			}
			if(AptCur.AptStatus==ApptStatus.Planned){
				;
			}
			else if(comboStatus.SelectedIndex==-1){
				AptCur.AptStatus=ApptStatus.Scheduled;
			}
			else{
				AptCur.AptStatus=(ApptStatus)comboStatus.SelectedIndex+1;
			}
			//if appointment is marked complete and any procedures are not,
			//then set the remaining procedures complete
      if(AptCur.AptStatus==ApptStatus.Complete){
				bool allProcsComplete=true;
				for(int i=0;i<ProcList.Length;i++){
					if(ProcList[i].AptNum!=AptCur.AptNum){
						continue;
					}
					if(ProcList[i].ProcStatus!=ProcStat.C){
						allProcsComplete=false;
						break;
					}
				}
				if(!allProcsComplete){
					if(!Security.IsAuthorized(Permissions.ProcComplCreate)){
						return false;
					}
					Procedures.SetCompleteInAppt(AptCur,PlanList,PatPlanList);
					SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate,pat.PatNum,
						pat.GetNameLF()+" "+AptCur.AptDateTime.ToShortDateString());
				}
			}
			//convert from current increment into 5 minute increment
			//MessageBox.Show(strBTime.ToString());
			StringBuilder savePattern=new StringBuilder();
			for(int i=0;i<strBTime.Length;i++){
				savePattern.Append(strBTime[i]);
				savePattern.Append(strBTime[i]);
				if(PrefB.GetInt("AppointmentTimeIncrement")==15){
					savePattern.Append(strBTime[i]);
				}
			}
			if(savePattern.Length==0){
				savePattern=new StringBuilder("/");
			}
			//MessageBox.Show(savePattern.ToString());
			AptCur.Pattern=savePattern.ToString();
			if(comboUnschedStatus.SelectedIndex==0)//none
				AptCur.UnschedStatus=0;
			else
				AptCur.UnschedStatus
					=DefB.Short[(int)DefCat.RecallUnschedStatus][comboUnschedStatus.SelectedIndex-1].DefNum;
			if(comboConfirmed.SelectedIndex!=-1)
				AptCur.Confirmed
					=DefB.Short[(int)DefCat.ApptConfirmed][comboConfirmed.SelectedIndex].DefNum;
			AptCur.AddTime=(int)(PIn.PInt(textAddTime.Text)/
				PIn.PInt(((Pref)PrefB.HList["AppointmentTimeIncrement"]).ValueString));
			AptCur.Note=textNote.Text;
			if(comboClinic.SelectedIndex==0)//none
				AptCur.ClinicNum=0;
			else
				AptCur.ClinicNum=Clinics.List[comboClinic.SelectedIndex-1].ClinicNum;
			//there should always be a non-hidden primary provider for an appt.
			if(comboProvNum.SelectedIndex==-1)
				AptCur.ProvNum=Providers.List[0].ProvNum;
			else
				AptCur.ProvNum=Providers.List[comboProvNum.SelectedIndex].ProvNum;
			if(comboProvHyg.SelectedIndex==0)//none
				AptCur.ProvHyg=0;
			else
				AptCur.ProvHyg=Providers.List[comboProvHyg.SelectedIndex-1].ProvNum;
			AptCur.IsHygiene=checkIsHygiene.Checked;
			if(comboAssistant.SelectedIndex==0)//none
				AptCur.Assistant=0;
			else
				AptCur.Assistant=Employees.ListShort[comboAssistant.SelectedIndex-1].EmployeeNum;
			if(comboInstructor.SelectedIndex==0)//none
				AptCur.InstructorNum=0;
			else
				AptCur.InstructorNum=Instructors.List[comboInstructor.SelectedIndex-1].InstructorNum;
			if(comboSchoolClass.SelectedIndex==0)//none
				AptCur.SchoolClassNum=0;
			else
				AptCur.SchoolClassNum=SchoolClasses.List[comboSchoolClass.SelectedIndex-1].SchoolClassNum;
			if(comboSchoolCourse.SelectedIndex==0)//none
				AptCur.SchoolCourseNum=0;
			else
				AptCur.SchoolCourseNum=SchoolCourses.List[comboSchoolCourse.SelectedIndex-1].SchoolCourseNum;
			//AptCur.GradePoint //already done at top of this function
			AptCur.Lab=(LabCaseOld)comboLab.SelectedIndex;
			AptCur.IsNewPatient=checkIsNewPatient.Checked;
			AptCur.ProcDescript="";
			if(AptCur.AptStatus==ApptStatus.Planned){
				for(int i=0;i<ProcList.Length;i++){
					if(ProcList[i].PlannedAptNum==AptCur.AptNum){
						AptCur.ProcDescript
							+=ProcedureCodes.GetProcCode(ProcList[i].ADACode).AbbrDesc+", ";
					}
				}
			}
			else{//standard appt
				for(int i=0;i<ProcList.Length;i++){
					if(ProcList[i].AptNum==AptCur.AptNum){
						AptCur.ProcDescript
							+=ProcedureCodes.GetProcCode(ProcList[i].ADACode).AbbrDesc+", ";
					}
				}
			}
			if(AptCur.ProcDescript.Length>1){
				//trims the last space and comma
				AptCur.ProcDescript
					=AptCur.ProcDescript.Substring(0,AptCur.ProcDescript.Length-2);
			}
			try{
				Appointments.InsertOrUpdate(AptCur,AptOld,false);
				AptOld=AptCur.Copy();
			}
			catch(ApplicationException ex){
				MessageBox.Show(ex.Message);
				return false;
			}
			if(IsNew){
				SecurityLogs.MakeLogEntry(Permissions.AppointmentCreate,pat.PatNum,
					pat.GetNameLF()+", "
					+AptCur.AptDateTime.ToString()
					+AptCur.ProcDescript);
			}
			else{
				SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit,pat.PatNum,
					pat.GetNameLF()+", "
					+AptCur.AptDateTime.ToString()
					+AptCur.ProcDescript);
			}
			return true;
		}
コード例 #15
0
ファイル: Appointments.cs プロジェクト: nampn/ODental
 ///<summary>Updates only the changed columns and returns the number of rows affected.  Supply an oldApt for comparison.</summary>
 public static void Update(Appointment appointment,Appointment oldAppointment)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         Meth.GetVoid(MethodBase.GetCurrentMethod(),appointment,oldAppointment);
         return;
     }
     Crud.AppointmentCrud.Update(appointment,oldAppointment);
 }
コード例 #16
0
ファイル: Appointments.cs プロジェクト: nampn/ODental
 ///<summary>Used in Chart module to test whether a procedure is attached to an appointment with today's date. The procedure might have a different date if still TP status.  ApptList should include all appointments for this patient. Does not make a call to db.</summary>
 public static bool ProcIsToday(Appointment[] apptList,Procedure proc)
 {
     //No need to check RemotingRole; no call to db.
     for(int i=0;i<apptList.Length;i++){
         if(apptList[i].AptDateTime.Date==DateTime.Today
             && apptList[i].AptNum==proc.AptNum
             && (apptList[i].AptStatus==ApptStatus.Scheduled
             || apptList[i].AptStatus==ApptStatus.ASAP
             || apptList[i].AptStatus==ApptStatus.Broken
             || apptList[i].AptStatus==ApptStatus.Complete))
         {
             return true;
         }
     }
     return false;
 }
コード例 #17
0
ファイル: Appointments.cs プロジェクト: nampn/ODental
 ///<summary>Set includeAptNum to true only in rare situations.  Like when we are inserting for eCW.</summary>
 public static long InsertIncludeAptNum(Appointment appt,bool useExistingPK)
 {
     if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
         appt.AptNum=Meth.GetLong(MethodBase.GetCurrentMethod(),appt,useExistingPK);
         return appt.AptNum;
     }
     //make sure all fields are properly filled:
     if(appt.Confirmed==0){
         appt.Confirmed=DefC.GetList(DefCat.ApptConfirmed)[0].DefNum;
     }
     if(appt.ProvNum==0){
         appt.ProvNum=ProviderC.ListShort[0].ProvNum;
     }
     return Crud.AppointmentCrud.Insert(appt,useExistingPK);
 }
コード例 #18
0
ファイル: FormApptsOther.cs プロジェクト: mnisl/OD
		public void MakeAppointment(){
			Appointment AptCur=new Appointment();
			AptCur.PatNum=PatCur.PatNum;
			if(PatCur.DateFirstVisit.Year<1880
				&& !Procedures.AreAnyComplete(PatCur.PatNum))//this only runs if firstVisit blank
			{
				AptCur.IsNewPatient=true;
			}
			AptCur.Pattern="/X/";
			if(PatCur.PriProv==0){
				AptCur.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
			}
			else{			
				AptCur.ProvNum=PatCur.PriProv;
			}
			AptCur.ProvHyg=PatCur.SecProv;
			AptCur.AptDateTime=DateTime.MinValue;//(was .Now) This is what triggers automatic deletion from db when clear pinboard is clicked.
			AptCur.ClinicNum=PatCur.ClinicNum;
			AptCur.TimeLocked=PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
			if(InitialClick){//initially double clicked on appt module
				DateTime d;
				if(ApptDrawing.IsWeeklyView){
					d=ContrAppt.WeekStartDate.AddDays(ContrAppt.SheetClickedonDay);
				}
				else{
					d=AppointmentL.DateSelected;
				}
				int minutes=(int)(ContrAppt.SheetClickedonMin/ApptDrawing.MinPerIncr)*ApptDrawing.MinPerIncr;
				AptCur.AptDateTime=new DateTime(d.Year,d.Month,d.Day
					,ContrAppt.SheetClickedonHour,minutes,0);
				if(PatCur.AskToArriveEarly>0){
					AptCur.DateTimeAskedToArrive=AptCur.AptDateTime.AddMinutes(-PatCur.AskToArriveEarly);
					MessageBox.Show(Lan.g(this,"Ask patient to arrive")+" "+PatCur.AskToArriveEarly
						+" "+Lan.g(this,"minutes early at")+" "+AptCur.DateTimeAskedToArrive.ToShortTimeString()+".");
				}
				AptCur.Op=ContrAppt.SheetClickedonOp;
				Operatory curOp=Operatories.GetOperatory(AptCur.Op);
				//if(curOp.ProvDentist!=0) {
				//  AptCur.ProvNum=curOp.ProvDentist;
				//}
				//AptCur.ProvHyg=curOp.ProvHygienist;
				List<Schedule> schedListPeriod=Schedules.RefreshDayEdit(AptCur.AptDateTime);
				long assignedDent=Schedules.GetAssignedProvNumForSpot(schedListPeriod,curOp,false,AptCur.AptDateTime);
				long assignedHyg=Schedules.GetAssignedProvNumForSpot(schedListPeriod,curOp,true,AptCur.AptDateTime);
				//the section below regarding providers is overly wordy because it's copied from ContrAppt.pinBoard_MouseUp to make maint easier.
				if(assignedDent!=0) {
					AptCur.ProvNum=assignedDent;
				}
				if(assignedHyg!=0) {//the hygienist will only be changed if the spot has a hygienist.
					AptCur.ProvHyg=assignedHyg;
				}
				if(curOp.IsHygiene) {
					AptCur.IsHygiene=true;
				}
				else {//op not marked as hygiene op
					if(assignedDent==0) {//no dentist assigned
						if(assignedHyg!=0) {//hyg is assigned (we don't really have to test for this)
							AptCur.IsHygiene=true;
						}
					}
					else {//dentist is assigned
						if(assignedHyg==0) {//hyg is not assigned
							AptCur.IsHygiene=false;
						}
						//if both dentist and hyg are assigned, it's tricky
						//only explicitly set it if user has a dentist assigned to the op
						if(curOp.ProvDentist!=0) {
							AptCur.IsHygiene=false;
						}
					}
				}
				if(curOp.ClinicNum!=0){
					AptCur.ClinicNum=curOp.ClinicNum;
				}
				AptCur.AptStatus=ApptStatus.Scheduled;
			}
			else{
				//new appt will be placed on pinboard instead of specific time
				AptCur.AptStatus=ApptStatus.UnschedList;//This is so that if it's on the pinboard when use shuts down OD, no db inconsistency.
			}
			try{
				Appointments.Insert(AptCur);
			}
			catch(ApplicationException ex){
				MessageBox.Show(ex.Message);
				return;
			}
			//This is done inside FormApptEdit.butOK_Click().  Don't want to make two create entries.
			//SecurityLogs.MakeLogEntry(Permissions.AppointmentCreate,AptCur.PatNum,
			//	AptCur.AptDateTime.ToString()+", "+AptCur.ProcDescript,
			//	AptCur.AptNum);
			FormApptEdit FormApptEdit2=new FormApptEdit(AptCur.AptNum);
			FormApptEdit2.IsNew=true;
			FormApptEdit2.ShowDialog();
			if(FormApptEdit2.DialogResult!=DialogResult.OK){
				return;
			}
			if(InitialClick) {
				//Change PatStatus to Prospective or from Prospective.
				Operatory opCur=Operatories.GetOperatory(AptCur.Op);
				if(opCur.SetProspective && PatCur.PatStatus!=PatientStatus.Prospective) { //Don't need to prompt if patient is already prospective.
					if(MsgBox.Show(this,MsgBoxButtons.OKCancel,"Patient's status will be set to Prospective.")) {
						Patient patOld=PatCur.Copy();
						PatCur.PatStatus=PatientStatus.Prospective;
						Patients.Update(PatCur,patOld);
					}
				}
				else if(!opCur.SetProspective && PatCur.PatStatus==PatientStatus.Prospective) {
					if(MsgBox.Show(this,MsgBoxButtons.OKCancel,"Patient's status will change from Prospective to Patient.")) {
						Patient patOld=PatCur.Copy();
						PatCur.PatStatus=PatientStatus.Patient;
						Patients.Update(PatCur,patOld);
					}
				}
			}
			AptNumsSelected.Add(AptCur.AptNum);
			if(InitialClick){
				oResult=OtherResult.CreateNew;
			}
			else{
				oResult=OtherResult.NewToPinBoard;
			}
			if(AptCur.IsNewPatient) {
				AutomationL.Trigger(AutomationTrigger.CreateApptNewPat,null,AptCur.PatNum);
			}
			DialogResult=DialogResult.OK;
		}
コード例 #19
0
        ///<summary>If not using clinics then supply an empty list of clinicNums.</summary>
        public static DataTable GetTreatPlanPresentationStatistics(DateTime dateStart, DateTime dateEnd, bool isFirstPresented, bool hasAllClinics
                                                                   , bool hasClinicsEnabled, bool isPresenter, bool isGross, bool hasAllUsers, List <long> listUserNums, List <long> listClinicNums)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd, isFirstPresented, hasAllClinics, hasClinicsEnabled, isPresenter, isGross
                                     , hasAllUsers, listUserNums, listClinicNums));
            }
            List <ProcTP>          listProcTPsAll       = ReportsComplex.RunFuncOnReportServer(() => ProcTPs.GetAllLim());
            List <TreatPlan>       listSavedTreatPlans  = ReportsComplex.RunFuncOnReportServer(() => TreatPlans.GetAllSavedLim());
            List <ProcTpTreatPlan> listProcTPTreatPlans = new List <ProcTpTreatPlan>();

            listProcTPsAll.ForEach(x =>
            {
                listProcTPTreatPlans.Add(new ProcTpTreatPlan()
                {
                    TreatPlanCur = listSavedTreatPlans.First(y => y.TreatPlanNum == x.TreatPlanNum),
                    ProcTPCur    = x
                });
            });
            //get one entry per procedure with their first/last date of presentation based on radio buttons.
            if (isFirstPresented)
            {
                listProcTPTreatPlans = listProcTPTreatPlans
                                       .OrderBy(x => x.ProcTPCur.ProcNumOrig)
                                       .ThenBy(x => x.TreatPlanCur.DateTP)
                                       .ThenBy(x => x.TreatPlanCur.TreatPlanNum)
                                       .GroupBy(x => x.ProcTPCur.ProcNumOrig)
                                       .Select(x => x.First())
                                       .ToList();
            }
            else
            {
                listProcTPTreatPlans = listProcTPTreatPlans
                                       .OrderBy(x => x.ProcTPCur.ProcNumOrig)
                                       .ThenByDescending(x => x.TreatPlanCur.DateTP)
                                       .ThenBy(x => x.TreatPlanCur.TreatPlanNum)
                                       .GroupBy(x => x.ProcTPCur.ProcNumOrig)
                                       .Select(x => x.First())
                                       .ToList();
            }
            //get rid of any entries that are outside the range selected.
            listProcTPTreatPlans = listProcTPTreatPlans.Where(x => x.TreatPlanCur.DateTP.Date >= dateStart &&
                                                              x.TreatPlanCur.DateTP.Date <= dateEnd).ToList();
            //Get the associated procedures, claimprocs, adjustments, users, appointments.
            List <Procedure> listProcsForTreatPlans = ReportsComplex.RunFuncOnReportServer(() =>
                                                                                           Procedures.GetForProcTPs(listProcTPTreatPlans.Select(x => x.ProcTPCur).ToList(), ProcStat.C, ProcStat.TP));

            if (hasClinicsEnabled && !hasAllClinics)
            {
                listProcsForTreatPlans =
                    listProcsForTreatPlans.FindAll(x => listClinicNums.Contains(x.ClinicNum));
            }
            List <ClaimProc> listClaimProcs = ReportsComplex.RunFuncOnReportServer(() => ClaimProcs.GetForProcsLimited(listProcsForTreatPlans.Select(x => x.ProcNum).ToList(),
                                                                                                                       ClaimProcStatus.CapComplete, ClaimProcStatus.NotReceived, ClaimProcStatus.Received, ClaimProcStatus.Supplemental, ClaimProcStatus.Estimate));
            List <Adjustment> listAdjustments = ReportsComplex.RunFuncOnReportServer(() => Adjustments.GetForProcs(listProcsForTreatPlans.Select(x => x.ProcNum).ToList()));
            List <Userod>     listUserods     = ReportsComplex.RunFuncOnReportServer(() => Userods.GetAll());
            List <TreatPlanPresenterEntry> listTreatPlanPresenterEntries = new List <TreatPlanPresenterEntry>();
            List <ProcedureCode>           listProcCodes = ReportsComplex.RunFuncOnReportServer(() => ProcedureCodes.GetCodesForCodeNums(listProcsForTreatPlans.Select(x => x.CodeNum).ToList()));
            List <Appointment>             listApts      = ReportsComplex.RunFuncOnReportServer(() => Appointments.GetMultApts(listProcsForTreatPlans.Select(x => x.AptNum).ToList()));
            double amt = listProcsForTreatPlans.Sum(x => x.ProcFee);

            foreach (Procedure procCur in listProcsForTreatPlans)
            {
                double grossProd = procCur.ProcFee * (procCur.UnitQty + procCur.BaseUnits);
                double writeOffs = listClaimProcs.Where(x => x.ProcNum == procCur.ProcNum)
                                   .Where(x => x.Status == ClaimProcStatus.CapComplete)
                                   .Sum(x => x.WriteOff);
                grossProd -= writeOffs;
                if (procCur.ProcStatus == ProcStat.C)
                {
                    writeOffs += listClaimProcs.Where(x => x.ProcNum == procCur.ProcNum)
                                 .Where(x => x.Status.In(ClaimProcStatus.NotReceived, ClaimProcStatus.Received, ClaimProcStatus.Supplemental))
                                 .Sum(x => x.WriteOff);
                }
                else
                {
                    foreach (ClaimProc claimProcCur in listClaimProcs.Where(x => x.ProcNum == procCur.ProcNum).Where(x => x.Status == ClaimProcStatus.Estimate))
                    {
                        if (claimProcCur.WriteOffEstOverride == -1)
                        {
                            if (claimProcCur.WriteOffEst != -1)
                            {
                                writeOffs += claimProcCur.WriteOffEst;
                            }
                        }
                        else
                        {
                            writeOffs += claimProcCur.WriteOffEstOverride;
                        }
                    }
                    //writeOffs += listClaimProcs.Where(x => x.ProcNum == procCur.ProcNum)
                    //	.Where(x => x.Status == ClaimProcStatus.Estimate)
                    //	.Sum(x => x.WriteOffEstOverride == -1 ? (x.WriteOffEst == -1 ? 0 : x.WriteOffEst) : x.WriteOffEstOverride); //Allen won't let me commit this nested ternary :(
                }
                double    adjustments  = listAdjustments.Where(x => x.ProcNum == procCur.ProcNum).Sum(x => x.AdjAmt);
                double    netProd      = grossProd - writeOffs + adjustments;
                TreatPlan treatPlanCur = listProcTPTreatPlans.Where(x => x.ProcTPCur.ProcNumOrig == procCur.ProcNum).First().TreatPlanCur;
                Userod    userPresenter;
                if (isPresenter)
                {
                    userPresenter = listUserods.FirstOrDefault(x => x.UserNum == treatPlanCur.UserNumPresenter);
                }
                else                   //radioEntryUser
                {
                    userPresenter = listUserods.FirstOrDefault(x => x.UserNum == treatPlanCur.SecUserNumEntry);
                }
                ProcedureCode procCode = listProcCodes.First(x => x.CodeNum == procCur.CodeNum);
                Appointment   aptCur   = listApts.FirstOrDefault(x => x.AptNum == procCur.AptNum);
                listTreatPlanPresenterEntries.Add(new TreatPlanPresenterEntry()
                {
                    Presenter        = userPresenter == null ? "" : userPresenter.UserName,
                    DatePresented    = treatPlanCur.DateTP,
                    DateCompleted    = procCur.ProcDate,
                    ProcDescript     = procCode.Descript,
                    GrossProd        = grossProd,
                    Adjustments      = adjustments,
                    WriteOffs        = writeOffs,
                    NetProd          = netProd,
                    UserNumPresenter = userPresenter == null?0:userPresenter.UserNum,
                    PresentedClinic  = procCur.ClinicNum,
                    ProcStatus       = procCur.ProcStatus,
                    TreatPlanNum     = treatPlanCur.TreatPlanNum,
                    AptNum           = procCur.AptNum,
                    AptStatus        = aptCur == null?ApptStatus.None:aptCur.AptStatus
                });
            }
            DataTable table = new DataTable();

            table.Columns.Add("Presenter");
            table.Columns.Add("# of Plans");
            table.Columns.Add("# of Procs");
            table.Columns.Add("# of ProcsSched");
            table.Columns.Add("# of ProcsComp");
            if (isGross)
            {
                table.Columns.Add("GrossTPAmt");
                table.Columns.Add("GrossSchedAmt");
                table.Columns.Add("GrossCompAmt");
            }
            else
            {
                table.Columns.Add("NetTpAmt");
                table.Columns.Add("NetSchedAmt");
                table.Columns.Add("NetCompAmt");
            }
            if (!hasAllUsers)
            {
                listTreatPlanPresenterEntries = listTreatPlanPresenterEntries.Where(x => listUserNums.Contains(x.UserNumPresenter)).ToList();
            }
            listTreatPlanPresenterEntries = listTreatPlanPresenterEntries.OrderBy(x => x.Presenter).ToList();
            listTreatPlanPresenterEntries
            .GroupBy(x => x.Presenter).ToList().ForEach(x =>
            {
                DataRow row            = table.NewRow();
                row["Presenter"]       = x.First().Presenter == "" ? "None" : x.First().Presenter;
                row["# of Plans"]      = x.GroupBy(y => y.TreatPlanNum).Count();
                row["# of Procs"]      = x.Count();
                row["# of ProcsSched"] = x.Count(y => y.ProcStatus == ProcStat.TP && y.AptNum != 0 && y.AptStatus == ApptStatus.Scheduled);
                row["# of ProcsComp"]  = x.Count(y => y.ProcStatus == ProcStat.C);
                if (isGross)
                {
                    row["GrossTpAmt"]    = x.Sum(y => y.GrossProd);
                    row["GrossSchedAmt"] = x.Where(y => y.ProcStatus == ProcStat.TP && y.AptNum != 0 && y.AptStatus == ApptStatus.Scheduled).Sum(y => y.GrossProd);
                    row["GrossCompAmt"]  = x.Where(y => y.ProcStatus == ProcStat.C).Sum(y => y.GrossProd);
                }
                else
                {
                    row["NetTpAmt"]    = x.Sum(y => y.NetProd);
                    row["NetSchedAmt"] = x.Where(y => y.ProcStatus == ProcStat.TP && y.AptNum != 0 && y.AptStatus == ApptStatus.Scheduled).Sum(y => y.NetProd);
                    row["NetCompAmt"]  = x.Where(y => y.ProcStatus == ProcStat.C).Sum(y => y.NetProd);
                }
                table.Rows.Add(row);
            });

            //DataTable table=ReportsComplex.RunFuncOnReportServer(() => ReportsComplex.GetTable(query));
            return(table);
        }
コード例 #20
0
		private void butNew_Click(object sender,EventArgs e) {
			/*if(ApptPlanned.Visible){
				if(MessageBox.Show(Lan.g(this,"Replace existing planned appointment?")
					,"",MessageBoxButtons.OKCancel)!=DialogResult.OK)
					return;
				//Procedures.UnattachProcsInPlannedAppt(ApptPlanned.Info.MyApt.AptNum);
				AppointmentL.Delete(PIn.PInt(ApptPlanned.DataRoww["AptNum"].ToString()));
			}*/
			Appointment AptCur=new Appointment();
			AptCur.PatNum=PatCur.PatNum;
			AptCur.ProvNum=PatCur.PriProv;
			AptCur.ClinicNum=PatCur.ClinicNum;
			AptCur.AptStatus=ApptStatus.Planned;
			AptCur.AptDateTime=DateTimeOD.Today;
			AptCur.Pattern="/X/";
			AptCur.TimeLocked=PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
			Appointments.Insert(AptCur);
			PlannedAppt plannedAppt=new PlannedAppt();
			plannedAppt.AptNum=AptCur.AptNum;
			plannedAppt.PatNum=PatCur.PatNum;
			plannedAppt.ItemOrder=TablePlanned.Rows.Count+1;
			PlannedAppts.Insert(plannedAppt);
			FormApptEdit FormApptEdit2=new FormApptEdit(AptCur.AptNum);
			FormApptEdit2.IsNew=true;
			FormApptEdit2.ShowDialog();
			if(FormApptEdit2.DialogResult!=DialogResult.OK){
				//delete new appt, delete plannedappt, and unattach procs already handled in dialog
				Refresh();
				return;
			}
			List<Procedure> myProcList=Procedures.Refresh(PatCur.PatNum);
			bool allProcsHyg=true;
			for(int i=0;i<myProcList.Count;i++){
				if(myProcList[i].PlannedAptNum!=AptCur.AptNum)
					continue;//only concerned with procs on this plannedAppt
				if(!ProcedureCodes.GetProcCode(myProcList[i].CodeNum).IsHygiene){
					allProcsHyg=false;
					break;
				}
			}
			if(allProcsHyg && PatCur.SecProv!=0){
				Appointment aptOld=AptCur.Clone();
				AptCur.ProvNum=PatCur.SecProv;
				Appointments.Update(AptCur,aptOld);
			}
			Patient patOld=PatCur.Copy();
			//PatCur.NextAptNum=AptCur.AptNum;
			PatCur.PlannedIsDone=false;
			Patients.Update(PatCur,patOld);
			Refresh();//if procs were added in appt, then this will display them
		}
コード例 #21
0
ファイル: HL7Tests.cs プロジェクト: romeroyonatan/opendental
		///<summary>Test 11: EcwOldTight,EcwOldFull,EcwTight,HL7DefEcwFull: Add 2 D0230 procedures, a D0150 procedure, and a D2332 procedure all with complete status and ProcDate='2012-09-06' to patient with PatNum=10.  Set the D2332 procedurelog.ToothNum=26 and procedurelog.Surf=MID.  Make sure the procedurelog.ProcFee for D0230 is 20.00, the D0150 is 75.00, and the D2332 is 150.00.  Using DOC1 provider from TEST 9, schedule appointment for patient 10 with appointment.AptNum=500 and appointment.ProvNum=provider.ProvNum and attach the four procedures.  Create a DFT message for this patient, provider, appointment, and procedures.  EcwOldStandalone,HL7DefEcwStandalone: DFT messages are not created in Standalone mode.</summary>
		public static string Test11(HL7TestInterfaceEnum hl7TestInterfaceEnum) {
			if(hl7TestInterfaceEnum==HL7TestInterfaceEnum.EcwOldStandalone 
				|| hl7TestInterfaceEnum==HL7TestInterfaceEnum.HL7DefEcwStandalone) {
					return "Test 11: Passed.\r\n";
			}
			List<Procedure> procList=new List<Procedure>();
			//Add the 4 procs to the procedurelog table on the correct date, for the correct appointment and patient and provider.
			Procedure proc=new Procedure();
			proc.AptNum=500;
			proc.PatNum=10;
			proc.ProcDate=new DateTime(2012,09,06);
			proc.CodeNum=ProcedureCodes.GetCodeNum("D0150");
			proc.ProcStatus=ProcStat.C;
			if(Providers.GetProvByEcwID("DOC1")==null) {
				return "Test 11: Couldn't locate provider.\r\n";
			}
			proc.ProvNum=Providers.GetProvByEcwID("DOC1").ProvNum;
			proc.ProcFee=75.00;
			Procedures.Insert(proc);
			procList.Add(proc);
			proc=new Procedure();
			proc.AptNum=500;
			proc.PatNum=10;
			proc.ProcDate=new DateTime(2012,09,06);
			proc.CodeNum=ProcedureCodes.GetCodeNum("D0230");
			proc.ProcStatus=ProcStat.C;
			proc.ProvNum=Providers.GetProvByEcwID("DOC1").ProvNum;
			proc.ProcFee=20.00;
			Procedures.Insert(proc);
			procList.Add(proc);
			Procedures.Insert(proc);
			procList.Add(proc);
			proc=new Procedure();
			proc.AptNum=500;
			proc.PatNum=10;
			proc.ProcDate=new DateTime(2012,09,06);
			proc.CodeNum=ProcedureCodes.GetCodeNum("D2332");
			proc.ProcStatus=ProcStat.C;
			proc.ProvNum=Providers.GetProvByEcwID("DOC1").ProvNum;
			proc.ToothNum="26";
			proc.Surf="MID";
			proc.ProcFee=150.00;
			Procedures.Insert(proc);
			procList.Add(proc);
			Appointment apt=new Appointment();
			apt.AptNum=500;
			apt.AptDateTime=new DateTime(2012,09,06,10,0,0);
			apt.PatNum=10;
			apt.ProvNum=Providers.GetProvByEcwID("DOC1").ProvNum;
			long aptNum=Appointments.InsertIncludeAptNum(apt,true);
			long provNum=apt.ProvNum;
			Patient pat=Patients.GetPat(10); if(pat==null) {
				return "Test 11: Couldn't locate patient.\r\n";
			}
			Patient oldPat=pat.Copy();
			pat.PriProv=Providers.GetProvByEcwID("DOC1").ProvNum;
			Patients.Update(pat,oldPat);
			Patient guar=Patients.GetPat(11);
			if(guar==null) {
				return "Test 11: Couldn't locate guarantor.\r\n";
			}
			MessageHL7 msg=null;
			try {
				switch(hl7TestInterfaceEnum) {
					//EcwOldStandalone and HL7DefEcwStandalone were handled higher up
					case HL7TestInterfaceEnum.EcwOldFull:
					case HL7TestInterfaceEnum.EcwOldTight:
						OpenDentBusiness.HL7.EcwDFT dft=new OpenDentBusiness.HL7.EcwDFT();
						dft.InitializeEcw(aptNum,provNum,pat,"Test Message","treatment",false);
						msg=new MessageHL7(dft.GenerateMessage());
						break;
					case HL7TestInterfaceEnum.HL7DefEcwFull:
					case HL7TestInterfaceEnum.HL7DefEcwTight:
						msg=new MessageHL7(OpenDentBusiness.HL7.MessageConstructor.GenerateDFT(procList,EventTypeHL7.P03,pat,guar,aptNum,"treatment","Test Message").ToString());
						//msg will be null if there's not DFT defined for the def.  Should handle results for those defs higher up
						break;
					default:
						return "Test 11: interface not found.";
				}
			}
			catch(Exception ex) {
				return "Test 11: Message creation error. "+ex+".\r\n";
			}
			string provField="";
			switch(hl7TestInterfaceEnum) {
				case HL7TestInterfaceEnum.EcwOldFull:
				case HL7TestInterfaceEnum.EcwOldTight:
					provField="DOC1^Albert, Brian S^^";
					break;
				default:
					provField="DOC1^Albert^Brian^S";
					break;
			}
			string msgtext=@"MSH|^~\&|OD||ECW||"+msg.Segments[0].GetFieldFullText(6)+"||DFT^P03||P|2.3\r\n"
				+"EVN|P03|"+msg.Segments[1].GetFieldFullText(2)+"|\r\n"
				+"PID|1|A11|10||Smith^Jane^N||19760205|F||White|421 Main St^Apt 17^Dallas^OR^97338||5035554045|5035554234||Married|||111224444|||\r\n"
				+"PV1|||||||"+provField+"||||||||||||500|||||||||||||||||||||||||||||||\r\n"
				+"FT1|1|||20120906000000|20120906000000|CG||||1.0||||||||||"+provField+"|"+provField+"|75.00|||D0150|^\r\n"
				+"FT1|2|||20120906000000|20120906000000|CG||||1.0||||||||||"+provField+"|"+provField+"|20.00|||D0230|^\r\n"
				+"FT1|3|||20120906000000|20120906000000|CG||||1.0||||||||||"+provField+"|"+provField+"|20.00|||D0230|^\r\n"
				+"FT1|4|||20120906000000|20120906000000|CG||||1.0||||||||||"+provField+"|"+provField+"|150.00|||D2332|26^MID\r\n"
				+"ZX1|6|PDF|PATHOLOGY^Pathology Report^L|treatment|Test Message";
			MessageHL7 correctMsg=new MessageHL7(msgtext);
			string retval=CompareMsgs(msg,correctMsg);
			if(retval.Length>0) {
				return "Test 11: "+retval;
			}
			return "Test 11: Passed.\r\n";
		}
コード例 #22
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;
		}
コード例 #23
0
ファイル: Procedures.cs プロジェクト: mnisl/OD
		///<summary>Loops through each proc. Does not add notes to a procedure that already has notes. Used three times, security checked in all three places before calling this.  Also sets provider for each proc and claimproc.</summary>
		public static void SetCompleteInAppt(Appointment apt,List<InsPlan> PlanList,List<PatPlan> patPlans,long siteNum,int patientAge,List<Procedure> procsInAppt,List<InsSub> subList) { 
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),apt,PlanList,patPlans,siteNum,patientAge,procsInAppt,subList);
				return;
			}
			List<Procedure> ProcList=Procedures.Refresh(apt.PatNum);
			List<ClaimProc> ClaimProcList=ClaimProcs.Refresh(apt.PatNum);
			List<Benefit> benefitList=Benefits.Refresh(patPlans,subList);
			//this query could be improved slightly to only get notes of interest.
			string command="SELECT * FROM procnote WHERE PatNum="+POut.Long(apt.PatNum)+" ORDER BY EntryDateTime";
			DataTable rawNotes=Db.GetTable(command);
			//CovPats.Refresh(PlanList,patPlans);
			//bool doResetRecallStatus=false;
			ProcedureCode procCode;
			Procedure oldProc;
			//int siteNum=0;
			//if(!PrefC.GetBool(PrefName.EasyHidePublicHealth")){
			//	siteNum=Patients.GetPat(apt.PatNum).SiteNum;
			//}
			List<long> encounterProvNums = new List<long>();  //for auto-inserting default encounters
			for(int i=0;i<ProcList.Count;i++) {
				if(ProcList[i].AptNum!=apt.AptNum) {
					continue;
				}
				//if(ProcList[i].ProcStatus==ProcStat.C) {//if the procedure is already complete, don't touch it.
				//too severe
				//}
				//attach the note, if it exists.
				for(int n=rawNotes.Rows.Count-1;n>=0;n--) {//loop through each note, backwards.
					if(ProcList[i].ProcNum.ToString()!=rawNotes.Rows[n]["ProcNum"].ToString()) {
						continue;
					}
					ProcList[i].UserNum=PIn.Long(rawNotes.Rows[n]["UserNum"].ToString());
					ProcList[i].Note=PIn.String(rawNotes.Rows[n]["Note"].ToString());
					ProcList[i].SigIsTopaz=PIn.Bool(rawNotes.Rows[n]["SigIsTopaz"].ToString());
					ProcList[i].Signature=PIn.String(rawNotes.Rows[n]["Signature"].ToString());
					break;//out of note loop.
				}
				oldProc=ProcList[i].Copy();
				procCode=ProcedureCodes.GetProcCode(ProcList[i].CodeNum);
				if(procCode.PaintType==ToothPaintingType.Extraction) {//if an extraction, then mark previous procs hidden
					//SetHideGraphical(ProcList[i]);//might not matter anymore
					ToothInitials.SetValue(apt.PatNum,ProcList[i].ToothNum,ToothInitialType.Missing);
				}
				ProcList[i].ProcStatus=ProcStat.C;
				if(oldProc.ProcStatus!=ProcStat.C) {
					ProcList[i].ProcDate=apt.AptDateTime.Date;//only change date to match appt if not already complete.
					ProcList[i].DateEntryC=DateTime.Now;//this triggers it to set to server time NOW().
					if(ProcList[i].DiagnosticCode=="") {
						ProcList[i].DiagnosticCode=PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
					}
				}
				ProcList[i].PlaceService=(PlaceOfService)PrefC.GetLong(PrefName.DefaultProcedurePlaceService);
				ProcList[i].ClinicNum=apt.ClinicNum;
				ProcList[i].SiteNum=siteNum;
				ProcList[i].PlaceService=Clinics.GetPlaceService(apt.ClinicNum);
				if(apt.ProvHyg!=0) {//if the appointment has a hygiene provider
					if(procCode.IsHygiene) {//hyg proc
						ProcList[i].ProvNum=apt.ProvHyg;
					}
					else {//regular proc
						ProcList[i].ProvNum=apt.ProvNum;
					}
				}
				else {//same provider for every procedure
					ProcList[i].ProvNum=apt.ProvNum;
				}
				if(procCode.ProvNumDefault!=0) {//Override provider for procedures with a default provider
					ProcList[i].ProvNum=procCode.ProvNumDefault;
				}
				//if procedure was already complete, then don't add more notes.
				if(oldProc.ProcStatus!=ProcStat.C) {
					ProcList[i].Note+=ProcCodeNotes.GetNote(ProcList[i].ProvNum,ProcList[i].CodeNum);
				}
				if(CultureInfo.CurrentCulture.Name.EndsWith("CA")) {//Canada
					Procedures.SetCanadianLabFeesCompleteForProc(ProcList[i]);
				}
				Plugins.HookAddCode(null,"Procedures.SetCompleteInAppt_procLoop",ProcList[i],oldProc);
				Procedures.Update(ProcList[i],oldProc);
				Procedures.ComputeEstimates(ProcList[i],apt.PatNum,ClaimProcList,false,PlanList,patPlans,benefitList,patientAge,subList);
				ClaimProcs.SetProvForProc(ProcList[i],ClaimProcList);
				//Add provnum to list to create an encounter later. Done to limit calls to DB from Encounters.InsertDefaultEncounter().
				if(oldProc.ProcStatus!=ProcStat.C && !encounterProvNums.Contains(ProcList[i].ProvNum)) {
					encounterProvNums.Add(ProcList[i].ProvNum);
				}
			}
			//Auto-insert default encounters for the providers that did work on this appointment
			for(int j=0;j<encounterProvNums.Count;j++) {
				Encounters.InsertDefaultEncounter(apt.PatNum,encounterProvNums[j],apt.AptDateTime);
			}
			//if(doResetRecallStatus){
			//	Recalls.Reset(apt.PatNum);//this also synchs recall
			//}
			Recalls.Synch(apt.PatNum);
			//Patient pt=Patients.GetPat(apt.PatNum);
			//jsparks-See notes within this method:
			//Reporting.Allocators.AllocatorCollection.CallAll_Allocators(pt.Guarantor);
		}
コード例 #24
0
ファイル: FormApptsOther.cs プロジェクト: nampn/ODental
 private void butNew_Click(object sender, System.EventArgs e)
 {
     Appointment AptCur=new Appointment();
     AptCur.PatNum=PatCur.PatNum;
     if(PatCur.DateFirstVisit.Year<1880
         && !Procedures.AreAnyComplete(PatCur.PatNum))//this only runs if firstVisit blank
     {
         AptCur.IsNewPatient=true;
     }
     AptCur.Pattern="/X/";
     if(PatCur.PriProv==0){
         AptCur.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
     }
     else{
         AptCur.ProvNum=PatCur.PriProv;
     }
     AptCur.ProvHyg=PatCur.SecProv;
     AptCur.AptDateTime=DateTime.MinValue;//(was .Now) This is what triggers automatic deletion from db when clear pinboard is clicked.
     AptCur.ClinicNum=PatCur.ClinicNum;
     if(InitialClick){//initially double clicked on appt module
         DateTime d;
         if(ApptDrawing.IsWeeklyView){
             d=ContrAppt.WeekStartDate.AddDays(ContrAppt.SheetClickedonDay);
         }
         else{
             d=AppointmentL.DateSelected;
         }
         int minutes=(int)(ContrAppt.SheetClickedonMin/ApptDrawing.MinPerIncr)*ApptDrawing.MinPerIncr;
         AptCur.AptDateTime=new DateTime(d.Year,d.Month,d.Day
             ,ContrAppt.SheetClickedonHour,minutes,0);
         if(PatCur.AskToArriveEarly>0){
             AptCur.DateTimeAskedToArrive=AptCur.AptDateTime.AddMinutes(-PatCur.AskToArriveEarly);
             MessageBox.Show(Lan.g(this,"Ask patient to arrive")+" "+PatCur.AskToArriveEarly
                 +" "+Lan.g(this,"minutes early at")+" "+AptCur.DateTimeAskedToArrive.ToShortTimeString()+".");
         }
         AptCur.Op=ContrAppt.SheetClickedonOp;
         Operatory curOp=Operatories.GetOperatory(AptCur.Op);
         //if(curOp.ProvDentist!=0) {
         //  AptCur.ProvNum=curOp.ProvDentist;
         //}
         //AptCur.ProvHyg=curOp.ProvHygienist;
         List<Schedule> schedListPeriod=Schedules.RefreshDayEdit(AptCur.AptDateTime);
         long assignedDent=Schedules.GetAssignedProvNumForSpot(schedListPeriod,curOp,false,AptCur.AptDateTime);
         long assignedHyg=Schedules.GetAssignedProvNumForSpot(schedListPeriod,curOp,true,AptCur.AptDateTime);
         if(assignedDent!=0) {//if no dentist is assigned to op, then keep the original dentist.  All appts must have prov.
             AptCur.ProvNum=assignedDent;
         }
         AptCur.ProvHyg=assignedHyg;
         AptCur.IsHygiene=curOp.IsHygiene;
         if(curOp.ClinicNum!=0){
             AptCur.ClinicNum=curOp.ClinicNum;
         }
         AptCur.AptStatus=ApptStatus.Scheduled;
     }
     else{
         //new appt will be placed on pinboard instead of specific time
         AptCur.AptStatus=ApptStatus.UnschedList;//This is so that if it's on the pinboard when use shuts down OD, no db inconsistency.
     }
     try{
         Appointments.Insert(AptCur);
     }
     catch(ApplicationException ex){
         MessageBox.Show(ex.Message);
         return;
     }
     FormApptEdit FormApptEdit2=new FormApptEdit(AptCur.AptNum);
     FormApptEdit2.IsNew=true;
     FormApptEdit2.ShowDialog();
     if(FormApptEdit2.DialogResult!=DialogResult.OK){
         return;
     }
     if(InitialClick) {
         //Change PatStatus to Prospective or from Prospective.
         Operatory opCur=Operatories.GetOperatory(AptCur.Op);
         if(opCur.SetProspective && PatCur.PatStatus!=PatientStatus.Prospective) { //Don't need to prompt if patient is already prospective.
             if(MsgBox.Show(this,MsgBoxButtons.OKCancel,"Patient's status will be set to Prospective.")) {
                 Patient patOld=PatCur.Copy();
                 PatCur.PatStatus=PatientStatus.Prospective;
                 Patients.Update(PatCur,patOld);
             }
         }
         else if(!opCur.SetProspective && PatCur.PatStatus==PatientStatus.Prospective) {
             if(MsgBox.Show(this,MsgBoxButtons.OKCancel,"Patient's status will change from Prospective to Patient.")) {
                 Patient patOld=PatCur.Copy();
                 PatCur.PatStatus=PatientStatus.Patient;
                 Patients.Update(PatCur,patOld);
             }
         }
     }
     AptNumsSelected.Add(AptCur.AptNum);
     if(InitialClick){
         oResult=OtherResult.CreateNew;
     }
     else{
         oResult=OtherResult.NewToPinBoard;
     }
     if(AptCur.IsNewPatient) {
         AutomationL.Trigger(AutomationTrigger.CreateApptNewPat,null,AptCur.PatNum);
     }
     DialogResult=DialogResult.OK;
 }
コード例 #25
0
ファイル: Procedures.cs プロジェクト: mnisl/OD
		///<Summary>Supply the list of procedures attached to the appointment.  It will loop through each and assign the correct provider.  Also sets clinic.  Also sets procDate for TP procs.  js 7/24/12 This is not supposed to be called if the appointment is complete.</Summary>
		public static void SetProvidersInAppointment(Appointment apt,List<Procedure> procList) {
			//No need to check RemotingRole; no call to db.
			ProcedureCode procCode;
			Procedure changedProc;
			for(int i=0;i<procList.Count;i++) {
				changedProc=procList[i].Copy();
				procCode=ProcedureCodes.GetProcCode(procList[i].CodeNum);
				if(apt.ProvHyg!=0) {//if the appointment has a hygiene provider
					if(procCode.IsHygiene) {//hygiene proc
						changedProc.ProvNum=apt.ProvHyg;
					} 
					else {//dentist proc
						changedProc.ProvNum=apt.ProvNum;
					}
				} 
				else {//same provider for every procedure
					changedProc.ProvNum=apt.ProvNum;
				}
				if(procCode.ProvNumDefault!=0) {
					changedProc.ProvNum=procCode.ProvNumDefault;//Override ProvNum if there is a default provider for procCode
				}
				changedProc.ClinicNum=apt.ClinicNum;
				if(procList[i].ProcStatus==ProcStat.TP) {
					changedProc.ProcDate=apt.AptDateTime;
				}
				Procedures.Update(changedProc,procList[i]);//won't go to db unless a field has changed.
			}
		}
コード例 #26
0
ファイル: FormApptsOther.cs プロジェクト: nampn/ODental
 /// <summary>Tests the appointment to see if it is acceptable to send it to the pinboard.  Also asks user appropriate questions to verify that's what they want to do.  Returns false if it will not be going to pinboard after all.</summary>
 private bool OKtoSendToPinboard(Appointment AptCur)
 {
     if(AptCur.AptStatus==ApptStatus.Planned){//if is a Planned appointment
         bool PlannedIsSched=false;
         for(int i=0;i<ApptList.Length;i++){
             if(ApptList[i].NextAptNum==AptCur.AptNum){//if the planned appointment is already sched
                 PlannedIsSched=true;
             }
         }
         if(PlannedIsSched){
             if(MessageBox.Show(Lan.g(this,"The Planned appointment is already scheduled.  Do you wish to continue?"),"",MessageBoxButtons.OKCancel)!=DialogResult.OK){
                 return false;
             }
         }
     }
     else{//if appointment is not Planned
         switch(AptCur.AptStatus){
             case ApptStatus.Complete:
                 MessageBox.Show(Lan.g(this,"Not allowed to move a completed appointment from here."));
                 return false;
             case ApptStatus.ASAP:
             case ApptStatus.Scheduled:
                 if(MessageBox.Show(Lan.g(this,"Do you really want to move a previously scheduled appointment?"),"",MessageBoxButtons.OKCancel)!=DialogResult.OK){
                     return false;
                 }
                 break;
             case ApptStatus.Broken://status gets changed after dragging off pinboard.
             case ApptStatus.None:
             case ApptStatus.UnschedList://status gets changed after dragging off pinboard.
                 break;
         }
     }
     //if it's a planned appointment, the planned appointment will end up on the pinboard.  The copy will be made after dragging it off the pinboard.
     return true;
 }
コード例 #27
0
        //Note that the columns ProcsColored and Note are VARCHAR(255) in this table while they are TEXT in the appointment table. This is intentional
        //because it is less important to store the entire note and color when the appointment is not current.

        ///<summary>Pass in the old appointment that needs to be recorded.</summary>
        public HistAppointment(Appointment appt)
        {
            SetAppt(appt);
        }
コード例 #28
0
ファイル: ContrAppt.cs プロジェクト: romeroyonatan/opendental
		///<summary>Called when releasing an appointment to make sure it does not overlap any other appointment.  Tests all appts for the day, even if not visible.</summary>
		private bool DoesOverlap(Appointment aptCur) {
			DateTime aptDateTime;
			for(int i=0;i<DS.Tables["Appointments"].Rows.Count;i++) {
				if(DS.Tables["Appointments"].Rows[i]["AptNum"].ToString()==aptCur.AptNum.ToString()) {
					continue;
				}
				if(DS.Tables["Appointments"].Rows[i]["Op"].ToString()!=aptCur.Op.ToString()) {
					continue;
				}
				aptDateTime=PIn.DateT(DS.Tables["Appointments"].Rows[i]["AptDateTime"].ToString());
				if(aptDateTime.Date!=aptCur.AptDateTime.Date) {
					continue;
				}
				//tests start time
				if(aptCur.AptDateTime.TimeOfDay >= aptDateTime.TimeOfDay
					&& aptCur.AptDateTime.TimeOfDay < aptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(
					DS.Tables["Appointments"].Rows[i]["Pattern"].ToString().Length*5))) {
					//Debug.WriteLine(TimeSpan.FromMinutes(ListDay[i].Pattern.Length*5).ToString());
					return true;
				}
				//tests stop time
				if(aptCur.AptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(aptCur.Pattern.Length*5)) > aptDateTime.TimeOfDay
					&& aptCur.AptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(aptCur.Pattern.Length*5))
					<= aptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(DS.Tables["Appointments"].Rows[i]["Pattern"].ToString().Length*5))) {
					return true;
				}
				//tests engulf
				if(aptCur.AptDateTime.TimeOfDay <= aptDateTime.TimeOfDay
					&& aptCur.AptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(aptCur.Pattern.Length*5))
					>= aptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(DS.Tables["Appointments"].Rows[i]["Pattern"].ToString().Length*5))) {
					return true;
				}
			}
			return false;
		}
コード例 #29
0
		public static string Validate(Appointment appt) {
			StringBuilder sb=new StringBuilder();
			Provider provFacility=Providers.GetProv(PrefC.GetInt(PrefName.PracticeDefaultProv));
			if(!Regex.IsMatch(provFacility.NationalProvID,"^(80840)?[0-9]{10}$")) {
				WriteError(sb,"Invalid NPI for provider '"+provFacility.Abbr+"'");
			}
			if(!PrefC.GetBool(PrefName.EasyNoClinics) && appt.ClinicNum!=0) {//Using clinics and a clinic is assigned.
				Clinic clinic=Clinics.GetClinic(appt.ClinicNum);
				if(clinic.Description=="") {
					WriteError(sb,"Missing clinic description for clinic attached to appointment.");
				}
			}
			else {//Not using clinics for this patient
				if(PrefC.GetString(PrefName.PracticeTitle)=="") {
					WriteError(sb,"Missing practice title.");
				}
			}
			Patient pat=Patients.GetPat(appt.PatNum);
			if(pat.PatStatus==PatientStatus.Deceased && pat.DateTimeDeceased.Year<1880) {
				WriteError(sb,"Missing date time deceased.");
			}			
			List<EhrAptObs> listObservations=EhrAptObses.Refresh(appt.AptNum);
			for(int i=0;i<listObservations.Count;i++) {
				EhrAptObs obs=listObservations[i];
				if(obs.ValType==EhrAptObsType.Coded) {
					if(obs.ValCodeSystem.Trim().ToUpper()=="LOINC") {
						Loinc loincVal=Loincs.GetByCode(obs.ValReported);
						if(loincVal==null) {
							WriteError(sb,"Loinc code not found '"+loincVal.LoincCode+"'.  Please add by going to Setup | EHR.");
						}
					}
					else if(obs.ValCodeSystem.Trim().ToUpper()=="SNOMEDCT") {
						Snomed snomedVal=Snomeds.GetByCode(obs.ValReported);
						if(snomedVal==null) {
							WriteError(sb,"Snomed code not found '"+snomedVal.SnomedCode+"'.  Please add by going to Setup | EHR.");
						}
					}
					else if(obs.ValCodeSystem.Trim().ToUpper()=="ICD9") {
						ICD9 icd9Val=ICD9s.GetByCode(obs.ValReported);
						if(icd9Val==null) {
							WriteError(sb,"ICD9 code not found '"+icd9Val.ICD9Code+"'.  Please add by going to Setup | EHR.");
						}
					}
					else if(obs.ValCodeSystem.Trim().ToUpper()=="ICD10") {
						Icd10 icd10Val=Icd10s.GetByCode(obs.ValReported);
						if(icd10Val==null) {
							WriteError(sb,"ICD10 code not found '"+icd10Val.Icd10Code+"'.  Please add by going to Setup | EHR.");
						}
					}
				}
				else if(obs.ValType==EhrAptObsType.Numeric && obs.UcumCode!="") {//We only validate the ucum code if it will be sent out.  Blank units allowed.
					Ucum ucum=Ucums.GetByCode(obs.UcumCode);
					if(ucum==null) {
						WriteError(sb,"Invalid unit code '"+obs.UcumCode+"' for observation (must be UCUM code).");
					}
				}
			}
			return sb.ToString();
		}
コード例 #30
0
		///<summary></summary>
		public FormApptEdit(long aptNum)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			Lan.F(this);
			DS=Appointments.GetApptEdit(aptNum);
			AptCur=Appointments.TableToObject(DS.Tables["Appointment"]);
			AptOld=AptCur.Clone();
		}
コード例 #31
0
ファイル: ContrAppt.cs プロジェクト: mnisl/OD
		///<summary>Checks if the appointment's start time overlaps another appt.  Tests all appts for the day, even if not visible.  Call RefreshPeriod before calling this.</summary>
		private bool HasValidStartTime(Appointment aptCur) {
			DateTime aptDateTime;
			for(int i=0;i<DS.Tables["Appointments"].Rows.Count;i++) {
				if(DS.Tables["Appointments"].Rows[i]["AptNum"].ToString()==aptCur.AptNum.ToString()) {
					continue;
				}
				if(DS.Tables["Appointments"].Rows[i]["Op"].ToString()!=aptCur.Op.ToString()) {
					continue;
				}
				aptDateTime=PIn.DateT(DS.Tables["Appointments"].Rows[i]["AptDateTime"].ToString());
				if(aptDateTime.Date!=aptCur.AptDateTime.Date) {
					continue;
				}
				//tests start time
				if(aptCur.AptDateTime.TimeOfDay >= aptDateTime.TimeOfDay
					&& aptCur.AptDateTime.TimeOfDay < aptDateTime.TimeOfDay.Add(TimeSpan.FromMinutes(
					DS.Tables["Appointments"].Rows[i]["Pattern"].ToString().Length*5))) 
				{
					return false;
				}
			}
			return true;
		}
コード例 #32
0
ファイル: Appointments.cs プロジェクト: mnisl/OD
		///<summary>Fills an appointment passed in with all appropriate procedures for the recall passed in.  It's up to the calling class to then place the appointment on the pinboard or schedule.  The appointment will be inserted into the database in this method so it's important to delete it if the appointment doesn't get scheduled.  Returns the list of procedures that were created for the appointment so that they can be displayed to Orion users.</summary>
		public static List<Procedure> FillAppointmentForRecall(Appointment aptCur,Recall recallCur,List<Recall> listRecalls,Patient patCur,List<string> listProcStrs,List<InsPlan> listPlans,List<InsSub> listSubs) {
			//No need to check RemotingRole; no call to db.
			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:
			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.
			{
				List<RecallType> listRecallTypes=RecallTypeC.GetListt();
				for(int i=0;i<listRecallTypes.Count;i++) {
					if(listRecallTypes[i].RecallTypeNum==RecallTypes.ChildProphyType) {
						List<string> childprocs=RecallTypes.GetProcs(listRecallTypes[i].RecallTypeNum);
						if(childprocs.Count>0) {
							listProcStrs=childprocs;//overrides adult procs.
						}
						string childpattern=RecallTypes.GetTimePattern(listRecallTypes[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<listRecalls.Count;i++) {
					if(recallCur.RecallNum==listRecalls[i].RecallNum) {
						continue;//already handled.
					}
					if(listRecalls[i].IsDisabled) {
						continue;
					}
					if(listRecalls[i].DateDue.Year<1880) {
						continue;
					}
					if(listRecalls[i].DateDue>recallCur.DateDue//if film due date is after prophy due date
						&& listRecalls[i].DateDue>DateTime.Today)//and not overdue
					{
						continue;
					}
					//incomplete: exclude manual recall types
					listProcStrs.AddRange(RecallTypes.GetProcs(listRecalls[i].RecallTypeNum));
				}
			}
			aptCur.ProcDescript="";
			aptCur.ProcsColored="";
			for(int i=0;i<listProcStrs.Count;i++) {
				string procDescOne="";
				if(i>0) {
					aptCur.ProcDescript+=", ";
				}
				procDescOne+=ProcedureCodes.GetProcCode(listProcStrs[i]).AbbrDesc;
				aptCur.ProcDescript+=procDescOne;
				//Color and previous date are determined by ProcApptColor object
				ProcApptColor pac=ProcApptColors.GetMatch(listProcStrs[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> listPatPlans=PatPlans.Refresh(patCur.PatNum);
			List<Benefit> listBenifits=Benefits.Refresh(listPatPlans,listSubs);
			InsPlan priplan=null;
			InsSub prisub=null;
			if(listPatPlans.Count>0) {
				prisub=InsSubs.GetSub(listPatPlans[0].InsSubNum,listSubs);
				priplan=InsPlans.GetPlan(prisub.PlanNum,listPlans);
			}
			double insfee;
			double standardfee;
			List<Procedure> listProcs=new List<Procedure>();
			for(int i=0;i<listProcStrs.Count;i++) {
				procCur=new Procedure();//this will be an insert
				//procnum
				procCur.PatNum=patCur.PatNum;
				procCur.AptNum=aptCur.AptNum;
				procCur.CodeNum=ProcedureCodes.GetCodeNum(listProcStrs[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,listPlans,listPatPlans,listSubs);
				}
				else {
					feeSch=Fees.GetFeeSched(patCur,listPlans,listPatPlans,listSubs);
				}
				//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,listPlans,listPatPlans,listBenifits,patCur.Age,listSubs);
				listProcs.Add(procCur);
			}
			return listProcs;
		}
コード例 #33
0
ファイル: AsapComms.cs プロジェクト: kjb7749/testImport
 ///<summary>Returns true if the appointment will fit in the time slot and there are no other appointments in the slot.</summary>
 public bool IsApptSlotAvailable(Appointment appt, long opNum, DateTime slotStart, DateTime slotEnd)
 {
     return(IsApptSlotAvailable(appt.Length, opNum, slotStart, slotEnd));
 }