示例#1
0
        ///<summary>Combines all the given employers into one. Updates patient and insplan. Then deletes all the others.
        ///No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
        public static void Combine(List <long> employerNums, long userNum = 0)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
            {
                userNum = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), employerNums, userNum);
                return;
            }
            long newNum = employerNums[0];

            for (int i = 1; i < employerNums.Count; i++)
            {
                string command = "UPDATE patient SET EmployerNum = " + POut.Long(newNum)
                                 + " WHERE EmployerNum = " + POut.Long(employerNums[i]);
                Db.NonQ(command);
                command = "SELECT * FROM insplan WHERE EmployerNum = " + POut.Long(employerNums[i]);
                List <InsPlan> listInsPlans = Crud.InsPlanCrud.SelectMany(command);
                command = "UPDATE insplan SET EmployerNum = " + POut.Long(newNum)
                          + " WHERE EmployerNum = " + POut.Long(employerNums[i]);
                Db.NonQ(command);
                listInsPlans.ForEach(x => {                 //log updated employernums for insplan.
                    InsEditLogs.MakeLogEntry("EmployerNum", userNum, employerNums[i].ToString(), newNum.ToString(),
                                             InsEditLogType.InsPlan, x.PlanNum, 0, x.GroupNum + " - " + x.GroupName);
                });
                Employer employerCur = Employers.GetEmployer(employerNums[i]); //from the cache
                Employers.Delete(employerCur);                                 //logging taken care of in Delete method.
            }
        }
示例#2
0
        ///<summary>Combines all the given employers into one. Updates patient and insplan. Then deletes all the others.</summary>
        public static void Combine(List <long> employerNums)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), employerNums);
                return;
            }
            long newNum = employerNums[0];

            for (int i = 1; i < employerNums.Count; i++)
            {
                string command = "UPDATE patient SET EmployerNum = " + POut.Long(newNum)
                                 + " WHERE EmployerNum = " + POut.Long(employerNums[i]);
                Db.NonQ(command);
                command = "SELECT * FROM insplan WHERE EmployerNum = " + POut.Long(employerNums[i]);
                List <InsPlan> listInsPlans = Crud.InsPlanCrud.SelectMany(command);
                command = "UPDATE insplan SET EmployerNum = " + POut.Long(newNum)
                          + " WHERE EmployerNum = " + POut.Long(employerNums[i]);
                Db.NonQ(command);
                //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
                listInsPlans.ForEach(x => {                 //log updated employernums for insplan.
                    InsEditLogs.MakeLogEntry("EmployerNum", Security.CurUser.UserNum, employerNums[i].ToString(), newNum.ToString(),
                                             InsEditLogType.InsPlan, x.PlanNum, 0, x.GroupNum + " - " + x.GroupName);
                });
                Employer employerCur = Employers.GetEmployer(employerNums[i]); //from the cache
                Employers.Delete(employerCur);                                 //logging taken care of in Delete method.
            }
        }
示例#3
0
        ///<summary>Surround with try/catch.  If there are any dependencies, then this will throw an exception.
        ///This is currently only called from FormCarrierEdit.
        ///No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
        public static void Delete(Carrier Cur, long userNum = 0)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
            {
                userNum = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), Cur, userNum);
                return;
            }
            //look for dependencies in insplan table.
            string command = "SELECT insplan.PlanNum,CONCAT(CONCAT(LName,', '),FName) FROM insplan "
                             + "LEFT JOIN inssub ON insplan.PlanNum=inssub.PlanNum "
                             + "LEFT JOIN patient ON inssub.Subscriber=patient.PatNum "
                             + "WHERE insplan.CarrierNum = " + POut.Long(Cur.CarrierNum) + " "
                             + "ORDER BY LName,FName";
            DataTable table = Db.GetTable(command);
            string    strInUse;

            if (table.Rows.Count > 0)
            {
                strInUse = "";              //new string[table.Rows.Count];
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 0)
                    {
                        strInUse += "; ";
                    }
                    strInUse += PIn.String(table.Rows[i][1].ToString());
                }
                throw new ApplicationException(Lans.g("Carriers", "Not allowed to delete carrier because it is in use.  Subscribers using this carrier include ") + strInUse);
            }
            //look for dependencies in etrans table.
            command = "SELECT DateTimeTrans FROM etrans WHERE CarrierNum=" + POut.Long(Cur.CarrierNum)
                      + " OR CarrierNum2=" + POut.Long(Cur.CarrierNum);
            table = Db.GetTable(command);
            if (table.Rows.Count > 0)
            {
                strInUse = "";
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    if (i > 0)
                    {
                        strInUse += ", ";
                    }
                    strInUse += PIn.DateT(table.Rows[i][0].ToString()).ToShortDateString();
                }
                throw new ApplicationException(Lans.g("Carriers", "Not allowed to delete carrier because it is in use in the etrans table.  Dates of claim sent history include ") + strInUse);
            }
            command = "DELETE from carrier WHERE CarrierNum = " + POut.Long(Cur.CarrierNum);
            Db.NonQ(command);
            InsEditLogs.MakeLogEntry(null, Cur, InsEditLogType.Carrier, userNum);
        }
