public static void CheckPersonal(IBackgroundContext context, DateParams checkPersonalParams)
        {
            if (context.CancellationPending) return;

            var onDate = checkPersonalParams.DateEnd.Date;

            context.ProgressSeparator();
            context.ReportProgress(@"ПРОВЕРКА СПРАВОЧНИКА СОТРУДНИКОВ ВистаМед на {0}", onDate.ToShortDateString());
            context.ReportProgress("");
            using (var dataContext = new PersonalCheckDataContext(context))
            {
                var dir = Properties.Settings.Default.DataDir;
                dataContext.Load(context, dir);

                var vistaPersonal =
                    (from p in dataContext.VistaMed.People
                     where p.RetireDate == null && p.RbSpeciality != null
                         && p.FederalCode != "000-000-000" select p).ToList();

                var notFoundPers =
                    (from p in vistaPersonal where !dataContext.DoctorList.Any(x => x.SNILS == p.FederalCode) select p);

                notFoundPers.ToList().ForEach(x => context.ReportError(@"сотрудник {0} не найден в списке ФРМР", x.ToLongString()));

                var nonCertPers = (from p in vistaPersonal
                                   from d in dataContext.DoctorList
                                   where  d.SNILS == p.FederalCode && !d.SpecCodes.Contains(p.RbSpeciality.FederalCode)
                                   select new {p, d});

                nonCertPers.ToList().ForEach(x => context.ReportError(@"сотрудник {0} не сертиф.по спец.""{1}"" (но имеет по ФРМР серт. {2})",
                    x.p.ToLongString(), x.p.RbSpeciality.FederalCode + " " + x.p.RbSpeciality.Name, x.d.CertNames));

                var expiredCert = (from p in vistaPersonal
                                   from d in dataContext.DoctorList
                                   from c in d.LastCertificates()
                                   where d.SNILS == p.FederalCode && p.RbSpeciality.FederalCode == c.SPEC_CODE
                                   && (onDate < c.CERT_DATE || onDate > c.CERT_DATE.AddYears(5))
                                   select new { p, c });

                expiredCert.ToList().ForEach(x => context.ReportError(@"сотрудник {0} имеет просроченный сертификат ""{1}""",
                    x.p.ToLongString(), x.c.ToString()));
            }
            context.ProgressSeparator('-');
        }
Example #2
0
        private LinearLayout BuildGrid(string tag_prefix, int weight_sum = 0, int button_weight = 1)
        {
            DateParams par = new DateParams(tag_prefix, this.base_year);

            LinearLayout ll  = this.root;
            LinearLayout llc = null;

            if (par.rows > 1)
            {
                ll             = new LinearLayout(this.view.Context);
                ll.Orientation = Orientation.Vertical;
                ll.SetPadding(0, 10, 0, 0);
                this.root.AddView(ll);
            }
            int amount = par.amount;

            for (int r = 0; r < par.rows; r++)
            {
                llc = new LinearLayout(this.view.Context);
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
                llc.Orientation = Orientation.Horizontal;
                //llc.SetPadding(0, 0, 0, 0);
                llc.WeightSum = weight_sum == 0 ? par.columns * 2 : weight_sum;
                ll.AddView(llc);
                for (int c = 0; c < par.columns; c++)
                {
                    Button b = new Button(this.view.Context);
                    b.Text   = "" + (r * par.columns + c + par.val_base);
                    b.Tag    = par.tag_prefix + (r * par.columns + c + par.val_base);
                    b.Click += OnClicked;
                    llc.AddView(b);
                    amount -= 1;
                    if (amount <= 0)
                    {
                        break;
                    }
                }
            }
            return(llc);
        }
