Example #1
0
        public static Payment MakePayment(long patNum, double payAmt, DateTime payDate, long payPlanNum = 0, long provNum = 0, long procNum = 0, long payType = 0,
                                          long clinicNum = 0, long unearnedType = 0)
        {
            Payment payment = new Payment();

            payment.PatNum    = patNum;
            payment.PayDate   = payDate;
            payment.PayAmt    = payAmt;
            payment.PayType   = payType;
            payment.ClinicNum = clinicNum;
            payment.DateEntry = payDate;
            Payments.Insert(payment);
            PaySplit split = new PaySplit();

            split.PayNum       = payment.PayNum;
            split.PatNum       = payment.PatNum;
            split.DatePay      = payDate;
            split.ClinicNum    = payment.ClinicNum;
            split.PayPlanNum   = payPlanNum;
            split.ProvNum      = provNum;
            split.ProcNum      = procNum;
            split.SplitAmt     = payAmt;
            split.DateEntry    = payDate;
            split.UnearnedType = unearnedType;
            PaySplits.Insert(split);
            return(payment);
        }
Example #2
0
        public static Payment MakePayment(long patNum, double payAmt, DateTime payDate, long payPlanNum = 0, long provNum = 0, long procNum = 0, long payType = 0,
                                          long clinicNum = 0, long unearnedType = 0, bool isRecurringCharge = false, DateTime recurringChargeDate             = default(DateTime), string externalId = ""
                                          , long adjNum  = 0)
        {
            Payment payment = new Payment();

            payment.PatNum              = patNum;
            payment.PayDate             = payDate;
            payment.PayAmt              = payAmt;
            payment.PayType             = payType;
            payment.ClinicNum           = clinicNum;
            payment.DateEntry           = payDate;
            payment.IsRecurringCC       = isRecurringCharge;
            payment.RecurringChargeDate = recurringChargeDate;
            payment.ExternalId          = externalId;
            Payments.Insert(payment);
            PaySplit split = new PaySplit();

            split.PayNum       = payment.PayNum;
            split.PatNum       = payment.PatNum;
            split.DatePay      = payDate;
            split.ClinicNum    = payment.ClinicNum;
            split.PayPlanNum   = payPlanNum;
            split.AdjNum       = adjNum;
            split.ProvNum      = provNum;
            split.ProcNum      = procNum;
            split.SplitAmt     = payAmt;
            split.DateEntry    = payDate;
            split.UnearnedType = unearnedType;
            PaySplits.Insert(split);
            return(payment);
        }
        private void butTransfer_Click(object sender, EventArgs e)
        {
            if (gridBal.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a row from the Family Balances grid first.");
                return;
            }
            if (comboProv.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a provider first.");
                return;
            }
            double amt = PIn.PDouble(tableBalances.Rows[gridBal.GetSelectedIndex()]["StartBal"].ToString());
            //From-----------------------------------------------------------------------------------
            PaySplit split = new PaySplit();

            split.PatNum   = PatNum;
            split.PayNum   = PaymentCur.PayNum;
            split.ProcDate = PIn.PDate(textDate.Text);         //this may be updated upon closing
            split.DatePay  = PIn.PDate(textDate.Text);         //this may be updated upon closing
            split.ProvNum  = PIn.PInt(tableBalances.Rows[gridBal.GetSelectedIndex()]["ProvNum"].ToString());
            split.SplitAmt = amt;
            SplitList.Add(split);
            //To-----------------------------------------------------------------------------------
            split          = new PaySplit();
            split.PatNum   = PatNum;
            split.PayNum   = PaymentCur.PayNum;
            split.ProcDate = PIn.PDate(textDate.Text);
            split.DatePay  = PIn.PDate(textDate.Text);
            split.ProvNum  = Providers.List[comboProv.SelectedIndex].ProvNum;
            split.SplitAmt = -amt;
            SplitList.Add(split);
            FillMain();
        }
Example #4
0
 ///<summary>Inserts one PaySplit into the database.  Returns the new priKey.</summary>
 public static long Insert(PaySplit paySplit)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         paySplit.SplitNum = DbHelper.GetNextOracleKey("paysplit", "SplitNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(paySplit, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     paySplit.SplitNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(paySplit, false));
     }
 }
