///<summary>Inserts one EhrNotPerformed into the database. Returns the new priKey.</summary> public static long Insert(EhrNotPerformed ehrNotPerformed) { if (DataConnection.DBtype == DatabaseType.Oracle) { ehrNotPerformed.EhrNotPerformedNum = DbHelper.GetNextOracleKey("ehrnotperformed", "EhrNotPerformedNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(ehrNotPerformed, true)); } catch (Oracle.DataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { ehrNotPerformed.EhrNotPerformedNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(ehrNotPerformed, false)); } }
///<summary>Updates one EhrNotPerformed in the database.</summary> public static void Update(EhrNotPerformed ehrNotPerformed) { string command = "UPDATE ehrnotperformed SET " + "PatNum = " + POut.Long(ehrNotPerformed.PatNum) + ", " + "ProvNum = " + POut.Long(ehrNotPerformed.ProvNum) + ", " + "CodeValue = '" + POut.String(ehrNotPerformed.CodeValue) + "', " + "CodeSystem = '" + POut.String(ehrNotPerformed.CodeSystem) + "', " + "CodeValueReason = '" + POut.String(ehrNotPerformed.CodeValueReason) + "', " + "CodeSystemReason = '" + POut.String(ehrNotPerformed.CodeSystemReason) + "', " + "Note = '" + POut.String(ehrNotPerformed.Note) + "', " + "DateEntry = " + POut.Date(ehrNotPerformed.DateEntry) + " " + "WHERE EhrNotPerformedNum = " + POut.Long(ehrNotPerformed.EhrNotPerformedNum); Db.NonQ(command); }
///<summary>Inserts one EhrNotPerformed into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EhrNotPerformed ehrNotPerformed) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(ehrNotPerformed, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { ehrNotPerformed.EhrNotPerformedNum = DbHelper.GetNextOracleKey("ehrnotperformed", "EhrNotPerformedNum"); //Cacheless method } return(InsertNoCache(ehrNotPerformed, true)); } }
///<summary>Converts a DataTable to a list of objects.</summary> public static List<EhrNotPerformed> TableToList(DataTable table){ List<EhrNotPerformed> retVal=new List<EhrNotPerformed>(); EhrNotPerformed ehrNotPerformed; for(int i=0;i<table.Rows.Count;i++) { ehrNotPerformed=new EhrNotPerformed(); ehrNotPerformed.EhrNotPerformedNum= PIn.Long (table.Rows[i]["EhrNotPerformedNum"].ToString()); ehrNotPerformed.PatNum = PIn.Long (table.Rows[i]["PatNum"].ToString()); ehrNotPerformed.ProvNum = PIn.Long (table.Rows[i]["ProvNum"].ToString()); ehrNotPerformed.CodeValue = PIn.String(table.Rows[i]["CodeValue"].ToString()); ehrNotPerformed.CodeSystem = PIn.String(table.Rows[i]["CodeSystem"].ToString()); ehrNotPerformed.CodeValueReason = PIn.String(table.Rows[i]["CodeValueReason"].ToString()); ehrNotPerformed.CodeSystemReason = PIn.String(table.Rows[i]["CodeSystemReason"].ToString()); ehrNotPerformed.Note = PIn.String(table.Rows[i]["Note"].ToString()); ehrNotPerformed.DateEntry = PIn.Date (table.Rows[i]["DateEntry"].ToString()); retVal.Add(ehrNotPerformed); } return retVal; }
///<summary>Inserts one EhrNotPerformed into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EhrNotPerformed ehrNotPerformed, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO ehrnotperformed ("; if (!useExistingPK && isRandomKeys) { ehrNotPerformed.EhrNotPerformedNum = ReplicationServers.GetKeyNoCache("ehrnotperformed", "EhrNotPerformedNum"); } if (isRandomKeys || useExistingPK) { command += "EhrNotPerformedNum,"; } command += "PatNum,ProvNum,CodeValue,CodeSystem,CodeValueReason,CodeSystemReason,Note,DateEntry) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(ehrNotPerformed.EhrNotPerformedNum) + ","; } command += POut.Long(ehrNotPerformed.PatNum) + "," + POut.Long(ehrNotPerformed.ProvNum) + "," + "'" + POut.String(ehrNotPerformed.CodeValue) + "'," + "'" + POut.String(ehrNotPerformed.CodeSystem) + "'," + "'" + POut.String(ehrNotPerformed.CodeValueReason) + "'," + "'" + POut.String(ehrNotPerformed.CodeSystemReason) + "'," + DbHelper.ParamChar + "paramNote," + POut.Date(ehrNotPerformed.DateEntry) + ")"; if (ehrNotPerformed.Note == null) { ehrNotPerformed.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(ehrNotPerformed.Note)); if (useExistingPK || isRandomKeys) { Db.NonQ(command, paramNote); } else { ehrNotPerformed.EhrNotPerformedNum = Db.NonQ(command, true, "EhrNotPerformedNum", "ehrNotPerformed", paramNote); } return(ehrNotPerformed.EhrNotPerformedNum); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <EhrNotPerformed> TableToList(DataTable table) { List <EhrNotPerformed> retVal = new List <EhrNotPerformed>(); EhrNotPerformed ehrNotPerformed; for (int i = 0; i < table.Rows.Count; i++) { ehrNotPerformed = new EhrNotPerformed(); ehrNotPerformed.EhrNotPerformedNum = PIn.Long(table.Rows[i]["EhrNotPerformedNum"].ToString()); ehrNotPerformed.PatNum = PIn.Long(table.Rows[i]["PatNum"].ToString()); ehrNotPerformed.ProvNum = PIn.Long(table.Rows[i]["ProvNum"].ToString()); ehrNotPerformed.CodeValue = PIn.String(table.Rows[i]["CodeValue"].ToString()); ehrNotPerformed.CodeSystem = PIn.String(table.Rows[i]["CodeSystem"].ToString()); ehrNotPerformed.CodeValueReason = PIn.String(table.Rows[i]["CodeValueReason"].ToString()); ehrNotPerformed.CodeSystemReason = PIn.String(table.Rows[i]["CodeSystemReason"].ToString()); ehrNotPerformed.Note = PIn.String(table.Rows[i]["Note"].ToString()); ehrNotPerformed.DateEntry = PIn.Date(table.Rows[i]["DateEntry"].ToString()); retVal.Add(ehrNotPerformed); } return(retVal); }
///<summary>Updates one EhrNotPerformed in the database.</summary> public static void Update(EhrNotPerformed ehrNotPerformed) { string command = "UPDATE ehrnotperformed SET " + "PatNum = " + POut.Long(ehrNotPerformed.PatNum) + ", " + "ProvNum = " + POut.Long(ehrNotPerformed.ProvNum) + ", " + "CodeValue = '" + POut.String(ehrNotPerformed.CodeValue) + "', " + "CodeSystem = '" + POut.String(ehrNotPerformed.CodeSystem) + "', " + "CodeValueReason = '" + POut.String(ehrNotPerformed.CodeValueReason) + "', " + "CodeSystemReason = '" + POut.String(ehrNotPerformed.CodeSystemReason) + "', " + "Note = " + DbHelper.ParamChar + "paramNote, " + "DateEntry = " + POut.Date(ehrNotPerformed.DateEntry) + " " + "WHERE EhrNotPerformedNum = " + POut.Long(ehrNotPerformed.EhrNotPerformedNum); if (ehrNotPerformed.Note == null) { ehrNotPerformed.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(ehrNotPerformed.Note)); Db.NonQ(command, paramNote); }
///<summary>Inserts one EhrNotPerformed into the database. Returns the new priKey.</summary> public static long Insert(EhrNotPerformed ehrNotPerformed){ if(DataConnection.DBtype==DatabaseType.Oracle) { ehrNotPerformed.EhrNotPerformedNum=DbHelper.GetNextOracleKey("ehrnotperformed","EhrNotPerformedNum"); int loopcount=0; while(loopcount<100){ try { return Insert(ehrNotPerformed,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ ehrNotPerformed.EhrNotPerformedNum++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(ehrNotPerformed,false); } }
///<summary>Inserts one EhrNotPerformed into the database. Provides option to use the existing priKey.</summary> public static long Insert(EhrNotPerformed ehrNotPerformed, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { ehrNotPerformed.EhrNotPerformedNum = ReplicationServers.GetKey("ehrnotperformed", "EhrNotPerformedNum"); } string command = "INSERT INTO ehrnotperformed ("; if (useExistingPK || PrefC.RandomKeys) { command += "EhrNotPerformedNum,"; } command += "PatNum,ProvNum,CodeValue,CodeSystem,CodeValueReason,CodeSystemReason,Note,DateEntry) VALUES("; if (useExistingPK || PrefC.RandomKeys) { command += POut.Long(ehrNotPerformed.EhrNotPerformedNum) + ","; } command += POut.Long(ehrNotPerformed.PatNum) + "," + POut.Long(ehrNotPerformed.ProvNum) + "," + "'" + POut.String(ehrNotPerformed.CodeValue) + "'," + "'" + POut.String(ehrNotPerformed.CodeSystem) + "'," + "'" + POut.String(ehrNotPerformed.CodeValueReason) + "'," + "'" + POut.String(ehrNotPerformed.CodeSystemReason) + "'," + "'" + POut.String(ehrNotPerformed.Note) + "'," + POut.Date(ehrNotPerformed.DateEntry) + ")"; if (useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { ehrNotPerformed.EhrNotPerformedNum = Db.NonQ(command, true); } return(ehrNotPerformed.EhrNotPerformedNum); }
///<summary>Returns true if Update(EhrNotPerformed,EhrNotPerformed) 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(EhrNotPerformed ehrNotPerformed, EhrNotPerformed oldEhrNotPerformed) { if (ehrNotPerformed.PatNum != oldEhrNotPerformed.PatNum) { return(true); } if (ehrNotPerformed.ProvNum != oldEhrNotPerformed.ProvNum) { return(true); } if (ehrNotPerformed.CodeValue != oldEhrNotPerformed.CodeValue) { return(true); } if (ehrNotPerformed.CodeSystem != oldEhrNotPerformed.CodeSystem) { return(true); } if (ehrNotPerformed.CodeValueReason != oldEhrNotPerformed.CodeValueReason) { return(true); } if (ehrNotPerformed.CodeSystemReason != oldEhrNotPerformed.CodeSystemReason) { return(true); } if (ehrNotPerformed.Note != oldEhrNotPerformed.Note) { return(true); } if (ehrNotPerformed.DateEntry.Date != oldEhrNotPerformed.DateEntry.Date) { return(true); } return(false); }
///<summary>Inserts one EhrNotPerformed into the database. Provides option to use the existing priKey.</summary> public static long Insert(EhrNotPerformed ehrNotPerformed,bool useExistingPK){ if(!useExistingPK && PrefC.RandomKeys) { ehrNotPerformed.EhrNotPerformedNum=ReplicationServers.GetKey("ehrnotperformed","EhrNotPerformedNum"); } string command="INSERT INTO ehrnotperformed ("; if(useExistingPK || PrefC.RandomKeys) { command+="EhrNotPerformedNum,"; } command+="PatNum,ProvNum,CodeValue,CodeSystem,CodeValueReason,CodeSystemReason,Note,DateEntry) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(ehrNotPerformed.EhrNotPerformedNum)+","; } command+= POut.Long (ehrNotPerformed.PatNum)+"," + POut.Long (ehrNotPerformed.ProvNum)+"," +"'"+POut.String(ehrNotPerformed.CodeValue)+"'," +"'"+POut.String(ehrNotPerformed.CodeSystem)+"'," +"'"+POut.String(ehrNotPerformed.CodeValueReason)+"'," +"'"+POut.String(ehrNotPerformed.CodeSystemReason)+"'," +"'"+POut.String(ehrNotPerformed.Note)+"'," + POut.Date (ehrNotPerformed.DateEntry)+")"; if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { ehrNotPerformed.EhrNotPerformedNum=Db.NonQ(command,true); } return ehrNotPerformed.EhrNotPerformedNum; }
///<summary>Updates one EhrNotPerformed 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(EhrNotPerformed ehrNotPerformed,EhrNotPerformed oldEhrNotPerformed){ string command=""; if(ehrNotPerformed.PatNum != oldEhrNotPerformed.PatNum) { if(command!=""){ command+=",";} command+="PatNum = "+POut.Long(ehrNotPerformed.PatNum)+""; } if(ehrNotPerformed.ProvNum != oldEhrNotPerformed.ProvNum) { if(command!=""){ command+=",";} command+="ProvNum = "+POut.Long(ehrNotPerformed.ProvNum)+""; } if(ehrNotPerformed.CodeValue != oldEhrNotPerformed.CodeValue) { if(command!=""){ command+=",";} command+="CodeValue = '"+POut.String(ehrNotPerformed.CodeValue)+"'"; } if(ehrNotPerformed.CodeSystem != oldEhrNotPerformed.CodeSystem) { if(command!=""){ command+=",";} command+="CodeSystem = '"+POut.String(ehrNotPerformed.CodeSystem)+"'"; } if(ehrNotPerformed.CodeValueReason != oldEhrNotPerformed.CodeValueReason) { if(command!=""){ command+=",";} command+="CodeValueReason = '"+POut.String(ehrNotPerformed.CodeValueReason)+"'"; } if(ehrNotPerformed.CodeSystemReason != oldEhrNotPerformed.CodeSystemReason) { if(command!=""){ command+=",";} command+="CodeSystemReason = '"+POut.String(ehrNotPerformed.CodeSystemReason)+"'"; } if(ehrNotPerformed.Note != oldEhrNotPerformed.Note) { if(command!=""){ command+=",";} command+="Note = '"+POut.String(ehrNotPerformed.Note)+"'"; } if(ehrNotPerformed.DateEntry != oldEhrNotPerformed.DateEntry) { if(command!=""){ command+=",";} command+="DateEntry = "+POut.Date(ehrNotPerformed.DateEntry)+""; } if(command==""){ return false; } command="UPDATE ehrnotperformed SET "+command +" WHERE EhrNotPerformedNum = "+POut.Long(ehrNotPerformed.EhrNotPerformedNum); Db.NonQ(command); return true; }
///<summary>Updates one EhrNotPerformed in the database.</summary> public static void Update(EhrNotPerformed ehrNotPerformed){ string command="UPDATE ehrnotperformed SET " +"PatNum = "+POut.Long (ehrNotPerformed.PatNum)+", " +"ProvNum = "+POut.Long (ehrNotPerformed.ProvNum)+", " +"CodeValue = '"+POut.String(ehrNotPerformed.CodeValue)+"', " +"CodeSystem = '"+POut.String(ehrNotPerformed.CodeSystem)+"', " +"CodeValueReason = '"+POut.String(ehrNotPerformed.CodeValueReason)+"', " +"CodeSystemReason = '"+POut.String(ehrNotPerformed.CodeSystemReason)+"', " +"Note = '"+POut.String(ehrNotPerformed.Note)+"', " +"DateEntry = "+POut.Date (ehrNotPerformed.DateEntry)+" " +"WHERE EhrNotPerformedNum = "+POut.Long(ehrNotPerformed.EhrNotPerformedNum); Db.NonQ(command); }
///<summary>Updates one EhrNotPerformed 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(EhrNotPerformed ehrNotPerformed, EhrNotPerformed oldEhrNotPerformed) { string command = ""; if (ehrNotPerformed.PatNum != oldEhrNotPerformed.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(ehrNotPerformed.PatNum) + ""; } if (ehrNotPerformed.ProvNum != oldEhrNotPerformed.ProvNum) { if (command != "") { command += ","; } command += "ProvNum = " + POut.Long(ehrNotPerformed.ProvNum) + ""; } if (ehrNotPerformed.CodeValue != oldEhrNotPerformed.CodeValue) { if (command != "") { command += ","; } command += "CodeValue = '" + POut.String(ehrNotPerformed.CodeValue) + "'"; } if (ehrNotPerformed.CodeSystem != oldEhrNotPerformed.CodeSystem) { if (command != "") { command += ","; } command += "CodeSystem = '" + POut.String(ehrNotPerformed.CodeSystem) + "'"; } if (ehrNotPerformed.CodeValueReason != oldEhrNotPerformed.CodeValueReason) { if (command != "") { command += ","; } command += "CodeValueReason = '" + POut.String(ehrNotPerformed.CodeValueReason) + "'"; } if (ehrNotPerformed.CodeSystemReason != oldEhrNotPerformed.CodeSystemReason) { if (command != "") { command += ","; } command += "CodeSystemReason = '" + POut.String(ehrNotPerformed.CodeSystemReason) + "'"; } if (ehrNotPerformed.Note != oldEhrNotPerformed.Note) { if (command != "") { command += ","; } command += "Note = '" + POut.String(ehrNotPerformed.Note) + "'"; } if (ehrNotPerformed.DateEntry != oldEhrNotPerformed.DateEntry) { if (command != "") { command += ","; } command += "DateEntry = " + POut.Date(ehrNotPerformed.DateEntry) + ""; } if (command == "") { return; } command = "UPDATE ehrnotperformed SET " + command + " WHERE EhrNotPerformedNum = " + POut.Long(ehrNotPerformed.EhrNotPerformedNum); Db.NonQ(command); }
///<summary>Updates one EhrNotPerformed 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(EhrNotPerformed ehrNotPerformed, EhrNotPerformed oldEhrNotPerformed) { string command = ""; if (ehrNotPerformed.PatNum != oldEhrNotPerformed.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(ehrNotPerformed.PatNum) + ""; } if (ehrNotPerformed.ProvNum != oldEhrNotPerformed.ProvNum) { if (command != "") { command += ","; } command += "ProvNum = " + POut.Long(ehrNotPerformed.ProvNum) + ""; } if (ehrNotPerformed.CodeValue != oldEhrNotPerformed.CodeValue) { if (command != "") { command += ","; } command += "CodeValue = '" + POut.String(ehrNotPerformed.CodeValue) + "'"; } if (ehrNotPerformed.CodeSystem != oldEhrNotPerformed.CodeSystem) { if (command != "") { command += ","; } command += "CodeSystem = '" + POut.String(ehrNotPerformed.CodeSystem) + "'"; } if (ehrNotPerformed.CodeValueReason != oldEhrNotPerformed.CodeValueReason) { if (command != "") { command += ","; } command += "CodeValueReason = '" + POut.String(ehrNotPerformed.CodeValueReason) + "'"; } if (ehrNotPerformed.CodeSystemReason != oldEhrNotPerformed.CodeSystemReason) { if (command != "") { command += ","; } command += "CodeSystemReason = '" + POut.String(ehrNotPerformed.CodeSystemReason) + "'"; } if (ehrNotPerformed.Note != oldEhrNotPerformed.Note) { if (command != "") { command += ","; } command += "Note = " + DbHelper.ParamChar + "paramNote"; } if (ehrNotPerformed.DateEntry.Date != oldEhrNotPerformed.DateEntry.Date) { if (command != "") { command += ","; } command += "DateEntry = " + POut.Date(ehrNotPerformed.DateEntry) + ""; } if (command == "") { return(false); } if (ehrNotPerformed.Note == null) { ehrNotPerformed.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(ehrNotPerformed.Note)); command = "UPDATE ehrnotperformed SET " + command + " WHERE EhrNotPerformedNum = " + POut.Long(ehrNotPerformed.EhrNotPerformedNum); Db.NonQ(command, paramNote); return(true); }
///<summary>Inserts one EhrNotPerformed into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EhrNotPerformed ehrNotPerformed) { return(InsertNoCache(ehrNotPerformed, false)); }