Ejemplo n.º 1
0
        ///<summary></summary>
        public static void Insert(PatPlan p)
        {
            if (PrefB.RandomKeys)
            {
                p.PatPlanNum = MiscData.GetKey("patplan", "PatPlanNum");
            }
            string command = "INSERT INTO patplan (";

            if (PrefB.RandomKeys)
            {
                command += "PatPlanNum,";
            }
            command += "PatNum,PlanNum,Ordinal,IsPending,Relationship,PatID) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(p.PatPlanNum) + "', ";
            }
            command +=
                "'" + POut.PInt(p.PatNum) + "', "
                + "'" + POut.PInt(p.PlanNum) + "', "
                + "'" + POut.PInt(p.Ordinal) + "', "
                + "'" + POut.PBool(p.IsPending) + "', "
                + "'" + POut.PInt((int)p.Relationship) + "', "
                + "'" + POut.PString(p.PatID) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                p.PatPlanNum = General.NonQ(command, true);
            }
        }
Ejemplo n.º 2
0
        ///<summary>This form does NOT take care of updating the patplan table for you.
        ///It passes around the patPlan you passed in by reference, so you can call update on the same patplan you passed in to update.</summary>
        public FormOrthoPat(PatPlan patPlanCur, InsPlan insPlanCur, string carrierName, string subID, double defaultFee)
        {
            InitializeComponent();
            Lan.F(this);
            _patPlanCur = patPlanCur;
            _insPlanCur = insPlanCur;
            Patient patCur = Patients.GetLim(patPlanCur.PatNum);

            textPatient.Text = patCur.GetNameLF();
            textCarrier.Text = carrierName;
            textSubID.Text   = subID;
            if (patPlanCur.OrthoAutoFeeBilledOverride == -1)
            {
                checkUseDefaultFee.Checked = true;
                textFee.ReadOnly           = true;
                textFee.Text = defaultFee.ToString();
            }
            else
            {
                checkUseDefaultFee.Checked = false;
                textFee.ReadOnly           = false;
                textFee.Text = patPlanCur.OrthoAutoFeeBilledOverride.ToString();
            }
            if (patPlanCur.OrthoAutoNextClaimDate.Date != DateTime.MinValue.Date)
            {
                textDateNextClaim.Text = patPlanCur.OrthoAutoNextClaimDate.ToShortDateString();
            }
            else               //there is no initial procedure or claim, so showing when the "next" claim will be would be misleading.
            {
                textDateNextClaim.Text = "";
            }
        }
Ejemplo n.º 3
0
        ///<summary>Inserts one PatPlan into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(PatPlan patPlan, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                patPlan.PatPlanNum = ReplicationServers.GetKey("patplan", "PatPlanNum");
            }
            string command = "INSERT INTO patplan (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "PatPlanNum,";
            }
            command += "PatNum,Ordinal,IsPending,Relationship,PatID,InsSubNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(patPlan.PatPlanNum) + ",";
            }
            command +=
                POut.Long(patPlan.PatNum) + ","
                + POut.Byte(patPlan.Ordinal) + ","
                + POut.Bool(patPlan.IsPending) + ","
                + POut.Int((int)patPlan.Relationship) + ","
                + "'" + POut.String(patPlan.PatID) + "',"
                + POut.Long(patPlan.InsSubNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                patPlan.PatPlanNum = Db.NonQ(command, true);
            }
            return(patPlan.PatPlanNum);
        }
Ejemplo n.º 4
0
        public void InsPlan_GetInsUsedDisplay_OrthoProcsNotAffectInsUsed()
        {
            string  suffix  = "13";
            Patient pat     = PatientT.CreatePatient(suffix);
            Carrier carrier = CarrierT.CreateCarrier(suffix);
            InsPlan plan    = InsPlanT.CreateInsPlan(carrier.CarrierNum);
            InsSub  sub     = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
            long    subNum  = sub.InsSubNum;
            PatPlan patPlan = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);

            BenefitT.CreateAnnualMax(plan.PlanNum, 100);
            BenefitT.CreateOrthoMax(plan.PlanNum, 500);
            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Diagnostic, 100);
            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Orthodontics, 100);
            Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0140", ProcStat.C, "", 59);      //limEx
            Procedure proc2 = ProcedureT.CreateProcedure(pat, "D8090", ProcStat.C, "", 348);     //Comprehensive ortho

            ClaimProcT.AddInsPaid(pat.PatNum, plan.PlanNum, proc1.ProcNum, 59, subNum, 0, 0);
            ClaimProcT.AddInsPaid(pat.PatNum, plan.PlanNum, proc2.ProcNum, 348, subNum, 0, 0);
            //Lists
            Family               fam         = Patients.GetFamily(pat.PatNum);
            List <InsSub>        subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan>       planList    = InsPlans.RefreshForSubList(subList);
            List <PatPlan>       patPlans    = PatPlans.Refresh(pat.PatNum);
            List <Benefit>       benefitList = Benefits.Refresh(patPlans, subList);
            List <ClaimProcHist> histList    = ClaimProcs.GetHistList(pat.PatNum, benefitList, patPlans, planList, DateTime.Today, subList);
            //Validate
            double insUsed = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, plan.PlanNum, patPlan.PatPlanNum, -1, planList, benefitList, pat.PatNum, subNum);

            Assert.AreEqual(59, insUsed);
        }
Ejemplo n.º 5
0
        ///<summary>Updates one PatPlan 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(PatPlan patPlan, PatPlan oldPatPlan)
        {
            string command = "";

            if (patPlan.PatNum != oldPatPlan.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(patPlan.PatNum) + "";
            }
            if (patPlan.Ordinal != oldPatPlan.Ordinal)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Ordinal = " + POut.Byte(patPlan.Ordinal) + "";
            }
            if (patPlan.IsPending != oldPatPlan.IsPending)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsPending = " + POut.Bool(patPlan.IsPending) + "";
            }
            if (patPlan.Relationship != oldPatPlan.Relationship)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Relationship = " + POut.Int((int)patPlan.Relationship) + "";
            }
            if (patPlan.PatID != oldPatPlan.PatID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatID = '" + POut.String(patPlan.PatID) + "'";
            }
            if (patPlan.InsSubNum != oldPatPlan.InsSubNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "InsSubNum = " + POut.Long(patPlan.InsSubNum) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE patplan SET " + command
                      + " WHERE PatPlanNum = " + POut.Long(patPlan.PatPlanNum);
            Db.NonQ(command);
        }
Ejemplo n.º 6
0
        public static InsuranceInfo AddInsurance(Patient pat, string carrierName, string planType = "", long feeSchedNum = 0, int ordinal = 1, bool isMedical = false,
                                                 EnumCobRule cobRule = EnumCobRule.Basic, long copayFeeSchedNum          = 0)
        {
            Carrier carrier = CarrierT.CreateCarrier(carrierName);
            InsPlan plan    = InsPlanT.CreateInsPlan(carrier.CarrierNum, cobRule);
            InsPlan planOld = plan.Copy();

            plan.PlanType      = planType;
            plan.FeeSched      = feeSchedNum;
            plan.IsMedical     = isMedical;
            plan.CopayFeeSched = copayFeeSchedNum;
            InsPlans.Update(plan, planOld);
            InsSub  sub     = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
            PatPlan patPlan = PatPlanT.CreatePatPlan((byte)ordinal, pat.PatNum, sub.InsSubNum);

            return(new InsuranceInfo {
                ListCarriers = new List <Carrier> {
                    carrier
                },
                ListInsPlans = new List <InsPlan> {
                    plan
                },
                ListInsSubs = new List <InsSub> {
                    sub
                },
                ListPatPlans = new List <PatPlan> {
                    patPlan
                },
            });
        }
