Example #1
0
		///<summary></summary>
		public static void Update(ApptField apptField){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				Meth.GetVoid(MethodBase.GetCurrentMethod(),apptField);
				return;
			}
			Crud.ApptFieldCrud.Update(apptField);
		}
Example #2
0
		///<summary></summary>
		public static long Insert(ApptField apptField){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
				apptField.ApptFieldNum=Meth.GetLong(MethodBase.GetCurrentMethod(),apptField);
				return apptField.ApptFieldNum;
			}
			return Crud.ApptFieldCrud.Insert(apptField);
		}
Example #3
0
 ///<summary></summary>
 public static void Update(ApptField apptField)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), apptField);
         return;
     }
     Crud.ApptFieldCrud.Update(apptField);
 }
Example #4
0
 ///<summary></summary>
 public static long Insert(ApptField apptField)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         apptField.ApptFieldNum = Meth.GetLong(MethodBase.GetCurrentMethod(), apptField);
         return(apptField.ApptFieldNum);
     }
     return(Crud.ApptFieldCrud.Insert(apptField));
 }
		///<summary></summary>
		public FormApptFieldEdit(ApptField field)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			Lan.F(this);
			Field=field;
		}
Example #6
0
 ///<summary>Deletes any pre-existing appt fields for the AptNum and FieldName combo and then inserts the apptField passed in.</summary>
 public static long Upsert(ApptField apptField)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         apptField.ApptFieldNum = Meth.GetLong(MethodBase.GetCurrentMethod(), apptField);
         return(apptField.ApptFieldNum);
     }
     //There could already be an appt field in the database due to concurrency.  Delete all entries prior to inserting the new one.
     DeleteFieldForAppt(apptField.FieldName, apptField.AptNum);           //Last in wins.
     return(Insert(apptField));
 }
Example #7
0
		private void gridFields_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			if(ApptFieldDefs.HasDuplicateFieldNames()) {//Check for duplicate field names.
				MsgBox.Show(this,"There are duplicate appointment field defs, go rename or delete the duplicates.");
				return;
			}
			ApptField field=ApptFields.GetOne(PIn.Long(DS.Tables["ApptFields"].Rows[e.Row]["ApptFieldNum"].ToString()));
			if(field==null) {
				field=new ApptField();
				field.AptNum=AptCur.AptNum;
				field.FieldName=DS.Tables["ApptFields"].Rows[e.Row]["FieldName"].ToString();
				if(ApptFieldDefs.Listt[e.Row].FieldType==ApptFieldType.Text) {
					FormApptFieldEdit formAF=new FormApptFieldEdit(field);
					formAF.IsNew=true;
					formAF.ShowDialog();
				}
				else if(ApptFieldDefs.Listt[e.Row].FieldType==ApptFieldType.PickList) {
					FormApptFieldPickEdit formAF=new FormApptFieldPickEdit(field);
					formAF.IsNew=true;
					formAF.ShowDialog();
				}
			}
			else {
				if(ApptFieldDefs.Listt[e.Row].FieldType==ApptFieldType.Text) {
					FormApptFieldEdit formAF=new FormApptFieldEdit(field);
					formAF.ShowDialog();
				}
				else if(ApptFieldDefs.Listt[e.Row].FieldType==ApptFieldType.PickList) {
					FormApptFieldPickEdit formAF=new FormApptFieldPickEdit(field);
					formAF.ShowDialog();
				}
			}
			DS.Tables.Remove("ApptFields");
			DS.Tables.Add(Appointments.GetApptEdit(AptCur.AptNum).Tables["ApptFields"].Copy());
			FillFields();
		}