示例#4
0
        /*
         * Not using this because it turned out to be more efficient to refresh the whole
         * list if an empnum could not be found.
         * ///<summary>Just refreshes Cur from the db with info for one employer.</summary>
         * public static void Refresh(int employerNum){
         *      Cur=new Employer();//just in case no rows are returned
         *      if(employerNum==0) return;
         *      string command="SELECT * FROM employer WHERE EmployerNum = '"+employerNum+"'";
         *      DataTable table=Db.GetTable(command);;
         *      for(int i=0;i<table.Rows.Count;i++){//almost always just 1 row, but sometimes 0
         *              Cur.EmployerNum   =PIn.PInt   (table.Rows[i][0].ToString());
         *              Cur.EmpName       =PIn.PString(table.Rows[i][1].ToString());
         *      }
         * }*/

        public static void Update(Employer empCur, Employer empOld)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), empCur, empOld);
                return;
            }
            Crud.EmployerCrud.Update(empCur, empOld);
            //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
            InsEditLogs.MakeLogEntry(empCur, empOld, InsEditLogType.Employer, Security.CurUser.UserNum);
        }
示例#5
0
 public static long Insert(Employer Cur)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Cur.EmployerNum = Meth.GetLong(MethodBase.GetCurrentMethod(), Cur);
         return(Cur.EmployerNum);
     }
     //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
     InsEditLogs.MakeLogEntry(Cur, null, InsEditLogType.Employer, Security.CurUser.UserNum);
     return(Crud.EmployerCrud.Insert(Cur));
 }
示例#6
0
		///<summary>No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
		public static long Insert(Employer Cur, long userNum = 0) {
			if(RemotingClient.RemotingRole!=RemotingRole.ServerWeb) {
				userNum=Security.CurUser.UserNum;//must be before normal remoting role check to get user at workstation
			}
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Cur.EmployerNum=Meth.GetLong(MethodBase.GetCurrentMethod(),Cur,userNum);
				return Cur.EmployerNum;
			}
			InsEditLogs.MakeLogEntry(Cur,null,InsEditLogType.Employer,userNum);
			return Crud.EmployerCrud.Insert(Cur);
		}
示例#7
0
		/*
		 * Not using this because it turned out to be more efficient to refresh the whole
		 * list if an empnum could not be found.
		///<summary>Just refreshes Cur from the db with info for one employer.</summary>
		public static void Refresh(int employerNum){
			Cur=new Employer();//just in case no rows are returned
			if(employerNum==0) return;
			string command="SELECT * FROM employer WHERE EmployerNum = '"+employerNum+"'";
			DataTable table=Db.GetTable(command);;
			for(int i=0;i<table.Rows.Count;i++){//almost always just 1 row, but sometimes 0
				Cur.EmployerNum   =PIn.PInt   (table.Rows[i][0].ToString());
				Cur.EmpName       =PIn.PString(table.Rows[i][1].ToString());
			}
		}*/

		///<summary>No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
		public static void Update(Employer empCur, Employer empOld, long userNum = 0) {
			if(RemotingClient.RemotingRole!=RemotingRole.ServerWeb) {
				userNum=Security.CurUser.UserNum;//must be before normal remoting role check to get user at workstation
			}
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),empCur,empOld,userNum);
				return;
			}
			Crud.EmployerCrud.Update(empCur,empOld);
			InsEditLogs.MakeLogEntry(empCur,empOld,InsEditLogType.Employer,userNum);
		}