Example #5
0
        public void PaymentEdit_AllocateUnearned_NoLinkToOriginalPrepayment()
        {
            Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            //create prepayment of $100
            long   provNum = ProviderT.CreateProvider("SG");
            Clinic clinic1 = ClinicT.CreateClinic("Clinic1");
            //create original prepayment.
            PaySplit prePay = PaySplitT.CreatePrepayment(pat.PatNum, 100, DateTime.Today.AddDays(-1), provNum, clinic1.ClinicNum);
            //complete a procedure
            Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, provNum: provNum);

            //Manually allocate prepayment without linking to the original prepayment.
            //We want to do it manually so we don't link this to the orginal prepayment correctly.
            //Not linking correctly will test that the AllocateUnearned method is implicitly linking prepayments correctly.
            PaySplitT.CreatePaySplitsForPrepayment(proc1, 50, prov: provNum, clinic: clinic1);
            //Create new procedure
            Procedure proc2 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, provNum: provNum);
            //test the PaymentEdit.AllocateUnearned() method.
            Family          fam = Patients.GetFamily(pat.PatNum);
            List <PaySplit> listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            //Should be $100
            double unearnedAmt = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);

            Assert.AreEqual(100, unearnedAmt);
            List <PaySplit> listPaySplitsUnearned = new List <PaySplit>();
            Payment         pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            List <PaySplits.PaySplitAssociated> retVal = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc2
            }, ref listPaySplitsUnearned, pay, unearnedAmt, fam);

            Assert.AreEqual(2, retVal.Count);
            //After running the AllocateUnearned, we should implicitly link the incorrect prepayment made when we call CreatePaySplitsForPrepayment above.
            Assert.AreEqual(-50, listPaySplitsUnearned.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
        }
        private void butAdd_Click(object sender, EventArgs e)
        {
            PaySplit PaySplitCur = new PaySplit();

            PaySplitCur.PayNum   = PaymentCur.PayNum;
            PaySplitCur.DatePay  = PIn.PDate(textDate.Text);         //this may be updated upon closing
            PaySplitCur.ProcDate = PIn.PDate(textDate.Text);         //this may be updated upon closing
            if (gridBal.GetSelectedIndex() == -1)
            {
                PaySplitCur.ProvNum = Patients.GetProvNum(PatCur);
            }
            else
            {
                PaySplitCur.ProvNum  = PIn.PInt(tableBalances.Rows[gridBal.GetSelectedIndex()]["ProvNum"].ToString());
                PaySplitCur.SplitAmt = -PIn.PDouble(tableBalances.Rows[gridBal.GetSelectedIndex()]["StartBal"].ToString());
            }
            PaySplitCur.PatNum = PatCur.PatNum;
            FormPaySplitEdit FormPS = new FormPaySplitEdit(FamCur);

            FormPS.PaySplitCur = PaySplitCur;
            FormPS.IsNew       = true;
            double total = 0;

            for (int i = 0; i < SplitList.Count; i++)
            {
                total += SplitList[i].SplitAmt;
            }
            FormPS.Remain = PaymentCur.PayAmt - total;
            if (FormPS.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            SplitList.Add(PaySplitCur);
            FillMain();
        }
Example #7
0
 ///<summary>Inserts one PaySplit into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(PaySplit paySplit,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         paySplit.SplitNum=ReplicationServers.GetKey("paysplit","SplitNum");
     }
     string command="INSERT INTO paysplit (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="SplitNum,";
     }
     command+="SplitAmt,PatNum,ProcDate,PayNum,IsDiscount,DiscountType,ProvNum,PayPlanNum,DatePay,ProcNum,DateEntry,UnearnedType,ClinicNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(paySplit.SplitNum)+",";
     }
     command+=
          "'"+POut.Double(paySplit.SplitAmt)+"',"
         +    POut.Long  (paySplit.PatNum)+","
         +    POut.Date  (paySplit.ProcDate)+","
         +    POut.Long  (paySplit.PayNum)+","
         +    POut.Bool  (paySplit.IsDiscount)+","
         +    POut.Byte  (paySplit.DiscountType)+","
         +    POut.Long  (paySplit.ProvNum)+","
         +    POut.Long  (paySplit.PayPlanNum)+","
         +    POut.Date  (paySplit.DatePay)+","
         +    POut.Long  (paySplit.ProcNum)+","
         +    DbHelper.Now()+","
         +    POut.Long  (paySplit.UnearnedType)+","
         +    POut.Long  (paySplit.ClinicNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         paySplit.SplitNum=Db.NonQ(command,true);
     }
     return paySplit.SplitNum;
 }
Example #8
0
 ///<summary>Inserts one PaySplit into the database.  Returns the new priKey.</summary>
 internal static long Insert(PaySplit paySplit)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         paySplit.SplitNum=DbHelper.GetNextOracleKey("paysplit","SplitNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(paySplit,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     paySplit.SplitNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(paySplit,false);
     }
 }
Example #9
0
        ///<summary>Updates one PaySplit in the database.</summary>
        public static void Update(PaySplit paySplit)
        {
            string command = "UPDATE paysplit SET "
                             + "SplitAmt        = '" + POut.Double(paySplit.SplitAmt) + "', "
                             + "PatNum          =  " + POut.Long(paySplit.PatNum) + ", "
                             + "ProcDate        =  " + POut.Date(paySplit.ProcDate) + ", "
                             + "PayNum          =  " + POut.Long(paySplit.PayNum) + ", "
                             + "IsDiscount      =  " + POut.Bool(paySplit.IsDiscount) + ", "
                             + "DiscountType    =  " + POut.Byte(paySplit.DiscountType) + ", "
                             + "ProvNum         =  " + POut.Long(paySplit.ProvNum) + ", "
                             + "PayPlanNum      =  " + POut.Long(paySplit.PayPlanNum) + ", "
                             + "DatePay         =  " + POut.Date(paySplit.DatePay) + ", "
                             + "ProcNum         =  " + POut.Long(paySplit.ProcNum) + ", "
                             //DateEntry not allowed to change
                             + "UnearnedType    =  " + POut.Long(paySplit.UnearnedType) + ", "
                             + "ClinicNum       =  " + POut.Long(paySplit.ClinicNum) + ", "
                             //SecUserNumEntry excluded from update
                             //SecDateTEdit can only be set by MySQL
                             + "FSplitNum       =  " + POut.Long(paySplit.FSplitNum) + ", "
                             + "AdjNum          =  " + POut.Long(paySplit.AdjNum) + ", "
                             + "PayPlanChargeNum=  " + POut.Long(paySplit.PayPlanChargeNum) + " "
                             + "WHERE SplitNum = " + POut.Long(paySplit.SplitNum);

            Db.NonQ(command);
        }
