コード例 #1
0
ファイル: FormRpPaySheet.cs プロジェクト: royedwards/DRDNet
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!checkAllProv.Checked && listProv.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one provider must be selected.");
                return;
            }
            if (PrefC.HasClinicsEnabled && !checkAllClin.Checked && listClin.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one clinic must be selected.");
                return;
            }
            if (!checkPatientTypes.Checked && listPatientTypes.SelectedIndices.Count == 0 &&
                !checkInsuranceTypes.Checked && listInsuranceTypes.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one type must be selected.");
                return;
            }
            if (!checkAllClaimPayGroups.Checked && listClaimPayGroups.SelectedIndices.Count == 0)
            {
                MsgBox.Show(this, "At least one claim payment group must be selected.");
                return;
            }
            ReportComplex report         = new ReportComplex(true, false);
            List <long>   listProvNums   = new List <long>();
            List <long>   listClinicNums = new List <long>();
            List <long>   listInsTypes   = new List <long>();
            List <long>   listPatTypes   = new List <long>();
            List <long>   listSelectedClaimPayGroupNums = new List <long>();

            if (checkAllProv.Checked)
            {
                listProvNums = _listProviders.Select(x => x.ProvNum).ToList();
            }
            else
            {
                listProvNums = listProv.SelectedIndices.OfType <int>().ToList().Select(x => _listProviders[x].ProvNum).ToList();
            }
            if (!PrefC.GetBool(PrefName.EasyNoClinics))
            {
                for (int i = 0; i < listClin.SelectedIndices.Count; i++)
                {
                    if (Security.CurUser.ClinicIsRestricted)
                    {
                        listClinicNums.Add(_listClinics[listClin.SelectedIndices[i]].ClinicNum);                        //we know that the list is a 1:1 to _listClinics
                    }
                    else
                    {
                        if (listClin.SelectedIndices[i] == 0)
                        {
                            listClinicNums.Add(0);
                        }
                        else
                        {
                            listClinicNums.Add(_listClinics[listClin.SelectedIndices[i] - 1].ClinicNum);                          //Minus 1 from the selected index
                        }
                    }
                }
            }
            if (checkInsuranceTypes.Checked)
            {
                listInsTypes = _listInsDefs.Select(x => x.DefNum).ToList();
            }
            else
            {
                listInsTypes = listInsuranceTypes.SelectedIndices.OfType <int>().Select(x => _listInsDefs[x].DefNum).ToList();
            }
            if (checkPatientTypes.Checked)
            {
                listPatTypes = _listPayDefs.Select(x => x.DefNum).ToList();
            }
            else
            {
                listPatTypes = listPatientTypes.SelectedIndices.OfType <int>().Select(x => _listPayDefs[x].DefNum).ToList();
            }
            if (checkAllClaimPayGroups.Checked)
            {
                listSelectedClaimPayGroupNums = _listClaimPayGroupDefs.Select(x => x.DefNum).ToList();
            }
            else
            {
                listSelectedClaimPayGroupNums = listClaimPayGroups.SelectedIndices.OfType <int>().Select(x => _listClaimPayGroupDefs[x].DefNum).ToList();
            }
            DataTable tableIns = new DataTable();

            if (listProvNums.Count != 0)
            {
                tableIns = RpPaySheet.GetInsTable(date1.SelectionStart, date2.SelectionStart, listProvNums, listClinicNums, listInsTypes,
                                                  listSelectedClaimPayGroupNums, checkAllProv.Checked, checkAllClin.Checked, checkInsuranceTypes.Checked, radioPatient.Checked,
                                                  checkAllClaimPayGroups.Checked, checkShowProvSeparate.Checked);
            }
            DataTable tablePat = RpPaySheet.GetPatTable(date1.SelectionStart, date2.SelectionStart, listProvNums, listClinicNums, listPatTypes,
                                                        checkAllProv.Checked, checkAllClin.Checked, checkPatientTypes.Checked, radioPatient.Checked, checkUnearned.Checked, checkShowProvSeparate.Checked);
            string subtitleProvs   = "";
            string subtitleClinics = "";

            if (checkAllProv.Checked)
            {
                subtitleProvs = Lan.g(this, "All Providers");
            }
            else
            {
                subtitleProvs += string.Join(", ", listProv.SelectedIndices.OfType <int>().ToList().Select(x => _listProviders[x].Abbr));
            }
            if (!PrefC.GetBool(PrefName.EasyNoClinics))
            {
                if (checkAllClin.Checked && !Security.CurUser.ClinicIsRestricted)
                {
                    subtitleClinics = Lan.g(this, "All Clinics");
                }
                else
                {
                    for (int i = 0; i < listClin.SelectedIndices.Count; i++)
                    {
                        if (i > 0)
                        {
                            subtitleClinics += ", ";
                        }
                        if (Security.CurUser.ClinicIsRestricted)
                        {
                            subtitleClinics += _listClinics[listClin.SelectedIndices[i]].Abbr;
                        }
                        else
                        {
                            if (listClin.SelectedIndices[i] == 0)
                            {
                                subtitleClinics += Lan.g(this, "Unassigned");
                            }
                            else
                            {
                                subtitleClinics += _listClinics[listClin.SelectedIndices[i] - 1].Abbr;                            //Minus 1 from the selected index
                            }
                        }
                    }
                }
            }
            Font font         = new Font("Tahoma", 9);
            Font fontBold     = new Font("Tahoma", 9, FontStyle.Bold);
            Font fontTitle    = new Font("Tahoma", 17, FontStyle.Bold);
            Font fontSubTitle = new Font("Tahoma", 10, FontStyle.Bold);

            report.ReportName = Lan.g(this, "Daily Payments");
            report.AddTitle("Title", Lan.g(this, "Daily Payments"), fontTitle);
            report.AddSubTitle("PracTitle", PrefC.GetString(PrefName.PracticeTitle), fontSubTitle);
            report.AddSubTitle("Providers", subtitleProvs, fontSubTitle);
            if (!PrefC.GetBool(PrefName.EasyNoClinics))
            {
                report.AddSubTitle("Clinics", subtitleClinics, fontSubTitle);
            }
            Dictionary <long, string> dictInsDefNames = new Dictionary <long, string>();
            Dictionary <long, string> dictPatDefNames = new Dictionary <long, string>();
            List <Def> insDefs = Defs.GetDefsForCategory(DefCat.InsurancePaymentType, true);
            List <Def> patDefs = Defs.GetDefsForCategory(DefCat.PaymentTypes, true);

            for (int i = 0; i < insDefs.Count; i++)
            {
                dictInsDefNames.Add(insDefs[i].DefNum, insDefs[i].ItemName);
            }
            for (int i = 0; i < patDefs.Count; i++)
            {
                dictPatDefNames.Add(patDefs[i].DefNum, patDefs[i].ItemName);
            }
            dictPatDefNames.Add(0, "Income Transfer");           //Otherwise income transfers show up with a payment type of "Undefined"
            int[] summaryGroups1 = { 1 };
            int[] summaryGroups2 = { 2 };
            int[] summaryGroups3 = { 1, 2 };
            //Insurance Payments Query-------------------------------------
            QueryObject query = report.AddQuery(tableIns, "Insurance Payments", "PayType", SplitByKind.Definition, 1, true, dictInsDefNames, fontSubTitle);

            query.AddColumn("Date", 90, FieldValueType.Date, font);
            //query.GetColumnDetail("Date").SuppressIfDuplicate = true;
            query.GetColumnDetail("Date").StringFormat = "d";
            query.AddColumn("Carrier", 150, FieldValueType.String, font);
            query.AddColumn("Patient Name", 150, FieldValueType.String, font);
            query.AddColumn("Provider", 90, FieldValueType.String, font);
            if (!PrefC.GetBool(PrefName.EasyNoClinics))
            {
                query.AddColumn("Clinic", 120, FieldValueType.String, font);
            }
            query.AddColumn("Check#", 75, FieldValueType.String, font);
            query.AddColumn("Amount", 90, FieldValueType.Number, font);
            query.AddGroupSummaryField("Total Insurance Payments:", "Amount", "amt", SummaryOperation.Sum, new List <int>(summaryGroups1), Color.Black, fontBold, 0, 10);
            //Patient Payments Query---------------------------------------
            query = report.AddQuery(tablePat, "Patient Payments", "PayType", SplitByKind.Definition, 2, true, dictPatDefNames, fontSubTitle);
            query.AddColumn("Date", 90, FieldValueType.Date, font);
            //query.GetColumnDetail("Date").SuppressIfDuplicate = true;
            query.GetColumnDetail("Date").StringFormat = "d";
            query.AddColumn("Paying Patient", 270, FieldValueType.String, font);
            query.AddColumn("Provider", 90, FieldValueType.String, font);
            if (!PrefC.GetBool(PrefName.EasyNoClinics))
            {
                query.AddColumn("Clinic", 120, FieldValueType.String, font);
            }
            query.AddColumn("Check#", 75, FieldValueType.String, font);
            query.AddColumn("Amount", 120, FieldValueType.Number, font);
            query.AddGroupSummaryField("Total Patient Payments:", "Amount", "amt", SummaryOperation.Sum, new List <int>(summaryGroups2), Color.Black, fontBold, 0, 10);
            query.AddGroupSummaryField("Total All Payments:", "Amount", "amt", SummaryOperation.Sum, new List <int>(summaryGroups3), Color.Black, fontBold, 0, 10);
            report.AddPageNum(font);
            report.AddGridLines();
            if (!report.SubmitQueries())
            {
                return;
            }
            FormReportComplex FormR = new FormReportComplex(report);

            FormR.ShowDialog();
            DialogResult = DialogResult.OK;
        }