Ejemplo n.º 7
0
        public static string RunOne(bool showForms)
        {
            string  retVal  = "";
            long    provNum = ProviderC.ListShort[0].ProvNum;       //dentist #1
            Patient pat     = Patients.GetPat(PatientTC.PatNum1);   //patient#1

            if (pat.PriProv != provNum)
            {
                Patient oldPat = pat.Copy();
                pat.PriProv = provNum;              //this script uses the primary provider for the patient
                Patients.Update(pat, oldPat);
            }
            PatPlan patplan = PatPlans.GetPatPlan(pat.PatNum, 1);
            InsSub  sub     = InsSubs.GetOne(patplan.InsSubNum);
            InsPlan plan    = InsPlans.GetPlan(sub.PlanNum, new List <InsPlan>());
            //the UI would block this due to carrier not supporting this transaction type.
            Clearinghouse    clearinghouseHq   = Clearinghouses.GetDefaultDental();
            Clearinghouse    clearinghouseClin = Clearinghouses.OverrideFields(clearinghouseHq, Clinics.ClinicNum);
            long             etransNum         = CanadianOutput.SendElegibility(clearinghouseClin, pat.PatNum, plan, new DateTime(1999, 1, 1), patplan.Relationship, patplan.PatID, showForms, sub);
            Etrans           etrans            = Etranss.GetEtrans(etransNum);
            string           message           = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData          = new CCDFieldInputter(message);
            string           responseStatus    = formData.GetValue("G05");

            if (responseStatus != "R")
            {
                throw new Exception("Should be R");
            }
            retVal += "Eligibility #1 successful.\r\n";
            return(retVal);
        }
Ejemplo n.º 8
0
        public static string RunFour(bool showForms)
        {
            string  retVal  = "";
            long    provNum = ProviderC.ListShort[1].ProvNum;       //dentist #2
            Patient pat     = Patients.GetPat(PatientTC.PatNum6);   //patient#6

            if (pat.PriProv != provNum)
            {
                Patient oldPat = pat.Copy();
                pat.PriProv = provNum;              //this script uses the primary provider for the patient
                Patients.Update(pat, oldPat);
            }
            PatPlan          patplan        = PatPlans.GetPatPlan(pat.PatNum, 1);
            InsSub           sub            = InsSubs.GetOne(patplan.InsSubNum);
            InsPlan          plan           = InsPlans.GetPlan(sub.PlanNum, new List <InsPlan>());
            long             etransNum      = CanadianOutput.SendElegibility(pat.PatNum, plan, new DateTime(1999, 1, 1), patplan.Relationship, patplan.PatID, showForms, sub);
            Etrans           etrans         = Etranss.GetEtrans(etransNum);
            string           message        = EtransMessageTexts.GetMessageText(etrans.EtransMessageTextNum);
            CCDFieldInputter formData       = new CCDFieldInputter(message);
            string           responseStatus = formData.GetValue("G05");

            if (responseStatus != "M")
            {
                throw new Exception("Should be M");
            }
            retVal += "Eligibility #4 successful.\r\n";
            return(retVal);
        }
Ejemplo n.º 9
0
 ///<summary>Inserts one PatPlan into the database.  Returns the new priKey.</summary>
 internal static long Insert(PatPlan patPlan)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         patPlan.PatPlanNum=DbHelper.GetNextOracleKey("patplan","PatPlanNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(patPlan,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     patPlan.PatPlanNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(patPlan,false);
     }
 }
Ejemplo n.º 10
0
 ///<summary>Inserts one PatPlan into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(PatPlan patPlan,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         patPlan.PatPlanNum=ReplicationServers.GetKey("patplan","PatPlanNum");
     }
     string command="INSERT INTO patplan (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="PatPlanNum,";
     }
     command+="PatNum,Ordinal,IsPending,Relationship,PatID,InsSubNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(patPlan.PatPlanNum)+",";
     }
     command+=
              POut.Long  (patPlan.PatNum)+","
         +    POut.Byte  (patPlan.Ordinal)+","
         +    POut.Bool  (patPlan.IsPending)+","
         +    POut.Int   ((int)patPlan.Relationship)+","
         +"'"+POut.String(patPlan.PatID)+"',"
         +    POut.Long  (patPlan.InsSubNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         patPlan.PatPlanNum=Db.NonQ(command,true);
     }
     return patPlan.PatPlanNum;
 }
Ejemplo n.º 11
0
 ///<summary>Only use pri or sec, not tot.  Used from ClaimProc.ComputeBaseEst. This is a low level function to get the percent to store in a claimproc.  It does not consider any percentOverride.  Always returns a number between 0 and 100.  The supplied benefit list should be sorted frirst.</summary>
 public static int GetPercent(string myCode, InsPlan insPlan, PatPlan patPlan, Benefit[] benList)
 {
     if (insPlan.PlanType == "f" || insPlan.PlanType == "c")
     {
         return(100);               //flat and cap are always covered 100%
     }
     CovSpan[] spansForCat;
     //loop through benefits starting at bottom (most specific)
     for (int i = benList.Length - 1; i >= 0; i--)
     {
         //if plan benefit, but no match
         if (benList[i].PlanNum != 0 && insPlan.PlanNum != benList[i].PlanNum)
         {
             continue;
         }
         //if patplan benefit, but no match
         if (benList[i].PatPlanNum != 0 && patPlan.PatPlanNum != benList[i].PatPlanNum)
         {
             continue;
         }
         if (benList[i].BenefitType != InsBenefitType.Percentage)
         {
             continue;
         }
         spansForCat = CovSpans.GetForCat(benList[i].CovCatNum);
         for (int j = 0; j < spansForCat.Length; j++)
         {
             if (String.Compare(myCode, spansForCat[j].FromCode) >= 0 && String.Compare(myCode, spansForCat[j].ToCode) <= 0)
             {
                 return(benList[i].Percent);
             }
         }
     }
     return(0);
 }
Ejemplo n.º 12
0
 ///<summary>Inserts one PatPlan into the database.  Returns the new priKey.</summary>
 public static long Insert(PatPlan patPlan)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         patPlan.PatPlanNum = DbHelper.GetNextOracleKey("patplan", "PatPlanNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(patPlan, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     patPlan.PatPlanNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(patPlan, false));
     }
 }
Ejemplo n.º 13
0
        public void InsPlans_ComputeEstimatesForSubscriber_CanadianLabFees()
        {
            string      suffix     = MethodBase.GetCurrentMethod().Name;
            CultureInfo curCulture = CultureInfo.CurrentCulture;

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-CA");          //Canada
            try {
                //Create a patient and treatment plan a procedure with a lab fee.
                Patient pat = PatientT.CreatePatient();
                ProcedureCodeT.AddIfNotPresent("14611");
                ProcedureCodeT.AddIfNotPresent("99111", isCanadianLab: true);
                Procedure proc    = ProcedureT.CreateProcedure(pat, "14611", ProcStat.TP, "", 250);
                Procedure procLab = ProcedureT.CreateProcedure(pat, "99111", ProcStat.TP, "", 149, procNumLab: proc.ProcNum);
                //Create a new primary insurance plan for this patient.
                //It is important that we add the insurance plan after the procedure has already been created for this particular scenario.
                Carrier carrier = CarrierT.CreateCarrier(suffix);
                InsPlan plan    = InsPlanT.CreateInsPlan(carrier.CarrierNum);
                InsSub  sub     = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
                PatPlan patPlan = PatPlanT.CreatePatPlan(1, pat.PatNum, sub.InsSubNum);
                //Invoking ComputeEstimatesForAll() will simulate the logic of adding a new insurance plan from the Family module.
                //The bug that this unit test is preventing is that a duplicate claimproc was being created for the lab fee.
                //This was causing a faux line to show up when a claim was created for the procedure in question.
                //It ironically doesn't matter if the procedures above are even covered by insurance because they'll get claimprocs created regardless.
                InsPlans.ComputeEstimatesForSubscriber(sub.Subscriber);
                //Check to see how many claimproc enteries there are for the current patient.  There should only be two.
                List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);
                Assert.AreEqual(2, listClaimProcs.Count);
            }
            finally {
                Thread.CurrentThread.CurrentCulture = curCulture;
            }
        }
