Пример #1
0
 ///<summary>Checks the loaded prefs to see if user has setup deposit linking.  Returns true if so.</summary>
 public static bool DepositsLinked()
 {
     //No need to check RemotingRole; no call to db.
     if (PrefC.GetInt(PrefName.AccountingSoftware) == (int)AccountingSoftware.QuickBooks)
     {
         if (PrefC.GetString(PrefName.QuickBooksDepositAccounts) == "")
         {
             return(false);
         }
         if (PrefC.GetString(PrefName.QuickBooksIncomeAccount) == "")
         {
             return(false);
         }
     }
     else
     {
         if (PrefC.GetString(PrefName.AccountingDepositAccounts) == "")
         {
             return(false);
         }
         if (PrefC.GetLong(PrefName.AccountingIncomeAccount) == 0)
         {
             return(false);
         }
     }
     //might add a few more checks later.
     return(true);
 }
Пример #2
0
        ///<summary>Updates a pref of type long.  Returns true if a change was required, or false if no change needed.</summary>
        public static bool UpdateLong(PrefName prefName, long newValue)
        {
            //Very unusual.  Involves cache, so Meth is used further down instead of here at the top.
            long curValue = PrefC.GetLong(prefName);

            if (curValue == newValue)
            {
                return(false);               //no change needed
            }
            string command = "UPDATE preference SET "
                             + "ValueString = '" + POut.Long(newValue) + "' "
                             + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'";
            bool retVal = true;

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue);
            }
            else
            {
                Db.NonQ(command);
            }
            Pref pref = new Pref();

            pref.PrefName    = prefName.ToString();
            pref.ValueString = newValue.ToString();
            Prefs.UpdateValueForKey(pref);
            return(retVal);
        }
Пример #3
0
        ///<summary>Updates a pref of type long.  Returns true if a change was required, or false if no change needed.</summary>
        public static bool UpdateLong(PrefName prefName, long newValue)
        {
            //Very unusual.  Involves cache, so Meth is used further down instead of here at the top.
            if (!PrefC.Dict.ContainsKey(prefName.ToString()))
            {
                throw new ApplicationException(prefName + " is an invalid pref name.");
            }
            if (PrefC.GetLong(prefName) == newValue)
            {
                return(false);               //no change needed
            }
            string command = "UPDATE preference SET "
                             + "ValueString = '" + POut.Long(newValue) + "' "
                             + "WHERE PrefName = '" + POut.String(prefName.ToString()) + "'";
            bool retVal = true;

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                retVal = Meth.GetBool(MethodBase.GetCurrentMethod(), prefName, newValue);
            }
            else
            {
                Db.NonQ(command);
            }
            Pref pref = new Pref();

            pref.PrefName    = prefName.ToString();
            pref.ValueString = newValue.ToString();
            PrefC.Dict[prefName.ToString()] = pref;          //in some cases, we just want to change the pref in local memory instead of doing a refresh afterwards.
            return(retVal);
        }
Пример #4
0
        ///<summary>Gets the default email address for the clinic/practice. Takes a clinic num. If clinic num is 0 or there is no default for that clinic, it will get practice default. May return a new blank object.</summary>
        public static EmailAddress GetByClinic(long clinicNum)
        {
            EmailAddress emailAddress = null;
            Clinic       clinic       = Clinics.GetClinic(clinicNum);

            if (PrefC.GetBool(PrefName.EasyNoClinics) || clinic == null)           //No clinic, get practice default
            {
                emailAddress = GetOne(PrefC.GetLong(PrefName.EmailDefaultAddressNum));
            }
            else
            {
                emailAddress = GetOne(clinic.EmailAddressNum);
                if (emailAddress == null)               //clinic.EmailAddressNum 0. Use default.
                {
                    emailAddress = GetOne(PrefC.GetLong(PrefName.EmailDefaultAddressNum));
                }
            }
            if (emailAddress == null)
            {
                if (listt.Count > 0)               //user didn't set a default
                {
                    emailAddress = listt[0];
                }
                else
                {
                    emailAddress = new EmailAddress();                  //To avoid null checks.
                }
            }
            return(emailAddress);
        }
