Esempio n. 1
0
        /// <summary>
        /// !!! ВСЕ ЭТО НАДО ПЕРЕДЕЛАТЬ КАК ЗДЕСЬ --> http://www.devexpress.com/Support/Center/Example/Details/E1487
        /// </summary>
        private void ImportExamination_Execute(object sender, EventArgs e)
        {
            importPatient = null;
            importExamination = null;
            isImportCompleted = false;
            importWizard = null;
            showWelcomePage = true;

               OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                CheckFileExists = true,
                Multiselect = true, //false,
                CheckPathExists = true,
                Filter = GetDialogFilter(), //CaptionHelper.GetLocalizedText("CustomFomrsMessages", "importFileDialogFileter"),
                Title = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "importFiledialogTitle")
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //importFileFullName = openFileDialog.FileName;

                var importFiles= openFileDialog.FileNames;

                int totalFiles = importFiles.Count();
                int currentNumber = 0;

                foreach (string file in importFiles)
                {
                    if (importWizard != null)
                    {
                        if (importWizard.Canceled == true)  return;
                    }
                    currentNumber++;
                    importFileFullName = file;
                    // находим модуль по расширению файла
                    string extension = Path.GetExtension(importFileFullName);
                    dynamicModule = GetModuleByAssociationAttributeFileExtension(extension);

                    if (dynamicModule == null)
                    {
                        string error = String.Format(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "FileImportError"), importFileFullName);
                        string desctiption = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportModuleError");

                        XtraMessageBox.Show(String.Format("{0}\n{1}",error, desctiption),"",MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                        //return;
                    }

                    XElement header = null;
                    // получаем данные пациента из файла
                    try { header = dynamicModule.DoVerb(VerboseCommand.ExtractData, importFileFullName) as XElement; }
                    catch (Exception ex)
                    {
                        if (ex.Message == "ExaminationImportNoPatientDataFound")
                        {
                            header = null;
                            //XtraMessageBox.Show(CaptionHelper.GetLocalizedText("Exceptions", "ExaminationImportNoPatientDataFound"));
                        }
                        else
                        {
                            string error = String.Format(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "FileImportError"), importFileFullName);
                            string desctiption = CaptionHelper.GetLocalizedText("Exceptions", "ExaminationImportWrongFileType");

                            XtraMessageBox.Show(String.Format("{0}\n{1}", error, desctiption),"",MessageBoxButtons.OK, MessageBoxIcon.Error);

                            isImportCompleted = false;
                            continue;
                            //return;
                        }
                    }

                    importData = CreateImportData(header);

                    //проверяем дату
                    if (importData.StartExaminationDateTime == DateTime.MinValue)
                    {// если дату из файла извлеч не удалось то ставим дату создания файла
                        FileInfo info = new FileInfo(importFileFullName);
                        importData.StartExaminationDateTime = info.CreationTime;
                    }

                    // Запускаем мастер импорта обследования в БД
                    importWizard = new ImportWizardForm();
                    string fullName = String.Format("{0} {1} {2}", importData.LastName, importData.FirstName, importData.MiddleName);

                    string title = String.Format("{0} ({1}/{2})", importFileFullName, currentNumber, totalFiles);

                    importWizard.SetTitle(title);

                    importWizard.SetMessage(string.Format(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportPatientCaptionSearch"), fullName), 1);
                    importWizard.SetMessage(CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportPatientClosiestMatch"), 2);
                    importWizard.isLocalized = true;

                    // Коллекция пациентов для мастера импорта
                    XPCollection patientsCollection = (XPCollection)Application.MainWindow.View.ObjectSpace.CreateCollection(typeof(IPatient));

                    importWizard.WelcomePage.Visible = (showWelcomePage == true);// скрываем страницу приветствия если она уже показывалась

                    importWizard.DisplayPatientCollection(patientsCollection, fullName);
                    importWizard.WizardControl.NextClick += new WizardCommandButtonClickEventHandler(importWizardControl_NextClick);
                    importWizard.WizardControl.SelectedPageChanging += new WizardPageChangingEventHandler(importWizardControl_SelectedPageChanging);

                    importWizard.WizardControl.CustomizeCommandButtons += (o,a) =>
                    {
                        if (currentNumber != totalFiles)
                        {// если файл не последний
                            CompletionWizardPage page = a.Page as CompletionWizardPage;
                            if (page != null)
                            {// см. Предложение #4587
                                page.AllowCancel = true;
                                page.ProceedText = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "DataImportMasterProceed");
                                a.FinishButton.Text = a.NextButton.Text; //"Далее >";
                            }
                        }
                    };

                    importWizard.WizardControl.CancelClick += (o, a) =>
                    {

                    };
                    importWizard.WizardCompleted += (args) =>
                    {
                        isImportCompleted = args;
                    };
                    importWizard.ShowDialog();
                }
            }
        }