Example #10
0
        private static List <PaySplit> RefreshAndFill(string command)
        {
            DataTable       table  = General.GetTable(command);
            List <PaySplit> retVal = new List <PaySplit>();
            PaySplit        split;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                split          = new PaySplit();
                split.SplitNum = PIn.PInt(table.Rows[i][0].ToString());
                split.SplitAmt = PIn.PDouble(table.Rows[i][1].ToString());
                split.PatNum   = PIn.PInt(table.Rows[i][2].ToString());
                split.ProcDate = PIn.PDate(table.Rows[i][3].ToString());
                split.PayNum   = PIn.PInt(table.Rows[i][4].ToString());
                //List[i].IsDiscount  = PIn.PBool  (table.Rows[i][5].ToString());
                //List[i].DiscountType= PIn.PInt   (table.Rows[i][6].ToString());
                split.ProvNum    = PIn.PInt(table.Rows[i][7].ToString());
                split.PayPlanNum = PIn.PInt(table.Rows[i][8].ToString());
                split.DatePay    = PIn.PDate(table.Rows[i][9].ToString());
                split.ProcNum    = PIn.PInt(table.Rows[i][10].ToString());
                split.DateEntry  = PIn.PDate(table.Rows[i][11].ToString());
                retVal.Add(split);
            }
            return(retVal);
        }
Example #11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PaySplit> TableToList(DataTable table)
        {
            List <PaySplit> retVal = new List <PaySplit>();
            PaySplit        paySplit;

            foreach (DataRow row in table.Rows)
            {
                paySplit                  = new PaySplit();
                paySplit.SplitNum         = PIn.Long(row["SplitNum"].ToString());
                paySplit.SplitAmt         = PIn.Double(row["SplitAmt"].ToString());
                paySplit.PatNum           = PIn.Long(row["PatNum"].ToString());
                paySplit.ProcDate         = PIn.Date(row["ProcDate"].ToString());
                paySplit.PayNum           = PIn.Long(row["PayNum"].ToString());
                paySplit.IsDiscount       = PIn.Bool(row["IsDiscount"].ToString());
                paySplit.DiscountType     = PIn.Byte(row["DiscountType"].ToString());
                paySplit.ProvNum          = PIn.Long(row["ProvNum"].ToString());
                paySplit.PayPlanNum       = PIn.Long(row["PayPlanNum"].ToString());
                paySplit.DatePay          = PIn.Date(row["DatePay"].ToString());
                paySplit.ProcNum          = PIn.Long(row["ProcNum"].ToString());
                paySplit.DateEntry        = PIn.Date(row["DateEntry"].ToString());
                paySplit.UnearnedType     = PIn.Long(row["UnearnedType"].ToString());
                paySplit.ClinicNum        = PIn.Long(row["ClinicNum"].ToString());
                paySplit.SecUserNumEntry  = PIn.Long(row["SecUserNumEntry"].ToString());
                paySplit.SecDateTEdit     = PIn.DateT(row["SecDateTEdit"].ToString());
                paySplit.FSplitNum        = PIn.Long(row["FSplitNum"].ToString());
                paySplit.AdjNum           = PIn.Long(row["AdjNum"].ToString());
                paySplit.PayPlanChargeNum = PIn.Long(row["PayPlanChargeNum"].ToString());
                retVal.Add(paySplit);
            }
            return(retVal);
        }
Example #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PaySplit> TableToList(DataTable table)
        {
            List <PaySplit> retVal = new List <PaySplit>();
            PaySplit        paySplit;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                paySplit              = new PaySplit();
                paySplit.SplitNum     = PIn.Long(table.Rows[i]["SplitNum"].ToString());
                paySplit.SplitAmt     = PIn.Double(table.Rows[i]["SplitAmt"].ToString());
                paySplit.PatNum       = PIn.Long(table.Rows[i]["PatNum"].ToString());
                paySplit.ProcDate     = PIn.Date(table.Rows[i]["ProcDate"].ToString());
                paySplit.PayNum       = PIn.Long(table.Rows[i]["PayNum"].ToString());
                paySplit.IsDiscount   = PIn.Bool(table.Rows[i]["IsDiscount"].ToString());
                paySplit.DiscountType = PIn.Byte(table.Rows[i]["DiscountType"].ToString());
                paySplit.ProvNum      = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                paySplit.PayPlanNum   = PIn.Long(table.Rows[i]["PayPlanNum"].ToString());
                paySplit.DatePay      = PIn.Date(table.Rows[i]["DatePay"].ToString());
                paySplit.ProcNum      = PIn.Long(table.Rows[i]["ProcNum"].ToString());
                paySplit.DateEntry    = PIn.Date(table.Rows[i]["DateEntry"].ToString());
                paySplit.UnearnedType = PIn.Long(table.Rows[i]["UnearnedType"].ToString());
                paySplit.ClinicNum    = PIn.Long(table.Rows[i]["ClinicNum"].ToString());
                retVal.Add(paySplit);
            }
            return(retVal);
        }
Example #13
0
        public static GridRow CreateRowForPaySplit(DataRow rowBundlePayment, PaySplit paySplit, bool isDynamic = false)
        {
            string descript = Defs.GetName(DefCat.PaymentTypes, PIn.Long(rowBundlePayment["PayType"].ToString()));

            if (rowBundlePayment["CheckNum"].ToString() != "")
            {
                descript += " #" + rowBundlePayment["CheckNum"].ToString();
            }
            descript += " " + paySplit.SplitAmt.ToString("c");
            if (PIn.Double(rowBundlePayment["PayAmt"].ToString()) != paySplit.SplitAmt)
            {
                descript += Lans.g("PayPlanL", "(split)");
            }
            GridRow row = new GridRow();

            row.Cells.Add(paySplit.DatePay.ToShortDateString());                                //0 Date
            row.Cells.Add(Providers.GetAbbr(PIn.Long(rowBundlePayment["ProvNum"].ToString()))); //1 Prov Abbr
            row.Cells.Add(descript);                                                            //2 Descript
            row.Cells.Add("");                                                                  //3 Principal
            row.Cells.Add("");                                                                  //4 Interest
            row.Cells.Add("");                                                                  //5 Due
            row.Cells.Add(paySplit.SplitAmt.ToString("n"));                                     //6 Payment
            if (!isDynamic)
            {
                row.Cells.Add("");        //7 Adjustment - Does not exist for dynamic payment plans
            }
            row.Cells.Add("");            //8 Balance (filled later)
            row.Tag       = paySplit;
            row.ColorText = Defs.GetDefByExactName(DefCat.AccountColors, "Payment").ItemColor;
            return(row);
        }
