Esempio n. 1
0
        public void ShowDiagnosisFileContents(string fileName)
        {
            this.Show();
            this.Text = string.Format("Viewing: {0}", fileName);
            this.Cursor = Cursors.WaitCursor;
            this.Update();

            try
            {

                DelimitedFileValidator<DiagnosisRow> validator = new DelimitedFileValidator<DiagnosisRow>();
                validator.Validate(fileName);
                DisplayErrors(validator);

                gvFileViewer.Columns.Clear();
                gvFileViewer.AutoGenerateColumns = true;
                gvFileViewer.DataSource = validator.Rows;
                foreach (var column in gvFileViewer.Columns)
                {
                    column.AutoSizeMode = BestFitColumnMode.DisplayedCells;
                }

                gvFileViewer.BestFitColumns();
                gvFileViewer.Refresh();

            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        protected override void ReadIncomingTable()
        {
            base.ReadIncomingTable();

            string fileToProcess = Path.Combine(SystemDataProvider.CurrentSettings.FileProcessingPath, file.FileName);
            log.DebugFormat("Looking for file {0}", fileToProcess);
            if (!File.Exists(fileToProcess))
            {
                throw new FileNotFoundException(fileToProcess);
            }
                        

            DelimitedFileValidator<Diagnosis> validator = new DelimitedFileValidator<Diagnosis>();
            validator.Validate(fileToProcess);

            var list = validator.Rows.OrderBy(x => x.EncounterNumber).ThenBy(x => x.DxCodePriority);
            if (list.Count() == 0)
            {
                throw new FileImportException(fileToProcess);
            }

            log.Debug("Creating Diagnosis objects");
            foreach (Diagnosis item in list)
            {
                StagingDiagnosisFile diagnosis = new StagingDiagnosisFile();
                diagnosis.JobID = job.JobID;
                //diagnosis.ClientOrganizationID = file.ClientOrganizationID;
                diagnosis.DiagnosticCode = item.DiagnosticCode;
                diagnosis.DiagnosticCodeFlag = item.DiagnosticFlag;

                int priority = 0;
                if (int.TryParse(item.DxCodePriority, out priority))
                {
                    diagnosis.DXCodePriority = priority;
                }
                else
                {
                    diagnosis.DXCodePriority = 0;
                }
                diagnosis.DXDate = item.DxDate;
                diagnosis.EncounterNumber = item.EncounterNumber;
                Diagnoses.Add(diagnosis);
            }
        }
        private bool ValidateProcedureFile(ImportedFileStatus candidate)
        {
            IImportValidator<Formats.Procedure> validator = new DelimitedFileValidator<Formats.Procedure>();

            // Validate the file and record the results                        
            validator.Validate(candidate.FileName);
            StringBuilder sb = new StringBuilder();
            validator.Errors.ForEach(x => sb.AppendLine(x.ToString()));
            SystemDataProvider.ClientDataProvider.ValidateImportedFile(candidate.ImportedFileStatusID, validator.TotalRows, validator.HasErrors, sb.ToString());


            if (validator.HasErrors)
            {
                log.WarnFormat("Row {0} has {1} errors!", candidate.ImportedFileStatusID, validator.Errors.Count());
            }
            else
            {
                log.DebugFormat("Row {0} validated successfully!", candidate.ImportedFileStatusID);
            }


            return !validator.HasErrors;
        }
Esempio n. 4
0
        private void tsbProcedureImportValidator_Click(object sender, EventArgs e)
        {
            dlgOpenFile.Title = "Select Procedure File to View";
            if (dlgOpenFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.Cursor = Cursors.WaitCursor;
                bool Validated = false;
                int TotalRows = 0;
                DelimitedFileValidator<Procedure> validator = new DelimitedFileValidator<Procedure>();
                try
                {
                    Validated = validator.Validate(dlgOpenFile.FileName);
                    TotalRows = validator.TotalRows;
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }

                if (!Validated)
                {
                    string errorMessage = validator.Errors[0].ToString();
                    MessageBox.Show(String.Format("File {0} fails validation!{2}{1}", dlgOpenFile.FileName, errorMessage, Environment.NewLine));
                }
                else
                {
                    MessageBox.Show(string.Format("File passed validation.  {0} Rows.", TotalRows));
                }
            }
        }