-
Notifications
You must be signed in to change notification settings - Fork 1
/
ValidateNCPDPTransations.cs
49 lines (44 loc) · 1.58 KB
/
ValidateNCPDPTransations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using EdiFabric.Core.Model.Edi;
using EdiFabric.Core.Model.Edi.ErrorContexts;
using EdiFabric.Examples.NCPDP.Telco.Common;
using EdiFabric.Framework.Readers;
using EdiFabric.Templates.TelcoD0;
namespace EdiFabric.Examples.NCPDP.Telco.ValidateNCPDP
{
class ValidateNCPDPTransations
{
/// <summary>
/// Validate NCPDP transactions from file
/// </summary>
public static void Run()
{
Debug.WriteLine("******************************");
Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
Debug.WriteLine("******************************");
Stream ncpdpStream = File.OpenRead(Directory.GetCurrentDirectory() + Config.TestFilesPath + @"\ClaimBilling");
List<IEdiItem> ncpdpItems;
using (var ncpdpReader = new NcpdpTelcoReader(ncpdpStream, "EdiFabric.Templates.Ncpdp"))
ncpdpItems = ncpdpReader.ReadToEnd().ToList();
var claims = ncpdpItems.OfType<TSB1>();
foreach (var claim in claims)
{
// Validate
MessageErrorContext errorContext;
if (!claim.IsValid(out errorContext))
{
// Report it back to the sender, log, etc.
var errors = errorContext.Flatten();
}
else
{
// claim is valid, handle it downstream
}
}
}
}
}