Example #14
0
 ///<summary>Returns true if Update(PaySplit,PaySplit) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(PaySplit paySplit, PaySplit oldPaySplit)
 {
     if (paySplit.SplitAmt != oldPaySplit.SplitAmt)
     {
         return(true);
     }
     if (paySplit.PatNum != oldPaySplit.PatNum)
     {
         return(true);
     }
     if (paySplit.ProcDate.Date != oldPaySplit.ProcDate.Date)
     {
         return(true);
     }
     if (paySplit.PayNum != oldPaySplit.PayNum)
     {
         return(true);
     }
     if (paySplit.IsDiscount != oldPaySplit.IsDiscount)
     {
         return(true);
     }
     if (paySplit.DiscountType != oldPaySplit.DiscountType)
     {
         return(true);
     }
     if (paySplit.ProvNum != oldPaySplit.ProvNum)
     {
         return(true);
     }
     if (paySplit.PayPlanNum != oldPaySplit.PayPlanNum)
     {
         return(true);
     }
     if (paySplit.DatePay.Date != oldPaySplit.DatePay.Date)
     {
         return(true);
     }
     if (paySplit.ProcNum != oldPaySplit.ProcNum)
     {
         return(true);
     }
     //DateEntry not allowed to change
     if (paySplit.UnearnedType != oldPaySplit.UnearnedType)
     {
         return(true);
     }
     if (paySplit.ClinicNum != oldPaySplit.ClinicNum)
     {
         return(true);
     }
     //SecUserNumEntry excluded from update
     //SecDateTEdit can only be set by MySQL
     if (paySplit.FSplitNum != oldPaySplit.FSplitNum)
     {
         return(true);
     }
     return(false);
 }
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            PaySplit paySplit = (PaySplit)gridMain.ListGridRows[e.Row].Tag;

            ListSelectedSplits.Clear();
            ListSelectedSplits.Add(paySplit);
            DialogResult = DialogResult.OK;
        }
Example #16
0
 private void ButCancel_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         PaySplitCur = null;
     }
     DialogResult = DialogResult.Cancel;
 }
 private void FindSplits(bool isShowAll)
 {
     ListSelectedSplits = new List <PaySplit>();
     if (IsPrePay)
     {
         if (isShowAll)                 //this will find all splits for the family, even if they have already been allocated.
         {
             GetSplitsForPats(isShowAll);
             return;
         }
         if (ListUnallocatedSplits == null)
         {
             _listPaySplits = PaySplits.GetPrepayForFam(Patients.GetFamily(_patNum));
             List <PaySplit> listSplitsForSplits = PaySplits.GetSplitsForPrepay(_listPaySplits);
             for (int i = _listPaySplits.Count - 1; i >= 0; i--)
             {
                 PaySplit        split = _listPaySplits[i];
                 List <PaySplit> listSplitsForSplit = listSplitsForSplits.FindAll(x => x.FSplitNum == split.SplitNum);
                 decimal         splitTotal         = 0;
                 foreach (PaySplits.PaySplitAssociated splitAssociated in ListPaySplitAssociated)
                 {
                     if (splitAssociated.PaySplitOrig.SplitNum == split.SplitNum && splitAssociated != SplitAssociatedDetached)
                     {
                         //add in amounts for assoications just made within payment window
                         splitTotal += (decimal)splitAssociated.PaySplitLinked.SplitAmt;
                     }
                 }
                 foreach (PaySplit paySplit in listSplitsForSplit)
                 {
                     if (paySplit.SplitNum == SplitNumCur)
                     {
                         continue;
                     }
                     splitTotal += (decimal)paySplit.SplitAmt;                          //add in amounts associated from previous payments
                 }
                 decimal leftOverAmt = (decimal)split.SplitAmt + splitTotal;            //splitTotal should be negative.
                 if (leftOverAmt <= 0)
                 {
                     _listPaySplits.Remove(split);
                 }
                 else
                 {
                     _dictLeftOverAmounts[split.SplitNum] = leftOverAmt;
                 }
             }
         }
         else
         {
             _listPaySplits = ListUnallocatedSplits;
         }
     }
     else
     {
         GetSplitsForPats(isShowAll);
     }
 }
Example #18
0
 private void UpdatePaySplitHelper(PaySplit ps, long patNum, long provNum, long clinicNum, long payNum)
 {
     if (payNum != 0 && payNum == ps.PayNum)
     {
         ps.PatNum    = patNum;
         ps.ProvNum   = provNum;
         ps.ClinicNum = clinicNum;
         PaySplits.Update(ps);
     }
 }
