///<summary></summary>
 public static long Insert(GroupPermission gp)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         gp.GroupPermNum = Meth.GetLong(MethodBase.GetCurrentMethod(), gp);
         return(gp.GroupPermNum);
     }
     if (gp.NewerDate.Year > 1880 && gp.NewerDays > 0)
     {
         throw new Exception(Lans.g("GroupPermissions", "Date or days can be set, but not both."));
     }
     if (!GroupPermissions.PermTakesDates(gp.PermType))
     {
         if (gp.NewerDate.Year > 1880 || gp.NewerDays > 0)
         {
             throw new Exception(Lans.g("GroupPermissions", "This type of permission may not have a date or days set."));
         }
     }
     if (gp.PermType == Permissions.SecurityAdmin)
     {
         //Make sure there are no hidden users in the group that is about to get the Security Admin permission.
         string command = "SELECT COUNT(*) FROM userod "
                          + "INNER JOIN usergroupattach ON usergroupattach.UserNum=userod.UserNum "
                          + "WHERE userod.IsHidden=1 "
                          + "AND usergroupattach.UserGroupNum=" + gp.UserGroupNum;
         int count = PIn.Int(Db.GetCount(command));
         if (count != 0)               //there are hidden users in this group
         {
             throw new Exception(Lans.g("FormSecurity", "The Security Admin permission cannot be given to a user group with hidden users."));
         }
     }
     return(Crud.GroupPermissionCrud.Insert(gp));
 }
Exemple #2
0
        ///<Summary>Checks bugIDs in list for incompletes. Returns false if incomplete exists.</Summary>
        public static bool CheckForCompletion(List <long> listBugIDs)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), listBugIDs));
            }
            //Create an ODThread so that we can safely change the database connection settings without affecting the calling method's connection.
            ODThread odThread = new ODThread(new ODThread.WorkerDelegate((ODThread o) => {
                //Always set the thread static database connection variables to set the serviceshq db conn.
#if DEBUG
                new DataConnection().SetDbT("localhost", "bugs", "root", "", "", "", DatabaseType.MySql, true);
#else
                new DataConnection().SetDbT("server", "bugs", "root", "", "", "", DatabaseType.MySql, true);
#endif
                string command = "SELECT COUNT(*) FROM bug "
                                 + "WHERE VersionsFixed='' "
                                 + "AND BugId IN (" + String.Join(",", listBugIDs) + ")";
                o.Tag = Db.GetCount(command);
            }));

            odThread.AddExceptionHandler(new ODThread.ExceptionDelegate((Exception e) => {
            }));            //Do nothing
            odThread.Name = "bugsCheckForCompletionThread";
            odThread.Start(true);
            if (!odThread.Join(THREAD_TIMEOUT))
            {
                return(true);
            }
            if (PIn.Int(odThread.Tag.ToString()) != 0)
            {
                return(false);
            }
            return(true);
        }
        ///<summary>Helper method to determine if an index already exists.
        ///Returns true if colNames matches the concatenation of all COLUMN_NAME(s) for the column(s) referenced by an index on the corresponding
        ///tableName.  If the index references multiple columns, colNames must have the column names in the exact order in which the index was created
        ///separated by commas, without spaces.
        ///Example: the claimproc table has the multi-column index on columns ClaimPaymentNum, Status, and InsPayAmt.
        ///To see if that index already exists, the parameters would be tableName="claimproc" and colNames="ClaimPaymentNum,Status,InsPayAmt".
        ///Not case sensitive.  This will always return false for Oracle.</summary>
        public static bool IndexExists(string tableName, string colNames)
        {
            if (DataConnection.DBtype == DatabaseType.Oracle)           //Oracle will not allow the same column to be indexed more than once
            {
                return(false);
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), tableName, colNames));
            }
            string command = "SELECT COUNT(*) FROM ("
                             + "SELECT GROUP_CONCAT(LOWER(COLUMN_NAME) ORDER BY SEQ_IN_INDEX) ColNames "
                             + "FROM INFORMATION_SCHEMA.STATISTICS "
                             + "WHERE TABLE_SCHEMA=SCHEMA() "
                             + "AND LOWER(TABLE_NAME)='" + POut.String(tableName.ToLower()) + "' "
                             + "GROUP BY INDEX_NAME) cols "
                             + "WHERE cols.ColNames='" + POut.String(colNames.ToLower()) + "'";

            try {
                if (Db.GetCount(command) == "0")
                {
                    return(false);
                }
            }
            catch (Exception ex) {
                ex.DoNothing();
                return(false);               //might happen if user does not have permission to query information schema tables.
            }
            return(true);
        }
