Ejemplo n.º 1
0
        ///<summary>Takes a list of fees to be deleted and deletes them from rest of the clinics in the feeschedgroup.</summary>
        public static void DeleteGroupFees(List <Fee> listFees)
        {
            //No need to check RemotingRole; no call to db.
            List <long> listFeeNumsToDelete = new List <long>();

            foreach (Fee feeCur in listFees)
            {
                FeeSchedGroup groupCur = GetOneForFeeSchedAndClinic(feeCur.FeeSched, feeCur.ClinicNum);
                if (groupCur == null)
                {
                    continue;
                }
                //Go through the clinics in the group and delete the fee.
                foreach (long clinicNum in groupCur.ListClinicNumsAll)
                {
                    //Skip fees passed into this method, they will be deleted elsewhere by FeeCrud
                    if (clinicNum == feeCur.ClinicNum)
                    {
                        continue;
                    }
                    Fee feeToDelete = Fees.GetFeeFromDb(feeCur.CodeNum, feeCur.FeeSched, clinicNum, feeCur.ProvNum, true);
                    if (feeToDelete != null)
                    {
                        listFeeNumsToDelete.Add(feeToDelete.FeeNum);
                    }
                }
            }
            Fees.DeleteMany(listFeeNumsToDelete, false);
        }
Ejemplo n.º 2
0
        ///<summary>If there is nothing in _queueFeeUdpates, reset _hasTransStarted to false and return.
        ///If all items in _queueFeeUpdates are Inserts, do a bulk insert to save time.
        ///If all items in _queueFeeUpdates are Deletes, do a bulk delete to save time.
        ///Otherwise, we need to loop through the list of updates and save them to the db, as order matters for these operations.
        ///Set signalods invalid for each distinct fee schedule represented in _queueFeeUpdates and re-initialize the static cache used by the Fees class.
        ///Finally, set _hasTransStarted back to false and clear _queueFeeUpdates.</summary>
        public void SaveToDb()
        {
            if (_queueFeeUpdates == null || _queueFeeUpdates.Count == 0)
            {
                _hasTransStarted = false;
                return;
            }
            List <long> listFeeScheds = new List <long>();

            if (_queueFeeUpdates.All(x => x.UpdateType == FeeUpdateType.Add))            //all updates are inserts, so do bulk insert
            {
                listFeeScheds = _queueFeeUpdates.Select(x => x.Fee.FeeSched).Distinct().ToList();
                Fees.InsertMany(_queueFeeUpdates.Select(x => (Fee)x.Fee).ToList());
            }
            else if (_queueFeeUpdates.All(x => x.UpdateType == FeeUpdateType.Remove))            //all updates are removes, so do bulk delete
            {
                listFeeScheds = _queueFeeUpdates.Select(x => x.Fee.FeeSched).Distinct().ToList();
                Fees.DeleteMany(_queueFeeUpdates.Select(x => x.Fee.FeeNum).ToList());
            }
            else               //There is a mixture of Add, Removes, and Updates
            {
                listFeeScheds = Fees.UpdateFromCache(_queueFeeUpdates.ToList());
            }
            foreach (long feeSched in listFeeScheds)
            {
                Signalods.SetInvalid(InvalidType.Fees, KeyType.FeeSched, feeSched);
            }
            Fees.InvalidateFeeSchedules(listFeeScheds);
            _hasTransStarted = false;
            _queueFeeUpdates = new ConcurrentQueue <FeeUpdate>();         //clear the list of updates
        }
Ejemplo n.º 3
0
        ///<summary>Deletes FeeScheds that are hidden and not attached to any insurance plans.  Returns the number of deleted fee scheds.</summary>
        public static long CleanupAllowedScheds()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetLong(MethodBase.GetCurrentMethod()));
            }
            long result;
            //Detach allowed FeeSchedules from any hidden InsPlans.
            string command = "UPDATE insplan "
                             + "SET AllowedFeeSched=0 "
                             + "WHERE IsHidden=1";

            Db.NonQ(command);
            //Delete unattached FeeSchedules.
            command = "DELETE FROM feesched "
                      + "WHERE FeeSchedNum NOT IN (SELECT AllowedFeeSched FROM insplan) "
                      + "AND FeeSchedType=" + POut.Int((int)FeeScheduleType.OutNetwork);
            result = Db.NonQ(command);
            //Delete all orphaned fees.
            command = "SELECT FeeNum FROM fee "
                      + "WHERE FeeSched NOT IN (SELECT FeeSchedNum FROM feesched)";
            List <long> listFeeNums = Db.GetListLong(command);

            Fees.DeleteMany(listFeeNums);
            return(result);
        }