Example #19
0
 private void FormProcSelect_Load(object sender, System.EventArgs e)
 {
     if (_isMultiSelect)
     {
         gridMain.SelectionMode = OpenDental.UI.GridSelectionMode.MultiExtended;
     }
     _listSelectedProcs = new List <Procedure>();
     _listProcedures    = Procedures.GetCompleteForPats(new List <long> {
         _patNumCur
     });
     if (ShowTpProcs)
     {
         _listProcedures.AddRange(Procedures.GetTpForPats(new List <long> {
             _patNumCur
         }));
     }
     _listAdjustments = Adjustments.GetAdjustForPats(new List <long> {
         _patNumCur
     });
     _listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patNumCur), _patNumCur).ToList();        //Does not get charges for the future.
     _listPaySplits      = PaySplits.GetForPats(new List <long> {
         _patNumCur
     });                                                                            //Might contain payplan payments.
     foreach (PaySplit split in ListSplitsCur)
     {
         //If this is a new payment, its paysplits will not be in the database yet, so we need to add them manually. We might also need to set the
         //ProcNum on the pay split if it has changed and has not been saved to the database.
         PaySplit splitDb = _listPaySplits.FirstOrDefault(x => x.IsSame(split));
         if (splitDb == null)
         {
             _listPaySplits.Add(split);
         }
         else
         {
             splitDb.ProcNum = split.ProcNum;
         }
     }
     _listInsPayAsTotal = ClaimProcs.GetByTotForPats(new List <long> {
         _patNumCur
     });
     _listClaimProcs          = ClaimProcs.GetForProcs(_listProcedures.Select(x => x.ProcNum).ToList());
     labelUnallocated.Visible = _doShowUnallocatedLabel;
     if (PrefC.GetInt(PrefName.RigorousAdjustments) == (int)RigorousAdjustments.DontEnforce)
     {
         radioIncludeAllCredits.Checked = true;
     }
     else
     {
         radioOnlyAllocatedCredits.Checked = true;
     }
     FillGrid();
 }
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an item first.");
                return;
            }
            ListSelectedSplits.Clear();
            PaySplit paySplit = (PaySplit)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;

            ListSelectedSplits.Add(paySplit);
            DialogResult = DialogResult.OK;
        }
Example #21
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (!MsgBox.Show(this, true, "Delete Item?"))
     {
         return;
     }
     PaySplitCur = null;
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     DialogResult = DialogResult.OK;
 }
Example #22
0
 ///<summary>Inserts one PaySplit into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PaySplit paySplit)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(paySplit, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             paySplit.SplitNum = DbHelper.GetNextOracleKey("paysplit", "SplitNum");                  //Cacheless method
         }
         return(InsertNoCache(paySplit, true));
     }
 }
Example #23
0
        ///<summary>Used once in ContrAccount to just get the splits for a single patient.  The supplied list also contains splits that are not necessarily for this one patient.</summary>
        public static PaySplit[] GetForPatient(int patNum, PaySplit[] List)
        {
            ArrayList retVal = new ArrayList();

            for (int i = 0; i < List.Length; i++)
            {
                if (List[i].PatNum == patNum)
                {
                    retVal.Add(List[i]);
                }
            }
            PaySplit[] retList = new PaySplit[retVal.Count];
            retVal.CopyTo(retList);
            return(retList);
        }
Example #24
0
 private void FindSplits(bool isShowAll)
 {
     ListSelectedSplits = new List <PaySplit>();
     if (IsPrePay)
     {
         if (isShowAll)                 //this will find all splits for the family, even if they have already been allocated.
         {
             GetSplitsForPats(isShowAll);
             return;
         }
         if (ListUnallocatedSplits == null)
         {
             _listPaySplits = PaySplits.GetPrepayForFam(Patients.GetFamily(_patNum));
             List <PaySplit> listSplitsForSplits = PaySplits.GetSplitsForPrepay(_listPaySplits);
             for (int i = _listPaySplits.Count - 1; i >= 0; i--)
             {
                 PaySplit        split = _listPaySplits[i];
                 List <PaySplit> listSplitsForSplit = listSplitsForSplits.FindAll(x => x.FSplitNum == split.SplitNum);
                 decimal         splitTotal         = 0;
                 foreach (PaySplit paySplit in listSplitsForSplit)
                 {
                     if (paySplit.SplitNum == SplitNumCur)
                     {
                         continue;
                     }
                     splitTotal += (decimal)paySplit.SplitAmt;
                 }
                 decimal leftOverAmt = (decimal)split.SplitAmt + splitTotal + AmtAllocated;                   //splitTotal should be negative.
                 if (leftOverAmt <= 0)
                 {
                     _listPaySplits.Remove(split);
                 }
                 else
                 {
                     split.SplitAmt = (double)leftOverAmt;                          //This will cause the left over amount to show up in the grid.  We don't do any saving in this form.
                 }
             }
         }
         else
         {
             _listPaySplits = ListUnallocatedSplits;
         }
     }
     else
     {
         GetSplitsForPats(isShowAll);
     }
 }
Example #25
0
        ///<summary></summary>
        public static void Update(PaySplit split)
        {
            string command = "UPDATE paysplit SET "
                             + "SplitAmt = '" + POut.PDouble(split.SplitAmt) + "'"
                             + ",PatNum = '" + POut.PInt(split.PatNum) + "'"
                             + ",ProcDate = " + POut.PDate(split.ProcDate)
                             + ",PayNum = '" + POut.PInt(split.PayNum) + "'"
                             + ",ProvNum = '" + POut.PInt(split.ProvNum) + "'"
                             + ",PayPlanNum = '" + POut.PInt(split.PayPlanNum) + "'"
                             + ",DatePay = " + POut.PDate(split.DatePay)
                             + ",ProcNum = '" + POut.PInt(split.ProcNum) + "'"
                             //+ ",DateEntry = '"   +POut.PDate  (DateEntry)+"'"//not allowed to change
                             + " WHERE splitNum = '" + POut.PInt(split.SplitNum) + "'";

            General.NonQ(command);
        }
