///<summary>True if we are in HQ, AvaTax is enabled, we tax the customer's state, and either the customer's tax exempt field is not defined or ///they are explicitly not tax exempt. Executes a small query.</summary> public static bool IsTaxable(long patNum) { if (!IsEnabled()) { return(false); //Save a few db calls } Patient pat = Patients.GetPat(patNum); if (pat == null) { return(false); } PatField taxExempt = null; if (TaxExemptPatField != null) { taxExempt = PatFields.Refresh(patNum).FirstOrDefault(x => x.FieldName == TaxExemptPatField.FieldName); } if (ListTaxableStates.Count == 0) { return(false); } if (!HasTaxableState(pat)) //if they aren't taxable, skip them { return(false); } if (taxExempt != null && PIn.Bool(taxExempt.FieldValue)) { return(false); } return(true); }
///<summary>True if we are in HQ, AvaTax is enabled, we tax the customer's state, and the procedure has a taxable proccode. Note that if the ///customer has an invalid zip but all other conditions are met, we will still return true because this procedure is still taxable by our rules ///we just know we would get an error back from Avalara. This method returning false will result in the procedure being created as before ///but without tax, so we need to return true for an invalid zip and let Avalara produce the error. Can execute two queries.</summary> public static bool DoSendProcToAvalara(Procedure proc, bool isSilent = false) { ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum); if (!IsEnabled()) { return(false); } if (proc.ProcFee == 0) //repeat charges for prepay use ProcFee=0 { return(false); } Patient patient = Patients.GetPat(proc.PatNum); //don't call IsTaxable() here, because that would get pat twice, so duplicating some if its functionality: if (patient == null) { return(false); } if (ListTaxableStates.Count == 0) { return(false); //no taxable states } if (!HasTaxableState(patient)) //if this patient is not in a taxable state { return(false); } if (TaxExemptPatField == null) //no tax exempt pat field entered in setup { return(false); } PatField taxExempt = PatFields.Refresh(patient.PatNum).FirstOrDefault(x => x.FieldName == TaxExemptPatField.FieldName); if (taxExempt != null && PIn.Bool(taxExempt.FieldValue)) //patient field exists and is true { return(false); //so not taxable } //end of the duplicated functionality from IsTaxable(). string procTaxCode = GetTaxOverrideIfNeeded(patient, procCode); //could be an avalara code, an override, or a percent if (string.IsNullOrWhiteSpace(procTaxCode)) //if there is no avalara code or percent for this proc/state { return(false); } if (!Patients.HasValidUSZipCode(patient)) { if (isSilent) { _logger.WriteLine($"Invalid ZipCode for PatNum {proc.PatNum} while running Repeat Charge Tool on {DateTime.Today}", LogLevel.Error); } else { //Remove the message box for now to avoid it from popping up on the server, stopping anyone using middletier to continue //forward, because they can't click OK in the message box. //MessageBox.Show("A valid zip code is required to process sales tax on procedures in this patient's state. " //+"Please update the patient information with a valid zip code before continuing."); } } return(true); }
///<summary>Gets the data necessary to load the Family Module.</summary> public static LoadData GetLoadData(long patNum, bool doCreateSecLog) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <LoadData>(MethodBase.GetCurrentMethod(), patNum, doCreateSecLog)); } LoadData data = new LoadData(); data.Fam = Patients.GetFamily(patNum); data.Pat = data.Fam.GetPatient(patNum); data.ListPatPlans = PatPlans.Refresh(patNum); if (!PatPlans.IsPatPlanListValid(data.ListPatPlans)) //PatPlans had invalid references and need to be refreshed. { data.ListPatPlans = PatPlans.Refresh(patNum); } data.PatNote = PatientNotes.Refresh(patNum, data.Pat.Guarantor); data.ListInsSubs = InsSubs.RefreshForFam(data.Fam); data.ListInsPlans = InsPlans.RefreshForSubList(data.ListInsSubs); data.ListBenefits = Benefits.Refresh(data.ListPatPlans, data.ListInsSubs); data.ListRecalls = Recalls.GetList(data.Fam.ListPats.Select(x => x.PatNum).ToList()); data.ArrPatFields = PatFields.Refresh(patNum); data.SuperFamilyMembers = Patients.GetBySuperFamily(data.Pat.SuperFamily); data.SuperFamilyGuarantors = Patients.GetSuperFamilyGuarantors(data.Pat.SuperFamily); data.DictCloneSpecialities = Patients.GetClonesAndSpecialties(patNum); data.PatPict = Documents.GetPatPictFromDb(patNum); data.HasPatPict = (data.PatPict == null ? YN.No : YN.Yes); List <DisplayField> listDisplayFields = DisplayFields.GetForCategory(DisplayFieldCategory.PatientInformation); foreach (DisplayField field in listDisplayFields) { switch (field.InternalName) { case "Guardians": data.ListGuardians = Guardians.Refresh(patNum); break; case "Pat Restrictions": data.ListPatRestricts = PatRestrictions.GetAllForPat(patNum); break; case "Payor Types": data.PayorTypeDesc = PayorTypes.GetCurrentDescription(patNum); break; case "PatFields": data.ListPatFieldDefLinks = FieldDefLinks.GetForLocation(FieldLocations.Family); break; case "References": data.ListCustRefEntries = CustRefEntries.GetEntryListForCustomer(patNum); break; case "Referrals": data.ListRefAttaches = RefAttaches.Refresh(patNum); break; case "ResponsParty": if (data.Pat.ResponsParty != 0) { data.ResponsibleParty = Patients.GetLim(data.Pat.ResponsParty); } break; } } if (data.Pat.DiscountPlanNum != 0) { data.DiscountPlan = DiscountPlans.GetPlan(data.Pat.DiscountPlanNum); } data.ListMergeLinks = PatientLinks.GetLinks(data.Fam.ListPats.Select(x => x.PatNum).ToList(), PatientLinkType.Merge); if (doCreateSecLog) { SecurityLogs.MakeLogEntry(Permissions.FamilyModule, patNum, ""); } return(data); }