Exemple #4
0
        ///<summary>Used when attempting to delete.  Returns empty string if not in use and an untranslated string if in use.</summary>
        public static string CheckInUse(long appointmentTypeNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetString(MethodBase.GetCurrentMethod(), appointmentTypeNum));
            }
            string command = "SELECT COUNT(*) FROM appointment WHERE AppointmentTypeNum = " + POut.Long(appointmentTypeNum);

            if (PIn.Int(Db.GetCount(command)) > 0)
            {
                return("Not allowed to delete appointment types that are in use on an appointment.");
            }
            command = "SELECT COUNT(*) FROM operatory WHERE AppointmentTypeNum = " + POut.Long(appointmentTypeNum);
            if (PIn.Int(Db.GetCount(command)) > 0)
            {
                return("Not allowed to delete appointment types that are in use on an operatory.");
            }
            command = "SELECT COUNT(*) FROM deflink "
                      + "WHERE LinkType = " + POut.Int((int)DefLinkType.AppointmentType) + " "
                      + "AND FKey = " + POut.Long(appointmentTypeNum) + " ";
            if (PIn.Int(Db.GetCount(command)) > 0)
            {
                //This message will need to change in the future if more definition categories utilize appointment types with the deflink table.
                return("Not allowed to delete appointment types that are in use by Web Sched New Pat Appt Types definitions.");
            }
            return("");
        }
Exemple #5
0
        ///<summary>Automatically generate and insert encounter as long as there is no other encounter with that date and provider for that patient.  Does not insert an encounter if one of the CQM default encounter prefs are invalid.</summary>
        public static void InsertDefaultEncounter(long patNum, long provNum, DateTime date)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), patNum, provNum, date);
                return;
            }
            //Validate prefs. If they are not set, we have nothing to insert so no reason to check.
            if (PrefC.GetString(PrefName.CQMDefaultEncounterCodeSystem) == "" || PrefC.GetString(PrefName.CQMDefaultEncounterCodeValue) == "none")
            {
                return;
            }
            //If no encounter for date for this patient
            string command = "SELECT COUNT(*) NumEncounters FROM encounter WHERE encounter.PatNum=" + POut.Long(patNum) + " "
                             + "AND encounter.DateEncounter=" + POut.Date(date) + " "
                             + "AND encounter.ProvNum=" + POut.Long(provNum);
            int count = PIn.Int(Db.GetCount(command));

            if (count > 0)              //Encounter already exists for date
            {
                return;
            }
            //Insert encounter with default encounter code system and code value set in Setup>EHR>Settings
            Encounter encounter = new Encounter();

            encounter.PatNum        = patNum;
            encounter.ProvNum       = provNum;
            encounter.DateEncounter = date;
            encounter.CodeSystem    = PrefC.GetString(PrefName.CQMDefaultEncounterCodeSystem);
            encounter.CodeValue     = PrefC.GetString(PrefName.CQMDefaultEncounterCodeValue);
            Insert(encounter);
        }
Exemple #6
0
        ///<summary>CAUTION.  This does not perform all validations.  It only properly validates for two def types right now.</summary>
        public static void Delete(Def def)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), def);
                return;
            }
            if (def.Category != DefCat.SupplyCats && def.Category != DefCat.ClaimCustomTracking)
            {
                throw new ApplicationException("NOT Allowed to delete this type of def.");
            }
            string command = "";

            if (def.Category == DefCat.SupplyCats)
            {
                command = "SELECT COUNT(*) FROM supply WHERE Category=" + POut.Long(def.DefNum);
            }
            else if (def.Category == DefCat.ClaimCustomTracking)
            {
                command = "SELECT COUNT(*) FROM claim WHERE CustomTracking=" + POut.Long(def.DefNum);
            }
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("Defs", "Def is in use.  Not allowed to delete."));
            }
            command = "DELETE FROM definition WHERE DefNum=" + POut.Long(def.DefNum);
            Db.NonQ(command);
            command = "UPDATE definition SET ItemOrder=ItemOrder-1 "
                      + "WHERE Category=" + POut.Long((int)def.Category)
                      + " AND ItemOrder > " + POut.Long(def.ItemOrder);
            Db.NonQ(command);
        }