Example #26
0
        ///<summary>Inserts one PaySplit into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(PaySplit paySplit, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO paysplit (";

            if (!useExistingPK && isRandomKeys)
            {
                paySplit.SplitNum = ReplicationServers.GetKeyNoCache("paysplit", "SplitNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "SplitNum,";
            }
            command += "SplitAmt,PatNum,ProcDate,PayNum,IsDiscount,DiscountType,ProvNum,PayPlanNum,DatePay,ProcNum,DateEntry,UnearnedType,ClinicNum,SecUserNumEntry,FSplitNum,AdjNum,PayPlanChargeNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(paySplit.SplitNum) + ",";
            }
            command +=
                "'" + POut.Double(paySplit.SplitAmt) + "',"
                + POut.Long(paySplit.PatNum) + ","
                + POut.Date(paySplit.ProcDate) + ","
                + POut.Long(paySplit.PayNum) + ","
                + POut.Bool(paySplit.IsDiscount) + ","
                + POut.Byte(paySplit.DiscountType) + ","
                + POut.Long(paySplit.ProvNum) + ","
                + POut.Long(paySplit.PayPlanNum) + ","
                + POut.Date(paySplit.DatePay) + ","
                + POut.Long(paySplit.ProcNum) + ","
                + DbHelper.Now() + ","
                + POut.Long(paySplit.UnearnedType) + ","
                + POut.Long(paySplit.ClinicNum) + ","
                + POut.Long(paySplit.SecUserNumEntry) + ","
                //SecDateTEdit can only be set by MySQL
                + POut.Long(paySplit.FSplitNum) + ","
                + POut.Long(paySplit.AdjNum) + ","
                + POut.Long(paySplit.PayPlanChargeNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                paySplit.SplitNum = Db.NonQ(command, true, "SplitNum", "paySplit");
            }
            return(paySplit.SplitNum);
        }
Example #27
0
        ///<summary></summary>
        public static void Insert(PaySplit split)
        {
            if (PrefB.RandomKeys)
            {
                split.SplitNum = MiscData.GetKey("paysplit", "SplitNum");
            }
            string command = "INSERT INTO paysplit (";

            if (PrefB.RandomKeys)
            {
                command += "SplitNum,";
            }
            command += "SplitAmt,PatNum,ProcDate, "
                       + "PayNum,IsDiscount,DiscountType,ProvNum,PayPlanNum,DatePay,ProcNum,DateEntry) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(split.SplitNum) + "', ";
            }
            command +=
                "'" + POut.PDouble(split.SplitAmt) + "', "
                + "'" + POut.PInt(split.PatNum) + "', "
                + POut.PDate(split.ProcDate) + ", "
                + "'" + POut.PInt(split.PayNum) + "', "
                + "'0', "               //IsDiscount
                + "'0', "               //DiscountType
                + "'" + POut.PInt(split.ProvNum) + "', "
                + "'" + POut.PInt(split.PayPlanNum) + "', "
                + POut.PDate(split.DatePay) + ", "
                + "'" + POut.PInt(split.ProcNum) + "', ";
            if (FormChooseDatabase.DBtype == DatabaseType.Oracle)
            {
                command += POut.PDateT(MiscData.GetNowDateTime());
            }
            else              //Assume MySQL
            {
                command += "NOW()";
            }
            command += ")";          //DateEntry: date of server
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                split.SplitNum = General.NonQ(command, true);
            }
        }
Example #28
0
        public void PaymentEdit_AllocateUnearned_LinkToOriginalPrepayment()
        {
            Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            //create prepayment of $100
            long   provNum = ProviderT.CreateProvider("SG");
            Clinic clinic1 = ClinicT.CreateClinic("Clinic1");
            Family fam     = Patients.GetFamily(pat.PatNum);
            //create original prepayment.
            PaySplit prePay = PaySplitT.CreatePrepayment(pat.PatNum, 100, DateTime.Today.AddDays(-1), provNum, clinic1.ClinicNum);
            //complete a procedure
            Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, provNum: provNum);
            //Setup to run the PaymentEdit.AllocateUnearned
            List <PaySplit> listPaySplits       = new List <PaySplit>();
            List <PaySplit> listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            //Unearned amount should be $100.
            double unearnedAmt = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);

            Assert.AreEqual(100, unearnedAmt);
            //Create the payment we will use to allocate some of the $100 prepayment.
            Payment pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            //Run the AllocateUnearned method. This a list of paysplitAssociated.
            //The ref list of paysplits should also have the new paysplits that are associated to the original prepayment.
            List <PaySplits.PaySplitAssociated> listPaySplitAssociated = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc1
            }, ref listPaySplits, pay, unearnedAmt, fam);

            //Insert the paysplits and link the prepayment paysplits. This is similar to what is done when a user creates a payment from FormPayment.cs.
            PaySplitT.InsertPrepaymentSplits(listPaySplits, listPaySplitAssociated);
            //The ref list of paysplits should have the correct allocated prepayment amount.
            Assert.AreEqual(-50, listPaySplits.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
            //Create new procedure
            Procedure proc2 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, provNum: provNum);

            //Now do what we just did again for a new procedure. The unallocated amount should be $50.
            listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            unearnedAmt         = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);
            Assert.AreEqual(50, unearnedAmt);
            List <PaySplit> listPaySplitsUnearned = new List <PaySplit>();

            pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            List <PaySplits.PaySplitAssociated> retVal = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc2
            }, ref listPaySplitsUnearned, pay, unearnedAmt, fam);

            Assert.AreEqual(2, retVal.Count);
            Assert.AreEqual(-50, listPaySplitsUnearned.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
        }
