Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
HL7.NET/EdiFabric.Examples.HL7.ValidateHL7/ValidateHL7Transations.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 lines (43 sloc)
1.54 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using EdiFabric.Core.Model.Edi; | |
using EdiFabric.Core.Model.Edi.ErrorContexts; | |
using EdiFabric.Framework.Readers; | |
using EdiFabric.Templates.Hl726; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
namespace EdiFabric.Examples.HL7.ValidateHL7 | |
{ | |
class ValidateHL7Transations | |
{ | |
/// <summary> | |
/// Validate HL7 transactions from file after read | |
/// </summary> | |
public static void Run() | |
{ | |
Debug.WriteLine("******************************"); | |
Debug.WriteLine(MethodBase.GetCurrentMethod().Name); | |
Debug.WriteLine("******************************"); | |
Stream hl7Stream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\PharmacyTreatmentDispense.txt"); | |
List<IEdiItem> hl7Items; | |
using (var reader = new Hl7Reader(hl7Stream, "EdiFabric.Templates.Hl7")) | |
hl7Items = reader.ReadToEnd().ToList(); | |
var dispenses = hl7Items.OfType<TSRDSO13>(); | |
foreach (var dispense in dispenses) | |
{ | |
// Validate | |
MessageErrorContext errorContext; | |
if (!dispense.IsValid(out errorContext)) | |
{ | |
// Report it back to the sender, log, etc. | |
var errors = errorContext.Flatten(); | |
} | |
else | |
{ | |
// dispense is valid, handle it downstream | |
} | |
} | |
} | |
} | |
} |