Ejemplo n.º 1
0
        /// <summary>
        /// Reads dispense and observations 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 hl7Stream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\MixedTransactions.txt");

            //  2.  Read multiple transactions batched up in the same interchange
            using (var hl7Reader = new Hl7Reader(hl7Stream, "EdiFabric.Templates.Hl7"))
            {
                while (hl7Reader.Read())
                {
                    //  Process dispenses if no parsing errors
                    var dispense = hl7Reader.Item as TSRDSO13;
                    if (dispense != null && !dispense.HasErrors)
                    {
                        ProcessDispense(hl7Reader.CurrentInterchangeHeader, hl7Reader.CurrentGroupHeader, dispense);
                    }

                    //  Process observations if no parsing errors
                    var observation = hl7Reader.Item as TSORUR01;
                    if (observation != null && !observation.HasErrors)
                    {
                        ProcessObservation(hl7Reader.CurrentInterchangeHeader, hl7Reader.CurrentGroupHeader, observation);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads one item at a time from the HL7 stream.
        /// Use for interchanges containing multiple transactions.
        /// The sample file contains two purchase orders - a valid one and an invalid one.
        /// </summary>
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            //  1.  Load to a stream
            Stream hl7Stream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\PharmacyTreatmentDispenses.txt");

            //  2. Read item by item, that is each call to Read()
            //  brings back either a control segment (or a transaction
            using (var hl7Reader = new Hl7Reader(hl7Stream, "EdiFabric.Templates.Hl7"))
            {
                while (hl7Reader.Read())
                {
                    //  3. Check if current item is dispense
                    var dispense = hl7Reader.Item as TSRDSO13;
                    if (dispense != null)
                    {
                        ProcessDispense(hl7Reader.CurrentInterchangeHeader, hl7Reader.CurrentGroupHeader, dispense);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Validate the typed control segments
        /// </summary>
        public static void Run()
        {
            Debug.WriteLine("******************************");
            Debug.WriteLine(MethodBase.GetCurrentMethod().Name);
            Debug.WriteLine("******************************");

            Stream hl7Stream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\MixedTransactions.txt");

            using (var hl7Reader = new Hl7Reader(hl7Stream, "EdiFabric.Templates.Hl7"))
            {
                while (hl7Reader.Read())
                {
                    var fhs = hl7Reader.Item as FHS;
                    if (fhs != null)
                    {
                        //  Validate
                        var fhsErrors = fhs.Validate();
                        //  Pull the sending application from FHS
                        var senderId = fhs.FileSendingApplication_03.NamespaceID_01;
                        Debug.WriteLine("Sending application:");
                        Debug.WriteLine(senderId);
                    }

                    var bhs = hl7Reader.Item as BHS;
                    if (bhs != null)
                    {
                        //  Validate
                        var bhsErrors = bhs.Validate();
                        //  Pull the sending application from BHS
                        var senderId = bhs.BatchSendingApplication_03.NamespaceID_01;
                        Debug.WriteLine("Sending application:");
                        Debug.WriteLine(senderId);
                    }
                }
            }
        }