/// <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());
        }
        /// <summary>
        /// Добавление пациента в нужный план, добавление информации о прохождении этапов профилактических осмотров.
        /// При необходимости удаление пациента из др. планов и информации о прохождении профилактических осмотров.
        /// </summary>
        /// <param name="patientExaminations">Экземпляр PatientExaminations</param>
        /// <exception cref="WebServiceOperationException">
        /// Вызвыет исключение при невозможности добавить пациента в нужный план.
        /// </exception>
        public async Task AddPatientExaminationsAsync(PatientExaminations patientExaminations)
        {
            if (IsAnyFutureDate(patientExaminations))
            {
                throw new WebServiceOperationException("Осмотр будущей датой не может быть загружен.");
            }

            var webPatientData = await ChangeOrAddPatientToPlanAsync(patientExaminations.InsuranceNumber, patientExaminations, patientExaminations.Kind, patientExaminations.Year);

            var transfer2StageDate = patientExaminations.Stage1?.EndDate ?? webPatientData.Disp1Date;
            var userSteps          = ConvertToExaminationsSteps(patientExaminations, transfer2StageDate);
            var webSteps           = ConvertToExaminationsSteps(webPatientData);

            await AddExaminationStepsAsync(webPatientData.Id, userSteps, webSteps);
        }
 static bool IsAnyFutureDate(PatientExaminations patientExaminations)
 => ((patientExaminations.Stage1?.BeginDate ?? default) > DateTime.Today) ||
예제 #4
0
 public LoadResult(PatientExaminations patientExaminations, bool isLoaded, string errorMessage)
 {
     PatientExaminations = patientExaminations;
     IsLoaded            = isLoaded;
     ErrorMessage        = errorMessage;
 }