コード例 #1
0
        /// <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());
                }
            }
        }
コード例 #2
0
        /// <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());
            }
        }
コード例 #3
0
        /// <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());
            }
        }
コード例 #4
0
        /// <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());
            }
        }
コード例 #5
0
        /// <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());
            }
        }
コード例 #6
0
        /// <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());
            }
        }
コード例 #7
0
        /// <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());
            }
        }