Пример #5
0
        ///<summary>Returns practice default for invalid clinicNums.  Will get results for hidden clinics too.</summary>
        public static PlaceOfService GetPlaceService(long clinicNum)
        {
            //No need to check RemotingRole; no call to db.
            Clinic clinic = GetFirstOrDefault(x => x.ClinicNum == clinicNum);

            return(clinic == null ? (PlaceOfService)PrefC.GetLong(PrefName.DefaultProcedurePlaceService) : clinic.DefaultPlaceService);
        }
Пример #6
0
        public static bool IsTextingEnabled(long clinicNum)
        {
            //No need to check RemotingRole; no call to db.
            if (Plugins.HookMethod(null, "Clinics.IsTextingEnabled_start", clinicNum))
            {
                return(true);
            }
            if (clinicNum == 0)
            {
                if (PrefC.HasClinicsEnabled)
                {
                    clinicNum = PrefC.GetLong(PrefName.TextingDefaultClinicNum);
                }
                else
                {
                    return(SmsPhones.IsIntegratedTextingEnabled());
                }
            }
            Clinic clinic = GetClinic(clinicNum);

            if (clinic == null)
            {
                return(false);               //also handles clinicNum=0 which happens when default clinic not initialized.
            }
            return(clinic.SmsContractDate.Year > 1880);
        }
Пример #7
0
        ///<summary>Gets the UCR fee for the provided procedure.</summary>
        public static double GetFeeUCR(Procedure proc)
        {
            //No need to check RemotingRole; no call to db.
            long provNum = proc.ProvNum;

            if (provNum == 0)           //if no prov set, then use practice default.
            {
                provNum = PrefC.GetLong(PrefName.PracticeDefaultProv);
            }
            int qty = proc.UnitQty + proc.BaseUnits;

            if (qty == 0)
            {
                qty = 1;
            }
            Provider providerFirst = Providers.GetFirst();          //Used in order to preserve old behavior...  If this fails, then old code would have failed.
            Provider provider      = Providers.GetFirstOrDefault(x => x.ProvNum == provNum) ?? providerFirst;
            //get the fee based on code and prov fee sched
            double ppoFee = Fees.GetAmount0(proc.CodeNum, provider.FeeSched, proc.ClinicNum, provNum);
            double ucrFee = proc.ProcFee;

            if (ucrFee > ppoFee)
            {
                return(qty * ucrFee);
            }
            else
            {
                return(qty * ppoFee);
            }
        }
Пример #8
0
        public static void RetrieveReportsAutomatic(bool isAllClinics)
        {
            List <long> listClinicNums = new List <long>();

            if (isAllClinics)
            {
                listClinicNums = Clinics.GetDeepCopy(true).Select(x => x.ClinicNum).ToList();
            }
            else
            {
                listClinicNums = new List <long> {
                    Clinics.ClinicNum
                };
            }
            string errMsg;
            bool   isTimeToRetrieve = IsTimeToRetrieveReports(true, out errMsg);

            if (isTimeToRetrieve)
            {
                Prefs.UpdateDateT(PrefName.ClaimReportReceiveLastDateTime, DateTime.Now);
            }
            List <Clearinghouse> listClearinghousesHq = GetDeepCopy();
            long defaultClearingHouseNum = PrefC.GetLong(PrefName.ClearinghouseDefaultDent);

            for (int i = 0; i < listClearinghousesHq.Count; i++)
            {
                Clearinghouse clearinghouseHq = listClearinghousesHq[i];
                Clearinghouse clearinghouseClin;
                for (int j = 0; j < listClinicNums.Count; j++)
                {
                    clearinghouseClin = OverrideFields(clearinghouseHq, listClinicNums[j]);
                    RetrieveReportsAutomaticHelper(clearinghouseClin, clearinghouseHq, defaultClearingHouseNum, isTimeToRetrieve);
                }
            }
        }