Example #8
0
		///<Summary>Usually happens after a pinboard appt has been dragged onto main appt sheet.</Summary>
		private void pinBoard_MouseUp(object sender,MouseEventArgs e) {
			if(!boolAptMoved) {
				mouseIsDown=false;
				if(TempApptSingle!=null) {
					TempApptSingle.Dispose();
				}
				return;
			}
			if(TempApptSingle.Location.X>ContrApptSheet2.Width) {
				mouseIsDown=false;
				boolAptMoved=false;
				TempApptSingle.Dispose();
				return;
			}
			if(pinBoard.SelectedAppt.DataRoww["AptStatus"].ToString()==((int)ApptStatus.Planned).ToString()//if Planned appt is on pinboard
				&& !Security.IsAuthorized(Permissions.AppointmentCreate))//and no permission to create a new appt
			{
				mouseIsDown = false;
				boolAptMoved=false;
				TempApptSingle.Dispose();
				return;
			}
			//security prevents moving an appointment by preventing placing it on the pinboard, not here
			//We no longer ask user this question.  It just slows things down: "Move Appointment?"
			//convert loc to new time
			Appointment aptCur=Appointments.GetOneApt(PIn.Long(pinBoard.SelectedAppt.DataRoww["AptNum"].ToString()));
			if(aptCur==null) {
				MsgBox.Show(this,"This appointment has been deleted since it was moved to the pinboard. It will now be cleared from the pinboard.");
				mouseIsDown = false;
				boolAptMoved=false;
				TempApptSingle.Dispose();
				pinBoard.ClearSelected();
				return;
			}
			Appointment aptOld=aptCur.Clone();
			RefreshModuleDataPatient(PIn.Long(pinBoard.SelectedAppt.DataRoww["PatNum"].ToString()));//redundant?
			//Patient pat=Patients.GetPat(PIn.PInt(pinBoard.SelectedAppt.DataRoww["PatNum"].ToString()));
			if(aptCur.IsNewPatient && AppointmentL.DateSelected!=aptCur.AptDateTime) {
				Procedures.SetDateFirstVisit(AppointmentL.DateSelected,4,PatCur);
			}
			int tHr=ApptDrawing.ConvertToHour(TempApptSingle.Location.Y-ContrApptSheet2.Location.Y-panelSheet.Location.Y);
			int tMin=ApptDrawing.ConvertToMin(TempApptSingle.Location.Y-ContrApptSheet2.Location.Y-panelSheet.Location.Y);
			DateTime tDate=AppointmentL.DateSelected;
			if(ApptDrawing.IsWeeklyView) {
				tDate=WeekStartDate.AddDays(ApptDrawing.ConvertToDay(TempApptSingle.Location.X-ContrApptSheet2.Location.X));
			}
			DateTime fromDate=aptCur.AptDateTime.Date;
			aptCur.AptDateTime=new DateTime(tDate.Year,tDate.Month,tDate.Day,tHr,tMin,0);
			if(AppointmentRuleC.List.Length>0) {
				//this is crude and temporary:
				List<long> aptNums=new List<long>();
				for(int i=0;i<DS.Tables["Appointments"].Rows.Count;i++) {
					aptNums.Add(PIn.Long(DS.Tables["Appointments"].Rows[i]["AptNum"].ToString()));//ListDay[i].AptNum;
				}
				List<Procedure> procsMultApts=Procedures.GetProcsMultApts(aptNums);
				Procedure[] procsForOne=Procedures.GetProcsOneApt(aptCur.AptNum,procsMultApts);
				ArrayList doubleBookedCodes=
					AppointmentL.GetDoubleBookedCodes(aptCur,DS.Tables["Appointments"].Copy(),procsMultApts,procsForOne);
				if(doubleBookedCodes.Count>0) {//if some codes would be double booked
					if(AppointmentRules.IsBlocked(doubleBookedCodes)) {
						MessageBox.Show(Lan.g(this,"Not allowed to double book:")+" "
							+AppointmentRules.GetBlockedDescription(doubleBookedCodes));
						mouseIsDown = false;
						boolAptMoved=false;
						TempApptSingle.Dispose();
						return;
					}
				}
			}
			Operatory curOp=ApptDrawing.VisOps
				[ApptDrawing.ConvertToOp(TempApptSingle.Location.X-ContrApptSheet2.Location.X)];
			aptCur.Op=curOp.OperatoryNum;
			long assignedDent=Schedules.GetAssignedProvNumForSpot(SchedListPeriod,curOp,false,aptCur.AptDateTime);
			long assignedHyg=Schedules.GetAssignedProvNumForSpot(SchedListPeriod,curOp,true,aptCur.AptDateTime);
			List<Procedure> procsForSingleApt=null;
			if(aptCur.AptStatus!=ApptStatus.PtNote && aptCur.AptStatus!=ApptStatus.PtNoteCompleted) {
				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()+".");
				}
				else {
					aptCur.DateTimeAskedToArrive=DateTime.MinValue;
				}
				//if no dentist/hygienist is assigned to spot, then keep the original dentist/hygienist without prompt.  All appts must have prov.
				if((assignedDent!=0 && assignedDent!=aptCur.ProvNum) || (assignedHyg!=0 && assignedHyg!=aptCur.ProvHyg)) {
					if(MessageBox.Show(Lan.g(this,"Change provider?"),"",MessageBoxButtons.YesNo)==DialogResult.Yes) {
						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;
								}
							}
						}
						bool isplanned=aptCur.AptStatus==ApptStatus.Planned;
						procsForSingleApt=Procedures.GetProcsForSingle(aptCur.AptNum,isplanned);
						List<long> codeNums=new List<long>();
						for(int p=0;p<procsForSingleApt.Count;p++) {
							codeNums.Add(procsForSingleApt[p].CodeNum);
						}
						string calcPattern=Appointments.CalculatePattern(aptCur.ProvNum,aptCur.ProvHyg,codeNums,true);
						if(aptCur.Pattern != calcPattern && !PrefC.GetBool(PrefName.AppointmentTimeIsLocked)) {
							if(aptCur.TimeLocked){
								if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Appointment length is locked.  Change length for new provider anyway?")) {
									aptCur.Pattern=calcPattern;
								}
							}
							else {//appt time not locked
								if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Change length for new provider?")) {
									aptCur.Pattern=calcPattern;
								}
							}
						}
					}
				}
			}
			if(DoesOverlap(aptCur)) {
				int startingOp=ApptDrawing.GetIndexOp(aptCur.Op);
				bool stillOverlaps=true;
				for(int i=startingOp;i<ApptDrawing.VisOps.Count;i++) {
					aptCur.Op=ApptDrawing.VisOps[i].OperatoryNum;
					if(!DoesOverlap(aptCur)) {
						stillOverlaps=false;
						break;
					}
				}
				if(stillOverlaps) {
					for(int i=startingOp;i>=0;i--) {
						aptCur.Op=ApptDrawing.VisOps[i].OperatoryNum;
						if(!DoesOverlap(aptCur)) {
							stillOverlaps=false;
							break;
						}
					}
				}
				if(stillOverlaps) {
					MessageBox.Show(Lan.g(this,"Appointment overlaps existing appointment."));
					mouseIsDown=false;
					boolAptMoved=false;
					TempApptSingle.Dispose();
					return;
				}
			}
			Operatory opCur=Operatories.GetOperatory(aptCur.Op);
			Operatory opOld=Operatories.GetOperatory(aptOld.Op);
			if(opOld==null || opCur.SetProspective!=opOld.SetProspective) {
				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) {
					//Do we need to warn about changing FROM prospective? Assume so for now.
					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);
					}
				}
			}
			if(aptCur.AptStatus==ApptStatus.Broken) {
				aptCur.AptStatus=ApptStatus.Scheduled;
			}
			if(aptCur.AptStatus==ApptStatus.UnschedList) {
				aptCur.AptStatus=ApptStatus.Scheduled;
			}
			//original position of provider settings
			if(curOp.ClinicNum==0){
				aptCur.ClinicNum=PatCur.ClinicNum;
			}
			else{
				aptCur.ClinicNum=curOp.ClinicNum;
			}
			if(aptCur.AptStatus==ApptStatus.Planned) {//if Planned appt is on pinboard
				long plannedAptNum=aptCur.AptNum;
				LabCase lab=LabCases.GetForPlanned(aptCur.AptNum);
				aptCur.NextAptNum=aptCur.AptNum;
				aptCur.AptStatus=ApptStatus.Scheduled;
				aptCur.TimeLocked=PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
				try {
					Appointments.Insert(aptCur);//now, aptnum is different.
					for(int i=0;i<pinBoard.SelectedAppt.TableApptFields.Rows.Count;i++) {//Duplicate the appointment fields.
						//in SendToPinboard, TableApptFields is refreshed for just the one planned appt instead of all appts for day.
						ApptField apptField=new ApptField();
						apptField.AptNum=aptCur.AptNum;
						apptField.FieldName=PIn.String(pinBoard.SelectedAppt.TableApptFields.Rows[i]["FieldName"].ToString());
						apptField.FieldValue=PIn.String(pinBoard.SelectedAppt.TableApptFields.Rows[i]["FieldValue"].ToString());
						ApptFields.Insert(apptField);
					}
					//for(int i=0;i<pinBoard.SelectedAppt.TablePatFields.Rows.Count;i++) {//Duplicate the patient fields.
					//	PatField patField=new PatField();
					//	patField.PatNum=aptCur.PatNum;
					//	patField.FieldName=PIn.String(pinBoard.SelectedAppt.TablePatFields.Rows[i]["FieldName"].ToString());
					//	patField.FieldValue=PIn.String(pinBoard.SelectedAppt.TablePatFields.Rows[i]["FieldValue"].ToString());
					//	PatFields.Insert(patField);
					//}
				}
				catch(ApplicationException ex) {
					MessageBox.Show(ex.Message);
					return;
				}
				SecurityLogs.MakeLogEntry(Permissions.AppointmentCreate,aptCur.PatNum,
					aptCur.AptDateTime.ToString()+", "+aptCur.ProcDescript,
					aptCur.AptNum);
				List<Procedure> ProcList=Procedures.Refresh(aptCur.PatNum);
				bool procAlreadyAttached=false;
				for(int i=0;i<ProcList.Count;i++) {
					if(ProcList[i].PlannedAptNum==plannedAptNum) {//if on the planned apt
						if(ProcList[i].AptNum>0) {//already attached to another appt
							procAlreadyAttached=true;
						}
						else {//only update procedures not already attached to another apt
							Procedures.UpdateAptNum(ProcList[i].ProcNum,aptCur.AptNum);
							//.Update(ProcCur,ProcOld);//recall synch not required.
						}
					}
				}
				if(procAlreadyAttached) {
					MessageBox.Show(Lan.g(this,"One or more procedures could not be scheduled because they were already attached to another appointment. Someone probably forgot to update the Next appointment in the Chart module."));
					FormApptEdit formAE=new FormApptEdit(aptCur.AptNum);
					CheckStatus();
					formAE.IsNew=true;
					formAE.ShowDialog();//to force refresh of aptDescript
					if(formAE.DialogResult!=DialogResult.OK) {//apt gets deleted from within aptEdit window.
						TempApptSingle.Dispose();
						RefreshModuleScreenPatient();
						RefreshPeriod();
						mouseIsDown = false;
						boolAptMoved=false;
						return;
					}
				}
				if(lab!=null) {
					LabCases.AttachToAppt(lab.LabCaseNum,aptCur.AptNum);
				}
			}//if planned appointment is on pinboard
			else {//simple drag off pinboard to a new date/time
				aptCur.Confirmed=DefC.Short[(int)DefCat.ApptConfirmed][0].DefNum;//Causes the confirmation status to be reset.
				try {
					Appointments.Update(aptCur,aptOld);
					SecurityLogs.MakeLogEntry(Permissions.AppointmentMove,aptCur.PatNum,
						aptCur.ProcDescript+", from "+aptOld.AptDateTime.ToString()+", to "+aptCur.AptDateTime.ToString(),
						aptCur.AptNum);
				}
				catch(ApplicationException ex) {
					MessageBox.Show(ex.Message);
					return;
				}
			}
			if(procsForSingleApt==null) {
				procsForSingleApt=Procedures.GetProcsForSingle(aptCur.AptNum,false);
			}
			Procedures.SetProvidersInAppointment(aptCur,procsForSingleApt);
			TempApptSingle.Dispose();
			pinBoard.ClearSelected();
			//PinApptSingle.Visible=false;
			//ContrApptSingle.PinBoardIsSelected=false;
			ContrApptSingle.SelectedAptNum=aptCur.AptNum;
			RefreshModuleScreenPatient();
			//RefreshModulePatient(PatCurNum);
			RefreshPeriod();//date moving to for this computer
			SetInvalid();//date moving to for other computers
			AppointmentL.DateSelected=fromDate;
			SetInvalid();//for date moved from for other computers.
			AppointmentL.DateSelected=aptCur.AptDateTime;
			mouseIsDown = false;
			boolAptMoved=false;
			List<string> procCodes=new List<string>();
			for(int i=0;i<procsForSingleApt.Count;i++) {
				procCodes.Add(ProcedureCodes.GetProcCode((long)procsForSingleApt[i].CodeNum).ProcCode);
			}
			//Recalls.SynchScheduledApptLazy(aptCur.PatNum, aptCur.AptDateTime, procCodes);
			Recalls.SynchScheduledApptFull(aptCur.PatNum);
		}
Example #9
0
		public FormApptFieldPickEdit(ApptField field) {
			InitializeComponent();
			Lan.F(this);
			Field=field;
		}
Example #10
0
 private void gridFields_CellDoubleClick(object sender,ODGridClickEventArgs e)
 {
     ApptField field=ApptFields.GetOne(PIn.Long(DS.Tables["ApptFields"].Rows[e.Row]["ApptFieldNum"].ToString()));
     if(field==null) {
         field=new ApptField();
         field.AptNum=AptCur.AptNum;
         field.FieldName=DS.Tables["ApptFields"].Rows[e.Row]["FieldName"].ToString();
         FormApptFieldEdit formAF=new FormApptFieldEdit(field);
         formAF.IsNew=true;
         formAF.ShowDialog();
     }
     else {
         FormApptFieldEdit formAF=new FormApptFieldEdit(field);
         formAF.ShowDialog();
     }
     DS.Tables.Remove("ApptFields");
     DS.Tables.Add(Appointments.GetApptEdit(AptCur.AptNum).Tables["ApptFields"].Copy());
     FillFields();
 }