Ejemplo n.º 14
0
        public void PaymentEdit_Init_AutoSplitWithClaimPayments()          //Legacy_TestFortyEight
        {
            string    suffix     = "48";
            Patient   pat        = PatientT.CreatePatient(suffix);
            long      patNum     = pat.PatNum;
            InsPlan   insPlan    = InsPlanT.CreateInsPlan(CarrierT.CreateCarrier(suffix).CarrierNum);
            InsSub    insSub     = InsSubT.CreateInsSub(patNum, insPlan.PlanNum);
            PatPlan   patPlan    = PatPlanT.CreatePatPlan(1, patNum, insSub.InsSubNum);
            Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, DateTime.Now.AddDays(-1));
            Procedure procedure2 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 40, DateTime.Now.AddDays(-2));
            Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Now.AddDays(-3));

            ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure1.ProcNum, 20, insSub.InsSubNum, 0, 0);
            ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure2.ProcNum, 5, insSub.InsSubNum, 5, 0);
            ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure3.ProcNum, 20, insSub.InsSubNum, 0, 10);
            Payment        payment       = PaymentT.MakePaymentNoSplits(patNum, 150, DateTime.Today);
            Family         famForPat     = Patients.GetFamily(patNum);
            List <Patient> listFamForPat = famForPat.ListPats.ToList();

            PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family {
            }, payment, new List <PaySplit>(), new List <Procedure>(), patNum);
            //Auto Splits will be in opposite order from least recent to most recent.
            //ListSplitsCur should contain four splits, 30, 35, and 30, then one unallocated for the remainder of the payment 55.
            Assert.AreEqual(4, init.AutoSplitData.ListSplitsCur.Count);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 40 || init.AutoSplitData.ListSplitsCur[0].ProcNum != procedure3.ProcNum ||
                           init.AutoSplitData.ListSplitsCur[0].PatNum != patNum);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[1].SplitAmt != 35 || init.AutoSplitData.ListSplitsCur[1].ProcNum != procedure2.ProcNum ||
                           init.AutoSplitData.ListSplitsCur[1].PatNum != patNum);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[2].SplitAmt != 30 || init.AutoSplitData.ListSplitsCur[2].ProcNum != procedure1.ProcNum ||
                           init.AutoSplitData.ListSplitsCur[2].PatNum != patNum);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[3].SplitAmt != 45 || init.AutoSplitData.ListSplitsCur[3].ProcNum != 0);
        }
Ejemplo n.º 15
0
        public static PatPlan CreatePatPlan(byte ordinal, long patNum, long subNum)
        {
            PatPlan patPlan = new PatPlan();

            patPlan.Ordinal   = ordinal;
            patPlan.PatNum    = patNum;
            patPlan.InsSubNum = subNum;
            PatPlans.Insert(patPlan);
            return(patPlan);
        }
Ejemplo n.º 16
0
        ///<summary></summary>
        public static void Update(PatPlan p)
        {
            string command = "UPDATE patplan SET "
                             + "PatNum = '" + POut.PInt(p.PatNum) + "'"
                             + ",PlanNum = '" + POut.PInt(p.PlanNum) + "'"
                             //+",Ordinal = '"     +POut.PInt   (Ordinal)+"'"//ordinal always set using SetOrdinal
                             + ",IsPending = '" + POut.PBool(p.IsPending) + "'"
                             + ",Relationship = '" + POut.PInt((int)p.Relationship) + "'"
                             + ",PatID = '" + POut.PString(p.PatID) + "'"
                             + " WHERE PatPlanNum = '" + POut.PInt(p.PatPlanNum) + "'";

            General.NonQ(command);
        }
Ejemplo n.º 17
0
        ///<summary>Updates one PatPlan in the database.</summary>
        internal static void Update(PatPlan patPlan)
        {
            string command = "UPDATE patplan SET "
                             + "PatNum      =  " + POut.Long(patPlan.PatNum) + ", "
                             + "Ordinal     =  " + POut.Byte(patPlan.Ordinal) + ", "
                             + "IsPending   =  " + POut.Bool(patPlan.IsPending) + ", "
                             + "Relationship=  " + POut.Int((int)patPlan.Relationship) + ", "
                             + "PatID       = '" + POut.String(patPlan.PatID) + "', "
                             + "InsSubNum   =  " + POut.Long(patPlan.InsSubNum) + " "
                             + "WHERE PatPlanNum = " + POut.Long(patPlan.PatPlanNum);

            Db.NonQ(command);
        }
Ejemplo n.º 18
0
        ///<summary>Updates one PatPlan in the database.</summary>
        public static void Update(PatPlan patPlan)
        {
            string command = "UPDATE patplan SET "
                             + "PatNum                    =  " + POut.Long(patPlan.PatNum) + ", "
                             + "Ordinal                   =  " + POut.Byte(patPlan.Ordinal) + ", "
                             + "IsPending                 =  " + POut.Bool(patPlan.IsPending) + ", "
                             + "Relationship              =  " + POut.Int((int)patPlan.Relationship) + ", "
                             + "PatID                     = '" + POut.String(patPlan.PatID) + "', "
                             + "InsSubNum                 =  " + POut.Long(patPlan.InsSubNum) + ", "
                             + "OrthoAutoFeeBilledOverride= '" + POut.Double(patPlan.OrthoAutoFeeBilledOverride) + "', "
                             + "OrthoAutoNextClaimDate    =  " + POut.Date(patPlan.OrthoAutoNextClaimDate) + " "
                             + "WHERE PatPlanNum = " + POut.Long(patPlan.PatPlanNum);

            Db.NonQ(command);
        }
Ejemplo n.º 19
0
 ///<summary>Inserts one PatPlan into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PatPlan patPlan)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(patPlan, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             patPlan.PatPlanNum = DbHelper.GetNextOracleKey("patplan", "PatPlanNum");                  //Cacheless method
         }
         return(InsertNoCache(patPlan, true));
     }
 }
Ejemplo n.º 20
0
        public static void ProcessIN1(Patient pat, SegmentHL7 seg)
        {
            //as a general strategy, if certain things are the same, like subscriber and carrier,
            //then we change the existing plan.
            //However, if basics change at all, then we drop the old plan and create a new one
            int     ordinal    = PIn.Int(seg.GetFieldFullText(1));
            PatPlan oldPatPlan = PatPlans.GetPatPlan(pat.PatNum, ordinal);

            if (oldPatPlan == null)
            {
                //create a new plan and a new patplan
            }
            //InsPlan oldPlan=InsPlans.g
            //we'll have to get back to this.  This is lower priority than appointments.
        }
Ejemplo n.º 21
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<PatPlan> TableToList(DataTable table){
			List<PatPlan> retVal=new List<PatPlan>();
			PatPlan patPlan;
			for(int i=0;i<table.Rows.Count;i++) {
				patPlan=new PatPlan();
				patPlan.PatPlanNum  = PIn.Long  (table.Rows[i]["PatPlanNum"].ToString());
				patPlan.PatNum      = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				patPlan.Ordinal     = PIn.Byte  (table.Rows[i]["Ordinal"].ToString());
				patPlan.IsPending   = PIn.Bool  (table.Rows[i]["IsPending"].ToString());
				patPlan.Relationship= (Relat)PIn.Int(table.Rows[i]["Relationship"].ToString());
				patPlan.PatID       = PIn.String(table.Rows[i]["PatID"].ToString());
				patPlan.InsSubNum   = PIn.Long  (table.Rows[i]["InsSubNum"].ToString());
				retVal.Add(patPlan);
			}
			return retVal;
		}
