/// <summary>
        /// Evaluates the type of the payment.
        /// </summary>
        /// <param name="paymentResult">The payment result.</param>
        /// <param name="claimCharge">The claim charge.</param>
        /// <returns></returns>
        private void EvaluateLine(PaymentResult paymentResult, ClaimCharge claimCharge)
        {
            //Update PaymentResult and set matching ServiceTypeId,PaymentTypeDetailId & PaymentTypeId
            Utilities.UpdatePaymentResult(paymentResult, PaymentTypeFeeSchedule.ServiceTypeId,
                                          PaymentTypeFeeSchedule.PaymentTypeDetailId, PaymentTypeFeeSchedule.PaymentTypeId);

            if (PaymentTypeFeeSchedule.ClaimFieldDoc != null &&
                PaymentTypeFeeSchedule.ClaimFieldDoc.ClaimFieldValues != null &&
                PaymentTypeFeeSchedule.ClaimFieldDoc.ClaimFieldValues.Count > 0)
            {
                string          hcpcsCode       = claimCharge.HcpcsCodeWithModifier.ToUpper();
                ClaimFieldValue claimFieldValue =
                    PaymentTypeFeeSchedule.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(
                        currentClaimFieldValue =>
                        (currentClaimFieldValue.Identifier.ToUpper() == hcpcsCode));
                if (claimFieldValue == null && hcpcsCode.Trim().Length != 5)
                {
                    claimFieldValue = PaymentTypeFeeSchedule.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(
                        currentClaimFieldValue =>
                        (currentClaimFieldValue.Identifier.ToUpper() == hcpcsCode.Substring(0, 5)));
                }
                if (claimFieldValue != null)
                {
                    ApplyFeeSchedule(paymentResult, claimFieldValue, claimCharge);
                }
                else
                {
                    ApplyNonFeeSchedule(paymentResult, claimCharge);
                }
            }
        }
