Exemplo n.º 1
0
        ///<summary>schedI is the currently displayed index of the fee schedule to save to.  If an amt of -1 is passed in, then it indicates a "blank" entry which will cause deletion of any existing fee.</summary>
        public static void Import(string codeText, double amt, long feeSchedNum)
        {
            //No need to check RemotingRole; no call to db.
            if (!ProcedureCodes.IsValidCode(codeText))
            {
                return;                //skip for now. Possibly insert a code in a future version.
            }
            long feeNum = GetFeeNum(ProcedureCodes.GetCodeNum(codeText), feeSchedNum);

            if (feeNum > 0)
            {
                Delete(feeNum);
            }
            if (amt == -1)
            {
                //RefreshCache();
                return;
            }
            Fee fee = new Fee();

            fee.Amount   = amt;
            fee.FeeSched = feeSchedNum;
            fee.CodeNum  = ProcedureCodes.GetCodeNum(codeText);
            Insert(fee);
            //RefreshCache();//moved this outside the loop
        }
Exemplo n.º 2
0
        ///<summary>This method will remove and/or add a fee for the fee information passed in.
        ///codeText will typically be one valid procedure code.  E.g. D1240
        ///If an amt of -1 is passed in, then it indicates a "blank" entry which will cause deletion of any existing fee.
        ///Returns listFees back after importing the passed in fee information.
        ///Does not make any database calls.  This is left up to the user to take action on the list of fees returned.
        ///Also, makes security log entries based on how the fee changed.  Does not make a log for codes that were removed (user already warned)</summary>
        public static List <Fee> Import(string codeText, double amt, long feeSchedNum, long clinicNum, long provNum, List <Fee> listFees)
        {
            //No need to check RemotingRole; no call to db.
            if (!ProcedureCodes.IsValidCode(codeText))
            {
                return(listFees);               //skip for now. Possibly insert a code in a future version.
            }
            string   feeOldStr    = "";
            long     codeNum      = ProcedureCodes.GetCodeNum(codeText);
            Fee      fee          = listFees.FirstOrDefault(x => x.CodeNum == codeNum && x.FeeSched == feeSchedNum && x.ClinicNum == clinicNum && x.ProvNum == provNum);
            DateTime datePrevious = DateTime.MinValue;

            if (fee != null)
            {
                feeOldStr    = Lans.g("FormFeeSchedTools", "Old Fee") + ": " + fee.Amount.ToString("c") + ", ";
                datePrevious = fee.SecDateTEdit;
                listFees.Remove(fee);
            }
            if (amt == -1)
            {
                return(listFees);
            }
            fee           = new Fee();
            fee.Amount    = amt;
            fee.FeeSched  = feeSchedNum;
            fee.CodeNum   = ProcedureCodes.GetCodeNum(codeText);
            fee.ClinicNum = clinicNum;    //Either 0 because you're importing on an HQ schedule or local clinic because the feesched is localizable.
            fee.ProvNum   = provNum;
            listFees.Add(fee);            //Insert new fee specific to the active clinic.
            SecurityLogs.MakeLogEntry(Permissions.ProcFeeEdit, 0, Lans.g("FormFeeSchedTools", "Procedure") + ": " + codeText + ", " + feeOldStr
                                      + Lans.g("FormFeeSchedTools", "New Fee") + ": " + amt.ToString("c") + ", "
                                      + Lans.g("FormFeeSchedTools", "Fee Schedule") + ": " + FeeScheds.GetDescription(feeSchedNum) + ". "
                                      + Lans.g("FormFeeSchedTools", "Fee changed using the Import button in the Fee Tools window."), ProcedureCodes.GetCodeNum(codeText),
                                      DateTime.MinValue);
            SecurityLogs.MakeLogEntry(Permissions.LogFeeEdit, 0, "Fee changed", fee.FeeNum, datePrevious);
            return(listFees);
        }
Exemplo n.º 3
0
        /// <summary>Deletes the current recalltype and recalltrigger tables and fills them with our default.  Typically ran to switch T codes to D codes.</summary>
        public static void SetToDefault()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            string command = "DELETE FROM recalltype WHERE RecallTypeNum >= 1 AND RecallTypeNum <= 6";          //Don't delete manually added recall types

            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,TimePattern,Procedures) VALUES (1,'Prophy',393217,'/XXXX/','D0120,D1110')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,TimePattern,Procedures) VALUES (2,'Child Prophy',0,'XXX','D0120,D1120,D1208')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,TimePattern,Procedures) VALUES (3,'Perio',262144,'/XXXX/','D4910')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,Procedures,AppendToSpecial) VALUES (4,'4BW',16777216,'D0274',1)";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,Procedures,AppendToSpecial) VALUES (5,'Pano',83886080,'D0330',1)";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,Procedures,AppendToSpecial) VALUES (6,'FMX',83886080,'D0210',1)";
            Db.NonQ(command);
            command = "DELETE FROM recalltrigger";          //OK to delete triggers for manually added recalls, because deleting the triggers disables the recall type.
            Db.NonQ(command);
            //command="INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (1,1,"+ProcedureCodes.GetCodeNum("D0415")+")";//collection of microorg for culture
            //Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (1,1," + ProcedureCodes.GetCodeNum("D0150") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (2,4," + ProcedureCodes.GetCodeNum("D0274") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (3,5," + ProcedureCodes.GetCodeNum("D0330") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (4,6," + ProcedureCodes.GetCodeNum("D0210") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (5,1," + ProcedureCodes.GetCodeNum("D1110") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (6,1," + ProcedureCodes.GetCodeNum("D1120") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (7,3," + ProcedureCodes.GetCodeNum("D4910") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (8,3," + ProcedureCodes.GetCodeNum("D4341") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (9,1," + ProcedureCodes.GetCodeNum("D0120") + ")";
            Db.NonQ(command);
            //Update the special types in preference table.
            command = "UPDATE preference SET ValueString='1' WHERE PrefName='RecallTypeSpecialProphy'";
            Db.NonQ(command);
            command = "UPDATE preference SET ValueString='2' WHERE PrefName='RecallTypeSpecialChildProphy'";
            Db.NonQ(command);
            command = "UPDATE preference SET ValueString='3' WHERE PrefName='RecallTypeSpecialPerio'";
            Db.NonQ(command);
            command = "UPDATE preference SET ValueString='1,2,3' WHERE PrefName='RecallTypesShowingInList'";
            Db.NonQ(command);
            //Delete recalls for manually added recall types.  This is the same strategy we use in FormRecallTypeEdit
            //Types 1 through 6 were reinserted above, and thus the foreign keys will still be correct.
            command = "DELETE FROM recall WHERE RecallTypeNum < 1 OR RecallTypeNum > 6";
            Db.NonQ(command);
        }