Ejemplo n.º 22
0
        public void InsPlan_GetDedRemainDisplay_IndividualAndFamilyDeductiblesInsRemaining()
        {
            string  suffix = "20";
            Patient pat    = PatientT.CreatePatient(suffix);       //guarantor
            long    patNum = pat.PatNum;
            Patient pat2   = PatientT.CreatePatient(suffix);

            PatientT.SetGuarantor(pat2, pat.PatNum);
            Patient pat3 = PatientT.CreatePatient(suffix);

            PatientT.SetGuarantor(pat3, pat.PatNum);
            Carrier carrier  = CarrierT.CreateCarrier(suffix);
            InsPlan plan     = InsPlanT.CreateInsPlan(carrier.CarrierNum);
            long    planNum  = plan.PlanNum;
            InsSub  sub      = InsSubT.CreateInsSub(pat.PatNum, planNum);      //guarantor is subscriber
            long    subNum   = sub.InsSubNum;
            PatPlan patPlan  = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);  //all three patients have the same plan
            PatPlan patPlan2 = PatPlanT.CreatePatPlan(1, pat2.PatNum, subNum); //all three patients have the same plan
            PatPlan patPlan3 = PatPlanT.CreatePatPlan(1, pat3.PatNum, subNum); //all three patients have the same plan

            BenefitT.CreateDeductibleGeneral(planNum, BenefitCoverageLevel.Individual, 75);
            BenefitT.CreateDeductibleGeneral(planNum, BenefitCoverageLevel.Family, 150);
            ClaimProcT.AddInsUsedAdjustment(pat3.PatNum, planNum, 0, subNum, 75);               //Adjustment goes on the third patient
            Procedure proc = ProcedureT.CreateProcedure(pat2, "D2750", ProcStat.C, "20", 1280); //proc for second patient with a deductible already applied.

            ClaimProcT.AddInsPaid(pat2.PatNum, planNum, proc.ProcNum, 304, subNum, 50, 597);
            proc = ProcedureT.CreateProcedure(pat, "D4355", ProcStat.TP, "", 135);      //proc is for the first patient
            long procNum = proc.ProcNum;
            //Lists
            List <ClaimProc>     claimProcs  = ClaimProcs.Refresh(patNum);
            Family               fam         = Patients.GetFamily(patNum);
            List <InsSub>        subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan>       planList    = InsPlans.RefreshForSubList(subList);
            List <PatPlan>       patPlans    = PatPlans.Refresh(patNum);
            List <Benefit>       benefitList = Benefits.Refresh(patPlans, subList);
            List <ClaimProcHist> histList    = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList);
            List <ClaimProcHist> loopList    = new List <ClaimProcHist>();
            //Validate
            List <ClaimProcHist> HistList = ClaimProcs.GetHistList(pat.PatNum, benefitList, patPlans, planList, DateTime.Today, subList);
            double dedFam = Benefits.GetDeductGeneralDisplay(benefitList, planNum, patPlan.PatPlanNum, BenefitCoverageLevel.Family);
            double ded    = Benefits.GetDeductGeneralDisplay(benefitList, planNum, patPlan.PatPlanNum, BenefitCoverageLevel.Individual);
            double dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTime.Today, planNum, patPlan.PatPlanNum, -1, planList, pat.PatNum, ded, dedFam);  //test family and individual deductible together

            Assert.AreEqual(25, dedRem);
            dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTime.Today, planNum, patPlan.PatPlanNum, -1, planList, pat.PatNum, ded, -1);  //test individual deductible by itself
            Assert.AreEqual(75, dedRem);
        }
Ejemplo n.º 23
0
 private PatPlan InsertOrUpdatePatPlan(PatPlan patPlan, InsSub insSub, InsPlan insPlan, Hx834_Member member,
                                       Carrier carrier, List <PatPlan> listOtherPatPlans)
 {
     if (patPlan == null)
     {
         patPlan         = new PatPlan();
         patPlan.Ordinal = 0;
         for (int p = 0; p < listOtherPatPlans.Count; p++)
         {
             if (listOtherPatPlans[p].Ordinal > patPlan.Ordinal)
             {
                 patPlan.Ordinal = listOtherPatPlans[p].Ordinal;
             }
         }
         patPlan.Ordinal++;                //Greatest ordinal for patient.
         patPlan.PatNum       = member.Pat.PatNum;
         patPlan.InsSubNum    = insSub.InsSubNum;
         patPlan.Relationship = member.PlanRelat;
         if (member.PlanRelat != Relat.Self)
         {
             //This is not needed yet.  If we do this in the future, then we need to mimic the Move tool in the Family module.
             //member.Pat.Guarantor=insSubMatch.Subscriber;
             //Patient memberPatOld=member.Pat.Copy();
             //Patients.Update(member.Pat,memberPatOld);
         }
         PatPlans.Insert(patPlan);
         SecurityLogs.MakeLogEntry(Permissions.InsPlanAddPat, patPlan.PatNum,
                                   "Insurance plan added to patient for carrier '" + carrier.CarrierName + "' and groupnum "
                                   + "'" + insPlan.GroupNum + "' and subscriber ID '" + insSub.SubscriberID + "' "
                                   + "from Import Ins Plans 834.", insPlan.PlanNum, LogSources.InsPlanImport834, insPlan.SecDateTEdit);
     }
     else
     {
         PatPlan patPlanOld = patPlan.Copy();
         patPlan.Relationship = member.PlanRelat;
         if (OpenDentBusiness.Crud.PatPlanCrud.UpdateComparison(patPlan, patPlanOld))
         {
             SecurityLogs.MakeLogEntry(Permissions.InsPlanEdit, patPlan.PatNum, "Insurance plan relationship changed from "
                                       + member.PlanRelat + " to " + patPlan.Relationship + " for carrier '" + carrier.CarrierName + "' and groupnum "
                                       + "'" + insPlan.GroupNum + "' from Import Ins Plans 834.", insPlan.PlanNum, LogSources.InsPlanImport834, insPlan.SecDateTEdit);
             PatPlans.Update(patPlan);
         }
     }
     return(patPlan);
 }
Ejemplo n.º 24
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <PatPlan> TableToList(DataTable table)
        {
            List <PatPlan> retVal = new List <PatPlan>();
            PatPlan        patPlan;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                patPlan              = new PatPlan();
                patPlan.PatPlanNum   = PIn.Long(table.Rows[i]["PatPlanNum"].ToString());
                patPlan.PatNum       = PIn.Long(table.Rows[i]["PatNum"].ToString());
                patPlan.Ordinal      = PIn.Byte(table.Rows[i]["Ordinal"].ToString());
                patPlan.IsPending    = PIn.Bool(table.Rows[i]["IsPending"].ToString());
                patPlan.Relationship = (Relat)PIn.Int(table.Rows[i]["Relationship"].ToString());
                patPlan.PatID        = PIn.String(table.Rows[i]["PatID"].ToString());
                patPlan.InsSubNum    = PIn.Long(table.Rows[i]["InsSubNum"].ToString());
                retVal.Add(patPlan);
            }
            return(retVal);
        }
Ejemplo n.º 25
0
        ///<summary>Returns false if the insurance plan is effective.  True if today is outside of the insurance effective date range.</summary>
        private static bool InsuranceNotEffectiveComparison(AutomationCondition autoCond, long patNum)
        {
            PatPlan patPlanCur = PatPlans.GetPatPlan(patNum, 1);

            if (patPlanCur == null)
            {
                return(false);
            }
            InsSub insSubCur = InsSubs.GetOne(patPlanCur.InsSubNum);

            if (insSubCur == null)
            {
                return(false);
            }
            if (DateTime.Today >= insSubCur.DateEffective && DateTime.Today <= insSubCur.DateTerm)
            {
                return(false);               //Allen - Not not effective
            }
            return(true);
        }
