예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePaths">Пути к xml файлам реестров-счетов. (может быть папками, xml файлами и/или zip архивами)</param>
        /// <returns></returns>
        public Register GetRegister(IEnumerable <string> filePaths)
        {
            var xmlLoader = new XmlBillsLoader();

            xmlLoader.Load(filePaths);

            var billsRegister = BillsRegister.Create(xmlLoader.PersonsBills, xmlLoader.CasesBills);

            var register = new Register()
            {
                Month     = billsRegister.Month,
                Year      = billsRegister.Year,
                BuildDate = billsRegister.Bills.Max(x => x.Cases.ZGLV.DATA),
                Title     = GetTitle(billsRegister.Bills.First().Cases.ZGLV.FILENAME),
            };

            foreach (var bill in billsRegister.Bills)
            {
                //добавлен DistinctBy потому то реестрах МЭК пациент может дублироваться хотя в реестре ЛПУ этого не было
                var billPersons = bill.Persons.PERS.DistinctBy(x => x.ID_PAC).ToDictionary(x => x.ID_PAC, x => x);

                foreach (var billCase in bill.Cases.ZAP)
                {
                    var billPerson = billPersons[billCase.PACIENT.ID_PAC];

                    var mCase = MapToCase(billPerson, billCase);

                    register.Cases.Add(mCase);
                }
            }

            register.CasesCount = register.Cases.Count;

            return(register);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePaths">Пути к xml файлам реестров-счетов. (может быть папками, xml файлами и/или zip архивами)</param>
        /// <returns></returns>
        public List <PatientExaminations> GetPatientExaminationsList(IEnumerable <string> filePaths)
        {
            var xmlLoader = new XmlBillsLoader();

            xmlLoader.XmlFileNameStartsWithFilter = XmlFileNameStartsWithFilter;
            xmlLoader.Load(filePaths);
            var billsRegister = BillsRegister.Create(xmlLoader.PersonsBills, xmlLoader.CasesBills);

            var result = new Dictionary <string, PatientExaminations>();

            foreach (var bill in billsRegister.Bills)
            {
                int examinationStage;

                if (!TryGetExaminationStage(bill.Cases.SCHET.DISP, out examinationStage))
                {
                    continue;
                }

                var billPersons = bill.Persons.PERS.ToDictionary(x => x.ID_PAC, x => x);

                foreach (var billCase in bill.Cases.ZAP)
                {
                    var examination = GetExamination(billCase, examinationStage);

                    if (examination.HealthGroup == HealthGroup.None)
                    {
                        continue;
                    }

                    var insuranceNumber = GetInsuranceNumber(billCase.PACIENT);
                    var examinationYear = billCase.Z_SL.SL.DATE_2.Year;
                    var patient         = billPersons[billCase.PACIENT.ID_PAC];
                    var examinationKind = GetExaminationType(bill.Cases.SCHET.DISP, examinationYear - patient.DR.Year);

                    PatientExaminations patientExamination;

                    var key = $"{insuranceNumber}{examinationYear}{examinationKind}".ToUpper();
                    if (!result.TryGetValue(key, out patientExamination))
                    {
                        patientExamination = new PatientExaminations()
                        {
                            InsuranceNumber = insuranceNumber,
                            Year            = examinationYear,
                            Kind            = examinationKind,
                            Surname         = patient.FAM,
                            Name            = patient.IM,
                            Patronymic      = patient.OT,
                            Birthdate       = patient.DR
                        };

                        result.Add(key, patientExamination);
                    }

                    patientExamination.AddStage(examinationStage, examination);
                }
            }

            return(result.Values.ToList());
        }