Пример #9
0
        ///<summary>Gets the default email address for the clinic/practice. Takes a clinic num.
        ///If clinic num is 0 or there is no default for that clinic, it will get practice default.
        ///May return a new blank object.</summary>
        public static EmailAddress GetByClinic(long clinicNum, bool doAllowNullReturn = false)
        {
            //No need to check RemotingRole; no call to db.
            EmailAddress emailAddress = null;
            Clinic       clinic       = Clinics.GetClinic(clinicNum);

            if (PrefC.GetBool(PrefName.EasyNoClinics) || clinic == null)           //No clinic, get practice default
            {
                emailAddress = GetOne(PrefC.GetLong(PrefName.EmailDefaultAddressNum));
            }
            else
            {
                emailAddress = GetOne(clinic.EmailAddressNum);
                if (emailAddress == null)               //clinic.EmailAddressNum 0. Use default.
                {
                    emailAddress = GetOne(PrefC.GetLong(PrefName.EmailDefaultAddressNum));
                }
            }
            if (emailAddress == null)
            {
                emailAddress = GetFirstOrDefault(x => true);            //user didn't set a default, so just pick the first email in the list.
                if (emailAddress == null && !doAllowNullReturn)         //If there are no email addresses AT ALL!!
                {
                    emailAddress = new EmailAddress();                  //To avoid null checks.
                    emailAddress.EmailPassword      = "";
                    emailAddress.EmailUsername      = "";
                    emailAddress.Pop3ServerIncoming = "";
                    emailAddress.SenderAddress      = "";
                    emailAddress.SMTPserver         = "";
                }
            }
            return(emailAddress);
        }
Пример #10
0
        ///<summary>Returns the max date of the last transaction for the transactions passed in.  Returns MinValue if none found.
        ///This method assumes that every aging transaction passed can cause a statement. i.e. the PayPlanCharges passed in are within the today's date
        ///plus the bill in advance days.</summary>
        public static DateTime GetDateLastTrans(List <PatAgingTransaction> listPatAgingTransactions, DateTime dateLastStatement)
        {
            //No need to check RemotingRole; no call to db.
            //Procedures and claimprocs are straight forward in the sense that a statement will be required if their date is after dateLastStatement.
            //Payment plans are tricky in the sense that we have a preference that allows billing patients X days in advance.
            //If there is a valid procedure or claimproc date and it falls after dateLastStatement then this patient needs a statement.
            DateTime dateLastTrans = new DateTime[] {
                GetMaxDateLastTransForType(listPatAgingTransactions, PatAgingTransaction.TransactionTypes.Procedure),
                GetMaxDateLastTransForType(listPatAgingTransactions, PatAgingTransaction.TransactionTypes.ClaimProc),
            }.Max();
            //Check to see if this patient has a payment plan that has a charge date greater than the last procedure or claimproc date.
            DateTime datePayPlanChargeMax = GetMaxDateLastTransForType(listPatAgingTransactions, PatAgingTransaction.TransactionTypes.PayPlanCharge);

            if (datePayPlanChargeMax > dateLastTrans)
            {
                //There is a chance that this patient has already received a statement due to this payment plan charge due to the fact that we allow
                //for "billing X days in advance" for payment plans only (via PayPlansBillInAdvanceDays).
                long billInAdvanceDays = PrefC.GetLong(PrefName.PayPlansBillInAdvanceDays);
                //Only set dateLastTrans to a payment plan charge date if the charge falls outside of the "bill X days in advance" preference.
                //E.g. A statement on the 1st of the month is treated as having covored all payment plan charges until the 11th when pref is set to 10 days.
                //However, dateLastTrans needs to be set when a billing list is created on the 5th with a new payment plan charge on the 14th.
                //This is because the statement created on the 1st does not cover the payment plan charge on the 14th.
                DateTime datePayPlanCreateMax = GetMaxDateLastTransForType(listPatAgingTransactions, PatAgingTransaction.TransactionTypes.PayPlanCharge, true);
                if (datePayPlanChargeMax > dateLastStatement.AddDays(billInAdvanceDays) || datePayPlanCreateMax > dateLastStatement)
                {
                    dateLastTrans = datePayPlanChargeMax;
                }
            }
            return(dateLastTrans);
        }
Пример #11
0
        ///<summary>Checks for dependencies first</summary>
        public static void Delete(UserGroup group)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), group);
                return;
            }
            string command = "SELECT COUNT(*) FROM usergroupattach WHERE UserGroupNum='"
                             + POut.Long(group.UserGroupNum) + "'";
            DataTable table = Db.GetTable(command);

            if (table.Rows[0][0].ToString() != "0")
            {
                throw new Exception(Lans.g("UserGroups", "Must move users to another group first."));
            }
            if (PrefC.GetLong(PrefName.SecurityGroupForStudents) == group.UserGroupNum)
            {
                throw new Exception(Lans.g("UserGroups", "Group is the default group for students and cannot be deleted.  Change the default student group before deleting."));
            }
            if (PrefC.GetLong(PrefName.SecurityGroupForInstructors) == group.UserGroupNum)
            {
                throw new Exception(Lans.g("UserGroups", "Group is the default group for instructors and cannot be deleted.  Change the default instructors group before deleting."));
            }
            command = "DELETE FROM usergroup WHERE UserGroupNum='"
                      + POut.Long(group.UserGroupNum) + "'";
            Db.NonQ(command);
            command = "DELETE FROM grouppermission WHERE UserGroupNum='"
                      + POut.Long(group.UserGroupNum) + "'";
            Db.NonQ(command);
        }
