Example #1
0
        /// <summary>Inserts a TsiTransLog for the adjustment if necessary.</summary>
        public static void CheckAndInsertLogsIfAdjTypeExcluded(Adjustment adj, bool isFromTsi = false)
        {
            Program progCur = Programs.GetCur(ProgramName.Transworld);

            if (progCur == null || !progCur.Enabled)
            {
                return;
            }
            Patient guar = Patients.GetGuarForPat(adj.PatNum);

            if (guar == null || !IsTransworldEnabled(guar.ClinicNum) || !Patients.IsGuarCollections(guar.PatNum))
            {
                return;
            }
            string       msgText = "This was not a message sent to Transworld.  This adjustment was entered due to a payment received from Transworld.";
            TsiTransType typeCur = TsiTransType.None;

            if (!isFromTsi)             //if not an adj due to a payment from TSI, see if it is an excluded adj type
            {
                Dictionary <long, List <ProgramProperty> > dictClinicProps = ProgramProperties
                                                                             .GetWhere(x => x.ProgramNum == progCur.ProgramNum && x.PropertyDesc.In(ExcludeAdjustTypes) && x.ClinicNum.In(0, guar.ClinicNum))
                                                                             .GroupBy(x => x.ClinicNum)
                                                                             .ToDictionary(x => x.Key, x => x.ToList());
                //use guar's clinic if clinics are enabled and props for that clinic exist, otherwise use ClinicNum 0
                long clinicNum = (PrefC.HasClinicsEnabled && dictClinicProps.ContainsKey(guar.ClinicNum))?guar.ClinicNum:0;
                if (!dictClinicProps.TryGetValue(clinicNum, out List <ProgramProperty> listPropsCur) ||          //should always be props for ClinicNum 0
                    listPropsCur.All(x => PIn.Long(x.PropertyValue, false) != adj.AdjType))
                {
                    return;                    //if this adjustment is not an excluded type, return
                }
                msgText = "Adjustment type is set to excluded type from transworld program properties.";
                typeCur = TsiTransType.Excluded;
            }
            InsertTsiLogsForAdjustment(guar.PatNum, adj, msgText, typeCur);
        }
Example #2
0
 public static string GenerateUpdate(long patNum, string clientID, TsiTransType transType, double transAmount, double newBal)
 {
     string[] fieldVals = new string[6] {
         clientID,
         POut.Long(patNum),
         transType.ToString(),
         DateTime.Today.ToString("MMddyyyy"),
         POut.Double(Math.Abs(transAmount)),                //msgs sent with pos amt, Transworld uses tran type to determine whether it increases or decreases amt owed
         POut.Double(newBal)
     };
     return(fieldVals.Aggregate((a, b) => (a ?? "") + "|" + (b ?? "")));
 }
Example #3
0
        private static void InsertTsiLogsForAdjustment(long patGuar, Adjustment adj, string msgText, TsiTransType transType)
        {
            //insert tsitranslog for this transaction so the ODService won't send it to Transworld.  _isTsiAdj means Transworld received a payment on
            //behalf of this guar and took a percentage and send the rest to the office for the account.  This will result in a payment being entered
            //into the account, having been received from Transworld, and an adjustment to account for Transorld's cut.
            PatAging patAgingCur = Patients.GetAgingListFromGuarNums(new List <long>()
            {
                patGuar
            }).FirstOrDefault();                                                                                              //should only ever be 1

            if (patAgingCur == null)
            {
                return;
            }
            double offsetAmt = adj.AdjAmt - patAgingCur.ListTsiLogs.FindAll(x => x.FKeyType == TsiFKeyType.Adjustment && x.FKey == adj.AdjNum).Sum(x => x.TransAmt);

            if (offsetAmt.IsZero())
            {
                return;
            }
            double balFromMsgs = GetBalFromMsgs(patAgingCur);

            if (balFromMsgs.IsZero())
            {
                return;
            }
            Insert(new TsiTransLog()
            {
                PatNum    = patAgingCur.PatNum,
                UserNum   = Security.CurUser.UserNum,
                TransType = transType,
                //TransDateTime=DateTime.Now,//set on insert, not editable by user
                //DemandType=TsiDemandType.Accelerator,//only valid for placement msgs
                //ServiceCode=TsiServiceCode.Diplomatic,//only valid for placement msgs
                ClientId       = patAgingCur.ListTsiLogs.FirstOrDefault()?.ClientId ?? "",      //can be blank, not used since this isn't really sent to Transworld
                TransAmt       = offsetAmt,
                AccountBalance = balFromMsgs + (transType == TsiTransType.Excluded?0:offsetAmt),
                FKeyType       = TsiFKeyType.Adjustment,
                FKey           = adj.AdjNum,
                RawMsgText     = msgText,
                //TransJson=""//only valid for placement msgs
                ClinicNum = (PrefC.HasClinicsEnabled?patAgingCur.ClinicNum:0)
            });
        }
