private void ProcessSVHCDMFiles(object sender, System.ComponentModel.DoWorkEventArgs e) { this.m_BackgroundWorker.ReportProgress(1, "Starting processing SVH CDM files."); YellowstonePathology.Business.Client.Model.ClientGroupClientCollection hrhGroup = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetClientGroupClientCollectionByClientGroupId("2"); YellowstonePathology.Business.ReportNoCollection reportNoCollection = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetReportNumbersBySVHProcess(this.m_PostDate); string workingFolder = System.IO.Path.Combine(this.m_BaseWorkingFolderPathSVH, this.m_PostDate.ToString("MMddyyyy")); if (Directory.Exists(workingFolder) == false) { Directory.CreateDirectory(workingFolder); Directory.CreateDirectory(System.IO.Path.Combine(workingFolder, "ft1")); Directory.CreateDirectory(System.IO.Path.Combine(workingFolder, "ft1", "done")); Directory.CreateDirectory(System.IO.Path.Combine(workingFolder, "result")); Directory.CreateDirectory(System.IO.Path.Combine(workingFolder, "result", "done")); } int rowCount = 0; foreach (YellowstonePathology.Business.ReportNo reportNo in reportNoCollection) { this.m_BackgroundWorker.ReportProgress(1, "Processing: " + reportNo.Value); string masterAccessionNo = YellowstonePathology.Business.Gateway.AccessionOrderGateway.GetMasterAccessionNoFromReportNo(reportNo.Value); YellowstonePathology.Business.Test.AccessionOrder accessionOrder = YellowstonePathology.Business.Persistence.DocumentGateway.Instance.PullAccessionOrder(masterAccessionNo, this); YellowstonePathology.Business.Test.PanelSetOrder panelSetOrder = accessionOrder.PanelSetOrderCollection.GetPanelSetOrder(reportNo.Value); foreach (Business.Test.PanelSetOrderCPTCodeBill panelSetOrderCPTCodeBill in panelSetOrder.PanelSetOrderCPTCodeBillCollection) { if (panelSetOrderCPTCodeBill.BillTo == "Client" && panelSetOrderCPTCodeBill.PostDate == this.m_PostDate) { if (YellowstonePathology.Business.Billing.Model.CDMCollection.Instance.Exists(panelSetOrderCPTCodeBill.CPTCode, "SVH") == true) { if (panelSetOrderCPTCodeBill.PostedToClient == false) { if (string.IsNullOrEmpty(panelSetOrderCPTCodeBill.MedicalRecord) == false && string.IsNullOrEmpty(panelSetOrderCPTCodeBill.Account) == false) { if (panelSetOrderCPTCodeBill.MedicalRecord.StartsWith("V") == true || panelSetOrderCPTCodeBill.MedicalRecord.StartsWith("R") == true) { this.m_BackgroundWorker.ReportProgress(1, "Writing File: " + reportNo.Value + " - " + panelSetOrderCPTCodeBill.CPTCode); Business.HL7View.EPIC.EPICFT1ResultView epicFT1ResultView = new Business.HL7View.EPIC.EPICFT1ResultView(accessionOrder, panelSetOrderCPTCodeBill); epicFT1ResultView.Publish(System.IO.Path.Combine(workingFolder, "ft1")); panelSetOrderCPTCodeBill.PostedToClient = true; panelSetOrderCPTCodeBill.PostedToClientDate = DateTime.Now; rowCount += 1; } else { throw new Exception("The MRN for this charge doesn't start with a V"); } } else { throw new Exception("This MRN or ACCT is null."); } } } else { this.m_BackgroundWorker.ReportProgress(1, "There is no CDM for ReportNo/Code: " + reportNo.Value + " - " + panelSetOrderCPTCodeBill.CPTCode); Business.Billing.Model.SVHNoCDMMailMessage.SendMessage(panelSetOrderCPTCodeBill.CPTCode); } } } } YellowstonePathology.Business.Persistence.DocumentGateway.Instance.Push(this); this.m_BackgroundWorker.ReportProgress(1, "Wrote " + rowCount + " SVH CDM files."); Business.Gateway.BillingGateway.UpdateBillingEODProcess(this.m_PostDate, "ProcessSVHCDMFiles"); }