Example #3
0
        private void UpdateGrid(string tag_prefix, int val, bool user_input)
        {
            LinearLayout.LayoutParams lp;
            DateParams par = new DateParams(tag_prefix, this.base_year);

            for (int i = 0; i < par.amount; i++)
            {
                Button b = (Button)this.view.FindViewWithTag(par.tag_prefix + (i + par.val_base));
                if (par.val_base + i == val)
                {
                    b.SetBackgroundColor(Android.Graphics.Color.LightGoldenrodYellow);
                }
                else
                {
                    b.SetBackgroundColor(Android.Graphics.Color.LightGray);// new Android.Graphics.Color(Resource.Color.Text_Warning));
                }
                b.SetTextColor(Android.Graphics.Color.Black);
                b.SetTextSize(ComplexUnitType.Sp, 18);
                lp        = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
                lp.Weight = 2;
                lp.Width  = 0;
                lp.SetMargins(1, 1, 1, 1);
                b.SetPadding(0, 0, 0, 0);
                b.Visibility       = (tag_prefix != "D" || i < max_days) ? ViewStates.Visible : ViewStates.Invisible;
                b.LayoutParameters = lp;
            }

            int day   = this.Date.Value.Day;
            int month = this.Date.Value.Month;
            int year  = this.Date.Value.Year;

            if (par.tag_prefix == "Y")
            {
                year = val;
            }
            else if (par.tag_prefix == "M")
            {
                month = val;
            }
            else
            {
                if (user_input)
                {
                    DayWasPicked = true;
                }
                day = val;
            }

            if (par.tag_prefix != "D")
            {
                this.max_days = 30;
                int[] ldays = { 1, 3, 5, 7, 8, 10, 12 };
                if (ldays.Contains(month))
                {
                    this.max_days = 31;
                }
                if (month == 2)
                {
                    // Schaltjahrberechnung funktioniert so bis 2399
                    if ((year % 4 == 0) && (year % 100 != 0))
                    {
                        this.max_days = 29;
                    }
                    else
                    {
                        this.max_days = 28;
                    }
                }
                if (!DayWasPicked)
                {
                    day = this.max_days;
                }
            }
            if (day > this.max_days)
            {
                day = this.max_days;
            }
            this.Date = new DateTime(year, month, day);

            if (par.tag_prefix != "D")
            {
                UpdateGrid("D", day, false);
            }

            ShowDate();
        }
        public static void BuildSmpExcelReport(IBackgroundContext context, DateParams args)
        {
            var onDate = args.DateEnd;
            var miacCode = args.LpuCode;
            using (var dataConext = new VistaMedDataContext(context))
            {
                var smpBills = (from b in dataConext.VistaMed.Accounts
                                where b.SettleDate == onDate && b.Contract != null && b.Contract.RbFinance != null &&
                                      b.Contract.RbFinance.Name.ToLower() == "бюджет"
                                      && (from a in b.AccountItems
                                          from s in dataConext.VistaMed.RbServices
                                          where a.ServiceId == s.Id && s.Code.StartsWith("00184")
                                          select a).Any()
                                select b).ToList();

                if (smpBills.Count == 0)
                    context.ReportError(@"Счета СМП за {0} не найдены", onDate);
                else
                {
                    var excel = new Application();
                    excel.Visible = true;
                    var templateName = Utils.GetReportFileName(@"ReestrSmp.xls");
                    if (File.Exists(templateName))
                    {
                        foreach (var smpBill in smpBills)
                        {
                            var newDoc = excel.Workbooks.Add(templateName);
                            newDoc.Names.Item("ОтчМесяц").RefersToRange.Value2 = onDate.ToString("MMMM yyyy") + " г.";
                            var lpu = dataConext.VistaMed.Organisations.FirstOrDefault(x => x.MiacCode == miacCode);
                            if (lpu != null)
                            {
                                newDoc.Names.Item("Лпу").RefersToRange.Value2 = lpu.ShortName;
                                newDoc.Names.Item("АдресЛпу").RefersToRange.Value2 = lpu.Address;
                                newDoc.Names.Item("Руководитель").RefersToRange.Value2 = lpu.Chief;
                                newDoc.Names.Item("Главбух").RefersToRange.Value2 = lpu.Accountant;
                                newDoc.Names.Item("ДатаДок").RefersToRange.Value2 = DateTime.Today.ToShortDateString();
                                newDoc.Names.Item("ИннЛпу").RefersToRange.Value2 = lpu.INN;
                                newDoc.Names.Item("КппЛпу").RefersToRange.Value2 = lpu.KPP;
                                newDoc.Names.Item("ТелЛпу").RefersToRange.Value2 = lpu.Phone;
                            }

                            #region реестр

                            var ws = (Worksheet)newDoc.Worksheets["реестр"];

                            int rowIndex = 8;
                            int rowNpp = 1;
                            var smpResultTypeNames = new[] {"(заболевания, не включенные в территориальную программу ОМС)",
                                    "(незастрахованный в системе ОМС)", "(безрезультатный)"};
                            var smpTarinfName = new[] { "НомсТариф", "НезТариф", "БезТариф" };
                            var smpVyzName = new[] { "НомсКолВыз", "НезКолВыз", "БезКолВыз" };
                            var smpKolVyz = new[] { 0, 0, 0 };

                            foreach (var accItem in smpBill.AccountItems.OrderBy(x => x.Event.Client.LastName + " "
                                + x.Event.Client.FirstName + " " + x.Event.Client.PatrName))
                            {
                                if (rowIndex > 8)
                                {
                                    ((Range)ws.Rows[rowIndex]).Insert(XlInsertShiftDirection.xlShiftDown);
                                }
                                var client = accItem.Event.Client;
                                if (client != null)
                                {
                                    ((Range)ws.Rows[rowIndex].Cells[1, 1]).Value2 = rowNpp;

                                    var clientPolicy =
                                        (from c in client.ClientPolicies
                                         where c.Id == dataConext.VistaMed.GetClientPolicyId(client.Id, 1)
                                         select c).FirstOrDefault();

                                    var hasPolicy = clientPolicy != null &&
                                                    !client.ClientStatusObservations.Any(
                                                        x => x.RbStatusObservationClientType
                                                             != null &&
                                                             x.RbStatusObservationClientType.Code !=
                                                             ColorMakerManager.InvalidPolicyMarkerCode);

                                    var smpResultType = hasPolicy ? 0 : 1;

                                    ((Range)ws.Rows[rowIndex].Cells[1, 2]).Value2 = client.LastName + " " + client.FirstName
                                        + " " + client.PatrName
                                        + " " + smpResultTypeNames[smpResultType];

                                    ((Range)ws.Rows[rowIndex].Cells[1, 3]).Value2 = client.Sex == 1 ? "М" : "Ж";
                                    ((Range)ws.Rows[rowIndex].Cells[1, 4]).Value2 = client.BirthDate.ToShortDateString();
                                    var clientDoc = dataConext.VistaMed.GetClientDocument(client.Id);
                                    ((Range)ws.Rows[rowIndex].Cells[1, 5]).Value2 = clientDoc;
                                    ((Range)ws.Rows[rowIndex].Cells[1, 6]).Value2 = dataConext.VistaMed.GetClientLocAddress(client.Id);
                                    ((Range)ws.Rows[rowIndex].Cells[1, 7]).FormulaLocal = @"=" + smpTarinfName[smpResultType];

                                    smpKolVyz[smpResultType]++;
                                }

                                rowNpp++;
                                rowIndex++;
                            }

                            for (var i = 0; i < smpVyzName.Length; i++)
                            {
                                newDoc.Names.Item(smpVyzName[i]).RefersToRange.Value2 = smpKolVyz[i];
                            }
                            ((Range)ws.Rows[rowIndex].Cells[1, 7]).Formula = @"=SUM(G8:G" + (rowIndex - 1).ToString() + ")";

                            #endregion
                            //var totalsRow = table.Rows.Add();
                            //totalsRow.Cells[1].Range.Text = String.Format(@"ИТОГО ({0})", rowIndex - 2);
                            //totalsRow.Cells[6].Range.Text = smpBill.Sum.ToString(@"F2");

                            #region реестр1

                            ws = (Worksheet)newDoc.Worksheets["реестр1"];

                            rowIndex = 8;
                            rowNpp = 1;

                            foreach (var accItem in smpBill.AccountItems.OrderBy(x => x.Event.Client.LastName + " "
                                + x.Event.Client.FirstName + " " + x.Event.Client.PatrName))
                            {
                                if (rowIndex > 8)
                                {
                                    ((Range)ws.Rows[rowIndex]).Insert(XlInsertShiftDirection.xlShiftDown);
                                }
                                var client = accItem.Event.Client;
                                if (client != null)
                                {

                                    var clientPolicy =
                                        (from c in client.ClientPolicies
                                         where c.Id == dataConext.VistaMed.GetClientPolicyId(client.Id, 1)
                                         select c).FirstOrDefault();

                                    var hasPolicy = clientPolicy != null &&
                                                    !client.ClientStatusObservations.Any(
                                                        x => x.RbStatusObservationClientType
                                                             != null &&
                                                             x.RbStatusObservationClientType.Code !=
                                                             ColorMakerManager.InvalidPolicyMarkerCode);

                                    var smpResultType = hasPolicy ? 0 : 1;
                                    ((Range)ws.Rows[rowIndex].Cells[1, 1]).Value2 = rowNpp;
                                    var smpEvent = accItem.Event;
                                    ((Range)ws.Rows[rowIndex].Cells[1, 2]).Value2 = smpEvent.ExecDate;
                                    ((Range)ws.Rows[rowIndex].Cells[1, 3]).Value2 = smpEvent.ExternalId;
                                    ((Range)ws.Rows[rowIndex].Cells[1, 4]).Value2 = client.LastName + " " + client.FirstName
                                        + " " + client.PatrName
                                        + " " + smpResultTypeNames[smpResultType];
                                    var diagId = dataConext.VistaMed.GetEventDiagnosis(smpEvent.Id);
                                    if (diagId.HasValue)
                                    {
                                        var diag =
                                            dataConext.VistaMed.Diagnoses.FirstOrDefault(x => x.Id == diagId.Value);
                                        if (diag != null)
                                            ((Range) ws.Rows[rowIndex].Cells[1, 5]).Value2 = diag.MKB;
                                    }
                                }

                                rowNpp++;
                                rowIndex++;
                            }

                            #endregion

                        }
                    }
                    else
                    {
                        context.ReportError(@"Файл шаблона отчета {0} не найден", templateName);
                    }
                }
            }
        }