Example #29
0
        public static List <PaySplit> CreatePaySplitsForPrepayment(Procedure proc, double amtToUse, PaySplit prePaySplit = null, Clinic clinic = null, long prov = 0)
        {
            List <PaySplit> retVal    = new List <PaySplit>();
            long            clinicNum = prePaySplit?.ClinicNum ?? clinic?.ClinicNum ?? proc.ClinicNum;
            long            provNum   = prePaySplit?.ProvNum ?? prov;

            if (clinic != null)
            {
                clinicNum = clinic.ClinicNum;
            }
            if (prov != 0)
            {
                provNum = prov;
            }
            Def      unearnedType = Defs.GetDefByExactName(DefCat.PaySplitUnearnedType, "PrePayment") ?? DefinitionT.CreateDefinition(DefCat.PaySplitUnearnedType, "PrePayment");
            Def      payType      = Defs.GetDefByExactName(DefCat.PaymentTypes, "Check") ?? DefinitionT.CreateDefinition(DefCat.PaymentTypes, "Check");
            Payment  pay          = PaymentT.MakePaymentNoSplits(proc.PatNum, amtToUse, payDate: DateTime.Now, clinicNum: clinicNum, payType: unearnedType.DefNum);
            PaySplit splitNeg     = new PaySplit();

            splitNeg.PatNum       = prePaySplit?.PatNum ?? proc.PatNum;
            splitNeg.PayNum       = pay.PayNum;
            splitNeg.FSplitNum    = prePaySplit?.SplitNum ?? 0;
            splitNeg.ClinicNum    = clinicNum;
            splitNeg.ProvNum      = provNum;
            splitNeg.SplitAmt     = 0 - amtToUse;
            splitNeg.UnearnedType = prePaySplit?.UnearnedType ?? unearnedType.DefNum;
            splitNeg.DatePay      = DateTime.Now;
            PaySplits.Insert(splitNeg);
            retVal.Add(splitNeg);
            //Make a different paysplit attached to proc and prov they want to use it for.
            PaySplit splitPos = new PaySplit();

            splitPos.PatNum    = prePaySplit?.PatNum ?? proc.PatNum;
            splitPos.PayNum    = pay.PayNum;
            splitPos.FSplitNum = splitNeg.SplitNum;
            splitPos.ProvNum   = provNum;
            splitPos.ClinicNum = clinicNum;
            splitPos.SplitAmt  = amtToUse;
            splitPos.DatePay   = DateTime.Now;
            splitPos.ProcNum   = proc.ProcNum;
            PaySplits.Insert(splitPos);
            retVal.Add(splitPos);
            return(retVal);
        }
		private void butOK_Click(object sender, System.EventArgs e) {
			if(textAmount.errorProvider1.GetError(textAmount)!="") {
				MsgBox.Show(this,"Please fix data entry errors first.");
				return;
			}
			if(textAmount.Text=="") {
				MsgBox.Show(this,"Please enter an amount.");
				return;
			}
			double amt=PIn.PDouble(textAmount.Text);
			if(amt<=0) {
				MsgBox.Show(this,"Amount must be be greater than zero.");
				return;
			}
			if(comboProvFrom.SelectedIndex==-1 || comboProvTo.SelectedIndex==-1){
				MsgBox.Show(this,"Providers must be selected");
				return;
			}
			if(FromPatNum==0 || ToPatNum==0){
				MsgBox.Show(this,"Patients must be selected");
				return;
			}
			SplitList=new List<PaySplit>();
			//From-----------------------------------------------------------------------------------
			PaySplit split=new PaySplit();
			split.PatNum=FromPatNum;
			split.PayNum=PayNum;
			split.ProcDate=DateTime.Today;//will be updated in parent form.
			split.DatePay=DateTime.Today;//will be updated when closing parent form.
			split.ProvNum=Providers.List[comboProvFrom.SelectedIndex].ProvNum;
			split.SplitAmt=-amt;
			SplitList.Add(split);
			//To-----------------------------------------------------------------------------------
			split=new PaySplit();
			split.PatNum=ToPatNum;
			split.PayNum=PayNum;
			split.ProcDate=DateTime.Today;//will be updated in parent form.
			split.DatePay=DateTime.Today;//will be updated when closing parent form.
			split.ProvNum=Providers.List[comboProvTo.SelectedIndex].ProvNum;
			split.SplitAmt=amt;
			SplitList.Add(split);
			DialogResult=DialogResult.OK;
		}
Example #31
0
        public static PaySplit CreateSplit(long clinicNum, long patNum, long payNum, long payplanNum, DateTime procDate, long procNum, long provNum
                                           , double splitAmt, long unearnedType)
        {
            PaySplit paysplit = new PaySplit()
            {
                ClinicNum    = clinicNum,
                PatNum       = patNum,
                PayNum       = payNum,
                PayPlanNum   = payplanNum,
                ProcDate     = procDate,
                ProcNum      = procNum,
                ProvNum      = provNum,
                SplitAmt     = splitAmt,
                UnearnedType = unearnedType
            };

            PaySplits.Insert(paysplit);
            return(paysplit);
        }
Example #32
0
        public static PaySplit CreatePrepayment(long patNum, int amt, DateTime datePay, long provNum = 0, long clinicNum = 0)
        {
            Def      unearnedType = Defs.GetDefByExactName(DefCat.PaySplitUnearnedType, "PrePayment") ?? DefinitionT.CreateDefinition(DefCat.PaySplitUnearnedType, "PrePayment");
            Def      payType      = Defs.GetDefByExactName(DefCat.PaymentTypes, "Check") ?? DefinitionT.CreateDefinition(DefCat.PaymentTypes, "Check");
            Payment  pay          = PaymentT.MakePaymentNoSplits(patNum, amt, datePay, clinicNum: clinicNum, payType: payType.DefNum);
            PaySplit split        = new PaySplit();

            split.PayNum       = pay.PayNum;
            split.PatNum       = pay.PatNum;
            split.DatePay      = datePay;
            split.ClinicNum    = pay.ClinicNum;
            split.PayPlanNum   = 0;
            split.ProvNum      = provNum;
            split.ProcNum      = 0;
            split.SplitAmt     = amt;
            split.DateEntry    = datePay;
            split.UnearnedType = unearnedType.DefNum;
            PaySplits.Insert(split);
            return(split);
        }