Exemple #7
0
        ///<summary>Returns without making any changes if dep.DepositNum==0.  Also handles detaching all payments and claimpayments.  Throws exception if
        ///deposit is attached as a source document to a transaction.  The program should have detached the deposit from the transaction ahead of time, so
        ///I would never expect the program to throw this exception unless there was a bug.</summary>
        public static void Delete(Deposit dep)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), dep);
                return;
            }
            if (dep.DepositNum == 0)
            {
                return;
            }
            //check dependencies
            string command = "SELECT COUNT(*) FROM transaction WHERE DepositNum =" + POut.Long(dep.DepositNum);

            if (PIn.Long(Db.GetCount(command)) > 0)
            {
                throw new ApplicationException(Lans.g("Deposits", "Cannot delete deposit because it is attached to a transaction."));
            }
            //ready to delete
            command = "UPDATE payment SET DepositNum=0 WHERE DepositNum=" + POut.Long(dep.DepositNum);
            Db.NonQ(command);
            command = "UPDATE claimpayment SET DepositNum=0 WHERE DepositNum=" + POut.Long(dep.DepositNum);
            Db.NonQ(command);
            Crud.DepositCrud.Delete(dep.DepositNum);
        }
Exemple #8
0
        ///<summary>Returns the number of partial batch insurance payments or if there are any claimprocs with status Received that have InsPayAmts but
        ///are not associated to a claim payment. Used to warn users that reports will be inaccurate until insurance payments are finalized.</summary>
        public static int GetPartialPaymentsCount()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod()));
            }
            //Union together two queries that look for incomplete insurance payments.
            //The first query will look for any partial batch insurance payments.
            //The second query will look for any claim payments (InsPayAmt > 0) that do not have a claim payment (no check / not finalized).
            string command = @"
				SELECT COUNT(*) 
				FROM ((SELECT claimpayment.ClaimPaymentNum 
					FROM claimpayment 
					WHERE claimpayment.IsPartial = 1 
					AND claimpayment.CheckDate <= "                     + POut.Date(DateTime.Now) + @" 
					AND claimpayment.CheckDate >= "                     + POut.Date(DateTime.Now.AddMonths(-1)) + @")
						UNION ALL
					(SELECT claimproc.ClaimProcNum 
					FROM claimproc
					WHERE claimproc.ClaimPaymentNum = 0
					AND claimproc.InsPayAmt != 0 
					AND claimproc.Status IN("                     + POut.Int((int)ClaimProcStatus.Received) + "," + POut.Int((int)ClaimProcStatus.Supplemental) + ","
                             + POut.Int((int)ClaimProcStatus.CapClaim) + @") 
					AND claimproc.DateEntry <= "                     + POut.Date(DateTime.Now) + @" 
					AND claimproc.DateEntry >= "                     + POut.Date(DateTime.Now.AddMonths(-1)) + @")
				) partialpayments"                ;//claimproc.DateEntry is updated when payment is received.

            return(PIn.Int(Db.GetCount(command), false));
        }
Exemple #9
0
        ///<summary>Surround with try/catch.  Checks dependencies first.  Throws exception if can't delete.</summary>
        public static void Delete(long labCaseNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), labCaseNum);
                return;
            }
            //check for dependencies
            string command = "SELECT count(*) FROM sheet,sheetfield "
                             + "WHERE sheet.SheetNum=sheetfield.SheetNum"
                             + " AND sheet.PatNum= (SELECT PatNum FROM labcase WHERE labcase.LabCaseNum=" + POut.Long(labCaseNum) + ")"
                             + " AND sheet.SheetType=" + POut.Long((int)SheetTypeEnum.LabSlip)
                             + " AND sheet.IsDeleted=0 "
                             + " AND sheetfield.FieldType=" + POut.Long((int)SheetFieldType.Parameter)
                             + " AND sheetfield.FieldName='LabCaseNum' "
                             + "AND sheetfield.FieldValue='" + POut.Long(labCaseNum) + "'";

            if (PIn.Int(Db.GetCount(command)) != 0)
            {
                throw new Exception(Lans.g("LabCases", "Cannot delete LabCase because lab slip is still attached."));
            }
            //delete
            command = "DELETE FROM labcase WHERE LabCaseNum = " + POut.Long(labCaseNum);
            Db.NonQ(command);
        }