Ejemplo n.º 4
0
        ///<summary>Used to check whether codes starting with T exist and are in a visible category.  If so, it moves them to the Obsolete category.  If the T code has never been used, then it deletes it.</summary>
        public static void TcodesClear()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            //first delete any unused T codes
            string        command         = @"SELECT CodeNum,ProcCode FROM procedurecode
				WHERE CodeNum NOT IN(SELECT CodeNum FROM procedurelog)
				AND CodeNum NOT IN(SELECT CodeNum FROM autocodeitem)
				AND CodeNum NOT IN(SELECT CodeNum FROM procbuttonitem)
				AND CodeNum NOT IN(SELECT CodeNum FROM recalltrigger)
				AND CodeNum NOT IN(SELECT CodeNum FROM benefit)
				AND ProcCode NOT IN(SELECT CodeValue FROM encounter WHERE CodeSystem='CDT')
				AND ProcCode LIKE 'T%'"                ;
            DataTable     table           = Db.GetTable(command);
            List <long>   listCodeNums    = new List <long>();
            List <string> listRecallCodes = RecallTypes.GetDeepCopy()
                                            .SelectMany(x => x.Procedures.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                                            .ToList();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (!listRecallCodes.Contains(PIn.String(table.Rows[i]["ProcCode"].ToString())))                 //The ProcCode is not attached to a recall type.
                {
                    listCodeNums.Add(PIn.Long(table.Rows[i]["CodeNum"].ToString()));
                }
            }
            if (listCodeNums.Count > 0)
            {
                ProcedureCodes.ClearFkey(listCodeNums);                //Zero securitylog FKey column for rows to be deleted.
                command = "SELECT FeeNum FROM fee WHERE CodeNum IN(" + String.Join(",", listCodeNums) + ")";
                List <long> listFeeNums = Db.GetListLong(command);
                Fees.DeleteMany(listFeeNums);
                command = "DELETE FROM proccodenote WHERE CodeNum IN(" + String.Join(",", listCodeNums) + ")";
                Db.NonQ(command);
                command = "DELETE FROM procedurecode WHERE CodeNum IN(" + String.Join(",", listCodeNums) + ")";
                Db.NonQ(command);
            }
            //then, move any other T codes to obsolete category
            command = @"SELECT DISTINCT ProcCat FROM procedurecode,definition 
				WHERE procedurecode.ProcCode LIKE 'T%'
				AND definition.IsHidden=0
				AND procedurecode.ProcCat=definition.DefNum"                ;
            table   = Db.GetTable(command);
            long catNum = Defs.GetByExactName(DefCat.ProcCodeCats, "Obsolete");         //check to make sure an Obsolete category exists.
            Def  def;

            if (catNum != 0)           //if a category exists with that name
            {
                def = Defs.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
            if (catNum == 0)
            {
                List <Def> listDefs = Defs.GetDefsForCategory(DefCat.ProcCodeCats);
                def           = new Def();
                def.Category  = DefCat.ProcCodeCats;
                def.ItemName  = "Obsolete";
                def.ItemOrder = listDefs.Count;
                def.IsHidden  = true;
                Defs.Insert(def);
                Defs.RefreshCache();
                catNum = def.DefNum;
            }
            for (int i = 0; i < table.Rows.Count; i++)
            {
                command = "UPDATE procedurecode SET ProcCat=" + POut.Long(catNum)
                          + " WHERE ProcCat=" + table.Rows[i][0].ToString()
                          + " AND procedurecode.ProcCode LIKE 'T%'";
                Db.NonQ(command);
            }
            //finally, set Never Used category to be hidden.  This isn't really part of clearing Tcodes, but is required
            //because many customers won't have that category hidden
            catNum = Defs.GetByExactName(DefCat.ProcCodeCats, "Never Used");
            if (catNum != 0)           //if a category exists with that name
            {
                def = Defs.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
        }