///<summary>Inserts one EhrPatient into the database. Returns the new priKey.</summary> public static long Insert(EhrPatient ehrPatient) { if (DataConnection.DBtype == DatabaseType.Oracle) { ehrPatient.PatNum = DbHelper.GetNextOracleKey("ehrpatient", "PatNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(ehrPatient, true)); } catch (Oracle.ManagedDataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { ehrPatient.PatNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(ehrPatient, false)); } }
///<summary>Inserts one EhrPatient into the database. Provides option to use the existing priKey.</summary> public static long Insert(EhrPatient ehrPatient, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { ehrPatient.PatNum = ReplicationServers.GetKey("ehrpatient", "PatNum"); } string command = "INSERT INTO ehrpatient ("; if (useExistingPK || PrefC.RandomKeys) { command += "PatNum,"; } command += "MotherMaidenFname,MotherMaidenLname,VacShareOk) VALUES("; if (useExistingPK || PrefC.RandomKeys) { command += POut.Long(ehrPatient.PatNum) + ","; } command += "'" + POut.String(ehrPatient.MotherMaidenFname) + "'," + "'" + POut.String(ehrPatient.MotherMaidenLname) + "'," + POut.Int((int)ehrPatient.VacShareOk) + ")"; if (useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { ehrPatient.PatNum = Db.NonQ(command, true); } return(ehrPatient.PatNum); }
///<summary>Updates one EhrPatient in the database.</summary> public static void Update(EhrPatient ehrPatient) { string command = "UPDATE ehrpatient SET " + "MotherMaidenFname= '" + POut.String(ehrPatient.MotherMaidenFname) + "', " + "MotherMaidenLname= '" + POut.String(ehrPatient.MotherMaidenLname) + "', " + "VacShareOk = " + POut.Int((int)ehrPatient.VacShareOk) + " " + "WHERE PatNum = " + POut.Long(ehrPatient.PatNum); Db.NonQ(command); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List<EhrPatient> TableToList(DataTable table){ List<EhrPatient> retVal=new List<EhrPatient>(); EhrPatient ehrPatient; for(int i=0;i<table.Rows.Count;i++) { ehrPatient=new EhrPatient(); ehrPatient.PatNum = PIn.Long (table.Rows[i]["PatNum"].ToString()); ehrPatient.MotherMaidenFname= PIn.String(table.Rows[i]["MotherMaidenFname"].ToString()); ehrPatient.MotherMaidenLname= PIn.String(table.Rows[i]["MotherMaidenLname"].ToString()); ehrPatient.VacShareOk = (OpenDentBusiness.YN)PIn.Int(table.Rows[i]["VacShareOk"].ToString()); retVal.Add(ehrPatient); } return retVal; }
///<summary>Updates one EhrPatient in the database.</summary> public static void Update(EhrPatient ehrPatient) { string command = "UPDATE ehrpatient SET " + "MotherMaidenFname = '" + POut.String(ehrPatient.MotherMaidenFname) + "', " + "MotherMaidenLname = '" + POut.String(ehrPatient.MotherMaidenLname) + "', " + "VacShareOk = " + POut.Int((int)ehrPatient.VacShareOk) + ", " + "MedicaidState = '" + POut.String(ehrPatient.MedicaidState) + "', " + "SexualOrientation = '" + POut.String(ehrPatient.SexualOrientation) + "', " + "GenderIdentity = '" + POut.String(ehrPatient.GenderIdentity) + "', " + "SexualOrientationNote= '" + POut.String(ehrPatient.SexualOrientationNote) + "', " + "GenderIdentityNote = '" + POut.String(ehrPatient.GenderIdentityNote) + "' " + "WHERE PatNum = " + POut.Long(ehrPatient.PatNum); Db.NonQ(command); }
///<summary>Inserts one EhrPatient into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EhrPatient ehrPatient) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(ehrPatient, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { ehrPatient.PatNum = DbHelper.GetNextOracleKey("ehrpatient", "PatNum"); //Cacheless method } return(InsertNoCache(ehrPatient, true)); } }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <EhrPatient> TableToList(DataTable table) { List <EhrPatient> retVal = new List <EhrPatient>(); EhrPatient ehrPatient; for (int i = 0; i < table.Rows.Count; i++) { ehrPatient = new EhrPatient(); ehrPatient.PatNum = PIn.Long(table.Rows[i]["PatNum"].ToString()); ehrPatient.MotherMaidenFname = PIn.String(table.Rows[i]["MotherMaidenFname"].ToString()); ehrPatient.MotherMaidenLname = PIn.String(table.Rows[i]["MotherMaidenLname"].ToString()); ehrPatient.VacShareOk = (YN)PIn.Int(table.Rows[i]["VacShareOk"].ToString()); retVal.Add(ehrPatient); } return(retVal); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <EhrPatient> TableToList(DataTable table) { List <EhrPatient> retVal = new List <EhrPatient>(); EhrPatient ehrPatient; foreach (DataRow row in table.Rows) { ehrPatient = new EhrPatient(); ehrPatient.PatNum = PIn.Long(row["PatNum"].ToString()); ehrPatient.MotherMaidenFname = PIn.String(row["MotherMaidenFname"].ToString()); ehrPatient.MotherMaidenLname = PIn.String(row["MotherMaidenLname"].ToString()); ehrPatient.VacShareOk = (OpenDentBusiness.YN)PIn.Int(row["VacShareOk"].ToString()); ehrPatient.MedicaidState = PIn.String(row["MedicaidState"].ToString()); ehrPatient.SexualOrientation = PIn.String(row["SexualOrientation"].ToString()); ehrPatient.GenderIdentity = PIn.String(row["GenderIdentity"].ToString()); ehrPatient.SexualOrientationNote = PIn.String(row["SexualOrientationNote"].ToString()); ehrPatient.GenderIdentityNote = PIn.String(row["GenderIdentityNote"].ToString()); retVal.Add(ehrPatient); } return(retVal); }
///<summary>Inserts one EhrPatient into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EhrPatient ehrPatient, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO ehrpatient ("; if (!useExistingPK && isRandomKeys) { ehrPatient.PatNum = ReplicationServers.GetKeyNoCache("ehrpatient", "PatNum"); } if (isRandomKeys || useExistingPK) { command += "PatNum,"; } command += "MotherMaidenFname,MotherMaidenLname,VacShareOk,MedicaidState,SexualOrientation,GenderIdentity,SexualOrientationNote,GenderIdentityNote) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(ehrPatient.PatNum) + ","; } command += "'" + POut.String(ehrPatient.MotherMaidenFname) + "'," + "'" + POut.String(ehrPatient.MotherMaidenLname) + "'," + POut.Int((int)ehrPatient.VacShareOk) + "," + "'" + POut.String(ehrPatient.MedicaidState) + "'," + "'" + POut.String(ehrPatient.SexualOrientation) + "'," + "'" + POut.String(ehrPatient.GenderIdentity) + "'," + "'" + POut.String(ehrPatient.SexualOrientationNote) + "'," + "'" + POut.String(ehrPatient.GenderIdentityNote) + "')"; if (useExistingPK || isRandomKeys) { Db.NonQ(command); } else { ehrPatient.PatNum = Db.NonQ(command, true, "PatNum", "ehrPatient"); } return(ehrPatient.PatNum); }
///<summary>Returns true if Update(EhrPatient,EhrPatient) would make changes to the database. ///Does not make any changes to the database and can be called before remoting role is checked.</summary> public static bool UpdateComparison(EhrPatient ehrPatient, EhrPatient oldEhrPatient) { if (ehrPatient.MotherMaidenFname != oldEhrPatient.MotherMaidenFname) { return(true); } if (ehrPatient.MotherMaidenLname != oldEhrPatient.MotherMaidenLname) { return(true); } if (ehrPatient.VacShareOk != oldEhrPatient.VacShareOk) { return(true); } if (ehrPatient.MedicaidState != oldEhrPatient.MedicaidState) { return(true); } if (ehrPatient.SexualOrientation != oldEhrPatient.SexualOrientation) { return(true); } if (ehrPatient.GenderIdentity != oldEhrPatient.GenderIdentity) { return(true); } if (ehrPatient.SexualOrientationNote != oldEhrPatient.SexualOrientationNote) { return(true); } if (ehrPatient.GenderIdentityNote != oldEhrPatient.GenderIdentityNote) { return(true); } return(false); }
///<summary>Updates one EhrPatient in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables.</summary> public static void Update(EhrPatient ehrPatient, EhrPatient oldEhrPatient) { string command = ""; if (ehrPatient.MotherMaidenFname != oldEhrPatient.MotherMaidenFname) { if (command != "") { command += ","; } command += "MotherMaidenFname = '" + POut.String(ehrPatient.MotherMaidenFname) + "'"; } if (ehrPatient.MotherMaidenLname != oldEhrPatient.MotherMaidenLname) { if (command != "") { command += ","; } command += "MotherMaidenLname = '" + POut.String(ehrPatient.MotherMaidenLname) + "'"; } if (ehrPatient.VacShareOk != oldEhrPatient.VacShareOk) { if (command != "") { command += ","; } command += "VacShareOk = " + POut.Int((int)ehrPatient.VacShareOk) + ""; } if (command == "") { return; } command = "UPDATE ehrpatient SET " + command + " WHERE PatNum = " + POut.Long(ehrPatient.PatNum); Db.NonQ(command); }
///<summary>Inserts one EhrPatient into the database. Provides option to use the existing priKey.</summary> public static long Insert(EhrPatient ehrPatient,bool useExistingPK){ if(!useExistingPK && PrefC.RandomKeys) { ehrPatient.PatNum=ReplicationServers.GetKey("ehrpatient","PatNum"); } string command="INSERT INTO ehrpatient ("; if(useExistingPK || PrefC.RandomKeys) { command+="PatNum,"; } command+="MotherMaidenFname,MotherMaidenLname,VacShareOk) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(ehrPatient.PatNum)+","; } command+= "'"+POut.String(ehrPatient.MotherMaidenFname)+"'," +"'"+POut.String(ehrPatient.MotherMaidenLname)+"'," + POut.Int ((int)ehrPatient.VacShareOk)+")"; if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { ehrPatient.PatNum=Db.NonQ(command,true); } return ehrPatient.PatNum; }
///<summary>Inserts one EhrPatient into the database. Returns the new priKey.</summary> public static long Insert(EhrPatient ehrPatient){ if(DataConnection.DBtype==DatabaseType.Oracle) { ehrPatient.PatNum=DbHelper.GetNextOracleKey("ehrpatient","PatNum"); int loopcount=0; while(loopcount<100){ try { return Insert(ehrPatient,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ ehrPatient.PatNum++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(ehrPatient,false); } }
///<summary>Updates one EhrPatient in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(EhrPatient ehrPatient, EhrPatient oldEhrPatient) { string command = ""; if (ehrPatient.MotherMaidenFname != oldEhrPatient.MotherMaidenFname) { if (command != "") { command += ","; } command += "MotherMaidenFname = '" + POut.String(ehrPatient.MotherMaidenFname) + "'"; } if (ehrPatient.MotherMaidenLname != oldEhrPatient.MotherMaidenLname) { if (command != "") { command += ","; } command += "MotherMaidenLname = '" + POut.String(ehrPatient.MotherMaidenLname) + "'"; } if (ehrPatient.VacShareOk != oldEhrPatient.VacShareOk) { if (command != "") { command += ","; } command += "VacShareOk = " + POut.Int((int)ehrPatient.VacShareOk) + ""; } if (ehrPatient.MedicaidState != oldEhrPatient.MedicaidState) { if (command != "") { command += ","; } command += "MedicaidState = '" + POut.String(ehrPatient.MedicaidState) + "'"; } if (ehrPatient.SexualOrientation != oldEhrPatient.SexualOrientation) { if (command != "") { command += ","; } command += "SexualOrientation = '" + POut.String(ehrPatient.SexualOrientation) + "'"; } if (ehrPatient.GenderIdentity != oldEhrPatient.GenderIdentity) { if (command != "") { command += ","; } command += "GenderIdentity = '" + POut.String(ehrPatient.GenderIdentity) + "'"; } if (ehrPatient.SexualOrientationNote != oldEhrPatient.SexualOrientationNote) { if (command != "") { command += ","; } command += "SexualOrientationNote = '" + POut.String(ehrPatient.SexualOrientationNote) + "'"; } if (ehrPatient.GenderIdentityNote != oldEhrPatient.GenderIdentityNote) { if (command != "") { command += ","; } command += "GenderIdentityNote = '" + POut.String(ehrPatient.GenderIdentityNote) + "'"; } if (command == "") { return(false); } command = "UPDATE ehrpatient SET " + command + " WHERE PatNum = " + POut.Long(ehrPatient.PatNum); Db.NonQ(command); return(true); }
///<summary>Inserts one EhrPatient into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EhrPatient ehrPatient) { return(InsertNoCache(ehrPatient, false)); }
///<summary>Updates one EhrPatient in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(EhrPatient ehrPatient,EhrPatient oldEhrPatient){ string command=""; if(ehrPatient.MotherMaidenFname != oldEhrPatient.MotherMaidenFname) { if(command!=""){ command+=",";} command+="MotherMaidenFname = '"+POut.String(ehrPatient.MotherMaidenFname)+"'"; } if(ehrPatient.MotherMaidenLname != oldEhrPatient.MotherMaidenLname) { if(command!=""){ command+=",";} command+="MotherMaidenLname = '"+POut.String(ehrPatient.MotherMaidenLname)+"'"; } if(ehrPatient.VacShareOk != oldEhrPatient.VacShareOk) { if(command!=""){ command+=",";} command+="VacShareOk = "+POut.Int ((int)ehrPatient.VacShareOk)+""; } if(command==""){ return false; } command="UPDATE ehrpatient SET "+command +" WHERE PatNum = "+POut.Long(ehrPatient.PatNum); Db.NonQ(command); return true; }
///<summary>Updates one EhrPatient in the database.</summary> public static void Update(EhrPatient ehrPatient){ string command="UPDATE ehrpatient SET " +"MotherMaidenFname= '"+POut.String(ehrPatient.MotherMaidenFname)+"', " +"MotherMaidenLname= '"+POut.String(ehrPatient.MotherMaidenLname)+"', " +"VacShareOk = "+POut.Int ((int)ehrPatient.VacShareOk)+" " +"WHERE PatNum = "+POut.Long(ehrPatient.PatNum); Db.NonQ(command); }
private void FormVaccines_Load(object sender, EventArgs e) { FillGridVaccine(); _ehrPatientCur = EhrPatients.Refresh(PatCur.PatNum); listVacShareOk.SelectedIndex = (int)_ehrPatientCur.VacShareOk; }