Ejemplo n.º 26
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PatPlan> TableToList(DataTable table)
        {
            List <PatPlan> retVal = new List <PatPlan>();
            PatPlan        patPlan;

            foreach (DataRow row in table.Rows)
            {
                patPlan              = new PatPlan();
                patPlan.PatPlanNum   = PIn.Long(row["PatPlanNum"].ToString());
                patPlan.PatNum       = PIn.Long(row["PatNum"].ToString());
                patPlan.Ordinal      = PIn.Byte(row["Ordinal"].ToString());
                patPlan.IsPending    = PIn.Bool(row["IsPending"].ToString());
                patPlan.Relationship = (OpenDentBusiness.Relat)PIn.Int(row["Relationship"].ToString());
                patPlan.PatID        = PIn.String(row["PatID"].ToString());
                patPlan.InsSubNum    = PIn.Long(row["InsSubNum"].ToString());
                patPlan.OrthoAutoFeeBilledOverride = PIn.Double(row["OrthoAutoFeeBilledOverride"].ToString());
                patPlan.OrthoAutoNextClaimDate     = PIn.Date(row["OrthoAutoNextClaimDate"].ToString());
                retVal.Add(patPlan);
            }
            return(retVal);
        }
Ejemplo n.º 27
0
        ///<summary>Gets a list of all patplans for a given patient</summary>
        public static PatPlan[] Refresh(int patNum)
        {
            string command = "SELECT * from patplan"
                             + " WHERE PatNum = " + patNum.ToString()
                             + " ORDER BY Ordinal";
            DataTable table = General.GetTable(command);

            PatPlan[] List = new PatPlan[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i]              = new PatPlan();
                List[i].PatPlanNum   = PIn.PInt(table.Rows[i][0].ToString());
                List[i].PatNum       = PIn.PInt(table.Rows[i][1].ToString());
                List[i].PlanNum      = PIn.PInt(table.Rows[i][2].ToString());
                List[i].Ordinal      = PIn.PInt(table.Rows[i][3].ToString());
                List[i].IsPending    = PIn.PBool(table.Rows[i][4].ToString());
                List[i].Relationship = (Relat)PIn.PInt(table.Rows[i][5].ToString());
                List[i].PatID        = PIn.PString(table.Rows[i][6].ToString());
            }
            return(List);
        }
Ejemplo n.º 28
0
        ///<summary>Inserts one PatPlan into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(PatPlan patPlan, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO patplan (";

            if (!useExistingPK && isRandomKeys)
            {
                patPlan.PatPlanNum = ReplicationServers.GetKeyNoCache("patplan", "PatPlanNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "PatPlanNum,";
            }
            command += "PatNum,Ordinal,IsPending,Relationship,PatID,InsSubNum,OrthoAutoFeeBilledOverride,OrthoAutoNextClaimDate) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(patPlan.PatPlanNum) + ",";
            }
            command +=
                POut.Long(patPlan.PatNum) + ","
                + POut.Byte(patPlan.Ordinal) + ","
                + POut.Bool(patPlan.IsPending) + ","
                + POut.Int((int)patPlan.Relationship) + ","
                + "'" + POut.String(patPlan.PatID) + "',"
                + POut.Long(patPlan.InsSubNum) + ","
                + "'" + POut.Double(patPlan.OrthoAutoFeeBilledOverride) + "',"
                + POut.Date(patPlan.OrthoAutoNextClaimDate) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                patPlan.PatPlanNum = Db.NonQ(command, true, "PatPlanNum", "patPlan");
            }
            return(patPlan.PatPlanNum);
        }
Ejemplo n.º 29
0
        public void Claims_CalculateAndUpdate_PreauthOrderWriteoff()
        {
            string suffix = MethodBase.GetCurrentMethod().Name;
            //create the patient and insurance information
            Patient pat = PatientT.CreatePatient(suffix);
            //proc - Crown
            Procedure proc         = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.C, "8", 1000);
            long      feeSchedNum1 = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix);

            FeeT.CreateFee(feeSchedNum1, proc.CodeNum, 900);
            Carrier carrier = CarrierT.CreateCarrier(suffix);
            InsPlan insPlan = InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, feeSchedNum1);

            BenefitT.CreateAnnualMax(insPlan.PlanNum, 1000);
            BenefitT.CreateCategoryPercent(insPlan.PlanNum, EbenefitCategory.Crowns, 100);
            InsSub  sub = InsSubT.CreateInsSub(pat.PatNum, insPlan.PlanNum);
            PatPlan pp  = PatPlanT.CreatePatPlan(1, pat.PatNum, sub.InsSubNum);
            //create lists and variables required for ComputeEstimates()
            List <InsSub>    SubList         = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
            List <InsPlan>   listInsPlan     = InsPlans.RefreshForSubList(SubList);
            List <PatPlan>   listPatPlan     = PatPlans.Refresh(pat.PatNum);
            List <Benefit>   listBenefits    = Benefits.Refresh(listPatPlan, SubList);
            List <Procedure> listProcsForPat = Procedures.Refresh(pat.PatNum);
            List <Procedure> procsForClaim   = new List <Procedure>();

            procsForClaim.Add(proc);
            //Create the claim and associated claimprocs
            //The order of these claimprocs is the whole point of the unit test.
            //Create Preauth
            ClaimProcs.CreateEst(new ClaimProc(), proc, insPlan, sub, 0, 500, true, true);
            //Create Estimate
            ClaimProcs.CreateEst(new ClaimProc(), proc, insPlan, sub, 1000, 1000, true, false);
            List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);
            Claim            claimWaiting   = ClaimT.CreateClaim("W", listPatPlan, listInsPlan, listClaimProcs, listProcsForPat, pat, procsForClaim, listBenefits, SubList, false);

            Assert.AreEqual(100, claimWaiting.WriteOff, "WriteOff Amount");
        }
Ejemplo n.º 30
0
 ///<summary>Returns true if Update(PatPlan,PatPlan) 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(PatPlan patPlan, PatPlan oldPatPlan)
 {
     if (patPlan.PatNum != oldPatPlan.PatNum)
     {
         return(true);
     }
     if (patPlan.Ordinal != oldPatPlan.Ordinal)
     {
         return(true);
     }
     if (patPlan.IsPending != oldPatPlan.IsPending)
     {
         return(true);
     }
     if (patPlan.Relationship != oldPatPlan.Relationship)
     {
         return(true);
     }
     if (patPlan.PatID != oldPatPlan.PatID)
     {
         return(true);
     }
     if (patPlan.InsSubNum != oldPatPlan.InsSubNum)
     {
         return(true);
     }
     if (patPlan.OrthoAutoFeeBilledOverride != oldPatPlan.OrthoAutoFeeBilledOverride)
     {
         return(true);
     }
     if (patPlan.OrthoAutoNextClaimDate.Date != oldPatPlan.OrthoAutoNextClaimDate.Date)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 31
0
        public void AddInsurance(Patient pat, string carrierName, string planType = "", long feeSchedNum = 0, int ordinal    = 1, bool isMedical      = false,
                                 EnumCobRule cobRule         = EnumCobRule.Basic, long copayFeeSchedNum  = 0, int monthRenew = 0, string subscriberID = "1234",
                                 ExclusionRule exclusionRule = ExclusionRule.PracticeDefault)
        {
            Carrier carrier = CarrierT.CreateCarrier(carrierName);
            InsPlan plan    = InsPlanT.CreateInsPlan(carrier.CarrierNum, cobRule);
            InsPlan planOld = plan.Copy();

            plan.PlanType         = planType;
            plan.MonthRenew       = (byte)monthRenew;
            plan.FeeSched         = feeSchedNum;
            plan.IsMedical        = isMedical;
            plan.CopayFeeSched    = copayFeeSchedNum;
            plan.ExclusionFeeRule = exclusionRule;
            InsPlans.Update(plan, planOld);
            InsSub  sub     = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum, subscriberID);
            PatPlan patPlan = PatPlanT.CreatePatPlan((byte)ordinal, pat.PatNum, sub.InsSubNum);

            ListCarriers.Add(carrier);
            ListInsPlans.Add(plan);
            ListInsSubs.Add(sub);
            ListPatPlans.Add(patPlan);
            Pat = pat;
        }