Example #33
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<PaySplit> TableToList(DataTable table){
			List<PaySplit> retVal=new List<PaySplit>();
			PaySplit paySplit;
			for(int i=0;i<table.Rows.Count;i++) {
				paySplit=new PaySplit();
				paySplit.SplitNum    = PIn.Long  (table.Rows[i]["SplitNum"].ToString());
				paySplit.SplitAmt    = PIn.Double(table.Rows[i]["SplitAmt"].ToString());
				paySplit.PatNum      = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				paySplit.ProcDate    = PIn.Date  (table.Rows[i]["ProcDate"].ToString());
				paySplit.PayNum      = PIn.Long  (table.Rows[i]["PayNum"].ToString());
				paySplit.IsDiscount  = PIn.Bool  (table.Rows[i]["IsDiscount"].ToString());
				paySplit.DiscountType= PIn.Byte  (table.Rows[i]["DiscountType"].ToString());
				paySplit.ProvNum     = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				paySplit.PayPlanNum  = PIn.Long  (table.Rows[i]["PayPlanNum"].ToString());
				paySplit.DatePay     = PIn.Date  (table.Rows[i]["DatePay"].ToString());
				paySplit.ProcNum     = PIn.Long  (table.Rows[i]["ProcNum"].ToString());
				paySplit.DateEntry   = PIn.Date  (table.Rows[i]["DateEntry"].ToString());
				paySplit.UnearnedType= PIn.Long  (table.Rows[i]["UnearnedType"].ToString());
				paySplit.ClinicNum   = PIn.Long  (table.Rows[i]["ClinicNum"].ToString());
				retVal.Add(paySplit);
			}
			return retVal;
		}
Example #34
0
 ///<summary>Updates one PaySplit in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
 internal static void Update(PaySplit paySplit,PaySplit oldPaySplit)
 {
     string command="";
     if(paySplit.SplitAmt != oldPaySplit.SplitAmt) {
         if(command!=""){ command+=",";}
         command+="SplitAmt = '"+POut.Double(paySplit.SplitAmt)+"'";
     }
     if(paySplit.PatNum != oldPaySplit.PatNum) {
         if(command!=""){ command+=",";}
         command+="PatNum = "+POut.Long(paySplit.PatNum)+"";
     }
     if(paySplit.ProcDate != oldPaySplit.ProcDate) {
         if(command!=""){ command+=",";}
         command+="ProcDate = "+POut.Date(paySplit.ProcDate)+"";
     }
     if(paySplit.PayNum != oldPaySplit.PayNum) {
         if(command!=""){ command+=",";}
         command+="PayNum = "+POut.Long(paySplit.PayNum)+"";
     }
     if(paySplit.IsDiscount != oldPaySplit.IsDiscount) {
         if(command!=""){ command+=",";}
         command+="IsDiscount = "+POut.Bool(paySplit.IsDiscount)+"";
     }
     if(paySplit.DiscountType != oldPaySplit.DiscountType) {
         if(command!=""){ command+=",";}
         command+="DiscountType = "+POut.Byte(paySplit.DiscountType)+"";
     }
     if(paySplit.ProvNum != oldPaySplit.ProvNum) {
         if(command!=""){ command+=",";}
         command+="ProvNum = "+POut.Long(paySplit.ProvNum)+"";
     }
     if(paySplit.PayPlanNum != oldPaySplit.PayPlanNum) {
         if(command!=""){ command+=",";}
         command+="PayPlanNum = "+POut.Long(paySplit.PayPlanNum)+"";
     }
     if(paySplit.DatePay != oldPaySplit.DatePay) {
         if(command!=""){ command+=",";}
         command+="DatePay = "+POut.Date(paySplit.DatePay)+"";
     }
     if(paySplit.ProcNum != oldPaySplit.ProcNum) {
         if(command!=""){ command+=",";}
         command+="ProcNum = "+POut.Long(paySplit.ProcNum)+"";
     }
     //DateEntry not allowed to change
     if(paySplit.UnearnedType != oldPaySplit.UnearnedType) {
         if(command!=""){ command+=",";}
         command+="UnearnedType = "+POut.Long(paySplit.UnearnedType)+"";
     }
     if(paySplit.ClinicNum != oldPaySplit.ClinicNum) {
         if(command!=""){ command+=",";}
         command+="ClinicNum = "+POut.Long(paySplit.ClinicNum)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE paysplit SET "+command
         +" WHERE SplitNum = "+POut.Long(paySplit.SplitNum);
     Db.NonQ(command);
 }
Example #35
0
 ///<summary>Updates one PaySplit in the database.</summary>
 internal static void Update(PaySplit paySplit)
 {
     string command="UPDATE paysplit SET "
         +"SplitAmt    = '"+POut.Double(paySplit.SplitAmt)+"', "
         +"PatNum      =  "+POut.Long  (paySplit.PatNum)+", "
         +"ProcDate    =  "+POut.Date  (paySplit.ProcDate)+", "
         +"PayNum      =  "+POut.Long  (paySplit.PayNum)+", "
         +"IsDiscount  =  "+POut.Bool  (paySplit.IsDiscount)+", "
         +"DiscountType=  "+POut.Byte  (paySplit.DiscountType)+", "
         +"ProvNum     =  "+POut.Long  (paySplit.ProvNum)+", "
         +"PayPlanNum  =  "+POut.Long  (paySplit.PayPlanNum)+", "
         +"DatePay     =  "+POut.Date  (paySplit.DatePay)+", "
         +"ProcNum     =  "+POut.Long  (paySplit.ProcNum)+", "
         //DateEntry not allowed to change
         +"UnearnedType=  "+POut.Long  (paySplit.UnearnedType)+", "
         +"ClinicNum   =  "+POut.Long  (paySplit.ClinicNum)+" "
         +"WHERE SplitNum = "+POut.Long(paySplit.SplitNum);
     Db.NonQ(command);
 }