Exemplo n.º 4
0
        ///<summary>Gets all possible fees associated with the various objects passed in.  Gets fees from db based on code and fee schedule combos.  Includes all provider overrides.  Includes default/no clinic as well as any specified clinic overrides. Although the list always includes extra fees from scheds that we don't need, it's still a very small list.  That list is then used repeatedly by other code in loops to find the actual individual fee amounts.</summary>
        public static List <Fee> GetListFromObjects(List <ProcedureCode> listProcedureCodes, List <string> listMedicalCodes, List <long> listProvNumsTreat, long patPriProv,
                                                    long patSecProv, long patFeeSched, List <InsPlan> listInsPlans, List <long> listClinicNums, List <Appointment> listAppts,
                                                    List <SubstitutionLink> listSubstLinks, long discountPlan
                                                    //listCodeNums,listProvNumsTreat,listProcCodesProvNumDefault,patPriProv,patSecProv,patFeeSched,listInsPlans,listClinicNums
                                                    //List<long> listProcCodesProvNumDefault
                                                    )
        {
            //listMedicalCodes: it already automatically gets the medical codes from procCodes.  This is just for procs. If no procs yet, it will be null.
            //listMedicalCodes can be done by: listProcedures.Select(x=>x.MedicalCode).ToList();  //this is just the strings
            //One way to get listProvNumsTreat is listProcedures.Select(x=>x.ProvNum).ToList()
            //One way to specify a single provNum in listProvNumsTreat is new List<long>(){provNum}
            //One way to get clinicNums is listProcedures.Select(x=>x.ClinicNum).ToList()
            //Another way to get clinicNums is new List<long>(){clinicNum}.
            //These objects will be cleaned up, so they can have duplicates, zeros, invalid keys, nulls, etc
            //In some cases, we need to pass in a list of appointments to make sure we've included all possible providers, both ProvNum and ProvHyg
            //In that case, it's common to leave listProvNumsTreat null because we clearly do not have any of those providers set yet.
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <Fee> >(MethodBase.GetCurrentMethod(), listProcedureCodes, listMedicalCodes, listProvNumsTreat, patPriProv,
                                                    patSecProv, patFeeSched, listInsPlans, listClinicNums, listAppts, listSubstLinks, discountPlan));
            }
            if (listProcedureCodes == null)
            {
                return(new List <Fee>());
            }
            List <long> listCodeNumsOut = new List <long>();

            foreach (ProcedureCode procedureCode in listProcedureCodes)
            {
                if (procedureCode == null)
                {
                    continue;
                }
                if (!listCodeNumsOut.Contains(procedureCode.CodeNum))
                {
                    listCodeNumsOut.Add(procedureCode.CodeNum);
                }
                if (ProcedureCodes.IsValidCode(procedureCode.MedicalCode))
                {
                    long codeNumMed = ProcedureCodes.GetCodeNum(procedureCode.MedicalCode);
                    if (!listCodeNumsOut.Contains(codeNumMed))
                    {
                        listCodeNumsOut.Add(codeNumMed);
                    }
                }
                if (ProcedureCodes.IsValidCode(procedureCode.SubstitutionCode))
                {
                    long codeNumSub = ProcedureCodes.GetCodeNum(procedureCode.SubstitutionCode);
                    if (!listCodeNumsOut.Contains(codeNumSub))
                    {
                        listCodeNumsOut.Add(codeNumSub);
                    }
                }
            }
            if (listMedicalCodes != null)
            {
                foreach (string strMedCode in listMedicalCodes)
                {
                    if (ProcedureCodes.IsValidCode(strMedCode))
                    {
                        long codeNumMed = ProcedureCodes.GetCodeNum(strMedCode);
                        if (!listCodeNumsOut.Contains(codeNumMed))
                        {
                            listCodeNumsOut.Add(codeNumMed);
                        }
                    }
                }
            }
            if (listSubstLinks != null)
            {
                foreach (SubstitutionLink substitutionLink in listSubstLinks)                //Grab all subst codes, since we don't know which ones we will need.
                {
                    if (ProcedureCodes.IsValidCode(substitutionLink.SubstitutionCode))
                    {
                        long codeNum = ProcedureCodes.GetCodeNum(substitutionLink.SubstitutionCode);
                        if (!listCodeNumsOut.Contains(codeNum))
                        {
                            listCodeNumsOut.Add(codeNum);
                        }
                    }
                }
            }
            //Fee schedules. Will potentially include many.=======================================================================================
            List <long> listFeeScheds = new List <long>();
            //Add feesched for first provider (See Claims.CalculateAndUpdate)---------------------------------------------------------------------
            Provider provFirst = Providers.GetFirst();

            if (provFirst != null && provFirst.FeeSched != 0 && !listFeeScheds.Contains(provFirst.FeeSched))
            {
                listFeeScheds.Add(provFirst.FeeSched);
            }
            //Add feesched for PracticeDefaultProv------------------------------------------------------------------------------------------------
            Provider provPracticeDefault = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));

            if (provPracticeDefault != null && provPracticeDefault.FeeSched != 0 && !listFeeScheds.Contains(provPracticeDefault.FeeSched))
            {
                listFeeScheds.Add(provPracticeDefault.FeeSched);
            }
            //Add feescheds for all treating providers---------------------------------------------------------------------------------------------
            if (listProvNumsTreat != null)
            {
                foreach (long provNumTreat in listProvNumsTreat)
                {
                    Provider provTreat = Providers.GetProv(provNumTreat);
                    if (provTreat != null && provTreat.FeeSched != 0 && !listFeeScheds.Contains(provTreat.FeeSched))
                    {
                        listFeeScheds.Add(provTreat.FeeSched);                        //treating provs fee scheds
                    }
                }
            }
            //Add feescheds for the patient's primary and secondary providers----------------------------------------------------------------------
            Provider providerPatPri = Providers.GetProv(patPriProv);

            if (providerPatPri != null && providerPatPri.FeeSched != 0 && !listFeeScheds.Contains(providerPatPri.FeeSched))
            {
                listFeeScheds.Add(providerPatPri.FeeSched);
            }
            Provider providerPatSec = Providers.GetProv(patSecProv);

            if (providerPatSec != null && providerPatSec.FeeSched != 0 && !listFeeScheds.Contains(providerPatSec.FeeSched))
            {
                listFeeScheds.Add(providerPatSec.FeeSched);
            }
            //Add feescheds for all procedurecode.ProvNumDefaults---------------------------------------------------------------------------------
            foreach (ProcedureCode procedureCode in listProcedureCodes)
            {
                if (procedureCode == null)
                {
                    continue;
                }
                long provNumDefault = procedureCode.ProvNumDefault;
                if (provNumDefault == 0)
                {
                    continue;
                }
                Provider provDefault = Providers.GetProv(provNumDefault);
                if (provDefault != null && provDefault.FeeSched != 0 && !listFeeScheds.Contains(provDefault.FeeSched))
                {
                    listFeeScheds.Add(provDefault.FeeSched);
                }
            }
            //Add feescheds for appointment providers---------------------------------------------------------------------------------------------
            if (listAppts != null)
            {
                foreach (Appointment appointment in listAppts)
                {
                    Provider provAppt = Providers.GetProv(appointment.ProvNum);
                    if (provAppt != null && provAppt.FeeSched != 0 && !listFeeScheds.Contains(provAppt.FeeSched))
                    {
                        listFeeScheds.Add(provAppt.FeeSched);
                    }
                    Provider provApptHyg = Providers.GetProv(appointment.ProvHyg);
                    if (provApptHyg != null && provApptHyg.FeeSched != 0 && !listFeeScheds.Contains(provApptHyg.FeeSched))
                    {
                        listFeeScheds.Add(provApptHyg.FeeSched);
                    }
                }
            }
            //Add feesched for patient.  Rare. --------------------------------------------------------------------------------------------------
            if (patFeeSched != 0)
            {
                if (!listFeeScheds.Contains(patFeeSched))
                {
                    listFeeScheds.Add(patFeeSched);
                }
            }
            //Add feesched for each insplan, both reg and allowed--------------------------------------------------------------------------------
            if (listInsPlans != null)
            {
                foreach (InsPlan insPlan in listInsPlans)
                {
                    if (insPlan.FeeSched != 0 && !listFeeScheds.Contains(insPlan.FeeSched))
                    {
                        listFeeScheds.Add(insPlan.FeeSched);                        //insplan feeSched
                    }
                    if (insPlan.AllowedFeeSched != 0 && !listFeeScheds.Contains(insPlan.AllowedFeeSched))
                    {
                        listFeeScheds.Add(insPlan.AllowedFeeSched);                        //allowed feeSched
                    }
                    if (insPlan.CopayFeeSched != 0 && !listFeeScheds.Contains(insPlan.CopayFeeSched))
                    {
                        listFeeScheds.Add(insPlan.CopayFeeSched);                        //copay feeSched
                    }
                }
            }
            if (discountPlan != 0)
            {
                long discountPlanFeeSched = DiscountPlans.GetPlan(discountPlan).FeeSchedNum;
                if (!listFeeScheds.Contains(discountPlanFeeSched))
                {
                    listFeeScheds.Add(discountPlanFeeSched);
                }
            }
            //ClinicNums========================================================================================================================
            List <long> listClinicNumsOut = new List <long>();        //usually empty or one entry

            if (listClinicNums != null)
            {
                foreach (long clinicNum in listClinicNums)
                {
                    if (clinicNum != 0 && !listClinicNumsOut.Contains(clinicNum))
                    {
                        listClinicNumsOut.Add(clinicNum);                        //proc ClinicNums
                    }
                }
            }
            if (listFeeScheds.Count == 0 || listProcedureCodes.Count == 0)
            {
                return(new List <Fee>());
            }
            string command = "SELECT * FROM fee WHERE (";

            for (int i = 0; i < listFeeScheds.Count; i++)
            {
                if (i > 0)
                {
                    command += " OR ";
                }
                command += "FeeSched=" + POut.Long(listFeeScheds[i]);
            }
            command += ") AND (";
            for (int i = 0; i < listCodeNumsOut.Count; i++)
            {
                if (i > 0)
                {
                    command += " OR ";
                }
                command += "CodeNum=" + POut.Long(listCodeNumsOut[i]);
            }
            command += ") AND (ClinicNum=0";
            for (int i = 0; i < listClinicNumsOut.Count; i++)
            {
                command += " OR ClinicNum=" + POut.Long(listClinicNumsOut[i]);
            }
            command += ")";
            return(Crud.FeeCrud.SelectMany(command));
        }
Exemplo n.º 5
0
 /// <summary>Runs repeating charges for the date passed in, usually today. Can't use 'out' variables because this runs over Middle Tier.</summary>
 public static RepeatChargeResult RunRepeatingCharges(DateTime dateRun)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetObject <RepeatChargeResult>(MethodBase.GetCurrentMethod(), dateRun));
     }
     Prefs.UpdateDateT(PrefName.RepeatingChargesBeginDateTime, dateRun);
     try {
         RepeatChargeResult  result = new RepeatChargeResult();
         List <RepeatCharge> listRepeatingCharges = RepeatCharges.Refresh(0).ToList();
         if (PrefC.IsODHQ)
         {
             //Remove all eService repeating charges.
             //EService charges have already been calculated and stored in EServiceBilling table. Add those here.
             List <string> listEServiceCodes = EServiceCodeLink.GetProcCodesForAll();
             listRepeatingCharges.RemoveAll(x => listEServiceCodes.Contains(x.ProcCode));
             result.ProceduresAddedCount += EServiceBillings.AddEServiceRepeatingChargesHelper(dateRun).Count;
         }
         DateTime startedUsingFKs = UpdateHistories.GetDateForVersion(new Version("16.1.0.0"));              //We started using FKs from procs to repeat charges in 16.1.
         foreach (RepeatCharge repeatCharge in listRepeatingCharges)
         {
             if (!repeatCharge.IsEnabled || (repeatCharge.DateStop.Year > 1880 && repeatCharge.DateStop.AddMonths(3) < dateRun))
             {
                 continue;                        //This repeating charge is too old to possibly create a new charge. Not precise but greatly reduces calls to DB.
                 //We will filter by more stringently on the DateStop later on.
             }
             long codeNum = ProcedureCodes.GetCodeNum(repeatCharge.ProcCode);
             //Must contain all procedures that affect the date range.
             DateTime         procRangeStart    = repeatCharge.DateStart.AddMonths(-1);       //Minus 1 month to catch accounts that have changed their billing date
             List <Procedure> listExistingProcs = Procedures.GetCompletedForDateRange(procRangeStart, dateRun,
                                                                                      new List <long> {
                 codeNum
             },
                                                                                      new List <long> {
                 repeatCharge.PatNum
             });
             for (int j = listExistingProcs.Count - 1; j >= 0; j--)               //iterate backwards to remove elements
             {
                 Procedure proc = listExistingProcs[j];
                 if (((proc.RepeatChargeNum == repeatCharge.RepeatChargeNum)                      //Check the procedure's FK first
                      //Use the old logic without matching FKs only if the procedure was added before updating to 16.1
                      //Match patnum, codenum, fee, year, and month (IsRepeatDateHelper uses special logic to determine correct month)
                      //Procedures with the ProcDate prior to the RepeatCharge.StartDate should not be considered as valid procedures
                      //associated to the current repeat charge.
                      || ((proc.ProcDate < startedUsingFKs || startedUsingFKs.Year < 1880) &&
                          proc.PatNum == repeatCharge.PatNum &&
                          proc.CodeNum == codeNum &&
                          proc.ProcFee.IsEqual(repeatCharge.ChargeAmt))) &&
                     (proc.ProcDate >= repeatCharge.DateStart ||                           //Consider procedures that fall on or after the repeat charge start date.
                      proc.ProcDate.Day != repeatCharge.DateStart.Day)) //Consider procs only when days are not the same. Catches procs that have changed their billing date
                 {
                     continue;                                          //This existing procedure needs to be counted for this repeat charge.
                 }
                 listExistingProcs.RemoveAt(j);                         //Removing so that another repeat charge of the same code, date, and amount will be added.
             }
             List <DateTime> listBillingDates;                          //This list will have 1 or 2 dates where a repeating charge might be added
             if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay))
             {
                 listBillingDates = GetBillingDatesHelper(repeatCharge.DateStart, repeatCharge.DateStop, dateRun, listExistingProcs, repeatCharge,
                                                          Patients.GetPat(repeatCharge.PatNum).BillingCycleDay);
             }
             else
             {
                 listBillingDates = GetBillingDatesHelper(repeatCharge.DateStart, repeatCharge.DateStop, dateRun, listExistingProcs, repeatCharge);
             }
             listBillingDates.RemoveAll(x => x.Date > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed));
             //If any billing dates have not been filtered out, add a repeating charge on those dates
             foreach (DateTime billingDate in listBillingDates)
             {
                 Procedure    procAdded       = AddRepeatingChargeHelper(repeatCharge, billingDate, dateRun);
                 List <Claim> listClaimsAdded = new List <Claim>();
                 if (repeatCharge.CreatesClaim && !ProcedureCodes.GetProcCode(repeatCharge.ProcCode).NoBillIns)
                 {
                     listClaimsAdded = AddClaimsHelper(repeatCharge, procAdded);
                 }
                 result.ProceduresAddedCount++;
                 result.ClaimsAddedCount += listClaimsAdded.Count;
             }
         }
         return(result);
     }
     finally {
         Prefs.UpdateString(PrefName.RepeatingChargesBeginDateTime, "");
     }
 }
Exemplo n.º 6
0
        /// <summary>Deletes the current recalltype and recalltrigger tables and fills them with our default.  Typically ran to switch T codes to D codes.</summary>
        public static void SetToDefault()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            string command = "DELETE FROM recalltype";

            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,TimePattern,Procedures) VALUES (1,'Prophy',393217,'/XXXX/','D0120,D1110')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,TimePattern,Procedures) VALUES (2,'Child Prophy',0,'XXX','D0120,D1120,D1203')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,TimePattern,Procedures) VALUES (3,'Perio',262144,'/XXXX/','D4910')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,Procedures) VALUES (4,'4BW',16777216,'D0274')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,Procedures) VALUES (5,'Pano',83886080,'D0330')";
            Db.NonQ(command);
            command = "INSERT INTO recalltype (RecallTypeNum,Description,DefaultInterval,Procedures) VALUES (6,'FMX',83886080,'D0210')";
            Db.NonQ(command);
            command = "DELETE FROM recalltrigger";
            Db.NonQ(command);
            //command="INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (1,1,"+ProcedureCodes.GetCodeNum("D0415")+")";//collection of microorg for culture
            //Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (1,1," + ProcedureCodes.GetCodeNum("D0150") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (2,4," + ProcedureCodes.GetCodeNum("D0274") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (3,5," + ProcedureCodes.GetCodeNum("D0330") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (4,6," + ProcedureCodes.GetCodeNum("D0210") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (5,1," + ProcedureCodes.GetCodeNum("D1110") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (6,1," + ProcedureCodes.GetCodeNum("D1120") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (7,3," + ProcedureCodes.GetCodeNum("D4910") + ")";
            Db.NonQ(command);
            command = "INSERT INTO recalltrigger (RecallTriggerNum,RecallTypeNum,CodeNum) VALUES (8,3," + ProcedureCodes.GetCodeNum("D4341") + ")";
            Db.NonQ(command);
            //Update the special types in preference table.
            command = "UPDATE preference SET ValueString='1' WHERE PrefName='RecallTypeSpecialProphy'";
            Db.NonQ(command);
            command = "UPDATE preference SET ValueString='2' WHERE PrefName='RecallTypeSpecialChildProphy'";
            Db.NonQ(command);
            command = "UPDATE preference SET ValueString='3' WHERE PrefName='RecallTypeSpecialPerio'";
            Db.NonQ(command);
            command = "UPDATE preference SET ValueString='1,2,3' WHERE PrefName='RecallTypesShowingInList'";
            Db.NonQ(command);
        }
Exemplo n.º 7
0
        ///<summary>Replaces ImportCanadaFeeSchedule.  Imports a canadian fee schedule. Called only in FormFeeSchedTools, located here to allow unit testing.
        ///Fires FeeSchedEvents for a progress bar.</summary>
        public static List <Fee> ImportCanadaFeeSchedule2(FeeSched feeSched, string feeData, long clinicNum, long provNum, out int numImported, out int numSkipped)
        {
            //No need to check RemotingRole; no call to db.
            string[] feeLines = feeData.Split('\n');
            numImported = 0;
            numSkipped  = 0;
            List <Fee> listFees         = Fees.GetListExact(feeSched.FeeSchedNum, clinicNum, provNum);
            List <Fee> listFeesImported = new List <Fee>(listFees);

            for (int i = 0; i < feeLines.Length; i++)
            {
                string[] fields = feeLines[i].Split('\t');
                if (fields.Length > 1)               // && fields[1]!=""){//we no longer skip blank fees
                {
                    string procCode = fields[0];
                    if (ProcedureCodes.IsValidCode(procCode))
                    {
                        long codeNum = ProcedureCodes.GetCodeNum(procCode);
                        Fee  fee     = Fees.GetFee(codeNum, feeSched.FeeSchedNum, clinicNum, provNum, listFees); //gets best match
                        if (fields[1] == "")                                                                     //an empty entry will delete an existing fee, but not insert a blank override
                        {
                            if (fee == null)                                                                     //nothing to do

                            {
                            }
                            else
                            {
                                //doesn't matter if the existing fee is an override or not.
                                Fees.Delete(fee);
                                listFeesImported.Remove(fee);
                            }
                        }
                        else                          //value found in text file
                        {
                            if (fee == null)          //no current fee
                            {
                                fee           = new Fee();
                                fee.Amount    = PIn.Double(fields[1], doUseEnUSFormat: true);                          //The fees are always in the format "1.00" so we need to parse accordingly.
                                fee.FeeSched  = feeSched.FeeSchedNum;
                                fee.CodeNum   = codeNum;
                                fee.ClinicNum = clinicNum;
                                fee.ProvNum   = provNum;
                                Fees.Insert(fee);
                                listFeesImported.Add(fee);
                            }
                            else
                            {
                                fee.Amount = PIn.Double(fields[1], doUseEnUSFormat: true);
                                Fees.Update(fee);
                            }
                        }
                        numImported++;
                    }
                    else
                    {
                        numSkipped++;
                    }
                    FeeSchedEvent.Fire(ODEventType.FeeSched,
                                       new ProgressBarHelper(Lans.g("FeeScheds", "Processing fees, please wait") + "...", "", (numImported + numSkipped), feeLines.Length,
                                                             ProgBarStyle.Continuous));
                }
            }
            return(listFeesImported);
        }
Exemplo n.º 8
0
 /// <summary>Runs repeating charges for the date passed in, usually today. Can't use 'out' variables because this runs over Middle Tier.</summary>
 public static RepeatChargeResult RunRepeatingCharges(DateTime dateRun)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetObject <RepeatChargeResult>(MethodBase.GetCurrentMethod(), dateRun));
     }
     Prefs.UpdateDateT(PrefName.RepeatingChargesBeginDateTime, dateRun);
     try {
         RepeatChargeResult  result = new RepeatChargeResult();
         List <RepeatCharge> listRepeatingCharges = RepeatCharges.Refresh(0).ToList();
         if (PrefC.IsODHQ)
         {
             //Remove all eService repeating charges.
             //EService charges have already been calculated and stored in EServiceBilling table. Add those here.
             List <string> listEServiceCodes = EServiceCodeLink.GetProcCodesForAll();
             listRepeatingCharges.RemoveAll(x => listEServiceCodes.Contains(x.ProcCode));
             result.ProceduresAddedCount += EServiceBillings.AddEServiceRepeatingChargesHelper(dateRun).Count;
         }
         //Must contain all procedures that affect the date range, safe to contain too many, bad to contain too few.
         List <Procedure> listExistingProcs = Procedures.GetCompletedForDateRange(dateRun.AddMonths(-3), dateRun.AddDays(1),
                                                                                  listRepeatingCharges.Select(x => x.ProcCode).Distinct().Select(x => ProcedureCodes.GetProcCode(x).CodeNum).ToList());
         DateTime startedUsingFKs = UpdateHistories.GetDateForVersion(new Version("16.1.0.0"));              //We started using FKs from procs to repeat charges in 16.1.
         foreach (RepeatCharge repeatCharge in listRepeatingCharges)
         {
             if (!repeatCharge.IsEnabled || (repeatCharge.DateStop.Year > 1880 && repeatCharge.DateStop.AddMonths(3) < dateRun))
             {
                 continue;                        //This repeating charge is too old to possibly create a new charge. Not precise but greatly reduces calls to DB.
                 //We will filter by more stringently on the DateStop later on.
             }
             Patient         pat = null;
             List <DateTime> listBillingDates;                   //This list will have 1 or 2 dates where a repeating charge might be added
             if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay))
             {
                 pat = Patients.GetPat(repeatCharge.PatNum);
                 listBillingDates = GetBillingDatesHelper(repeatCharge.DateStart, repeatCharge.DateStop, dateRun, pat.BillingCycleDay);
             }
             else
             {
                 listBillingDates = GetBillingDatesHelper(repeatCharge.DateStart, repeatCharge.DateStop, dateRun);
             }
             long codeNum = ProcedureCodes.GetCodeNum(repeatCharge.ProcCode);
             //Remove billing dates if there is a procedure from this repeat charge in that month and year
             for (int i = listBillingDates.Count - 1; i >= 0; i--)             //iterate backwards to remove elements
             {
                 DateTime billingDate = listBillingDates[i];
                 for (int j = listExistingProcs.Count - 1; j >= 0; j--)                 //iterate backwards to remove elements
                 {
                     Procedure proc = listExistingProcs[j];
                     if ((proc.RepeatChargeNum == repeatCharge.RepeatChargeNum &&                       //Check the procedure's FK first
                          IsRepeatDateHelper(repeatCharge, billingDate, proc.ProcDate, pat))
                         //Use the old logic without matching FKs only if the procedure was added before updating to 16.1
                         //Match patnum, codenum, fee, year, and month (IsRepeatDateHelper uses special logic to determine correct month)
                         || ((proc.ProcDate < startedUsingFKs || startedUsingFKs.Year < 1880) &&
                             proc.PatNum == repeatCharge.PatNum &&
                             proc.CodeNum == codeNum &&
                             IsRepeatDateHelper(repeatCharge, billingDate, proc.ProcDate, pat) &&
                             proc.ProcFee.IsEqual(repeatCharge.ChargeAmt)))
                     {
                         //This is a match to an existing procedure.
                         listBillingDates.RemoveAt(i);         //Removing so that a procedure will not get added on this date.
                         listExistingProcs.RemoveAt(j);        //Removing so that another repeat charge of the same code, date, and amount will be added.
                         break;                                //Go to the next billing date
                     }
                 }
             }
             //If any billing dates have not been filtered out, add a repeating charge on those dates
             foreach (DateTime billingDate in listBillingDates)
             {
                 Procedure    procAdded       = AddRepeatingChargeHelper(repeatCharge, billingDate, dateRun);
                 List <Claim> listClaimsAdded = new List <Claim>();
                 if (repeatCharge.CreatesClaim && !ProcedureCodes.GetProcCode(repeatCharge.ProcCode).NoBillIns)
                 {
                     listClaimsAdded = AddClaimsHelper(repeatCharge, procAdded);
                 }
                 result.ProceduresAddedCount++;
                 result.ClaimsAddedCount += listClaimsAdded.Count;
             }
         }
         return(result);
     }
     finally {
         Prefs.UpdateString(PrefName.RepeatingChargesBeginDateTime, "");
     }
 }
Exemplo n.º 9
0
 ///<summary>Helper method so that we do not have to duplicate code.  The length of toothValues must match the length of chartOrigVals.</summary>
 private static void ProcessScreenChartHelper(long patNum, List <string> toothValues, ScreenChartType chartType, long provNum, long sheetNum
                                              , List <string> chartOrigVals)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < toothValues.Count; i++)       //toothValues is in the order from low to high tooth number in the chart
     {
         if (!toothValues[i].Contains("S"))            //No sealant, nothing to do.
         {
             continue;
         }
         //Logic to determine if the "S" changed surfaces or was erased between the time the toothchart was opened and when it was submitted.
         string[] newSurfaces  = toothValues[i].Split(',');
         string[] origSurfaces = chartOrigVals[i].Split(',');
         bool     isDiff       = false;
         for (int j = 0; j < origSurfaces.Length; j++)                                                                   //Both arrays have the same length unless the chart doesn't exist in the original.
         {
             if ((newSurfaces[j] == "S" && origSurfaces[j] != "S") || (newSurfaces[j] != "S" && origSurfaces[j] == "S")) //"S" changed surfaces or was removed.
             {
                 isDiff = true;
                 break;
             }
         }
         //If there is no difference don't make any duplicates.  We don't care if they changed a surface from N to PS for example, only S surfaces are important.
         if (!isDiff)
         {
             continue;                    //All the "S" surfaces are the same.
         }
         string surf     = "";
         int    toothNum = 0;
         bool   isMolar  = false;
         bool   isRight  = false;
         bool   isLing   = false;
         string tooth    = "";
         #region Parse ScreenChart FieldValues
         if (i <= 1)               //Top left quadrant of toothchart
         {
             toothNum = i + 2;
             isMolar  = true;
             isRight  = true;
             isLing   = true;
         }
         else if (i > 1 && i <= 3)             //Top middle-left quadrant of toothchart
         {
             toothNum = i + 2;
             isMolar  = false;
             isRight  = true;
             isLing   = true;
         }
         else if (i > 3 && i <= 5)             //Top middle-right quadrant of toothchart
         {
             toothNum = i + 8;
             isMolar  = false;
             isRight  = false;
             isLing   = true;
         }
         else if (i > 5 && i <= 7)             //Top right quadrant of toothchart
         {
             toothNum = i + 8;
             isMolar  = true;
             isRight  = false;
             isLing   = true;
         }
         else if (i > 7 && i <= 9)             //Lower right quadrant of toothchart
         {
             toothNum = i + 10;
             isMolar  = true;
             isRight  = false;
             isLing   = false;
         }
         else if (i > 9 && i <= 11)             //Lower middle-right quadrant of toothchart
         {
             toothNum = i + 10;
             isMolar  = false;
             isRight  = false;
             isLing   = false;
         }
         else if (i > 11 && i <= 13)             //Lower middle-left quadrant of toothchart
         {
             toothNum = i + 16;
             isMolar  = false;
             isRight  = true;
             isLing   = false;
         }
         else if (i > 13)               //Lower left quadrant of toothchart
         {
             toothNum = i + 16;
             isMolar  = true;
             isRight  = true;
             isLing   = false;
         }
         if (isMolar)
         {
             if (isRight)
             {
                 if (newSurfaces[0] == "S")
                 {
                     surf += "D";
                 }
                 if (newSurfaces[1] == "S")
                 {
                     surf += "M";
                 }
             }
             else                      //Is Left side
             {
                 if (newSurfaces[0] == "S")
                 {
                     surf += "M";
                 }
                 if (newSurfaces[1] == "S")
                 {
                     surf += "D";
                 }
             }
             if (isLing && newSurfaces[2] == "S")
             {
                 surf += "L";
             }
             if (!isLing && newSurfaces[2] == "S")
             {
                 surf += "B";
             }
         }
         else                  //Front teeth, only look at 3rd surface position in control as that's the only one the user can see.
         {
             if (newSurfaces[2] == "S")
             {
                 surf = "O";                      //NOTE: Not sure what surface to enter here... This is just a placeholder for now until we figure it out...
             }
         }
         if (toothNum != 0)
         {
             tooth = toothNum.ToString();
         }
         #endregion Parse Toothchart FieldValues
         surf = Tooth.SurfTidyForDisplay(surf, tooth);
         if (chartType == ScreenChartType.TP)               //Create TP'd sealant procs if they don't already exist for this patient.
         {
             if (Procedures.GetProcForPatByToothSurfStat(patNum, toothNum, surf, ProcStat.TP) != null)
             {
                 continue;
             }
             Procedure proc = Procedures.CreateProcForPatNum(patNum, ProcedureCodes.GetCodeNum("D1351"), surf, tooth, ProcStat.TP, provNum);
             if (proc != null)
             {
                 SecurityLogs.MakeLogEntry(Permissions.ProcEdit, patNum, "D1351 " + Lans.g("Screens", "treatment planned during screening with tooth")
                                           + " " + proc.ToothNum.ToString() + " " + Lans.g("Screens", "and surface") + " " + proc.Surf);
             }
         }
         else if (chartType == ScreenChartType.C)
         {
             Procedure proc = Procedures.GetProcForPatByToothSurfStat(patNum, toothNum, surf, ProcStat.TP);
             if (proc == null)                   //A TP procedure does not already exist.
             {
                 proc = Procedures.CreateProcForPatNum(patNum, ProcedureCodes.GetCodeNum("D1351"), surf, tooth, ProcStat.C, provNum);
             }
             else                      //TP proc already exists, set it complete.
             {
                 Procedure procOld = proc.Copy();
                 proc.ProcStatus = ProcStat.C;
                 proc.DateEntryC = DateTime.Now;
                 Procedures.Update(proc, procOld);
             }
             if (proc != null)
             {
                 SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate, patNum, "D1351 " + Lans.g("Screens", "set complete during screening with tooth")
                                           + " " + proc.ToothNum.ToString() + " " + Lans.g("Screens", "and surface") + " " + proc.Surf);
             }
         }
     }
     if (chartType == ScreenChartType.C)
     {
         Recalls.Synch(patNum);
     }
 }
Exemplo n.º 10
0
        ///<summary>Takes a screening sheet that is associated to a patient and processes any corresponding ScreenCharts found.
        ///Processing will create treatment planned or completed procedures for the patient.
        ///Supply the sheet and then a bitwise enum of screen chart types to digest.
        ///listProcOrigVals, nulls are allowed, the first represents the fluoride field, second is assessment field, all others are other procs.</summary>
        public static void ProcessScreenChart(Sheet sheet, ScreenChartType chartTypes, long provNum, long sheetNum, List <SheetField> listChartOrigVals
                                              , List <SheetField> listProcOrigVals)
        {
            //No need to check RemotingRole; no call to db.
            if (sheet == null || sheet.PatNum == 0)
            {
                return;                //An invalid screening sheet was passed in.
            }
            List <string> listToothVals    = new List <string>();
            List <string> listToothValsOld = new List <string>();

            //Process treatment planned sealants.
            foreach (SheetField field in sheet.SheetFields)             //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.TP) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantTreatment")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[0] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[0].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.TP;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            listToothVals = new List <string>();            //Clear out the tooth values for the next tooth chart.
            //Process completed sealants.
            foreach (SheetField field in sheet.SheetFields) //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.C) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantComplete")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[1] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[1].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.C;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            //Process if the user wants to TP fluoride and/or assessment procedures and/or other procedures.
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;                    //Only care about check box types.
                }
                if (field.FieldName != "FluorideProc" && field.FieldName != "AssessmentProc" && !field.FieldName.StartsWith("Proc:"))
                {
                    continue;                    //Field name must be one of the two hard coded values, or a FieldName that starts with "Proc".
                }
                //Make other proc with provNum and patNum
                SheetField sheetFieldOrig = listProcOrigVals.FirstOrDefault(x => x.FieldName == field.FieldName && x.FieldType == SheetFieldType.CheckBox);
                if (sheetFieldOrig == null || sheetFieldOrig.FieldValue != "" || field.FieldValue != "X")
                {
                    //Either not found or field was previously checked (already charted proc) or field is not checked (do not chart).
                    continue;
                }
                string strProcCode = "";
                switch (field.FieldName)
                {
                case "FluorideProc":                        //Original value was blank, new value is "checked", make the D1206 (fluoride) proc.
                    strProcCode = "D1206";
                    break;

                case "AssessmentProc":                        //Original value was blank, new value is "checked", make the D0191 (assessment) proc.
                    strProcCode = "D0191";
                    break;

                default:                                        //Original value was blank, new value is "checked", make the proc.
                    strProcCode = field.FieldName.Substring(5); //Drop "Proc:" from FieldName.
                    break;
                }
                Procedure proc = Procedures.CreateProcForPatNum(sheet.PatNum, ProcedureCodes.GetCodeNum(strProcCode), "", "", ProcStat.C, provNum);
                if (proc != null)
                {
                    SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, strProcCode + " " + Lans.g("Screens", "treatment planned during screening."));
                }
            }
        }
Exemplo n.º 11
0
        /*//<summary>Used when a button is moved out of a category.  This leaves a 'hole' in the order, so we need to clean up the orders.  Remember to run Refresh before this.</summary>
         * public static void ResetOrder(int cat){
         *
         * }*/

        ///<summary>Deletes all current ProcButtons from the Chart module, and then adds the default ProcButtons.  Procedure codes must have already been entered or they cannot be added as a ProcButton.</summary>
        public static void SetToDefault()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            string command = "DELETE FROM procbutton";

            Db.NonQ(command);
            command = "DELETE FROM procbuttonitem";
            Db.NonQ(command);
            command = "DELETE FROM definition WHERE Category=26";
            Db.NonQ(command);
            long category;            //defNum
            long procButtonNum;
            long autoCodeNum;
            long autoCodeNum2;

            //Db---------------------------------------------------------------------------------------------------------
            command = "INSERT INTO definition (Category,ItemOrder,ItemName,ItemValue,ItemColor,IsHidden) "
                      + "VALUES (26,0,'General','',0,0)";
            category = Db.NonQ(command, true);
            //Amalgam
            autoCodeNum = AutoCodes.GetNumFromDescript("Amalgam");
            if (autoCodeNum != 0)
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('Amalgam',0,"
                          + POut.Long(category) + @",'Qk12BgAAAAAAADYAAAAoAAAAFAAAABQAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA/////////////////////9bW1v+ctbX/vebv/8XW1v+tvbX/hKWt/36crf9+nKX/nLW1/97v7//m9/f/pdbe/5y9vf/3////////////////////////////////////ztbO/5y1rf+cxcX/hKWt/5S1vf+cvcX/nMXO/5S9zv+Mrb3/jK2t/629vf+cxc7/nL29//f///////////////////////////////////+9zs7/fpSM/5S1vf+cxc7/tdbe/87m5v/O5u//1u/v/8Xe5v+lxdb/jK21/4Slrf+cvbX/9////////////////////////////////////7XW1v+ErbX/rc7W/8Xm5v/F3ub/3u/v/9739//W7+//zubv/87m7/+11t7/jK21/5y9vf/////////////////////////////////39/f/nLW9/5zFzv/O5ub/3vf3/8Xe5v/m////7////+/////O5u//zu/v/9739/+11tb/lLW1/+/39////////////////////////////9bW5v9NXb3/VWbv/8XW9//v////vdbm/+b3///v////9////73e3v+UtbX/5vf3/7XF9/9ufr3/zt7m////////////////////////////xcXv/xws3v8THO//bn73/87e5v+MrbX/xd7m/+/////v////rc7W/4ylpf/e7///PU33/xwk5v+1ve////////////////////////////+1ve//HCze/xwk7/80Pe//doy9/5y9vf/O5ub/9/////f///+1ztb/nLW1/4yc9/8cJOb/EyTv/4SU7////////////////////////////5yl7/8kLOb/HCzv/xwk7/80Rc7/foze/5Sl7/+crff/nK33/36U5v9dbsX/PUXv/xwk5v8cJOb/XW7m///////////////////////m9/f/foTv/yQs5v8cLO//HCzm/xws7/8kLOb/JCzm/yQs5v8kLOb/JCzm/xws5v8cJOb/HCzm/xwk7/9FVdb/9////////////////////+/39/9dbt7/HCTm/xws5v8cLOb/HCzm/xws5v8cLOb/HCzm/xws5v8cLOb/HCzm/xws5v8cLOb/HCTv/0VVzv/3/////////////////////////1Vm1v8cJO//HCzm/xws5v8cJOb/HCTv/xwk5v8cJOb/HCTm/xwk5v8cJO//HCTm/xws5v8cJO//RVXO//f39//////////////////3////RVXO/xwk7/8cLOb/HCTm/yw05v8sNOb/ND3v/zQ97/80Pe//ND3v/yw05v8kLO//HCTm/xwk7/9FVc7/9/f3//////////////////f///9FVc7/HCTv/xwk5v8sNOb/jJzm/3aErf+1xff/xdb3/8XW//+ElL3/nLXe/4yc9/8kLOb/HCTv/0VVzv/39/f/////////////////9////0VVzv8THO//ND3v/7XF9//O5ub/lK2l/87e1v/3////9////5y1rf/W7+//9////4yU9/8cJO//RVXW//f/////////////////////////boTF/1Vm7//Fzv//9////97v9/+1ztb/xdbW//f////m9/f/rcXO/+b39//3////7////5Sl7/9NXbX/9/f3//////////////////////+91tb/nL3F//f////v////5vf3/87m5v/e7/f/7////+b39//W7+//7////+/////v////tc7O/629vf////////////////////////////////+lxcX/pcXF/+/////3////1u/v/9739//3////3u/3/97v9//3////7////7XO1v+lvcX/9/////////////////////////////////////f39/+lvcX/nL3F/+b39//3////7////+/////m////7////97v7/+txcX/pb3F//f39/////////////////////////////////////////////f39/+txcX/lLW1/629vf/O3t7/3vf3/8Xe3v+lxcX/jKWc/7XFxf/39/f//////////////////////w==')";
                procButtonNum = Db.NonQ(command, true);
                command       = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                                + POut.Long(autoCodeNum) + ")";
                Db.NonQ(command);
            }
            //Composite
            autoCodeNum = AutoCodes.GetNumFromDescript("Composite");
            if (autoCodeNum != 0)
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('Composite',1,"
                          + POut.Long(category) + @",'Qk12BgAAAAAAADYAAAAoAAAAFAAAABQAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA///////////e5v//RU3m/yQ05v8kNOb/JDTm/xwk7/8cJO//JCzm/36UnP9+lJT/fpSc/3aUlP9+lIz/xc7O/////////////////////////////////3Z+9/8kLOb/Znbv/3aE7/+ElO//fpTv/zQ97/8kLOb/rcXm/73e3v+11t7/tdbe/5zFzv+EpaX/1t7e////////////////////////////LDTv/11u5v/e7/f/5vf//+/////3////pbX//yQs7//e7///7////+b39//e7/f/zubv/5S1vf+tvbX///////////////////////////80Pff/XW7m/+b////3////7/////f///+1xf//JCzv/+b3///3////7////+b39//W7+//nL3F/629vf///////////////////////////z1F9/9dbu//7/f//+/////v////9////4yc//89Rff/5vf//+/////v////7////9bv7/+cvcX/rb29////////////////////////////ND3v/3aE7//3////7////+/////v////XWb3/36M9//3////7////+/////v////1u/3/5S1vf+9zs7///////////////////////////8sNO//doTv//f////v////7////+////80Pe//pbX///f////v////7////+/////e7/f/jK2t/9be3v///////////////////////////yw07/9ufu//7////+/////v////3u///zQ97/+9zv//9////+/////v////7////87m7/9+lIz/3u/v////////////////////////////JCzv/2Z27//m////7/////f///+MlP//VWb3//f////v////7////+/////v////zubm/36UlP/m7+////////////////////////////89Rff/VWbm/97v9//3////7////11m9/9mbvf/9////+/////v////7////+////+91t7/lK2t//f3/////////////////////////////5yl//80Rd7/zubv//f////O3v//LDTv/7XF///3////7////+/////v////5vf//6W9xf+ctbX/////////////////////////////////1t7//yQ05v+MnO///////4yU//89Rff/5vf//+/////v////7////+/////m9///nL3F/7XFzv/////////////////////////////////39///Zm73/0VV5v+9zvf/LDTv/5yl///3////7////+/////v////7////+b39/+UrbX/1t7e//////////////////////////////////////+UnPf/JCzm/yw07/9dbvf/5vf//+/////v////7////+/////v////1ubv/4ylpf/m7+///////////////////////////////////////97m//8sNO//XW7v/97v///3////7////+/////v////7////+/////F3t7/nK2t/////////////////////////////////////////////////25+vf+Mpc7/7////+/////v////7////+/////v////7////6W9vf/Fzs7/////////////////////////////////////////////////pb21/5Strf/O5ub/7////+/////v////7/////f////e7+//jK2t/+bv7//////////////////////////////////////////////////O5ub/fpyc/7XOzv/e9/f/9////+/////v////9////7XOzv+EpaX/5vf3/////////////////////////////////////////////////+bv7/+MvcX/lK2t/5y1tf/O5ub/5vf3/+bv7/+9zs7/lL29/4ytrf/3////////////////////////////////////////////////////3ubm/5TFxf+95u//rb29/4ylnP+cra3/lK2t/6W9vf+t1t7/nLW1/////////////////////////////////w==')";
                procButtonNum = Db.NonQ(command, true);
                command       = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                                + POut.Long(autoCodeNum) + ")";
                Db.NonQ(command);
            }
            //Crown
            if (ProcedureCodes.IsValidCode("D2750") || ProcedureCodes.IsValidCode("N4118"))
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('Crown',2,"
                          + POut.Long(category) + @",'Qk12BgAAAAAAADYAAAAoAAAAFAAAABQAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+1ve//PVXW/1Vu7/9mdu//Znbv/2Z27/9mdu//XW7v/2Z27/9mbu//Zm7v/2Zu7/9dbu//XW7v/01m7/9FXeb/pa33/////////////////11m7/89Re//XWbv/11m7/9dZu//XWbv/11m7/9dZu//XWbv/11m7/9dZu//XWbv/11m7/9dZu//XWbv/z1F7/9NVe/////////////e3v//LDTv/6Wt9//39///9/f///f3///39///9/f///f3///39///9/f///f3///39///9/f///f3///39///vb3//zQ97//W1v///////5Sc9/80Re//5ub////////////////////////////////////////////////////////////////////////W1v//PUXv/73F9//39///XWbv/2Zu7////////////////////////////////////////////////////////////////////////////9bW//89Re//vcX3/87O//8sNO//tb3/////////////////////////////////////////////////////////////////////////////3t7//zRF7/+cpff/hIz3/z1F7//v7///////////////////////////////////////////////////////////////////////////////////XWbv/2529/9udvf/VV3v//f3//////////////////////////////////////////////////////////////////////////////////+MlPf/TVXv/2529/9VXe//9/f/////////////////////////////7+///6Wl9/+1vf///////////////////////////////////////6Wl9/80Re//bnb3/1Vd7//39//////////////////////////////W1v//RU3v/6Wl9///////////////////////////////////////3t7//yw07/9mdu//XWbv//f3/////////////////////////////87W//9FTe//zs7////////////////////////////////////////39///VV3v/3Z+9/9NVe//9/f/////////////////////////////1tb//1Vd7//Ozv////////////////////////////////////////f3//9VXe//vb3//yQs7//Ozv////////////////////////////+9xff/ND3v/4yU9//v7///////////////////////////////////tb3//yw07//v7///VV3v/z1F7/+cnPf/5ub///f3///m5v//jJT3/zQ97/89Re//LDTv/0VN7/+MlPf/pa33/87O///v9///5ub//5Sc9/8sNO//foT3///////e5v//foT3/z1N7/8sNO//VV3v/zQ97/9FTe//lJz3/+/v///e5v//foT3/01V7/9FTe//LDTv/0VN7/8sNO//ND3v/4yU9////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////w==')";
                procButtonNum = Db.NonQ(command, true);
                if (ProcedureCodes.IsValidCode("D2750"))
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum)
                              + "," + ProcedureCodes.GetCodeNum("D2750") + ",0)";
                    Db.NonQ(command);
                }
                if (ProcedureCodes.IsValidCode("N4118"))
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum)
                              + "," + ProcedureCodes.GetCodeNum("N4118") + ",0)";
                    Db.NonQ(command);
                }
            }
            //RCT
            autoCodeNum = AutoCodes.GetNumFromDescript("Root Canal");
            if (autoCodeNum != 0)
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('RCT',3,"
                          + POut.Long(category) + @",'Qk12BgAAAAAAADYAAAAoAAAAFAAAABQAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA///////////////////////////////////////////F1tb/boyt/xwkpf/m5ub//////////////////////////////////////////////////////////////////////////////////////36MjP9VbpT/EySc/7XFxf//////////////////////////////////////////////////////////////////////////////////////XWZm/36lzv8kNMX/ZnZu//////////////////////////////////////////////////////////////////////////////////f39/9NXV3/fpz//wMD//9ddm7/zs7O////////////////////////////////////////////////////////////////////////////3t7e/2Z+dv9mfv//AwP//2aEfv+lpaX////////////////////////////////////////////////////////////////////////////FxcX/XXZ2/26E//8DA///jK2t/5ycnP///////////////////////////////////////////////////////////////////////////8XFxf9mfnb/fpT//wMD//+Era3/lJSU//f39///////////////////////////////////////////////////////////////////////nKWl/2aMjP9uhP//AwP//4y1tf+UnJz/9/f3//////////////////////////////////////////////////////////////////////9mbm7/ZoSE/2Z+//8DA///nMXF/4SMjP/39/f//////////////////////////////////////////////////////////////////////2Zubv9ujIT/Znb//wMD//+lzs7/foyM//f39///////////////////////////////////////////////////////////////////////PUVF/36lpf9ufv//AwP//63W1v9ufn7/9/f3/////////////////////////////////////////////////////////////////+/v7/9VVVX/jLW1/2Z2//8DA///td7m/2Z2dv/v7+//////////////////////////////////////////////////////////////////3t7e/1VVVf+Uxb3/bn7//wMD//+13ub/ZnZ2/+bm5v/////////////////////////////////////////////////////////////////e3t7/XWZu/5TFvf9mdv//AwP//7Xe5v9mdnb/3t7e/////////////////////////////////////////////////////////////////8XFxf9mbm7/nMXF/11m//8DA///zu/3/1VmXf/e3t7/////////////////////////////////////////////////////////////////zs7O/11mZv+cxcX/XW7//wMD///O7/f/VWZm/87Ozv/////////////////////////////////////////////////////////////////FxcX/ZnZ2/6XOzv9dbv//AwP//9bv9/9Vbm7/pa2t/////////////////////////////////////////////////////////////////62trf9VZmb/rdbW/01d//8DA///1u/3/01mZv+UlJT/////////////////////////////////////////////////////////////////nJyc/0VNTf+t3tb/XW7//wMD//+Urf//RV1d/4yUlP////////////////////////////////////////////////////////////////+1tbX/RV1d/7Xe3v9dZv//AwP//4yl//89VVX/foSE/////////////////////////////////w==')";
                procButtonNum = Db.NonQ(command, true);
                command       = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                                + POut.Long(autoCodeNum) + ")";
                Db.NonQ(command);
            }
            //RCT BU PFM
            autoCodeNum  = AutoCodes.GetNumFromDescript("Root Canal");
            autoCodeNum2 = AutoCodes.GetNumFromDescript("BU/P&C");
            if (autoCodeNum != 0 || ProcedureCodes.IsValidCode("D2750"))           //we add this button if either RCT or crown is available.
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('RCT BU PFM',4,"
                          + POut.Long(category) + @",'Qk12BgAAAAAAADYAAAAoAAAAFAAAABQAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA////////////////pcXF/63W7/89Te//Exzv/01V7/+95u//tebm/7Xm5v9+lO//HCTv/xwk7/9Vbu//pdbe/73m5v////////////////////////////////+cvb3/rdbv/z1N7/8cJO//PUXv/63W7/+15ub/tebm/11u7/8cJO//HCTv/01d7/+cztb/td7e////////////////////////////9/f//5y9tf+t1u//PU3v/xwk7/8kLO//pb33/73m5v/W7/f/PU3v/xwk7/8cJO//PU3v/4zF3v+13t7/////////////////////////////////lL21/6XW7/89Te//HCTv/xwk7/+ElPf/zvfv/5yt9/8kLO//HCTv/xwk7/89Te//lMXe/73e3v////////////////////////////////+UvbX/vd73/0VN7/8cJO//HCzv/yw97/9mbu//LDTv/xwk7/8cLO//HCTv/0VN7/+Uvc7/rc7O/////////////////////////////////6XO1v+13u//RU3v/xwk7/8cLO//HCTv/xwk7/8cJO//HCzv/xws7/8cJO//RU3v/4S13v+lztb////////////////////////////m5v//PU3v/zRF5v8kLO//EyTv/xwk7/8cJO//HCTv/xwk7/8cJO//HCTv/xMk7/8cJO//JCzv/zRF5v/W1v///////////////////////5yl9/8sNO//fn73/4SM9/+EjPf/hIz3/4SM9/+EjPf/hIz3/4SM9/+EjPf/hIz3/4SM9/+EhPf/ND3v/4yU9//////////////////39///TVXv/36E9/////////////////////////////////////////////////////////////////9mbvf/VV3v//f3/////////////8XF//8cLO//zs7//////////////////////////////////////////////////////////////////4SM9/8sPe//7+//////////////hIz3/0VN7//39///////////////////////////////////////////////////////////////////paX3/yQs7//m5v///////+bm//9FTe//hIT3///////////////////////////////////////////////////////////////////////Fxf//JCzv/7299///////xcX//yw07/+9vff//////////////////////////////////////////////////////////////////////+/v//89Re//VV3v///////Ozv//ND3v/7299////////////////////////////+/v///e3v//9/f/////////////////////////////9/f//1Vd7/9FTe///////8XO//80Pe//vb33////////////////////////////ra33/11m7//e3v//////////////////////////////////dn73/yQs7///////xcX//yw07//Fxf////////////////////////////+UlPf/Zm7v//////////////////////////////////////+1tf//JCzv///////W1v//NEXv/7299////////////////////////////5yl9/92fvf//////////////////////////////////////7299/8kLO////////f3//9dZu//fn73////////////////////////////foT3/z1F7//Ozv//////////////////////////////////dn73/zQ97////////////5yl9/8kLO//jJT3/+bm///39///5u///4SM9/8sNO//LDTv/yQs7/9+hPf/vb33/97e///39///5u///3Z+9/8kLO//vb33////////////9/f//5Sc9/9NVe//ND3v/z1F7/80Pe//TVXv/62t9//v7///nKX3/0VN7/8sNO//LDTv/01V7/80Pe//PUXv/7299////////////w==')";
                procButtonNum = Db.NonQ(command, true);
                if (ProcedureCodes.IsValidCode("D2750"))
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum)
                              + "," + ProcedureCodes.GetCodeNum("D2750") + ",0)";
                    Db.NonQ(command);
                }
                if (ProcedureCodes.IsValidCode("N4118"))
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum)
                              + "," + ProcedureCodes.GetCodeNum("N4118") + ",0)";
                    Db.NonQ(command);
                }
                if (autoCodeNum != 0)
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                              + POut.Long(autoCodeNum) + ")";
                    Db.NonQ(command);
                }
                if (autoCodeNum2 != 0)
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                              + POut.Long(autoCodeNum2) + ")";
                    Db.NonQ(command);
                }
            }
            //Bridge
            autoCodeNum = AutoCodes.GetNumFromDescript("Bridge");
            if (autoCodeNum != 0 || ProcedureCodes.IsValidCode("N4127"))
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('Bridge',5,"
                          + POut.Long(category) + @",'')";
                procButtonNum = Db.NonQ(command, true);
                if (ProcedureCodes.IsValidCode("N4127"))
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum)
                              + "," + ProcedureCodes.GetCodeNum("N4127") + ",0)";
                    Db.NonQ(command);
                }
                if (autoCodeNum != 0)
                {
                    command = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                              + POut.Long(autoCodeNum) + ")";
                    Db.NonQ(command);
                }
            }
            //Build Up
            autoCodeNum = AutoCodes.GetNumFromDescript("BU/P&C");
            if (autoCodeNum != 0)
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('BU/P&C',6,"
                          + POut.Long(category) + @",'')";
                procButtonNum = Db.NonQ(command, true);
                command       = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum) + ",0,"
                                + POut.Long(autoCodeNum) + ")";
                Db.NonQ(command);
            }
            //Exams/Cleanings Category--------------------------------------------------------------------------------------------
            command = "INSERT INTO definition (Category,ItemOrder,ItemName,ItemValue,ItemColor,IsHidden) "
                      + "VALUES (26,1,'Exams/Cleanings','',0,0)";
            category = Db.NonQ(command, true);
            //PA
            if (ProcedureCodes.IsValidCode("D0220"))
            {
                command = "INSERT INTO procbutton (Description,ItemOrder,Category,ButtonImage) VALUES('PA',0,"
                          + POut.Long(category) + @",'Qk12BgAAAAAAADYAAAAoAAAAFAAAABQAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9/f3/0VFRf8DAwP/AwMD/wMDA/9dXV3/jIyM/yQkJP8DAwP/AwMD/4SEhP8LCwv/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/RUVF/97e3v+MjIz/AwMD/wMDA/8DAwP/AwMD/35+fv/FxcX/JCQk/wMDA/8DAwP/5ubm/5SUlP8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/VVVV/wMDA/8DAwP/AwMD/wMDA/8LCwv/nJyc/+bm5v9dXV3/AwMD/wsLC/+MjIz/ZmZm/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wsLC/+lpaX/xcXF/zQ0NP8DAwP/NDQ0/62trf9dXV3/JCQk/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/TU1N/2ZmZv/Ozs7/dnZ2/wMDA/9dXV3/xcXF/+bm5v80NDT/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/9FRUX/lJSU/8XFxf+tra3/hISE/7W1tf/FxcX/tbW1/2ZmZv8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/01NTf/Ozs7/1tbW/+bm5v/Ozs7/7+/v/+bm5v/v7+//jIyM/yQkJP8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/ZmZm/+bm5v//////5ubm/+/v7//v7+//5ubm//f39//W1tb/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/9mZmb////////////39/f/5ubm//f39///////9/f3/+bm5v80NDT/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/1VVVf/39/f//////+/v7//m5ub/////////////////7+/v/yQkJP8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/3t7e/+/v7//39/f/9/f3/9bW1v/m5ub////////////v7+//AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/+EhIT/paWl/8XFxf//////3t7e/97e3v/v7+//5ubm/5ycnP8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/TU1N/wsLC/8DAwP/AwMD/wMDA/89PT3/1tbW/87Ozv/FxcX/lJSU/35+fv+MjIz/dnZ2/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/2ZmZv//////XV1d/wMDA/8DAwP/AwMD/wMDA/8LCwv/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/8DAwP/AwMD/wMDA/9mZmb//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////w==')";
                procButtonNum = Db.NonQ(command, true);
                command       = "INSERT INTO procbuttonitem (ProcButtonNum,CodeNum,AutoCodeNum) VALUES (" + POut.Long(procButtonNum)
                                + "," + ProcedureCodes.GetCodeNum("D0220") + ",0)";
                Db.NonQ(command);
            }
            //NewChildExam
        }
Exemplo n.º 12
0
        ///<summary>Takes a screening sheet that is associated to a patient and processes any corresponding ScreenCharts found.
        ///Processing will create treatment planned or completed procedures for the patient.
        ///Supply the sheet and then a bitwise enum of screen chart types to digest.
        ///procOrigVals MUST be two items long, nulls are allowed, the first represents the fluoride field, second is assessment field.</summary>
        public static void ProcessScreenChart(Sheet sheet, ScreenChartType chartTypes, long provNum, long sheetNum, List <SheetField> listChartOrigVals
                                              , List <SheetField> listProcOrigVals)
        {
            //No need to check RemotingRole; no call to db.
            if (sheet == null || sheet.PatNum == 0)
            {
                return;                //An invalid screening sheet was passed in.
            }
            List <string> listToothVals    = new List <string>();
            List <string> listToothValsOld = new List <string>();

            //Process treatment planned sealants.
            foreach (SheetField field in sheet.SheetFields)             //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.TP) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantTreatment")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[0] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[0].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.TP;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            listToothVals = new List <string>();            //Clear out the tooth values for the next tooth chart.
            //Process completed sealants.
            foreach (SheetField field in sheet.SheetFields) //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.C) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantComplete")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[1] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[1].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.C;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            //Process if the user wants to TP fluoride and / or assessment procedures.
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;                    //Only care about check box types.
                }
                if (field.FieldName != "FluorideProc" && field.FieldName != "AssessmentProc")
                {
                    continue;                    //Field name must be one of the two hard coded values.
                }
                //Make D1206 proc with provNum and patNum
                if (field.FieldName == "FluorideProc" && listProcOrigVals[1] != null && listProcOrigVals[1].FieldValue == "" && field.FieldValue == "X")
                {
                    //Original value was blank, new value is "checked", make the D1206 (fluoride) proc.
                    Procedure proc = Procedures.CreateProcForPat(sheet.PatNum, ProcedureCodes.GetCodeNum("D1206"), "", "", ProcStat.C, provNum);
                    if (proc != null)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, "D1206 " + Lans.g("Screens", "treatment planned during screening"));
                    }
                }
                //Make D0191 proc with provNum and patNum
                if (field.FieldName == "AssessmentProc" && listProcOrigVals[0] != null && listProcOrigVals[0].FieldValue == "" && field.FieldValue == "X")
                {
                    //Original value was blank, new value is "checked", make the D0191 (assessment) proc.
                    Procedure proc = Procedures.CreateProcForPat(sheet.PatNum, ProcedureCodes.GetCodeNum("D0191"), "", "", ProcStat.C, provNum);
                    if (proc != null)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, "D0191 " + Lans.g("Screens", "treatment planned during screening."));
                    }
                }
            }
        }
