예제 #1
0
 ///<summary>Inserts one ProviderIdent into the database.  Returns the new priKey.</summary>
 public static long Insert(ProviderIdent providerIdent)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         providerIdent.ProviderIdentNum = DbHelper.GetNextOracleKey("providerident", "ProviderIdentNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(providerIdent, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     providerIdent.ProviderIdentNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(providerIdent, false));
     }
 }
예제 #2
0
        ///<summary>Inserts one ProviderIdent into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(ProviderIdent providerIdent, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                providerIdent.ProviderIdentNum = ReplicationServers.GetKey("providerident", "ProviderIdentNum");
            }
            string command = "INSERT INTO providerident (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "ProviderIdentNum,";
            }
            command += "ProvNum,PayorID,SuppIDType,IDNumber) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(providerIdent.ProviderIdentNum) + ",";
            }
            command +=
                POut.Long(providerIdent.ProvNum) + ","
                + "'" + POut.String(providerIdent.PayorID) + "',"
                + POut.Int((int)providerIdent.SuppIDType) + ","
                + "'" + POut.String(providerIdent.IDNumber) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                providerIdent.ProviderIdentNum = Db.NonQ(command, true);
            }
            return(providerIdent.ProviderIdentNum);
        }
예제 #3
0
        ///<summary>Inserts one ProviderIdent into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(ProviderIdent providerIdent, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO providerident (";

            if (!useExistingPK && isRandomKeys)
            {
                providerIdent.ProviderIdentNum = ReplicationServers.GetKeyNoCache("providerident", "ProviderIdentNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "ProviderIdentNum,";
            }
            command += "ProvNum,PayorID,SuppIDType,IDNumber) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(providerIdent.ProviderIdentNum) + ",";
            }
            command +=
                POut.Long(providerIdent.ProvNum) + ","
                + "'" + POut.String(providerIdent.PayorID) + "',"
                + POut.Int((int)providerIdent.SuppIDType) + ","
                + "'" + POut.String(providerIdent.IDNumber) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                providerIdent.ProviderIdentNum = Db.NonQ(command, true, "ProviderIdentNum", "providerIdent");
            }
            return(providerIdent.ProviderIdentNum);
        }
예제 #4
0
 ///<summary>Inserts one ProviderIdent into the database.  Returns the new priKey.</summary>
 internal static long Insert(ProviderIdent providerIdent)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         providerIdent.ProviderIdentNum=DbHelper.GetNextOracleKey("providerident","ProviderIdentNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(providerIdent,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     providerIdent.ProviderIdentNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(providerIdent,false);
     }
 }
예제 #5
0
		///<summary>Inserts one ProviderIdent into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(ProviderIdent providerIdent,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				providerIdent.ProviderIdentNum=ReplicationServers.GetKey("providerident","ProviderIdentNum");
			}
			string command="INSERT INTO providerident (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="ProviderIdentNum,";
			}
			command+="ProvNum,PayorID,SuppIDType,IDNumber) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(providerIdent.ProviderIdentNum)+",";
			}
			command+=
				     POut.Long  (providerIdent.ProvNum)+","
				+"'"+POut.String(providerIdent.PayorID)+"',"
				+    POut.Int   ((int)providerIdent.SuppIDType)+","
				+"'"+POut.String(providerIdent.IDNumber)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				providerIdent.ProviderIdentNum=Db.NonQ(command,true);
			}
			return providerIdent.ProviderIdentNum;
		}
예제 #6
0
        ///<summary>Updates one ProviderIdent in the database.</summary>
        public static void Update(ProviderIdent providerIdent)
        {
            string command = "UPDATE providerident SET "
                             + "ProvNum         =  " + POut.Long(providerIdent.ProvNum) + ", "
                             + "PayorID         = '" + POut.String(providerIdent.PayorID) + "', "
                             + "SuppIDType      =  " + POut.Int((int)providerIdent.SuppIDType) + ", "
                             + "IDNumber        = '" + POut.String(providerIdent.IDNumber) + "' "
                             + "WHERE ProviderIdentNum = " + POut.Long(providerIdent.ProviderIdentNum);

            Db.NonQ(command);
        }