Exemple #10
0
        ///<summary>Surround with try-catch</summary>
        public static void Delete(long employeeNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), employeeNum);
                return;
            }
            //appointment.Assistant will not block deletion
            //schedule.EmployeeNum will not block deletion
            string command = "SELECT COUNT(*) FROM clockevent WHERE EmployeeNum=" + POut.Long(employeeNum);

            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached clock events."));
            }
            command = "SELECT COUNT(*) FROM timeadjust WHERE EmployeeNum=" + POut.Long(employeeNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached time adjustments."));
            }
            command = "SELECT COUNT(*) FROM userod WHERE EmployeeNum=" + POut.Long(employeeNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached user."));
            }
            command = "UPDATE appointment SET Assistant=0 WHERE Assistant=" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "DELETE FROM schedule WHERE EmployeeNum=" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "DELETE FROM employee WHERE EmployeeNum =" + POut.Long(employeeNum);
            Db.NonQ(command);
        }
Exemple #11
0
        ///<summary>Surround with try/catch because it can throw exceptions.  We don't really need to make this public, but it's required in order to follow the RemotingRole pattern.</summary>
        public static void Validate(bool isNew, Userod user, bool excludeHiddenUsers)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), isNew, user, excludeHiddenUsers);
                return;
            }
            //should add a check that employeenum and provnum are not both set.
            //make sure username is not already taken
            string command;
            long   excludeUserNum;

            if (isNew)
            {
                excludeUserNum = 0;
            }
            else
            {
                excludeUserNum = user.UserNum;              //it's ok if the name matches the current username
            }
            //It doesn't matter if the UserName is already in use if the user being updated is going to be hidden.  This check will block them from unhiding duplicate users.
            if (!user.IsHidden)             //if the user is now not hidden
            {
                if (!IsUserNameUnique(user.UserName, excludeUserNum, excludeHiddenUsers))
                {
                    throw new Exception(Lans.g("Userods", "UserName already in use."));
                }
            }
            //make sure that there would still be at least one user with security admin permissions
            if (!isNew)
            {
                command = "SELECT COUNT(*) FROM grouppermission "
                          + "WHERE PermType='" + POut.Long((int)Permissions.SecurityAdmin) + "' "
                          + "AND UserGroupNum=" + POut.Long(user.UserGroupNum);
                if (Db.GetCount(command) == "0")              //if this user would not have admin
                //make sure someone else has admin
                {
                    command = "SELECT COUNT(*) FROM userod,grouppermission "
                              + "WHERE grouppermission.PermType='" + POut.Long((int)Permissions.SecurityAdmin) + "'"
                              + " AND userod.UserGroupNum=grouppermission.UserGroupNum"
                              + " AND userod.IsHidden =0"
                              + " AND userod.UserNum != " + POut.Long(user.UserNum);
                    if (Db.GetCount(command) == "0")                  //there are no other users with this permission
                    {
                        throw new Exception(Lans.g("Users", "At least one user must have Security Admin permission."));
                    }
                }
            }
            //an admin user can never be hidden
            command = "SELECT COUNT(*) FROM grouppermission "
                      + "WHERE PermType='" + POut.Long((int)Permissions.SecurityAdmin) + "' "
                      + "AND UserGroupNum=" + POut.Long(user.UserGroupNum);
            if (Db.GetCount(command) != "0" &&      //if this user is admin
                user.IsHidden)                   //and hidden
            {
                throw new Exception(Lans.g("Userods", "Admins cannot be hidden."));
            }
        }