示例#8
0
        ///<summary>Surround with try/catch Combines all the given carriers into one.
        ///The carrier that will be used as the basis of the combination is specified in the pickedCarrier argument.
        ///Updates insplan and etrans, then deletes all the other carriers.</summary>
        public static void Combine(List <long> carrierNums, long pickedCarrierNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), carrierNums, pickedCarrierNum);
                return;
            }
            if (carrierNums.Count == 1)
            {
                return;                //nothing to do
            }
            //remove pickedCarrierNum from the carrierNums list to make the queries easier to construct.
            List <long> carrierNumList = new List <long>();

            for (int i = 0; i < carrierNums.Count; i++)
            {
                if (carrierNums[i] == pickedCarrierNum)
                {
                    continue;
                }
                carrierNumList.Add(carrierNums[i]);
            }
            //Now, do the actual combining----------------------------------------------------------------------------------
            for (int i = 0; i < carrierNums.Count; i++)
            {
                if (carrierNums[i] == pickedCarrierNum)
                {
                    continue;
                }
                string         command     = "SELECT * FROM insplan WHERE CarrierNum = " + POut.Long(carrierNums[i]);
                List <InsPlan> listInsPlan = Crud.InsPlanCrud.SelectMany(command);
                command = "UPDATE insplan SET CarrierNum = '" + POut.Long(pickedCarrierNum) + "' "
                          + "WHERE CarrierNum = " + POut.Long(carrierNums[i]);
                Db.NonQ(command);
                command = "UPDATE etrans SET CarrierNum='" + POut.Long(pickedCarrierNum) + "' "
                          + "WHERE CarrierNum=" + POut.Long(carrierNums[i]);
                Db.NonQ(command);
                command = "UPDATE etrans SET CarrierNum2='" + POut.Long(pickedCarrierNum) + "' "
                          + "WHERE CarrierNum2=" + POut.Long(carrierNums[i]);
                Db.NonQ(command);
                //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
                listInsPlan.ForEach(x => {                 //Log InsPlan CarrierNum change.
                    InsEditLogs.MakeLogEntry("CarrierNum", Security.CurUser.UserNum, POut.Long(carrierNums[i]), POut.Long(pickedCarrierNum),
                                             InsEditLogType.InsPlan, x.PlanNum, 0, x.GroupNum + " - " + x.GroupName);
                });
                Carrier carrierCur = GetCarrier(carrierNums[i]);                 //gets from cache
                command = "DELETE FROM carrier"
                          + " WHERE CarrierNum = '" + carrierNums[i].ToString() + "'";
                Db.NonQ(command);
                //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
                InsEditLogs.MakeLogEntry(null, carrierCur, InsEditLogType.Carrier, Security.CurUser.UserNum);
            }
        }
示例#9
0
		///<summary>There MUST not be any dependencies before calling this or there will be invalid foreign keys.  
		///This is only called from FormEmployers after proper validation.
		///No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
		public static void Delete(Employer Cur,long userNum=0) {
			if(RemotingClient.RemotingRole!=RemotingRole.ServerWeb) {
				userNum=Security.CurUser.UserNum;//must be before normal remoting role check to get user at workstation
			}
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),Cur,userNum);
				return;
			}
			string command="DELETE from employer WHERE EmployerNum = '"+Cur.EmployerNum.ToString()+"'";
			Db.NonQ(command);
			InsEditLogs.MakeLogEntry(null,Cur,InsEditLogType.Employer,userNum);
		}
