Пример #1
0
		//private void button1_Click(object sender,EventArgs e) {
		//	Random rand=new Random();
		//	FormCDSIntervention FormCDSI=new FormCDSIntervention();
		//	FormCDSI.DictEhrTriggerResults=EhrTriggers.TriggerMatch(ICD9s.GetOne(rand.Next(8000)),Patients.GetPat(1));
		//	FormCDSI.ShowIfRequired();
		//	if(FormCDSI.DialogResult==DialogResult.Cancel) {//using ==DialogResult.Cancel instead of !=DialogResult.OK
		//		MsgBox.Show(this,"You have disarmed the nuke.");
		//		return;//effectively canceling the action.
		//	}
		//	MsgBox.Show(this,"Yay, you did it.");
		//	//stuff you might do, like prescribe meds or diagnose problem.
		//}

//		private void butICD9CM31_Click(object sender,EventArgs e) {
//			if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"This button does not perform error checking and only works from Ryan's computer.")) {
//				return;
//			}
//			Cursor=Cursors.WaitCursor;
//			try {
//				//Import ICD9-CM DX codes with long description----------------------------------------------------------------------------------------------------------
//				MsgBox.Show(this,"Importing ICD9-CM DX codes with long description.");
//				System.IO.StreamReader sr=new System.IO.StreamReader(@"C:\Users\Ryan\Desktop\ICD9CM31\DXL.txt");
//				string command=@"DROP TABLE IF EXISTS ICD9CMDX";
//				DataCore.NonQ(command);
//				command=@"CREATE TABLE `ICD9CMDX` (
//									`ICD9CMDXNum` BIGINT(20) NOT NULL AUTO_INCREMENT,
//									`CodeString` VARCHAR(255) DEFAULT '',
//									`DescriptionLong` VARCHAR(255) DEFAULT '',
//									`DescriptionShort` VARCHAR(255) DEFAULT '',
//									INDEX(CodeString),
//									PRIMARY KEY (`ICD9CMDXNum`)
//									) DEFAULT CHARSET=utf8;";
//				DataCore.NonQ(command);
//				string[] arrayICD9CM=new string[2];
//				string line="";
//				while(!sr.EndOfStream) {//each loop should read exactly one line of code.
//					line=sr.ReadLine();
//					arrayICD9CM[0]=line.Substring(0,5).Trim();//fixed width column
//					if(arrayICD9CM[0].Length>3){
//						arrayICD9CM[0]=arrayICD9CM[0].Substring(0,3)+"."+arrayICD9CM[0].Substring(3);
//					}
//					arrayICD9CM[1]=line.Substring(6);
//					command="INSERT INTO ICD9CMDX (CodeString,DescriptionLong) VALUES ('"+POut.String(arrayICD9CM[0])+"','"+POut.String(arrayICD9CM[1])+"')";
//					DataCore.NonQ(command);
//				}
//				//Import ICD9-CM DX codes with short description----------------------------------------------------------------------------------------------------------
//				MsgBox.Show(this,"Importing ICD9-CM DX codes with short description.");
//				sr.Dispose();
//				sr=new System.IO.StreamReader(@"C:\Users\Ryan\Desktop\ICD9CM31\DXS.txt");
//				while(!sr.EndOfStream) {//each loop should read exactly one line of code.
//					line=sr.ReadLine();
//					arrayICD9CM[0]=line.Substring(0,5).Trim();//fixed width column
//					if(arrayICD9CM[0].Length>3) {
//						arrayICD9CM[0]=arrayICD9CM[0].Substring(0,3)+"."+arrayICD9CM[0].Substring(3);
//					}
//					arrayICD9CM[1]=line.Substring(6);
//					command="UPDATE ICD9CMDX SET DescriptionShort='"+POut.String(arrayICD9CM[1])+"' WHERE CodeString='"+POut.String(arrayICD9CM[0])+"'";
//					DataCore.NonQ(command);
//				}
//				//Import ICD9-CM SG codes with long description----------------------------------------------------------------------------------------------------------
//				MsgBox.Show(this,"Importing ICD9-CM SG codes with long description.");
//				sr.Dispose();
//				sr=new System.IO.StreamReader(@"C:\Users\Ryan\Desktop\ICD9CM31\SGL.txt");
//				command=@"DROP TABLE IF EXISTS ICD9CMSG";
//				DataCore.NonQ(command);
//				command=@"CREATE TABLE `ICD9CMSG` (
//									`ICD9CMSGNum` BIGINT(20) NOT NULL AUTO_INCREMENT,
//									`CodeString` VARCHAR(255) DEFAULT '',
//									`DescriptionLong` VARCHAR(255) DEFAULT '',
//									`DescriptionShort` VARCHAR(255) DEFAULT '',
//									INDEX(CodeString),
//									PRIMARY KEY (`ICD9CMSGNum`)
//									) DEFAULT CHARSET=utf8;";
//				DataCore.NonQ(command);
//				while(!sr.EndOfStream) {//each loop should read exactly one line of code.
//					line=sr.ReadLine();
//					arrayICD9CM[0]=line.Substring(0,5).Trim();//fixed width column
//					if(arrayICD9CM[0].Length>2) {
//						arrayICD9CM[0]=arrayICD9CM[0].Substring(0,2)+"."+arrayICD9CM[0].Substring(2);
//					}
//					arrayICD9CM[1]=line.Substring(5);
//					command="INSERT INTO ICD9CMSG (CodeString,DescriptionLong) VALUES ('"+POut.String(arrayICD9CM[0])+"','"+POut.String(arrayICD9CM[1])+"')";
//					DataCore.NonQ(command);
//				}
//				//Import ICD9-CM SG codes with short description----------------------------------------------------------------------------------------------------------
//				MsgBox.Show(this,"Importing ICD9-CM SG codes with short description.");
//				sr.Dispose();
//				sr=new System.IO.StreamReader(@"C:\Users\Ryan\Desktop\ICD9CM31\SGS.txt");
//				while(!sr.EndOfStream) {//each loop should read exactly one line of code.
//					line=sr.ReadLine();
//					arrayICD9CM[0]=line.Substring(0,5).Trim();//fixed width column
//					if(arrayICD9CM[0].Length>2) {
//						arrayICD9CM[0]=arrayICD9CM[0].Substring(0,2)+"."+arrayICD9CM[0].Substring(2);
//					}
//					arrayICD9CM[1]=line.Substring(5);
//					command="UPDATE ICD9CMSG SET DescriptionShort='"+POut.String(arrayICD9CM[1])+"' WHERE CodeString='"+POut.String(arrayICD9CM[0])+"'";
//					DataCore.NonQ(command);
//				}
//			}
//			catch(Exception ex) {
//				MessageBox.Show(this,Lan.g(this,"Error importing ICD9CM codes:")+"\r\n"+ex.Message);
//			}
//			Cursor=Cursors.Default;
//		}

		private void butTimeSynch_Click(object sender,EventArgs e) {
			FormEhrTimeSynch formET = new FormEhrTimeSynch();
			formET.ShowDialog();
		}
