Example of source code how to use Greenrain MNC API is provided below.
Source code example
using System; using System.Collections.Generic; using System.IO; using Greenrain.Connect; using Greenrain.Mnc; namespace Greenrain.Examples { class Program { public static void Main(string[] args) { // Input XML file name. // The example file can be in the folder Greenrain.Mnc.Examples\Example Files\TestOneClaimWithErrors.xml. // This file can be copied to the executable file folder and run app with the parameter. // For example> "C:\Greenrain.Mnc.Examples\Greenrain.Mnc.Examples\bin\Debug>Greenrain.Mnc.Examples.exe TestOneClaimWithErrors.xml" // Or use the next line: //args = new[] { "TestOneClaimWithErrors.xml" }; // Exceptions info and validation errors. ValidationResult result; var mnc = new GreenrainMnc(); Console.WriteLine("Running..."); Console.WriteLine(); // Check input parameters if (args == null || args.Length == 0) { // Examples for GreenrainMnc.RunMnc(). result = RunMncExample(mnc); } else { // Examples for GreenrainMnc.RunClaimSubmissionChecks(). result = RunClaimSubmissionChecksExample(args, mnc); } PrintMncResult(result); // Exit the app. Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } private static ValidationResult RunMncExample(GreenrainMnc mnc) { // MNC validation: Exception code -1002 "Claim ID must have value". //var result = mnc.RunMnc(null, null, null, null, null, null, null); // MNC validation: Exception code -1003 "At least one CPT code must be provided". //var result = mnc.RunMnc("id_512", null, null, null, null, null, null); // MNC validation: 10 errors. var result = mnc.RunMnc( "id_512", null, 0, 1, new List<string> {"82550", "82565", "85379", "82575", "82947", "85025", "0001F", "0005F"}, "R51", new List<string> {"I10", "R06.02"}); return result; } private static ValidationResult RunClaimSubmissionChecksExample(string[] args, GreenrainMnc mnc) { var result = new ValidationResult(); var fileName = args[0]; if (string.IsNullOrEmpty(fileName)) { Console.WriteLine("File name not present."); Console.WriteLine(); return result; } if (Path.GetExtension(fileName).ToUpper() != ".XML") { Console.WriteLine($"It is not XML file - {fileName}."); Console.WriteLine(); return result; } if (!File.Exists(Path.Combine(Directory.GetCurrentDirectory(), fileName))) { Console.WriteLine($"Not found file - {fileName}."); Console.WriteLine(); return result; } // Read XML file data var content = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), fileName)); // Run MNC validation. result = mnc.RunClaimSubmissionChecks(content, fileName); return result; } private static void PrintMncResult(ValidationResult result) { if (result == null) { return; } // Exception code. if the code < 0, then an exception has occurred Console.WriteLine($"Result Code: {result.Code}"); Console.WriteLine($"Result exception description: {result.Description}"); Console.WriteLine($"Errors count: {result.ErrorCollection.ValidationErrors.Count}"); // Print error list Console.WriteLine(); Console.WriteLine("Errors:"); foreach (var error in result.ErrorCollection.ValidationErrors) { Console.WriteLine( $" - {error.ValidationRuleId}; " + $"{error.ReferenceObjectName}; {error.ReferenceObjectPropertyName}; {error.ReferenceObjectPropertyValue}; " + $"{error.OwnerObjectName}; {error.OwnerObjectPropertyName}; {error.OwnerObjectPropertyValue}; " + $"{error.ErrorType}; \n{error.ErrorDescription}; "); Console.WriteLine(); } } } }