Example of source code how to use Greenrain MNC API is provided below.
...
Example of Claim.Submission XML file is available on this link: TestOneClaimWithErrors.xml.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
using System; using System.Collections.Generic; using System.IO; using Greenrain.Connect; using Greenrain.Mnc; using Greenrain.Mnc.Enums; namespace Greenrain.MncExamplesMncExample { class Program { public static void Main(string[] args) { // Input XML file name. // The example file can be found in the folder Greenrain.Mnc.Examples\Example Files\TestOneClaimWithErrors.xml. // This file canwould 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, PostOfficeEnum.Shafafiya, null, null, null DateTime.Now, 0, 1, new List<string> { "82550", "82565", "85379", "82575", "82947", "85025", "0001F", "0005F" }, "R51", new List<string> { "I10", "R06.02" }); */ // MNC validation: 106 errors. var result = mnc.RunMnc( "id_512", PostOfficeEnum.Shafafiya, null, DateTime.Now, 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 is not present."); Console.WriteLine(); return result; } if (Path.GetExtension(fileName).ToUpper() != ".XML") { Console.WriteLine($"ItThe file is not an XML file -: {fileName}."); Console.WriteLine(); return result; } if (!File.Exists(Path.Combine(Directory.GetCurrentDirectory(), fileName))) { Console.WriteLine($"NotFile foundis filenot -found: {fileName}."); Console.WriteLine(); return result; } // Read XML file data var content = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), fileName)); // Run MNC validation. result = mnc.RunClaimSubmissionChecks(PostOfficeEnum.Shafafiya, content, fileName); return result; } private static void PrintMncResult(ValidationResult result) { if (result == null) { return; } // Exception code.codeL 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(); } } } } |
...