public void Execute(ref StagingDiagnosisFile diagnosis)
 {
     Parameters.AddWithValue("@ChapterID", diagnosis.ChapterID);
     Parameters.AddWithValue("@DiagnosisCodeID", diagnosis.DiagnosisCodeID);
     Parameters.AddWithValue("@DiagnosisCodeTypeID", diagnosis.DiagnosisCodeTypeID);
     Parameters.AddWithValue("@DiagnosticCode", diagnosis.DiagnosticCode);
     Parameters.AddWithValue("@DiagnosticCodeFlag", diagnosis.DiagnosticCodeFlag);
     Parameters.AddWithValue("@DxCodePriority", diagnosis.DXCodePriority);
     Parameters.AddWithValue("@DxDate", diagnosis.DXDate);
     Parameters.AddWithValue("@EncounterID", diagnosis.EncounterID);
     Parameters.AddWithValue("@EncounterNumber", diagnosis.EncounterNumber);
     Parameters.AddWithValue("@FileID", diagnosis.FileID);
     Parameters.AddWithValue("@JobID", diagnosis.JobID);
     Parameters.AddWithValue("@SectionID", diagnosis.SectionID);
     Parameters.AddWithValue("@SubSectionID", diagnosis.SubSectionID);
     Parameters.AddWithValue("@Version", diagnosis.Version);
     ExecuteNonQuery();
 }
        /// <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);
            }
        }
 public StagingDiagnosisFile Clone()
 {
     StagingDiagnosisFile result = new StagingDiagnosisFile();
     result.PrimaryID = this.PrimaryID;
     result.EncounterID = this.EncounterID;
     result.DiagnosticCode = this.DiagnosticCode;
     result.DiagnosticCodeFlag = this.DiagnosticCodeFlag;
     result.DXCodePriority = this.DXCodePriority;
     result.DXDate = this.DXDate;
     result.FileID = this.FileID;
     result.Version = this.Version;
     result.DiagnosisCodeTypeID = this.DiagnosisCodeTypeID;
     result.DiagnosisCodeID = this.DiagnosisCodeID;
     result.JobID = this.JobID;
     result.EncounterNumber = this.EncounterNumber;
     result.NewDiagnosisCodeID = this.NewDiagnosisCodeID;
     result.ChapterID = this.ChapterID;
     result.SectionID = this.SectionID;
     result.SubSectionID = this.SubSectionID;
     return result;
 }
 public void StagingDiagnosisFileSave(ref StagingDiagnosisFile diagnosis)
 {
     spStagingDiagnosisAdd proc = new spStagingDiagnosisAdd(this.ConnectionString);
     proc.Execute(ref diagnosis);
 }