Exemplo n.º 1
0
 private static string GetClaimIdentifier(PaymentDTO paymentDTO)
 {
     string result = "";
     bool areDone = false;
     if (!string.IsNullOrEmpty(paymentDTO.AimClaimId)) { result = paymentDTO.AimClaimId;
         areDone = true; }
     if (!areDone & !string.IsNullOrEmpty(paymentDTO.ClientUniqueIdentifier))
     { result = paymentDTO.ClientUniqueIdentifier;
         areDone = true; }
     if (!areDone & !string.IsNullOrEmpty(paymentDTO.ClientClaimId))
     { result = paymentDTO.ClientClaimId;
         areDone = true; }
     if (!areDone & !string.IsNullOrEmpty(paymentDTO.ClaimHeaderKey.ToString()))
     {
         result = paymentDTO.ClaimHeaderKey.ToString();
     }
     return result;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a ProvClmHdrKey based on provided information
        /// </summary>
        /// <param name="paymentDTO"></param>
        /// <returns></returns>
        public PaymentDTO IdentifyClaimPreInvoice(PaymentDTO paymentDTO        )
        {
            int headerKey = 0;
            int contractKey = 0;
            double recoveredAmount = 0;
            string claimId = "";
            string insClaimId = "";
            string txReference = "";
            string insurerContractCode = "";
            string insurerCode = "";
            string note = "";

            IDataManager manager = SqlDataManager.UniqueInstance;

            IList<SqlParameter> parameters = new List<SqlParameter>();
            parameters = AddSqlParameter(parameters, "@ClaimID", paymentDTO.AimClaimId, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@InsClaimID", paymentDTO.ClientUniqueIdentifier, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@PayerClaimID", paymentDTO.ClientClaimId, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@ContractCode", paymentDTO.InsurerContractCode, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@InsCode", paymentDTO.InsurerCode, SqlDbType.VarChar, "in");
            if (paymentDTO.ClaimHeaderKey > 0)
            {
                parameters = AddSqlParameter(parameters, "@ProvClmHdrKey", paymentDTO.ClaimHeaderKey.ToString(), SqlDbType.Int, "in");
            }

            SqlDataReader reader;
            try
            {
                ExecuteOutcome outcome ;
                string outcomeMessage;
                reader = (SqlDataReader) manager.Execute(
                                                           TransactionChoice.WithoutTransaction
                                                           , CommandType.StoredProcedure
                                                           , "corBulkPosting_IdentifyClaimProvClmHdr"
                                                           , ExecuteType.ExecuteReader
                                                           , parameters
                                                           , out outcome, out outcomeMessage);

                EvaluateOutcome(outcome, outcomeMessage, "IdentifyClaimPreInvoice");

                if (reader == null)
                {
                    throw new Exception("IdentifyClaimPreInvoice: Reader does not return result.");
                }
            }
            catch(Exception ex)
            {
                throw new Exception("IdentifyClaimPreInvoice: Error executing stored procedure.", ex);
            }
            try
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Object[] values = new Object[reader.FieldCount];
                        int fieldCount = reader.GetValues(values);

                        if (values[0] != null & values[0].ToString().Length > 0)
                        {

                            for (int i = 0; i < fieldCount; i++)
                            {
                                try
                                {
                                    if (values[i] != null)
                                    {
                                        switch (i)
                                        {
                                            case 0:
                                                headerKey = (int) values[i];
                                                break;
                                            case 1:
                                                contractKey = (int) values[i];
                                                break;
                                            case 2:
                                                recoveredAmount = Double.Parse(values[i].ToString());
                                                break;
                                            case 3:
                                                claimId = (string) values[i];
                                                break;
                                            case 4:
                                                insClaimId = (string) values[i];
                                                break;
                                            case 5:
                                                if (values[i] != null)
                                                {txReference = (string)values[i];}
                                                break;
                                            case 6:
                                                insurerContractCode = (string) values[i];
                                                break;
                                            case 7:
                                                insurerCode = (string) values[i];
                                                break;
                                            default:
                                                //do nothing; no more columns at this time
                                                break;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    StringBuilder str = new StringBuilder();
                                    str.AppendLine(note);
                                    str.AppendFormat("Problem returning post invoice information:{0} for field {1}",
                                                     headerKey, i);
                                    str.AppendLine(ex.Message);
                                    note = str.ToString();
                                }
                            }
                        }

                    }
                }
            }
            finally
            {
                reader.Close();
            }
            PaymentDTO newPaymentDTO = null;
            if (headerKey > 0)
            {
                newPaymentDTO = new PaymentDTO(claimId, insClaimId, txReference
                    , insurerContractCode, insurerCode, paymentDTO.Amount
                    , headerKey, contractKey, 0, recoveredAmount, 0, false, note);
            }
            return newPaymentDTO;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the InsClmHdrKey of a claim based on provided parameters
        /// </summary>
        public PaymentDTO IdentifyClaimPostInvoice(PaymentDTO paymentDTO)
        {
            PaymentDTO newPaymentDTO = null;
            int headerKey = 0;
            IDataManager manager;
            int invoiceKey = 0;
            bool isInvoiceClosed = false;
            int insurerContractKey = 0;
            double invoiceBalanceDue= 0;
            double refundRecoveredAmount = 0;
            string note = "";
            string aimClaimId = "";
            string clientUniqueIdentifier = "";
            string payerClaimId = "";
            string insurerContractCode = "";
            string insurerCode = "";

            try
            {
               manager = SqlDataManager.UniqueInstance;
            }
            catch(Exception ex)
            {
                throw new Exception("Problem calling SqlDataManager", ex);
            }
            IList<SqlParameter> parameters = new List<SqlParameter>();
            parameters = AddSqlParameter(parameters, "@ClaimID", paymentDTO.AimClaimId, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@InsClaimID", paymentDTO.ClientUniqueIdentifier, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@PayerClaimID", paymentDTO.ClientClaimId, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@Amount", paymentDTO.Amount.ToString(), SqlDbType.Money , "in");
            parameters = AddSqlParameter(parameters, "@ContractCode", paymentDTO.InsurerContractCode, SqlDbType.VarChar, "in");
            parameters = AddSqlParameter(parameters, "@InsCode", paymentDTO.InsurerCode, SqlDbType.VarChar, "in");
            if (paymentDTO.ClaimHeaderKey > 0)
            {
                parameters = AddSqlParameter(parameters, "@ProvClmHdrKey", paymentDTO.ClaimHeaderKey.ToString(), SqlDbType.Int, "in");
            }

            ExecuteOutcome outcome ;
            string outcomeMessage;
            SqlDataReader reader = (SqlDataReader)manager.Execute(
                TransactionChoice.WithoutTransaction
                , CommandType.StoredProcedure
                , "corBulkPosting_IdentifyClaimInsClmHdr"
                , ExecuteType.ExecuteReader
                , parameters
                , out outcome
                , out outcomeMessage);

            EvaluateOutcome( outcome, outcomeMessage, "IdentifyClaimPostInvoice");

            try
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Object[] values = new Object[reader.FieldCount];
                        int fieldCount = reader.GetValues(values);

                        if (values[0] != null & values[0].ToString().Length > 0)
                        {
                            for (int i = 0; i < fieldCount; i++)
                            {
                                try
                                {
                                    if (values[i] != null)
                                    {
                                        switch (i)
                                        {
                                            case 0:
                                                headerKey = (int)values[i];
                                                break;
                                            case 1:
                                                invoiceKey = (int)values[i];
                                                break;
                                            case 2:
                                                int invoiceStatus = (int)values[i];
                                                isInvoiceClosed = invoiceStatus != 0;
                                                break;
                                            case 3:
                                                insurerContractKey = (int)values[i];
                                              break;
                                            case 4:
                                                invoiceBalanceDue = Double.Parse(values[i].ToString());
                                                break;
                                            case 5:
                                                refundRecoveredAmount = Double.Parse(values[i].ToString());
                                                break;
                                            case 6:
                                                aimClaimId = (string)values[i];
                                                break;
                                            case 7:
                                                clientUniqueIdentifier = (string)values[i];
                                                break;
                                            case 8:
                                                if (values[i] != null)
                                                {payerClaimId = (string)values[i];}
                                                break;
                                            case 9:
                                                insurerContractCode = (string)values[i];
                                                break;
                                            case 10:
                                                insurerCode = (string)values[i];
                                                break;
                                            default:
                                                //do nothing; no more columns at this time
                                                break;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    StringBuilder str = new StringBuilder();
                                    str.AppendLine(note);
                                    str.AppendFormat("Problem returning post invoice information:{0} for field {1}. ",
                                                     headerKey, i);
                                    str.AppendLine(ex.Message);
                                    note = str.ToString();
                                }
                            }
                            newPaymentDTO = new PaymentDTO(aimClaimId, clientUniqueIdentifier, payerClaimId
                                                           , insurerContractCode, insurerCode, paymentDTO.Amount
                                                           , headerKey, insurerContractKey, invoiceBalanceDue
                                                           , refundRecoveredAmount, invoiceKey, isInvoiceClosed, note);
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                reader.Close();
            }
            return newPaymentDTO;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tries to tie a submitted payment to a specific claim
        /// </summary>
        /// <param name="paymentDTO"></param>
        /// <returns></returns>
        public PaymentDTO IdentifyClaim(PaymentDTO paymentDTO)
        {
            PaymentDTO newPaymentDTO;

            try
            {
                newPaymentDTO = IdentifyClaimPostInvoice(paymentDTO);
            }
            catch (Exception ex)
            {
                StringBuilder str = new StringBuilder();
                str.AppendFormat("Problem identifying post invoice on claim {0}", GetClaimIdentifier(paymentDTO));
                str.AppendLine(ex.Message);
                newPaymentDTO = paymentDTO;
                newPaymentDTO.Note = str.ToString();
            }

            if (newPaymentDTO == null)
            {
                try
                {
                    newPaymentDTO = IdentifyClaimPreInvoice(paymentDTO);
                }
                catch(Exception ex)
                {
                    StringBuilder str = new StringBuilder();
                    str.AppendFormat("Problem identifying preinvoice on claim {0}", GetClaimIdentifier(paymentDTO));
                    str.AppendLine(ex.Message);
                    newPaymentDTO = paymentDTO;
                    newPaymentDTO.Note = str.ToString();
                }

                if (newPaymentDTO == null)
                {
                    //could not identify claim
                }
            }
            return newPaymentDTO;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Adds a PaymentDTO to the Payments property
 /// </summary>
 /// <param name="paymentDTO"></param>
 private void AddPayment(PaymentDTO paymentDTO)
 {
     IPayment payment = new Payment(
         paymentDTO.AimClaimId
         , paymentDTO.Amount
         , paymentDTO.ClientUniqueIdentifier
         , paymentDTO.ClientClaimId
         , paymentDTO.InsurerContractCode
         , paymentDTO.InsurerCode
         );
     payment.UpdateInformation(
         paymentDTO.ClaimHeaderKey
         , paymentDTO.InvoiceKey
         , paymentDTO.IsInvoiceClosed
         , paymentDTO.InsurerContractKey
         , paymentDTO.InvoiceBalanceDue
         , paymentDTO.RefundRecoveredAmount
         );
     _payments.Add(payment);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a PaymentDTO from an IPayment
 /// </summary>
 /// <param name="payment"></param>
 /// <returns></returns>
 private static PaymentDTO CreatePaymentDTOFromPayment(IPayment payment)
 {
     PaymentDTO paymentDTO = new PaymentDTO(
         payment.AimClaimId
         , payment.ClientUniqueIdentifier
         , payment.ClientClaimId
         , payment.InsurerContractCode
         , payment.InsurerCode
         , payment.Amount
         , payment.ClaimHeaderKey
         , payment.InsurerContractKey
         , payment.InvoiceBalanceDue
         , payment.RefundRecoveredAmount
         , payment.InvoiceKey
         , payment.IsInvoiceClosed
         , payment.Note
         );
     return paymentDTO;
 }