예제 #7
0
		///<summary></summary>
		public static void Refresh(){
			string command="SELECT * from providerident";
 			DataTable table=General.GetTable(command);
			List=new ProviderIdent[table.Rows.Count];
			for(int i=0;i<table.Rows.Count;i++){
				List[i]=new ProviderIdent();
				List[i].ProviderIdentNum= PIn.PInt   (table.Rows[i][0].ToString());
				List[i].ProvNum         = PIn.PInt   (table.Rows[i][1].ToString());
				List[i].PayorID         = PIn.PString(table.Rows[i][2].ToString());
				List[i].SuppIDType      = (ProviderSupplementalID)PIn.PInt(table.Rows[i][3].ToString());
				List[i].IDNumber        = PIn.PString(table.Rows[i][4].ToString());
			}
		}
예제 #8
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<ProviderIdent> TableToList(DataTable table){
			List<ProviderIdent> retVal=new List<ProviderIdent>();
			ProviderIdent providerIdent;
			for(int i=0;i<table.Rows.Count;i++) {
				providerIdent=new ProviderIdent();
				providerIdent.ProviderIdentNum= PIn.Long  (table.Rows[i]["ProviderIdentNum"].ToString());
				providerIdent.ProvNum         = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				providerIdent.PayorID         = PIn.String(table.Rows[i]["PayorID"].ToString());
				providerIdent.SuppIDType      = (ProviderSupplementalID)PIn.Int(table.Rows[i]["SuppIDType"].ToString());
				providerIdent.IDNumber        = PIn.String(table.Rows[i]["IDNumber"].ToString());
				retVal.Add(providerIdent);
			}
			return retVal;
		}
예제 #9
0
 ///<summary>Inserts one ProviderIdent into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(ProviderIdent providerIdent)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(providerIdent, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             providerIdent.ProviderIdentNum = DbHelper.GetNextOracleKey("providerident", "ProviderIdentNum");                  //Cacheless method
         }
         return(InsertNoCache(providerIdent, true));
     }
 }
예제 #10
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ProviderIdent> TableToList(DataTable table)
        {
            List <ProviderIdent> retVal = new List <ProviderIdent>();
            ProviderIdent        providerIdent;

            foreach (DataRow row in table.Rows)
            {
                providerIdent = new ProviderIdent();
                providerIdent.ProviderIdentNum = PIn.Long(row["ProviderIdentNum"].ToString());
                providerIdent.ProvNum          = PIn.Long(row["ProvNum"].ToString());
                providerIdent.PayorID          = PIn.String(row["PayorID"].ToString());
                providerIdent.SuppIDType       = (OpenDentBusiness.ProviderSupplementalID)PIn.Int(row["SuppIDType"].ToString());
                providerIdent.IDNumber         = PIn.String(row["IDNumber"].ToString());
                retVal.Add(providerIdent);
            }
            return(retVal);
        }
예제 #11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <ProviderIdent> TableToList(DataTable table)
        {
            List <ProviderIdent> retVal = new List <ProviderIdent>();
            ProviderIdent        providerIdent;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                providerIdent = new ProviderIdent();
                providerIdent.ProviderIdentNum = PIn.Long(table.Rows[i]["ProviderIdentNum"].ToString());
                providerIdent.ProvNum          = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                providerIdent.PayorID          = PIn.String(table.Rows[i]["PayorID"].ToString());
                providerIdent.SuppIDType       = (ProviderSupplementalID)PIn.Int(table.Rows[i]["SuppIDType"].ToString());
                providerIdent.IDNumber         = PIn.String(table.Rows[i]["IDNumber"].ToString());
                retVal.Add(providerIdent);
            }
            return(retVal);
        }
예제 #12
0
        ///<summary>Updates one ProviderIdent 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(ProviderIdent providerIdent, ProviderIdent oldProviderIdent)
        {
            string command = "";

            if (providerIdent.ProvNum != oldProviderIdent.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(providerIdent.ProvNum) + "";
            }
            if (providerIdent.PayorID != oldProviderIdent.PayorID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PayorID = '" + POut.String(providerIdent.PayorID) + "'";
            }
            if (providerIdent.SuppIDType != oldProviderIdent.SuppIDType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SuppIDType = " + POut.Int((int)providerIdent.SuppIDType) + "";
            }
            if (providerIdent.IDNumber != oldProviderIdent.IDNumber)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IDNumber = '" + POut.String(providerIdent.IDNumber) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE providerident SET " + command
                      + " WHERE ProviderIdentNum = " + POut.Long(providerIdent.ProviderIdentNum);
            Db.NonQ(command);
            return(true);
        }