Example #4
0
        private void FillTextSelectedFieldDetails(string fieldDescript, string selectedText)
        {
            switch (fieldDescript)
            {
            case "CLIENT NUMBER":
                textSelectedFieldDetails.Text = "ID assigned to the office/clinic by TSI";
                return;

            case "TRANSMITTAL NUMBER":
                textSelectedFieldDetails.Text = "Not used";
                return;

            case "DEBTOR REFERENCE":
            case "TRANSMITTAL/REFERENCE NUMBER":
                textSelectedFieldDetails.Text = "Open Dental PatNum for the guarantor of the family";
                return;

            case "DEBTOR PHONE":
                textSelectedFieldDetails.Text = "Home phone for the guarantor of the family";
                return;

            case "SECONDARY PHONE":
                textSelectedFieldDetails.Text = "Wireless phone for the guarantor of the family";
                return;

            case "PATIENTTYPE":
                if (selectedText == "0")
                {
                    textSelectedFieldDetails.Text = "Self/Default";
                }
                else if (selectedText == "1")
                {
                    textSelectedFieldDetails.Text = "Spouse/Significant other";
                }
                else if (selectedText == "2")
                {
                    textSelectedFieldDetails.Text = "Parent/Guardian";
                }
                else if (selectedText == "3")
                {
                    textSelectedFieldDetails.Text = "Child";
                }
                else if (selectedText == "4")
                {
                    textSelectedFieldDetails.Text = "Other (Grandparent/Grandchild/Sitter/Sibling/Friend/Other)";
                }
                return;

            case "PATIENTPHONE1":
                textSelectedFieldDetails.Text = "Home phone for the patient being placed for account management by TSI";
                return;

            case "PATIENTPHONE2":
                textSelectedFieldDetails.Text = "Wireless phone for the patient being placed for account management by TSI";
                return;

            case "DEMANDTYPE":
                if (selectedText == "1")
                {
                    textSelectedFieldDetails.Text = "Accelerator/Profit Recovery";
                }
                else if (selectedText == "2")
                {
                    textSelectedFieldDetails.Text = "Collection";
                }
                return;

            case "SERVICECODE":
                if (string.IsNullOrWhiteSpace(selectedText))
                {
                    return;                            //nothing in the field so no text selected for translation
                }
                textSelectedFieldDetails.Text = PIn.Enum <TsiServiceCode>(PIn.Int(selectedText, false) - 1).GetDescription();
                return;

            case "TRANSACTION TYPE":
                if (string.IsNullOrWhiteSpace(selectedText))
                {
                    return;                            //nothing in the field so no text selected for translation
                }
                TsiTransType typeCur = PIn.Enum <TsiTransType>(selectedText, true);
                textSelectedFieldDetails.Text = typeCur.GetDescription();
                if (typeCur == TsiTransType.None)
                {
                    textSelectedFieldDetails.Text += " (transaction NOT sent to TSI, e.g. a payment received from TSI)";
                }
                return;

            case "DEBTOR DATE OF BIRTH":
            case "PATIENTDOB":
            case "DATE OF DEBT":
            case "DATE OF LAST PAY":
            case "TRANSACTION DATE":
                DateTime dateCur;
                if (string.IsNullOrWhiteSpace(selectedText) ||
                    !DateTime.TryParseExact(selectedText, "MMddyyyy", new CultureInfo("en-US"), DateTimeStyles.AllowWhiteSpaces, out dateCur))
                {
                    return;
                }
                textSelectedFieldDetails.Text = dateCur.ToShortDateString();
                return;
            }
        }