/// <summary> /// Write without auto trailers /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); using (var stream = new MemoryStream()) { // Set AutoTrailers to false using (var writer = new NcpdpScriptWriter(stream, new NcpdpScriptWriterSettings { AutoTrailers = false })) { // Write the interchange header writer.Write(SegmentBuilders.BuildInterchangeHeader()); // Write the prescription request writer.Write(SegmentBuilders.BuildPrescriptionRequest()); // trailers need to be manually written } using (var writer = new StreamWriter(stream)) { var uiz = new UIZ { InterchangeControlCount_02 = "1" }; writer.Write(uiz.ToEdi(Separators.NcpdpScript)); writer.Flush(); Debug.Write(stream.LoadToString()); } } }
/// <summary> /// Write transactions with whitespace. /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); var prescriptionRequest = SegmentBuilders.BuildPrescriptionRequest(); // Initialize some properties with blanks prescriptionRequest.PVD[0].I016_09 = new I016(); prescriptionRequest.PVD[0].I016_09.CommunicationNumber_01 = ""; using (var stream = new MemoryStream()) { using (var writer = new NcpdpScriptWriter(stream, new NcpdpScriptWriterSettings() { PreserveWhitespace = true })) { // Write the interchange header writer.Write(SegmentBuilders.BuildInterchangeHeader()); // Write the prescription request writer.Write(prescriptionRequest); } Debug.Write(stream.LoadToString()); } }
/// <summary> /// Batch multiple interchanges in the same stream. /// </summary> public static void Run2() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); using (var stream = new MemoryStream()) { using (var writer = new NcpdpScriptWriter(stream)) { // Write transmission header 1 writer.Write(SegmentBuilders.BuildInterchangeHeader("1")); // Write the prescription request writer.Write(SegmentBuilders.BuildPrescriptionRequest("1")); // Write transmission header 2 writer.Write(SegmentBuilders.BuildInterchangeHeader("1")); // Write the prescription request writer.Write(SegmentBuilders.BuildPrescriptionRequest("1")); //... } Debug.Write(stream.LoadToString()); } }
/// <summary> /// Generate and write NCPDP document to a file /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); using (var writer = new NcpdpScriptWriter(@"C:\Test\Output.txt", false)) { // Write the transmission header writer.Write(SegmentBuilders.BuildInterchangeHeader()); // Write the prescription request writer.Write(SegmentBuilders.BuildPrescriptionRequest()); } }
/// <summary> /// Write with segment postfix. /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); using (var stream = new MemoryStream()) { using (var writer = new NcpdpScriptWriter(stream, new NcpdpScriptWriterSettings() { Postfix = Environment.NewLine })) { // Write the interchange header writer.Write(SegmentBuilders.BuildInterchangeHeader()); // Write the prescription request writer.Write(SegmentBuilders.BuildPrescriptionRequest()); } Debug.Write(stream.LoadToString()); } }
/// <summary> /// Write with custom separators, by default it uses the standard separators. /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); using (var stream = new MemoryStream()) { using (var writer = new NcpdpScriptWriter(stream)) { // Set a custom segment separator. var separators = Separators.NcpdpScript; separators.Segment = '|'; // Write the interchange header writer.Write(SegmentBuilders.BuildInterchangeHeader(), separators); // Write the prescription request writer.Write(SegmentBuilders.BuildPrescriptionRequest()); } Debug.Write(stream.LoadToString()); } }
/// <summary> /// Writes to stream without envelopes - no UIB /// </summary> public static void Run() { Debug.WriteLine("******************************"); Debug.WriteLine(MethodBase.GetCurrentMethod().Name); Debug.WriteLine("******************************"); using (var stream = new MemoryStream()) { using (var writer = new NcpdpScriptWriter(stream)) { // Write the prescription request, no interchange header writer.Write(SegmentBuilders.BuildPrescriptionRequest()); } Debug.Write(stream.LoadToString()); } }