Пример #2
0
        private void GetValidChargeAdjudicatedValue(ClaimFieldValue validCode, IEnumerable <ClaimCharge> validCharges, List <PaymentResult> validPaymentResults, ref int order)
        {
            foreach (var charge in validCharges)
            {
                PaymentResult paymentResult =
                    validPaymentResults.FirstOrDefault(
                        currentPaymentResult =>
                        currentPaymentResult.Line == charge.Line && validCode.Line == charge.Line && currentPaymentResult.AdjudicatedValue == null);
                if (paymentResult != null)
                {
                    //Update PaymentResult and set matching ServiceTypeId,PaymentTypeDetailId & PaymentTypeId
                    Utilities.UpdatePaymentResult(paymentResult, PaymentTypeAscFeeSchedule.ServiceTypeId,
                                                  PaymentTypeAscFeeSchedule.PaymentTypeDetailId, PaymentTypeAscFeeSchedule.PaymentTypeId);

                    string hcpcsCode = charge.HcpcsCode.ToUpper();

                    if ((hcpcsCode == validCode.Identifier || hcpcsCode.Substring(0, 5) == validCode.Identifier.Substring(0, 5)) && validCode.Line == charge.Line)
                    {
                        string amount = validCode.Value;
                        switch (order)
                        {
                        case 0:
                            GetAdjudicatedValue(PaymentTypeAscFeeSchedule.Primary, amount, paymentResult);
                            break;

                        case 1:
                            GetAdjudicatedValue(PaymentTypeAscFeeSchedule.Secondary, amount, paymentResult);
                            break;

                        case 2:
                            GetAdjudicatedValue(PaymentTypeAscFeeSchedule.Tertiary, amount, paymentResult);
                            break;

                        case 3:
                            GetAdjudicatedValue(PaymentTypeAscFeeSchedule.Quaternary, amount, paymentResult);
                            break;

                        default:
                            GetAdjudicatedValue(PaymentTypeAscFeeSchedule.Others, amount, paymentResult);
                            break;
                        }
                        order++;
                        break;
                    }
                }
            }
        }
        //TODO: This method is referring to an SP "AddEditCAPPayment" not present, so I assume this method is not in use. Please verify.
        /// <summary>
        /// Adds the claim field values.
        /// </summary>
        /// <param name="claimFieldValues">The claim field values.</param>
        /// <returns></returns>
        public long AddClaimFieldValues(ClaimFieldValue claimFieldValues)
        {
            //Checks if input request is not null
            if (claimFieldValues != null)
            {
                // Initialize the Stored Procedure
                _databaseCommandObj = _databaseObj.GetStoredProcCommand("AddEditClaimFieldvalues");
                // Pass parameters to Stored Procedure(i.e., @ParamName), add values for

                // Retrieve the results of the Stored Procedure in Dataset
                long claimFieldValueId;
                long returnValue = long.TryParse(_databaseObj.ExecuteScalar(_databaseCommandObj).ToString(), out claimFieldValueId) ? claimFieldValueId : 0;

                //returns response to Business layer
                return(returnValue);
            }
            return(0);
        }
        /// <summary>
        /// prepares a dictionary of variables and values present in excel sheet
        /// </summary>
        /// <param name="uploadedValue">uploaded values</param>
        /// <returns>a dictionary with variables and values</returns>
        private Dictionary <string, string> PrepareClaimFieldDocValueDictionary(ClaimFieldValue uploadedValue)
        {
            Dictionary <string, string> claimFieldDocValueDictionary = new Dictionary <string, string>();

            List <string> headers = Utilities.SplitCsvRowToArray(PaymentTypeCustomTable.ClaimFieldDoc.ColumnHeaderSecond);
            List <string> values  = Utilities.SplitCsvRowToArrayForAdjudication(uploadedValue.Value);

            for (int index = 0; index < headers.Count; index++)
            {
                string value = Regex.Replace(
                    values == null || values.Count == 0 || values.Count < index - 1 ? string.Empty : values[index],
                    Constants.RegExPatternDoubleUnderscore, string.Empty);
                claimFieldDocValueDictionary.Add(
                    Constants.ReferenceTableTag + Regex.Replace(headers[index], Constants.RegExPatternDoubleUnderscore, Constants.Comma),
                    Regex.Replace(value, Constants.RegExPatternSpecialCharacter, string.Empty));
            }

            return(claimFieldDocValueDictionary);
        }
 /// <summary>
 /// Gets the code and occurence value.
 /// </summary>
 /// <param name="uploadedValue">The uploaded value.</param>
 /// <param name="codeDetailsList">The codes.</param>
 /// <param name="claimCharge">The claim charge.</param>
 /// <param name="codeDetails">The code details.</param>
 private void GetCodeAndOccurenceValue(ClaimFieldValue uploadedValue, IEnumerable <CodeDetails> codeDetailsList,
                                       ClaimCharge claimCharge, CodeDetails codeDetails)
 {
     if (!PaymentTypeCustomTable.IsPerDayOfStay)
     {
         CodeDetails perCode = codeDetailsList.First(
             pday => pday.Code == uploadedValue.Identifier);
         codeDetails.Occurence = perCode.Occurence;
         codeDetails.Code      = perCode.Code;
         codeDetails.Limit     = perCode.Limit;
     }
     else
     {
         CodeDetails perDayOfStay = codeDetailsList.First(
             pday => pday.Code == uploadedValue.Identifier && pday.Day == claimCharge.ServiceFromDate);
         codeDetails.Occurence = perDayOfStay.Occurence;
         codeDetails.Code      = perDayOfStay.Code;
         codeDetails.Limit     = perDayOfStay.Limit;
     }
 }
        /// <summary>
        /// Evaluates the claim at claim level
        /// </summary>
        /// <param name="claim">claim to be adjudicated</param>
        /// <param name="paymentResults">payment result out of adjudicated claim</param>
        /// <param name="isCarveOut">if the service type is carved out</param>
        /// <returns>list of payment results</returns>
        private List <PaymentResult> EvaluateClaimLevel(IEvaluateableClaim claim, List <PaymentResult> paymentResults, bool isCarveOut)
        {
            ClaimFieldValue uploadedValue = GetMatchedClaimFieldValues(claim);

            if (uploadedValue != null)
            {
                PaymentResult claimPaymentResult = GetClaimLevelPaymentResult(paymentResults, isCarveOut);
                if (claimPaymentResult != null)
                {
                    EvaluateAdjudicatedValue(claimPaymentResult, uploadedValue, claim);
                    //Remove PaymentResult if its not satisfied threshold condition
                    if (claimPaymentResult.AdjudicatedValue == null &&
                        claimPaymentResult.ClaimStatus == (byte)Enums.AdjudicationOrVarianceStatuses.UnAdjudicated)
                    {
                        paymentResults.Remove(claimPaymentResult);
                    }
                }
            }
            return(paymentResults);
        }
        /// <summary>
        /// Evaluates the type of the payment.
        /// </summary>
        /// <param name="paymentResults">The payment result.</param>
        /// <param name="claim">The claim.</param>
        /// <param name="claimCharge">The claim charge.</param>
        /// <param name="isCarveOut">if set to <c>true</c> [is carve out].</param>
        /// <param name="codeDetailsList">The per day of stays.</param>
        private void EvaluateLine(List <PaymentResult> paymentResults, IEvaluateableClaim claim, ClaimCharge claimCharge, bool isCarveOut, List <CodeDetails> codeDetailsList)
        {
            if (PaymentTypeCustomTable.ClaimFieldDoc != null &&
                PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues != null &&
                PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.Count > 0)
            {
                string          limitExpandedExpression = PaymentTypeCustomTable.ObserveServiceUnitLimit;
                ClaimFieldValue uploadedValue           = GetMatchedClaimFieldValues(claim, claimCharge);
                if (uploadedValue != null)
                {
                    PaymentResult paymentResult = GetPaymentResult(paymentResults, isCarveOut, claimCharge.Line);
                    if (paymentResult != null)
                    {
                        claim.SmartBox.LC = claimCharge.Amount;
                        Dictionary <string, string> claimFieldDocValueDictionary =
                            PrepareClaimFieldDocValueDictionary(uploadedValue);
                        int limit = 0;
                        if (!string.IsNullOrWhiteSpace(PaymentTypeCustomTable.ObserveServiceUnitLimit))
                        {
                            limitExpandedExpression = GetExpandedExpression(claimFieldDocValueDictionary, limitExpandedExpression);
                            limit = (Convert.ToInt32(Utilities.EvaluateExpression(limitExpandedExpression, claim,
                                                                                  PaymentTypeCustomTable, Constants.LimitOccurence)));
                        }
                        limit = (limit < 0) ? 0 : limit; //if limit is negative value then making it zero
                        string code = uploadedValue.Identifier;
                        if (PaymentTypeCustomTable.IsPerDayOfStay)
                        {
                            AddLimitsPerdayOfStay(claimCharge, codeDetailsList, code, limit);
                        }
                        else
                        {
                            AddLimitByCode(codeDetailsList, code, limit);
                        }

                        EvaluateAdjudicatedValue(paymentResult, uploadedValue, claim, codeDetailsList, claimCharge);
                    }
                }
            }
        }
        /// <summary>
        /// calculates and adds the result to payment dictionary
        /// </summary>
        /// <param name="claimPaymentResult">payment result of the claim</param>
        /// <param name="uploadedValue">uploaded excel values</param>
        /// <param name="claim">claim details</param>
        /// <param name="codeDetailsList">The codes.</param>
        /// <param name="claimCharge">The claim charge.</param>
        private void EvaluateAdjudicatedValue(PaymentResult claimPaymentResult, ClaimFieldValue uploadedValue, IEvaluateableClaim claim, List <CodeDetails> codeDetailsList = null, ClaimCharge claimCharge = null)
        {
            Utilities.UpdatePaymentResult(claimPaymentResult, PaymentTypeCustomTable.ServiceTypeId,
                                          PaymentTypeCustomTable.PaymentTypeDetailId, PaymentTypeCustomTable.PaymentTypeId);
            Dictionary <string, string> claimFieldDocValueDictionary =
                PrepareClaimFieldDocValueDictionary(uploadedValue);
            double convertedAmount;

            string[]      expandedExpression = { PaymentTypeCustomTable.Expression };
            List <string> validValues        = new List <string>();

            foreach (KeyValuePair <string, string> pair in claimFieldDocValueDictionary.OrderByDescending(key => key.Key.Length).Where(pair => expandedExpression[0].IndexOf(pair.Key, StringComparison.CurrentCultureIgnoreCase) >= 0))
            {
                validValues.Add(pair.Value);
                expandedExpression[0] = Regex.Replace(expandedExpression[0], pair.Key, pair.Value, RegexOptions.IgnoreCase);
            }

            if (claimCharge != null && codeDetailsList != null)
            {
                double?formula = Utilities.EvaluateExpression(expandedExpression[0], claim,
                                                              PaymentTypeCustomTable);
                EvaluateLineByOccurence(claimPaymentResult, claim, codeDetailsList, claimCharge, claimFieldDocValueDictionary, formula, uploadedValue);
            }
            else if (validValues.Any(x => !double.TryParse(x, out convertedAmount)))
            {
                claimPaymentResult.ClaimStatus = validValues.Any(string.IsNullOrEmpty)
                    ? (byte)Enums.AdjudicationOrVarianceStatuses.AdjudicationErrorInvalidPaymentData
                    : (byte)Enums.AdjudicationOrVarianceStatuses.UnAdjudicated;
            }
            else
            {
                claimPaymentResult.AdjudicatedValue = Utilities.EvaluateExpression(expandedExpression[0], claim,
                                                                                   PaymentTypeCustomTable);
                claimPaymentResult.ClaimStatus = (byte)Enums.AdjudicationOrVarianceStatuses.Adjudicated;
                Utilities.UpdateCustomTableDetails(claimPaymentResult, claim.SmartBox, PaymentTypeCustomTable);
            }
        }
 /// <summary>
 /// Adds the claim field values.
 /// </summary>
 /// <param name="claimFieldValues">The claim field values.</param>
 /// <returns></returns>
 public long AddClaimFieldValues(ClaimFieldValue claimFieldValues)
 {
     return(_claimFieldValuesRepository.AddClaimFieldValues(claimFieldValues));
 }
        /// <summary>
        /// Evaluates the line by occurence.
        /// </summary>
        /// <param name="claimPaymentResult">The claim payment result.</param>
        /// <param name="claim">The claim.</param>
        /// <param name="codeDetailsList">The codes.</param>
        /// <param name="claimCharge">The claim charge.</param>
        /// <param name="claimFieldDocValueDictionary">The claim field document value dictionary.</param>
        /// <param name="formula">The formula.</param>
        /// <param name="uploadedValue">The uploaded value.</param>
        private void EvaluateLineByOccurence(PaymentResult claimPaymentResult, IEvaluateableClaim claim,
                                             List <CodeDetails> codeDetailsList, ClaimCharge claimCharge, Dictionary <string, string> claimFieldDocValueDictionary,
                                             double?formula, ClaimFieldValue uploadedValue)
        {
            bool isMultiplierexist = PaymentTypeCustomTable.MultiplierFirst != null || PaymentTypeCustomTable.MultiplierSecond != null ||
                                     PaymentTypeCustomTable.MultiplierThird != null || PaymentTypeCustomTable.MultiplierFourth != null ||
                                     PaymentTypeCustomTable.MultiplierOther != null;

            for (int unit = 0; unit < ((!PaymentTypeCustomTable.IsObserveServiceUnit && !isMultiplierexist) ? 1 : claimCharge.Units); unit++)
            {
                CodeDetails codeDetails = new CodeDetails();
                GetCodeAndOccurenceValue(uploadedValue, codeDetailsList, claimCharge, codeDetails);
                if ((PaymentTypeCustomTable.IsObserveServiceUnit && codeDetails.Limit > 0) ||
                    (PaymentTypeCustomTable.IsObserveServiceUnit &&
                     PaymentTypeCustomTable.ObserveServiceUnitLimit == null) || !PaymentTypeCustomTable.IsObserveServiceUnit)
                {
                    switch (codeDetails.Occurence)
                    {
                    case 1:
                        string multiplierFirstExpandedExpression = PaymentTypeCustomTable.MultiplierFirst ??
                                                                   Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierFirstExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    case 2:
                        string multiplierSecondExpandedExpression = PaymentTypeCustomTable.MultiplierSecond ??
                                                                    Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierSecondExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    case 3:
                        string multiplierThirdExpandedExpression = PaymentTypeCustomTable.MultiplierThird ??
                                                                   Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierThirdExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    case 4:
                        string multiplierFourthExpandedExpression = PaymentTypeCustomTable.MultiplierFourth ??
                                                                    Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierFourthExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;

                    default:
                        string multiplierOthersExpandedExpression = PaymentTypeCustomTable.MultiplierOther ??
                                                                    Constants.StringOne;
                        CalculateAdjudicatedValue(claimPaymentResult, claim, codeDetailsList,
                                                  claimCharge,
                                                  multiplierOthersExpandedExpression, claimFieldDocValueDictionary, codeDetails.Code,
                                                  codeDetails.Occurence,
                                                  formula, isMultiplierexist);
                        break;
                    }
                }
                else if (claimPaymentResult.AdjudicatedValue == null)
                {
                    claimPaymentResult.ClaimStatus      = (byte)Enums.AdjudicationOrVarianceStatuses.Adjudicated;
                    claimPaymentResult.AdjudicatedValue = 0.0;
                }
            }
        }
        private ClaimFieldValue GetMatchedClaimFieldValues(IEvaluateableClaim claim, ClaimCharge claimCharge = null)
        {
            ClaimFieldValue claimFieldValue;

            switch (PaymentTypeCustomTable.ClaimFieldId)
            {
            case (byte)Enums.ClaimFieldTypes.Drg:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => PrePendZeros(claimField.Identifier) == PrePendZeros(claim.Drg));
                break;

            case (byte)Enums.ClaimFieldTypes.BillType:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier.ToUpper(CultureInfo.InvariantCulture) == claim.BillType.ToUpper(CultureInfo.InvariantCulture));
                break;

            case (byte)Enums.ClaimFieldTypes.PatientAccountNumber:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier.ToUpper(CultureInfo.InvariantCulture) == claim.PatAcctNum.ToUpper(CultureInfo.InvariantCulture));
                break;

            case (byte)Enums.ClaimFieldTypes.PayerName:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier.ToUpperInvariant() == claim.PriPayerName.ToUpperInvariant());
                break;

            case (byte)Enums.ClaimFieldTypes.InsuredId:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.InsuredCodes.Any(x => x.CertificationNumber.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.InsuredGroup:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.InsuredCodes.Any(x => x.GroupNumber.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.Icn:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier.ToUpperInvariant() == claim.Icn.ToUpperInvariant());
                break;

            case (byte)Enums.ClaimFieldTypes.Mrn:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier.ToUpperInvariant() == claim.Mrn.ToUpperInvariant());
                break;

            case (byte)Enums.ClaimFieldTypes.ReferringPhysician:
                claimFieldValue = GetReferringPhysicianClaimFieldValue(claim);
                break;

            case (byte)Enums.ClaimFieldTypes.RenderingPhysician:
                claimFieldValue = GetRenderingPhysicianClaimFieldValue(claim);
                break;

            case (byte)Enums.ClaimFieldTypes.AttendingPhysician:
                claimFieldValue = GetAttendingPhysicianClaimFieldValue(claim);
                break;

            case (byte)Enums.ClaimFieldTypes.IcdDiagnosis:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.DiagnosisCodes.Any(x => x.IcddCode.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.IcdProcedure:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.ProcedureCodes.Any(x => x.IcdpCode.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.ValueCodes:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.ValueCodes.Any(x => x.Code.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.OccurrenceCode:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.OccurrenceCodes.Any(x => x.Code.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.ConditionCodes:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claim.ConditionCodes.Any(x => x.Code.ToUpperInvariant() == claimField.Identifier.ToUpperInvariant()));
                break;

            case (byte)Enums.ClaimFieldTypes.CustomField1:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.First(claimField => claim.CustomField1 == claimField.Identifier);
                break;

            case (byte)Enums.ClaimFieldTypes.CustomField2:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.First(claimField => claim.CustomField2 == claimField.Identifier);
                break;

            case (byte)Enums.ClaimFieldTypes.CustomField3:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.First(claimField => claim.CustomField4 == claimField.Identifier);
                break;

            case (byte)Enums.ClaimFieldTypes.CustomField4:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.First(claimField => claim.CustomField4 == claimField.Identifier);
                break;

            case (byte)Enums.ClaimFieldTypes.CustomField5:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.First(claimField => claim.CustomField5 == claimField.Identifier);
                break;

            case (byte)Enums.ClaimFieldTypes.CustomField6:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.First(claimField => claim.CustomField6 == claimField.Identifier);
                break;

            case (byte)Enums.ClaimFieldTypes.RevenueCode:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(currentClaimFieldValue => claimCharge != null && ((currentClaimFieldValue.Identifier.Length == 4 ? Regex.Replace(currentClaimFieldValue.Identifier, "^0?", string.Empty) : currentClaimFieldValue.Identifier) == claimCharge.RevCode));
                break;

            case (byte)Enums.ClaimFieldTypes.HcpcsOrRateOrHipps:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.
                                  FirstOrDefault(currentClaimFieldValue => claimCharge != null && (currentClaimFieldValue.Identifier.Equals(claimCharge.HcpcsCodeWithModifier, StringComparison.OrdinalIgnoreCase)));
                if (claimCharge != null && (claimFieldValue == null && claimCharge.HcpcsCodeWithModifier.Trim().Length != 5))
                {
                    claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.
                                      FirstOrDefault(currentClaimFieldValue => (currentClaimFieldValue.Identifier.Equals(claimCharge.HcpcsCode, StringComparison.OrdinalIgnoreCase)));
                }
                break;

            case (byte)Enums.ClaimFieldTypes.PlaceOfService:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(currentClaimFieldValue => claimCharge != null && currentClaimFieldValue.Identifier.Equals(claimCharge.PlaceOfService, StringComparison.OrdinalIgnoreCase));
                break;

            case (byte)Enums.ClaimFieldTypes.Los:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier == Convert.ToString(claim.Los, CultureInfo.InvariantCulture));
                break;

            case (byte)Enums.ClaimFieldTypes.Age:
                claimFieldValue = PaymentTypeCustomTable.ClaimFieldDoc.ClaimFieldValues.FirstOrDefault(claimField => claimField.Identifier == Convert.ToString(claim.Age, CultureInfo.InvariantCulture));
                break;

            default:
                claimFieldValue = new ClaimFieldValue();
                break;
            }
            return(claimFieldValue);
        }
 /// <summary>
 /// Adds the claim field values.
 /// </summary>
 /// <param name="claimFieldValues">The claim field values.</param>
 /// <returns></returns>
 public long AddClaimFieldValues(ClaimFieldValue claimFieldValues)
 {
     return(_claimFieldValuesLogic.AddClaimFieldValues(claimFieldValues));
 }