Ejemplo n.º 32
0
        ///<summary>Updates one PatPlan 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.  Returns true if an update occurred.</summary>
        public static bool Update(PatPlan patPlan, PatPlan oldPatPlan)
        {
            string command = "";

            if (patPlan.PatNum != oldPatPlan.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(patPlan.PatNum) + "";
            }
            if (patPlan.Ordinal != oldPatPlan.Ordinal)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Ordinal = " + POut.Byte(patPlan.Ordinal) + "";
            }
            if (patPlan.IsPending != oldPatPlan.IsPending)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsPending = " + POut.Bool(patPlan.IsPending) + "";
            }
            if (patPlan.Relationship != oldPatPlan.Relationship)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Relationship = " + POut.Int((int)patPlan.Relationship) + "";
            }
            if (patPlan.PatID != oldPatPlan.PatID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatID = '" + POut.String(patPlan.PatID) + "'";
            }
            if (patPlan.InsSubNum != oldPatPlan.InsSubNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "InsSubNum = " + POut.Long(patPlan.InsSubNum) + "";
            }
            if (patPlan.OrthoAutoFeeBilledOverride != oldPatPlan.OrthoAutoFeeBilledOverride)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OrthoAutoFeeBilledOverride = '" + POut.Double(patPlan.OrthoAutoFeeBilledOverride) + "'";
            }
            if (patPlan.OrthoAutoNextClaimDate.Date != oldPatPlan.OrthoAutoNextClaimDate.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "OrthoAutoNextClaimDate = " + POut.Date(patPlan.OrthoAutoNextClaimDate) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE patplan SET " + command
                      + " WHERE PatPlanNum = " + POut.Long(patPlan.PatPlanNum);
            Db.NonQ(command);
            return(true);
        }
Ejemplo n.º 33
0
 ///<summary>Updates one PatPlan in the database.</summary>
 internal static void Update(PatPlan patPlan)
 {
     string command="UPDATE patplan SET "
         +"PatNum      =  "+POut.Long  (patPlan.PatNum)+", "
         +"Ordinal     =  "+POut.Byte  (patPlan.Ordinal)+", "
         +"IsPending   =  "+POut.Bool  (patPlan.IsPending)+", "
         +"Relationship=  "+POut.Int   ((int)patPlan.Relationship)+", "
         +"PatID       = '"+POut.String(patPlan.PatID)+"', "
         +"InsSubNum   =  "+POut.Long  (patPlan.InsSubNum)+" "
         +"WHERE PatPlanNum = "+POut.Long(patPlan.PatPlanNum);
     Db.NonQ(command);
 }