Пример #12
0
        ///<summary>Converts the passed in time pattern into 5 minute increments.
        ///The time pattern returned is altered based on the AppointmentTimeIncrement preference.
        ///E.g. "/XX/" passed in with 10 minute increments set will return "//XXXX//"
        ///If an empty timePattern is passed in, a default pattern of //XX// will be returned (unless using 15 min inc, then ///XXX///)</summary>
        public static string ConvertTimePattern(string timePattern)
        {
            //convert time pattern to 5 minute increment
            StringBuilder patternConverted = new StringBuilder();

            for (int i = 0; i < timePattern.Length; i++)
            {
                patternConverted.Append(timePattern.Substring(i, 1));
                if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 10)
                {
                    patternConverted.Append(timePattern.Substring(i, 1));
                }
                if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15)
                {
                    patternConverted.Append(timePattern.Substring(i, 1));
                    patternConverted.Append(timePattern.Substring(i, 1));
                }
            }
            if (patternConverted.ToString() == "")
            {
                if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15)
                {
                    patternConverted.Append("///XXX///");
                }
                else
                {
                    patternConverted.Append("//XX//");
                }
            }
            return(patternConverted.ToString());
        }
Пример #13
0
        ///<summary>For UI display when we store a zero/meaningless value as -1. Returns "0" when useZero is true, otherwise "".</summary>
        public static string GetLongHideNegOne(PrefName prefName, bool useZero = false)
        {
            long prefVal = PrefC.GetLong(prefName);

            if (prefVal == -1)
            {
                return(useZero?"0":"");
            }
            return(POut.Long(prefVal));
        }
Пример #14
0
        ///<summary>We should merge these results with GetDefaultPracticeProvider(), but
        ///that would require restructuring indexes in different places in the code and this is
        ///faster to do as we are just moving the queries down in to the business layer for now.</summary>
        public static DataTable GetDefaultPracticeProvider3()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod()));
            }
            string command = @"SELECT NationalProvID " +
                             "FROM provider WHERE provnum=" +
                             POut.Long(PrefC.GetLong(PrefName.PracticeDefaultProv));

            return(Db.GetTable(command));
        }
Пример #15
0
 ///<summary>Returns and error message to display to the user if default clearinghouses are not set up; Otherwise, empty string.</summary>
 public static string CheckClearinghouseDefaults()
 {
     if (PrefC.GetLong(PrefName.ClearinghouseDefaultDent) == 0)
     {
         return(Lans.g("ContrAccount", "No default dental clearinghouse defined."));
     }
     if (PrefC.GetBool(PrefName.ShowFeatureMedicalInsurance) && PrefC.GetLong(PrefName.ClearinghouseDefaultMed) == 0)
     {
         return(Lans.g("ContrAccount", "No default medical clearinghouse defined."));
     }
     return("");
 }
Пример #16
0
 ///<summary>Returns practice default for invalid clinicNums.</summary>
 public static PlaceOfService GetPlaceService(long clinicNum)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < List.Length; i++)
     {
         if (List[i].ClinicNum == clinicNum)
         {
             return(List[i].DefaultPlaceService);
         }
     }
     return((PlaceOfService)PrefC.GetLong(PrefName.DefaultProcedurePlaceService));
     //return PlaceOfService.Office;
 }
Пример #17
0
        ///<summary>We should merge these results with GetDefaultPracticeProvider(), but
        ///that would require restructuring indexes in different places in the code and this is
        ///faster to do as we are just moving the queries down in to the business layer for now.</summary>
        public static DataTable GetDefaultPracticeProvider2()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod()));
            }
            string command = @"SELECT FName,LName,Specialty " +
                             "FROM provider WHERE provnum=" +
                             POut.Long(PrefC.GetLong(PrefName.PracticeDefaultProv));

            //Convert.ToInt32(((Pref)PrefC.HList["PracticeDefaultProv"]).ValueString);
            return(Db.GetTable(command));
        }