Пример #13
0
        /// <summary>
        /// Gets the table look up details by contract unique identifier.
        /// </summary>
        /// <param name="claimFieldDoc"></param>
        /// <returns></returns>
        public List <ClaimFieldDoc> GetClaimFieldDocs(ClaimFieldDoc claimFieldDoc)
        {
            //holds the response data
            List <ClaimFieldDoc> claimFieldDocs = new List <ClaimFieldDoc>();

            // Initialize the Stored Procedure
            _databaseCommandObj = _databaseObj.GetStoredProcCommand("GetTableLookUpDetailsByContractID");
            _databaseObj.AddInParameter(_databaseCommandObj, "@ContractId", DbType.Int64, claimFieldDoc.ContractId);
            _databaseObj.AddInParameter(_databaseCommandObj, "@ClaimFieldId", DbType.Int64,
                                        claimFieldDoc.ClaimFieldId);
            _databaseObj.AddInParameter(_databaseCommandObj, "@ClaimFieldDocId", DbType.Int64,
                                        claimFieldDoc.ClaimFieldDocId);
            // Retrieve the results of the Stored Procedure

            DataSet claimFieldDocDetails = _databaseObj.ExecuteDataSet(_databaseCommandObj);

            //Map datatable to business objects
            // sending 0 to insure that table at index is having valid data.
            if (claimFieldDocDetails.IsTableDataPopulated(0))
            {
                DataTable dataTable = claimFieldDocDetails.Tables[0];
                for (int indexCount = 0; indexCount < dataTable.Rows.Count; indexCount++)
                {
                    ClaimFieldDoc tempData = new ClaimFieldDoc
                    {
                        TableName       = Convert.ToString(dataTable.Rows[indexCount]["TableName"]),
                        ClaimFieldDocId = DBNull.Value != dataTable.Rows[indexCount]["ClaimFieldDocID"]
                                                                   ? long.Parse(dataTable.Rows[indexCount]["ClaimFieldDocID"].ToString()) : 0
                    };
                    claimFieldDocs.Add(tempData);
                }

                if (claimFieldDocs.Any())
                {
                    List <ClaimFieldValue> claimFieldValueList = new List <ClaimFieldValue>();
                    if (claimFieldDocDetails.IsTableDataPopulated(1))
                    {
                        dataTable = claimFieldDocDetails.Tables[1];
                        for (int indexCount = 0; indexCount < dataTable.Rows.Count; indexCount++)
                        {
                            ClaimFieldValue tempData = new ClaimFieldValue
                            {
                                ColumnHeaderSecond = Convert.ToString(dataTable.Rows[indexCount]["ColumnHeaderSecond"]),
                                ColumnHeaderFirst  = Convert.ToString(dataTable.Rows[indexCount]["ColumnHeaderFirst"]),
                                Value             = Convert.ToString(dataTable.Rows[indexCount]["Value"]),
                                Identifier        = Convert.ToString(dataTable.Rows[indexCount]["Identifier"]),
                                ClaimFieldValueId = DBNull.Value == dataTable.Rows[indexCount]["ClaimFieldValueID"]
                                                                           ? long.Parse(dataTable.Rows[indexCount]["ClaimFieldValueID"].ToString()) : 0,
                                ClaimFieldDocId = DBNull.Value != dataTable.Rows[indexCount]["ClaimFieldDocID"]
                                                                           ? long.Parse(dataTable.Rows[indexCount]["ClaimFieldDocID"].ToString()) : 0
                            };
                            claimFieldValueList.Add(tempData);
                        }
                    }
                    if (true & claimFieldDocs.Any() && claimFieldValueList.Any())
                    {
                        claimFieldDocs.First().ClaimFieldValues = claimFieldValueList.ToList();
                    }
                }
            }
            //returns the response to Business layer
            return(claimFieldDocs);
        }