Exemple #12
0
        ///<summary>Throws exception if account is in use.</summary>
        public static void Delete(Account acct)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), acct);
                return;
            }
            //check to see if account has any journal entries
            string command = "SELECT COUNT(*) FROM journalentry WHERE AccountNum=" + POut.Long(acct.AccountNum);

            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormAccountEdit",
                                                      "Not allowed to delete an account with existing journal entries."));
            }
            //Check various preference entries
            command = "SELECT ValueString FROM preference WHERE PrefName='AccountingDepositAccounts'";
            string result = Db.GetCount(command);

            string[] strArray = result.Split(new char[] { ',' });
            for (int i = 0; i < strArray.Length; i++)
            {
                if (strArray[i] == acct.AccountNum.ToString())
                {
                    throw new ApplicationException(Lans.g("FormAccountEdit", "Account is in use in the setup section."));
                }
            }
            command = "SELECT ValueString FROM preference WHERE PrefName='AccountingIncomeAccount'";
            result  = Db.GetCount(command);
            if (result == acct.AccountNum.ToString())
            {
                throw new ApplicationException(Lans.g("FormAccountEdit", "Account is in use in the setup section."));
            }
            command = "SELECT ValueString FROM preference WHERE PrefName='AccountingCashIncomeAccount'";
            result  = Db.GetCount(command);
            if (result == acct.AccountNum.ToString())
            {
                throw new ApplicationException(Lans.g("FormAccountEdit", "Account is in use in the setup section."));
            }
            //check AccountingAutoPay entries
            List <AccountingAutoPay> listAutoPays = AccountingAutoPays.GetDeepCopy();

            for (int i = 0; i < listAutoPays.Count; i++)
            {
                strArray = listAutoPays[i].PickList.Split(new char[] { ',' });
                for (int s = 0; s < strArray.Length; s++)
                {
                    if (strArray[s] == acct.AccountNum.ToString())
                    {
                        throw new ApplicationException(Lans.g("FormAccountEdit", "Account is in use in the setup section."));
                    }
                }
            }
            command = "DELETE FROM account WHERE AccountNum = " + POut.Long(acct.AccountNum);
            Db.NonQ(command);
        }
Exemple #13
0
        ///<summary>Check to see if column can be deleted, returns true is the column contains only nulls.</summary>
        public static bool CheckColumnEmpty(string listName, string colName)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), listName, colName));
            }
            string command = "SELECT COUNT(*) FROM wikilist_" + POut.String(listName) + " WHERE " + POut.String(colName) + "!=''";

            return(Db.GetCount(command).Equals("0"));
        }
        public static bool IsSheetDefInUse(long sheetDefNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), sheetDefNum));
            }
            string command = "SELECT COUNT(*) FROM eclipboardsheetdef WHERE SheetDefNum=" + POut.Long(sheetDefNum);

            return(PIn.Int(Db.GetCount(command)) > 0);
        }
Exemple #15
0
        ///<summary></summary>
        public static bool IsReferralAttached(long referralNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), referralNum));
            }
            string command = "SELECT COUNT(*) FROM refattach WHERE ReferralNum = '" + POut.Long(referralNum) + "'";

            return(Db.GetCount(command) != "0");
        }
Exemple #16
0
        /*
         #region CachePattern
         * //This region can be eliminated if this is not a table type with cached data.
         * //If leaving this region in place, be sure to add RefreshCache and FillCache
         * //to the Cache.cs file with all the other Cache types.
         *
         * ///<summary>A list of all RxNorms.</summary>
         * private static List<RxNorm> listt;
         *
         * ///<summary>A list of all RxNorms.</summary>
         * public static List<RxNorm> Listt{
         *      get {
         *              if(listt==null) {
         *                      RefreshCache();
         *              }
         *              return listt;
         *      }
         *      set {
         *              listt=value;
         *      }
         * }
         *
         * ///<summary></summary>
         * public static DataTable RefreshCache(){
         *      //No need to check RemotingRole; Calls GetTableRemotelyIfNeeded().
         *      string command="SELECT * FROM rxnorm ORDER BY ItemOrder";//stub query probably needs to be changed
         *      DataTable table=Cache.GetTableRemotelyIfNeeded(MethodBase.GetCurrentMethod(),command);
         *      table.TableName="RxNorm";
         *      FillCache(table);
         *      return table;
         * }
         *
         * ///<summary></summary>
         * public static void FillCache(DataTable table){
         *      //No need to check RemotingRole; no call to db.
         *      listt=Crud.RxNormCrud.TableToList(table);
         * }
         #endregion*/

        public static bool IsRxNormTableEmpty()
        {
            string command = "SELECT COUNT(*) FROM rxnorm";

            if (Db.GetCount(command) == "0")
            {
                return(true);
            }
            return(false);
        }