Ejemplo n.º 34
0
 ///<summary>Updates one PatPlan 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(PatPlan patPlan,PatPlan oldPatPlan)
 {
     string command="";
     if(patPlan.PatNum != oldPatPlan.PatNum) {
         if(command!=""){ command+=",";}
         command+="PatNum = "+POut.Long(patPlan.PatNum)+"";
     }
     if(patPlan.Ordinal != oldPatPlan.Ordinal) {
         if(command!=""){ command+=",";}
         command+="Ordinal = "+POut.Byte(patPlan.Ordinal)+"";
     }
     if(patPlan.IsPending != oldPatPlan.IsPending) {
         if(command!=""){ command+=",";}
         command+="IsPending = "+POut.Bool(patPlan.IsPending)+"";
     }
     if(patPlan.Relationship != oldPatPlan.Relationship) {
         if(command!=""){ command+=",";}
         command+="Relationship = "+POut.Int   ((int)patPlan.Relationship)+"";
     }
     if(patPlan.PatID != oldPatPlan.PatID) {
         if(command!=""){ command+=",";}
         command+="PatID = '"+POut.String(patPlan.PatID)+"'";
     }
     if(patPlan.InsSubNum != oldPatPlan.InsSubNum) {
         if(command!=""){ command+=",";}
         command+="InsSubNum = "+POut.Long(patPlan.InsSubNum)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE patplan SET "+command
         +" WHERE PatPlanNum = "+POut.Long(patPlan.PatPlanNum);
     Db.NonQ(command);
 }
Ejemplo n.º 35
0
		///<summary>Only for creating the IN1 segment(s).</summary>
		public static string GenerateFieldIN1(HL7Def def,string fieldName,int sequenceNum,PatPlan patplanCur,InsSub inssubCur,InsPlan insplanCur,Carrier carrierCur,int patplanCount,Patient patSub) {
			switch(fieldName) {
				#region Carrier
				case "carrier.addressCityStateZip":
					if(carrierCur==null) {
						return "";
					}
					return gConcat(def.ComponentSeparator,carrierCur.Address,carrierCur.Address2,carrierCur.City,carrierCur.State,carrierCur.Zip);
				case "carrier.CarrierName":
					if(carrierCur==null) {
						return "";
					}
					return carrierCur.CarrierName;
				case "carrier.ElectID":
					if(carrierCur==null) {
						return "";
					}
					return carrierCur.ElectID;
				case "carrier.Phone":
					//Example: ^WPN^PH^^^800^3635432
					if(carrierCur==null) {
						return "";
					}
					string carrierPh=gXTN(carrierCur.Phone,10);
					if(carrierPh=="") {
						return "";
					}
					return gConcat(def.ComponentSeparator,"","WPN","PH","","",carrierPh.Substring(0,3),carrierPh.Substring(3));//carrierPh guaranteed to be 10 digits or blank
				#endregion Carrier
				#region InsPlan
				case "insplan.cob":
					if(insplanCur==null) {
						return "";
					}
					if(patplanCount>1) {
						return "CO";
					}
					return "IN";
				case "insplan.coverageType":
					if(insplanCur==null) {
						return "";
					}
					if(insplanCur.IsMedical) {
						return "M";
					}
					return "D";
				case "insplan.empName":
					if(insplanCur==null) {
						return "";
					}
					return Employers.GetName(insplanCur.EmployerNum);//will return empty string if EmployerNum=0 or not found
				case "insplan.GroupName":
					if(insplanCur==null) {
						return "";
					}
					return insplanCur.GroupName;
				case "insplan.GroupNum":
					if(insplanCur==null) {
						return "";
					}
					return insplanCur.GroupNum;
				case "insplan.planNum":
					//Example: 2.16.840.1.113883.3.4337.1486.6566.7.1234
					//If OID for insplan is not set, then it will be ODInsPlan.1234 (where 1234=PlanNum)
					if(insplanCur==null) {
						return "";
					}
					OIDInternal insplanOid=OIDInternals.GetForType(IdentifierType.InsPlan);//returns root+".7" or whatever they have set in their oidinternal table for type InsPlan
					string insplanOidRoot="ODInsPlan";
					if(insplanOid!=null && insplanOid.IDRoot!="") {
						insplanOidRoot=insplanOid.IDRoot;
					}
					return insplanOidRoot+"."+insplanCur.PlanNum;//tack on "."+PlanNum for extension
				case "insplan.PlanType":
					if(insplanCur==null) {
						return "";
					}
					if(insplanCur.PlanType=="p") {
						return "PPO Percentage";
					}
					if(insplanCur.PlanType=="f") {
						return "Medicaid or Flat Copay";
					}
					if(insplanCur.PlanType=="c") {
						return "Capitation";
					}
					return "Category Percentage";
				#endregion InsPlan
				#region InsSub
				case "inssub.AssignBen":
					if(inssubCur==null) {
						return "";
					}
					if(inssubCur.AssignBen) {
						return "Y";
					}
					return "N";
				case "inssub.DateEffective":
					if(inssubCur==null || inssubCur.DateEffective==DateTime.MinValue) {
						return "";
					}
					return gDTM(inssubCur.DateEffective,8);
				case "inssub.DateTerm":
					if(inssubCur==null || inssubCur.DateTerm==DateTime.MinValue) {
						return "";
					}
					return gDTM(inssubCur.DateTerm,8);
				case "inssub.ReleaseInfo":
					if(inssubCur==null) {
						return "";
					}
					if(inssubCur.ReleaseInfo) {
						return "Y";
					}
					return "N";
				case "inssub.subAddrCityStateZip":
					if(patSub==null) {
						return "";
					}
					return gConcat(def.ComponentSeparator,patSub.Address,patSub.Address2,patSub.City,patSub.State,patSub.Zip);
				case "inssub.subBirthdate":
					if(patSub==null) {
						return "";
					}
					return gDTM(patSub.Birthdate,8);
				case "inssub.SubscriberID":
					if(inssubCur==null) {
						return "";
					}
					return inssubCur.SubscriberID;
				case "inssub.subscriberName":
					if(patSub==null) {
						return "";
					}
					return gConcat(def.ComponentSeparator,patSub.LName,patSub.FName,patSub.MiddleI);
				#endregion InsSub
				#region PatPlan
				case "patplan.Ordinal":
					if(patplanCur==null) {
						return "";
					}
					return patplanCur.Ordinal.ToString();
				case "patplan.policyNum":
					if(patplanCur==null || inssubCur==null) {
						return "";
					}
					if(patplanCur.PatID!="") {
						return patplanCur.PatID;
					}
					return inssubCur.SubscriberID;
				case "patplan.subRelationToPat":
					//SEL-Self, SPO-Spouse, DOM-LifePartner, CHD-Child (PAR-Parent), EME-Employee (EMR-Employer)
					//DEP-HandicapDep (GRD-Guardian), DEP-Dependent, OTH-SignifOther (OTH-Other), OTH-InjuredPlantiff
					//We store relationship to subscriber and they want subscriber's relationship to patient, therefore
					//Relat.Child will return "PAR" for Parent, Relat.Employee will return "EMR" for Employer, and Relat.HandicapDep and Relat.Dependent will return "GRD" for Guardian
					//Example: |PAR^Parent|
					if(patplanCur==null) {
						return "";
					}
					if(patplanCur.Relationship==Relat.Self) {
						return gConcat(def.ComponentSeparator,"SEL","Self");
					}
					if(patplanCur.Relationship==Relat.Spouse) {
						return gConcat(def.ComponentSeparator,"SPO","Spouse");
					}
					if(patplanCur.Relationship==Relat.LifePartner) {
						return gConcat(def.ComponentSeparator,"DOM","Life Partner");
					}
					if(patplanCur.Relationship==Relat.Child) {
						return gConcat(def.ComponentSeparator,"PAR","Parent");
					}
					if(patplanCur.Relationship==Relat.Employee) {
						return gConcat(def.ComponentSeparator,"EMR","Employer");
					}
					if(patplanCur.Relationship==Relat.Dependent || patplanCur.Relationship==Relat.HandicapDep) {
						return gConcat(def.ComponentSeparator,"GRD","Guardian");
					}
					//if Relat.SignifOther or Relat.InjuredPlaintiff or any others
					return gConcat(def.ComponentSeparator,"OTH","Other");
				#endregion PatPlan
				case "sequenceNum":
					return sequenceNum.ToString();
				default:
					return "";
			}
		}
Ejemplo n.º 36
0
        ///<summary>Sends data for Patient.Cur to an export file and then launches an exe to notify PT.  If patient exists, this simply opens the patient.  If patient does not exist, then this triggers creation of the patient in PT Dental.  If isUpdate is true, then the export file and exe will have different names. In PT, update is a separate programlink with a separate button.</summary>
        public static void SendData(Program ProgramCur, Patient pat, bool isUpdate)
        {
            //ArrayList ForProgram=ProgramProperties.GetForProgram(ProgramCur.ProgramNum);
            //ProgramProperty PPCur=ProgramProperties.GetCur(ForProgram, "InfoFile path");
            //string infoFile=PPCur.PropertyValue;
            if (!Directory.Exists(dir))
            {
                MessageBox.Show(dir + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            if (pat == null)
            {
                MessageBox.Show("No patient is selected.");
                return;
            }
            if (!File.Exists(dir + "\\" + exportAddExe))
            {
                MessageBox.Show(dir + "\\" + exportAddExe + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            if (!File.Exists(dir + "\\" + exportUpdateExe))
            {
                MessageBox.Show(dir + "\\" + exportUpdateExe + " does not exist.  PT Dental doesn't seem to be properly installed on this computer.");
                return;
            }
            string filename = dir + "\\" + exportAddCsv;

            if (isUpdate)
            {
                filename = dir + "\\" + exportUpdateCsv;
            }
            using (StreamWriter sw = new StreamWriter(filename, false)){               //overwrites if it already exists.
                sw.WriteLine("PAT_PK,PAT_LOGFK,PAT_LANFK,PAT_TITLE,PAT_FNAME,PAT_MI,PAT_LNAME,PAT_CALLED,PAT_ADDR1,PAT_ADDR2,PAT_CITY,PAT_ST,PAT_ZIP,PAT_HPHN,PAT_WPHN,PAT_EXT,PAT_FAX,PAT_PAGER,PAT_CELL,PAT_EMAIL,PAT_SEX,PAT_EDOCS,PAT_STATUS,PAT_TYPE,PAT_BIRTH,PAT_SSN,PAT_NOCALL,PAT_NOCORR,PAT_DISRES,PAT_LSTUPD,PAT_INSNM,PAT_INSGPL,PAT_INSAD1,PAT_INSAD2,PAT_INSCIT,PAT_INSST,PAT_INSZIP,PAT_INSPHN,PAT_INSEXT,PAT_INSCON,PAT_INSGNO,PAT_EMPNM,PAT_EMPAD1,PAT_EMPAD2,PAT_EMPCIT,PAT_EMPST,PAT_EMPZIP,PAT_EMPPHN,PAT_REFLNM,PAT_REFFNM,PAT_REFMI,PAT_REFPHN,PAT_REFEML,PAT_REFSPE,PAT_NOTES,PAT_FPSCAN,PAT_PREMED,PAT_MEDS,PAT_FTSTUD,PAT_PTSTUD,PAT_COLLEG,PAT_CHRTNO,PAT_OTHID,PAT_RESPRT,PAT_POLHLD,PAT_CUSCD,PAT_PMPID");
                sw.Write(",");                                                         //PAT_PK  Primary key. Long alphanumeric. We do not use.
                sw.Write(",");                                                         //PAT_LOGFK Internal PT logical, it can be ignored.
                sw.Write(",");                                                         //PAT_LANFK Internal PT logical, it can be ignored.
                sw.Write(",");                                                         //PAT_TITLE We do not have this field yet
                sw.Write(Tidy(pat.FName) + ",");                                       //PAT_FNAME
                sw.Write(Tidy(pat.MiddleI) + ",");                                     //PAT_MI
                sw.Write(Tidy(pat.LName) + ",");                                       //PAT_LNAME
                sw.Write(Tidy(pat.Preferred) + ",");                                   //PAT_CALLED Nickname
                sw.Write(Tidy(pat.Address) + ",");                                     //PAT_ADDR1
                sw.Write(Tidy(pat.Address2) + ",");                                    //PAT_ADDR2
                sw.Write(Tidy(pat.City) + ",");                                        //PAT_CITY
                sw.Write(Tidy(pat.State) + ",");                                       //PAT_ST
                sw.Write(Tidy(pat.Zip) + ",");                                         //PAT_ZIP
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.HmPhone) + ",");       //PAT_HPHN No punct
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.WkPhone) + ",");       //PAT_WPHN
                sw.Write(",");                                                         //PAT_EXT
                sw.Write(",");                                                         //PAT_FAX
                sw.Write(",");                                                         //PAT_PAGER
                sw.Write(TelephoneNumbers.FormatNumbersOnly(pat.WirelessPhone) + ","); //PAT_CELL
                sw.Write(Tidy(pat.Email) + ",");                                       //PAT_EMAIL
                if (pat.Gender == PatientGender.Female)
                {
                    sw.Write("Female");
                }
                else if (pat.Gender == PatientGender.Male)
                {
                    sw.Write("Male");
                }
                sw.Write(",");                            //PAT_SEX might be blank if unknown
                sw.Write(",");                            //PAT_EDOCS Internal PT logical, it can be ignored.
                sw.Write(pat.PatStatus.ToString() + ","); //PAT_STATUS Any text allowed
                sw.Write(pat.Position.ToString() + ",");  //PAT_TYPE Any text allowed
                if (pat.Birthdate.Year > 1880)
                {
                    sw.Write(pat.Birthdate.ToString("MM/dd/yyyy"));                    //PAT_BIRTH MM/dd/yyyy
                }
                sw.Write(",");
                sw.Write(Tidy(pat.SSN) + ",");              //PAT_SSN No punct
                if (pat.PreferContactMethod == ContactMethod.DoNotCall ||
                    pat.PreferConfirmMethod == ContactMethod.DoNotCall ||
                    pat.PreferRecallMethod == ContactMethod.DoNotCall)
                {
                    sw.Write("1");
                }
                sw.Write(",");                //PAT_NOCALL T if no call
                sw.Write(",");                //PAT_NOCORR No correspondence HIPAA
                sw.Write(",");                //PAT_DISRES Internal PT logical, it can be ignored.
                sw.Write(",");                //PAT_LSTUPD Internal PT logical, it can be ignored.
                List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum);
                Family         fam         = Patients.GetFamily(pat.PatNum);
                List <InsSub>  subList     = InsSubs.RefreshForFam(fam);
                List <InsPlan> planList    = InsPlans.RefreshForSubList(subList);
                PatPlan        patplan     = null;
                InsSub         sub         = null;
                InsPlan        plan        = null;
                Carrier        carrier     = null;
                Employer       emp         = null;
                if (patPlanList.Count > 0)
                {
                    patplan = patPlanList[0];
                    sub     = InsSubs.GetSub(patplan.InsSubNum, subList);
                    plan    = InsPlans.GetPlan(sub.PlanNum, planList);
                    carrier = Carriers.GetCarrier(plan.CarrierNum);
                    if (plan.EmployerNum != 0)
                    {
                        emp = Employers.GetEmployer(plan.EmployerNum);
                    }
                }
                if (plan == null)
                {
                    sw.Write(",");                    //PAT_INSNM
                    sw.Write(",");                    //PAT_INSGPL Ins group plan name
                    sw.Write(",");                    //PAT_INSAD1
                    sw.Write(",");                    //PAT_INSAD2
                    sw.Write(",");                    //PAT_INSCIT
                    sw.Write(",");                    //PAT_INSST
                    sw.Write(",");                    //PAT_INSZIP
                    sw.Write(",");                    //PAT_INSPHN
                }
                else
                {
                    sw.Write(Tidy(carrier.CarrierName) + ",");                         //PAT_INSNM
                    sw.Write(Tidy(plan.GroupName) + ",");                              //PAT_INSGPL Ins group plan name
                    sw.Write(Tidy(carrier.Address) + ",");                             //PAT_INSAD1
                    sw.Write(Tidy(carrier.Address2) + ",");                            //PAT_INSAD2
                    sw.Write(Tidy(carrier.City) + ",");                                //PAT_INSCIT
                    sw.Write(Tidy(carrier.State) + ",");                               //PAT_INSST
                    sw.Write(Tidy(carrier.Zip) + ",");                                 //PAT_INSZIP
                    sw.Write(TelephoneNumbers.FormatNumbersOnly(carrier.Phone) + ","); //PAT_INSPHN
                }
                sw.Write(",");                                                         //PAT_INSEXT
                sw.Write(",");                                                         //PAT_INSCON Ins contact person
                if (plan == null)
                {
                    sw.Write(",");
                }
                else
                {
                    sw.Write(Tidy(plan.GroupNum) + ",");                  //PAT_INSGNO Ins group number
                }
                if (emp == null)
                {
                    sw.Write(",");                    //PAT_EMPNM
                }
                else
                {
                    sw.Write(Tidy(emp.EmpName) + ","); //PAT_EMPNM
                }
                sw.Write(",");                         //PAT_EMPAD1
                sw.Write(",");                         //PAT_EMPAD2
                sw.Write(",");                         //PAT_EMPCIT
                sw.Write(",");                         //PAT_EMPST
                sw.Write(",");                         //PAT_EMPZIP
                sw.Write(",");                         //PAT_EMPPHN

                /*we don't support employer info yet.
                 * sw.Write(Tidy(emp.Address)+",");//PAT_EMPAD1
                 * sw.Write(Tidy(emp.Address2)+",");//PAT_EMPAD2
                 * sw.Write(Tidy(emp.City)+",");//PAT_EMPCIT
                 * sw.Write(Tidy(emp.State)+",");//PAT_EMPST
                 * sw.Write(Tidy(emp.State)+",");//PAT_EMPZIP
                 * sw.Write(TelephoneNumbers.FormatNumbersOnly(emp.Phone)+",");//PAT_EMPPHN*/
                Referral referral = Referrals.GetReferralForPat(pat.PatNum);              //could be null
                if (referral == null)
                {
                    sw.Write(",");                    //PAT_REFLNM
                    sw.Write(",");                    //PAT_REFFNM
                    sw.Write(",");                    //PAT_REFMI
                    sw.Write(",");                    //PAT_REFPHN
                    sw.Write(",");                    //PAT_REFEML Referral source email
                    sw.Write(",");                    //PAT_REFSPE Referral specialty. Customizable, so any allowed
                }
                else
                {
                    sw.Write(Tidy(referral.LName) + ",");                //PAT_REFLNM
                    sw.Write(Tidy(referral.FName) + ",");                //PAT_REFFNM
                    sw.Write(Tidy(referral.MName) + ",");                //PAT_REFMI
                    sw.Write(referral.Telephone + ",");                  //PAT_REFPHN
                    sw.Write(Tidy(referral.EMail) + ",");                //PAT_REFEML Referral source email
                    if (referral.PatNum == 0 && !referral.NotPerson)     //not a patient, and is a person
                    {
                        sw.Write(Defs.GetName(DefCat.ProviderSpecialties, referral.Specialty));
                    }
                    sw.Write(",");            //PAT_REFSPE Referral specialty. Customizable, so any allowed
                }
                sw.Write(",");                //PAT_NOTES No limits.  We won't use this right now for exports.
                //sw.Write(",");//PAT_NOTE1-PAT_NOTE10 skipped
                sw.Write(",");                //PAT_FPSCAN Internal PT logical, it can be ignored.
                if (pat.Premed)
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                        //PAT_PREMED F or T
                sw.Write(Tidy(pat.MedUrgNote) + ","); //PAT_MEDS The meds that they must premedicate with.
                if (pat.StudentStatus == "F")         //fulltime
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                //PAT_FTSTUD T/F
                if (pat.StudentStatus == "P") //parttime
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                         //PAT_PTSTUD
                sw.Write(Tidy(pat.SchoolName) + ",");  //PAT_COLLEG Name of college
                sw.Write(Tidy(pat.ChartNumber) + ","); //PAT_CHRTNO
                sw.Write(pat.PatNum.ToString() + ","); //PAT_OTHID The primary key in Open Dental ************IMPORTANT***************
                if (pat.PatNum == pat.Guarantor)
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");                                    //PAT_RESPRT Responsible party checkbox T/F
                if (plan != null && pat.PatNum == sub.Subscriber) //if current patient is the subscriber on their primary plan
                {
                    sw.Write("1");
                }
                else
                {
                    sw.Write("0");
                }
                sw.Write(",");               //PAT_POLHLD Policy holder checkbox T/F
                sw.Write(",");               //PAT_CUSCD Web sync folder, used internally this can be ignored.
                sw.Write("");                //PAT_PMPID Practice Management Program ID. Can be ignored
                sw.WriteLine();
            }
            try{
                if (isUpdate)
                {
                    ODFileUtils.ProcessStart(dir + "\\" + exportUpdateExe);                //already validated to exist
                }
                else
                {
                    ODFileUtils.ProcessStart(dir + "\\" + exportAddExe);                //already validated to exist
                }
                //MessageBox.Show("done");
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }