Esempio n. 1
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);
        }