Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string fileName     = "PERT_V1_TM_TC01_Debug.txt";
            string hl7v2message = File.ReadAllText(Path.Combine("data", fileName));

            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            IVocabularyService vocabService = new InMemoryVocabularyService();
            IMmgService        mmgService   = new InMemoryMmgService();

            Validator validator = new Validator(vocabService, mmgService);

            var result = validator.ValidateMessage(hl7v2message);

            foreach (var validationMessage in result.ValidationMessages)
            {
                Console.WriteLine($"{fileName} : {validationMessage.MessageType} : {validationMessage.Path} : {validationMessage.Content}");
            }

            Console.WriteLine();

            Console.WriteLine($"{result.Errors} errors, {result.Warnings} warnings, {result.ValidationMessages.Where(r => r.Severity == Severity.Information).Count()} information. Elapsed time: {sw.Elapsed.TotalMilliseconds.ToString("N0")} ms. Validation CPU time: {result.Elapsed.TotalMilliseconds.ToString("N0")}");
        }
        private Validator BuildValidator()
        {
            IMmgService        mmgService   = new FileSystemMmgService();
            IVocabularyService vocabService = new InMemoryVocabularyService();

            Validator validator = new Validator(
                vocabService: vocabService,
                mmgService: mmgService);

            return(validator);
        }