Exemplo n.º 1
0
        ///<summary>Returns number of subscribers affected.  Can throw an exception if user clicks cancel in a note box.</summary>
        private static int ProcessTrojanPlan(string trojanPlan, bool updateBenefits, bool updateNoteAutomatic)
        {
            TrojanObject troj    = ProcessTextToObject(trojanPlan);
            Carrier      carrier = new Carrier();

            carrier.Phone       = troj.ELIGPHONE;
            carrier.ElectID     = troj.PAYERID;
            carrier.CarrierName = troj.MAILTO;
            carrier.Address     = troj.MAILTOST;
            carrier.City        = troj.MAILCITYONLY;
            carrier.State       = troj.MAILSTATEONLY;
            carrier.Zip         = troj.MAILZIPONLY;
            carrier.NoSendElect = false;          //regardless of what Trojan says.  Nobody sends paper anymore.
            if (carrier.CarrierName == null || carrier.CarrierName == "")
            {
                //if, for some reason, carrier is absent from the file, we can't do a thing with it.
                return(0);
            }
            carrier = Carriers.GetIndentical(carrier);
            //now, save this all to the database.
            troj.CarrierNum = carrier.CarrierNum;
            InsPlan plan = TrojanQueries.GetPlanWithTrojanID(troj.TROJANID);

            if (plan == null)
            {
                return(0);
            }
            TrojanQueries.UpdatePlan(troj, plan.PlanNum, updateBenefits);
            plan = InsPlans.RefreshOne(plan.PlanNum);
            if (updateNoteAutomatic)
            {
                if (plan.PlanNote != troj.PlanNote)
                {
                    plan.PlanNote = troj.PlanNote;
                    InsPlans.Update(plan);
                }
            }
            else
            {
                //let user pick note
                if (plan.PlanNote != troj.PlanNote)
                {
                    string[] notes = new string[2];
                    notes[0] = plan.PlanNote;
                    notes[1] = troj.PlanNote;
                    FormNotePick FormN = new FormNotePick(notes);
                    FormN.ShowDialog();
                    if (FormN.DialogResult == DialogResult.OK)
                    {
                        if (plan.PlanNote != FormN.SelectedNote)
                        {
                            plan.PlanNote = FormN.SelectedNote;
                            InsPlans.Update(plan);
                        }
                    }
                }
            }
            return(1);
        }
Exemplo n.º 2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!textAmount.IsValid)
            {
                MsgBox.Show(this, "Please fix debt amount.");
                return;
            }
            double amtDebt = PIn.Double(textAmount.Text);

            if (!textDate.IsValid)
            {
                MsgBox.Show(this, "Date is not valid.");
                return;
            }
            DateTime dateDelinquency = PIn.Date(textDate.Text);

            if (dateDelinquency.Year < 1950)
            {
                MessageBox.Show("Date is not valid.");
                return;
            }
            if (dateDelinquency > DateTime.Today)
            {
                MsgBox.Show(this, "Date cannot be a future date.");
                return;
            }
            long   programNum = Programs.GetProgramNum(ProgramName.TrojanExpressCollect);
            string password   = ProgramProperties.GetPropVal(programNum, "Password");

            if (!Regex.IsMatch(password, @"^[A-Z]{2}\d{4}$"))
            {
                MsgBox.Show(this, "Password is not in correct format. Must be like this: AB1234");
                return;
            }
            string folderPath = ProgramProperties.GetPropVal(programNum, "FolderPath");

            if (string.IsNullOrEmpty(folderPath))
            {
                MsgBox.Show(this, "Export folder has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            long billingType = PIn.Long(ProgramProperties.GetPropVal(programNum, "BillingType"));

            if (billingType == 0)
            {
                MsgBox.Show(this, "Billing type has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            if (!File.Exists(ODFileUtils.CombinePaths(folderPath, "TROBEN.HB")))
            {
                Cursor = Cursors.Default;
                MessageBox.Show(Lan.g(this, "The Trojan Communicator is not installed or is not configured for the folder") + ": "
                                + folderPath + ".  " + Lan.g(this, "Please contact Trojan Software Support at 800-451-9723 x1 or x2"));
                return;
            }
            try {
                File.Delete(ODFileUtils.CombinePaths(folderPath, "TROBEN.HB"));
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "There was an error attempting to delete a file from the export folder path.  Check folder permissions and/or try running as administrator.");
                return;
            }
            using (FileSystemWatcher watcher = new FileSystemWatcher(folderPath, "TROBEN.HB")) {
                if (watcher.WaitForChanged(WatcherChangeTypes.Created, 10000).TimedOut)
                {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "The Trojan Communicator is not running. Please check it.");
                    return;
                }
            }
            StringBuilder str = new StringBuilder();

            if (radioDiplomatic.Checked)
            {
                str.Append("D*");
            }
            else if (radioFirm.Checked)
            {
                str.Append("F*");
            }
            else if (radioSkip.Checked)
            {
                str.Append("S*");
            }
            str.Append(Clip(_patCur.LName, 18) + "*");
            str.Append(Clip(_patCur.FName, 18) + "*");
            str.Append(Clip(_patCur.MiddleI, 1) + "*");
            str.Append(Clip(_guarCur.LName, 18) + "*");                                                                               //validated
            str.Append(Clip(_guarCur.FName, 18) + "*");                                                                               //validated
            str.Append(Clip(_guarCur.MiddleI, 1) + "*");
            str.Append(_guarCur.SSN.Substring(0, 3) + "-" + _guarCur.SSN.Substring(3, 2) + "-" + _guarCur.SSN.Substring(5, 4) + "*"); //validated
            if (_guarCur.Birthdate.Year >= 1880)
            {
                str.Append(_guarCur.Birthdate.ToShortDateString());
            }
            str.Append("*");
            str.Append(Clip(_guarCur.HmPhone, 13) + "*");
            str.Append(Clip(_empCur?.EmpName, 35) + "*");
            str.Append(Clip(_empCur?.Phone, 13) + "*");
            string address = _guarCur.Address;          //validated

            if (!string.IsNullOrEmpty(_guarCur.Address2))
            {
                address += ", " + _guarCur.Address2;
            }
            str.Append(Clip(address, 30) + "*");
            str.Append(Clip(_guarCur.City, 20) + "*");             //validated
            str.Append(Clip(_guarCur.State, 2) + "*");             //validated
            str.Append(Clip(_guarCur.Zip, 5) + "*");               //validated
            str.Append(amtDebt.ToString("F2") + "*");              //validated
            str.Append(dateDelinquency.ToShortDateString() + "*"); //validated
            str.Append(password + "*");                            //validated
            str.AppendLine(Clip(Security.CurUser.UserName, 25));   //There is always a logged in user
            int    thisNum    = TrojanQueries.GetUniqueFileNum();
            string outputFile = "CT" + thisNum.ToString().PadLeft(6, '0') + ".TRO";

            try {
                File.AppendAllText(ODFileUtils.CombinePaths(folderPath, outputFile), str.ToString());
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "There was an error writing to the export file.  Check folder permissions and/or try running as administrator.");
                return;
            }
            using (FileSystemWatcher watcher = new FileSystemWatcher(folderPath, outputFile)) {
                if (watcher.WaitForChanged(WatcherChangeTypes.Deleted, 10000).TimedOut)
                {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "Warning!! Request was not sent to Trojan within the 10 second limit.");
                    return;
                }
            }
            Patients.UpdateFamilyBillingType(billingType, _patCur.Guarantor);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void FormTrojanCollect_Load(object sender, EventArgs e)
        {
            if (_patCur == null)
            {
                MsgBox.Show(this, "Please select a patient first.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            _guarCur = Patients.GetPat(_patCur.Guarantor);
            if (_guarCur.EmployerNum > 0)
            {
                _empCur = Employers.GetEmployer(_guarCur.EmployerNum);
            }
            if (_guarCur.LName.Length == 0)
            {
                MsgBox.Show(this, "Missing guarantor last name.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (_guarCur.FName.Length == 0)
            {
                MsgBox.Show(this, "Missing guarantor first name.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (!Regex.IsMatch(_guarCur.SSN, @"^\d{9}$"))
            {
                MsgBox.Show(this, "Guarantor SSN must be exactly 9 digits.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (_guarCur.Address.Length == 0)
            {
                MsgBox.Show(this, "Missing guarantor address.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (_guarCur.City.Length == 0)
            {
                MsgBox.Show(this, "Missing guarantor city.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (_guarCur.State.Length != 2)
            {
                MsgBox.Show(this, "Guarantor state must be 2 characters.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (_guarCur.Zip.Length < 5)
            {
                MsgBox.Show(this, "Invalid guarantor zip.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            labelGuarantor.Text = _guarCur.GetNameFL();
            labelAddress.Text   = _guarCur.Address;
            if (!string.IsNullOrEmpty(_guarCur.Address2))
            {
                labelAddress.Text += ", " + _guarCur.Address2;
            }
            labelCityStZip.Text = _guarCur.City + ", " + _guarCur.State + " " + _guarCur.Zip;
            labelSSN.Text       = _guarCur.SSN.Substring(0, 3) + "-" + _guarCur.SSN.Substring(3, 2) + "-" + _guarCur.SSN.Substring(5, 4);
            labelDOB.Text       = _guarCur.Birthdate.Year < 1880?"":_guarCur.Birthdate.ToShortDateString();
            labelPhone.Text     = Clip(_guarCur.HmPhone, 13);
            labelEmployer.Text  = _empCur?.EmpName ?? "";
            labelEmpPhone.Text  = _empCur?.Phone ?? "";
            labelPatient.Text   = _patCur.GetNameFL();
            DateTime lastProcDate = TrojanQueries.GetMaxProcedureDate(_guarCur.PatNum);
            DateTime lastPayDate  = TrojanQueries.GetMaxPaymentDate(_guarCur.PatNum);

            textDate.Text   = (lastPayDate > lastProcDate?lastPayDate:lastProcDate).ToShortDateString();
            textAmount.Text = _guarCur.BalTotal.ToString("F2");
        }
Exemplo n.º 4
0
        ///<summary>Process the deletion of existing insurance plans.</summary>
        private static void ProcessDeletedPlans(string file)
        {
            if (!File.Exists(file))
            {
                //Nothing to process.
                return;
            }
            string deleteplantext = File.ReadAllText(file);

            if (deleteplantext == "")
            {
                //Nothing to process. Don't delete the file in-case Trojan is filling the file right now.
                return;
            }
            deletePatientRecords = new Collection <string[]>();
            deleteTrojanRecords  = new Collection <string[]>();
            string[] trojanplans          = deleteplantext.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            Collection <string[]> records = new Collection <string[]>();

            for (int i = 0; i < trojanplans.Length; i++)
            {
                string[] record = trojanplans[i].Split(new string[] { "\t" }, StringSplitOptions.None);
                for (int j = 0; j < record.Length; j++)
                {
                    //Remove any white space around the field and remove the surrounding quotes.
                    record[j] = record[j].Trim().Substring(1);
                    record[j] = record[j].Substring(0, record[j].Length - 1);
                }
                records.Add(record);
                string whoToContact = record[3].ToUpper();
                if (whoToContact == "T")
                {
                    deleteTrojanRecords.Add(record);
                }
                else                 //whoToContact="P"
                {
                    deletePatientRecords.Add(record);
                }
            }
            if (deletePatientRecords.Count > 0)
            {
                pendingDeletionTable = TrojanQueries.GetPendingDeletionTable(deletePatientRecords);
                if (pendingDeletionTable.Rows.Count > 0)
                {
                    FormPrintReport fpr = new FormPrintReport();
                    fpr.Text           = "Trojan Plans Pending Deletion: Contact Patients";
                    fpr.ScrollAmount   = 10;
                    fpr.printGenerator = ShowPendingDeletionReportForPatients;
                    fpr.UsePageNumbers(new Font(FontFamily.GenericMonospace, 8));
                    fpr.MinimumTimesToPrint = 1;
                    fpr.ShowDialog();
                }
            }
            if (deleteTrojanRecords.Count > 0)
            {
                pendingDeletionTableTrojan = TrojanQueries.GetPendingDeletionTableTrojan(deleteTrojanRecords);
                if (pendingDeletionTableTrojan.Rows.Count > 0)
                {
                    FormPrintReport fpr = new FormPrintReport();
                    fpr.Text           = "Trojan Plans Pending Deletion: Contact Trojan";
                    fpr.ScrollAmount   = 10;
                    fpr.printGenerator = ShowPendingDeletionReportForTrojan;
                    fpr.UsePageNumbers(new Font(FontFamily.GenericMonospace, 8));
                    fpr.MinimumTimesToPrint = 1;
                    fpr.Landscape           = true;
                    fpr.ShowDialog();
                }
            }
            //Now that the plans have been reported, drop the plans that are marked finally deleted.
            for (int i = 0; i < records.Count; i++)
            {
                if (records[i][1] == "F")
                {
                    try {
                        InsPlan[] insplans = InsPlans.GetByTrojanID(records[i][0]);
                        for (int j = 0; j < insplans.Length; j++)
                        {
                            InsPlan planOld = insplans[j].Copy();
                            insplans[j].PlanNote = "PLAN DROPPED BY TROJAN" + Environment.NewLine + insplans[j].PlanNote;
                            insplans[j].TrojanID = "";
                            InsPlans.Update(insplans[j], planOld);
                            PatPlan[] patplans = PatPlans.GetByPlanNum(insplans[j].PlanNum);
                            for (int k = 0; k < patplans.Length; k++)
                            {
                                PatPlans.Delete(patplans[k].PatPlanNum);
                            }
                        }
                    }
                    catch (ApplicationException ex) {
                        MessageBox.Show(ex.Message);
                        return;
                    }
                }
            }
            File.Delete(file);
        }
Exemplo n.º 5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            double amtDebt = PIn.Double(textAmount.Text);

            if (amtDebt == 0)
            {
                MessageBox.Show("Please fill in an amount.");
                return;
            }
            if (amtDebt < 25)
            {
                MessageBox.Show("Amount of debt must be at least $25.00.");
                return;
            }
            if (amtDebt > 9999999.00)           //limit 10 char
            {
                MessageBox.Show("Amount of debt is unreasonably large.");
                return;
            }
            DateTime dateDelinquency = PIn.Date(textDate.Text);

            if (dateDelinquency.Year < 1950)
            {
                MessageBox.Show("Date is not valid.");
                return;
            }
            if (dateDelinquency > DateTime.Today)
            {
                MessageBox.Show("Date cannot be a future date.");
                return;
            }
            if (!Regex.IsMatch(textPassword.Text, @"^[A-Z]{2}\d{4}$"))
            {
                MessageBox.Show("Password is not in correct format. Must be like this: AB1234");
                return;
            }
            if (textPassword.Text != PrefC.GetString(PrefName.TrojanExpressCollectPassword))          //user changed password
            {
                Prefs.UpdateString(PrefName.TrojanExpressCollectPassword, textPassword.Text);
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            Cursor = Cursors.WaitCursor;
            string folderPath = PrefC.GetString(PrefName.TrojanExpressCollectPath);

            if (folderPath == "")
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Export folder has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            if (!folderPath.EndsWith("\\"))
            {
                folderPath += "\\";
            }
            if (!File.Exists(folderPath + "TROBEN.HB"))
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The Trojan Communicator is not installed or is not configured for the folder: "
                                + folderPath + ".  Please contact Trojan Software Support at 800-451-9723 x1 or x2");
                return;
            }
            File.Delete(folderPath + "TROBEN.HB");
            FileSystemWatcher    watcher    = new FileSystemWatcher(folderPath, "TROBEN.HB");
            WaitForChangedResult waitResult = watcher.WaitForChanged(WatcherChangeTypes.Created, 10000);

            if (waitResult.TimedOut)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The Trojan Communicator is not running. Please check it.");
                return;
            }
            long billingType = PrefC.GetLong(PrefName.TrojanExpressCollectBillingType);

            if (billingType == 0)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Billing type has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            StringBuilder str = new StringBuilder();

            if (radioDiplomatic.Checked)
            {
                str.Append("D*");
            }
            else if (radioFirm.Checked)
            {
                str.Append("F*");
            }
            else if (radioSkip.Checked)
            {
                str.Append("S*");
            }
            str.Append(Clip(patCur.LName, 18) + "*");
            str.Append(Clip(patCur.FName, 18) + "*");
            str.Append(Clip(patCur.MiddleI, 1) + "*");
            str.Append(Clip(guarCur.LName, 18) + "*");                                                                             //validated
            str.Append(Clip(guarCur.FName, 18) + "*");                                                                             //validated
            str.Append(Clip(guarCur.MiddleI, 1) + "*");
            str.Append(guarCur.SSN.Substring(0, 3) + "-" + guarCur.SSN.Substring(3, 2) + "-" + guarCur.SSN.Substring(5, 4) + "*"); //validated
            if (guarCur.Birthdate.Year < 1880)
            {
                str.Append("*");
            }
            else
            {
                str.Append(guarCur.Birthdate.ToString("MM/dd/yyyy") + "*");
            }
            str.Append(Clip(guarCur.HmPhone, 13) + "*");
            if (empCur == null)
            {
                str.Append("**");
            }
            else
            {
                str.Append(Clip(empCur.EmpName, 35) + "*");
                str.Append(Clip(empCur.Phone, 13) + "*");
            }
            string address = guarCur.Address;          //validated

            if (guarCur.Address2 != "")
            {
                address += ", " + guarCur.Address2;
            }
            str.Append(Clip(address, 30) + "*");
            str.Append(Clip(guarCur.City, 20) + "*");                 //validated
            str.Append(Clip(guarCur.State, 2) + "*");                 //validated
            str.Append(Clip(guarCur.Zip, 5) + "*");                   //validated
            str.Append(amtDebt.ToString("F2") + "*");                 //validated
            str.Append(dateDelinquency.ToString("MM/dd/yyyy") + "*"); //validated
            str.Append(textPassword.Text + "*");                      //validated
            str.Append(Clip(Security.CurUser.UserName, 25) + "\r\n"); //There is always a logged in user
            int    thisNum    = TrojanQueries.GetUniqueFileNum();
            string outputFile = "CT" + thisNum.ToString().PadLeft(6, '0') + ".TRO";

            File.AppendAllText(folderPath + outputFile, str.ToString());
            watcher    = new FileSystemWatcher(folderPath, outputFile);
            waitResult = watcher.WaitForChanged(WatcherChangeTypes.Deleted, 10000);
            if (waitResult.TimedOut)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Warning!! Request was not sent to Trojan within the 10 second limit.");
                return;
            }
            Patients.UpdateFamilyBillingType(billingType, patCur.Guarantor);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 6
0
        private void FormTrojanCollect_Load(object sender, EventArgs e)
        {
            patCur  = Patients.GetPat(PatNum);
            guarCur = Patients.GetPat(patCur.Guarantor);
            if (guarCur.EmployerNum == 0)
            {
                empCur = null;
            }
            else
            {
                empCur = Employers.GetEmployer(guarCur.EmployerNum);
            }
            if (guarCur.LName.Length == 0)
            {
                MessageBox.Show("Missing guarantor last name.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (guarCur.FName.Length == 0)
            {
                MessageBox.Show("Missing guarantor first name.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (!Regex.IsMatch(guarCur.SSN, @"^\d{9}$"))
            {
                MessageBox.Show("Guarantor SSN must be exactly 9 digits.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (guarCur.Address.Length == 0)
            {
                MessageBox.Show("Missing guarantor address.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (guarCur.City.Length == 0)
            {
                MessageBox.Show("Missing guarantor city.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (guarCur.State.Length != 2)
            {
                MessageBox.Show("Guarantor state must be 2 characters.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (guarCur.Zip.Length < 5)
            {
                MessageBox.Show("Invalid guarantor zip.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            labelGuarantor.Text = guarCur.GetNameFL();
            labelAddress.Text   = guarCur.Address;
            if (guarCur.Address2 != "")
            {
                labelAddress.Text += ", " + guarCur.Address2;
            }
            labelCityStZip.Text = guarCur.City + ", " + guarCur.State + " " + guarCur.Zip;
            labelSSN.Text       = guarCur.SSN.Substring(0, 3) + "-" + guarCur.SSN.Substring(3, 2) + "-" + guarCur.SSN.Substring(5, 4);
            if (guarCur.Birthdate.Year < 1880)
            {
                labelDOB.Text = "";
            }
            else
            {
                labelDOB.Text = guarCur.Birthdate.ToString("MM/dd/yyyy");
            }
            labelPhone.Text = Clip(guarCur.HmPhone, 13);
            if (empCur == null)
            {
                labelEmployer.Text = "";
                labelEmpPhone.Text = "";
            }
            else
            {
                labelEmployer.Text = empCur.EmpName;
                labelEmpPhone.Text = empCur.Phone;
            }
            labelPatient.Text = patCur.GetNameFL();
            DataTable table = TrojanQueries.GetMaxProcedureDate(guarCur.PatNum);
            DateTime  lastProcDate;

            if (table.Rows.Count == 0)
            {
                lastProcDate = DateTime.MinValue;              //this should never happen
            }
            else
            {
                lastProcDate = PIn.Date(table.Rows[0][0].ToString());
            }
            table = TrojanQueries.GetMaxPaymentDate(guarCur.PatNum);
            DateTime lastPayDate;

            if (table.Rows.Count == 0)
            {
                lastPayDate = DateTime.MinValue;
            }
            else
            {
                lastPayDate = PIn.Date(table.Rows[0][0].ToString());
            }
            if (lastPayDate > lastProcDate)
            {
                textDate.Text = lastPayDate.ToString("MM/dd/yyyy");
            }
            else
            {
                textDate.Text = lastProcDate.ToString("MM/dd/yyyy");
            }
            textAmount.Text   = guarCur.BalTotal.ToString("F2");
            textPassword.Text = PrefC.GetString(PrefName.TrojanExpressCollectPassword);
        }