Пример #18
0
        ///<summary>Returns the clearinghouseNum for claims for the supplied payorID.  If the payorID was not entered or if no default was set, then 0 is returned.</summary>
        public static long AutomateClearinghouseSelection(string payorID, EnumClaimMedType medType)
        {
            //No need to check RemotingRole; no call to db.
            //payorID can be blank.  For example, Renaissance does not require payorID.
            if (HList == null)
            {
                RefreshCache();
            }
            Clearinghouse clearinghouse = null;

            if (medType == EnumClaimMedType.Dental)
            {
                if (PrefC.GetLong(PrefName.ClearinghouseDefaultDent) == 0)
                {
                    return(0);
                }
                clearinghouse = GetClearinghouse(PrefC.GetLong(PrefName.ClearinghouseDefaultDent));
            }
            if (medType == EnumClaimMedType.Medical || medType == EnumClaimMedType.Institutional)
            {
                if (PrefC.GetLong(PrefName.ClearinghouseDefaultMed) == 0)
                {
                    return(0);
                }
                clearinghouse = GetClearinghouse(PrefC.GetLong(PrefName.ClearinghouseDefaultMed));
            }
            if (clearinghouse == null)          //we couldn't find a default clearinghouse for that medType.  Needs to always be a default.
            {
                return(0);
            }
            if (payorID != "" && HList.ContainsKey(payorID))          //an override exists for this payorID
            {
                Clearinghouse ch = GetClearinghouse((long)HList[payorID]);
                if (ch.Eformat == ElectronicClaimFormat.x837D_4010 || ch.Eformat == ElectronicClaimFormat.x837D_5010_dental)
                {
                    if (medType == EnumClaimMedType.Dental)                  //med type matches
                    {
                        return(ch.ClearinghouseNum);
                    }
                }
                if (ch.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
                {
                    if (medType == EnumClaimMedType.Medical || medType == EnumClaimMedType.Institutional)                //med type matches
                    {
                        return(ch.ClearinghouseNum);
                    }
                }
            }
            //no override, so just return the default.
            return(clearinghouse.ClearinghouseNum);
        }
Пример #19
0
 ///<summary>Checks the loaded prefs and accountingAutoPays to see if user has setup auto pay linking.  Returns true if so.</summary>
 public static bool PaymentsLinked()
 {
     //No need to check RemotingRole; no call to db.
     if (AccountingAutoPays.GetCount() == 0)
     {
         return(false);
     }
     if (PrefC.GetLong(PrefName.AccountingCashIncomeAccount) == 0)
     {
         return(false);
     }
     //might add a few more checks later.
     return(true);
 }
Пример #20
0
        ///<summary>Returns the clearinghouseNum for claims for the supplied payorID.  If the payorID was not entered or if no default was set, then 0 is returned.</summary>
        public static long AutomateClearinghouseHqSelection(string payorID, EnumClaimMedType medType)
        {
            //No need to check RemotingRole; no call to db.
            //payorID can be blank.  For example, Renaissance does not require payorID.
            Clearinghouse clearinghouseHq = null;

            if (medType == EnumClaimMedType.Dental)
            {
                if (PrefC.GetLong(PrefName.ClearinghouseDefaultDent) == 0)
                {
                    return(0);
                }
                clearinghouseHq = GetClearinghouse(PrefC.GetLong(PrefName.ClearinghouseDefaultDent));
            }
            if (medType == EnumClaimMedType.Medical || medType == EnumClaimMedType.Institutional)
            {
                if (PrefC.GetLong(PrefName.ClearinghouseDefaultMed) == 0)
                {
                    return(0);
                }
                clearinghouseHq = GetClearinghouse(PrefC.GetLong(PrefName.ClearinghouseDefaultMed));
            }
            if (clearinghouseHq == null)          //we couldn't find a default clearinghouse for that medType.  Needs to always be a default.
            {
                return(0);
            }
            Clearinghouse clearingHouseOverride = GetClearinghouseByPayorID(payorID);

            if (clearingHouseOverride != null)           //an override exists for this payorID
            {
                if (clearingHouseOverride.Eformat == ElectronicClaimFormat.x837D_4010 || clearingHouseOverride.Eformat == ElectronicClaimFormat.x837D_5010_dental ||
                    clearingHouseOverride.Eformat == ElectronicClaimFormat.Canadian || clearingHouseOverride.Eformat == ElectronicClaimFormat.Ramq)
                {                                           //all dental formats
                    if (medType == EnumClaimMedType.Dental) //med type matches
                    {
                        return(clearingHouseOverride.ClearinghouseNum);
                    }
                }
                if (clearingHouseOverride.Eformat == ElectronicClaimFormat.x837_5010_med_inst)
                {
                    if (medType == EnumClaimMedType.Medical || medType == EnumClaimMedType.Institutional)                 //med type matches
                    {
                        return(clearingHouseOverride.ClearinghouseNum);
                    }
                }
            }
            //no override, so just return the default.
            return(clearinghouseHq.ClearinghouseNum);
        }
Пример #21
0
        ///<summary>Returns a list of valid diseasedefnums to delete from the passed in list.</summary>
        public static List <long> ValidateDeleteList(List <long> listDiseaseDefNums)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), listDiseaseDefNums));
            }
            List <long> listDiseaseDefNumsNotDeletable = new List <long>();

            if (listDiseaseDefNums == null || listDiseaseDefNums.Count < 1)
            {
                return(listDiseaseDefNumsNotDeletable);
            }
            //In use by preference
            if (listDiseaseDefNums.Contains(PrefC.GetLong(PrefName.ProblemsIndicateNone)))
            {
                listDiseaseDefNumsNotDeletable.Add(PrefC.GetLong(PrefName.ProblemsIndicateNone));
            }
            //Validate patient attached
            string command = "SELECT DISTINCT disease.DiseaseDefNum "
                             + "FROM patient,disease "
                             + "WHERE patient.PatNum=disease.PatNum "
                             + "AND disease.DiseaseDefNum IN (" + String.Join(",", listDiseaseDefNums) + ") ";

            try {
                listDiseaseDefNumsNotDeletable.AddRange(Db.GetListLong(command));
            }
            catch {
                //Do Nothing
            }
            //Validate edu resource attached
            command = "SELECT DISTINCT eduresource.DiseaseDefNum FROM eduresource WHERE eduresource.DiseaseDefNum IN (" + String.Join(",", listDiseaseDefNums) + ") ";
            try {
                listDiseaseDefNumsNotDeletable.AddRange(Db.GetListLong(command));
            }
            catch {
                //Do Nothing
            }
            //Validate family health history attached
            command = "SELECT DISTINCT familyhealth.DiseaseDefNum FROM patient,familyhealth "
                      + "WHERE patient.PatNum=familyhealth.PatNum "
                      + "AND familyhealth.DiseaseDefNum IN (" + String.Join(",", listDiseaseDefNums) + ") ";
            try {
                listDiseaseDefNumsNotDeletable.AddRange(Db.GetListLong(command));
            }
            catch {
                //Do Nothing
            }
            return(listDiseaseDefNumsNotDeletable);
        }
Пример #22
0
        ///<summary>This overload is for when the listForPeriod includes only one day.</summary>
        public static List <Schedule> GetSchedsForOp(List <Schedule> listForPeriod, Operatory op)
        {
            //No need to check RemotingRole; no call to db.
            List <Schedule> retVal = new List <Schedule>();

            for (int i = 0; i < listForPeriod.Count; i++)
            {
                //if a schedule is not a provider type, then skip it
                if (listForPeriod[i].SchedType != ScheduleType.Provider)
                {
                    continue;
                }
                //if the schedule has ops set, then only apply the schedule to those ops
                if (listForPeriod[i].Ops.Count > 0)
                {
                    if (listForPeriod[i].Ops.Contains(op.OperatoryNum))
                    {
                        retVal.Add(listForPeriod[i].Copy());
                    }
                }
                //but if the schedule does not have ops set, then look at the op settings to determine whether to use it.
                else
                {
                    if (op.ProvDentist != 0 && !op.IsHygiene)                   //op uses dentist
                    {
                        if (listForPeriod[i].ProvNum == op.ProvDentist)
                        {
                            retVal.Add(listForPeriod[i].Copy());
                        }
                    }
                    else if (op.ProvHygienist != 0 && op.IsHygiene)                   //op uses hygienist
                    {
                        if (listForPeriod[i].ProvNum == op.ProvHygienist)
                        {
                            retVal.Add(listForPeriod[i].Copy());
                        }
                    }
                    else                      //op has no provider set
                                              //so use the provider that's set for unassigned ops
                    {
                        if (listForPeriod[i].ProvNum == PrefC.GetLong(PrefName.ScheduleProvUnassigned))
                        {
                            retVal.Add(listForPeriod[i].Copy());
                        }
                    }
                }
            }
            return(retVal);
        }
Пример #23
0
        ///<summary>Returns 0 if clinics not in use, or patient.ClinicNum if assigned to a clinic, or ClinicNum of the default texting clinic.</summary>
        public static long GetClinicNumForTexting(long patNum)
        {
            //No need to check RemotingRole; no call to db.
            if (!PrefC.HasClinicsEnabled || Clinics.GetCount() == 0)
            {
                return(0);                                                        //0 used for no clinics
            }
            Clinic clinic = Clinics.GetClinic(Patients.GetPat(patNum).ClinicNum); //if patnum invalid will throw unhandled exception.

            if (clinic != null)                                                   //if pat assigned to invalid clinic or clinic num 0
            {
                return(clinic.ClinicNum);
            }
            return(PrefC.GetLong(PrefName.TextingDefaultClinicNum));
        }
Пример #24
0
        ///<summary>Checks if the current database connected to is the replication report server.  Allows users to run dangerous custom queries that could potentially break replication.  We will allow these queries to be run on exactly one replication server (the report server), because our custom queries contain CREATE TABLE statements for static temporary table names which can cause replication failure if multiple users run the same query at the same time.</summary>
        public static bool IsConnectedReportServer()
        {
            //No need to check RemotingRole; no call to db.
            if (PrefC.GetLong(PrefName.ReplicationUserQueryServer) == 0)           //Report server not set up.
            {
                return(false);
            }
            ReplicationServer repServer = GetForLocalComputer();

            if (repServer == null || repServer.ReplicationServerNum != PrefC.GetLong(PrefName.ReplicationUserQueryServer))
            {
                return(false);
            }
            return(true);
        }
Пример #25
0
        ///<summary>Returns a list of PatNums that have an allergy from the PatNums that are passed in.</summary>
        public static List <long> GetPatientsWithAllergy(List <long> listPatNums)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <List <long> >(MethodBase.GetCurrentMethod(), listPatNums));
            }
            if (listPatNums.Count == 0)
            {
                return(new List <long>());
            }
            string command = "SELECT DISTINCT PatNum FROM allergy WHERE PatNum IN (" + string.Join(",", listPatNums) + ") "
                             + "AND allergy.AllergyDefNum != " + POut.Long(PrefC.GetLong(PrefName.AllergiesIndicateNone));

            return(Db.GetListLong(command));
        }
Пример #26
0
        ///<summary>Creates a new discount adjustment for the given procedure.</summary>
        public static void CreateAdjustmentForDiscount(Procedure procedure)
        {
            //No need to check RemotingRole; no call to db.
            Adjustment AdjustmentCur = new Adjustment();

            AdjustmentCur.DateEntry = DateTime.Today;
            AdjustmentCur.AdjDate   = DateTime.Today;
            AdjustmentCur.ProcDate  = procedure.ProcDate;
            AdjustmentCur.ProvNum   = procedure.ProvNum;
            AdjustmentCur.PatNum    = procedure.PatNum;
            AdjustmentCur.AdjType   = PrefC.GetLong(PrefName.TreatPlanDiscountAdjustmentType);
            AdjustmentCur.ClinicNum = procedure.ClinicNum;
            AdjustmentCur.AdjAmt    = -procedure.Discount;       //Discount must be negative here.
            AdjustmentCur.ProcNum   = procedure.ProcNum;
            Adjustments.Insert(AdjustmentCur);
        }