示例#10
0
        ///<summary>There MUST not be any dependencies before calling this or there will be invalid foreign keys.
        ///This is only called from FormEmployers after proper validation.</summary>
        public static void Delete(Employer Cur)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), Cur);
                return;
            }
            string command = "DELETE from employer WHERE EmployerNum = '" + Cur.EmployerNum.ToString() + "'";

            Db.NonQ(command);
            //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
            InsEditLogs.MakeLogEntry(null, Cur, InsEditLogType.Employer, Security.CurUser.UserNum);
        }
示例#11
0
 ///<summary>Surround with try/catch if possibly adding a Canadian carrier.</summary>
 public static long Insert(Carrier carrier, Carrier carrierOld = null)
 {
     if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
     {
         carrier.SecUserNumEntry = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
     }
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         carrier.CarrierNum = Meth.GetLong(MethodBase.GetCurrentMethod(), carrier, carrierOld);
         return(carrier.CarrierNum);
     }
     //string command;
     if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Canadian. en-CA or fr-CA
     {
         if (carrier.IsCDA)
         {
             if (carrier.ElectID == "")
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number required."));
             }
             if (!Regex.IsMatch(carrier.ElectID, "^[0-9]{6}$"))
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number must be exactly 6 numbers."));
             }
         }
     }
     if (carrierOld == null)
     {
         carrierOld = carrier.Copy();
     }
     Crud.CarrierCrud.Insert(carrier);
     if (carrierOld.CarrierNum != 0)
     {
         InsEditLogs.MakeLogEntry(carrier, carrierOld, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     else
     {
         InsEditLogs.MakeLogEntry(carrier, null, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     return(carrier.CarrierNum);
 }
示例#12
0
        ///<summary>Surround with try/catch.
        ///No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
        public static void Update(Carrier carrier, Carrier oldCarrier, long userNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), carrier, oldCarrier, userNum);
                return;
            }
            string    command;
            DataTable table;

            if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Canadian. en-CA or fr-CA
            {
                if (carrier.IsCDA)
                {
                    if (carrier.ElectID == "")
                    {
                        throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number required."));
                    }
                    if (!Regex.IsMatch(carrier.ElectID, "^[0-9]{6}$"))
                    {
                        throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number must be exactly 6 numbers."));
                    }
                }
                //so the edited carrier looks good, but now we need to make sure that the original was allowed to be changed.
                command = "SELECT ElectID,IsCDA FROM carrier WHERE CarrierNum = '" + POut.Long(carrier.CarrierNum) + "'";
                table   = Db.GetTable(command);
                if (PIn.Bool(table.Rows[0]["IsCDA"].ToString()) &&            //if original carrier IsCDA
                    PIn.String(table.Rows[0]["ElectID"].ToString()).Trim() != "" &&                   //and the ElectID was already set
                    PIn.String(table.Rows[0]["ElectID"].ToString()) != carrier.ElectID)                     //and the ElectID was changed
                {
                    command = "SELECT COUNT(*) FROM etrans WHERE CarrierNum= " + POut.Long(carrier.CarrierNum)
                              + " OR CarrierNum2=" + POut.Long(carrier.CarrierNum);
                    if (Db.GetCount(command) != "0")
                    {
                        throw new ApplicationException(Lans.g("Carriers", "Not allowed to change Carrier Identification Number because it's in use in the claim history."));
                    }
                }
            }
            Crud.CarrierCrud.Update(carrier, oldCarrier);
            InsEditLogs.MakeLogEntry(carrier, oldCarrier, InsEditLogType.Carrier, userNum);
        }
