Beispiel #1
0
        /// <summary>
        /// Write transactions with whitespace.
        /// </summary>
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            var dispense = SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1");

            //  Add "" as the value to account for a delete
            dispense.LoopORC[0].ORC.PlacerOrderNumber_02.NamespaceID_02 = "\"\"";

            //  Add empty string as the value to add an extra separator to keep the position
            dispense.LoopORC[0].ORC.PlacerOrderNumber_02.UniversalID_03 = "";

            using (var stream = new MemoryStream())
            {
                using (var writer = new Hl7Writer(stream, new Hl7WriterSettings()
                {
                    PreserveWhitespace = true
                }))
                {
                    //  Write the dispense
                    writer.Write(dispense);
                }

                Debug.Write(stream.LoadToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Batch multiple transactions under multiple functional groups in the same HL7 stream
        /// </summary>
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            using (var stream = new MemoryStream())
            {
                using (var writer = new Hl7Writer(stream))
                {
                    writer.Write(SegmentBuilders.BuildFhs("LAB1", "LAB", "DEST2", "DEST", "TESTFILE", "1234"));

                    //  1.  Write the first group
                    writer.Write(SegmentBuilders.BuildBhs("LAB1", "LAB", "DEST2", "DEST", "TESTBATCH", "1"));
                    //  Write the transactions...
                    writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"));

                    //  2.  Write the second group
                    writer.Write(SegmentBuilders.BuildBhs("LAB1", "LAB", "DEST2", "DEST", "TESTBATCH", "2"));
                    //  Write the transactions...
                    writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"));
                }

                Debug.Write(stream.LoadToString());
            }
        }
Beispiel #3
0
        /// <summary>
        /// Generate and write HL7 document to a file
        /// </summary>
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            //  Write directly to a file
            //  Change the path to a file on your machine
            using (var writer = new Hl7Writer(@"C:\Test\Output.txt", false))
            {
                writer.Write(SegmentBuilders.BuildFhs("LAB1", "LAB", "DEST2", "DEST", "TESTFILE", "1"));
                writer.Write(SegmentBuilders.BuildBhs("LAB1", "LAB", "DEST2", "DEST", "TESTBATCH", "1"));
                writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"));
            }
        }
        /// <summary>
        /// Generate and write HL7 document to a stream async
        /// </summary>
        public static async void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            using (var stream = new MemoryStream())
            {
                using (var writer = new Hl7Writer(stream))
                {
                    //  Write the dispense
                    await writer.WriteAsync(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"));
                }

                Debug.Write(stream.LoadToString());
            }
        }
        /// <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 Hl7Writer(stream, new Hl7WriterSettings()
                {
                    Postfix = Environment.NewLine
                }))
                {
                    //  Write the dispense
                    writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"));
                }

                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 Hl7Writer(stream))
                {
                    //  Set a custom subcomponent separator.
                    var separators = Separators.Hl7;
                    separators.SubComponent = '#';

                    //  Write the dispense
                    writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"), true, separators);
                }

                Debug.Write(stream.LoadToString());
            }
        }
Beispiel #7
0
        /// <summary>
        /// Batch multiple transactions in the same HL7 stream.
        /// </summary>
        public static void Run2()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            using (var stream = new MemoryStream())
            {
                using (var writer = new Hl7Writer(stream))
                {
                    //  NO Envelope

                    //  Write the first dispense
                    writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "1"));
                    //  Write the second dispense
                    writer.Write(SegmentBuilders.BuildDispense("LAB1", "LAB", "DEST2", "DEST", "2"));
                }

                Debug.Write(stream.LoadToString());
            }
        }