Esempio n. 2
0
        internal bool CheckPatientData(ImportData data)
        {
            bool result = true;
            if (data.FirstName == string.Empty)
            {
                string error = CaptionHelper.GetLocalizedText("ImportRules", "PatientFirstNameMustBeSpecified");
                errorProvider.SetError(this.FirstNameTextEdit, error);
                SetWarningBorder(this.FirstNameTextEdit, true);

                result &= false;
            }
            else
            {
                errorProvider.SetError(this.FirstNameTextEdit, null);
                SetWarningBorder(this.FirstNameTextEdit, false);
            }

            if (data.LastName == string.Empty)
            {
                //...
                string error = CaptionHelper.GetLocalizedText("ImportRules", "PatientLastNameMustBeSpecified");
                errorProvider.SetError(this.LastNameTextEdit, error);
                SetWarningBorder(this.LastNameTextEdit, true);
                result &= false;
            }
            else
            {
                errorProvider.SetError(this.LastNameTextEdit, null);
                SetWarningBorder(this.LastNameTextEdit, false);
            }

            if (data.Gender == (DomainComponents.Common.Gender.Male & DomainComponents.Common.Gender.Female))
            {
                string error = CaptionHelper.GetLocalizedText("ImportRules", "PatientGenderMustBeSpecified");
                errorProvider.SetError(this.GenderLookUpEdit, error);
                SetWarningBorder(this.GenderLookUpEdit, true);

                result &= false;
            }
            else
            {
                errorProvider.SetError(this.GenderLookUpEdit, null);
                SetWarningBorder(this.GenderLookUpEdit, false);
            }

            if (data.BirthDate < DateTime.Now.AddYears(-150) || data.BirthDate > DateTime.Now)
            {
                string error = CaptionHelper.GetLocalizedText("ImportRules", "BirthdateIsNotValid");
                errorProvider.SetError(this.BirthdayDateEdit, error);
                SetWarningBorder(this.BirthdayDateEdit, true);

                result &= false;
            }
            else
            {
                errorProvider.SetError(this.BirthdayDateEdit, null);
                SetWarningBorder(this.BirthdayDateEdit, false);
            }

            return result;
        }
Esempio n. 3
0
        private ImportData CreateImportData(XElement header)
        {
            ImportData data = new ImportData()
            {
                FirstName = string.Empty,
                LastName = string.Empty,
                MiddleName = string.Empty,
                Gender = (Gender.Male & Gender.Female),//Gender.None,
                BirthDate = DateTime.MinValue,
                Phone = string.Empty,
                Adress = string.Empty,

                StartExaminationDateTime = DateTime.MinValue,
                EndExaminationDateTime = DateTime.MinValue,
            };

            if (header != null)
            {
                string fullName = Converters.RemoveInvalidChars(GetValueByID(header, "Name"));
                string[] splits = fullName.Split(' ');
                try
                {
                    data.FirstName = splits[1];
                    data.LastName = splits[0];
                    data.MiddleName = splits[2];
                }
                catch { };

                string gender = RemoveNotLetterChars(GetValueByID(header, "Gender"));

                string[] male = { "м", "муж", "мужской", "m", "male" };
                string[] female = { "ж", "жен", "женский", "f", "female" };

                if (male.Any(m => m.Equals(gender, StringComparison.CurrentCultureIgnoreCase)) == true)
                    data.Gender = Gender.Male;
                else if (female.Any(m => m.Equals(gender, StringComparison.CurrentCultureIgnoreCase)) == true)
                    data.Gender = Gender.Female;
                else
                    data.Gender = (Gender.Male & Gender.Female);//Gender.None;

                DateTime birthday;
                string dob = GetValueByID(header, "DOB");
                DateTime.TryParse(dob, out birthday);
                data.BirthDate = birthday;

                data.Phone = GetValueByID(header, "Phone");
                data.Adress = GetValueByID(header, "Address");

                DateTime examDateTime = ConcatenateDateAndTime(GetValueByID(header, "ExamDate"), GetValueByID(header, "ExamTime"));

                data.StartExaminationDateTime = examDateTime;//(examDateTime != DateTime.MinValue) ? examDateTime : DateTime.Now;
                data.EndExaminationDateTime = examDateTime;//(examDateTime != DateTime.MinValue) ? examDateTime : DateTime.Now;
            }

            return data;
        }
Esempio n. 4
0
        public void GetPatientData(ref ImportData importData)
        {
            importData.FirstName = this.FirstNameTextEdit.Text;
            importData.LastName = this.LastNameTextEdit.Text;

            //importData.BirthDate = (DateTime)this.BirthdayDateEdit.EditValue;
            DateTime? birthday = this.BirthdayDateEdit.EditValue as DateTime?;
            if(birthday!=null) { importData.BirthDate = (DateTime)birthday; }
            else { importData.BirthDate=DateTime.MinValue;}

            importData.Gender = (DomainComponents.Common.Gender)this.GenderLookUpEdit.EditValue;
        }