示例#13
0
 ///<summary>Surround with try/catch if possibly adding a Canadian carrier.</summary>
 public static long Insert(Carrier carrier, Carrier carrierOld = null, bool useExistingPriKey = false)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         carrier.CarrierNum = Meth.GetLong(MethodBase.GetCurrentMethod(), carrier, carrierOld, useExistingPriKey);
         return(carrier.CarrierNum);
     }
     //Security.CurUser.UserNum gets set on MT by the DtoProcessor so it matches the user from the client WS.
     carrier.SecUserNumEntry = Security.CurUser.UserNum;
     //string command;
     if (CultureInfo.CurrentCulture.Name.EndsWith("CA"))             //Canadian. en-CA or fr-CA
     {
         if (carrier.IsCDA)
         {
             if (carrier.ElectID == "")
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number required."));
             }
             if (!Regex.IsMatch(carrier.ElectID, "^[0-9]{6}$"))
             {
                 throw new ApplicationException(Lans.g("Carriers", "Carrier Identification Number must be exactly 6 numbers."));
             }
         }
     }
     if (carrierOld == null)
     {
         carrierOld = carrier.Copy();
     }
     Crud.CarrierCrud.Insert(carrier, useExistingPriKey);
     if (carrierOld.CarrierNum != 0)
     {
         InsEditLogs.MakeLogEntry(carrier, carrierOld, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     else
     {
         InsEditLogs.MakeLogEntry(carrier, null, InsEditLogType.Carrier, carrier.SecUserNumEntry);
     }
     return(carrier.CarrierNum);
 }
示例#14
0
        ///<summary>Surround with try/catch Combines all the given carriers into one.
        ///The carrier that will be used as the basis of the combination is specified in the pickedCarrier argument.
        ///Updates insplan, then deletes all the other carriers.
        ///No need to pass in usernum, it is set before the remoting role and passed in for logging.</summary>
        public static void Combine(List <long> carrierNums, long pickedCarrierNum, long userNum = 0)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ServerWeb)
            {
                userNum = Security.CurUser.UserNum;              //must be before normal remoting role check to get user at workstation
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), carrierNums, pickedCarrierNum, userNum);
                return;
            }
            if (carrierNums.Count == 1)
            {
                return;                //nothing to do
            }
            //remove pickedCarrierNum from the carrierNums list to make the queries easier to construct.
            List <long> carrierNumList = new List <long>();

            for (int i = 0; i < carrierNums.Count; i++)
            {
                if (carrierNums[i] == pickedCarrierNum)
                {
                    continue;
                }
                carrierNumList.Add(carrierNums[i]);
            }
            //Make sure that none of the carrierNums are in use in the etrans table
            string command = "SELECT COUNT(*) FROM etrans WHERE";

            for (int i = 0; i < carrierNumList.Count; i++)
            {
                if (i > 0)
                {
                    command += " OR";
                }
                command += " (CarrierNum=" + carrierNumList[i].ToString() + " AND CarrierTransCounter>0)";
            }
            for (int i = 0; i < carrierNumList.Count; i++)
            {
                command += " OR (CarrierNum2=" + carrierNumList[i].ToString() + " AND CarrierTransCounter2>0)";
            }
            DataTable table  = Db.GetTable(command);
            string    ecount = table.Rows[0][0].ToString();

            if (ecount != "0")
            {
                throw new ApplicationException(Lans.g("Carriers", "Not allowed to combine carriers because some are in use in the etrans table.  Number of entries involved: ") + ecount);
            }
            //Now, do the actual combining----------------------------------------------------------------------------------
            for (int i = 0; i < carrierNums.Count; i++)
            {
                if (carrierNums[i] == pickedCarrierNum)
                {
                    continue;
                }
                command = "SELECT * FROM insplan WHERE CarrierNum = " + POut.Long(carrierNums[i]);
                List <InsPlan> listInsPlan = Crud.InsPlanCrud.SelectMany(command);
                command = "UPDATE insplan SET CarrierNum = '" + POut.Long(pickedCarrierNum)
                          + "' WHERE CarrierNum = " + POut.Long(carrierNums[i]);
                Db.NonQ(command);
                listInsPlan.ForEach(x => {                 //Log InsPlan CarrierNum change.
                    InsEditLogs.MakeLogEntry("CarrierNum", userNum, POut.Long(carrierNums[i]), POut.Long(pickedCarrierNum),
                                             InsEditLogType.InsPlan, x.PlanNum, 0, x.GroupNum + " - " + x.GroupName);
                });
                Carrier carrierCur = GetCarrier(carrierNums[i]);                 //gets from cache
                command = "DELETE FROM carrier"
                          + " WHERE CarrierNum = '" + carrierNums[i].ToString() + "'";
                Db.NonQ(command);
                InsEditLogs.MakeLogEntry(null, carrierCur, InsEditLogType.Carrier, userNum);
            }
        }