Exemple #17
0
        ///<summary>Returns true if there is already a conference room with the passed in extension within the database.  Otherwise false.</summary>
        public static bool HasConfRoom(long confRoomExtension)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), confRoomExtension));
            }
            string command = "SELECT COUNT(*) FROM phoneconf WHERE Extension=" + POut.Long(confRoomExtension);

            return(Db.GetCount(command) != "0");
        }
        ///<summary>Returns true if a provider with the same last and first name passed in has ever had an EHR prov key.</summary>
        public static bool HasProvHadKey(string lName, string fName)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), lName, fName));
            }
            string command = "SELECT COUNT(*) FROM ehrprovkey WHERE ehrprovkey.LName='" + POut.String(lName) + "' AND ehrprovkey.FName='" + POut.String(fName) + "'";

            return(Db.GetCount(command) != "0");
        }
Exemple #19
0
        ///<summary>Counts the number of fees in the db for this fee sched, including all clinic and prov overrides.</summary>
        public static int GetCountByFeeSchedNum(long feeSchedNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), feeSchedNum));
            }
            string command = "SELECT COUNT(*) FROM fee WHERE FeeSched =" + POut.Long(feeSchedNum);

            return(PIn.Int(Db.GetCount(command)));
        }
Exemple #20
0
        public static int GetUserNameCount(string userName, UserWebFKeyType fkeyType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), userName, fkeyType));
            }
            string command = "SELECT COUNT(*) FROM userweb WHERE UserName='******' AND FKeyType=" + POut.Int((int)fkeyType);

            return(PIn.Int(Db.GetCount(command)));
        }
Exemple #21
0
        public static int GetCountForPatient(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = "SELECT COUNT(*) FROM medlab WHERE PatNum=" + POut.Long(patNum);

            return(PIn.Int(Db.GetCount(command)));
        }
Exemple #22
0
        ///<summary>Returns true if there are any rows that have a Note with char length greater than 65,535</summary>
        public static bool HasAnyLongNotes()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod()));
            }
            string command = "SELECT COUNT(*) FROM commlog WHERE CHAR_LENGTH(commlog.Note)>65535";

            return(Db.GetCount(command) != "0");
        }
Exemple #23
0
        ///<summary></summary>
        public static int GetCountBySubNum(long insSubNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), insSubNum));
            }
            string command = "SELECT COUNT(*) FROM patplan WHERE InsSubNum='" + POut.Long(insSubNum) + "'";

            return(PIn.Int(Db.GetCount(command)));
        }
Exemple #24
0
        ///<summary>Returns the total count of CDCREC codes.  CDCREC codes cannot be hidden.</summary>
        public static long GetCodeCount()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod()));
            }
            string command = "SELECT COUNT(*) FROM cdcrec";

            return(PIn.Long(Db.GetCount(command)));
        }
Exemple #25
0
        ///<summary>Returns true if this PatNum is currently linked to a MobileAppDevice row.</summary>
        public static bool PatientIsAlreadyUsingDevice(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = $"SELECT COUNT(*) FROM mobileappdevice WHERE PatNum={POut.Long(patNum)}";

            return(PIn.Long(Db.GetCount(command)) > 0);
        }
Exemple #26
0
        ///<summary>Returns the login attempts for the given user in the last X minutes.</summary>
        public static int CountForUser(string userName, UserWebFKeyType type, int lastXMinutes)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <int>(MethodBase.GetCurrentMethod(), userName, type, lastXMinutes));
            }
            string command = $@"SELECT COUNT(*) FROM loginattempt WHERE UserName='******' AND LoginType={POut.Int((int)type)}
				AND DateTFail >= {DbHelper.DateAddMinute("NOW()",POut.Int(-lastXMinutes))}"                ;

            return(PIn.Int(Db.GetCount(command)));
        }
