protected static PaymentResult GetPaymentResult(List <PaymentResult> paymentResults, bool isCarveOut, int lineId) { PaymentResult paymentResult = null; PaymentResult claimChargePaymentResult = paymentResults.FirstOrDefault( currentPaymentResult => currentPaymentResult.Line == lineId && currentPaymentResult.AdjudicatedValue != null); //If service type is CarveOut and matching line already adjudicated (AdjudicatedValue != null) then clone(add) charge line and set AdjudicatedValue = null if (paymentResults != null && (isCarveOut && !paymentResults.Exists(result => result.Line == lineId && result.AdjudicatedValue == null))) { if (claimChargePaymentResult != null) { //For carve out service type we need to add clone payment result object with adjudicated value, status, service type to null ( using Utilities.ResetPaymentResult()) paymentResult = claimChargePaymentResult.Clone(); //Reset clone fields Adj amount, payment type id , adj status and service type id Utilities.ResetPaymentResult(paymentResult); //Add updated result into Payment result list paymentResults.Add(paymentResult); } } else if (paymentResults != null) { paymentResult = paymentResults.FirstOrDefault( currentPaymentResult => currentPaymentResult.Line == lineId && currentPaymentResult.AdjudicatedValue == null); } return(paymentResult); }
protected static PaymentResult GetClaimLevelPaymentResult(List <PaymentResult> paymentResults, bool isCarveOut) { PaymentResult paymentResult = null; if (paymentResults != null) { if (paymentResults.Count(currentPaymentResult => currentPaymentResult.Line == null) == 1) { PaymentResult claimPaymentResult = paymentResults.FirstOrDefault(); if (claimPaymentResult != null) { paymentResult = claimPaymentResult.Clone(); paymentResult.IsInitialEntry = false; paymentResults.Add(paymentResult); } } else { paymentResult = paymentResults.FirstOrDefault( a => a.ServiceTypeId != null && a.Line == null && a.AdjudicatedValue == null); if (paymentResult == null && isCarveOut) { PaymentResult claimPaymentResult = paymentResults.FirstOrDefault(); if (claimPaymentResult != null) { paymentResult = claimPaymentResult.Clone(); paymentResult.IsInitialEntry = false; paymentResults.Add(paymentResult); } } } } return(paymentResult); }