/// <summary> /// Validate the typed control segments /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); Stream ncpdpStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\PrescriptionRequest_NEWRX.txt"); using (var ncpdpReader = new NcpdpScriptReader(ncpdpStream, "EdiFabric.Templates.Ncpdp")) { while (ncpdpReader.Read()) { var header = ncpdpReader.Item as UIB; if (header != null) { // Validate var headerErrors = header.Validate(); // Pull the sending application from UIB var senderId = header.INTERCHANGESENDER_06.SenderIdentification_01; Debug.WriteLine("Sender ID:"); Debug.WriteLine(senderId); } } } }
/// <summary> /// Reads prescription requests and changes batched up in the same interchange. /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); // 1. Load to a stream Stream ncpdpStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\MixedTransactions.txt"); // 2. Read multiple transactions batched up in the same interchange using (var ncpdpReader = new NcpdpScriptReader(ncpdpStream, "EdiFabric.Templates.Ncpdp")) { while (ncpdpReader.Read()) { // Process prescription request if no parsing errors var pr = ncpdpReader.Item as TSNEWRX; if (pr != null && !pr.HasErrors) { ProcessPrescriptionRequest(ncpdpReader.CurrentInterchangeHeader, pr); } // Process prescription change if no parsing errors var pc = ncpdpReader.Item as TSCHGRES; if (pc != null && !pc.HasErrors) { ProcessPrescriptionChange(ncpdpReader.CurrentInterchangeHeader, pc); } } } }