Exemple #27
0
        ///<summary>Surround with try-catch</summary>
        public static void Delete(long employeeNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), employeeNum);
                return;
            }
            //appointment.Assistant will not block deletion
            //schedule.EmployeeNum will not block deletion
            string command = "SELECT COUNT(*) FROM clockevent WHERE EmployeeNum=" + POut.Long(employeeNum);

            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached clock events."));
            }
            command = "SELECT COUNT(*) FROM timeadjust WHERE EmployeeNum=" + POut.Long(employeeNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached time adjustments."));
            }
            command = "SELECT COUNT(*) FROM userod WHERE EmployeeNum=" + POut.Long(employeeNum);
            if (Db.GetCount(command) != "0")
            {
                throw new ApplicationException(Lans.g("FormEmployeeSelect",
                                                      "Not allowed to delete employee because of attached user."));
            }
            command = "UPDATE appointment SET Assistant=0 WHERE Assistant=" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "SELECT ScheduleNum FROM schedule WHERE EmployeeNum=" + POut.Long(employeeNum);
            DataTable     table            = Db.GetTable(command);
            List <string> listScheduleNums = new List <string>();        //Used for deleting scheduleops below

            for (int i = 0; i < table.Rows.Count; i++)
            {
                //Add entry to deletedobjects table if it is a provider schedule type
                DeletedObjects.SetDeleted(DeletedObjectType.ScheduleProv, PIn.Long(table.Rows[i]["ScheduleNum"].ToString()));
                listScheduleNums.Add(table.Rows[i]["ScheduleNum"].ToString());
            }
            if (listScheduleNums.Count > 0)
            {
                command = "DELETE FROM scheduleop WHERE ScheduleNum IN(" + POut.String(String.Join(",", listScheduleNums)) + ")";
                Db.NonQ(command);
            }
            //command="DELETE FROM scheduleop WHERE ScheduleNum IN(SELECT ScheduleNum FROM schedule WHERE EmployeeNum="+POut.Long(employeeNum)+")";
            //Db.NonQ(command);
            command = "DELETE FROM schedule WHERE EmployeeNum=" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "DELETE FROM employee WHERE EmployeeNum =" + POut.Long(employeeNum);
            Db.NonQ(command);
            command = "DELETE FROM timecardrule WHERE EmployeeNum=" + POut.Long(employeeNum);
            Db.NonQ(command);
        }
Exemple #28
0
        ///<summary>Returns the number of refattaches that this referral has.</summary>
        public static int CountReferralAttach(long referralNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetInt(MethodBase.GetCurrentMethod(), referralNum));
            }
            string command = "SELECT COUNT(*) FROM refattach "
                             + "WHERE ReferralNum=" + POut.Long(referralNum);

            return(PIn.Int(Db.GetCount(command)));
        }
        ///<summary>Since repeating charges are saved using the ProcCode of the procedurecode table instead of the PK, this method will join on the
        ///procedurecode table in order to see if the procCode passed in is linked to within the eservicecodelink table.
        ///Returns true if there are any links to the procedure code passed in.  This method and class are only used by HQ.</summary>
        public static bool IsProcCodeAnEService(string procCode)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), procCode));
            }
            string command = @"SELECT COUNT(*) FROM eservicecodelink
				INNER JOIN procedurecode ON eservicecodelink.CodeNum=procedurecode.CodeNum
				WHERE procedurecode.ProcCode='"                 + POut.String(procCode) + "'";

            return(Db.GetCount(command) != "0");
        }
        ///<summary>Called whenever user wants to edit patient info.  Not allowed to if patient edit window is open at a terminal.  Once patient is done
        ///at terminal, then staff allowed back into patient edit window.</summary>
        public static bool PatIsInUse(long patNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), patNum));
            }
            string command = "SELECT COUNT(*) FROM terminalactive WHERE PatNum=" + POut.Long(patNum)
                             + " AND (TerminalStatus=" + POut.Long((int)TerminalStatusEnum.PatientInfo)
                             + " OR TerminalStatus=" + POut.Long((int)TerminalStatusEnum.UpdateOnly) + ")";

            return(Db.GetCount(command) != "0");
        }