/// <summary>Checks if the Fee Schedule is invalidated. If it is invalidated, refresh the fees for that Fee Sched and the clinics in the queue /// from the db.</summary> public void RefreshInvalidFees(long feeSchedNum) { if (_dict.IsFeeSchedInvalidated(feeSchedNum)) { List <Fee> listFeeSchedFees = Fees.GetByFeeSchedNumsClinicNums(new List <long> { feeSchedNum }, this._queueClinicNums.ToList()); _dict.RefreshFeeSched(feeSchedNum, listFeeSchedFees); } }
///<summary>Get all non-hidden fee sched fees for a clinic and add to the cache. Cannot be used as part of a transaction.</summary> private void AddClinicFees(long clinicNum) { List <long> listFeeScheds = FeeScheds.GetDeepCopy(true).Select(x => x.FeeSchedNum).ToList(); List <Fee> listFees = Fees.GetByFeeSchedNumsClinicNums(listFeeScheds, new List <long>() { clinicNum }); Add(listFees); }
///<summary>Load the dictionary with the non-hidden fee schedule fees for each of the clinics currently in the queue.</summary> public void Initialize() { List <long> listFeeScheds = FeeScheds.GetDeepCopy(true).Select(x => x.FeeSchedNum).ToList(); _dict = new FeeCacheDictionary(Fees.GetByFeeSchedNumsClinicNums(listFeeScheds, _queueClinicNums.ToList())); }
///<summary>Get the list of fees for a list of feeSchedules and their clinicNums and add to the cache. Cannot be used as part of a transaction.</summary> private void AddFeeSchedFees(List <long> listFeeScheds, List <long> listClinicNums) { List <Fee> listFees = Fees.GetByFeeSchedNumsClinicNums(listFeeScheds, listClinicNums); Add(listFees); }
///<summary>Attempts to return the fee that best matches the provided codeNum, feeSchedNum, clinicNum, and provNum. ///When doGetExactMatch is true, this will return either the fee that matches the parameters exactly, or null if no such fee exists. ///When doGetExactMatch is false, and the fee schedule is global, we ignore the clinicNum and provNum and return the HQ fee that matches the given codeNum and feeSchedNum. ///When doGetExactMatch is false, and the fee schedule is not global, and no exact match exists we attempt to return the closest matching fee in this order: ///1 - The fee with the same codeNum, feeSchedNum, and providerNum, with a clinicNum of 0 ///2 - The fee with the same codeNum, feeSchedNum, and clinicNum, with a providerNum of 0 ///3 - The fee with the same codeNum, feeSchedNum, and both a clinicNum and providerNum of 0 ///If no partial match can be found, return null.</summary> public Fee GetFee(long codeNum, long feeSchedNum, long clinicNum = 0, long provNum = 0, bool doGetExactMatch = false) { AddClinicNum(clinicNum); //Global fee schedules will never have clinicNum or provNum, so force them to equal 0 if they are not. if (FeeScheds.IsGlobal(feeSchedNum) && !doGetExactMatch) { clinicNum = 0; provNum = 0; } if (!_dict.ContainsFeeSched(feeSchedNum)) { //This is likely a hidden fee sched. We will add the fee sched to the cache now. List <Fee> listFeeSchedFees = Fees.GetByFeeSchedNumsClinicNums(new List <long> { feeSchedNum }, this._queueClinicNums.ToList()); if (listFeeSchedFees.Count == 0) { _dict.AddFeeSchedOnly(feeSchedNum); } else { this.Add(listFeeSchedFees); } } if (!_dict.ContainsFeeSchedAndClinic(feeSchedNum, clinicNum)) { _dict.AddFeeSchedClinicNumOnly(feeSchedNum, clinicNum); } RefreshInvalidFees(feeSchedNum); //If the logic changes here, then we need to change FeeNoCache.GetFee. FeeKey feeKey = new FeeKey(feeSchedNum, clinicNum, codeNum, provNum); Fee exactMatch; if (_dict.TryGetValue(feeKey, out exactMatch)) { return(exactMatch); //Found an exact match on clinic and provider } //Can't find exact an exact match if (doGetExactMatch) { return(null); } //We don't need an exact match, try same provider and codeNum with default clinic. feeKey = new FeeKey(feeSchedNum, 0, codeNum, provNum); Fee partialMatch; if (_dict.TryGetValue(feeKey, out partialMatch)) { return(partialMatch); } //Can't find a match for the provider, try same clinic with no provider. feeKey = new FeeKey(feeSchedNum, clinicNum, codeNum, 0); if (_dict.TryGetValue(feeKey, out partialMatch)) { return(partialMatch); } //Can't find a match for the clinic, try the default for this code. feeKey = new FeeKey(feeSchedNum, 0, codeNum, 0); if (_dict.TryGetValue(feeKey, out partialMatch)) { return(partialMatch); } return(null); //This fee sched does not have a default fee for this code. }