Пример #27
0
        ///<summary>Returns a string if medication is in use in medicationpat, allergydef, eduresources, or preference.MedicationsIndicateNone. The string will explain where the medication is in use.</summary>
        public static string IsInUse(Medication med)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetString(MethodBase.GetCurrentMethod(), med));
            }
            string[] brands;
            if (med.MedicationNum == med.GenericNum)
            {
                brands = GetBrands(med.MedicationNum);
            }
            else
            {
                brands = new string[0];
            }
            if (brands.Length > 0)
            {
                return("You can not delete a medication that has brand names attached.");
            }
            string command = "SELECT COUNT(*) FROM medicationpat WHERE MedicationNum=" + POut.Long(med.MedicationNum);

            if (PIn.Int(Db.GetCount(command)) != 0)
            {
                return("Not allowed to delete medication because it is in use by a patient");
            }
            command = "SELECT COUNT(*) FROM allergydef WHERE MedicationNum=" + POut.Long(med.MedicationNum);
            if (PIn.Int(Db.GetCount(command)) != 0)
            {
                return("Not allowed to delete medication because it is in use by an allergy");
            }
            command = "SELECT COUNT(*) FROM eduresource WHERE MedicationNum=" + POut.Long(med.MedicationNum);
            if (PIn.Int(Db.GetCount(command)) != 0)
            {
                return("Not allowed to delete medication because it is in use by an education resource");
            }
            command = "SELECT COUNT(*) FROM rxalert WHERE MedicationNum=" + POut.Long(med.MedicationNum);
            if (PIn.Int(Db.GetCount(command)) != 0)
            {
                return("Not allowed to delete medication because it is in use by an Rx alert");
            }
            //If any more tables are added here in the future, then also update GetAllInUseMedicationNums() to include the new table.
            if (PrefC.GetLong(PrefName.MedicationsIndicateNone) == med.MedicationNum)
            {
                return("Not allowed to delete medication because it is in use by a medication");
            }
            return("");
        }
Пример #28
0
 public static bool IsSpecialRecallType(long recallTypeNum)
 {
     //No need to check RemotingRole; no call to db.
     if (recallTypeNum == PrefC.GetLong(PrefName.RecallTypeSpecialProphy))
     {
         return(true);
     }
     if (recallTypeNum == PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy))
     {
         return(true);
     }
     if (recallTypeNum == PrefC.GetLong(PrefName.RecallTypeSpecialPerio))
     {
         return(true);
     }
     return(false);
 }
Пример #29
0
 public static string GetSpecialTypeStr(long recallTypeNum)
 {
     //No need to check RemotingRole; no call to db.
     if (recallTypeNum == PrefC.GetLong(PrefName.RecallTypeSpecialProphy))
     {
         return(Lans.g("FormRecallTypeEdit", "Prophy"));
     }
     if (recallTypeNum == PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy))
     {
         return(Lans.g("FormRecallTypeEdit", "ChildProphy"));
     }
     if (recallTypeNum == PrefC.GetLong(PrefName.RecallTypeSpecialPerio))
     {
         return(Lans.g("FormRecallTypeEdit", "Perio"));
     }
     return("");
 }
Пример #30
0
        /// <summary>Saves to either AtoZ folder or to db.  Saves image as a jpg.  Compression will be according to user setting.</summary>
        public static EobAttach ImportEobAttach(Bitmap image, long claimPaymentNum)
        {
            string eobFolder = "";

            if (PrefC.UsingAtoZfolder)
            {
                eobFolder = GetEobFolder();
            }
            EobAttach eob = new EobAttach();

            eob.FileName        = ".jpg";
            eob.DateTCreated    = DateTime.Now;
            eob.ClaimPaymentNum = claimPaymentNum;
            EobAttaches.Insert(eob);            //creates filename and saves to db
            eob = EobAttaches.GetOne(eob.EobAttachNum);
            long           qualityL = PrefC.GetLong(PrefName.ScannerCompression);
            ImageCodecInfo myImageCodecInfo;

            ImageCodecInfo[] encoders;
            encoders         = ImageCodecInfo.GetImageEncoders();
            myImageCodecInfo = null;
            for (int j = 0; j < encoders.Length; j++)
            {
                if (encoders[j].MimeType == "image/jpeg")
                {
                    myImageCodecInfo = encoders[j];
                }
            }
            EncoderParameters myEncoderParameters = new EncoderParameters(1);
            EncoderParameter  myEncoderParameter  = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityL);

            myEncoderParameters.Param[0] = myEncoderParameter;
            try {
                SaveEobAttach(eob, image, myImageCodecInfo, myEncoderParameters, eobFolder);
                if (!PrefC.UsingAtoZfolder)
                {
                    EobAttaches.Update(eob);                    //because SaveEobAttach stuck the image in eob.RawBase64.
                    //no thumbnail
                }
            }
            catch {
                EobAttaches.Delete(eob.EobAttachNum);
                throw;
            }
            return(eob);
        }