Пример #2
0
        private void butTimeSynch_Click(object sender, EventArgs e)
        {
            FormEhrTimeSynch formET = new FormEhrTimeSynch();

            formET.ShowDialog();
        }
Пример #3
0
		private void FormOpenDental_Load(object sender, System.EventArgs e){
			Splash.Dispose();
			Version versionOd=Assembly.GetAssembly(typeof(FormOpenDental)).GetName().Version;
			Version versionObBus=Assembly.GetAssembly(typeof(Db)).GetName().Version;
			if(versionOd!=versionObBus) {
				MessageBox.Show("Mismatched program file versions. Please run the Open Dental setup file again on this computer.");//No MsgBox or Lan.g() here, because we don't want to access the database if there is a version conflict.
				Application.Exit();
				return;
			}
			allNeutral();
			string odUser="";
			string odPassHash="";
			string webServiceUri="";
			YN webServiceIsEcw=YN.Unknown;
			string odPassword="";
			string serverName="";
			string databaseName="";
			string mySqlUser="";
			string mySqlPassword="";
			if(CommandLineArgs.Length!=0) {
				for(int i=0;i<CommandLineArgs.Length;i++) {
					if(CommandLineArgs[i].StartsWith("UserName="******"');
					}
					if(CommandLineArgs[i].StartsWith("PassHash=") && CommandLineArgs[i].Length>9) {
						odPassHash=CommandLineArgs[i].Substring(9).Trim('"');
					}
					if(CommandLineArgs[i].StartsWith("WebServiceUri=") && CommandLineArgs[i].Length>14) {
						webServiceUri=CommandLineArgs[i].Substring(14).Trim('"');
					}
					if(CommandLineArgs[i].StartsWith("WebServiceIsEcw=") && CommandLineArgs[i].Length>16) {
						if(CommandLineArgs[i].Substring(16).Trim('"')=="True") {
							webServiceIsEcw=YN.Yes;
						}
						else {
							webServiceIsEcw=YN.No;
						}
					}
					if(CommandLineArgs[i].StartsWith("OdPassword="******"');
					}
					if(CommandLineArgs[i].StartsWith("ServerName=") && CommandLineArgs[i].Length>11) {
						serverName=CommandLineArgs[i].Substring(11).Trim('"');
					}
					if(CommandLineArgs[i].StartsWith("DatabaseName=") && CommandLineArgs[i].Length>13) {
						databaseName=CommandLineArgs[i].Substring(13).Trim('"');
					}
					if(CommandLineArgs[i].StartsWith("MySqlUser="******"');
					}
					if(CommandLineArgs[i].StartsWith("MySqlPassword="******"');
					}
				}
			}
			YN noShow=YN.Unknown;
			if(webServiceUri!=""){//a web service was specified
				if(odUser!="" && odPassword!=""){//and both a username and password were specified
					noShow=YN.Yes;
				}
			}
			else if(databaseName!=""){
				noShow=YN.Yes;
			}
			FormChooseDatabase formChooseDb=new FormChooseDatabase();
			formChooseDb.OdUser=odUser;
			formChooseDb.OdPassHash=odPassHash;
			formChooseDb.WebServiceUri=webServiceUri;
			formChooseDb.WebServiceIsEcw=webServiceIsEcw;
			formChooseDb.OdPassword=odPassword;
			formChooseDb.ServerName=serverName;
			formChooseDb.DatabaseName=databaseName;
			formChooseDb.MySqlUser=mySqlUser;
			formChooseDb.MySqlPassword=mySqlPassword;
			formChooseDb.NoShow=noShow;//either unknown or yes
			formChooseDb.GetConfig();
			formChooseDb.GetCmdLine();
			while(true) {//Most users will loop through once.  If user tries to connect to a db with replication failure, they will loop through again.
				if(formChooseDb.NoShow==YN.Yes) {
					if(!formChooseDb.TryToConnect()) {
						formChooseDb.ShowDialog();
						if(formChooseDb.DialogResult==DialogResult.Cancel) {
							Application.Exit();
							return;
						}
					}
				}
				else {
					formChooseDb.ShowDialog();
					if(formChooseDb.DialogResult==DialogResult.Cancel) {
						Application.Exit();
						return;
					}
				}
				Cursor=Cursors.WaitCursor;
				Plugins.LoadAllPlugins(this);//moved up from near RefreshLocalData(invalidTypes). New position might cause problems.
				Splash=new FormSplash();
				if(CommandLineArgs.Length==0) {
					Splash.Show();
				}
				if(!PrefsStartup()){//looks for the AtoZ folder here, but would like to eventually move that down to after login
					Cursor=Cursors.Default;
					Splash.Dispose();
					Application.Exit();
					return;
				}
				if(ReplicationServers.Server_id!=0 && ReplicationServers.Server_id==PrefC.GetInt(PrefName.ReplicationFailureAtServer_id)) {
					MsgBox.Show(this,"This database is temporarily unavailable.  Please connect instead to your alternate database at the other location.");
					formChooseDb.NoShow=YN.No;//This ensures they will get a choose db window next time through the loop.
					ReplicationServers.Server_id=-1;
					continue;
				}
				break;
			}
			if(Programs.UsingEcwTightOrFullMode()) {
				Splash.Dispose();//We don't show splash screen when bridging to eCW.
			}
			//We no longer do this shotgun approach because it can slow the loading time.
			//RefreshLocalData(InvalidType.AllLocal);
			List<InvalidType> invalidTypes=new List<InvalidType>();
			invalidTypes.Add(InvalidType.Prefs);
			invalidTypes.Add(InvalidType.Defs);
			invalidTypes.Add(InvalidType.Providers);//obviously heavily used
			invalidTypes.Add(InvalidType.Programs);//already done above, but needs to be done explicitly to trigger the PostCleanup 
			invalidTypes.Add(InvalidType.ToolBut);//so program buttons will show in all the toolbars
			if(Programs.UsingEcwTightMode()) {
				lightSignalGrid1.Visible=false;
			}
			else{
				invalidTypes.Add(InvalidType.Signals);//so when mouse moves over light buttons, it won't crash
			}
			//Plugins.LoadAllPlugins(this);//moved up from right after optimizing tooth chart graphics.  New position might cause problems.
			//It was moved because RefreshLocalData()=>RefreshLocalDataPostCleanup()=>ContrChart2.InitializeLocalData()=>LayoutToolBar() has a hook.
			//Moved it up again on 10/3/13
			RefreshLocalData(invalidTypes.ToArray());
			FillSignalButtons(null);
			ContrManage2.InitializeOnStartup();//so that when a signal is received, it can handle it.
			//Lan.Refresh();//automatically skips if current culture is en-US
			//LanguageForeigns.Refresh(CultureInfo.CurrentCulture);//automatically skips if current culture is en-US
			DataValid.BecameInvalid += new OpenDental.ValidEventHandler(DataValid_BecameInvalid);
			signalLastRefreshed=MiscData.GetNowDateTime();
			if(PrefC.GetInt(PrefName.ProcessSigsIntervalInSecs)==0) {
				timerSignals.Enabled=false;
			}
			else {
				timerSignals.Interval=PrefC.GetInt(PrefName.ProcessSigsIntervalInSecs)*1000;
				timerSignals.Enabled=true;
			}
			timerTimeIndic.Enabled=true;
			myOutlookBar.Buttons[0].Caption=Lan.g(this,"Appts");
			myOutlookBar.Buttons[1].Caption=Lan.g(this,"Family");
			myOutlookBar.Buttons[2].Caption=Lan.g(this,"Account");
			myOutlookBar.Buttons[3].Caption=Lan.g(this,"Treat' Plan");
			//myOutlookBar.Buttons[4].Caption=Lan.g(this,"Chart");//??done in RefreshLocalData
			myOutlookBar.Buttons[5].Caption=Lan.g(this,"Images");
			myOutlookBar.Buttons[6].Caption=Lan.g(this,"Manage");
			foreach(MenuItem menuItem in mainMenu.MenuItems){
				TranslateMenuItem(menuItem);
			}
			if(CultureInfo.CurrentCulture.Name=="en-US") {
				//for the business layer, this functionality is duplicated in the Lan class.  Need for SL.
				CultureInfo cInfo=(CultureInfo)CultureInfo.CurrentCulture.Clone();
				cInfo.DateTimeFormat.ShortDatePattern="MM/dd/yyyy";
				Application.CurrentCulture=cInfo;
				//
				//if(CultureInfo.CurrentCulture.TwoLetterISOLanguageName=="en"){
				menuItemTranslation.Visible=false;
			}
			else {//not en-US
				CultureInfo cInfo=(CultureInfo)CultureInfo.CurrentCulture.Clone();
				string dateFormatCur=cInfo.DateTimeFormat.ShortDatePattern;
				//The carrot indicates the beginning of a word.  {2} means that there has to be exactly 2 y's.  [^a-z] means any character except a through z.  $ means end of word.
				if(Regex.IsMatch(dateFormatCur,"^y{2}[^a-z]")
					|| Regex.IsMatch(dateFormatCur,"[^a-z]y{2}$")) 
				{
					//We know there are only two y's in the format.  Force there to be four.
					cInfo.DateTimeFormat.ShortDatePattern=dateFormatCur.Replace("yy","yyyy");
					Application.CurrentCulture=cInfo;
				}
			}
			if(!File.Exists("Help.chm")){
				menuItemHelpWindows.Visible=false;
			}
			if(Environment.OSVersion.Platform==PlatformID.Unix){//Create A to Z unsupported on Unix for now.
				menuItemCreateAtoZFolders.Visible=false;
			}
			if(!PrefC.GetBool(PrefName.ProcLockingIsAllowed)) {
				menuItemProcLockTool.Visible=false;
			}
			if(!PrefC.GetBool(PrefName.ADAdescriptionsReset)) {
				ProcedureCodes.ResetADAdescriptions();
				Prefs.UpdateBool(PrefName.ADAdescriptionsReset,true);
			}
			Splash.Dispose();
			//Choose a default DirectX format when no DirectX format has been specified and running in DirectX tooth chart mode.
			//ComputerPref localComputerPrefs=ComputerPrefs.GetForLocalComputer();
			if(ComputerPrefs.LocalComputer.GraphicsSimple==DrawingMode.DirectX && ComputerPrefs.LocalComputer.DirectXFormat=="") {
				//MessageBox.Show(Lan.g(this,"Optimizing tooth chart graphics. This may take a few minutes. You will be notified when the process is complete."));
				ComputerPrefs.LocalComputer.DirectXFormat=FormGraphics.GetPreferredDirectXFormat(this);
				if(ComputerPrefs.LocalComputer.DirectXFormat=="invalid") {
					//No valid local DirectX format could be found.
					//Simply revert to OpenGL.
					ComputerPrefs.LocalComputer.GraphicsSimple=DrawingMode.Simple2D;
				}
				ComputerPrefs.Update(ComputerPrefs.LocalComputer);
				ContrChart2.InitializeOnStartup();
				//MsgBox.Show(this,"Done optimizing tooth chart graphics.");
			}
			if(ODEnvironment.IsRunningOnDbServer(MiscData.GetODServer()) && PrefC.GetBool(PrefName.ShowFeatureEhr)) {//OpenDental has EHR enabled and is running on the same machine as the mysql server it is connected to.*/
				_threadTimeSynch=new Thread(new ThreadStart(ThreadTimeSynch_Synch));
				_threadTimeSynch.Start();
			}
			if(Security.CurUser==null) {//It could already be set if using web service because login from ChooseDatabase window.
				if(Programs.UsingEcwTightOrFullMode() && odUser!="") {//only leave it null if a user was passed in on the commandline.  If starting OD manually, it will jump into the else.
					//leave user as null
				}
				else {
					if(odUser!="" && odPassword!=""){//if a username and password were passed in
						//Userod user=Userods.GetUserByName(odUser,Programs.UsingEcwTight());
						Userod user=Userods.GetUserByName(odUser,Programs.UsingEcwTightOrFullMode());
						if(user!=null){
							if(Userods.CheckTypedPassword(odPassword,user.Password)){//password matches
								Security.CurUser=user.Copy();
								if(RemotingClient.RemotingRole==RemotingRole.ClientWeb){
									string pw=odPassword;
									//if(Programs.UsingEcwTight()) {//ecw requires hash, but non-ecw requires actual password
									if(Programs.UsingEcwTightOrFullMode()) {//ecw requires hash, but non-ecw requires actual password
										pw=Userods.EncryptPassword(pw,true);
									}
									Security.PasswordTyped=pw;
								}
								//TasksCheckOnStartup is one thing that doesn't get done because login window wasn't used
							}
						}
					}
					if(Security.CurUser==null) {//normal manual log in process
						Userod adminUser=Userods.GetAdminUser();
						if(adminUser.Password=="") {
							Security.CurUser=adminUser.Copy();
						}
						else {
							FormLogOn_=new FormLogOn();
							FormLogOn_.ShowDialog(this);
							if(FormLogOn_.DialogResult==DialogResult.Cancel) {
								Cursor=Cursors.Default;
								Application.Exit();
								return;
							}
						}
					}
				}
			}
			if(userControlTasks1.Visible) {
				userControlTasks1.InitializeOnStartup();
			}
			myOutlookBar.SelectedIndex=Security.GetModule(0);//for eCW, this fails silently.
			//if(Programs.UsingEcwTight()) {
			if(Programs.UsingEcwTightOrFullMode()
				|| (HL7Defs.IsExistingHL7Enabled() && !HL7Defs.GetOneDeepEnabled().ShowAppts)) {
				myOutlookBar.SelectedIndex=4;//Chart module
				//ToolBarMain.Height=0;//this should force the modules further up on the screen
				//ToolBarMain.Visible=false;
				LayoutControls();
			}
			if(Programs.UsingOrion) {
				myOutlookBar.SelectedIndex=1;//Family module
			}
			myOutlookBar.Invalidate();
			LayoutToolBar();
			SetModuleSelected();
			Cursor=Cursors.Default;
			if(myOutlookBar.SelectedIndex==-1){
				MsgBox.Show(this,"You do not have permission to use any modules.");
			}
			Bridges.Trojan.StartupCheck();
			FormUAppoint.StartThreadIfEnabled();
			Bridges.ICat.StartFileWatcher();
			if(PrefC.GetBool(PrefName.DockPhonePanelShow)) {
				menuItemResellers.Visible=true;
				#if !DEBUG
					if(Process.GetProcessesByName("WebCamOD").Length==0) {
						try {
							Process.Start("WebCamOD.exe");
						}
						catch { }//for example, if working from home.
					}
				#endif
				ThreadVM=new Thread(new ThreadStart(this.ThreadVM_SetLabelMsg));
				ThreadVM.Start();//It's done this way because the file activity tends to lock the UI on slow connections.
				FillTriageLabels();
			}
			#if !TRIALONLY
				if(PrefC.GetDate(PrefName.BackupReminderLastDateRun).AddMonths(1)<DateTime.Today) {
					FormBackupReminder FormBR=new FormBackupReminder();
					FormBR.ShowDialog();
					if(FormBR.DialogResult==DialogResult.OK){
						Prefs.UpdateDateT(PrefName.BackupReminderLastDateRun,DateTimeOD.Today);
					}
					else{
						Application.Exit();
						return;
					}
				}
				if(PrefC.GetBool(PrefName.ShowFeatureEhr) && !_isTimeSynchThreadRunning) {
					FormEhrTimeSynch FormEhrTS = new FormEhrTimeSynch();
					FormEhrTS.IsAutoLaunch=true;
					if(!FormEhrTS.TimesInSynchFast()) {
						FormEhrTS.ShowDialog();
					}
				}
			#endif
			FillPatientButton(null);
			ThreadCommandLine=new Thread(new ThreadStart(Listen));
			if(!IsSecondInstance) {//can't use a port that's already in use.
				//js We can't do this yet.  I tried it already, and it consumes nearly 100% CPU.  Not while testing, but later.
				//So until we really need to do it, it's easiest no just not start the thread for now.
				//ThreadCommandLine.Start();
			}
			//if(CommandLineArgs.Length>0) {
			ProcessCommandLine(CommandLineArgs);
			//}
			try {
				Computers.UpdateHeartBeat(Environment.MachineName,true);
			}
			catch { }
			//string dllPathEHR=ODFileUtils.CombinePaths(Application.StartupPath,"EHR.dll");
			//if(PrefC.GetBoolSilent(PrefName.ShowFeatureEhr,false)) {
			//	#if EHRTEST
			//		FormEHR=new FormEHR();
			//		ContrChart2.InitializeLocalData();//because toolbar is now missing the EHR button.  Only a problem if a db conversion is done when opening the program.
			//	#else
			//		ObjFormEhrMeasures=null;
			//		AssemblyEHR=null;
			//		if(File.Exists(dllPathEHR)) {//EHR.dll is available, so load it up
			//			AssemblyEHR=Assembly.LoadFile(dllPathEHR);
			//			Type type=AssemblyEHR.GetType("EHR.FormEHR");//namespace.class
			//			ObjFormEhrMeasures=Activator.CreateInstance(type);
			//		}
			//	#endif
			//}
			dateTimeLastActivity=DateTime.Now;
			timerLogoff.Enabled=true;
			timerReplicationMonitor.Enabled=true;
			ThreadEmailInbox=new Thread(new ThreadStart(ThreadEmailInbox_Receive));
			ThreadEmailInbox.Start();
			Plugins.HookAddCode(this,"FormOpenDental.Load_end");
		}