Beispiel #1
0
        ///<summary>Returns the named def.  If it can't find the name, then it returns the first def in the category.</summary>
        public static long GetByExactNameNeverZero(DefCat myCat, string itemName)
        {
            //No need to check RemotingRole; no call to db.
            List <Def> listDefs = Defs.GetDefsForCategory(myCat);
            Def        def;

            //We have been getting bug submissions from customers where listDefs will be null (e.g. DefCat.ProviderSpecialties cat itemName "General")
            //Therefore, we should check for null or and entirely empty category first before looking for a match.
            if (listDefs == null || listDefs.Count == 0)
            {
                //There are no defs for the category passed in, create one because this method should never return zero.
                def           = new Def();
                def.Category  = myCat;
                def.ItemOrder = 0;
                def.ItemName  = itemName;
                Defs.Insert(def);
                Defs.RefreshCache();
                return(def.DefNum);
            }
            //From this point on, we know our list of definitions contains at least one def.
            def = listDefs.FirstOrDefault(x => x.ItemName == itemName);
            if (def != null)
            {
                return(def.DefNum);
            }
            //Couldn't find a match so return the first definition from our list as a last resort.
            return(listDefs[0].DefNum);
        }
Beispiel #2
0
 ///<summary>Returns the named def.  If it can't find the name, then it returns the first def in the category.</summary>
 public static long GetByExactNameNeverZero(DefCat myCat, string itemName)
 {
     if (itemName == "")
     {
         return(DefC.Long[(int)myCat][0].DefNum);               //return the first one in the list
     }
     for (int i = 0; i < DefC.Long[(int)myCat].GetLength(0); i++)
     {
         if (DefC.Long[(int)myCat][i].ItemName == itemName)
         {
             return(DefC.Long[(int)myCat][i].DefNum);
         }
     }
     if (DefC.Long[(int)myCat].Length == 0)
     {
         Def def = new Def();
         def.Category  = myCat;
         def.ItemOrder = 0;
         def.ItemName  = itemName;
         Defs.Insert(def);
         Defs.RefreshCache();
     }
     return(DefC.Long[(int)myCat][0].DefNum);           //return the first one in the list
 }
Beispiel #3
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 NOT EXISTS(SELECT * FROM procedurelog WHERE procedurelog.CodeNum=procedurecode.CodeNum)
				AND ProcCode LIKE 'T%'"                ;
            DataTable table   = Db.GetTable(command);
            long      codenum;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                codenum = PIn.Long(table.Rows[i]["CodeNum"].ToString());
                command = "DELETE FROM fee WHERE CodeNum=" + POut.Long(codenum);
                Db.NonQ(command);
                command = "DELETE FROM procedurecode WHERE CodeNum=" + POut.Long(codenum);
                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 = DefC.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 = DefC.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
            if (catNum == 0)
            {
                def           = new Def();
                def.Category  = DefCat.ProcCodeCats;
                def.ItemName  = "Obsolete";
                def.ItemOrder = DefC.Long[(int)DefCat.ProcCodeCats].Length;
                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 = DefC.GetByExactName(DefCat.ProcCodeCats, "Never Used");
            if (catNum != 0)           //if a category exists with that name
            {
                def = DefC.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
        }
Beispiel #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();
                }
            }
        }