Exemplo n.º 13
0
        //------

        ///<summary>Deletes all current autocodes and then adds the default autocodes.  Procedure codes must have already been entered or they cannot be added as an autocode.</summary>
        public static void SetToDefault()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            string command = "DELETE FROM autocode";

            Db.NonQ(command);
            command = "DELETE FROM autocodecond";
            Db.NonQ(command);
            command = "DELETE FROM autocodeitem";
            Db.NonQ(command);
            long autoCodeNum;
            long autoCodeItemNum;

            //Amalgam-------------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('Amalgam',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //1Surf
            if (ProcedureCodes.IsValidCode("D2140"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2140") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.One_Surf) + ")";
                Db.NonQ(command);
            }
            //2Surf
            if (ProcedureCodes.IsValidCode("D2150"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2150") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Two_Surf) + ")";
                Db.NonQ(command);
            }
            //3Surf
            if (ProcedureCodes.IsValidCode("D2160"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2160") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Three_Surf) + ")";
                Db.NonQ(command);
            }
            //4Surf
            if (ProcedureCodes.IsValidCode("D2161"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2161") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Four_Surf) + ")";
                Db.NonQ(command);
            }
            //5Surf
            if (ProcedureCodes.IsValidCode("D2161"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2161") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Five_Surf) + ")";
                Db.NonQ(command);
            }
            //Composite-------------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('Composite',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //1SurfAnt
            if (ProcedureCodes.IsValidCode("D2330"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2330") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.One_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //2SurfAnt
            if (ProcedureCodes.IsValidCode("D2331"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2331") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Two_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //3SurfAnt
            if (ProcedureCodes.IsValidCode("D2332"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2332") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Three_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //4SurfAnt
            if (ProcedureCodes.IsValidCode("D2335"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2335") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Four_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //5SurfAnt
            if (ProcedureCodes.IsValidCode("D2335"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2335") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Five_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //Posterior Composite----------------------------------------------------------------------------------------------
            //1SurfPost
            if (ProcedureCodes.IsValidCode("D2391"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2391") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.One_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Posterior) + ")";
                Db.NonQ(command);
            }
            //2SurfPost
            if (ProcedureCodes.IsValidCode("D2392"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2392") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Two_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Posterior) + ")";
                Db.NonQ(command);
            }
            //3SurfPost
            if (ProcedureCodes.IsValidCode("D2393"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2393") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Three_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Posterior) + ")";
                Db.NonQ(command);
            }
            //4SurfPost
            if (ProcedureCodes.IsValidCode("D2394"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2394") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Four_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Posterior) + ")";
                Db.NonQ(command);
            }
            //5SurfPost
            if (ProcedureCodes.IsValidCode("D2394"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2394") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Five_Surf) + ")";
                Db.NonQ(command);
                command = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                          + POut.Long((int)AutoCondition.Posterior) + ")";
                Db.NonQ(command);
            }
            //Root Canal-------------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('Root Canal',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //Ant
            if (ProcedureCodes.IsValidCode("D3310"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D3310") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //Premolar
            if (ProcedureCodes.IsValidCode("D3320"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D3320") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Premolar) + ")";
                Db.NonQ(command);
            }
            //Molar
            if (ProcedureCodes.IsValidCode("D3330"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D3330") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Molar) + ")";
                Db.NonQ(command);
            }
            //Bridge-------------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('Bridge',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //Pontic
            if (ProcedureCodes.IsValidCode("D6242"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D6242") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Pontic) + ")";
                Db.NonQ(command);
            }
            //Retainer
            if (ProcedureCodes.IsValidCode("D6752"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D6752") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Retainer) + ")";
                Db.NonQ(command);
            }
            //Denture-------------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('Denture',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //Max
            if (ProcedureCodes.IsValidCode("D5110"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D5110") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Maxillary) + ")";
                Db.NonQ(command);
            }
            //Mand
            if (ProcedureCodes.IsValidCode("D5120"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D5120") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Mandibular) + ")";
                Db.NonQ(command);
            }
            //BU/P&C-------------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('BU/P&C',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //BU
            if (ProcedureCodes.IsValidCode("D2950"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2950") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Posterior) + ")";
                Db.NonQ(command);
            }
            //P&C
            if (ProcedureCodes.IsValidCode("D2954"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D2954") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //Root Canal Retreat--------------------------------------------------------------------------------------------------
            command     = "INSERT INTO autocode (Description,IsHidden,LessIntrusive) VALUES ('RCT Retreat',0,0)";
            autoCodeNum = Db.NonQ(command, true);
            //Ant
            if (ProcedureCodes.IsValidCode("D3346"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D3346") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Anterior) + ")";
                Db.NonQ(command);
            }
            //Premolar
            if (ProcedureCodes.IsValidCode("D3347"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D3347") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Premolar) + ")";
                Db.NonQ(command);
            }
            //Molar
            if (ProcedureCodes.IsValidCode("D3348"))
            {
                command = "INSERT INTO autocodeitem (AutoCodeNum,CodeNum) VALUES (" + POut.Long(autoCodeNum) + ","
                          + ProcedureCodes.GetCodeNum("D3348") + ")";
                autoCodeItemNum = Db.NonQ(command, true);
                command         = "INSERT INTO autocodecond (AutoCodeItemNum,Cond) VALUES (" + POut.Long(autoCodeItemNum) + ","
                                  + POut.Long((int)AutoCondition.Molar) + ")";
                Db.NonQ(command);
            }
        }