예제 #13
0
 ///<summary>Returns true if Update(ProviderIdent,ProviderIdent) 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(ProviderIdent providerIdent, ProviderIdent oldProviderIdent)
 {
     if (providerIdent.ProvNum != oldProviderIdent.ProvNum)
     {
         return(true);
     }
     if (providerIdent.PayorID != oldProviderIdent.PayorID)
     {
         return(true);
     }
     if (providerIdent.SuppIDType != oldProviderIdent.SuppIDType)
     {
         return(true);
     }
     if (providerIdent.IDNumber != oldProviderIdent.IDNumber)
     {
         return(true);
     }
     return(false);
 }
예제 #14
0
 ///<summary>Inserts one ProviderIdent into the database.  Returns the new priKey.</summary>
 public static long Insert(ProviderIdent providerIdent)
 {
     return(Insert(providerIdent, false));
 }
예제 #15
0
		///<summary>Gets all supplemental identifiers that have been attached to this provider. Used in the provider edit window.</summary>
		public static ProviderIdent[] GetForProv(int provNum){
			ArrayList arrayL=new ArrayList();
			for(int i=0;i<List.Length;i++){
				if(List[i].ProvNum==provNum){
					arrayL.Add(List[i]);
				}
			}
			ProviderIdent[] ForProv=new ProviderIdent[arrayL.Count];
			for(int i=0;i<arrayL.Count;i++){
				ForProv[i]=(ProviderIdent)arrayL[i];
			}
			return ForProv;
		}
예제 #16
0
		///<summary>Updates one ProviderIdent 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(ProviderIdent providerIdent,ProviderIdent oldProviderIdent){
			string command="";
			if(providerIdent.ProvNum != oldProviderIdent.ProvNum) {
				if(command!=""){ command+=",";}
				command+="ProvNum = "+POut.Long(providerIdent.ProvNum)+"";
			}
			if(providerIdent.PayorID != oldProviderIdent.PayorID) {
				if(command!=""){ command+=",";}
				command+="PayorID = '"+POut.String(providerIdent.PayorID)+"'";
			}
			if(providerIdent.SuppIDType != oldProviderIdent.SuppIDType) {
				if(command!=""){ command+=",";}
				command+="SuppIDType = "+POut.Int   ((int)providerIdent.SuppIDType)+"";
			}
			if(providerIdent.IDNumber != oldProviderIdent.IDNumber) {
				if(command!=""){ command+=",";}
				command+="IDNumber = '"+POut.String(providerIdent.IDNumber)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE providerident SET "+command
				+" WHERE ProviderIdentNum = "+POut.Long(providerIdent.ProviderIdentNum);
			Db.NonQ(command);
		}
예제 #17
0
		///<summary>Updates one ProviderIdent in the database.</summary>
		public static void Update(ProviderIdent providerIdent){
			string command="UPDATE providerident SET "
				+"ProvNum         =  "+POut.Long  (providerIdent.ProvNum)+", "
				+"PayorID         = '"+POut.String(providerIdent.PayorID)+"', "
				+"SuppIDType      =  "+POut.Int   ((int)providerIdent.SuppIDType)+", "
				+"IDNumber        = '"+POut.String(providerIdent.IDNumber)+"' "
				+"WHERE ProviderIdentNum = "+POut.Long(providerIdent.ProviderIdentNum);
			Db.NonQ(command);
		}
예제 #18
0
		///<summary>Gets all supplemental identifiers that have been attached to this provider and for this particular payorID.  Called from X12 when creating a claim file.  Also used now on printed claims.</summary>
		public static ProviderIdent[] GetForPayor(int provNum,string payorID){
			ArrayList arrayL=new ArrayList();
			for(int i=0;i<List.Length;i++){
				if(List[i].ProvNum==provNum
					&& List[i].PayorID==payorID)
				{
					arrayL.Add(List[i]);
				}
			}
			ProviderIdent[] ForPayor=new ProviderIdent[arrayL.Count];
			for(int i=0;i<arrayL.Count;i++){
				ForPayor[i]=(ProviderIdent)arrayL[i];
			}
			return ForPayor;
		}