Beispiel #5
0
        ///<summary>If ClientWeb, then this method is instead run on the server, and the result passed back to the client.  And since it's ClientWeb, FillCache will be run on the client.</summary>
        public static DataSet GetCacheDs(string itypesStr)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetDS(MethodBase.GetCurrentMethod(), itypesStr));
            }
            //so this part below only happens if direct or server------------------------------------------------
            List <int> itypes = new List <int>();

            string[] strArray = itypesStr.Split(',');
            for (int i = 0; i < strArray.Length; i++)
            {
                itypes.Add(PIn.Int(strArray[i]));
            }
            bool isAll = false;

            if (itypes.Contains((int)InvalidType.AllLocal))
            {
                isAll = true;
            }
            DataSet ds = new DataSet();

            if (itypes.Contains((int)InvalidType.AccountingAutoPays) || isAll)
            {
                ds.Tables.Add(AccountingAutoPays.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.AutoCodes) || isAll)
            {
                ds.Tables.Add(AutoCodes.RefreshCache());
                ds.Tables.Add(AutoCodeItems.RefreshCache());
                ds.Tables.Add(AutoCodeConds.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Automation) || isAll)
            {
                ds.Tables.Add(Automations.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.AutoNotes) || isAll)
            {
                ds.Tables.Add(AutoNotes.RefreshCache());
                ds.Tables.Add(AutoNoteControls.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Carriers) || isAll)
            {
                ds.Tables.Add(Carriers.RefreshCache());                //run on startup, after telephone reformat, after list edit.
            }
            if (itypes.Contains((int)InvalidType.ClaimForms) || isAll)
            {
                ds.Tables.Add(ClaimFormItems.RefreshCache());
                ds.Tables.Add(ClaimForms.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ClearHouses) || isAll)
            {
                ds.Tables.Add(Clearinghouses.RefreshCache());                //kh wants to add an EasyHideClearHouses to disable this
            }
            if (itypes.Contains((int)InvalidType.Computers) || isAll)
            {
                ds.Tables.Add(Computers.RefreshCache());
                ds.Tables.Add(Printers.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Defs) || isAll)
            {
                ds.Tables.Add(Defs.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.DentalSchools) || isAll)
            {
                ds.Tables.Add(SchoolClasses.RefreshCache());
                ds.Tables.Add(SchoolCourses.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.DictCustoms) || isAll)
            {
                ds.Tables.Add(DictCustoms.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Diseases) || isAll)
            {
                ds.Tables.Add(DiseaseDefs.RefreshCache());
                ds.Tables.Add(ICD9s.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.DisplayFields) || isAll)
            {
                ds.Tables.Add(DisplayFields.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ElectIDs) || isAll)
            {
                ds.Tables.Add(ElectIDs.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Email) || isAll)
            {
                ds.Tables.Add(EmailAddresses.RefreshCache());
                ds.Tables.Add(EmailTemplates.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Employees) || isAll)
            {
                ds.Tables.Add(Employees.RefreshCache());
                ds.Tables.Add(PayPeriods.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Employers) || isAll)
            {
                ds.Tables.Add(Employers.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Fees) || isAll)
            {
                ds.Tables.Add(Fees.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.FeeScheds) || isAll)
            {
                ds.Tables.Add(FeeScheds.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.HL7Defs) || isAll)
            {
                ds.Tables.Add(HL7Defs.RefreshCache());
                ds.Tables.Add(HL7DefMessages.RefreshCache());
                ds.Tables.Add(HL7DefSegments.RefreshCache());
                ds.Tables.Add(HL7DefFields.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.InsCats) || isAll)
            {
                ds.Tables.Add(CovCats.RefreshCache());
                ds.Tables.Add(CovSpans.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.InsFilingCodes) || isAll)
            {
                ds.Tables.Add(InsFilingCodes.RefreshCache());
                ds.Tables.Add(InsFilingCodeSubtypes.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Languages) || isAll)
            {
                if (CultureInfo.CurrentCulture.Name != "en-US")
                {
                    ds.Tables.Add(Lans.RefreshCache());
                }
            }
            if (itypes.Contains((int)InvalidType.Letters) || isAll)
            {
                ds.Tables.Add(Letters.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.LetterMerge) || isAll)
            {
                ds.Tables.Add(LetterMergeFields.RefreshCache());
                ds.Tables.Add(LetterMerges.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Operatories) || isAll)
            {
                ds.Tables.Add(Operatories.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.PatFields) || isAll)
            {
                ds.Tables.Add(PatFieldDefs.RefreshCache());
                ds.Tables.Add(ApptFieldDefs.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Pharmacies) || isAll)
            {
                ds.Tables.Add(Pharmacies.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Prefs) || isAll)
            {
                ds.Tables.Add(Prefs.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ProcButtons) || isAll)
            {
                ds.Tables.Add(ProcButtons.RefreshCache());
                ds.Tables.Add(ProcButtonItems.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ProcCodes) || isAll)
            {
                ds.Tables.Add(ProcedureCodes.RefreshCache());
                ds.Tables.Add(ProcCodeNotes.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Programs) || isAll)
            {
                ds.Tables.Add(Programs.RefreshCache());
                ds.Tables.Add(ProgramProperties.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ProviderIdents) || isAll)
            {
                ds.Tables.Add(ProviderIdents.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Providers) || isAll)
            {
                ds.Tables.Add(Providers.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.QuickPaste) || isAll)
            {
                ds.Tables.Add(QuickPasteNotes.RefreshCache());
                ds.Tables.Add(QuickPasteCats.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.RecallTypes) || isAll)
            {
                ds.Tables.Add(RecallTypes.RefreshCache());
                ds.Tables.Add(RecallTriggers.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ReplicationServers) || isAll)
            {
                ds.Tables.Add(ReplicationServers.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Security) || isAll)
            {
                ds.Tables.Add(Userods.RefreshCache());
                ds.Tables.Add(UserGroups.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Sheets) || isAll)
            {
                ds.Tables.Add(SheetDefs.RefreshCache());
                ds.Tables.Add(SheetFieldDefs.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Signals) || isAll)
            {
                ds.Tables.Add(SigElementDefs.RefreshCache());
                ds.Tables.Add(SigButDefs.RefreshCache());                //includes SigButDefElements.Refresh()
            }
            if (itypes.Contains((int)InvalidType.Sites) || isAll)
            {
                ds.Tables.Add(Sites.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Sops) || isAll)
            {
                ds.Tables.Add(Sops.RefreshCache());
            }
            //InvalidTypes.Tasks not handled here.
            if (itypes.Contains((int)InvalidType.TimeCardRules) || isAll)
            {
                ds.Tables.Add(TimeCardRules.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ToolBut) || isAll)
            {
                ds.Tables.Add(ToolButItems.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Vaccines) || isAll)
            {
                ds.Tables.Add(VaccineDefs.RefreshCache());
                ds.Tables.Add(DrugManufacturers.RefreshCache());
                ds.Tables.Add(DrugUnits.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Views) || isAll)
            {
                ds.Tables.Add(ApptViews.RefreshCache());
                ds.Tables.Add(ApptViewItems.RefreshCache());
                ds.Tables.Add(AppointmentRules.RefreshCache());
                ds.Tables.Add(ProcApptColors.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.Wiki) || isAll)
            {
                ds.Tables.Add(WikiListHeaderWidths.RefreshCache());
                ds.Tables.Add(WikiPages.RefreshCache());
            }
            if (itypes.Contains((int)InvalidType.ZipCodes) || isAll)
            {
                ds.Tables.Add(ZipCodes.RefreshCache());
            }
            return(ds);
        }