diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/X12.NET.iml b/.idea/X12.NET.iml new file mode 100644 index 00000000..d6ebd480 --- /dev/null +++ b/.idea/X12.NET.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..3c741df7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..0c0d1469 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/X12.sln b/X12.sln index 9f64c185..419655af 100644 --- a/X12.sln +++ b/X12.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2042 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30907.101 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X12.X12Parser", "src\X12.X12Parser\X12.X12Parser.csproj", "{19307F16-3D8C-4E4D-8903-8BAD12EDAE78}" EndProject @@ -50,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X12.Specifications", "src\X EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X12.Transformations", "src\X12.Transformations\X12.Transformations.csproj", "{C080E31B-1F81-4F6E-B634-90D834B1811D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "X12UtilsFRM", "X12UtilsFRM\X12UtilsFRM.csproj", "{08B4E0A3-3C17-40F5-B986-562232797C60}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -244,6 +246,18 @@ Global {C080E31B-1F81-4F6E-B634-90D834B1811D}.Release|Mixed Platforms.Build.0 = Release|Any CPU {C080E31B-1F81-4F6E-B634-90D834B1811D}.Release|x86.ActiveCfg = Release|Any CPU {C080E31B-1F81-4F6E-B634-90D834B1811D}.Release|x86.Build.0 = Release|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Debug|x86.ActiveCfg = Debug|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Debug|x86.Build.0 = Debug|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Release|Any CPU.Build.0 = Release|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Release|x86.ActiveCfg = Release|Any CPU + {08B4E0A3-3C17-40F5-B986-562232797C60}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -266,6 +280,7 @@ Global {29EEAA38-BFB2-4732-A286-EB91355F9BCD} = {FC1769FD-76F2-40B7-9FA3-AC3E2F24D8B2} {26E9A9D5-D0B4-4B86-83D7-A0A3370A57EA} = {FC1769FD-76F2-40B7-9FA3-AC3E2F24D8B2} {C080E31B-1F81-4F6E-B634-90D834B1811D} = {FC1769FD-76F2-40B7-9FA3-AC3E2F24D8B2} + {08B4E0A3-3C17-40F5-B986-562232797C60} = {57B7B5ED-5C3D-464D-B67C-7623BBBA8AC0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {82406A0F-880D-4913-8252-9A64EC0C4A3B} diff --git a/X12UtilsFRM/App.config b/X12UtilsFRM/App.config new file mode 100644 index 00000000..ac0734eb --- /dev/null +++ b/X12UtilsFRM/App.config @@ -0,0 +1,70 @@ + + + + +
+ + + + + + + + + False + + + GeorgiaPacific + + + 4010 + + + HTML + + + C:\EDI\TestCases + + + + + + False + + + False + + + True + + + False + + + False + + + 5 + + + 5 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/X12UtilsFRM/BiztalkFunctoidNode.cs b/X12UtilsFRM/BiztalkFunctoidNode.cs new file mode 100644 index 00000000..dfb4965e --- /dev/null +++ b/X12UtilsFRM/BiztalkFunctoidNode.cs @@ -0,0 +1,146 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace X12UtilsFRM +{ + public class BizTalkFunctoidNode : Panel + { + public string CustomScript { get; set; } + public string FunctoidName { get; private set; } + public string FunctoidCategory { get; private set; } + + public Label LblIcon { get; private set; } + public Label LblText { get; private set; } + + // Core tracking variables for drawing cascading links between functoids + private Point mouseStartLoc = Point.Empty; + private bool trackingForLineConnection = false; + + public BizTalkFunctoidNode(string text, Point location) + { + this.FunctoidName = text; + this.FunctoidCategory = DetermineCategory(text); + + // Configure the outer BizTalk block capsule size + this.Size = new Size(130, 36); + this.Location = location; + this.BorderStyle = BorderStyle.FixedSingle; + this.Cursor = Cursors.SizeAll; + + // Determine specific color schemes and symbols based on BizTalk categories + Color headerColor; + Color bodyColor; + string iconSymbol; + + switch (this.FunctoidCategory) + { + case "String": + headerColor = Color.FromArgb(0, 122, 204); // BizTalk Blue + bodyColor = Color.FromArgb(235, 245, 255); + iconSymbol = "ℱ"; // Math function script symbol + break; + case "Math": + headerColor = Color.FromArgb(220, 100, 0); // BizTalk Orange/Amber + bodyColor = Color.FromArgb(255, 242, 230); + iconSymbol = "∑"; // Sigma summation symbol + break; + case "Date": + headerColor = Color.FromArgb(16, 124, 65); // BizTalk Green + bodyColor = Color.FromArgb(230, 247, 236); + iconSymbol = "📅"; // Calendar block emoji/glyph + break; + default: + headerColor = Color.FromArgb(100, 100, 100); // Standard Gray + bodyColor = Color.FromArgb(240, 240, 240); + iconSymbol = "⚙"; + break; + } + + this.BackColor = bodyColor; + + // 1. Left Icon Anchor Bar Block + LblIcon = new Label + { + Text = iconSymbol, + Font = new Font("Segoe UI", 11f, FontStyle.Bold), + BackColor = headerColor, + ForeColor = Color.White, + Size = new Size(30, this.Height - 2), + Location = new Point(0, 0), + TextAlign = ContentAlignment.MiddleCenter, + Cursor = Cursors.SizeAll + }; + this.Controls.Add(LblIcon); + + // 2. Right Text Label Description Strip + LblText = new Label + { + Text = text, + Font = new Font("Segoe UI", 8.25f, FontStyle.Regular), + ForeColor = Color.FromArgb(30, 30, 30), + Size = new Size(95, this.Height - 2), + Location = new Point(32, 0), + TextAlign = ContentAlignment.MiddleLeft, + Cursor = Cursors.SizeAll + }; + this.Controls.Add(LblText); + + // Seed initial execution script snippet properties + this.CustomScript = FunctoidXsltCompiler.GetXsltSnippet(text, "SOURCE_XPATH_PLACEHOLDER", text.Replace(" ", "_")); + + // 3. Register Drag Line Intercept Listeners contextually across all component layout areas + AttachLineDragHooks(this); + AttachLineDragHooks(LblIcon); + AttachLineDragHooks(LblText); + } + + private string DetermineCategory(string functoidName) + { + string name = functoidName.ToLower(); + if (name.Contains("string") || name.Contains("concat") || name.Contains("trim") || name.Contains("case")) + return "String"; + if (name.Contains("add") || name.Contains("sub") || name.Contains("multiply") || name.Contains("divide") || name.Contains("mod") || name.Contains("abs")) + return "Math"; + if (name.Contains("date") || name.Contains("time") || name.Contains("diff")) + return "Date"; + + return "Custom"; + } + + /// + /// Binds connection dragging hooks recursively so users can Shift+Drag from anywhere on the control. + /// + private void AttachLineDragHooks(Control control) + { + control.MouseDown += (s, e) => + { + if (e.Button == MouseButtons.Left && Control.ModifierKeys == Keys.Shift) + { + trackingForLineConnection = true; + mouseStartLoc = e.Location; + } + }; + + control.MouseMove += (s, e) => + { + if (trackingForLineConnection) + { + int dx = Math.Abs(e.X - mouseStartLoc.X); + int dy = Math.Abs(e.Y - mouseStartLoc.Y); + + // Once the mouse slips past system drag sensitivity variables, trip the mapper drop engine + if (dx >= SystemInformation.DragSize.Width || dy >= SystemInformation.DragSize.Height) + { + trackingForLineConnection = false; + + // Pass THIS entire instance as the underlying link source node reference payload + this.DoDragDrop(this, DragDropEffects.Link); + } + } + }; + + control.MouseUp += (s, e) => { trackingForLineConnection = false; }; + } + } +} \ No newline at end of file diff --git a/X12UtilsFRM/ControlExtensions.cs b/X12UtilsFRM/ControlExtensions.cs new file mode 100644 index 00000000..5344813d --- /dev/null +++ b/X12UtilsFRM/ControlExtensions.cs @@ -0,0 +1,28 @@ +using System; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +public static class ControlExtensions +{ + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); + + private const int WM_SETREDRAW = 0x000B; + + public static void BeginUpdate(this Control control) + { + if (control != null && !control.IsDisposed && control.IsHandleCreated) + { + SendMessage(control.Handle, WM_SETREDRAW, 0, IntPtr.Zero); + } + } + + public static void EndUpdate(this Control control) + { + if (control != null && !control.IsDisposed && control.IsHandleCreated) + { + SendMessage(control.Handle, WM_SETREDRAW, 1, IntPtr.Zero); + control.Invalidate(true); // Forces a full redraw of the control and its children + } + } +} diff --git a/X12UtilsFRM/FunctoidScriptEditorForm.cs b/X12UtilsFRM/FunctoidScriptEditorForm.cs new file mode 100644 index 00000000..d89fe868 --- /dev/null +++ b/X12UtilsFRM/FunctoidScriptEditorForm.cs @@ -0,0 +1,76 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace X12UtilsFRM +{ + public class FunctoidScriptEditorForm : Form + { + private TextBox txtScript; + private Button btnSave; + private Button btnCancel; + public string CompiledScriptText { get; private set; } + + public FunctoidScriptEditorForm(string functoidName, string currentScript) + { + this.Text = $"Configure Functoid Script Properties - [{functoidName}]"; + this.Size = new Size(500, 380); + this.StartPosition = FormStartPosition.CenterParent; + this.FormBorderStyle = FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Font = new Font("Segoe UI", 9f); + + // 1. Info Header Label Banner + Label lblInfo = new Label + { + Text = "Modify the raw XSLT expression value snippet injected during map output compilation loops:", + Location = new Point(12, 12), + Size = new Size(460, 32), + ForeColor = Color.FromArgb(60, 60, 80) + }; + this.Controls.Add(lblInfo); + + // 2. Multi-line Script Editor TextBox + txtScript = new TextBox + { + Multiline = true, + ScrollBars = ScrollBars.Both, + Font = new Font("Consolas", 9.75f, FontStyle.Regular), // Code Editor Monospace Font + Text = currentScript, + Location = new Point(15, 48), + Size = new Size(455, 230), + WordWrap = false + }; + this.Controls.Add(txtScript); + + // 3. Save Operational Trigger Action Button + btnSave = new Button + { + Text = "Save Changes", + DialogResult = DialogResult.OK, + Location = new Point(265, 295), + Size = new Size(100, 30), + BackColor = Color.FromArgb(0, 122, 204), + ForeColor = Color.White, + FlatStyle = FlatStyle.Flat + }; + btnSave.FlatAppearance.BorderSize = 0; + btnSave.Click += (s, e) => { this.CompiledScriptText = txtScript.Text; this.Close(); }; + this.Controls.Add(btnSave); + + // 4. Cancel Operative Control Button + btnCancel = new Button + { + Text = "Cancel", + DialogResult = DialogResult.Cancel, + Location = new Point(370, 295), + Size = new Size(100, 30), + FlatStyle = FlatStyle.Flat + }; + this.AcceptButton = btnSave; + this.CancelButton = btnCancel; + this.Controls.Add(btnCancel); + } + } +} \ No newline at end of file diff --git a/X12UtilsFRM/FunctoidXsltCompiler.cs b/X12UtilsFRM/FunctoidXsltCompiler.cs new file mode 100644 index 00000000..01652b91 --- /dev/null +++ b/X12UtilsFRM/FunctoidXsltCompiler.cs @@ -0,0 +1,69 @@ +using System; + +namespace X12UtilsFRM +{ + public static class FunctoidXsltCompiler + { + /// + /// Generates an XSLT element snippet matching the processing rules of standard BizTalk functoids. + /// + /// The type of the operational functoid capsule. + /// The computed absolute XPath matching the linked source document node. + /// The fallback sanitized output XML node name tag structure. + public static string GetXsltSnippet(string functoidName, string sourceXPath, string targetNodeName) + { + switch (functoidName) + { + // ========================================== + // STRING FUNCTOIDS + // ========================================== + case "Uppercase": + return $"<{targetNodeName}>"; + + case "Lowercase": + return $"<{targetNodeName}>"; + + case "Trim": + return $"<{targetNodeName}>"; + + case "String Left": + // XSLT 1.0 substring extraction rule (Starts at index position 1, captures 4 chars as an initial sample frame) + return $"<{targetNodeName}>"; + + case "String Right": + // Grabs the trailing tail subset elements natively + return $"<{targetNodeName}>"; + + // ========================================== + // MATHEMATICAL TOOLS + // ========================================== + case "Add": + return $"<{targetNodeName}>"; + + case "Subtract": + return $"<{targetNodeName}>"; + + case "Absolute": + return $"<{targetNodeName}>"; + + // ========================================== + // DATE / TIME UTILITIES + // ========================================== + case "Current Date": + // Safe basic expression string rule + return $"<{targetNodeName}>"; + + // ========================================== + // INTERNAL SYSTEM FALLBACKS + // ========================================== + case "DirectLink": + // Used when a line stretches directly from a tree item straight into another tree item (no capsule) + return $"<{targetNodeName}>"; + + default: + // General pass-through backup option + return $"<{targetNodeName}>"; + } + } + } +} \ No newline at end of file diff --git a/X12UtilsFRM/InstitutionalClaim5010.xslt b/X12UtilsFRM/InstitutionalClaim5010.xslt new file mode 100644 index 00000000..a6b534ed --- /dev/null +++ b/X12UtilsFRM/InstitutionalClaim5010.xslt @@ -0,0 +1,52 @@ + + + + + + + + + + + type="text/xsl" href=" + + " + + + + + + + + + + + + + + + + + + + + + + + diff --git a/X12UtilsFRM/NLog.config b/X12UtilsFRM/NLog.config new file mode 100644 index 00000000..64915387 --- /dev/null +++ b/X12UtilsFRM/NLog.config @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/X12UtilsFRM/OpenTK.dll.config b/X12UtilsFRM/OpenTK.dll.config new file mode 100644 index 00000000..7098d39e --- /dev/null +++ b/X12UtilsFRM/OpenTK.dll.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/X12UtilsFRM/Program.cs b/X12UtilsFRM/Program.cs new file mode 100644 index 00000000..845619fb --- /dev/null +++ b/X12UtilsFRM/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using NLog; +using NLog.Config; + +namespace X12UtilsFRM { + static class Program { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + Application.Run(new X12UtilsFRM()); + } + } +} diff --git a/X12UtilsFRM/Properties/AssemblyInfo.cs b/X12UtilsFRM/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..c1e745fc --- /dev/null +++ b/X12UtilsFRM/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("X12UtilsFRM")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("X12UtilsFRM")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("08b4e0a3-3c17-40f5-b986-562232797c60")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/X12UtilsFRM/Properties/Resources.Designer.cs b/X12UtilsFRM/Properties/Resources.Designer.cs new file mode 100644 index 00000000..47f4f1a4 --- /dev/null +++ b/X12UtilsFRM/Properties/Resources.Designer.cs @@ -0,0 +1,82 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace X12UtilsFRM.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("X12UtilsFRM.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?> + ///<TransactionSpecification xmlns="http://tempuri.org/X12ParserSpecification.xsd" TransactionSetIdentifierCode="856"> + /// <Segment SegmentId="BSN" Repeat="1"/> + /// <Segment SegmentId="DTM"/> + /// <Segment SegmentId="CTT" Usage="Situational" Trailer="true" Repeat="1"/> + /// <HierarchicalLoop LoopId="SHIPMENT" Usage="Required" LevelCode="S"> + /// <Name>SHIPMENT</Name> + /// <Segment SegmentId="LIN"/> + /// <Segment SegmentId="SN1"/> + /// <Segment SegmentId="SLN"/> + /// <Segment [rest of string was truncated]";. + /// + internal static string GeogiaPacific_856_4010_Specification { + get { + return ResourceManager.GetString("GeogiaPacific_856_4010_Specification", resourceCulture); + } + } + } +} diff --git a/X12UtilsFRM/Properties/Resources.resx b/X12UtilsFRM/Properties/Resources.resx new file mode 100644 index 00000000..685d154f --- /dev/null +++ b/X12UtilsFRM/Properties/Resources.resx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\GeorgiaPacific-856-4010-Specification.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file diff --git a/X12UtilsFRM/Properties/Settings.Designer.cs b/X12UtilsFRM/Properties/Settings.Designer.cs new file mode 100644 index 00000000..ff470d03 --- /dev/null +++ b/X12UtilsFRM/Properties/Settings.Designer.cs @@ -0,0 +1,182 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace X12UtilsFRM.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.6.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool SurppressParsingComments { + get { + return ((bool)(this["SurppressParsingComments"])); + } + set { + this["SurppressParsingComments"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("GeorgiaPacific")] + public string PartnerId { + get { + return ((string)(this["PartnerId"])); + } + set { + this["PartnerId"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("4010")] + public string PartnerX12VersionId { + get { + return ((string)(this["PartnerX12VersionId"])); + } + set { + this["PartnerX12VersionId"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("HTML")] + public string TransformFormat { + get { + return ((string)(this["TransformFormat"])); + } + set { + this["TransformFormat"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("C:\\EDI\\TestCases")] + public string X12Folder { + get { + return ((string)(this["X12Folder"])); + } + set { + this["X12Folder"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string fileList { + get { + return ((string)(this["fileList"])); + } + set { + this["fileList"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool throwExceptions { + get { + return ((bool)(this["throwExceptions"])); + } + set { + this["throwExceptions"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ParseToXML { + get { + return ((bool)(this["ParseToXML"])); + } + set { + this["ParseToXML"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ParseToHTML { + get { + return ((bool)(this["ParseToHTML"])); + } + set { + this["ParseToHTML"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool chkBrowseCheked { + get { + return ((bool)(this["chkBrowseCheked"])); + } + set { + this["chkBrowseCheked"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool chkTargetSchemaChecked { + get { + return ((bool)(this["chkTargetSchemaChecked"])); + } + set { + this["chkTargetSchemaChecked"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("5")] + public int SelectedInfile { + get { + return ((int)(this["SelectedInfile"])); + } + set { + this["SelectedInfile"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("5")] + public int SelectedTargetSchema { + get { + return ((int)(this["SelectedTargetSchema"])); + } + set { + this["SelectedTargetSchema"] = value; + } + } + } +} diff --git a/X12UtilsFRM/Properties/Settings.settings b/X12UtilsFRM/Properties/Settings.settings new file mode 100644 index 00000000..2ee6ba04 --- /dev/null +++ b/X12UtilsFRM/Properties/Settings.settings @@ -0,0 +1,45 @@ + + + + + + False + + + GeorgiaPacific + + + 4010 + + + HTML + + + C:\EDI\TestCases + + + + + + False + + + False + + + True + + + False + + + False + + + 5 + + + 5 + + + \ No newline at end of file diff --git a/X12UtilsFRM/Resources/GeorgiaPacific-856-4010-Specification.xml b/X12UtilsFRM/Resources/GeorgiaPacific-856-4010-Specification.xml new file mode 100644 index 00000000..125a7b3a --- /dev/null +++ b/X12UtilsFRM/Resources/GeorgiaPacific-856-4010-Specification.xml @@ -0,0 +1,186 @@ + + + + + + + SHIPMENT + + + + + + + + + + + + + + + + + + + Bill-To-Party + + + + + + + + + + + + Intermedicate Consignee + + + + + + + + + + + + Supplier + + + + + + + + + + + + Ship To + + + + + + + + + + + + Ship From + + + + + + + + + + + + Selling Party + + + + + + + + + + + + Buying Party + + + + + + + + + + + + Service, Promotion, Allowance, or Charge + + + + + + ORDER + + + + + + + Service, Promotion, Allowance, or Charge + + + + + Buying Party + + + + + + + + + + + + + TARE + + + + PACK + + + + + + DETAIL + + + + + + + + ITEM + + + + + + + + + + + + + + + + + + + + + LOAD DETAIL + + + + + + \ No newline at end of file diff --git a/X12UtilsFRM/SchemaNodeItem.cs b/X12UtilsFRM/SchemaNodeItem.cs new file mode 100644 index 00000000..7d64b55f --- /dev/null +++ b/X12UtilsFRM/SchemaNodeItem.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; +using System.Xml; + +namespace X12UtilsFRM +{ + public class SchemaNodeItem : UserControl + { + public XmlNode XmlSourceNode { get; private set; } + public List ChildNodes { get; set; } = new List(); + public bool IsExpanded { get; set; } + public int IndentLevel { get; set; } = 0; + public int Depth { get; private set; } + + private Label lblToggle; + private Label lblText; + private Action _onStateChanged; + private Point _mouseDownLocation; + private bool _isPotentialDrag = false; + + public SchemaNodeItem(XmlNode xmlNode, int depth, Action onStateChanged) + { + this.XmlSourceNode = xmlNode; + this.Depth = depth; + this._onStateChanged = onStateChanged; + + this.Height = 28; + this.Width = 260; + this.BackColor = Color.Transparent; + + // 1. Expand / Collapse Toggle Button + if (xmlNode.HasChildNodes && xmlNode.FirstChild.NodeType == XmlNodeType.Element) + { + lblToggle = new Label + { + Text = "▼", + Font = new Font("Segoe UI", 8, FontStyle.Bold), + Size = new Size(16, 16), + Location = new Point(5 + (Depth * 15), 6), + Cursor = Cursors.Hand, + TextAlign = ContentAlignment.MiddleCenter + }; + lblToggle.Click += Toggle_Click; + this.Controls.Add(lblToggle); + } + + // 2. Node Text Label (Acts as the Draggable handle) + lblText = new Label + { + Text = xmlNode.Name, + Font = new Font("Segoe UI", 9, FontStyle.Regular), + AutoSize = true, + Location = new Point((lblToggle != null ? 22 : 10) + (Depth * 15), 5), + Cursor = Cursors.Hand + }; + + // --- REVISED DRAG INITIATION LOGIC --- + + // Step A: Record initial click coordinates + lblText.MouseDown += (s, e) => { + if (e.Button == MouseButtons.Left) + { + _isPotentialDrag = true; + _mouseDownLocation = e.Location; + } + }; + + // Step B: Only trigger DoDragDrop if the mouse actually moves beyond the OS drag threshold + lblText.MouseMove += (s, e) => { + if (_isPotentialDrag) + { + int deltaX = Math.Abs(e.X - _mouseDownLocation.X); + int deltaY = Math.Abs(e.Y - _mouseDownLocation.Y); + + // SystemInformation.DragSize prevents twitch-clicks from acting like drags + if (deltaX >= SystemInformation.DragSize.Width || deltaY >= SystemInformation.DragSize.Height) + { + _isPotentialDrag = false; // Drag recognized, clear intent flag + + // Package the layout snapshot payload + TreeNode dragSnapshot = new TreeNode(this.XmlSourceNode.Name) { Tag = this.XmlSourceNode }; + + // Fire the drag-drop execution sequence safely + this.DoDragDrop(dragSnapshot, DragDropEffects.Copy | DragDropEffects.Link); + } + } + }; + + // Step C: Cancel the drag sequence gracefully if mouse button is released early + lblText.MouseUp += (s, e) => { + if (e.Button == MouseButtons.Left) + { + _isPotentialDrag = false; + } + }; + + this.Controls.Add(lblText); + } + private void Toggle_Click(object sender, EventArgs e) + { + IsExpanded = !IsExpanded; + lblToggle.Text = IsExpanded ? "▼" : "►"; + _onStateChanged?.Invoke(this); + } + } +} \ No newline at end of file diff --git a/X12UtilsFRM/SkiaMapper.cs b/X12UtilsFRM/SkiaMapper.cs new file mode 100644 index 00000000..417fc66d --- /dev/null +++ b/X12UtilsFRM/SkiaMapper.cs @@ -0,0 +1,658 @@ +using NLog; +using SkiaSharp; +using SkiaSharp.Views.Desktop; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using System.Xml; + +namespace X12UtilsFRM +{ + public class SkiaMapper : SKControl + { + // Virtual Drag and Drop Trackers + private SchemaNodeItem _draggedVirtualNode = null; + private Point _dragStartPoint; + private const int DragThreshold = 5; + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + + // --- INFINITE FLOATING CANVAS TRACKERS --- + private SKPoint _canvasPanOffset = new SKPoint(0, 0); + private Point _lastMousePosition; + private bool _isPanningCanvas = false; + + // Canvas Data Models + public List Connections { get; set; } = new List(); + public List FlatSchemaRegistry { get; set; } = new List(); + public List FlatTargetSchemaRegistry { get; set; } = new List(); + + // Virtual Column Trackers + private VirtualRegion _leftSchemaRegion = new VirtualRegion { Name = "LeftSchema" }; + private VirtualRegion _centerCanvasRegion = new VirtualRegion { Name = "CenterCanvas" }; + private VirtualRegion _rightSchemaRegion = new VirtualRegion { Name = "RightSchema" }; + + // Splitter Coordinates & State + private float _splitterLeftX; + private float _splitterRightX; + private const float SplitterHitWidth = 6f; + + private bool _isDraggingLeftSplitter = false; + private bool _isDraggingRightSplitter = false; + + private ContextMenuStrip _lineContextMenu; + private MappingConnection _selectedConnectionForDelete; + + public SkiaMapper() + { + this.Dock = DockStyle.Fill; + InitializeLineContextMenu(); + + // Native input sub-bindings + this.MouseDown += Mapper_MouseDown; + this.MouseMove += Mapper_MouseMove; + this.MouseUp += Mapper_MouseUp; + this.MouseWheel += Mapper_MouseWheel; + } + + private void InitializeLineContextMenu() + { + _lineContextMenu = new ContextMenuStrip(); + var deleteItem = new ToolStripMenuItem("Delete Connection"); + deleteItem.Click += (s, e) => + { + if (_selectedConnectionForDelete != null) + { + Connections.Remove(_selectedConnectionForDelete); + _selectedConnectionForDelete = null; + this.Invalidate(); + } + }; + _lineContextMenu.Items.Add(deleteItem); + } + + public void RecalculateVirtualLayout() + { + float height = this.Height; + float width = this.Width; + + if (height <= 0 || width <= 0) return; + + if (_splitterLeftX == 0 && _splitterRightX == 0) + { + _splitterLeftX = width / 3f; + _splitterRightX = _splitterLeftX * 2f; + } + + _leftSchemaRegion.Bounds = new SKRect(0, 0, _splitterLeftX, height); + _centerCanvasRegion.Bounds = new SKRect(_splitterLeftX, 0, _splitterRightX, height); + _rightSchemaRegion.Bounds = new SKRect(_splitterRightX, 0, width, height); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + RecalculateVirtualLayout(); + this.Invalidate(); + } + + protected override void WndProc(ref Message m) + { + const int WM_RBUTTONDOWN = 0x0204; + + if (m.Msg == WM_RBUTTONDOWN) + { + Point clientPt = this.PointToClient(Cursor.Position); + CheckForLineRightClick(clientPt); + } + + base.WndProc(ref m); + } + + private void CheckForLineRightClick(Point clickPt) + { + SKPoint skClick = new SKPoint(clickPt.X, clickPt.Y); + + foreach (var conn in Connections) + { + object visualSource = conn.Source; + object visualTarget = conn.Target; + + if (conn.Source is XmlNode sourceXml) + { + var matchingSource = FlatSchemaRegistry.FirstOrDefault(sni => sni.XmlSourceNode == sourceXml); + if (matchingSource != null) visualSource = matchingSource; + } + + if (conn.Target is XmlNode targetXml) + { + var matchingTarget = FlatTargetSchemaRegistry.FirstOrDefault(sni => sni.XmlSourceNode == targetXml); + if (matchingTarget != null) visualTarget = matchingTarget; + } + + var start = GetControlPoint(visualSource, isSource: true); + var end = GetControlPoint(visualTarget, isSource: false); + + if (start != SKPoint.Empty && end != SKPoint.Empty) + { + if (IsPointNearBezier(skClick, start, end, 8.0f)) + { + _selectedConnectionForDelete = conn; + _lineContextMenu.Show(Cursor.Position); + break; + } + } + } + } + + private bool IsPointNearBezier(SKPoint clickPt, SKPoint start, SKPoint end, float tolerance) + { + float controlOffset = Math.Abs(start.X - end.X) / 2; + + SKPoint p0 = start; + SKPoint p1 = new SKPoint(start.X + controlOffset, start.Y); + SKPoint p2 = new SKPoint(end.X - controlOffset, end.Y); + SKPoint p3 = end; + + int samples = 20; + for (int i = 0; i <= samples; i++) + { + float t = (float)i / samples; + float u = 1 - t; + float tt = t * t; + float uu = u * u; + float uuu = uu * u; + float ttt = tt * t; + + float x = uuu * p0.X + 3 * uu * t * p1.X + 3 * u * tt * p2.X + ttt * p3.X; + float y = uuu * p0.Y + 3 * uu * t * p1.Y + 3 * u * tt * p2.Y + ttt * p3.Y; + + float dx = clickPt.X - x; + float dy = clickPt.Y - y; + float distance = (float)Math.Sqrt(dx * dx + dy * dy); + + if (distance <= tolerance) return true; + } + return false; + } + + public void RenderEngine(SKCanvas canvas, int width, int height) + { + canvas.Clear(Color.FromArgb(245, 247, 250).ToSKColor()); + + // --- DRAW BACKGROUND REGIONS --- + using (var paint = new SKPaint()) + { + paint.Color = SKColors.White; + canvas.DrawRect(_leftSchemaRegion.Bounds, paint); + canvas.DrawRect(_rightSchemaRegion.Bounds, paint); + } + + // --- DRAW TREE NODES (VIRTUAL CHANNELS) --- + RenderVirtualTreeNodes(canvas, FlatSchemaRegistry, _leftSchemaRegion); + RenderVirtualTreeNodes(canvas, FlatTargetSchemaRegistry, _rightSchemaRegion); + + // --- DRAW MAPPER CONNECTIONS --- + OnPaintSurfaceEngine(canvas); + + // --- DRAW SPLITTER SEPARATORS --- + using (var paint = new SKPaint { Color = Color.FromArgb(210, 214, 219).ToSKColor(), StrokeWidth = 2 }) + { + canvas.DrawLine(_splitterLeftX, 0, _splitterLeftX, height, paint); + canvas.DrawLine(_splitterRightX, 0, _splitterRightX, height, paint); + } + } + + private void RenderVirtualTreeNodes(SKCanvas canvas, List nodes, VirtualRegion region) + { + canvas.Save(); + canvas.ClipRect(region.Bounds); + + float currentY = 20 + region.ScrollOffset; + float indentStep = 20f; + + using (var textPaint = new SKPaint { Color = Color.FromArgb(40, 44, 52).ToSKColor(), TextSize = 13f, IsAntialias = true }) + { + foreach (var node in nodes) + { + if (!IsNodeChainVisible(node, nodes)) continue; + + float xPosition = region.Bounds.Left + 15f + (node.Depth * indentStep); + string prefix = node.ChildNodes.Count > 0 ? (node.IsExpanded ? "▼ " : "► ") : " "; + + canvas.DrawText($"{prefix}{node.XmlSourceNode.Name}", xPosition, currentY, textPaint); + + node.Tag = new SKRect(region.Bounds.Left, currentY - 15, region.Bounds.Right, currentY + 5); + currentY += 28f; + } + } + region.MaxScrollHeight = Math.Max(0, currentY - region.ScrollOffset); + canvas.Restore(); + } + + private bool IsNodeChainVisible(SchemaNodeItem item, List registry) + { + var current = item; + while (current != null) + { + var parent = registry.Find(p => p.ChildNodes.Contains(current)); + if (parent != null && !parent.IsExpanded) return false; + current = parent; + } + return true; + } + + private void Mapper_MouseDown(object sender, MouseEventArgs e) + { + if (Math.Abs(e.X - _splitterLeftX) <= SplitterHitWidth / 2) + { + _isDraggingLeftSplitter = true; + } + else if (Math.Abs(e.X - _splitterRightX) <= SplitterHitWidth / 2) + { + _isDraggingRightSplitter = true; + } + // MMB or Left Click + Space triggers canvas panning + else if (e.Button == MouseButtons.Middle || (e.Button == MouseButtons.Left && Control.ModifierKeys == Keys.Space)) + { + if (_centerCanvasRegion.Bounds.Contains(e.X, e.Y)) + { + _isPanningCanvas = true; + _lastMousePosition = e.Location; + this.Cursor = Cursors.NoMove2D; + } + } + else + { + var activeRegistry = _leftSchemaRegion.Bounds.Contains(e.X, e.Y) ? FlatSchemaRegistry : FlatTargetSchemaRegistry; + SchemaNodeItem clickedNode = null; + + foreach (var item in activeRegistry) + { + if (item.Tag is SKRect rowBounds && rowBounds.Contains(e.X, e.Y)) + { + clickedNode = item; + break; + } + } + + if (clickedNode != null) + { + _draggedVirtualNode = clickedNode; + _dragStartPoint = e.Location; + } + } + } + + private void Mapper_MouseMove(object sender, MouseEventArgs e) + { + // 1. Handle Infinite Canvas Panning Transformations + if (_isPanningCanvas) + { + float deltaX = e.X - _lastMousePosition.X; + float deltaY = e.Y - _lastMousePosition.Y; + _lastMousePosition = e.Location; + + _canvasPanOffset = new SKPoint(_canvasPanOffset.X + deltaX, _canvasPanOffset.Y + deltaY); + + // Dynamically translate all physical Functoid custom controls + if (this.Parent != null) + { + foreach (Control ctrl in this.Parent.Controls) + { + if (ctrl != this && !(ctrl.Name.Contains("Toolbox"))) + { + ctrl.Location = new Point(ctrl.Location.X + (int)deltaX, ctrl.Location.Y + (int)deltaY); + } + } + } + + this.Invalidate(); + return; + } + + // 2. Handle Virtual Node Drag Initiation + if (_draggedVirtualNode != null && e.Button == MouseButtons.Left) + { + int deltaX = Math.Abs(e.X - _dragStartPoint.X); + int deltaY = Math.Abs(e.Y - _dragStartPoint.Y); + + if (deltaX > DragThreshold || deltaY > DragThreshold) + { + TreeNode dragPayload = new TreeNode(_draggedVirtualNode.XmlSourceNode.Name) + { + Tag = _draggedVirtualNode.XmlSourceNode + }; + + _draggedVirtualNode = null; + this.DoDragDrop(dragPayload, DragDropEffects.Copy | DragDropEffects.Link); + return; + } + } + + // 3. Handle Splitter Dragging Changes + if (_isDraggingLeftSplitter) + { + _splitterLeftX = Clamp(e.X, 100, _splitterRightX - 100); + RecalculateVirtualLayout(); + this.Invalidate(); + } + else if (_isDraggingRightSplitter) + { + _splitterRightX = Clamp(e.X, _splitterLeftX + 100, this.Width - 100); + RecalculateVirtualLayout(); + this.Invalidate(); + } + + // 4. Splitter Cursor Overrides + if (Math.Abs(e.X - _splitterLeftX) <= SplitterHitWidth / 2 || + Math.Abs(e.X - _splitterRightX) <= SplitterHitWidth / 2) + { + this.Cursor = Cursors.VSplit; + } + else + { + this.Cursor = Cursors.Default; + } + } + + private void Mapper_MouseUp(object sender, MouseEventArgs e) + { + if (_isPanningCanvas) + { + _isPanningCanvas = false; + this.Cursor = Cursors.Default; + return; + } + + _isDraggingLeftSplitter = false; + _isDraggingRightSplitter = false; + + if (_draggedVirtualNode != null) + { + _draggedVirtualNode.IsExpanded = !_draggedVirtualNode.IsExpanded; + Logger.Info($"Virtual Node Click Expanded Toggle: {_draggedVirtualNode.XmlSourceNode.Name}"); + _draggedVirtualNode = null; + this.Invalidate(); + } + } + + private void Mapper_MouseWheel(object sender, MouseEventArgs e) + { + if (_leftSchemaRegion.Bounds.Contains(e.X, e.Y)) + { + _leftSchemaRegion.ScrollOffset = Clamp(_leftSchemaRegion.ScrollOffset + (e.Delta > 0 ? 30 : -30), -_leftSchemaRegion.MaxScrollHeight, 0); + this.Invalidate(); + } + else if (_rightSchemaRegion.Bounds.Contains(e.X, e.Y)) + { + _rightSchemaRegion.ScrollOffset = Clamp(_rightSchemaRegion.ScrollOffset + (e.Delta > 0 ? 30 : -30), -_rightSchemaRegion.MaxScrollHeight, 0); + this.Invalidate(); + } + } + + protected override void OnPaintSurface(SKPaintSurfaceEventArgs e) + { + RenderEngine(e.Surface.Canvas, e.Info.Width, e.Info.Height); + } + + private void OnPaintSurfaceEngine(SKCanvas canvas) + { + canvas.Save(); + + // Clip rendering to the center canvas area + canvas.ClipRect(_centerCanvasRegion.Bounds); + + // --- FIX: REMOVED canvas.Translate HERE --- + // Panning physically relocates the WinForms controls, so our lines should + // be drawn directly in standard coordinate space to prevent double-offset skewing! + + using (var paint = new SKPaint()) + using (var textPaint = new SKPaint()) + { + paint.Style = SKPaintStyle.Stroke; + paint.StrokeWidth = 2; + paint.Color = SKColors.DodgerBlue; + paint.IsAntialias = true; + + textPaint.Color = Color.FromArgb(70, 80, 110).ToSKColor(); + textPaint.TextSize = 10.5f; + textPaint.IsAntialias = true; + textPaint.Typeface = SKTypeface.FromFamilyName("Segoe UI", SKFontStyle.Bold); + textPaint.TextAlign = SKTextAlign.Center; + + foreach (var conn in Connections) + { + object visualSource = conn.Source; + object visualTarget = conn.Target; + + if (conn.Source is XmlNode sourceXml) + { + var matchingSource = FlatSchemaRegistry.FirstOrDefault(sni => sni.XmlSourceNode == sourceXml); + if (matchingSource != null) visualSource = matchingSource; + } + + if (conn.Target is XmlNode targetXml) + { + var matchingTarget = FlatTargetSchemaRegistry.FirstOrDefault(sni => sni.XmlSourceNode == targetXml); + if (matchingTarget != null) visualTarget = matchingTarget; + } + + // Look up coordinates (returns absolute positions relative to the canvas control) + var start = GetControlPoint(visualSource, isSource: true); + var end = GetControlPoint(visualTarget, isSource: false); + + if (start != SKPoint.Empty && end != SKPoint.Empty) + { + // Extract label texts based on type configurations + string sourceLabelText = visualSource is SchemaNodeItem srcSni ? srcSni.XmlSourceNode.Name : + visualSource is BizTalkFunctoidNode srcFunctoid ? srcFunctoid.FunctoidName : ""; + + string targetLabelText = visualTarget is SchemaNodeItem tgtSni ? tgtSni.XmlSourceNode.Name : + visualTarget is BizTalkFunctoidNode tgtFunctoid ? tgtFunctoid.FunctoidName : ""; + + bool isSourceSchema = (visualSource is SchemaNodeItem) || (conn.Source is XmlNode); + bool isTargetSchema = (visualTarget is SchemaNodeItem) || (conn.Target is XmlNode); + bool isSourceFunctoid = visualSource is BizTalkFunctoidNode; + bool isTargetFunctoid = visualTarget is BizTalkFunctoidNode; + + // Apply visibility filters + if (isSourceSchema) + { + targetLabelText = string.Empty; + } + else if (isTargetSchema) + { + sourceLabelText = string.Empty; + } + else if (isSourceFunctoid && isTargetFunctoid) + { + sourceLabelText = string.Empty; + targetLabelText = string.Empty; + } + else if (!string.IsNullOrEmpty(sourceLabelText) && sourceLabelText == targetLabelText) + { + sourceLabelText = string.Empty; + } + + DrawBezierLine(canvas, paint, textPaint, start, end, sourceLabelText, targetLabelText); + } + } + } + canvas.Restore(); + } + + private void DrawBezierLine(SKCanvas canvas, SKPaint paint, SKPaint textPaint, SKPoint start, SKPoint end, string sourceLabel, string targetLabel) + { + float controlOffset = Math.Abs(start.X - end.X) / 2; + + SKPoint p0 = start; + SKPoint p1 = new SKPoint(start.X + controlOffset, start.Y); + SKPoint p2 = new SKPoint(end.X - controlOffset, end.Y); + SKPoint p3 = end; + + using (var path = new SKPath()) + { + path.MoveTo(start); + path.CubicTo(p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y); + canvas.DrawPath(path, paint); + } + + if (!string.IsNullOrEmpty(sourceLabel)) + { + SKPoint pointOnCurve = GetCubicBezierPoint(0.30f, p0, p1, p2, p3); + DrawLabelBadge(canvas, textPaint, pointOnCurve, sourceLabel); + } + + if (!string.IsNullOrEmpty(targetLabel)) + { + SKPoint pointOnCurve = GetCubicBezierPoint(0.70f, p0, p1, p2, p3); + DrawLabelBadge(canvas, textPaint, pointOnCurve, targetLabel); + } + } + + private SKPoint GetCubicBezierPoint(float t, SKPoint p0, SKPoint p1, SKPoint p2, SKPoint p3) + { + float u = 1 - t; + float tt = t * t; + float uu = u * u; + float uuu = uu * u; + float ttt = tt * t; + + float x = uuu * p0.X + 3 * uu * t * p1.X + 3 * u * tt * p2.X + ttt * p3.X; + float y = uuu * p0.Y + 3 * uu * t * p1.Y + 3 * u * tt * p2.Y + ttt * p3.Y; + + return new SKPoint(x, y); + } + + private void DrawLabelBadge(SKCanvas canvas, SKPaint textPaint, SKPoint position, string text) + { + float textWidth = textPaint.MeasureText(text); + + using (var bgPaint = new SKPaint { Color = SKColors.White, Style = SKPaintStyle.Fill }) + { + var bgRect = new SKRect(position.X - (textWidth / 2) - 5, position.Y - 13, position.X + (textWidth / 2) + 5, position.Y + 3); + canvas.DrawRoundRect(bgRect, 4, 4, bgPaint); + } + + canvas.DrawText(text, position.X, position.Y - 1, textPaint); + } + + private SKPoint GetControlPoint(object visualElement, bool isSource) + { + if (visualElement == null) return SKPoint.Empty; + + if (visualElement is SchemaNodeItem sni) + { + if (sni.Tag is SKRect rect) + { + float x = isSource ? rect.Right : rect.Left; + float y = rect.Top + (rect.Height / 2f); + return new SKPoint(x, y); + } + return SKPoint.Empty; + } + + if (visualElement is Control ctrl) + { + if (ctrl.Parent == null) return SKPoint.Empty; + try + { + int targetX = isSource ? ctrl.Width : 0; + Point localAnchorPt = new Point(targetX, ctrl.Height / 2); + + // Convert position straight into local mapper canvas coordinate map space + Point screenPt = ctrl.PointToScreen(localAnchorPt); + Point localPt = this.PointToClient(screenPt); + + return new SKPoint(localPt.X, localPt.Y); + } + catch (Exception) + { + return SKPoint.Empty; + } + } + + return SKPoint.Empty; + } + + private float Clamp(float value, float min, float max) + { + if (value < min) return min; + if (value > max) return max; + return value; + } + public static void DrawToolboxIcon(SKCanvas canvas, SKPoint position, float size, SKColor color) + { + using (var paint = new SKPaint()) + { + paint.Style = SKPaintStyle.Stroke; + paint.StrokeWidth = size * 0.1f; + paint.Color = color; + paint.IsAntialias = true; + paint.StrokeCap = SKStrokeCap.Round; + paint.StrokeJoin = SKStrokeJoin.Round; + + // 1. Draw main toolbox body container box + float boxWidth = size; + float boxHeight = size * 0.7f; + var bodyRect = new SKRect( + position.X - boxWidth / 2f, + position.Y - boxHeight / 2f + (size * 0.1f), + position.X + boxWidth / 2f, + position.Y + boxHeight / 2f + (size * 0.1f) + ); + canvas.DrawRoundRect(bodyRect, size * 0.1f, size * 0.1f, paint); + + // 2. Draw top handle attachment loop + using (var handlePath = new SKPath()) + { + handlePath.MoveTo(position.X - size * 0.25f, bodyRect.Top); + handlePath.LineTo(position.X - size * 0.25f, bodyRect.Top - size * 0.2f); + handlePath.LineTo(position.X + size * 0.25f, bodyRect.Top - size * 0.2f); + handlePath.LineTo(position.X + size * 0.25f, bodyRect.Top); + canvas.DrawPath(handlePath, paint); + } + + // 3. Draw central latch point accent line + canvas.DrawLine( + position.X, + bodyRect.Top, + position.X, + bodyRect.Top + (boxHeight * 0.3f), + paint + ); + } + } + public void ClearAllConnections() + { + if (this.Connections != null) + { + this.Connections.Clear(); + } + + + + this.Invalidate(); // Forces the Skia rendering engine to repaint the blank canvas immediately + Logger.Info("Mapping canvas links successfully purged."); + } + } + + public class MappingConnection + { + public object Source { get; set; } + public object Target { get; set; } + public SKColor LineColor { get; set; } = SKColors.DodgerBlue; + } + + public class VirtualRegion + { + public string Name { get; set; } + public SKRect Bounds { get; set; } + public float ScrollOffset { get; set; } = 0; + public float MaxScrollHeight { get; set; } = 0; + } + + +} \ No newline at end of file diff --git a/X12UtilsFRM/SkiaMapper.resx b/X12UtilsFRM/SkiaMapper.resx new file mode 100644 index 00000000..e5858cc2 --- /dev/null +++ b/X12UtilsFRM/SkiaMapper.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file diff --git a/X12UtilsFRM/SkiaShared.cs b/X12UtilsFRM/SkiaShared.cs new file mode 100644 index 00000000..5b58cbc2 --- /dev/null +++ b/X12UtilsFRM/SkiaShared.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace X12UtilsFRM +{ + public class CanvasSaveState + { + public string SourceSchemaFile { get; set; } + public string TargetSchemaFile { get; set; } + public List Functoids { get; set; } = new List(); + public List Wires { get; set; } = new List(); + } + + public class CanvasFunctoidDto + { + public string Id { get; set; } + public string FunctoidName { get; set; } + public float X { get; set; } + public float Y { get; set; } + public string CustomScript { get; set; } + } + + public class CanvasConnectionDto + { + public string SourceType { get; set; } // "SchemaNode" or "Functoid" + public string SourceIdOrXPath { get; set; } + + public string TargetType { get; set; } // "SchemaNode" or "Functoid" + public string TargetIdOrXPath { get; set; } + } + + +} + diff --git a/X12UtilsFRM/ToolboxCategory.cs b/X12UtilsFRM/ToolboxCategory.cs new file mode 100644 index 00000000..44747363 --- /dev/null +++ b/X12UtilsFRM/ToolboxCategory.cs @@ -0,0 +1,146 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace X12UtilsFRM +{ + public class ToolboxCategory : Panel + { + public string CategoryName { get; private set; } + public bool IsExpanded { get; private set; } = false; + public List FunctoidTemplates { get; set; } = new List(); + + private Label lblHeader; + private FlowLayoutPanel pnlContent; + private Action _onStateChanged; + + public ToolboxCategory(string name, List functoids, Action onStateChanged) + { + this.CategoryName = name; + this.FunctoidTemplates = functoids; + this._onStateChanged = onStateChanged; + + this.Width = 205; // Lock the base category width tightly + this.BackColor = Color.Transparent; + + // 1. Category Header Label + lblHeader = new Label + { + Text = "► " + name, + Font = new Font("Segoe UI", 9, FontStyle.Bold), + BackColor = Color.FromArgb(230, 235, 245), + ForeColor = Color.FromArgb(50, 50, 80), + Dock = DockStyle.Top, + Height = 26, + TextAlign = ContentAlignment.MiddleLeft, + Cursor = Cursors.Hand, + Padding = new Padding(5, 0, 0, 0) + }; + lblHeader.Click += Header_Click; + this.Controls.Add(lblHeader); + + // 2. Content Flow Panel for Functoids + pnlContent = new FlowLayoutPanel + { + Location = new Point(0, lblHeader.Height), + Width = this.Width, // Enforce strict fixed width tracking + BackColor = Color.FromArgb(250, 250, 252), + Padding = new Padding(6, 4, 6, 4), + FlowDirection = FlowDirection.LeftToRight, + WrapContents = true, + AutoSize = false, // CRITICAL FIX: Turn off AutoSize so it stops expanding horizontally! + Visible = false + }; + + foreach (var templateName in functoids) + { + Label btnTemplate = CreateTemplateItem(templateName); + pnlContent.Controls.Add(btnTemplate); + } + + this.Controls.Add(pnlContent); + this.Controls.SetChildIndex(lblHeader, 0); + this.Controls.SetChildIndex(pnlContent, 1); + + UpdateHeight(); + } + + public void UpdateHeight() + { + if (!IsExpanded) + { + this.Height = lblHeader.Height; + } + else + { + // Force inner flow layout boundaries to match the parent category container perfectly + pnlContent.Width = this.Width; + + // Force the layout engine to calculate wrapping rows based on the rigid fixed width bounds + pnlContent.PerformLayout(); + + // Ask the layout engine how much vertical space it needs for the wrapped grid rows + Size neededSize = pnlContent.GetPreferredSize(new Size(pnlContent.Width, 0)); + + // Apply the computed height constraints directly to both container layers + pnlContent.Height = neededSize.Height; + this.Height = lblHeader.Height + pnlContent.Height + 4; + } + } + private Label CreateTemplateItem(string text) + { + Label lbl = new Label + { + Text = text, + Font = new Font("Segoe UI", 8.5f, FontStyle.Regular), + BackColor = Color.LightSteelBlue, + BorderStyle = BorderStyle.FixedSingle, + TextAlign = ContentAlignment.MiddleCenter, + // FIX B: Shrink item size from 92px down to 90px wide. + // (2 buttons * 90px) + margins + padding fits beautifully in a 210px container! + Size = new Size(90, 28), + Margin = new Padding(3), + Cursor = Cursors.Hand + }; + + // Keep your smart drag-size tracking logic intact... + Point mouseDownLocation = Point.Empty; + bool isPotentialDrag = false; + + lbl.MouseDown += (s, e) => + { + if (e.Button == MouseButtons.Left) { isPotentialDrag = true; mouseDownLocation = e.Location; } + }; + lbl.MouseMove += (s, e) => + { + if (isPotentialDrag) + { + int deltaX = Math.Abs(e.X - mouseDownLocation.X); + int deltaY = Math.Abs(e.Y - mouseDownLocation.Y); + if (deltaX >= SystemInformation.DragSize.Width || deltaY >= SystemInformation.DragSize.Height) + { + isPotentialDrag = false; + TreeNode dragSnapshot = new TreeNode(text) { Tag = "FUNCTOID_TEMPLATE" }; + this.DoDragDrop(dragSnapshot, DragDropEffects.Copy | DragDropEffects.Link); + } + } + }; + lbl.MouseUp += (s, e) => { if (e.Button == MouseButtons.Left) isPotentialDrag = false; }; + + return lbl; + } + + private void Header_Click(object sender, EventArgs e) + { + IsExpanded = !IsExpanded; + lblHeader.Text = (IsExpanded ? "▼ " : "► ") + CategoryName; + pnlContent.Visible = IsExpanded; + + UpdateHeight(); + _onStateChanged?.Invoke(); + } + } +} + + \ No newline at end of file diff --git a/X12UtilsFRM/X12UtilsFRM.Designer.cs b/X12UtilsFRM/X12UtilsFRM.Designer.cs new file mode 100644 index 00000000..40b3484e --- /dev/null +++ b/X12UtilsFRM/X12UtilsFRM.Designer.cs @@ -0,0 +1,664 @@ + +namespace X12UtilsFRM { + partial class X12UtilsFRM + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.parse = new System.Windows.Forms.TabPage(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.btnApplyXslt = new System.Windows.Forms.Button(); + this.grpFileExtensionFilter = new System.Windows.Forms.GroupBox(); + this.rbtfXslt = new System.Windows.Forms.RadioButton(); + this.rbtfTxt = new System.Windows.Forms.RadioButton(); + this.rbtfXml = new System.Windows.Forms.RadioButton(); + this.lblSourceFolder = new System.Windows.Forms.Label(); + this.lbxTargetSchema = new System.Windows.Forms.ListBox(); + this.btnMap = new System.Windows.Forms.Button(); + this.btnFindSpec = new System.Windows.Forms.Button(); + this.btnHippaParse = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.btnParse = new System.Windows.Forms.Button(); + this.lblInterchangeCount = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.lblSelectedFile = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.rbHtml = new System.Windows.Forms.RadioButton(); + this.rbXml = new System.Windows.Forms.RadioButton(); + this.btnAddFiles = new System.Windows.Forms.Button(); + this.lbxInfileList = new System.Windows.Forms.ListBox(); + this.rtLog = new System.Windows.Forms.RichTextBox(); + this.rtxInterchangeFile = new System.Windows.Forms.RichTextBox(); + this.browser = new System.Windows.Forms.TabPage(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.lblSaveAs = new System.Windows.Forms.Label(); + this.webBrowser1 = new System.Windows.Forms.WebBrowser(); + this.label2 = new System.Windows.Forms.Label(); + this.FormLocations = new System.Windows.Forms.TabPage(); + this.rtLocations = new System.Windows.Forms.RichTextBox(); + this.tbpMap = new System.Windows.Forms.TabPage(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.pnlFunctoids = new System.Windows.Forms.Panel(); + this.trvTarget = new System.Windows.Forms.TreeView(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.tabControl1.SuspendLayout(); + this.parse.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.grpFileExtensionFilter.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.browser.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + this.FormLocations.SuspendLayout(); + this.tbpMap.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // statusStrip1 + // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); + this.statusStrip1.Location = new System.Drawing.Point(0, 749); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 10, 0); + this.statusStrip1.Size = new System.Drawing.Size(1545, 22); + this.statusStrip1.TabIndex = 0; + this.statusStrip1.Text = "statusStrip1"; + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.parse); + this.tabControl1.Controls.Add(this.browser); + this.tabControl1.Controls.Add(this.FormLocations); + this.tabControl1.Controls.Add(this.tbpMap); + this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabControl1.Location = new System.Drawing.Point(0, 0); + this.tabControl1.Margin = new System.Windows.Forms.Padding(2); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(1545, 749); + this.tabControl1.TabIndex = 1; + this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); + // + // parse + // + this.parse.Controls.Add(this.splitContainer1); + this.parse.Location = new System.Drawing.Point(4, 22); + this.parse.Margin = new System.Windows.Forms.Padding(2); + this.parse.Name = "parse"; + this.parse.Padding = new System.Windows.Forms.Padding(2); + this.parse.Size = new System.Drawing.Size(1537, 723); + this.parse.TabIndex = 0; + this.parse.Text = "Parse"; + this.parse.UseVisualStyleBackColor = true; + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer1.Location = new System.Drawing.Point(2, 2); + this.splitContainer1.Margin = new System.Windows.Forms.Padding(2); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.btnApplyXslt); + this.splitContainer1.Panel1.Controls.Add(this.grpFileExtensionFilter); + this.splitContainer1.Panel1.Controls.Add(this.lblSourceFolder); + this.splitContainer1.Panel1.Controls.Add(this.lbxTargetSchema); + this.splitContainer1.Panel1.Controls.Add(this.btnMap); + this.splitContainer1.Panel1.Controls.Add(this.btnFindSpec); + this.splitContainer1.Panel1.Controls.Add(this.btnHippaParse); + this.splitContainer1.Panel1.Controls.Add(this.button1); + this.splitContainer1.Panel1.Controls.Add(this.btnParse); + this.splitContainer1.Panel1.Controls.Add(this.lblInterchangeCount); + this.splitContainer1.Panel1.Controls.Add(this.label3); + this.splitContainer1.Panel1.Controls.Add(this.lblSelectedFile); + this.splitContainer1.Panel1.Controls.Add(this.label1); + this.splitContainer1.Panel1.Controls.Add(this.groupBox1); + this.splitContainer1.Panel1.Controls.Add(this.btnAddFiles); + this.splitContainer1.Panel1.Controls.Add(this.lbxInfileList); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.rtLog); + this.splitContainer1.Panel2.Controls.Add(this.rtxInterchangeFile); + this.splitContainer1.Size = new System.Drawing.Size(1533, 719); + this.splitContainer1.SplitterDistance = 363; + this.splitContainer1.SplitterWidth = 3; + this.splitContainer1.TabIndex = 0; + // + // btnApplyXslt + // + this.btnApplyXslt.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnApplyXslt.Location = new System.Drawing.Point(211, 552); + this.btnApplyXslt.Margin = new System.Windows.Forms.Padding(2); + this.btnApplyXslt.Name = "btnApplyXslt"; + this.btnApplyXslt.Size = new System.Drawing.Size(133, 34); + this.btnApplyXslt.TabIndex = 17; + this.btnApplyXslt.Text = "Apply Xslt"; + this.btnApplyXslt.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.btnApplyXslt.UseVisualStyleBackColor = true; + this.btnApplyXslt.Click += new System.EventHandler(this.btnApplyXslt_Click); + // + // grpFileExtensionFilter + // + this.grpFileExtensionFilter.Controls.Add(this.rbtfXslt); + this.grpFileExtensionFilter.Controls.Add(this.rbtfTxt); + this.grpFileExtensionFilter.Controls.Add(this.rbtfXml); + this.grpFileExtensionFilter.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.grpFileExtensionFilter.Location = new System.Drawing.Point(8, 277); + this.grpFileExtensionFilter.Margin = new System.Windows.Forms.Padding(2); + this.grpFileExtensionFilter.Name = "grpFileExtensionFilter"; + this.grpFileExtensionFilter.Padding = new System.Windows.Forms.Padding(2); + this.grpFileExtensionFilter.Size = new System.Drawing.Size(356, 53); + this.grpFileExtensionFilter.TabIndex = 16; + this.grpFileExtensionFilter.TabStop = false; + this.grpFileExtensionFilter.Text = "Filter"; + // + // rbtfXslt + // + this.rbtfXslt.AutoSize = true; + this.rbtfXslt.Location = new System.Drawing.Point(126, 23); + this.rbtfXslt.Margin = new System.Windows.Forms.Padding(2); + this.rbtfXslt.Name = "rbtfXslt"; + this.rbtfXslt.Size = new System.Drawing.Size(54, 24); + this.rbtfXslt.TabIndex = 5; + this.rbtfXslt.Text = "xslt"; + this.rbtfXslt.UseVisualStyleBackColor = true; + this.rbtfXslt.CheckedChanged += new System.EventHandler(this.extensionFilter_CheckedChanged); + // + // rbtfTxt + // + this.rbtfTxt.AutoSize = true; + this.rbtfTxt.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::X12UtilsFRM.Properties.Settings.Default, "ParseToHTML", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.rbtfTxt.Location = new System.Drawing.Point(72, 23); + this.rbtfTxt.Margin = new System.Windows.Forms.Padding(2); + this.rbtfTxt.Name = "rbtfTxt"; + this.rbtfTxt.Size = new System.Drawing.Size(47, 24); + this.rbtfTxt.TabIndex = 4; + this.rbtfTxt.Text = "txt"; + this.rbtfTxt.UseVisualStyleBackColor = true; + this.rbtfTxt.CheckedChanged += new System.EventHandler(this.extensionFilter_CheckedChanged); + // + // rbtfXml + // + this.rbtfXml.AutoSize = true; + this.rbtfXml.Checked = true; + this.rbtfXml.Location = new System.Drawing.Point(17, 24); + this.rbtfXml.Margin = new System.Windows.Forms.Padding(2); + this.rbtfXml.Name = "rbtfXml"; + this.rbtfXml.Size = new System.Drawing.Size(53, 24); + this.rbtfXml.TabIndex = 3; + this.rbtfXml.TabStop = true; + this.rbtfXml.Text = "xml"; + this.rbtfXml.UseVisualStyleBackColor = true; + this.rbtfXml.CheckedChanged += new System.EventHandler(this.extensionFilter_CheckedChanged); + // + // lblSourceFolder + // + this.lblSourceFolder.AutoSize = true; + this.lblSourceFolder.Location = new System.Drawing.Point(5, 5); + this.lblSourceFolder.Name = "lblSourceFolder"; + this.lblSourceFolder.Size = new System.Drawing.Size(105, 13); + this.lblSourceFolder.TabIndex = 15; + this.lblSourceFolder.Text = "Default source folder"; + this.lblSourceFolder.Click += new System.EventHandler(this.lblSourceFolder_Click); + // + // lbxTargetSchema + // + this.lbxTargetSchema.FormattingEnabled = true; + this.lbxTargetSchema.Location = new System.Drawing.Point(4, 331); + this.lbxTargetSchema.Margin = new System.Windows.Forms.Padding(2); + this.lbxTargetSchema.Name = "lbxTargetSchema"; + this.lbxTargetSchema.Size = new System.Drawing.Size(356, 160); + this.lbxTargetSchema.TabIndex = 13; + this.lbxTargetSchema.SelectedIndexChanged += new System.EventHandler(this.lbxfileList_SelectedIndexChanged); + // + // btnMap + // + this.btnMap.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnMap.Location = new System.Drawing.Point(8, 666); + this.btnMap.Margin = new System.Windows.Forms.Padding(2); + this.btnMap.Name = "btnMap"; + this.btnMap.Size = new System.Drawing.Size(158, 34); + this.btnMap.TabIndex = 11; + this.btnMap.Text = "Map"; + this.toolTip1.SetToolTip(this.btnMap, "Adds Inbound X12 EDI files saved into $\"{Properties.Settings.Default.X12Flist}\" "); + this.btnMap.UseVisualStyleBackColor = true; + this.btnMap.Click += new System.EventHandler(this.btnMap_Click); + // + // btnFindSpec + // + this.btnFindSpec.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnFindSpec.Location = new System.Drawing.Point(8, 628); + this.btnFindSpec.Margin = new System.Windows.Forms.Padding(2); + this.btnFindSpec.Name = "btnFindSpec"; + this.btnFindSpec.Size = new System.Drawing.Size(158, 34); + this.btnFindSpec.TabIndex = 10; + this.btnFindSpec.Text = "Find Spec"; + this.toolTip1.SetToolTip(this.btnFindSpec, "Adds Inbound X12 EDI files saved into $\"{Properties.Settings.Default.X12Flist}\" "); + this.btnFindSpec.UseVisualStyleBackColor = true; + this.btnFindSpec.Click += new System.EventHandler(this.btnFindSpec_Click); + // + // btnHippaParse + // + this.btnHippaParse.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnHippaParse.Location = new System.Drawing.Point(8, 590); + this.btnHippaParse.Margin = new System.Windows.Forms.Padding(2); + this.btnHippaParse.Name = "btnHippaParse"; + this.btnHippaParse.Size = new System.Drawing.Size(158, 34); + this.btnHippaParse.TabIndex = 9; + this.btnHippaParse.Text = "Parse Hippa"; + this.toolTip1.SetToolTip(this.btnHippaParse, "Adds Inbound X12 EDI files saved into $\"{Properties.Settings.Default.X12Flist}\" "); + this.btnHippaParse.UseVisualStyleBackColor = true; + this.btnHippaParse.Click += new System.EventHandler(this.btnHippaParse_Click); + // + // button1 + // + this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(8, 552); + this.button1.Margin = new System.Windows.Forms.Padding(2); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(158, 34); + this.button1.TabIndex = 8; + this.button1.Text = "Any Xml to HTML"; + this.toolTip1.SetToolTip(this.button1, "Adds Inbound X12 EDI files saved into $\"{Properties.Settings.Default.X12Flist}\" "); + this.button1.UseVisualStyleBackColor = true; + // + // btnParse + // + this.btnParse.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnParse.Location = new System.Drawing.Point(211, 508); + this.btnParse.Margin = new System.Windows.Forms.Padding(2); + this.btnParse.Name = "btnParse"; + this.btnParse.Size = new System.Drawing.Size(122, 34); + this.btnParse.TabIndex = 7; + this.btnParse.Text = "<< Parse"; + this.btnParse.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.toolTip1.SetToolTip(this.btnParse, "Adds Inbound X12 EDI files saved into $\"{Properties.Settings.Default.X12Flist}\" "); + this.btnParse.UseVisualStyleBackColor = true; + this.btnParse.Click += new System.EventHandler(this.btnParse_Click); + // + // lblInterchangeCount + // + this.lblInterchangeCount.AutoSize = true; + this.lblInterchangeCount.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblInterchangeCount.ForeColor = System.Drawing.Color.Red; + this.lblInterchangeCount.Location = new System.Drawing.Point(207, 65); + this.lblInterchangeCount.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblInterchangeCount.Name = "lblInterchangeCount"; + this.lblInterchangeCount.Size = new System.Drawing.Size(19, 20); + this.lblInterchangeCount.TabIndex = 6; + this.lblInterchangeCount.Text = "0"; + this.lblInterchangeCount.TextChanged += new System.EventHandler(this.lblInterchangeCount_TextChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(88, 65); + this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(115, 20); + this.label3.TabIndex = 5; + this.label3.Text = "Interchanges"; + // + // lblSelectedFile + // + this.lblSelectedFile.AutoSize = true; + this.lblSelectedFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblSelectedFile.ForeColor = System.Drawing.Color.Red; + this.lblSelectedFile.Location = new System.Drawing.Point(82, 65); + this.lblSelectedFile.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblSelectedFile.Name = "lblSelectedFile"; + this.lblSelectedFile.Size = new System.Drawing.Size(0, 20); + this.lblSelectedFile.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(4, 65); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(80, 20); + this.label1.TabIndex = 3; + this.label1.Text = "Selected"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.rbHtml); + this.groupBox1.Controls.Add(this.rbXml); + this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.groupBox1.Location = new System.Drawing.Point(8, 495); + this.groupBox1.Margin = new System.Windows.Forms.Padding(2); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Padding = new System.Windows.Forms.Padding(2); + this.groupBox1.Size = new System.Drawing.Size(182, 53); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Transform.."; + // + // rbHtml + // + this.rbHtml.AutoSize = true; + this.rbHtml.Location = new System.Drawing.Point(72, 23); + this.rbHtml.Name = "rbHtml"; + this.rbHtml.Size = new System.Drawing.Size(74, 24); + this.rbHtml.TabIndex = 1; + this.rbHtml.Text = "HTML"; + this.rbHtml.UseVisualStyleBackColor = true; + // + // rbXml + // + this.rbXml.AutoSize = true; + this.rbXml.Checked = true; + this.rbXml.Location = new System.Drawing.Point(5, 23); + this.rbXml.Name = "rbXml"; + this.rbXml.Size = new System.Drawing.Size(63, 24); + this.rbXml.TabIndex = 0; + this.rbXml.TabStop = true; + this.rbXml.Text = "XML"; + this.rbXml.UseVisualStyleBackColor = true; + // + // btnAddFiles + // + this.btnAddFiles.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAddFiles.Location = new System.Drawing.Point(5, 38); + this.btnAddFiles.Margin = new System.Windows.Forms.Padding(2); + this.btnAddFiles.Name = "btnAddFiles"; + this.btnAddFiles.Size = new System.Drawing.Size(122, 25); + this.btnAddFiles.TabIndex = 1; + this.btnAddFiles.Text = "Add files.."; + this.btnAddFiles.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.toolTip1.SetToolTip(this.btnAddFiles, "Adds Inbound X12 EDI files saved into $\"{Properties.Settings.Default.X12Flist}\" "); + this.btnAddFiles.UseVisualStyleBackColor = true; + this.btnAddFiles.Click += new System.EventHandler(this.btnAddFiles_Click); + // + // lbxInfileList + // + this.lbxInfileList.FormattingEnabled = true; + this.lbxInfileList.Location = new System.Drawing.Point(4, 87); + this.lbxInfileList.Margin = new System.Windows.Forms.Padding(2); + this.lbxInfileList.Name = "lbxInfileList"; + this.lbxInfileList.Size = new System.Drawing.Size(356, 186); + this.lbxInfileList.TabIndex = 0; + this.lbxInfileList.SelectedIndexChanged += new System.EventHandler(this.lbxfileList_SelectedIndexChanged); + // + // rtLog + // + this.rtLog.BackColor = System.Drawing.Color.Black; + this.rtLog.Dock = System.Windows.Forms.DockStyle.Fill; + this.rtLog.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.rtLog.ForeColor = System.Drawing.Color.Lime; + this.rtLog.Location = new System.Drawing.Point(0, 0); + this.rtLog.Name = "rtLog"; + this.rtLog.Size = new System.Drawing.Size(1167, 719); + this.rtLog.TabIndex = 1; + this.rtLog.Text = "aaaa"; + // + // rtxInterchangeFile + // + this.rtxInterchangeFile.Location = new System.Drawing.Point(0, 0); + this.rtxInterchangeFile.Margin = new System.Windows.Forms.Padding(2); + this.rtxInterchangeFile.Name = "rtxInterchangeFile"; + this.rtxInterchangeFile.Size = new System.Drawing.Size(682, 515); + this.rtxInterchangeFile.TabIndex = 0; + this.rtxInterchangeFile.Text = ""; + // + // browser + // + this.browser.Controls.Add(this.tableLayoutPanel2); + this.browser.Location = new System.Drawing.Point(4, 22); + this.browser.Margin = new System.Windows.Forms.Padding(2); + this.browser.Name = "browser"; + this.browser.Padding = new System.Windows.Forms.Padding(2); + this.browser.Size = new System.Drawing.Size(1537, 723); + this.browser.TabIndex = 1; + this.browser.Text = "Browser"; + this.browser.UseVisualStyleBackColor = true; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 1467F)); + this.tableLayoutPanel2.Controls.Add(this.lblSaveAs, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.webBrowser1, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.label2, 0, 0); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(2, 2); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 3; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(1533, 719); + this.tableLayoutPanel2.TabIndex = 1; + // + // lblSaveAs + // + this.lblSaveAs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.lblSaveAs.AutoSize = true; + this.lblSaveAs.Location = new System.Drawing.Point(69, 0); + this.lblSaveAs.Name = "lblSaveAs"; + this.lblSaveAs.Size = new System.Drawing.Size(53, 25); + this.lblSaveAs.TabIndex = 2; + this.lblSaveAs.Text = "lblSaveas"; + this.lblSaveAs.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // webBrowser1 + // + this.webBrowser1.AllowWebBrowserDrop = false; + this.tableLayoutPanel2.SetColumnSpan(this.webBrowser1, 2); + this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; + this.webBrowser1.Location = new System.Drawing.Point(2, 27); + this.webBrowser1.Margin = new System.Windows.Forms.Padding(2); + this.webBrowser1.MinimumSize = new System.Drawing.Size(15, 16); + this.webBrowser1.Name = "webBrowser1"; + this.webBrowser1.Size = new System.Drawing.Size(1529, 670); + this.webBrowser1.TabIndex = 0; + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(3, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(53, 25); + this.label2.TabIndex = 1; + this.label2.Text = "Save As.."; + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // FormLocations + // + this.FormLocations.Controls.Add(this.rtLocations); + this.FormLocations.Location = new System.Drawing.Point(4, 22); + this.FormLocations.Name = "FormLocations"; + this.FormLocations.Padding = new System.Windows.Forms.Padding(3); + this.FormLocations.Size = new System.Drawing.Size(1537, 723); + this.FormLocations.TabIndex = 2; + this.FormLocations.Text = "Form locations"; + this.FormLocations.UseVisualStyleBackColor = true; + // + // rtLocations + // + this.rtLocations.BackColor = System.Drawing.Color.Black; + this.rtLocations.Dock = System.Windows.Forms.DockStyle.Fill; + this.rtLocations.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.rtLocations.ForeColor = System.Drawing.Color.Lime; + this.rtLocations.Location = new System.Drawing.Point(3, 3); + this.rtLocations.Name = "rtLocations"; + this.rtLocations.Size = new System.Drawing.Size(1531, 717); + this.rtLocations.TabIndex = 2; + this.rtLocations.Text = "aaaa"; + // + // tbpMap + // + this.tbpMap.Controls.Add(this.tableLayoutPanel1); + this.tbpMap.Location = new System.Drawing.Point(4, 22); + this.tbpMap.Name = "tbpMap"; + this.tbpMap.Size = new System.Drawing.Size(1537, 723); + this.tbpMap.TabIndex = 3; + this.tbpMap.Text = "Mapper"; + this.tbpMap.UseVisualStyleBackColor = true; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.pnlFunctoids, 0, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1537, 723); + this.tableLayoutPanel1.TabIndex = 1; + // + // pnlFunctoids + // + this.pnlFunctoids.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlFunctoids.Location = new System.Drawing.Point(3, 3); + this.pnlFunctoids.Name = "pnlFunctoids"; + this.pnlFunctoids.Size = new System.Drawing.Size(1531, 662); + this.pnlFunctoids.TabIndex = 0; + this.pnlFunctoids.DragDrop += new System.Windows.Forms.DragEventHandler(this.pnlFunctoids_DragDrop); + this.pnlFunctoids.DragEnter += new System.Windows.Forms.DragEventHandler(this.pnlFunctoids_DragEnter); + // + // trvTarget + // + this.trvTarget.Dock = System.Windows.Forms.DockStyle.Fill; + this.trvTarget.LineColor = System.Drawing.Color.Empty; + this.trvTarget.Location = new System.Drawing.Point(0, 0); + this.trvTarget.Name = "trvTarget"; + this.trvTarget.Size = new System.Drawing.Size(441, 519); + this.trvTarget.TabIndex = 1; + // + // saveFileDialog1 + // + this.saveFileDialog1.DefaultExt = "Save As.."; + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + // + // X12UtilsFRM + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1545, 771); + this.Controls.Add(this.tabControl1); + this.Controls.Add(this.statusStrip1); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "X12UtilsFRM"; + this.Text = "Form1"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.X12UtilsFRM_FormClosing); + this.Load += new System.EventHandler(this.Form1_Load); + this.tabControl1.ResumeLayout(false); + this.parse.ResumeLayout(false); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel1.PerformLayout(); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.grpFileExtensionFilter.ResumeLayout(false); + this.grpFileExtensionFilter.PerformLayout(); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.browser.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); + this.FormLocations.ResumeLayout(false); + this.tbpMap.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage parse; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.TabPage browser; + private System.Windows.Forms.ListBox lbxInfileList; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.Button btnAddFiles; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.Label lblInterchangeCount; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label lblSelectedFile; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.RichTextBox rtxInterchangeFile; + private System.Windows.Forms.WebBrowser webBrowser1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button btnFindSpec; + private System.Windows.Forms.Button btnHippaParse; + private System.Windows.Forms.TabPage FormLocations; + //private NLog.Windows.Forms.RichTextBoxTarget rtLog; + private System.Windows.Forms.RichTextBox rtLog; + private System.Windows.Forms.RichTextBox rtLocations; + private System.Windows.Forms.Button btnMap; + private System.Windows.Forms.TabPage tbpMap; + private System.Windows.Forms.TreeView trvTarget; + private System.Windows.Forms.Panel pnlFunctoids; + private System.Windows.Forms.ListBox lbxTargetSchema; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label lblSaveAs; + private System.Windows.Forms.Label lblSourceFolder; + private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.GroupBox grpFileExtensionFilter; + private System.Windows.Forms.RadioButton rbtfXslt; + private System.Windows.Forms.RadioButton rbtfTxt; + private System.Windows.Forms.RadioButton rbtfXml; + private System.Windows.Forms.RadioButton rbHtml; + private System.Windows.Forms.RadioButton rbXml; + private System.Windows.Forms.Button btnApplyXslt; + private System.Windows.Forms.Button btnParse; + } +} + diff --git a/X12UtilsFRM/X12UtilsFRM.cs b/X12UtilsFRM/X12UtilsFRM.cs new file mode 100644 index 00000000..cc863844 --- /dev/null +++ b/X12UtilsFRM/X12UtilsFRM.cs @@ -0,0 +1,1464 @@ +using NLog; +using NLog.Windows.Forms; +using PdfX.App.Services; +using SkiaSharp; +using SkiaSharp.Views.Desktop; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Xsl; +using X12.Hipaa.Claims; +using X12.Hipaa.Claims.Services; +using X12.Parsing; +using X12.Shared.Models; +using X12.Transformations; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; +using GroupBox = System.Windows.Forms.GroupBox; +using Label = System.Windows.Forms.Label; +using RadioButton = System.Windows.Forms.RadioButton; +using Rectangle = System.Drawing.Rectangle; + +namespace X12UtilsFRM +{ + public enum enmTabPages + { + parse, + browser, + formLocations, + map + } + public partial class X12UtilsFRM : Form + { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private SkiaMapper _mapper; + private List toolboxCategories = new List(); + private Panel pnlToolboxContainer = null; + private Panel pnlToolboxWrapper = null; + private FlowLayoutPanel pnlToolboxCategoriesContainer = null; + private Button btnToolboxToggle = null; + private bool _isToolboxExpanded = true; + private const int ToolboxWidth = 245; + private Button btnToolboxVerticalToggle = null; + private bool _isToolboxExpandedVertical = true; + private int _originalFloatingHeight = 400; // Default expanded height memory + // Draggable capsule tracking properties + private bool _isDraggingToolbox = false; + private Point _toolboxDragStartMousePos; + private Point _toolboxDragStartPanelPos; + private bool _isDraggingFunctoid = false; + private Point _dragStartMousePos; + private Point _dragStartControlPos; + private Form _detachedWorkspaceWindow = null; + private Point _originalPanelLocation; + private Size _originalPanelSize; + private AnchorStyles _originalPanelAnchor; + List interchanges = null; + ToolTip tt = null; + private string locationsFile = ""; + private static readonly string TestImageDirectory = @"..\..\..\tests\X12.Hipaa.Tests.Unit\Claims\TestData\Images\"; + static readonly string pdfOutDirectory = @"C:\Temp\Pdfs"; + public X12UtilsFRM() + { + InitializeComponent(); + + // Instantiate our updated 100% pure Skia layout manager canvas + _mapper = new SkiaMapper(); + _mapper.Dock = DockStyle.Fill; + + if (this.pnlFunctoids != null) + { + this.pnlFunctoids.Controls.Add(_mapper); + _mapper.SendToBack(); + + // Track control resizing changes so the virtual splits adapt smoothly + this.pnlFunctoids.Resize += (s, e) => + { + _mapper.RecalculateVirtualLayout(); + _mapper.Invalidate(); + }; + } + + this.pnlFunctoids.AllowDrop = true; + _mapper.AllowDrop = true; + + // Wire drag-drop routing mechanics onto the primary canvas + _mapper.DragEnter += pnlFunctoids_DragEnter; + _mapper.DragOver += pnlFunctoids_DragEnter; + _mapper.DragDrop += pnlFunctoids_DragDrop; + + SetupListboxContextMenus(); + + + + } + private static void Log(String s, [CallerMemberName] string cn = "", [CallerLineNumber] int ln = 0, [CallerFilePath] string fp = "") + { + Trace.WriteLine($"{DateTime.Now.ToString()}-{cn}@{fp.Substring(fp.LastIndexOf('\\') + 1)}:{ln}:{s}"); + Trace.Flush(); + } + #region Toolbox Implementation + private void InitializeToolbox() + { + _originalFloatingHeight = pnlFunctoids.Height - 40; + + // Create the main workspace panel frame block + pnlToolboxWrapper = new Panel + { + Width = ToolboxWidth + 20, + Height = _originalFloatingHeight, + Location = new Point(pnlFunctoids.Width - (ToolboxWidth + 40), 20), + BackColor = Color.FromArgb(235, 240, 250), + BorderStyle = BorderStyle.FixedSingle + }; + pnlFunctoids.Controls.Add(pnlToolboxWrapper); + pnlToolboxWrapper.BringToFront(); + + // 1. The "Functoids" Top Header Title Strip + Panel pnlHeaderBar = new Panel + { + Height = 25, + Dock = DockStyle.Top, + BackColor = Color.FromArgb(220, 225, 235) + }; + pnlToolboxWrapper.Controls.Add(pnlHeaderBar); + + // 2. The Vertical Toggle Button placed directly onto the right side of the HeaderBar + #region vertical toggle button + btnToolboxVerticalToggle = new Button + { + Text = "▲", + Font = new Font("Segoe UI", 7, FontStyle.Bold), + Size = new Size(22, 21), + // Position it on the far right of the header bar with a small 2px padding offset + Location = new Point(pnlToolboxWrapper.Width - 26, 2), + FlatStyle = FlatStyle.Popup, + BackColor = Color.FromArgb(195, 200, 215), + ForeColor = Color.FromArgb(50, 50, 80), + Cursor = Cursors.Hand, + Anchor = AnchorStyles.Top | AnchorStyles.Right + }; + btnToolboxVerticalToggle.FlatAppearance.BorderSize = 0; + btnToolboxVerticalToggle.Click += ToggleToolboxVertical_Click; + pnlHeaderBar.Controls.Add(btnToolboxVerticalToggle); + #endregion vertical toggle button + + pnlHeaderBar.Paint += (sender, e) => // Handle title text and icon drawing manually via GDI+ to Skia bridging + { + var info = new SKImageInfo(pnlHeaderBar.Width, pnlHeaderBar.Height); + using (var surface = SKSurface.Create(info)) + { + SKCanvas canvas = surface.Canvas; + canvas.Clear(Color.FromArgb(220, 225, 235).ToSKColor()); + + // Define position parameters for our custom vector icon + SKPoint iconPosition = new SKPoint(15, pnlHeaderBar.Height / 2f); + float iconSize = 12f; + SKColor iconColor = Color.Red.ToSKColor(); + + // Call the vector method we placed in SkiaMapper + SkiaMapper.DrawToolboxIcon(canvas, iconPosition, iconSize, iconColor); + + // Draw the "Functoids" text next to the icon manually + using (var textPaint = new SKPaint { Color = iconColor, IsAntialias = true }) + using (var textFont = new SKFont(SKTypeface.FromFamilyName("Segoe UI", SKFontStyle.Bold), 12)) + { + canvas.DrawText("Functoids & Tools", 28, (pnlHeaderBar.Height / 2f) + 4.5f, textFont, textPaint); + } + + canvas.Flush(); + using (var snapshot = surface.Snapshot()) + using (var bitmap = snapshot.ToBitmap()) + { + e.Graphics.DrawImage(bitmap, 0, 0); + } + } + }; + // bottom tool bar with action buttons + int bButtonRows = 2; // bottom button rows + int buttonWidth = (ToolboxWidth - 10) / 2; + int buttonHeight = 30; + + Panel pnlCanvasToolsBottomBar = new Panel + { + Dock = DockStyle.Bottom, + Height = 100, + BackColor = Color.FromArgb(225, 230, 245), + Padding = new Padding(10, 6, 10, 6), + BorderStyle = BorderStyle.None + }; + pnlCanvasToolsBottomBar.Paint += (s, e) => + { + using (var pen = new Pen(Color.FromArgb(190, 200, 220), 1)) + { + e.Graphics.DrawLine(pen, 0, 0, pnlCanvasToolsBottomBar.Width, 0); + } + }; + + Button btnClearCanvas = new Button { + Text = "Clear Canvas", + Size = new Size(buttonWidth, buttonHeight), + Location = new Point(10, 6), + FlatStyle = FlatStyle.Popup, + BackColor = Color.FromArgb(210, 220, 240), + Font = new Font("Segoe UI", 9, FontStyle.Regular), + Cursor = Cursors.Hand + }; + btnClearCanvas.Click += btnClearCanvas_Click; + + Button btnSave = new Button { + Text = "Save", + Size = new Size(buttonWidth, buttonHeight), + Location = new Point(15 + buttonWidth, 6), + FlatStyle = FlatStyle.Popup, + BackColor = Color.FromArgb(210, 220, 240), + Font = new Font("Segoe UI", 9, FontStyle.Regular), + Cursor = Cursors.Hand + }; + btnSave.Click += btnSaveCanvas_Click; + + + Button btnTransform = new Button { + Text = "Transform", + Size = new Size(buttonWidth, 32), + Location = new Point(10, 10 + (buttonHeight)), + FlatStyle = FlatStyle.Popup, + BackColor = Color.FromArgb(210, 220, 240), + Font = new Font("Segoe UI", 9, FontStyle.Regular), + Cursor = Cursors.Hand + }; + btnTransform.Click += btnGenerateXsltFromCanvas_Click; + + Button btnLoadCanvas = new Button { + Text = "Load Canvas", + Size = new Size(buttonWidth, buttonHeight), + Location = new Point(15 + buttonWidth, 10 + buttonHeight), + FlatStyle = FlatStyle.Popup, + BackColor = Color.FromArgb(210, 220, 240), + Font = new Font("Segoe UI", 9, FontStyle.Regular), + Cursor = Cursors.Hand + }; + btnLoadCanvas.Click += btnLoadCanvas_Click; + + + + + + + + pnlCanvasToolsBottomBar.Controls.Add(btnClearCanvas); + pnlCanvasToolsBottomBar.Controls.Add(btnTransform); + pnlCanvasToolsBottomBar.Controls.Add(btnSave); + pnlCanvasToolsBottomBar.Controls.Add(btnLoadCanvas); + pnlToolboxWrapper.Controls.Add(pnlCanvasToolsBottomBar); + + // 4. Create the main categories scroll container view (Fills remaining space) + pnlToolboxCategoriesContainer = new FlowLayoutPanel + { + Dock = DockStyle.Fill, + BackColor = Color.Transparent, + FlowDirection = FlowDirection.TopDown, + WrapContents = false, + AutoScroll = true, + Margin = new Padding(0, 5, 0, 0), + Padding = new Padding(10, 18, 18, 10) + }; + pnlToolboxWrapper.Controls.Add(pnlToolboxCategoriesContainer); + + // Ensure all components maintain correct Z-order layering inside the wrapper frame + // To prevent layout overlap during minimization, the Fill container must live at the + // bottom of the Z-order stack so Top/Bottom docked components overlay cleanly on top of it. + pnlToolboxCategoriesContainer.SendToBack(); + pnlCanvasToolsBottomBar.BringToFront(); + pnlHeaderBar.BringToFront(); + + // Tie movement drag actions onto the header bar background layer + AttachToolboxDragEvents(pnlHeaderBar); + + var stringTools = new List { "Concatenate", "String Left", "String Right", "Trim", "Uppercase", "Lowercase" }; + var mathTools = new List { "Add", "Subtract", "Multiply", "Divide", "Modulus", "Absolute" }; + var dateTools = new List { "Current Date", "Date Format", "Add Days", "Date Diff" }; + + Action triggerLayoutUpdate = () => { RenderToolboxLayout(); }; + + toolboxCategories.Clear(); + toolboxCategories.Add(new ToolboxCategory("String Functoids", stringTools, triggerLayoutUpdate)); + toolboxCategories.Add(new ToolboxCategory("Mathematical Tools", mathTools, triggerLayoutUpdate)); + toolboxCategories.Add(new ToolboxCategory("Date / Time Utilities", dateTools, triggerLayoutUpdate)); + + RenderToolboxLayout(); + } + private void ToggleToolboxVertical_Click(object sender, EventArgs e) + { + // If the palette is fully collapsed horizontally, ignore vertical commands + if (!_isToolboxExpanded) return; + + _isToolboxExpandedVertical = !_isToolboxExpandedVertical; + pnlFunctoids.SuspendLayout(); + + // Extract the header and bottom bar components safely from the wrapper + Control pnlHeader = pnlToolboxWrapper.Controls.Cast().FirstOrDefault(c => c.Dock == DockStyle.Top); + Control pnlBottomBar = pnlToolboxWrapper.Controls.Cast().FirstOrDefault(c => c.Dock == DockStyle.Bottom); + + int headerHeight = pnlHeader?.Height ?? 25; + int bottomBarHeight = pnlBottomBar?.Height ?? 45; + int topMarginOffset = pnlBottomBar?.Margin.Top ?? 8; + + if (_isToolboxExpandedVertical) + { + // Restore height back out to our expanded memory size state + pnlToolboxWrapper.Height = _originalFloatingHeight; + pnlToolboxCategoriesContainer.Visible = true; + btnToolboxVerticalToggle.Text = "▲"; + } + else + { + // Save the current height dynamically before crushing it down (in case the user resized the form) + // Keep threshold slightly above the dynamic collapsed height calculation + int minimumCollapsedHeight = headerHeight + bottomBarHeight + topMarginOffset; + + if (pnlToolboxWrapper.Height > minimumCollapsedHeight + 20) + { + _originalFloatingHeight = pnlToolboxWrapper.Height; + } + + // Drop the central scrolling categories out of layout calculation completely + pnlToolboxCategoriesContainer.Visible = false; + + // Collapse down precisely matching the visible elements + the structural margin spring + pnlToolboxWrapper.Height = minimumCollapsedHeight; + btnToolboxVerticalToggle.Text = "▼"; + } + + // Force the wrapper container block to evaluate layout rules and enforce spacing margins + pnlToolboxWrapper.PerformLayout(); + pnlFunctoids.ResumeLayout(true); + _mapper.Invalidate(); + } + + private void btnClearCanvas_Click(object sender, EventArgs e) + { + DialogResult result = MessageBox.Show( + "Are you sure you want to clear the entire canvas? This will delete all functoids and connection wires.", + "Clear Canvas", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning + ); + + if (result == DialogResult.Yes) + { + // 2. Erase the connection data collection lines + _mapper.ClearAllConnections(); + + // 3. Scan the UI collection and purge temporary Functoid controls safely + // Loop backwards to safely delete controls while modifying the collection + for (int i = pnlFunctoids.Controls.Count - 1; i >= 0; i--) + { + Control ctrl = pnlFunctoids.Controls[i]; + + // Check if it's a dynamic functoid capsule (and not the underlying SkiaMapper canvas itself) + if (ctrl is BizTalkFunctoidNode) + { + pnlFunctoids.Controls.RemoveAt(i); + ctrl.Dispose(); // Free system layout memory resources instantly + } + } + + Logger.Info("Master canvas layout workspace resetting completed."); + } + + + } + + private dynamic FindNodeByXPath(IEnumerable schemaRegistry, string xpath) + { + var generator = new XsltMapGenerator(_mapper); + foreach (var nodeItem in schemaRegistry) + { + XmlNode xmlNode = nodeItem is XmlNode node ? node : nodeItem.XmlSourceNode; + if (xmlNode != null) + { + // Internal path matching wrapper + string computedPath = generator.GetNodePathForLookup(xmlNode); + if (computedPath == xpath) + { + return nodeItem; + } + } + } + return null; + } + + private void btnLoadCanvas_Click(object sender, EventArgs e) + { + using (OpenFileDialog ofd = new OpenFileDialog()) + { + ofd.Filter = "Mapping Layout Files (*.map.json)|*.map.json"; + + if (ofd.ShowDialog() == DialogResult.OK) + { + string jsonRaw = File.ReadAllText(ofd.FileName); + var savedState = System.Text.Json.JsonSerializer.Deserialize(jsonRaw); + + // 1. Clear active connections and existing manual functoids from canvas + _mapper.Connections.Clear(); + + // Clean up old visual functoid controls if your mapper holds a separate list + // _mapper.Functoids?.Clear(); + + // Track newly generated functoids mapped from their JSON layout coordinate string "X_Y" + var runtimeFunctoidRegistry = new Dictionary(); + + // 2. Rehydrate and spawn Functoid nodes onto the canvas interface + foreach (var f in savedState.Functoids) + { + Control newFunctoid = CreateFunctoid(f.FunctoidName, new System.Drawing.Point((int)f.X, (int)f.Y)); + + // CRITICAL FIX: Mount the control physically onto the WinForms Canvas Surface Container! + pnlFunctoids.Controls.Add(newFunctoid); + newFunctoid.BringToFront(); + + // Map the original file ID token to this live runtime instance pointer + runtimeFunctoidRegistry[f.Id] = newFunctoid; + } + + // 3. Reconnect Wires + foreach (var wire in savedState.Wires) + { + dynamic sourcePointer = null; + dynamic targetPointer = null; + + // Resolve Source Pointer + if (wire.SourceType == "SchemaNode") + { + // Find matching node inside left schema tree via XPath helper + sourcePointer = FindNodeByXPath(_mapper.FlatSchemaRegistry, wire.SourceIdOrXPath); + } + else if (wire.SourceType == "Functoid") + { + runtimeFunctoidRegistry.TryGetValue(wire.SourceIdOrXPath, out sourcePointer); + } + + // Resolve Target Pointer + if (wire.TargetType == "SchemaNode") + { + // Find matching node inside right schema tree via XPath helper + targetPointer = FindNodeByXPath(_mapper.FlatTargetSchemaRegistry, wire.TargetIdOrXPath); + } + else if (wire.TargetType == "Functoid") + { + runtimeFunctoidRegistry.TryGetValue(wire.TargetIdOrXPath, out targetPointer); + } + + // 4. Append wire connection link if both ends were successfully resolved + if (sourcePointer != null && targetPointer != null) + { + // Create connection structure match matching your canvas model definition + // ❌ ERROR LINE + // _mapper.Connections.Add(new ConnectionItem(sourcePointer, targetPointer)); + _mapper.Connections.Add(new MappingConnection { Source = sourcePointer, Target = targetPointer }); + } + } + + // If your _mapper object handles the canvas lifecycle UI itself: + _mapper.Invalidate(); + // 5. Explicitly force the Skia Graphics Canvas control to refresh and repaint the connections + // skiaControl.Invalidate(); + + MessageBox.Show("Canvas wire layouts successfully loaded and re-drawn!", "State Restored"); + } + } + } + + private void ToggleToolbox_Click(object sender, EventArgs e) + { + _isToolboxExpanded = !_isToolboxExpanded; + pnlFunctoids.SuspendLayout(); + + if (_isToolboxExpanded) + { + pnlToolboxWrapper.Width = ToolboxWidth + 20; + btnToolboxVerticalToggle.Visible = true; // Show vertical control strip option back + + // Respect the current vertical state profile + pnlToolboxCategoriesContainer.Visible = _isToolboxExpandedVertical; + pnlToolboxWrapper.Height = _isToolboxExpandedVertical ? _originalFloatingHeight : 52; + + btnToolboxToggle.Text = "»"; + RenderToolboxLayout(); + } + else + { + // Minimize completely into a sleek sidebar profile line + pnlToolboxCategoriesContainer.Visible = false; + btnToolboxVerticalToggle.Visible = false; // Hide vertical arrow + pnlToolboxWrapper.Width = btnToolboxToggle.Width; + pnlToolboxWrapper.Height = 25; // Just high enough for the single << character button + btnToolboxToggle.Text = "«"; + } + + pnlFunctoids.ResumeLayout(true); + _mapper.Invalidate(); + } + private void AttachToolboxDragEvents(Control dragHandle) + { + dragHandle.MouseDown += (sender, e) => + { + if (e.Button == MouseButtons.Left) + { + _isDraggingToolbox = true; + _toolboxDragStartMousePos = Cursor.Position; + _toolboxDragStartPanelPos = pnlToolboxWrapper.Location; + pnlToolboxWrapper.BringToFront(); + } + }; + dragHandle.MouseMove += (sender, e) => + { + if (_isDraggingToolbox) + { + int deltaX = Cursor.Position.X - _toolboxDragStartMousePos.X; + int deltaY = Cursor.Position.Y - _toolboxDragStartMousePos.Y; + int newX = _toolboxDragStartPanelPos.X + deltaX; + int newY = _toolboxDragStartPanelPos.Y + deltaY; + if (pnlFunctoids != null)// Optional: Clamp the toolbox so it can't be dragged completely off screen edges + { + newX = Math.Max(0, Math.Min(newX, pnlFunctoids.Width - pnlToolboxWrapper.Width)); + newY = Math.Max(0, Math.Min(newY, pnlFunctoids.Height - 30)); + } + pnlToolboxWrapper.Location = new Point(newX, newY); + _mapper.Invalidate(); // Refresh lines to redraw cleanly around it + } + }; + dragHandle.MouseUp += (sender, e) => + { + if (e.Button == MouseButtons.Left) + { + _isDraggingToolbox = false; + } + }; + } + private void RenderToolboxLayout() + { + if (pnlToolboxCategoriesContainer == null) return; + pnlToolboxCategoriesContainer.SuspendLayout(); + pnlToolboxCategoriesContainer.Controls.Clear(); + foreach (var category in toolboxCategories) + { + category.Width = 205; + category.UpdateHeight(); + category.Margin = new Padding(6, 0, 0, 6); + pnlToolboxCategoriesContainer.Controls.Add(category); + } + pnlToolboxCategoriesContainer.ResumeLayout(true); + } + #endregion + #region Drag and Drop Handling Logic + private void ToggleWorkspaceDetachment() + { + // If the workspace isn't detached yet, pop it out into its own separate OS window + if (_detachedWorkspaceWindow == null) + { + // 1. Cache the original layout positions so we can restore them cleanly later + _originalPanelLocation = pnlFunctoids.Location; + _originalPanelSize = pnlFunctoids.Size; + _originalPanelAnchor = pnlFunctoids.Anchor; + + // 2. Instantiate a brand new tool window container frame + _detachedWorkspaceWindow = new Form + { + Text = "X12 Schema Mapping Studio - Detached Workspace", + Size = new Size(1200, 800), + StartPosition = FormStartPosition.CenterScreen, + FormBorderStyle = FormBorderStyle.SizableToolWindow, // Gives it a clean tool panel border + MinimizeBox = false + }; + + // Ensure that if the developer clicks the "X" button on the floating window, + // it intercepts destruction and re-docks itself back to the parent form safely. + _detachedWorkspaceWindow.FormClosing += (s, e) => + { + if (e.CloseReason == CloseReason.UserClosing) + { + e.Cancel = true; // Abort form disposal + ReDockWorkspaceToMainForm(); + } + }; + + // 3. Tear the workspace out of the primary main form control tree + this.Controls.Remove(pnlFunctoids); + + // 4. Mount it into the detached window container frame + _detachedWorkspaceWindow.Controls.Add(pnlFunctoids); + pnlFunctoids.Dock = DockStyle.Fill; // Let it expand to the whole size of the window + + // 5. Display the window to the user (passing 'this' keeps it grouped on top of the app) + _detachedWorkspaceWindow.Show(this); + + // 6. Force Skia to recalculate boundaries based on the new dimensions + _mapper.RecalculateVirtualLayout(); + _mapper.Invalidate(); + } + else + { + // If it's already detached, call the reverse re-dock method + ReDockWorkspaceToMainForm(); + } + } + private void ReDockWorkspaceToMainForm() + { + if (_detachedWorkspaceWindow != null) + { + // 1. Strip the panel out of the detached floating frame container + _detachedWorkspaceWindow.Controls.Remove(pnlFunctoids); + + // 2. Destroy the temporary floating form window frame manager safely + _detachedWorkspaceWindow.Dispose(); + _detachedWorkspaceWindow = null; + + // 3. Restore the panel control back into its original spot on the main app form + pnlFunctoids.Dock = DockStyle.None; + pnlFunctoids.Location = _originalPanelLocation; + pnlFunctoids.Size = _originalPanelSize; + pnlFunctoids.Anchor = _originalPanelAnchor; + + this.Controls.Add(pnlFunctoids); + pnlFunctoids.BringToFront(); + + // 4. Refresh the virtual split positions + _mapper.RecalculateVirtualLayout(); + _mapper.Invalidate(); + } + } + private void MakeControlDraggable(Control masterControl) + { + AttachDragEvents(masterControl, masterControl); + foreach (Control child in masterControl.Controls) + { + AttachDragEvents(child, masterControl); + } + } + private void AttachDragEvents(Control eventTriggerControl, Control actualMovingTarget) + { + eventTriggerControl.MouseDown += (sender, e) => + { + if (e.Button == MouseButtons.Left) + { + if (Control.ModifierKeys == Keys.Shift) return; + + _isDraggingFunctoid = true; + _dragStartMousePos = Cursor.Position; + _dragStartControlPos = actualMovingTarget.Location; + actualMovingTarget.BringToFront(); + } + }; + + eventTriggerControl.MouseMove += (sender, e) => + { + if (Control.ModifierKeys == Keys.Shift) + { + _isDraggingFunctoid = false; + return; + } + + if (_isDraggingFunctoid) + { + int deltaX = Cursor.Position.X - _dragStartMousePos.X; + int deltaY = Cursor.Position.Y - _dragStartMousePos.Y; + + actualMovingTarget.Location = new Point( + _dragStartControlPos.X + deltaX, + _dragStartControlPos.Y + deltaY + ); + + _mapper.Invalidate(); + } + }; + + eventTriggerControl.MouseUp += (sender, e) => + { + if (e.Button == MouseButtons.Left) + { + _isDraggingFunctoid = false; + } + }; + } + #endregion + #region Embedded Schema Virtual Setup + private void InitializeEmbeddedSchemaLayout(string sourceXmlPath, string targetXmlPath) + { + // Clear connections and bind data directly into the background Skia registries + _mapper.Connections.Clear(); + _mapper.FlatSchemaRegistry.Clear(); + _mapper.FlatTargetSchemaRegistry.Clear(); + + // Set up default initial coordinate divisions + float initialWidth = pnlFunctoids.Width; + _mapper.RecalculateVirtualLayout(); + + // Load Source XML Data Tree Structures straight to data variables + XmlDocument sourceDoc = new XmlDocument(); + sourceDoc.Load(sourceXmlPath); + BuildCustomSchemaTree(sourceDoc.DocumentElement, 0, isTargetSchema: false); + + // Load Target XML Data Tree Structures straight to data variables + XmlDocument targetDoc = new XmlDocument(); + targetDoc.Load(targetXmlPath); + BuildCustomSchemaTree(targetDoc.DocumentElement, 0, isTargetSchema: true); + + InitializeToolbox(); + _mapper.Invalidate(); + } + private void BuildCustomSchemaTree(XmlNode node, int depth, bool isTargetSchema) + { + if (node == null) return; + + SchemaNodeItem item = new SchemaNodeItem(node, depth, (clickedItem) => + { + _mapper.Invalidate(); // Redraw vector elements cleanly + }); + + if (isTargetSchema) + { + _mapper.FlatTargetSchemaRegistry.Add(item); + } + else + { + _mapper.FlatSchemaRegistry.Add(item); + } + + if (node.Attributes != null) + { + foreach (XmlAttribute attr in node.Attributes) + { + BuildCustomSchemaTree(attr, depth + 1, isTargetSchema); + } + } + + foreach (XmlNode child in node.ChildNodes) + { + if (child.NodeType == XmlNodeType.Element) + { + BuildCustomSchemaTree(child, depth + 1, isTargetSchema); + } + } + } + #endregion + #region Form Controls & Life Cycle + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + RichTextBoxTarget.ReInitializeAllTextboxes(this); + Logger.Info("RichTextBox target initialized successfully."); + } + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + RichTextBoxTarget.ReInitializeAllTextboxes(this); + Logger.Info("RichTextBox logging attached (UI-safe)."); + } + + private void PopulateFileList(string folderPath) + { + if (Directory.Exists(folderPath)) + { + lbxInfileList.Items.Clear(); + lbxInfileList.Items.AddRange(Directory.GetFiles(folderPath, "*.txt")); + lbxInfileList.Items.AddRange(Directory.GetFiles(folderPath, "*.xml")); + lbxInfileList.Items.AddRange(Directory.GetFiles(folderPath, "*.xslt")); + } + else + { + MessageBox.Show($"The specified folder path does not exist: {folderPath}", "Folder Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void Form1_Load(object sender, EventArgs e) + { + + tt = new ToolTip(); + tt.SetToolTip(btnAddFiles, $"Import X12 Inbound files from {Properties.Settings.Default.X12Folder}"); + + if (string.IsNullOrEmpty(Properties.Settings.Default.fileList)) + { + btnAddFiles_Click(null, null); + } + lbxInfileList.Items.AddRange(Properties.Settings.Default.fileList.Split(',')); + lbxTargetSchema.Items.AddRange(Properties.Settings.Default.fileList.Split(',')); + + lbxInfileList.SelectedIndex = Properties.Settings.Default.SelectedInfile; + lbxTargetSchema.SelectedIndex = Properties.Settings.Default.SelectedTargetSchema; + //lbxTargetSchema.SelectedIndex = 5; + + lblSourceFolder.Text = $"Source Folder: {Properties.Settings.Default.X12Folder} (..)"; + + btnParse.Enabled = false; + } + private void X12UtilsFRM_FormClosing(object sender, FormClosingEventArgs e) + { + Properties.Settings.Default.Save(); + } + #endregion + #region File Processing Actions + private void btnMap_Click(object sender, EventArgs e) + { + string inputFileName = lbxInfileList.Text; + string outputFileName = lbxTargetSchema.Text; + + if (string.IsNullOrEmpty(inputFileName) || string.IsNullOrEmpty(outputFileName)) + { + MessageBox.Show("Please select both source and target XML files for mapping."); + return; + } + + if (Path.GetExtension(inputFileName) != ".xml") + { + MessageBox.Show("File extension must be an XML"); + return; + } + + tabControl1.SelectedIndex = (int)enmTabPages.map; + InitializeEmbeddedSchemaLayout(inputFileName, outputFileName); + } + private void parser_ParserWarning(object sender, X12ParserWarningEventArgs args) + { + Logger.Info($"IC#={args.InterchangeControlNumber}-FG={args.FunctionalGroupControlNumber}-Segment={args.Segment}{args.Message}"); + } + private (string Text, bool IsChecked) checkedOption(GroupBox grp) + { + var checkedControl = grp.Controls.Cast().FirstOrDefault(c => ((dynamic)c).Checked == true); + if (checkedControl != null) + { + Logger.Info($"Found control type: {checkedControl.Name}"); + return (checkedControl.Text, true); + } + else return (null, false); + + + } + private void btnParse_Click(object sender, EventArgs e) + { + string x = ""; + var (_checkedOption, isChecked) = checkedOption(groupBox1); + + try + { + switch (_checkedOption) + { + //case "HTML": x = X12Tohtml(rtxInterchangeFile.Text); break; + case "HTML": rtxInterchangeFile.Text = ContentFromFile(lbxInfileList.Text); x = X12Tohtml(rtxInterchangeFile.Text); break; + case "XML": + rtxInterchangeFile.Text = ContentFromFile(lbxInfileList.Text); + X12.Parsing.X12Parser parser = new X12.Parsing.X12Parser(new x12Test.specFinder(), true); + parser.ParserWarning += new X12.Parsing.X12Parser.X12ParserWarningEventHandler(parser_ParserWarning); + interchanges = parser.ParseMultiple(rtxInterchangeFile.Text); + x = X12ToXml(rtxInterchangeFile.Text); + break; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + return; + } + DisplayHtml(_checkedOption); + tabControl1.SelectedIndex = (int)enmTabPages.browser; + } + + public string X12Tohtml(string x12) + { + var htmlService = new X12HtmlTransformationService(new X12EdiParsingService(Properties.Settings.Default.SurppressParsingComments, new x12Test.specFinder())); + return htmlService.Transform(x12); + } + public string X12ToXml(string x12) + { + if (string.IsNullOrEmpty(x12)) return string.Empty; + + using (MemoryStream memStream = new MemoryStream(1000)) + { + interchanges.First().Serialize(memStream); + memStream.Seek(0, 0); + StreamReader sr = new StreamReader(memStream); + return sr.ReadToEnd(); + } + } + private void DisplayHtml(string html) + { + webBrowser1.Navigate("about:blank"); + webBrowser1.AllowWebBrowserDrop = false; + webBrowser1.AllowNavigation = false; + + try + { + if (webBrowser1.Document != null) webBrowser1.Document.Write(string.Empty); + } + catch { } + webBrowser1.DocumentText = html; + webBrowser1.AllowNavigation = true; + } + private void btnAddFiles_Click(object sender, EventArgs e) + { + lbxInfileList.Items.Clear(); + lbxInfileList.Items.AddRange(Directory.GetFiles(Properties.Settings.Default.X12Folder, "*.txt")); + lbxInfileList.Items.AddRange(Directory.GetFiles(Properties.Settings.Default.X12Folder, "*.xml")); + string[] ss = new string[lbxInfileList.Items.Count]; + lbxInfileList.Items.CopyTo(ss, 0); + Properties.Settings.Default.fileList = string.Join(",", ss); + Properties.Settings.Default.Save(); + } + private void btnFindSpec_Click(object sender, EventArgs e) + { + var finder = new x12Test.specFinder(); + var spec = finder.FindTransactionSpec("SH", "005010X222A1", "856"); + Logger.Info($"Spec Found for 856: {spec?.Name}"); + + Logger.Trace("Trace message"); + Logger.Debug("Debug message"); + Logger.Info("Info message"); + Logger.Warn("Warning message"); + Logger.Error("Error message"); + Logger.Fatal("Fatal message"); + + if (spec != null) + { + + MessageBox.Show($"Spec Found for 856: {spec.Name}"); + } + else + { + MessageBox.Show($"Spec Not Found for 856"); + } + } + #endregion + #region Functional Canvas Drag-Drop Core Engine + private Control ResolveActualTargetNode(Control control, Point clientPt) + { + if (control == null) return null; + + // If dropping directly onto the Skia background surface, check if a physical + // Functoid control is sitting underneath the cursor coordinates + if (control is SkiaMapper) + { + foreach (Control c in pnlFunctoids.Controls) + { + // Skip the background mapper canvas itself and the toolbox wrapper + if (c != _mapper && c != pnlToolboxWrapper && c.Bounds.Contains(clientPt)) + { + return ResolveActualTargetNode(c, clientPt); + } + } + + // If it hits empty canvas space, return the mapper itself as a valid placement target + return _mapper; + } + + // Handle dropping onto nested child components inside an existing Functoid capsule + if (control.Parent is BizTalkFunctoidNode targetCapsule) return targetCapsule; + if (control is BizTalkFunctoidNode) return control; + + return control; + } + private void pnlFunctoids_DragDrop(object sender, DragEventArgs e) + { + // 1. Calculate drop coordinates relative to the central pnlFunctoids working area + Point clientPoint = pnlFunctoids.PointToClient(new Point(e.X, e.Y)); + Control rawTarget = pnlFunctoids.GetChildAtPoint(clientPoint); + Control targetControl = ResolveActualTargetNode(rawTarget, clientPoint); + + // Block drops completely if they clip over the right-hand toolbox panel boundaries + if (targetControl == pnlToolboxWrapper || targetControl == pnlToolboxCategoriesContainer || targetControl == btnToolboxToggle) + return; + + object connectionSource = null; + bool isSourceANode = false; + + // --- 2. EXTRACT SOURCE DATA PAYLOAD --- + if (e.Data.GetDataPresent(typeof(TreeNode))) + { + TreeNode sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); + if (sourceNode != null) + { + // If dragging an abstract template item from the toolbox, spawn a new functoid control + if (sourceNode.Tag as string == "FUNCTOID_TEMPLATE") + { + Control customFunctoidBlock = CreateFunctoid(sourceNode.Text, clientPoint); + pnlFunctoids.Controls.Add(customFunctoidBlock); + customFunctoidBlock.BringToFront(); + _mapper.Invalidate(); + return; + } + + // If it's a virtual schema node payload generated by our SkiaMapper + if (sourceNode.Tag is XmlNode realXmlNode) + { + connectionSource = realXmlNode; + isSourceANode = true; + } + } + } + else if (e.Data.GetDataPresent(typeof(BizTalkFunctoidNode))) + { + // Source is an existing central functoid capsule being dragged to form a link + connectionSource = e.Data.GetData(typeof(BizTalkFunctoidNode)) as BizTalkFunctoidNode; + } + + // --- 3. PROCESS PATH CONNECTIONS --- + if (connectionSource != null) + { + // Determine if this XML node belongs to the destination target schema registry + bool isRightPanelNode = isSourceANode && _mapper.FlatTargetSchemaRegistry.Any(sni => sni.XmlSourceNode == (XmlNode)connectionSource); + + if (isRightPanelNode) + { + // Reverse Drop Rule: If dragged from Right Schema onto a Functoid, link Functoid -> Schema Node + if (targetControl is BizTalkFunctoidNode functoid) + { + if (!_mapper.Connections.Exists(c => c.Source == functoid && c.Target == connectionSource)) + { + _mapper.Connections.Add(new MappingConnection { Source = functoid, Target = connectionSource }); + } + _mapper.Invalidate(); + } + return; + } + + // Standard Flow: Left panel schema node or center functoid dragging towards something else + if (targetControl != null && targetControl != connectionSource) + { + // Scenario A: Dropping onto a center functoid control capsule + if (targetControl is BizTalkFunctoidNode) + { + if (!_mapper.Connections.Exists(c => c.Source == connectionSource && c.Target == targetControl)) + { + _mapper.Connections.Add(new MappingConnection { Source = connectionSource, Target = targetControl }); + } + _mapper.Invalidate(); + } + // Scenario B: Dropping onto empty space on the SkiaMapper background canvas + else if (targetControl is SkiaMapper && isSourceANode) + { + // If a source node is dropped into empty gray space, auto-generate a new intermediate functoid capsule + Control autoFunctoid = CreateFunctoid(((XmlNode)connectionSource).Name, clientPoint); + pnlFunctoids.Controls.Add(autoFunctoid); + autoFunctoid.BringToFront(); + + _mapper.Connections.Add(new MappingConnection + { + Source = connectionSource, + Target = autoFunctoid + }); + _mapper.Invalidate(); + } + } + } + } + private void pnlFunctoids_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(typeof(TreeNode)) || e.Data.GetDataPresent(typeof(BizTalkFunctoidNode))) + { + e.Effect = DragDropEffects.Copy | DragDropEffects.Link; + } + else + { + e.Effect = DragDropEffects.None; + } + } + private Control CreateFunctoid(string text, Point location) + { + BizTalkFunctoidNode functoidNode = new BizTalkFunctoidNode(text, location); + MakeControlDraggable(functoidNode); + + ContextMenuStrip functoidMenu = new ContextMenuStrip(); + var editScriptItem = new ToolStripMenuItem("Configure Script Properties..."); + editScriptItem.Click += (sender, e) => + { + using (var editorDlg = new FunctoidScriptEditorForm(functoidNode.FunctoidName, functoidNode.CustomScript)) + { + if (editorDlg.ShowDialog(this) == DialogResult.OK) + { + functoidNode.CustomScript = editorDlg.CompiledScriptText; + } + } + }; + functoidMenu.Items.Add(editScriptItem); + functoidMenu.Items.Add(new ToolStripSeparator()); + + var deleteItem = new ToolStripMenuItem("Delete Functoid"); + deleteItem.Click += (sender, e) => + { + _mapper.Connections.RemoveAll(conn => conn.Target == functoidNode || conn.Source == functoidNode); + pnlFunctoids.Controls.Remove(functoidNode); + functoidNode.Dispose(); + _mapper.Invalidate(); + }; + functoidMenu.Items.Add(deleteItem); + + functoidNode.ContextMenuStrip = functoidMenu; + functoidNode.LblIcon.ContextMenuStrip = functoidMenu; + functoidNode.LblText.ContextMenuStrip = functoidMenu; + + return functoidNode; + } + #endregion + #region Code Compilation Utilities (Xslt Outbound Maps) + #endregion + + + + private void btnSaveCanvas_Click(object sender, EventArgs e) + { + using (SaveFileDialog sfd = new SaveFileDialog()) + { + sfd.Filter = "Mapping Layout Files (*.map.json)|*.map.json"; + sfd.Title = "Save Canvas Workflow State"; + + if (sfd.ShowDialog() == DialogResult.OK) + { + var generator = new XsltMapGenerator(_mapper); + + // Saves the visual structural nodes out as JSON mapping rules + generator.SaveCanvasLayout(sfd.FileName, lbxInfileList.Text, "TargetSchema.xsd"); + MessageBox.Show("Canvas layout snapshot preserved successfully!", "State Saved"); + } + } + } + private void btnHippaParse_Click(object sender, EventArgs e) { } + private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + { + enmTabPages currentTab = (enmTabPages)tabControl1.SelectedIndex; + switch (currentTab) + { + case enmTabPages.parse: + // Action when user switches to the Parse tab + Log("Switched to Parse tab."); + // e.g., Refresh file list or reset parsing states if needed + break; + + case enmTabPages.browser: + // Action when user switches to the Browser tab + Log("Switched to Browser tab."); + // e.g., Ensure a document is loaded or focus the webBrowser1 control + lblSaveAs.Text = lbxInfileList.Text; + //using (SaveFileDialog saveFileDialog = new SaveFileDialog()) + //{ + // saveFileDialog.InitialDirectory = Path.GetDirectoryName(lbxInfileList.Text); + // webBrowser1.ShowSaveAsDialog(); + //} + webBrowser1.Focus(); + break; + + default: + Log($"Unknown tab index: {tabControl1.SelectedIndex}"); + break; + } + + } + private void lblInterchangeCount_TextChanged(object sender, EventArgs e) + { + int fcount = int.Parse(((Label)sender).Text); + btnParse.Enabled = fcount == 1 ? true : false; + } + + public void LinkXsltToSourceXmlFile(string sourceXmlPath, string xsltFilePath) + { + if (string.IsNullOrEmpty(sourceXmlPath) || !File.Exists(sourceXmlPath)) + throw new FileNotFoundException("Source XML file could not be found.", sourceXmlPath); + + // Load the source XML document + XmlDocument doc = new XmlDocument(); + doc.Load(sourceXmlPath); + + // Extract pure file name (e.g., "M850.xslt") to keep the path relative inside the XML + string pureXsltName = Path.GetFileName(xsltFilePath); + string piData = $"type=\"text/xsl\" href=\"{pureXsltName}\""; + + // Check if an xml-stylesheet link already exists so we don't duplicate it + XmlProcessingInstruction existingPi = doc.ChildNodes + .OfType() + .FirstOrDefault(pi => pi.Name == "xml-stylesheet"); + + if (existingPi != null) + { + // Update the existing link path + existingPi.Data = piData; + } + else + { + // Create a new independent processing instruction node + XmlProcessingInstruction newPi = doc.CreateProcessingInstruction("xml-stylesheet", piData); + + // Safely insert it right after the standard declaration if present + XmlNode xmlDeclaration = doc.ChildNodes.OfType().FirstOrDefault(); + if (xmlDeclaration != null) + { + doc.InsertAfter(newPi, xmlDeclaration); + } + else + { + doc.PrependChild(newPi); + } + } + + // Save the modified source XML file back to its location + using (var writer = new XmlTextWriter(sourceXmlPath, Encoding.UTF8)) + { + writer.Formatting = Formatting.Indented; + doc.Save(writer); + } + } + private void btnGenerateXsltFromCanvas_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(lbxInfileList.Text)) + { + MessageBox.Show("Please select a source file from the list first.", "Missing Source Context"); + return; + } + try + { + var generator = new XsltMapGenerator(_mapper); + string directory = Path.GetDirectoryName(lbxInfileList.Text); + string filenameWithoutExt = Path.GetFileNameWithoutExtension(lbxInfileList.Text); + string targetSchemaFileName = Path.Combine(directory, filenameWithoutExt + ".xslt"); + string transformDirectory = Path.GetDirectoryName(targetSchemaFileName); + if (!Directory.Exists(transformDirectory)) + { + Directory.CreateDirectory(transformDirectory); + } + string compiledXslt = generator.GenerateXsltFromCanvas(lbxInfileList.Text, targetSchemaFileName); + File.WriteAllText(targetSchemaFileName, compiledXslt); + LinkXsltToSourceXmlFile(lbxInfileList.Text, targetSchemaFileName); + + ShowFormWith(compiledXslt); + + MessageBox.Show($"XSLT Map generated successfully at:\n{targetSchemaFileName}", "Success"); + } + catch (Exception ex) + { + MessageBox.Show($"Failed to generate XSLT map layout:\n{ex.Message}", "Generation Error"); + } + } + + private void ShowFormWith(string stringToShow) + { + using (Form previewForm = new Form { Text = "Compiled Script XSLT Output", Width = 700, Height = 550, StartPosition = FormStartPosition.CenterParent }) + { + // 1. Create the Close Button + Button btnClose = new Button + { + Text = "Close", + DialogResult = DialogResult.Cancel, // Automatically closes the dialog when clicked + Width = 100, + Height = 30, + Location = new Point(560, 10) // Positions it on the right side of the bottom panel + }; + + // Ensure pressing the Enter or Esc key also closes the form naturally + previewForm.CancelButton = btnClose; + previewForm.AcceptButton = btnClose; + + // 2. Create a bottom panel to hold the button neatly + Panel buttonPanel = new Panel + { + Dock = DockStyle.Bottom, + Height = 50 + }; + buttonPanel.Controls.Add(btnClose); + + // 3. Create the Text Box (Change DockStyle.Fill behavior to respect the bottom panel) + TextBox txtPreview = new TextBox + { + Multiline = true, + ScrollBars = ScrollBars.Both, + Dock = DockStyle.Fill, + Font = new Font("Consolas", 10f), + WordWrap = false, + Text = stringToShow, + ReadOnly = true + }; + + // 4. Add controls to the form (order matters slightly for layout nesting) + previewForm.Controls.Add(txtPreview); + previewForm.Controls.Add(buttonPanel); // Docked to bottom, so TextBox fills the remaining space + + previewForm.ShowDialog(this); + } + } + + public string ContentFromFile(string filename/*fullPath*/) + { + using (Stream ediFile = new FileStream(filename, FileMode.Open, FileAccess.Read)) + { + return new StreamReader(filename).ReadToEnd(); + } + } + private void lbxfileList_SelectedIndexChanged(object sender, EventArgs e) + { + string name = ((ListBox)sender).Name; + switch (name) + { + case "lbxInfileList": + Properties.Settings.Default.SelectedInfile = ((ListBox)sender).SelectedIndex; + break; + case "lbxTargetSchema": + Properties.Settings.Default.SelectedTargetSchema = ((ListBox)sender).SelectedIndex; + break; + } + string fileName = ((ListBox)sender).Text; + if (String.IsNullOrEmpty(fileName)) return; + tt.SetToolTip(lbxInfileList, fileName + " is Selected now.."); + lblInterchangeCount.Text = "0"; + lblInterchangeCount.Text = "1"; + Properties.Settings.Default.Save(); + } + + + private void lblSourceFolder_Click(object sender, EventArgs e) + { + using (FolderBrowserDialog fb = new FolderBrowserDialog()) + { + fb.Description = "Select the X12 Source Folder"; + + + // Assign the initial directory from your application properties + // Adjust the exact settings path if your namespace differs (e.g., Properties.Settings.Default...) + if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.X12Folder) && + System.IO.Directory.Exists(Properties.Settings.Default.X12Folder)) + { + fb.SelectedPath = Properties.Settings.Default.X12Folder; + } + + // Show the dialog and check if the user clicked OK + if (fb.ShowDialog() == DialogResult.OK) + { + // Update the setting with the new path + Properties.Settings.Default.X12Folder = fb.SelectedPath; + + // Save the settings persistantly + Properties.Settings.Default.Save(); + + // Optional: Update the label or a textbox text to reflect the new selection + + lblSourceFolder.Text = $"Source Folder: {fb.SelectedPath} (..)"; + lbxfileList_SelectedIndexChanged(lbxInfileList, null); + PopulateFileList(Properties.Settings.Default.X12Folder); + + + } + } + } + + private void extensionFilter_CheckedChanged(object sender, EventArgs e) + { + var (text, isChecked) = checkedOption(grpFileExtensionFilter); + if (!isChecked) return; + switch (text.ToLower()) + { + case "txt": + lbxTargetSchema.Items.Clear(); + lbxTargetSchema.Items.AddRange(Directory.GetFiles(Properties.Settings.Default.X12Folder, "*.txt")); + break; + case "xml": + lbxTargetSchema.Items.Clear(); + lbxTargetSchema.Items.AddRange(Directory.GetFiles(Properties.Settings.Default.X12Folder, "*.xml")); break; + case "xslt": + lbxTargetSchema.Items.Clear(); + lbxTargetSchema.Items.AddRange(Directory.GetFiles(Properties.Settings.Default.X12Folder, "*.xslt")); + break; + } + + + } + + private void btnApplyXslt_Click(object sender, EventArgs e) + { + string infile = lbxInfileList.Text; + string outXml = Path.Combine(Path.GetDirectoryName(infile),$"{Path.GetFileNameWithoutExtension(infile)}_out.xml" ); + XsltTransformer.ApplyXslt(infile, lbxTargetSchema.Text,outXml ); + } + + private void MenuBrowse_Click(object sender, EventArgs e) + { + // Identify which ListBox was right-clicked + ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender; + ContextMenuStrip ownerMenu = (ContextMenuStrip)clickedItem.Owner; + ListBox parentControl = ownerMenu.SourceControl as ListBox; + string htmlContent = $@"{ContentFromFile(parentControl.Text)}"; + // DisplayHtml(htmlContent); + + ShowFormWith(ContentFromFile(parentControl.Text)); + //tabControl1.SelectedIndex = (int)enmTabPages.browser; + } + + private void MenuDelete_Click(object sender, EventArgs e) + { + // Identify which ListBox was right-clicked + ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; + ContextMenuStrip owner = (ContextMenuStrip)menuItem.Owner; + ListBox targetListBox = (ListBox)owner.SourceControl; + + // Check if an item is selected to be deleted + if (targetListBox.SelectedItem != null) + { + string removedItem = targetListBox.SelectedItem.ToString(); + + // Remove from UI + targetListBox.Items.Remove(targetListBox.SelectedItem); + + Logger.Info($"Removed '{removedItem}' from {targetListBox.Name}"); + } + else + { + MessageBox.Show("Please select an item first to delete.", "No Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + + + private void SetupListboxContextMenus() + { + // Create the ContextMenuStrip + ContextMenuStrip listboxMenu = new ContextMenuStrip(); + + // Create the Browse item + ToolStripMenuItem menuBrowse = new ToolStripMenuItem("Browse..."); + menuBrowse.Click += MenuBrowse_Click; + + // Create the Delete item + ToolStripMenuItem menuDelete = new ToolStripMenuItem("Delete"); + menuDelete.Click += MenuDelete_Click; + + // Add items to the context menu + listboxMenu.Items.Add(menuBrowse); + listboxMenu.Items.Add(new ToolStripSeparator()); // Optional visual separator line + listboxMenu.Items.Add(menuDelete); + + // Assign the same context menu to both ListBoxes + lbxInfileList.ContextMenuStrip = listboxMenu; + lbxTargetSchema.ContextMenuStrip = listboxMenu; + + // Optional: Select the ListBox item automatically on a right-click + lbxInfileList.MouseDown += ListBox_MouseDown; + lbxTargetSchema.MouseDown += ListBox_MouseDown; + } + + private void ListBox_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + ListBox listBox = (ListBox)sender; + // Find the index of the item corresponding to the coordinates of the mouse click + int index = listBox.IndexFromPoint(e.Location); + + if (index != ListBox.NoMatches) + { + listBox.SelectedIndex = index; // Programmatically select it + } + } + } + } +} \ No newline at end of file diff --git a/X12UtilsFRM/X12UtilsFRM.csproj b/X12UtilsFRM/X12UtilsFRM.csproj new file mode 100644 index 00000000..e2ffac21 --- /dev/null +++ b/X12UtilsFRM/X12UtilsFRM.csproj @@ -0,0 +1,256 @@ + + + + + Debug + AnyCPU + {08B4E0A3-3C17-40F5-B986-562232797C60} + WinExe + X12UtilsFRM + X12UtilsFRM + v4.7.2 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Fonet.1.0\lib\net20\Fonet.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.8\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\NLog.6.0.2\lib\net46\NLog.dll + + + ..\packages\NLog.Windows.Forms.6.0.2\lib\net35\NLog.Windows.Forms.dll + + + ..\packages\OpenTK.3.1.0\lib\net20\OpenTK.dll + + + ..\packages\OpenTK.GLControl.3.1.0\lib\net20\OpenTK.GLControl.dll + + + ..\packages\SkiaSharp.3.119.2\lib\net462\SkiaSharp.dll + + + ..\packages\SkiaSharp.Views.Desktop.Common.3.119.2\lib\net462\SkiaSharp.Views.Desktop.Common.dll + + + ..\packages\SkiaSharp.Views.WindowsForms.3.119.2\lib\net462\SkiaSharp.Views.WindowsForms.dll + + + C:\Users\tony\.nuget\packages\syncfusion.diagram.base\33.2.6\lib\net8.0-windows7.0\Design\WinForms\Syncfusion.Diagram.Base.Client.dll + + + C:\Users\tony\.nuget\packages\syncfusion.diagram.base\33.2.6\lib\net8.0-windows7.0\Design\WinForms\Syncfusion.Diagram.Base.Protocol.dll + + + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll + + + + ..\packages\System.Configuration.ConfigurationManager.10.0.8\lib\net462\System.Configuration.ConfigurationManager.dll + + + + ..\packages\System.IO.Pipelines.10.0.8\lib\net462\System.IO.Pipelines.dll + + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Text.Encodings.Web.10.0.8\lib\net462\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.10.0.8\lib\net462\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll + + + + + + + + + + + + + + + Component + + + Form + + + + + + UserControl + + + Component + + + + Component + + + Form + + + X12UtilsFRM.cs + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SkiaMapper.cs + + + X12UtilsFRM.cs + Designer + + + + PreserveNewest + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {1e3bd8a3-21ea-4b71-8a55-31910211a316} + X12.Hipaa.ClaimParser + + + {203c0f4b-d1f0-4c20-8968-7dbd84f4a815} + X12.Hipaa + + + {29eeaa38-bfb2-4732-a286-eb91355f9bcd} + X12.Parsing + + + {74a34062-7cf9-41b5-9f36-a0367c9afa2f} + X12.Shared + + + {26E9A9D5-D0B4-4B86-83D7-A0A3370A57EA} + X12.Specifications + + + {c080e31b-1f81-4f6e-b634-90d834b1811d} + X12.Transformations + + + {8e4b7c5f-87ee-43cb-a1de-75ecb5916b19} + X12.TransformToX12 + + + {19307f16-3d8c-4e4d-8903-8bad12edae78} + X12.X12Parser + + + + + Always + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/X12UtilsFRM/X12UtilsFRM.resx b/X12UtilsFRM/X12UtilsFRM.resx new file mode 100644 index 00000000..5abc6b1c --- /dev/null +++ b/X12UtilsFRM/X12UtilsFRM.resx @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 133, 17 + + + 230, 17 + + + 365, 17 + + + 532, 17 + + \ No newline at end of file diff --git a/X12UtilsFRM/XsltMapGenerator.cs b/X12UtilsFRM/XsltMapGenerator.cs new file mode 100644 index 00000000..2ee4665e --- /dev/null +++ b/X12UtilsFRM/XsltMapGenerator.cs @@ -0,0 +1,348 @@ +using NLog.Targets; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml; +using X12UtilsFRM; +using System.Text.Json; +using System.IO; + +namespace PdfX.App.Services +{ + public class XsltMapGenerator + { + private readonly dynamic _mapper; + + public XsltMapGenerator(dynamic mapper) + { + _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); + } + private string BuildAbsoluteXPath(XmlNode node) + { + if (node == null || node.NodeType == XmlNodeType.Document) return ""; + if (node.NodeType == XmlNodeType.Attribute) + return BuildAbsoluteXPath(((XmlAttribute)node).OwnerElement) + "/@" + node.Name; + + string parentPath = BuildAbsoluteXPath(node.ParentNode); + return string.IsNullOrEmpty(parentPath) ? node.Name : parentPath + "/" + node.Name; + } + public string GenerateXsltFromCanvas(string sourceFileName = "unknown_source_payload.xml", string xsltFileName = "BizTalkTransformMap.xslt") + { + if (_mapper.Connections == null || _mapper.Connections.Count == 0) + { + return string.Empty; + } + + if (!string.IsNullOrEmpty(sourceFileName) && (sourceFileName.Contains("\\") || sourceFileName.Contains("/"))) + sourceFileName = System.IO.Path.GetFileName(sourceFileName); + + if (!string.IsNullOrEmpty(xsltFileName) && (xsltFileName.Contains("\\") || xsltFileName.Contains("/"))) + xsltFileName = System.IO.Path.GetFileName(xsltFileName); + + var flatSchemaRegistry = (IEnumerable)_mapper.FlatSchemaRegistry; + var flatTargetSchemaRegistry = (IEnumerable)_mapper.FlatTargetSchemaRegistry; + var connections = (IEnumerable)_mapper.Connections; + + // Extract the actual root XmlNodes to inspect their namespaces + XmlNode sourceRootNode = flatSchemaRegistry.FirstOrDefault()?.XmlSourceNode; + XmlNode targetRootNode = flatTargetSchemaRegistry.FirstOrDefault()?.XmlSourceNode; + + string sourceRootName = sourceRootNode?.Name ?? "SOURCE_ROOT"; + string targetRootName = targetRootNode?.Name ?? "ROOT"; + + // --- DYNAMIC NAMESPACE DISCOVERY --- + string sourceNamespaceDecl = ""; + string targetNamespaceDecl = ""; + + if (sourceRootNode != null && !string.IsNullOrEmpty(sourceRootNode.Prefix) && !string.IsNullOrEmpty(sourceRootNode.NamespaceURI)) + { + sourceNamespaceDecl = $"xmlns:{sourceRootNode.Prefix}=\"{sourceRootNode.NamespaceURI}\""; + } + if (targetRootNode != null && !string.IsNullOrEmpty(targetRootNode.Prefix) && !string.IsNullOrEmpty(targetRootNode.NamespaceURI)) + { + targetNamespaceDecl = $"xmlns:{targetRootNode.Prefix}=\"{targetRootNode.NamespaceURI}\""; + } + + StringBuilder xslt = new StringBuilder(); + + // 1. Core Header Definitions (with dynamically injected namespaces) + xslt.AppendLine(""); + xslt.AppendLine(""); + xslt.AppendLine(" "); + xslt.AppendLine(); + + // 2. Global Metadata Parameters + xslt.AppendLine(" "); + xslt.AppendLine($" "); + xslt.AppendLine($" "); + xslt.AppendLine(); + + // 3. Root Template Match Entry Point with Processing Instruction + xslt.AppendLine(" "); + xslt.AppendLine(" "); + xslt.AppendLine(" type=\"text/xsl\" href=\""); + xslt.AppendLine(" "); + xslt.AppendLine(" \""); + xslt.AppendLine(" "); + xslt.AppendLine(" "); + xslt.AppendLine(" "); + xslt.AppendLine(); + + xslt.AppendLine($" "); + xslt.AppendLine($" <{targetRootName}>"); + xslt.AppendLine(" "); + xslt.AppendLine(); + + int variableCounter = 1; + Dictionary uniqueScriptMethodsRegistry = new Dictionary(); + var targetBoundConnections = connections.Where(c => + c.Target is XmlNode || c.Target.GetType().Name == "SchemaNodeItem").ToList(); + + foreach (var conn in targetBoundConnections) + { + XmlNode targetXmlNode = conn.Target is XmlNode xmlTgt ? xmlTgt : conn.Target.XmlSourceNode; + if (targetXmlNode == null) continue; + + xslt.AppendLine($" <{targetXmlNode.Name}>"); + if (conn.Source is XmlNode || conn.Source.GetType().Name == "SchemaNodeItem") + { + XmlNode srcXmlNode = conn.Source is XmlNode xmlSrc ? xmlSrc : conn.Source.XmlSourceNode; + string structuralXPath = BuildAbsoluteXPath(srcXmlNode).Replace(sourceRootName + "/", ""); + xslt.AppendLine($" "); + } + else if (conn.Source.GetType().Name == "BizTalkFunctoidNode") + { + string varName = $"var:v{variableCounter}"; + + string inlineExpressionCall = ResolveFunctoidExpression( + conn.Source, + sourceRootName, + uniqueScriptMethodsRegistry, + connections + ); + xslt.AppendLine($" "); + xslt.AppendLine($" "); + variableCounter++; + } + xslt.AppendLine($" "); + } + + xslt.AppendLine($" "); + xslt.AppendLine(" "); + xslt.AppendLine(); + + // 4. Mount consolidated deduplicated C# script functions + if (uniqueScriptMethodsRegistry.Count > 0) + { + xslt.AppendLine(" "); + xslt.AppendLine(" "); + xslt.AppendLine(" "); + } + + xslt.AppendLine(""); + return xslt.ToString(); + } + + public string GetNodePathForLookup(XmlNode node) + { + return BuildAbsoluteXPath(node); + } + + + private string ResolveFunctoidExpression( + dynamic functoidNode, + string sourceRootName, + Dictionary scriptRegistry, + IEnumerable connections) + { + var inputLinks = connections.Where(c => object.ReferenceEquals(c.Target, functoidNode)).ToList(); + List optimizedArguments = new List(); + List formalParameters = new List(); + + int argIdx = 1; + foreach (var inputConn in inputLinks) + { + if (inputConn.Source is XmlNode || inputConn.Source.GetType().Name == "SchemaNodeItem") + { + XmlNode inputXmlNode = inputConn.Source is XmlNode xmlIn ? xmlIn : inputConn.Source.XmlSourceNode; + if (inputXmlNode != null) + { + string inputPath = BuildAbsoluteXPath(inputXmlNode).Replace(sourceRootName + "/", ""); + optimizedArguments.Add($"string({inputPath})"); + formalParameters.Add($"string p_arg{argIdx}"); + argIdx++; + } + } + else if (inputConn.Source.GetType().Name == "BizTalkFunctoidNode") + { + string nestedExpression = ResolveFunctoidExpression(inputConn.Source, sourceRootName, scriptRegistry, connections); + optimizedArguments.Add(nestedExpression); + formalParameters.Add($"string p_arg{argIdx}"); + argIdx++; + } + } + + string toolName = functoidNode.FunctoidName; + var standardTools = new List { "Concatenate", "Add", "Subtract", "Trim", "Uppercase", "Lowercase" }; + if (!standardTools.Contains(toolName)) toolName = "DirectPassThrough"; + + int argumentCount = optimizedArguments.Count; + string functionName = $"Fct_{toolName}_{argumentCount}"; + string paramsJoined = string.Join(", ", formalParameters); + + if (!scriptRegistry.ContainsKey(functionName)) + { + StringBuilder methodBody = new StringBuilder(); + + switch (toolName) + { + case "Concatenate": + // GENERATES: public string Fct_Concatenate_2(string p_arg1, string p_arg2) + methodBody.AppendLine($" public string {functionName}({paramsJoined})"); + methodBody.AppendLine(" {"); + + // Get the variable names: p_arg1, p_arg2, etc. + var catVars = formalParameters.Select(p => p.Split(' ')[1]); + methodBody.AppendLine($" return string.Concat({string.Join(", ", catVars)});"); + methodBody.AppendLine(" }"); + break; + + case "Add": + // GENERATES: public string Fct_Add_2(string p_arg1, string p_arg2) + methodBody.AppendLine($" public string {functionName}({paramsJoined})"); + methodBody.AppendLine(" {"); + methodBody.AppendLine(" double total = 0;"); + foreach (var param in formalParameters) + { + string varName = param.Split(' ')[1]; + methodBody.AppendLine($" if (double.TryParse({varName}, out double val_{varName})) total += val_{varName};"); + } + methodBody.AppendLine(" return total.ToString();"); + methodBody.AppendLine(" }"); + break; + + case "Uppercase": + methodBody.AppendLine($" public string {functionName}({paramsJoined})"); + methodBody.AppendLine(" {"); + string upperParam = formalParameters.Count > 0 ? formalParameters[0].Split(' ')[1] : "\"\""; + methodBody.AppendLine($" return ({upperParam} ?? \"\").ToUpper();"); + methodBody.AppendLine(" }"); + break; + + default: + methodBody.AppendLine($" public string {functionName}({paramsJoined})"); + methodBody.AppendLine(" {"); + string fallbackParam = formalParameters.Count > 0 ? formalParameters[0].Split(' ')[1] : "\"\""; + methodBody.AppendLine($" return {fallbackParam};"); + methodBody.AppendLine(" }"); + break; + } + + scriptRegistry.Add(functionName, methodBody.ToString()); + } + + return $"userCSharp:{functionName}({string.Join(", ", optimizedArguments)})"; + } + public void SaveCanvasLayout(string outputJsonFilePath, string sourcePath, string targetPath) + { + var state = new CanvasSaveState + { + SourceSchemaFile = sourcePath, + TargetSchemaFile = targetPath + }; + + var connections = (IEnumerable)_mapper.Connections; + + foreach (var conn in connections) + { + // --- 1. RESOLVE SOURCE IDENTIFIER --- + string sourceIdOrXPath; + string sourceType; + + // Safely check if it's an XmlNode OR your custom SchemaNodeItem wrapper + if (conn.Source is XmlNode || conn.Source.GetType().Name == "SchemaNodeItem") + { + sourceType = "SchemaNode"; + XmlNode xmlSrc = conn.Source is XmlNode xmlNode ? xmlNode : conn.Source.XmlSourceNode; + sourceIdOrXPath = BuildAbsoluteXPath(xmlSrc); + } + else // It's a BizTalkFunctoidNode + { + sourceType = "Functoid"; + string functoidId = conn.Source.GetHashCode().ToString(); + sourceIdOrXPath = functoidId; + + if (!state.Functoids.Any(f => f.Id == functoidId)) + { + state.Functoids.Add(new CanvasFunctoidDto + { + Id = functoidId, + FunctoidName = conn.Source.FunctoidName, + X = (float)conn.Source.Location.X, // Using Location.X since raw .X property doesn't exist + Y = (float)conn.Source.Location.Y, // Using Location.Y since raw .Y property doesn't exist + CustomScript = conn.Source.CustomScript + }); + } + } + + // --- 2. RESOLVE TARGET IDENTIFIER --- + string targetIdOrXPath; + string targetType; + + if (conn.Target is XmlNode || conn.Target.GetType().Name == "SchemaNodeItem") + { + targetType = "SchemaNode"; + XmlNode xmlTgt = conn.Target is XmlNode xmlNode ? xmlNode : conn.Target.XmlSourceNode; + targetIdOrXPath = BuildAbsoluteXPath(xmlTgt); + } + else // It's a BizTalkFunctoidNode target + { + targetType = "Functoid"; + string functoidId = conn.Target.GetHashCode().ToString(); + targetIdOrXPath = functoidId; + + if (!state.Functoids.Any(f => f.Id == functoidId)) + { + state.Functoids.Add(new CanvasFunctoidDto + { + Id = functoidId, + FunctoidName = conn.Target.FunctoidName, + X = (float)conn.Target.Location.X, + Y = (float)conn.Target.Location.Y + }); + } + } + + // --- 3. ADD REGISTERED WIRE LINK --- + state.Wires.Add(new CanvasConnectionDto + { + SourceType = sourceType, + SourceIdOrXPath = sourceIdOrXPath, + TargetType = targetType, + TargetIdOrXPath = targetIdOrXPath + }); + } + + var options = new JsonSerializerOptions { WriteIndented = true }; + string jsonString = JsonSerializer.Serialize(state, options); + File.WriteAllText(outputJsonFilePath, jsonString); + } + } +} diff --git a/X12UtilsFRM/XsltTransformer.cs b/X12UtilsFRM/XsltTransformer.cs new file mode 100644 index 00000000..258d2cfb --- /dev/null +++ b/X12UtilsFRM/XsltTransformer.cs @@ -0,0 +1,41 @@ +using NLog; +using System; +using System.Xml; +using System.Xml.Xsl; + +public class XsltTransformer +{ + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + public static void ApplyXslt(string xmlFilePath, string xsltFilePath, string outputFilePath) + { + try + { + // 1. Enable script execution inside the XSLT (critical for BizTalk maps) + XsltSettings settings = new XsltSettings(enableDocumentFunction: true, enableScript: true); + + // 2. Load the XSLT stylesheet + XslCompiledTransform xslt = new XslCompiledTransform(); + xslt.Load(xsltFilePath, settings, new XmlUrlResolver()); + + // 3. Optional: Set up standard writer settings for clean, indented output + XmlWriterSettings writerSettings = new XmlWriterSettings + { + Indent = true, + IndentChars = " ", + NewLineOnAttributes = false + }; + + // 4. Execute the transformation and save to disk + using (XmlWriter writer = XmlWriter.Create(outputFilePath, writerSettings)) + { + xslt.Transform(xmlFilePath, writer); + } + + Logger.Info($"Transformation successful! Output saved to: {outputFilePath}"); + } + catch (Exception ex) + { + Logger.Error($"Error running transformation: {ex.Message}\n {ex.InnerException}"); + } + } +} \ No newline at end of file diff --git a/X12UtilsFRM/packages.config b/X12UtilsFRM/packages.config new file mode 100644 index 00000000..1de2d228 --- /dev/null +++ b/X12UtilsFRM/packages.config @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/X12UtilsFRM/specFinder.cs b/X12UtilsFRM/specFinder.cs new file mode 100644 index 00000000..e8542e0d --- /dev/null +++ b/X12UtilsFRM/specFinder.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace X12UtilsFRM { + + using System.IO; + using System.Reflection; + using System.Diagnostics; + using System.Runtime.CompilerServices; + using System; + using X12.Specifications; + using X12.Specifications.Finders; + + namespace x12Test { + public class specFinder : SpecificationFinder { + static void Log(String s, [CallerMemberName] string cn = "", [CallerLineNumber] int ln = 0, [CallerFilePath] string fp = "") { + + Trace.WriteLine($"{DateTime.Now.ToString()}-{cn}@{fp.Substring(fp.LastIndexOf('\\') + 1)}:{ln}:{s}"); + Trace.Flush(); + } + public override TransactionSpecification FindTransactionSpec(string functionalCode, string versionCode, string transactionSetCode) { + + //{PartnerId}-{TransactionId}-{PartnerX12VersionId}Specification.xml + if (transactionSetCode == "856") { + Assembly a = Assembly.GetExecutingAssembly(); + string spec = $"{a.GetName().Name}.Resources.{Properties.Settings.Default.PartnerId}-{transactionSetCode}-{Properties.Settings.Default.PartnerX12VersionId}-Specification.xml"; + + // Stream specStream = a.GetManifestResourceStream(spec); + + Stream specStream = a.GetManifestResourceStream(spec); + Log($"SpecStream={specStream}"); + Log($"SPec={spec}"); + + return TransactionSpecification.Deserialize(new StreamReader(specStream).ReadToEnd()); + } + else + return base.FindTransactionSpec(functionalCode, versionCode, transactionSetCode); + } + } + } + +} diff --git a/src/X12.AcknowledgeX12/App.config b/src/X12.AcknowledgeX12/App.config index 63e4aab5..cf52bd13 100644 --- a/src/X12.AcknowledgeX12/App.config +++ b/src/X12.AcknowledgeX12/App.config @@ -8,4 +8,4 @@ - + diff --git a/src/X12.AcknowledgeX12/X12.AcknowledgeX12.csproj b/src/X12.AcknowledgeX12/X12.AcknowledgeX12.csproj index 6e9aa465..77176708 100644 --- a/src/X12.AcknowledgeX12/X12.AcknowledgeX12.csproj +++ b/src/X12.AcknowledgeX12/X12.AcknowledgeX12.csproj @@ -10,7 +10,7 @@ Properties X12.AcknowledgeX12 X12.AcknowledgeX12 - v4.6.1 + v4.7.2 512 diff --git a/src/X12.Hipaa.ClaimParser/App.config b/src/X12.Hipaa.ClaimParser/App.config index 71cd2ba5..93448e65 100644 --- a/src/X12.Hipaa.ClaimParser/App.config +++ b/src/X12.Hipaa.ClaimParser/App.config @@ -5,4 +5,4 @@ - + diff --git a/src/X12.Hipaa.ClaimParser/Program.cs b/src/X12.Hipaa.ClaimParser/Program.cs index 4da02ab0..46489adc 100644 --- a/src/X12.Hipaa.ClaimParser/Program.cs +++ b/src/X12.Hipaa.ClaimParser/Program.cs @@ -7,10 +7,9 @@ using System.Linq; using System.Xml; - using Fonet; - using X12.Hipaa.Claims.Services; using X12.Parsing; + using Fonet; /// /// Primary driver for the Hippa.ClaimParser diff --git a/src/X12.Hipaa.ClaimParser/X12.Hipaa.ClaimParser.csproj b/src/X12.Hipaa.ClaimParser/X12.Hipaa.ClaimParser.csproj index 4c0fb39f..1cf22a14 100644 --- a/src/X12.Hipaa.ClaimParser/X12.Hipaa.ClaimParser.csproj +++ b/src/X12.Hipaa.ClaimParser/X12.Hipaa.ClaimParser.csproj @@ -10,7 +10,7 @@ Properties X12.Hipaa.ClaimParser X12.Hipaa.ClaimParser - v4.6.1 + v4.7.2 512 diff --git a/src/X12.Hipaa/Claims/Services/CompilerAttributes.cs b/src/X12.Hipaa/Claims/Services/CompilerAttributes.cs new file mode 100644 index 00000000..2ca08f6e --- /dev/null +++ b/src/X12.Hipaa/Claims/Services/CompilerAttributes.cs @@ -0,0 +1,13 @@ +namespace System.Runtime.CompilerServices +{ + [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + public sealed class CallerArgumentExpressionAttribute : Attribute + { + public CallerArgumentExpressionAttribute(string parameterName) + { + ParameterName = parameterName; + } + + public string ParameterName { get; } + } +} \ No newline at end of file diff --git a/src/X12.Hipaa/Claims/Services/InstitutionalClaimToUB04ClaimFormTransformation.cs b/src/X12.Hipaa/Claims/Services/InstitutionalClaimToUB04ClaimFormTransformation.cs index 563e2878..ab03f197 100644 --- a/src/X12.Hipaa/Claims/Services/InstitutionalClaimToUB04ClaimFormTransformation.cs +++ b/src/X12.Hipaa/Claims/Services/InstitutionalClaimToUB04ClaimFormTransformation.cs @@ -4,24 +4,24 @@ using System.Collections.Generic; using System.Linq; using System.Text; - using X12.Hipaa.Claims.Forms; using X12.Hipaa.Claims.Forms.Institutional; using X12.Hipaa.Common; using X12.Hipaa.Enums; - + using System.Runtime.CompilerServices; + using System.IO; + using Microsoft.Extensions.Logging; + using NLog; public class InstitutionalClaimToUb04ClaimFormTransformation : IClaimToClaimFormTransfomation { + public event EventHandler DebugFile; private readonly string formImagePath; - - /// - /// Initializes a new instance of the class - /// - /// Form image path to be transformed + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public InstitutionalClaimToUb04ClaimFormTransformation(string formImagePath) { this.formImagePath = formImagePath; this.PerPageTotalChargesView = false; + } public bool PerPageTotalChargesView { get; set; } @@ -382,15 +382,15 @@ public virtual UB04Claim TransformClaimToUB04(Claim claim) foreach (var line in claim.ServiceLines) { ub.ServiceLines.Add(new UB04ServiceLine - { - Field42_RevenueCode = line.RevenueCode, - Field43_Description = line.RevenueCodeDescription, - Field44_ProcedureCodes = SetProcedureCodeWithModifiers(line.Procedure), - Field45_ServiceDate = line.ServiceDateFrom > DateTime.MinValue ? $"{line.ServiceDateFrom:MMddyy}" : string.Empty, - Field46_ServiceUnits = line.Quantity.ToString(), - Field47_TotalCharges = line.ChargeAmount, - Field48_NonCoveredCharges = line.NonCoveredChargeAmount - }); + { + Field42_RevenueCode = line.RevenueCode, + Field43_Description = line.RevenueCodeDescription, + Field44_ProcedureCodes = SetProcedureCodeWithModifiers(line.Procedure), + Field45_ServiceDate = line.ServiceDateFrom > DateTime.MinValue ? $"{line.ServiceDateFrom:MMddyy}" : string.Empty, + Field46_ServiceUnits = line.Quantity.ToString(), + Field47_TotalCharges = line.ChargeAmount, + Field48_NonCoveredCharges = line.NonCoveredChargeAmount + }); } ub.Field47_Line23_TotalCharges = claim.TotalClaimChargeAmount; @@ -429,7 +429,7 @@ public virtual UB04Claim TransformClaimToUB04(Claim claim) var subscriber = claim.OtherSubscriberInformations[1]; SetOtherPayers(subscriber, ub); } - + var controlNumbers = claim.Identifications.Where(id => new[] { "F8", "D9", "9A", "9C", "LX" }.Contains(id.Qualifier)).ToList(); if (controlNumbers.Count > 0) { @@ -697,7 +697,7 @@ public virtual UB04Claim TransformClaimToUB04(Claim claim) } } } - + if (claim.Notes != null) { List remarksList = null; @@ -771,7 +771,7 @@ private static void LimitFieldWidths(UB04Claim ub) line.Field43_Description = SetStringLength(line.Field43_Description, 29); } } - + private static void SetOtherProviders(Provider provider, UB04Provider ub04Provider) { ub04Provider.Npi = SetStringLength(provider.Npi, 11); @@ -803,7 +803,7 @@ private static string SetStringLength(string source, int limit) return source.Length > limit ? source.Substring(0, limit) : source; } - private static void SetBillingProviderAddressDetails(UB04Claim ub, Provider provider,SubmitterInfo submitterinfo) + private static void SetBillingProviderAddressDetails(UB04Claim ub, Provider provider, SubmitterInfo submitterinfo) { if (provider?.Address == null) { @@ -824,8 +824,8 @@ private static void SetBillingProviderAddressDetails(UB04Claim ub, Provider prov if (string.IsNullOrEmpty(ub.Field01_BillingProvider.Line4)) { - if (submitterinfo?.Providers != null && - submitterinfo.Providers.Contacts.Count > 0 && + if (submitterinfo?.Providers != null && + submitterinfo.Providers.Contacts.Count > 0 && submitterinfo.Providers.Contacts[0].Numbers.Count > 0) { ub.Field01_BillingProvider.Line4 = submitterinfo.Providers.Contacts[0].Numbers[0].Number; @@ -872,79 +872,79 @@ private static void SetOtherPayers(OtherSubscriberInformation subscriber, UB04Cl switch (subscriber.SubscriberInformation.PayerResponsibilitySequenceNumberCode) { case "P": - { - if (subscriber.OtherPayer != null) { - ub.PayerA_Primary.Field50_PayerName = SetStringLength(subscriber.OtherPayer.Formatted(), 26); - ub.PayerA_Primary.Field51_HealthPlanId = SetStringLength(subscriber.OtherPayer.Identification.Id, 17); - if (!string.IsNullOrEmpty(subscriber.OtherPayer.PriorAuthorizationNumber)) + if (subscriber.OtherPayer != null) { - ub.Field63A_TreatmentAuthorizationCode = SetStringLength(subscriber.OtherPayer.PriorAuthorizationNumber, 34); + ub.PayerA_Primary.Field50_PayerName = SetStringLength(subscriber.OtherPayer.Formatted(), 26); + ub.PayerA_Primary.Field51_HealthPlanId = SetStringLength(subscriber.OtherPayer.Identification.Id, 17); + if (!string.IsNullOrEmpty(subscriber.OtherPayer.PriorAuthorizationNumber)) + { + ub.Field63A_TreatmentAuthorizationCode = SetStringLength(subscriber.OtherPayer.PriorAuthorizationNumber, 34); + } } - } - ub.PayerA_Primary.Field52_ReleaseOfInfoCertIndicator = subscriber.ReleaseOfInformationCode; - ub.PayerA_Primary.Field53_AssignmentOfBenefitsCertIndicator = subscriber.BenefitsAssignmentCertificationIndicator; - ub.PayerA_Primary.Field54_PriorPayments = subscriber.PayorPaidAmount; - ub.PayerA_Primary.Field55_EstimatedAmountDue = subscriber.RemainingPatientLiability; - - ub.PayerA_Primary.Field58_InsuredsName = SetStringLength(subscriber.Name.Formatted(), 29); - ub.PayerA_Primary.Field59_PatientRelationship = subscriber.SubscriberInformation.IndividualRelationshipCode; - ub.PayerA_Primary.Field60_InsuredsUniqueId = SetStringLength(subscriber.Name.Identification.Id, 23); - ub.PayerA_Primary.Field61_GroupName = SetStringLength(subscriber.SubscriberInformation.Name, 17); - ub.PayerA_Primary.Field62_InsuredsGroupNumber = SetStringLength(subscriber.SubscriberInformation.ReferenceIdentification, 21); - break; - } + ub.PayerA_Primary.Field52_ReleaseOfInfoCertIndicator = subscriber.ReleaseOfInformationCode; + ub.PayerA_Primary.Field53_AssignmentOfBenefitsCertIndicator = subscriber.BenefitsAssignmentCertificationIndicator; + ub.PayerA_Primary.Field54_PriorPayments = subscriber.PayorPaidAmount; + ub.PayerA_Primary.Field55_EstimatedAmountDue = subscriber.RemainingPatientLiability; + + ub.PayerA_Primary.Field58_InsuredsName = SetStringLength(subscriber.Name.Formatted(), 29); + ub.PayerA_Primary.Field59_PatientRelationship = subscriber.SubscriberInformation.IndividualRelationshipCode; + ub.PayerA_Primary.Field60_InsuredsUniqueId = SetStringLength(subscriber.Name.Identification.Id, 23); + ub.PayerA_Primary.Field61_GroupName = SetStringLength(subscriber.SubscriberInformation.Name, 17); + ub.PayerA_Primary.Field62_InsuredsGroupNumber = SetStringLength(subscriber.SubscriberInformation.ReferenceIdentification, 21); + break; + } case "S": - { - if (subscriber.OtherPayer != null) { - ub.PayerB_Secondary.Field50_PayerName = SetStringLength(subscriber.OtherPayer.Formatted(), 26); - ub.PayerB_Secondary.Field51_HealthPlanId = SetStringLength(subscriber.OtherPayer.Identification.Id, 17); - if (!string.IsNullOrEmpty(subscriber.OtherPayer.PriorAuthorizationNumber)) + if (subscriber.OtherPayer != null) { - ub.Field63B_TreatmentAuthorizationCode = SetStringLength(subscriber.OtherPayer.PriorAuthorizationNumber, 34); + ub.PayerB_Secondary.Field50_PayerName = SetStringLength(subscriber.OtherPayer.Formatted(), 26); + ub.PayerB_Secondary.Field51_HealthPlanId = SetStringLength(subscriber.OtherPayer.Identification.Id, 17); + if (!string.IsNullOrEmpty(subscriber.OtherPayer.PriorAuthorizationNumber)) + { + ub.Field63B_TreatmentAuthorizationCode = SetStringLength(subscriber.OtherPayer.PriorAuthorizationNumber, 34); + } } - } - ub.PayerB_Secondary.Field52_ReleaseOfInfoCertIndicator = subscriber.ReleaseOfInformationCode; - ub.PayerB_Secondary.Field53_AssignmentOfBenefitsCertIndicator = subscriber.BenefitsAssignmentCertificationIndicator; - ub.PayerB_Secondary.Field54_PriorPayments = subscriber.PayorPaidAmount; - ub.PayerB_Secondary.Field55_EstimatedAmountDue = subscriber.RemainingPatientLiability; - - ub.PayerB_Secondary.Field58_InsuredsName = SetStringLength(subscriber.Name.Formatted(), 29); - ub.PayerB_Secondary.Field59_PatientRelationship = subscriber.SubscriberInformation.IndividualRelationshipCode; - ub.PayerB_Secondary.Field60_InsuredsUniqueId = SetStringLength(subscriber.Name.Identification.Id, 23); - ub.PayerB_Secondary.Field61_GroupName = SetStringLength(subscriber.SubscriberInformation.Name, 17); - ub.PayerB_Secondary.Field62_InsuredsGroupNumber = SetStringLength(subscriber.SubscriberInformation.ReferenceIdentification, 21); - break; - } + ub.PayerB_Secondary.Field52_ReleaseOfInfoCertIndicator = subscriber.ReleaseOfInformationCode; + ub.PayerB_Secondary.Field53_AssignmentOfBenefitsCertIndicator = subscriber.BenefitsAssignmentCertificationIndicator; + ub.PayerB_Secondary.Field54_PriorPayments = subscriber.PayorPaidAmount; + ub.PayerB_Secondary.Field55_EstimatedAmountDue = subscriber.RemainingPatientLiability; + + ub.PayerB_Secondary.Field58_InsuredsName = SetStringLength(subscriber.Name.Formatted(), 29); + ub.PayerB_Secondary.Field59_PatientRelationship = subscriber.SubscriberInformation.IndividualRelationshipCode; + ub.PayerB_Secondary.Field60_InsuredsUniqueId = SetStringLength(subscriber.Name.Identification.Id, 23); + ub.PayerB_Secondary.Field61_GroupName = SetStringLength(subscriber.SubscriberInformation.Name, 17); + ub.PayerB_Secondary.Field62_InsuredsGroupNumber = SetStringLength(subscriber.SubscriberInformation.ReferenceIdentification, 21); + break; + } case "T": - { - if (subscriber.OtherPayer != null) { - ub.PayerC_Tertiary.Field50_PayerName = SetStringLength(subscriber.OtherPayer.Formatted(), 26); - ub.PayerC_Tertiary.Field51_HealthPlanId = SetStringLength(subscriber.OtherPayer.Identification.Id, 17); - if (!string.IsNullOrEmpty(subscriber.OtherPayer.PriorAuthorizationNumber)) + if (subscriber.OtherPayer != null) { - ub.Field63C_TreatmentAuthorizationCode = SetStringLength(subscriber.OtherPayer.PriorAuthorizationNumber, 34); + ub.PayerC_Tertiary.Field50_PayerName = SetStringLength(subscriber.OtherPayer.Formatted(), 26); + ub.PayerC_Tertiary.Field51_HealthPlanId = SetStringLength(subscriber.OtherPayer.Identification.Id, 17); + if (!string.IsNullOrEmpty(subscriber.OtherPayer.PriorAuthorizationNumber)) + { + ub.Field63C_TreatmentAuthorizationCode = SetStringLength(subscriber.OtherPayer.PriorAuthorizationNumber, 34); + } } - } - ub.PayerC_Tertiary.Field52_ReleaseOfInfoCertIndicator = subscriber.ReleaseOfInformationCode; - ub.PayerC_Tertiary.Field53_AssignmentOfBenefitsCertIndicator = subscriber.BenefitsAssignmentCertificationIndicator; - ub.PayerC_Tertiary.Field54_PriorPayments = subscriber.PayorPaidAmount; - ub.PayerC_Tertiary.Field55_EstimatedAmountDue = subscriber.RemainingPatientLiability; - - ub.PayerC_Tertiary.Field58_InsuredsName = SetStringLength(subscriber.Name.Formatted(), 29); - ub.PayerC_Tertiary.Field59_PatientRelationship = subscriber.SubscriberInformation.IndividualRelationshipCode; - ub.PayerC_Tertiary.Field60_InsuredsUniqueId = SetStringLength(subscriber.Name.Identification.Id, 23); - ub.PayerC_Tertiary.Field61_GroupName = SetStringLength(subscriber.SubscriberInformation.Name, 17); - ub.PayerC_Tertiary.Field62_InsuredsGroupNumber = SetStringLength(subscriber.SubscriberInformation.ReferenceIdentification, 21); - break; - } + ub.PayerC_Tertiary.Field52_ReleaseOfInfoCertIndicator = subscriber.ReleaseOfInformationCode; + ub.PayerC_Tertiary.Field53_AssignmentOfBenefitsCertIndicator = subscriber.BenefitsAssignmentCertificationIndicator; + ub.PayerC_Tertiary.Field54_PriorPayments = subscriber.PayorPaidAmount; + ub.PayerC_Tertiary.Field55_EstimatedAmountDue = subscriber.RemainingPatientLiability; + + ub.PayerC_Tertiary.Field58_InsuredsName = SetStringLength(subscriber.Name.Formatted(), 29); + ub.PayerC_Tertiary.Field59_PatientRelationship = subscriber.SubscriberInformation.IndividualRelationshipCode; + ub.PayerC_Tertiary.Field60_InsuredsUniqueId = SetStringLength(subscriber.Name.Identification.Id, 23); + ub.PayerC_Tertiary.Field61_GroupName = SetStringLength(subscriber.SubscriberInformation.Name, 17); + ub.PayerC_Tertiary.Field62_InsuredsGroupNumber = SetStringLength(subscriber.SubscriberInformation.ReferenceIdentification, 21); + break; + } } } @@ -1062,10 +1062,11 @@ private static string SetProcedureCodeWithModifiers(MedicalProcedure procedure) return procedureCode.ToString(); } - - private static FormBlock AddBlock(FormPage page, decimal x, decimal y, decimal width, string text, TextAlign textAlign = TextAlign.left) + + private static FormBlock AddBlock(FormPage page, decimal x, decimal y, decimal width, string text, TextAlign textAlign = TextAlign.left, [CallerArgumentExpression("text")] string expressionPath = "",string debugOutFileName="") { - decimal xScale = 0.08333m; + + decimal xScale = 0.08333m; decimal yScale = 0.16667m; var block = new FormBlock { @@ -1075,13 +1076,23 @@ private static FormBlock AddBlock(FormPage page, decimal x, decimal y, decimal w Width = xScale * width, Height = yScale * 1.1m, Text = text - }; + }; + + logger.Log(NLog.LogLevel.Info,$"Adding block at x:{x}, y:{y}, width:{width} with text:'{text}' for expression {expressionPath}"); + + + System.IO.File.AppendAllText(debugOutFileName, $"{x,-6},\t{y,-6},\tLeft:{block.Left}\tTop:{block.Top}\t{expressionPath}:{text}{Environment.NewLine}"); + page.Blocks.Add(block); return block; } - + public virtual List TransformUb04ToFormPages(UB04Claim ub04) { + string fn = Path.Combine(Path.GetTempPath(),"debug.txt"); + + + if( System.IO.File.Exists(fn)) System.IO.File.Delete(fn); List pages = new List(); int pageCount = 1 + ((ub04.ServiceLines.Count - 1) / 22); FormPage page = null; @@ -1098,163 +1109,155 @@ public virtual List TransformUb04ToFormPages(UB04Claim ub04) // header // Box 1 - AddBlock(page, 2, 1, 28, ub04.Field01_BillingProvider.Line1); - AddBlock(page, 2, 2, 28, ub04.Field01_BillingProvider.Line2); - AddBlock(page, 2, 3, 28, ub04.Field01_BillingProvider.Line3); - AddBlock(page, 2, 4, 28, ub04.Field01_BillingProvider.Line4); - + AddBlock(page, 2, 1, 28, ub04.Field01_BillingProvider.Line1,debugOutFileName:fn); + AddBlock(page, 2, 2, 28, ub04.Field01_BillingProvider.Line2,debugOutFileName:fn); + AddBlock(page, 2, 3, 28, ub04.Field01_BillingProvider.Line3,debugOutFileName:fn); + AddBlock(page, 2, 4, 28, ub04.Field01_BillingProvider.Line4,debugOutFileName:fn); + // Box 2 - AddBlock(page, 32, 1, 28, ub04.Field02_PayToProvider.Line1); - AddBlock(page, 32, 2, 28, ub04.Field02_PayToProvider.Line2); - AddBlock(page, 32, 3, 28, ub04.Field02_PayToProvider.Line3); - AddBlock(page, 32, 4, 28, ub04.Field02_PayToProvider.Line4); + AddBlock(page, 32, 1, 28, ub04.Field02_PayToProvider.Line1,debugOutFileName:fn); + AddBlock(page, 32, 2, 28, ub04.Field02_PayToProvider.Line2,debugOutFileName:fn); + AddBlock(page, 32, 3, 28, ub04.Field02_PayToProvider.Line3,debugOutFileName:fn); + AddBlock(page, 32, 4, 28, ub04.Field02_PayToProvider.Line4,debugOutFileName:fn); // Box 3 - AddBlock(page, 65, 1, 27, ub04.Field03a_PatientControlNumber); - AddBlock(page, 65, 2, 27, ub04.Field03b_MedicalRecordNumber); - + AddBlock(page, 65, 1, 27, ub04.Field03a_PatientControlNumber,debugOutFileName:fn); + AddBlock(page, 65, 2, 27, ub04.Field03b_MedicalRecordNumber,debugOutFileName:fn); + // Box 4 - AddBlock(page, 94, 2, 5, ub04.Field04_TypeOfBill); - + AddBlock(page, 94, 2, 5, ub04.Field04_TypeOfBill,debugOutFileName:fn); + // Box 5 - AddBlock(page, 62, 4, 10, ub04.Field05_FederalTaxId); + AddBlock(page, 62, 4, 10, ub04.Field05_FederalTaxId,debugOutFileName:fn); // Box 6 - Statement Covers Period - AddBlock(page, 74, 4, 9, ub04.Field06_StatementCoversPeriod.FromDate); - AddBlock(page, 82, 4, 9, ub04.Field06_StatementCoversPeriod.ThroughDate); - + AddBlock(page, 74, 4, 9, ub04.Field06_StatementCoversPeriod.FromDate,debugOutFileName:fn); + AddBlock(page, 82, 4, 9, ub04.Field06_StatementCoversPeriod.ThroughDate,debugOutFileName:fn); // Box 7 - Blank - AddBlock(page, 91, 3, 8, ub04.Field07.Line1); - AddBlock(page, 91, 4, 8, ub04.Field07.Line2); + AddBlock(page, 91, 3, 8, ub04.Field07.Line1,debugOutFileName:fn); + AddBlock(page, 91, 4, 8, ub04.Field07.Line2,debugOutFileName:fn); // Box 8 - AddBlock(page, 15, 5, 21, ub04.Field08_PatientName_a); - AddBlock(page, 3, 6, 33, ub04.Field08_PatientName_b); - + AddBlock(page, 15, 5, 21, ub04.Field08_PatientName_a,debugOutFileName:fn); + AddBlock(page, 3, 6, 33, ub04.Field08_PatientName_b,debugOutFileName:fn); // Box 9 - AddBlock(page, 51, 5, 48, ub04.Field09_PatientAddress.a_Street); - AddBlock(page, 39, 6, 37, ub04.Field09_PatientAddress.b_City); - AddBlock(page, 78, 6, 2, ub04.Field09_PatientAddress.c_State); - AddBlock(page, 83, 6, 10, ub04.Field09_PatientAddress.d_PostalCode); - AddBlock(page, 96, 6, 3, ub04.Field09_PatientAddress.e_CountryCode); + AddBlock(page, 51, 5, 48, ub04.Field09_PatientAddress.a_Street,debugOutFileName:fn); + AddBlock(page, 39, 6, 37, ub04.Field09_PatientAddress.b_City,debugOutFileName:fn); + AddBlock(page, 78, 6, 2, ub04.Field09_PatientAddress.c_State,debugOutFileName:fn); + AddBlock(page, 83, 6, 10, ub04.Field09_PatientAddress.d_PostalCode,debugOutFileName:fn); + AddBlock(page, 96, 6, 3, ub04.Field09_PatientAddress.e_CountryCode,debugOutFileName:fn); // Box 10 - AddBlock(page, 2, 8, 8, ub04.Field10_Birthdate); - + AddBlock(page, 2, 8, 8, ub04.Field10_Birthdate,debugOutFileName:fn); // Box 11 - AddBlock(page, 13, 8, 1, ub04.Field11_Sex); + AddBlock(page, 13, 8, 1, ub04.Field11_Sex,debugOutFileName:fn); // Box 12-15 - AddBlock(page, 16, 8, 6, ub04.Field12_AdmissionDate); - AddBlock(page, 23, 8, 2, ub04.Field13_AdmissionHour); - AddBlock(page, 27, 8, 2, ub04.Field14_AdmissionType); - AddBlock(page, 30, 8, 2, ub04.Field15_AdmissionSource); + AddBlock(page, 16, 8, 6, ub04.Field12_AdmissionDate,debugOutFileName:fn); + AddBlock(page, 23, 8, 2, ub04.Field13_AdmissionHour,debugOutFileName:fn); + AddBlock(page, 27, 8, 2, ub04.Field14_AdmissionType,debugOutFileName:fn); + AddBlock(page, 30, 8, 2, ub04.Field15_AdmissionSource,debugOutFileName:fn); // Box 16 - AddBlock(page, 34, 8, 2, ub04.Field16_DischargeHour); + AddBlock(page, 34, 8, 2, ub04.Field16_DischargeHour,debugOutFileName:fn); // Box 17 - AddBlock(page, 38, 8, 2, ub04.Field17_DischargeStatus); - - // Box 18 - 28 Condition Codes - AddBlock(page, 41, 8, 2, ub04.Field18_ConditionCode01); - AddBlock(page, 45, 8, 2, ub04.Field19_ConditionCode02); - AddBlock(page, 48, 8, 2, ub04.Field20_ConditionCode03); - AddBlock(page, 52, 8, 2, ub04.Field21_ConditionCode04); - AddBlock(page, 56, 8, 2, ub04.Field22_ConditionCode05); - AddBlock(page, 59, 8, 2, ub04.Field23_ConditionCode06); - AddBlock(page, 63, 8, 2, ub04.Field24_ConditionCode07); - AddBlock(page, 66, 8, 2, ub04.Field25_ConditionCode08); - AddBlock(page, 70, 8, 2, ub04.Field26_ConditionCode09); - AddBlock(page, 73.5m, 8, 2, ub04.Field27_ConditionCode10); - AddBlock(page, 77, 8, 2, ub04.Field28_ConditionCode11); + AddBlock(page, 38, 8, 2, ub04.Field17_DischargeStatus,debugOutFileName:fn); + // Box 18 - 28 Condition Codes + AddBlock(page, 41, 8, 2, ub04.Field18_ConditionCode01,debugOutFileName:fn); + AddBlock(page, 45, 8, 2, ub04.Field19_ConditionCode02,debugOutFileName:fn); + AddBlock(page, 48, 8, 2, ub04.Field20_ConditionCode03,debugOutFileName:fn); + AddBlock(page, 52, 8, 2, ub04.Field21_ConditionCode04,debugOutFileName:fn); + AddBlock(page, 56, 8, 2, ub04.Field22_ConditionCode05,debugOutFileName:fn); + AddBlock(page, 59, 8, 2, ub04.Field23_ConditionCode06,debugOutFileName:fn ); + AddBlock(page, 63, 8, 2, ub04.Field24_ConditionCode07,debugOutFileName:fn); + AddBlock(page, 66, 8, 2, ub04.Field25_ConditionCode08,debugOutFileName:fn); + AddBlock(page, 70, 8, 2, ub04.Field26_ConditionCode09,debugOutFileName:fn); + AddBlock(page, 73.5m, 8, 2, ub04.Field27_ConditionCode10,debugOutFileName:fn); + AddBlock(page, 77, 8, 2, ub04.Field28_ConditionCode11,debugOutFileName:fn); // Box 29 - AddBlock(page, 81, 8, 2, ub04.Field29_AccidentState); - + AddBlock(page, 81, 8, 2, ub04.Field29_AccidentState,debugOutFileName:fn); + // Box 30 - AddBlock(page, 85, 8, 14, ub04.Field30); + AddBlock(page, 85, 8, 14, ub04.Field30,debugOutFileName:fn); // Box 31 - AddBlock(page, 2, 10, 2, ub04.Field31a_Occurrence.Code); - AddBlock(page, 6, 10, 6, ub04.Field31a_Occurrence.Date); - AddBlock(page, 2, 11, 2, ub04.Field31b_Occurrence.Code); - AddBlock(page, 6, 11, 6, ub04.Field31b_Occurrence.Date); + AddBlock(page, 2, 10, 2, ub04.Field31a_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 6, 10, 6, ub04.Field31a_Occurrence.Date,debugOutFileName:fn); + AddBlock(page, 2, 11, 2, ub04.Field31b_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 6, 11, 6, ub04.Field31b_Occurrence.Date,debugOutFileName:fn); - // Box 32 - AddBlock(page, 14, 10, 2, ub04.Field32a_Occurrence.Code); - AddBlock(page, 18, 10, 6, ub04.Field32a_Occurrence.Date); - AddBlock(page, 14, 11, 2, ub04.Field32b_Occurrence.Code); - AddBlock(page, 18, 11, 6, ub04.Field32b_Occurrence.Date); + // Box 32 + AddBlock(page, 14, 10, 2, ub04.Field32a_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 18, 10, 6, ub04.Field32a_Occurrence.Date,debugOutFileName:fn); + AddBlock(page, 14, 11, 2, ub04.Field32b_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 18, 11, 6, ub04.Field32b_Occurrence.Date,debugOutFileName:fn); // Box 33 - AddBlock(page, 26, 10, 2, ub04.Field33a_Occurrence.Code); - AddBlock(page, 30, 10, 6, ub04.Field33a_Occurrence.Date); - AddBlock(page, 26, 11, 2, ub04.Field33b_Occurrence.Code); - AddBlock(page, 30, 11, 6, ub04.Field33b_Occurrence.Date); + AddBlock(page, 26, 10, 2, ub04.Field33a_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 30, 10, 6, ub04.Field33a_Occurrence.Date,debugOutFileName:fn); + AddBlock(page, 26, 11, 2, ub04.Field33b_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 30, 11, 6, ub04.Field33b_Occurrence.Date,debugOutFileName:fn); // Box 34 - AddBlock(page, 38, 10, 2, ub04.Field34a_Occurrence.Code); - AddBlock(page, 41, 10, 6, ub04.Field34a_Occurrence.Date); - AddBlock(page, 38, 11, 2, ub04.Field34b_Occurrence.Code); - AddBlock(page, 41, 11, 6, ub04.Field34b_Occurrence.Date); + AddBlock(page, 38, 10, 2, ub04.Field34a_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 41, 10, 6, ub04.Field34a_Occurrence.Date,debugOutFileName:fn); + AddBlock(page, 38, 11, 2, ub04.Field34b_Occurrence.Code,debugOutFileName:fn); + AddBlock(page, 41, 11, 6, ub04.Field34b_Occurrence.Date,debugOutFileName:fn); // Box 35 - AddBlock(page, 50, 10, 2, ub04.Field35a_OccurrenceSpan.Code); - AddBlock(page, 53, 10, 6, ub04.Field35a_OccurrenceSpan.FromDate); - AddBlock(page, 62, 10, 6, ub04.Field35a_OccurrenceSpan.ThroughDate); - AddBlock(page, 50, 11, 2, ub04.Field35b_OccurrenceSpan.Code); - AddBlock(page, 53, 11, 6, ub04.Field35b_OccurrenceSpan.FromDate); - AddBlock(page, 62, 11, 6, ub04.Field35b_OccurrenceSpan.ThroughDate); + AddBlock(page, 50, 10, 2, ub04.Field35a_OccurrenceSpan.Code,debugOutFileName:fn); + AddBlock(page, 53, 10, 6, ub04.Field35a_OccurrenceSpan.FromDate,debugOutFileName:fn); + AddBlock(page, 62, 10, 6, ub04.Field35a_OccurrenceSpan.ThroughDate,debugOutFileName:fn); + AddBlock(page, 50, 11, 2, ub04.Field35b_OccurrenceSpan.Code,debugOutFileName:fn); + AddBlock(page, 53, 11, 6, ub04.Field35b_OccurrenceSpan.FromDate,debugOutFileName:fn); + AddBlock(page, 62, 11, 6, ub04.Field35b_OccurrenceSpan.ThroughDate,debugOutFileName:fn); // Box 36 - AddBlock(page, 70, 10, 2, ub04.Field36a_OccurrenceSpan.Code); - AddBlock(page, 74, 10, 6, ub04.Field36a_OccurrenceSpan.FromDate); - AddBlock(page, 82, 10, 6, ub04.Field36a_OccurrenceSpan.ThroughDate); - AddBlock(page, 70, 11, 2, ub04.Field36b_OccurrenceSpan.Code); - AddBlock(page, 74, 11, 6, ub04.Field36b_OccurrenceSpan.FromDate); - AddBlock(page, 82, 11, 6, ub04.Field36b_OccurrenceSpan.ThroughDate); + AddBlock(page, 70, 10, 2, ub04.Field36a_OccurrenceSpan.Code,debugOutFileName:fn); + AddBlock(page, 74, 10, 6, ub04.Field36a_OccurrenceSpan.FromDate,debugOutFileName:fn); + AddBlock(page, 82, 10, 6, ub04.Field36a_OccurrenceSpan.ThroughDate,debugOutFileName:fn); + AddBlock(page, 70, 11, 2, ub04.Field36b_OccurrenceSpan.Code,debugOutFileName:fn); + AddBlock(page, 74, 11, 6, ub04.Field36b_OccurrenceSpan.FromDate,debugOutFileName:fn); + AddBlock(page, 82, 11, 6, ub04.Field36b_OccurrenceSpan.ThroughDate,debugOutFileName:fn); // Box 37 - Blank - AddBlock(page, 90, 10, 9, ub04.Field37.Line1); - AddBlock(page, 90, 11, 9, ub04.Field37.Line2); - + AddBlock(page, 90, 10, 9, ub04.Field37.Line1,debugOutFileName:fn); + AddBlock(page, 90, 11, 9, ub04.Field37.Line2,debugOutFileName:fn); // Box 38 - Responsible Party - AddBlock(page, 2, 12, 48, ub04.Field38_ResponsibleParty.Line1); - AddBlock(page, 2, 13, 48, ub04.Field38_ResponsibleParty.Line2); - AddBlock(page, 2, 14, 48, ub04.Field38_ResponsibleParty.Line3); - AddBlock(page, 2, 15, 48, ub04.Field38_ResponsibleParty.Line4); - AddBlock(page, 2, 16, 48, ub04.Field38_ResponsibleParty.Line5); - + AddBlock(page, 2, 12, 48, ub04.Field38_ResponsibleParty.Line1,debugOutFileName:fn); + AddBlock(page, 2, 13, 48, ub04.Field38_ResponsibleParty.Line2,debugOutFileName:fn); + AddBlock(page, 2, 14, 48, ub04.Field38_ResponsibleParty.Line3,debugOutFileName:fn); + AddBlock(page, 2, 15, 48, ub04.Field38_ResponsibleParty.Line4,debugOutFileName:fn); + AddBlock(page, 2, 16, 48, ub04.Field38_ResponsibleParty.Line5,debugOutFileName:fn); // Box 39 - Value Codes - AddBlock(page, 53, 13, 2, ub04.Field39a_Value.Code); - AddBlock(page, 57, 13, 12, $"{ub04.Field39a_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right); - AddBlock(page, 53, 14, 2, ub04.Field39b_Value.Code); - AddBlock(page, 57, 14, 12, $"{ub04.Field39b_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right); - AddBlock(page, 53, 15, 2, ub04.Field39c_Value.Code); - AddBlock(page, 57, 15, 12, $"{ub04.Field39c_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right); - AddBlock(page, 53, 16, 2, ub04.Field39d_Value.Code); - AddBlock(page, 57, 16, 12, $"{ub04.Field39d_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right); - + AddBlock(page, 53, 13, 2, ub04.Field39a_Value.Code,debugOutFileName:fn); + AddBlock(page, 57, 13, 12, $"{ub04.Field39a_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 53, 14, 2, ub04.Field39b_Value.Code,debugOutFileName:fn); + AddBlock(page, 57, 14, 12, $"{ub04.Field39b_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 53, 15, 2, ub04.Field39c_Value.Code,debugOutFileName:fn); + AddBlock(page, 57, 15, 12, $"{ub04.Field39c_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 53, 16, 2, ub04.Field39d_Value.Code,debugOutFileName:fn); + AddBlock(page, 57, 16, 12, $"{ub04.Field39d_Value.Amount:0.00}".Replace('.', ' '), TextAlign.right, debugOutFileName:fn); // Box 40 - AddBlock(page, 69, 13, 2, ub04.Field40a_Value.Code); - AddBlock(page, 72.5m, 13, 12, string.Format("{0:0.00}", ub04.Field40a_Value.Amount).Replace('.', ' '), TextAlign.right); - AddBlock(page, 69, 14, 2, ub04.Field40b_Value.Code); - AddBlock(page, 72.5m, 14, 12, string.Format("{0:0.00}", ub04.Field40b_Value.Amount).Replace('.', ' '), TextAlign.right); - AddBlock(page, 69, 15, 2, ub04.Field40c_Value.Code); - AddBlock(page, 72.5m, 15, 12, string.Format("{0:0.00}", ub04.Field40c_Value.Amount).Replace('.', ' '), TextAlign.right); - AddBlock(page, 69, 16, 2, ub04.Field40d_Value.Code); - AddBlock(page, 72.5m, 16, 12, string.Format("{0:0.00}", ub04.Field40d_Value.Amount).Replace('.', ' '), TextAlign.right); - + AddBlock(page, 69, 13, 2, ub04.Field40a_Value.Code,debugOutFileName:fn); + AddBlock(page, 72.5m, 13, 12, string.Format("{0:0.00}", ub04.Field40a_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 69, 14, 2, ub04.Field40b_Value.Code,debugOutFileName:fn); + AddBlock(page, 72.5m, 14, 12, string.Format("{0:0.00}", ub04.Field40b_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 69, 15, 2, ub04.Field40c_Value.Code,debugOutFileName:fn); + AddBlock(page, 72.5m, 15, 12, string.Format("{0:0.00}", ub04.Field40c_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 69, 16, 2, ub04.Field40d_Value.Code,debugOutFileName:fn); + AddBlock(page, 72.5m, 16, 12, string.Format("{0:0.00}", ub04.Field40d_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); // Box 41 - Value Codes - AddBlock(page, 84, 13, 2, ub04.Field41a_Value.Code); - AddBlock(page, 88, 13, 12, string.Format("{0:0.00}", ub04.Field41a_Value.Amount).Replace('.', ' '), TextAlign.right); - AddBlock(page, 84, 14, 2, ub04.Field41b_Value.Code); - AddBlock(page, 88, 14, 12, string.Format("{0:0.00}", ub04.Field41b_Value.Amount).Replace('.', ' '), TextAlign.right); - AddBlock(page, 84, 15, 2, ub04.Field41c_Value.Code); - AddBlock(page, 88, 15, 12, string.Format("{0:0.00}", ub04.Field41c_Value.Amount).Replace('.', ' '), TextAlign.right); - AddBlock(page, 84, 16, 2, ub04.Field41d_Value.Code); - AddBlock(page, 88, 16, 12, string.Format("{0:0.00}", ub04.Field41d_Value.Amount).Replace('.', ' '), TextAlign.right); + AddBlock(page, 84, 13, 2, ub04.Field41a_Value.Code,debugOutFileName:fn); + AddBlock(page, 88, 13, 12, string.Format("{0:0.00}", ub04.Field41a_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 84, 14, 2, ub04.Field41b_Value.Code,debugOutFileName:fn); + AddBlock(page, 88, 14, 12, string.Format("{0:0.00}", ub04.Field41b_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 84, 15, 2, ub04.Field41c_Value.Code,debugOutFileName:fn); + AddBlock(page, 88, 15, 12, string.Format("{0:0.00}", ub04.Field41c_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 84, 16, 2, ub04.Field41d_Value.Code,debugOutFileName:fn); + AddBlock(page, 88, 16, 12, string.Format("{0:0.00}", ub04.Field41d_Value.Amount).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); } // service lines @@ -1262,21 +1265,20 @@ public virtual List TransformUb04ToFormPages(UB04Claim ub04) var line = ub04.ServiceLines[i]; // Box 42 - 49 - Service Lines - AddBlock(page, 2, y, 4, line.Field42_RevenueCode); - AddBlock(page, 7, y, 29, line.Field43_Description); - AddBlock(page, 37, y, 17, line.Field44_ProcedureCodes); - AddBlock(page, 56, y, 6, line.Field45_ServiceDate); - AddBlock(page, 64, y, 9, line.Field46_ServiceUnits, TextAlign.right); - - AddBlock(page, 74, y, 11, string.Format("{0:0.00}", line.Field47_TotalCharges).Replace('.', ' '), TextAlign.right); - AddBlock(page, 86, y, 11, string.Format("{0:0.00}", line.Field48_NonCoveredCharges).Replace('.', ' '), TextAlign.right); - AddBlock(page, 97, y, 2, line.Field49); + AddBlock(page, 2, y, 4, line.Field42_RevenueCode,debugOutFileName:fn); + AddBlock(page, 7, y, 29, line.Field43_Description,debugOutFileName:fn); + AddBlock(page, 37, y, 17, line.Field44_ProcedureCodes,debugOutFileName:fn); + AddBlock(page, 56, y, 6, line.Field45_ServiceDate,debugOutFileName:fn); + AddBlock(page, 64, y, 9, line.Field46_ServiceUnits, TextAlign.right, debugOutFileName:fn); + AddBlock(page, 74, y, 11, string.Format("{0:0.00}", line.Field47_TotalCharges).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 86, y, 11, string.Format("{0:0.00}", line.Field48_NonCoveredCharges).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 97, y, 2, line.Field49,debugOutFileName:fn); // Footer - if (i % 22 == 21 || i == ub04.ServiceLines.Count - 1) + if (i % 22 == 21 || i == ub04.ServiceLines.Count - 1) { - AddBlock(page, 13, 40, 3, pageIndex.ToString(), TextAlign.right); - AddBlock(page, 20, 40, 3, pageCount.ToString(), TextAlign.right); + AddBlock(page, 13, 40, 3, pageIndex.ToString(), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 20, 40, 3, pageCount.ToString(), TextAlign.right, debugOutFileName:fn); if (this.PerPageTotalChargesView) { int lowIndex; @@ -1304,271 +1306,262 @@ public virtual List TransformUb04ToFormPages(UB04Claim ub04) } } - AddBlock(page, 74, 40, 11, string.Format("{0:0.00}", pageCharges).Replace('.', ' '), TextAlign.right); - AddBlock(page, 86, 40, 11, string.Format("{0:0.00}", nonCoveredCharges).Replace('.', ' '), TextAlign.right); + AddBlock(page, 74, 40, 11, string.Format("{0:0.00}", pageCharges).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 86, 40, 11, string.Format("{0:0.00}", nonCoveredCharges).Replace('.', ' '), TextAlign.right,debugOutFileName:fn ); } else { if (pageIndex == pageCount) { - AddBlock(page, 74, 40, 11, string.Format("{0:0.00}", ub04.Field47_Line23_TotalCharges).Replace('.', ' '), TextAlign.right); - AddBlock(page, 86, 40, 11, string.Format("{0:0.00}", ub04.Field48_Line23_NonCoveredCharges).Replace('.', ' '), TextAlign.right); + AddBlock(page, 74, 40, 11, string.Format("{0:0.00}", ub04.Field47_Line23_TotalCharges).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 86, 40, 11, string.Format("{0:0.00}", ub04.Field48_Line23_NonCoveredCharges).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); } } // Box 50 - AddBlock(page, 2, 42, 26, ub04.PayerA_Primary.Field50_PayerName); - AddBlock(page, 2, 43, 26, ub04.PayerB_Secondary.Field50_PayerName); - AddBlock(page, 2, 44, 26, ub04.PayerC_Tertiary.Field50_PayerName); + AddBlock(page, 2, 42, 26, ub04.PayerA_Primary.Field50_PayerName, debugOutFileName:fn); + AddBlock(page, 2, 43, 26, ub04.PayerB_Secondary.Field50_PayerName, debugOutFileName:fn); + AddBlock(page, 2, 44, 26, ub04.PayerC_Tertiary.Field50_PayerName, debugOutFileName:fn); // Box 51 - AddBlock(page, 29, 42, 17, ub04.PayerA_Primary.Field51_HealthPlanId); - AddBlock(page, 29, 43, 17, ub04.PayerB_Secondary.Field51_HealthPlanId); - AddBlock(page, 29, 44, 17, ub04.PayerC_Tertiary.Field51_HealthPlanId); - + AddBlock(page, 29, 42, 17, ub04.PayerA_Primary.Field51_HealthPlanId, debugOutFileName:fn); + AddBlock(page, 29, 43, 17, ub04.PayerB_Secondary.Field51_HealthPlanId, debugOutFileName:fn); + AddBlock(page, 29, 44, 17, ub04.PayerC_Tertiary.Field51_HealthPlanId, debugOutFileName:fn); + // Box 52 - Release of Info - AddBlock(page, 46.5m, 42, 2, ub04.PayerA_Primary.Field52_ReleaseOfInfoCertIndicator); - AddBlock(page, 46.5m, 43, 2, ub04.PayerB_Secondary.Field52_ReleaseOfInfoCertIndicator); - AddBlock(page, 46.5m, 44, 2, ub04.PayerC_Tertiary.Field52_ReleaseOfInfoCertIndicator); + AddBlock(page, 46.5m, 42, 2, ub04.PayerA_Primary.Field52_ReleaseOfInfoCertIndicator, debugOutFileName:fn); + AddBlock(page, 46.5m, 43, 2, ub04.PayerB_Secondary.Field52_ReleaseOfInfoCertIndicator, debugOutFileName:fn); + AddBlock(page, 46.5m, 44, 2, ub04.PayerC_Tertiary.Field52_ReleaseOfInfoCertIndicator, debugOutFileName:fn); // Box 53 - AddBlock(page, 50, 42, 2, ub04.PayerA_Primary.Field53_AssignmentOfBenefitsCertIndicator); - AddBlock(page, 50, 43, 2, ub04.PayerB_Secondary.Field53_AssignmentOfBenefitsCertIndicator); - AddBlock(page, 50, 44, 2, ub04.PayerC_Tertiary.Field53_AssignmentOfBenefitsCertIndicator); + AddBlock(page, 50, 42, 2, ub04.PayerA_Primary.Field53_AssignmentOfBenefitsCertIndicator, debugOutFileName:fn); + AddBlock(page, 50, 43, 2, ub04.PayerB_Secondary.Field53_AssignmentOfBenefitsCertIndicator, debugOutFileName:fn); + AddBlock(page, 50, 44, 2, ub04.PayerC_Tertiary.Field53_AssignmentOfBenefitsCertIndicator, debugOutFileName:fn); // Box 54 - AddBlock(page, 54.25m, 42, 11, string.Format("{0:0.00}", ub04.PayerA_Primary.Field54_PriorPayments).Replace('.', ' '), TextAlign.right); - AddBlock(page, 54.25m, 43, 11, string.Format("{0:0.00}", ub04.PayerB_Secondary.Field54_PriorPayments).Replace('.', ' '), TextAlign.right); - AddBlock(page, 54.25m, 44, 11, string.Format("{0:0.00}", ub04.PayerC_Tertiary.Field54_PriorPayments).Replace('.', ' '), TextAlign.right); + AddBlock(page, 54.25m, 42, 11, string.Format("{0:0.00}", ub04.PayerA_Primary.Field54_PriorPayments).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 54.25m, 43, 11, string.Format("{0:0.00}", ub04.PayerB_Secondary.Field54_PriorPayments).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 54.25m, 44, 11, string.Format("{0:0.00}", ub04.PayerC_Tertiary.Field54_PriorPayments).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); // Box 55 - AddBlock(page, 66.5m, 42, 12, string.Format("{0:0.00}", ub04.PayerA_Primary.Field55_EstimatedAmountDue).Replace('.', ' '), TextAlign.right); - AddBlock(page, 66.5m, 43, 12, string.Format("{0:0.00}", ub04.PayerB_Secondary.Field55_EstimatedAmountDue).Replace('.', ' '), TextAlign.right); - AddBlock(page, 66.5m, 44, 12, string.Format("{0:0.00}", ub04.PayerC_Tertiary.Field55_EstimatedAmountDue).Replace('.', ' '), TextAlign.right); + AddBlock(page, 66.5m, 42, 12, string.Format("{0:0.00}", ub04.PayerA_Primary.Field55_EstimatedAmountDue).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 66.5m, 43, 12, string.Format("{0:0.00}", ub04.PayerB_Secondary.Field55_EstimatedAmountDue).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); + AddBlock(page, 66.5m, 44, 12, string.Format("{0:0.00}", ub04.PayerC_Tertiary.Field55_EstimatedAmountDue).Replace('.', ' '), TextAlign.right, debugOutFileName:fn); // Box 56 - AddBlock(page, 85, 41, 10, ub04.Field56_NationalProviderIdentifier); + AddBlock(page, 85, 41, 10, ub04.Field56_NationalProviderIdentifier, debugOutFileName:fn); // Box 57 - AddBlock(page, 82, 42, 17, ub04.Field57_OtherProviderIdA); - AddBlock(page, 82, 43, 17, ub04.Field57_OtherProviderIdB); - AddBlock(page, 82, 44, 17, ub04.Field57_OtherProviderIdC); + AddBlock(page, 82, 42, 17, ub04.Field57_OtherProviderIdA, debugOutFileName:fn); + AddBlock(page, 82, 43, 17, ub04.Field57_OtherProviderIdB, debugOutFileName:fn); + AddBlock(page, 82, 44, 17, ub04.Field57_OtherProviderIdC, debugOutFileName:fn); // Box 58 - AddBlock(page, 2, 46, 29, ub04.PayerA_Primary.Field58_InsuredsName); - AddBlock(page, 2, 47, 29, ub04.PayerB_Secondary.Field58_InsuredsName); - AddBlock(page, 2, 48, 29, ub04.PayerC_Tertiary.Field58_InsuredsName); + AddBlock(page, 2, 46, 29, ub04.PayerA_Primary.Field58_InsuredsName, debugOutFileName:fn); + AddBlock(page, 2, 47, 29, ub04.PayerB_Secondary.Field58_InsuredsName, debugOutFileName:fn); + AddBlock(page, 2, 48, 29, ub04.PayerC_Tertiary.Field58_InsuredsName, debugOutFileName:fn); // Box 59 - AddBlock(page, 33, 46, 2, ub04.PayerA_Primary.Field59_PatientRelationship); - AddBlock(page, 33, 47, 2, ub04.PayerB_Secondary.Field59_PatientRelationship); - AddBlock(page, 33, 48, 2, ub04.PayerC_Tertiary.Field59_PatientRelationship); + AddBlock(page, 33, 46, 2, ub04.PayerA_Primary.Field59_PatientRelationship, debugOutFileName:fn); + AddBlock(page, 33, 47, 2, ub04.PayerB_Secondary.Field59_PatientRelationship, debugOutFileName:fn); + AddBlock(page, 33, 48, 2, ub04.PayerC_Tertiary.Field59_PatientRelationship, debugOutFileName:fn); // Box 60 - AddBlock(page, 36, 46, 23, ub04.PayerA_Primary.Field60_InsuredsUniqueId); - AddBlock(page, 36, 47, 23, ub04.PayerB_Secondary.Field60_InsuredsUniqueId); - AddBlock(page, 36, 48, 23, ub04.PayerC_Tertiary.Field60_InsuredsUniqueId); + AddBlock(page, 36, 46, 23, ub04.PayerA_Primary.Field60_InsuredsUniqueId, debugOutFileName:fn); + AddBlock(page, 36, 47, 23, ub04.PayerB_Secondary.Field60_InsuredsUniqueId, debugOutFileName:fn); + AddBlock(page, 36, 48, 23, ub04.PayerC_Tertiary.Field60_InsuredsUniqueId, debugOutFileName:fn); // Box 61 - AddBlock(page, 60, 46, 17, ub04.PayerA_Primary.Field61_GroupName); - AddBlock(page, 60, 47, 17, ub04.PayerB_Secondary.Field61_GroupName); - AddBlock(page, 60, 48, 17, ub04.PayerC_Tertiary.Field61_GroupName); + AddBlock(page, 60, 46, 17, ub04.PayerA_Primary.Field61_GroupName, debugOutFileName:fn); + AddBlock(page, 60, 47, 17, ub04.PayerB_Secondary.Field61_GroupName, debugOutFileName:fn); + AddBlock(page, 60, 48, 17, ub04.PayerC_Tertiary.Field61_GroupName, debugOutFileName:fn); // Box 62 - AddBlock(page, 78, 46, 21, ub04.PayerA_Primary.Field62_InsuredsGroupNumber); - AddBlock(page, 78, 47, 21, ub04.PayerB_Secondary.Field62_InsuredsGroupNumber); - AddBlock(page, 78, 48, 21, ub04.PayerC_Tertiary.Field62_InsuredsGroupNumber); + AddBlock(page, 78, 46, 21, ub04.PayerA_Primary.Field62_InsuredsGroupNumber, debugOutFileName:fn); + AddBlock(page, 78, 47, 21, ub04.PayerB_Secondary.Field62_InsuredsGroupNumber, debugOutFileName:fn); + AddBlock(page, 78, 48, 21, ub04.PayerC_Tertiary.Field62_InsuredsGroupNumber, debugOutFileName:fn); // Box 63 - AddBlock(page, 2, 50, 35, ub04.Field63A_TreatmentAuthorizationCode); - AddBlock(page, 2, 51, 35, ub04.Field63B_TreatmentAuthorizationCode); - AddBlock(page, 2, 52, 35, ub04.Field63C_TreatmentAuthorizationCode); + AddBlock(page, 2, 50, 35, ub04.Field63A_TreatmentAuthorizationCode, debugOutFileName:fn); + AddBlock(page, 2, 51, 35, ub04.Field63B_TreatmentAuthorizationCode, debugOutFileName:fn); + AddBlock(page, 2, 52, 35, ub04.Field63C_TreatmentAuthorizationCode, debugOutFileName:fn); // Box 64 - Document Control Number - AddBlock(page, 39, 50, 30, ub04.Field64A_DocumentControlNumber); - AddBlock(page, 39, 51, 30, ub04.Field64B_DocumentControlNumber); - AddBlock(page, 39, 52, 30, ub04.Field64C_DocumentControlNumber); + AddBlock(page, 39, 50, 30, ub04.Field64A_DocumentControlNumber, debugOutFileName:fn); + AddBlock(page, 39, 51, 30, ub04.Field64B_DocumentControlNumber, debugOutFileName:fn); + AddBlock(page, 39, 52, 30, ub04.Field64C_DocumentControlNumber, debugOutFileName:fn); // Box 65 - Employer Name - AddBlock(page, 70, 50, 29, ub04.Field65a_EmployerName); - AddBlock(page, 70, 51, 29, ub04.Field65b_EmployerName); - AddBlock(page, 70, 52, 29, ub04.Field65c_EmployerName); + AddBlock(page, 70, 50, 29, ub04.Field65a_EmployerName, debugOutFileName:fn); + AddBlock(page, 70, 51, 29, ub04.Field65b_EmployerName, debugOutFileName:fn); + AddBlock(page, 70, 52, 29, ub04.Field65c_EmployerName, debugOutFileName:fn); // Box 66 - ICD Version - AddBlock(page, 1, 54, 1, ub04.Field66_Version); + AddBlock(page, 1, 54, 1, ub04.Field66_Version, debugOutFileName:fn); // Box 67 - Primary Diagnosis - AddBlock(page, 3, 53, 6, ub04.Field67_PrincipleDiagnosis.Code); - AddBlock(page, 10.5m, 53, 1, ub04.Field67_PrincipleDiagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 3, 53, 6, ub04.Field67_PrincipleDiagnosis.Code, debugOutFileName:fn); + AddBlock(page, 10.5m, 53, 1, ub04.Field67_PrincipleDiagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67A - AddBlock(page, 13, 53, 6, ub04.Field67A_Diagnosis.Code); - AddBlock(page, 20, 53, 1, ub04.Field67A_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 13, 53, 6, ub04.Field67A_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 20, 53, 1, ub04.Field67A_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67B - AddBlock(page, 22, 53, 6, ub04.Field67B_Diagnosis.Code); - AddBlock(page, 29.75m, 53, 1, ub04.Field67B_Diagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 22, 53, 6, ub04.Field67B_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 29.75m, 53, 1, ub04.Field67B_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67C - AddBlock(page, 32, 53, 6, ub04.Field67C_Diagnosis.Code); - AddBlock(page, 39.25m, 53, 1, ub04.Field67C_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 32, 53, 6, ub04.Field67C_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 39.25m, 53, 1, ub04.Field67C_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67D - AddBlock(page, 42, 53, 6, ub04.Field67D_Diagnosis.Code); - AddBlock(page, 49m, 53, 1, ub04.Field67D_Diagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 42, 53, 6, ub04.Field67D_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 49m, 53, 1, ub04.Field67D_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67E - AddBlock(page, 51, 53, 6, ub04.Field67E_Diagnosis.Code); - AddBlock(page, 58.5m, 53, 1, ub04.Field67E_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 51, 53, 6, ub04.Field67E_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 58.5m, 53, 1, ub04.Field67E_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67F - AddBlock(page, 61, 53, 6, ub04.Field67F_Diagnosis.Code); - AddBlock(page, 68m, 53, 1, ub04.Field67F_Diagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 61, 53, 6, ub04.Field67F_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 68m, 53, 1, ub04.Field67F_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67G - AddBlock(page, 70, 53, 6, ub04.Field67G_Diagnosis.Code); - AddBlock(page, 77.75m, 53, 1, ub04.Field67G_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 70, 53, 6, ub04.Field67G_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 77.75m, 53, 1, ub04.Field67G_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67H - AddBlock(page, 80, 53, 6, ub04.Field67H_Diagnosis.Code); - AddBlock(page, 87.25m, 53, 1, ub04.Field67H_Diagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 80, 53, 6, ub04.Field67H_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 87.25m, 53, 1, ub04.Field67H_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67I - AddBlock(page, 3, 54, 6, ub04.Field67I_Diagnosis.Code); - AddBlock(page, 10.5m, 54, 1, ub04.Field67I_Diagnosis.PresentOnAdmissionIndicator); - - // Box 67J - AddBlock(page, 13, 54, 6, ub04.Field67J_Diagnosis.Code); - AddBlock(page, 20, 54, 1, ub04.Field67J_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 3, 54, 6, ub04.Field67I_Diagnosis.Code, debugOutFileName:fn ); + AddBlock(page, 10.5m, 54, 1, ub04.Field67I_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); + // Box 67J + AddBlock(page, 13, 54, 6, ub04.Field67J_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 20, 54, 1, ub04.Field67J_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67K - AddBlock(page, 22, 54, 6, ub04.Field67K_Diagnosis.Code); - AddBlock(page, 29.75m, 54, 1, ub04.Field67K_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 22, 54, 6, ub04.Field67K_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 29.75m, 54, 1, ub04.Field67K_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn ); // Box 67L - AddBlock(page, 32, 54, 6, ub04.Field67L_Diagnosis.Code); - AddBlock(page, 39.25m, 54, 1, ub04.Field67L_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 32, 54, 6, ub04.Field67L_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 39.25m, 54, 1, ub04.Field67L_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67M - AddBlock(page, 42, 54, 6, ub04.Field67M_Diagnosis.Code); - AddBlock(page, 49m, 54, 1, ub04.Field67M_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 42, 54, 6, ub04.Field67M_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 49m, 54, 1, ub04.Field67M_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67N - AddBlock(page, 51, 54, 6, ub04.Field67N_Diagnosis.Code); - AddBlock(page, 58.5m, 54, 1, ub04.Field67N_Diagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 51, 54, 6, ub04.Field67N_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 58.5m, 54, 1, ub04.Field67N_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67O - AddBlock(page, 61, 54, 6, ub04.Field67O_Diagnosis.Code); - AddBlock(page, 68m, 54, 1, ub04.Field67O_Diagnosis.PresentOnAdmissionIndicator); + AddBlock(page, 61, 54, 6, ub04.Field67O_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 68m, 54, 1, ub04.Field67O_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67P - AddBlock(page, 70, 54, 6, ub04.Field67P_Diagnosis.Code); - AddBlock(page, 77.75m, 54, 1, ub04.Field67P_Diagnosis.PresentOnAdmissionIndicator); - + AddBlock(page, 70, 54, 6, ub04.Field67P_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 77.75m, 54, 1, ub04.Field67P_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 67Q - AddBlock(page, 80, 54, 6, ub04.Field67Q_Diagnosis.Code); - AddBlock(page, 87.25m, 54, 1, ub04.Field67Q_Diagnosis.PresentOnAdmissionIndicator); - - // Box 68 - AddBlock(page, 90, 53, 9, ub04.Field68.Line1); - AddBlock(page, 90, 54, 9, ub04.Field68.Line2); + AddBlock(page, 80, 54, 6, ub04.Field67Q_Diagnosis.Code, debugOutFileName:fn); + AddBlock(page, 87.25m, 54, 1, ub04.Field67Q_Diagnosis.PresentOnAdmissionIndicator, debugOutFileName:fn); + // Box 68 + AddBlock(page, 90, 53, 9, ub04.Field68.Line1, debugOutFileName:fn); + AddBlock(page, 90, 54, 9, ub04.Field68.Line2, debugOutFileName:fn); // Box 69 - Admitting Diagnosis - AddBlock(page, 6, 55, 6, ub04.Field69_AdmittingDiagnosisCode.Code); + AddBlock(page, 6, 55, 6, ub04.Field69_AdmittingDiagnosisCode.Code, debugOutFileName:fn); // Box 70 - Patient Reason Diagnosis - AddBlock(page, 21, 55, 6, ub04.Field70a_PatientReasonDiagnosisCode.Code); - AddBlock(page, 29, 55, 6, ub04.Field70b_PatientReasonDiagnosisCode.Code); - AddBlock(page, 38, 55, 6, ub04.Field70c_PatientReasonDiagnosisCode.Code); + AddBlock(page, 21, 55, 6, ub04.Field70a_PatientReasonDiagnosisCode.Code, debugOutFileName:fn); + AddBlock(page, 29, 55, 6, ub04.Field70b_PatientReasonDiagnosisCode.Code, debugOutFileName:fn); + AddBlock(page, 38, 55, 6, ub04.Field70c_PatientReasonDiagnosisCode.Code, debugOutFileName:fn); // Box 71 - PPS Code - AddBlock(page, 51, 55, 5, ub04.Field71_PPSCode); + AddBlock(page, 51, 55, 5, ub04.Field71_PPSCode, debugOutFileName:fn); // Box 72 - External Cause of Injury - AddBlock(page, 59, 55, 6, ub04.Field72a_ExternalCauseOfInjury.Code); - AddBlock(page, 67m, 55, 1, ub04.Field72a_ExternalCauseOfInjury.PresentOnAdmissionIndicator); - AddBlock(page, 69, 55, 6, ub04.Field72b_ExternalCauseOfInjury.Code); - AddBlock(page, 76.75m, 55, 1, ub04.Field72b_ExternalCauseOfInjury.PresentOnAdmissionIndicator); - AddBlock(page, 79, 55, 6, ub04.Field72c_ExternalCauseOfInjury.Code); - AddBlock(page, 86.25m, 55, 1, ub04.Field72c_ExternalCauseOfInjury.PresentOnAdmissionIndicator); + AddBlock(page, 59, 55, 6, ub04.Field72a_ExternalCauseOfInjury.Code, debugOutFileName:fn); + AddBlock(page, 67m, 55, 1, ub04.Field72a_ExternalCauseOfInjury.PresentOnAdmissionIndicator, debugOutFileName:fn); + AddBlock(page, 69, 55, 6, ub04.Field72b_ExternalCauseOfInjury.Code, debugOutFileName:fn); + AddBlock(page, 76.75m, 55, 1, ub04.Field72b_ExternalCauseOfInjury.PresentOnAdmissionIndicator, debugOutFileName:fn); + AddBlock(page, 79, 55, 6, ub04.Field72c_ExternalCauseOfInjury.Code, debugOutFileName:fn); + AddBlock(page, 86.25m, 55, 1, ub04.Field72c_ExternalCauseOfInjury.PresentOnAdmissionIndicator, debugOutFileName:fn); // Box 73 - Blank - AddBlock(page, 89, 55, 10, ub04.Field73); + AddBlock(page, 89, 55, 10, ub04.Field73, debugOutFileName:fn); // Box 74 - AddBlock(page, 2, 57, 8, ub04.Field74_PrincipalProcedure.Code); - AddBlock(page, 12, 57, 6, ub04.Field74_PrincipalProcedure.Date); - AddBlock(page, 20, 57, 8, ub04.Field74a_OtherProcedure.Code); - AddBlock(page, 29, 57, 6, ub04.Field74a_OtherProcedure.Date); - AddBlock(page, 38, 57, 8, ub04.Field74b_OtherProcedure.Code); - AddBlock(page, 48, 57, 6, ub04.Field74b_OtherProcedure.Date); - AddBlock(page, 2, 59, 8, ub04.Field74c_OtherProcedure.Code); - AddBlock(page, 12, 59, 6, ub04.Field74c_OtherProcedure.Date); - AddBlock(page, 20, 59, 8, ub04.Field74d_OtherProcedure.Code); - AddBlock(page, 29, 59, 6, ub04.Field74d_OtherProcedure.Date); - AddBlock(page, 38, 59, 8, ub04.Field74e_OtherProcedure.Code); - AddBlock(page, 48, 59, 6, ub04.Field74e_OtherProcedure.Date); - + AddBlock(page, 2, 57, 8, ub04.Field74_PrincipalProcedure.Code, debugOutFileName:fn); + AddBlock(page, 12, 57, 6, ub04.Field74_PrincipalProcedure.Date, debugOutFileName:fn); + AddBlock(page, 20, 57, 8, ub04.Field74a_OtherProcedure.Code, debugOutFileName:fn); + AddBlock(page, 29, 57, 6, ub04.Field74a_OtherProcedure.Date, debugOutFileName:fn); + AddBlock(page, 38, 57, 8, ub04.Field74b_OtherProcedure.Code, debugOutFileName:fn); + AddBlock(page, 48, 57, 6, ub04.Field74b_OtherProcedure.Date, debugOutFileName:fn); + AddBlock(page, 2, 59, 8, ub04.Field74c_OtherProcedure.Code, debugOutFileName:fn); + AddBlock(page, 12, 59, 6, ub04.Field74c_OtherProcedure.Date, debugOutFileName:fn); + AddBlock(page, 20, 59, 8, ub04.Field74d_OtherProcedure.Code, debugOutFileName:fn); + AddBlock(page, 29, 59, 6, ub04.Field74d_OtherProcedure.Date, debugOutFileName:fn); + AddBlock(page, 38, 59, 8, ub04.Field74e_OtherProcedure.Code, debugOutFileName:fn); + AddBlock(page, 48, 59, 6, ub04.Field74e_OtherProcedure.Date, debugOutFileName:fn); // Box 75 - AddBlock(page, 56, 56, 4, ub04.Field75.Line1); - AddBlock(page, 56, 57, 4, ub04.Field75.Line2); - AddBlock(page, 56, 58, 4, ub04.Field75.Line3); - AddBlock(page, 56, 59, 4, ub04.Field75.Line4); + AddBlock(page, 56, 56, 4, ub04.Field75.Line1, debugOutFileName:fn); + AddBlock(page, 56, 57, 4, ub04.Field75.Line2, debugOutFileName:fn); + AddBlock(page, 56, 58, 4, ub04.Field75.Line3, debugOutFileName:fn); + AddBlock(page, 56, 59, 4, ub04.Field75.Line4, debugOutFileName:fn); // Box 76 - AddBlock(page, 72, 56, 10, ub04.Field76_AttendingPhysician.Npi); - AddBlock(page, 86, 56, 2, ub04.Field76_AttendingPhysician.IdentifierQualifier); - AddBlock(page, 89, 56, 10, ub04.Field76_AttendingPhysician.Identifier); - AddBlock(page, 64, 57, 18, ub04.Field76_AttendingPhysician.LastName); - AddBlock(page, 86, 57, 13, ub04.Field76_AttendingPhysician.FirstName); + AddBlock(page, 72, 56, 10, ub04.Field76_AttendingPhysician.Npi, debugOutFileName:fn); + AddBlock(page, 86, 56, 2, ub04.Field76_AttendingPhysician.IdentifierQualifier, debugOutFileName:fn); + AddBlock(page, 89, 56, 10, ub04.Field76_AttendingPhysician.Identifier, debugOutFileName:fn); + AddBlock(page, 64, 57, 18, ub04.Field76_AttendingPhysician.LastName, debugOutFileName:fn); + AddBlock(page, 86, 57, 13, ub04.Field76_AttendingPhysician.FirstName, debugOutFileName:fn); // Box 77 - AddBlock(page, 72, 58, 10, ub04.Field77_OperatingPhysician.Npi); - AddBlock(page, 86, 58, 2, ub04.Field77_OperatingPhysician.IdentifierQualifier); - AddBlock(page, 89, 58, 10, ub04.Field77_OperatingPhysician.Identifier); - AddBlock(page, 64, 59, 18, ub04.Field77_OperatingPhysician.LastName); - AddBlock(page, 86, 59, 13, ub04.Field77_OperatingPhysician.FirstName); + AddBlock(page, 72, 58, 10, ub04.Field77_OperatingPhysician.Npi, debugOutFileName:fn); + AddBlock(page, 86, 58, 2, ub04.Field77_OperatingPhysician.IdentifierQualifier, debugOutFileName:fn); + AddBlock(page, 89, 58, 10, ub04.Field77_OperatingPhysician.Identifier, debugOutFileName:fn); + AddBlock(page, 64, 59, 18, ub04.Field77_OperatingPhysician.LastName, debugOutFileName:fn); + AddBlock(page, 86, 59, 13, ub04.Field77_OperatingPhysician.FirstName, debugOutFileName:fn); // Box 78 - AddBlock(page, 72, 60, 10, ub04.Field78_OtherProvider.Npi); - AddBlock(page, 67, 60, 2, ub04.Field78_OtherProvider.ProviderQualifier); - AddBlock(page, 86, 60, 2, ub04.Field78_OtherProvider.IdentifierQualifier); - AddBlock(page, 89, 60, 10, ub04.Field78_OtherProvider.Identifier); - AddBlock(page, 64, 61, 18, ub04.Field78_OtherProvider.LastName); - AddBlock(page, 86, 61, 13, ub04.Field78_OtherProvider.FirstName); + AddBlock(page, 72, 60, 10, ub04.Field78_OtherProvider.Npi, debugOutFileName:fn); + AddBlock(page, 67, 60, 2, ub04.Field78_OtherProvider.ProviderQualifier, debugOutFileName:fn); + AddBlock(page, 86, 60, 2, ub04.Field78_OtherProvider.IdentifierQualifier, debugOutFileName:fn); + AddBlock(page, 89, 60, 10, ub04.Field78_OtherProvider.Identifier, debugOutFileName:fn); + AddBlock(page, 64, 61, 18, ub04.Field78_OtherProvider.LastName, debugOutFileName:fn); + AddBlock(page, 86, 61, 13, ub04.Field78_OtherProvider.FirstName, debugOutFileName:fn); // Box 79 - AddBlock(page, 72, 62, 10, ub04.Field79_OtherProvider.Npi); - AddBlock(page, 67, 62, 2, ub04.Field79_OtherProvider.ProviderQualifier); - AddBlock(page, 86, 62, 2, ub04.Field79_OtherProvider.IdentifierQualifier); - AddBlock(page, 89, 62, 10, ub04.Field79_OtherProvider.Identifier); - AddBlock(page, 64, 63, 18, ub04.Field79_OtherProvider.LastName); - AddBlock(page, 86, 63, 13, ub04.Field79_OtherProvider.FirstName); + AddBlock(page, 72, 62, 10, ub04.Field79_OtherProvider.Npi, debugOutFileName:fn); + AddBlock(page, 67, 62, 2, ub04.Field79_OtherProvider.ProviderQualifier, debugOutFileName:fn); + AddBlock(page, 86, 62, 2, ub04.Field79_OtherProvider.IdentifierQualifier, debugOutFileName:fn); + AddBlock(page, 89, 62, 10, ub04.Field79_OtherProvider.Identifier, debugOutFileName:fn); + AddBlock(page, 64, 63, 18, ub04.Field79_OtherProvider.LastName, debugOutFileName:fn); + AddBlock(page, 86, 63, 13, ub04.Field79_OtherProvider.FirstName, debugOutFileName:fn); // Box 80 - AddBlock(page, 2, 61, 27, ub04.Field80_Remarks.Line1); - AddBlock(page, 2, 62, 27, ub04.Field80_Remarks.Line2); - AddBlock(page, 2, 63, 27, ub04.Field80_Remarks.Line3); + AddBlock(page, 2, 61, 27, ub04.Field80_Remarks.Line1, debugOutFileName:fn); + AddBlock(page, 2, 62, 27, ub04.Field80_Remarks.Line2, debugOutFileName:fn); + AddBlock(page, 2, 63, 27, ub04.Field80_Remarks.Line3, debugOutFileName:fn); // Box 81 - AddBlock(page, 32, 60, 2, ub04.Field81a.Qualifier); - AddBlock(page, 35, 60, 10, ub04.Field81a.Code1); - AddBlock(page, 48, 60, 12, ub04.Field81a.Code2); - AddBlock(page, 32, 61, 2, ub04.Field81b.Qualifier); - AddBlock(page, 35, 61, 10, ub04.Field81b.Code1); - AddBlock(page, 48, 61, 12, ub04.Field81b.Code2); - AddBlock(page, 32, 62, 2, ub04.Field81c.Qualifier); - AddBlock(page, 35, 62, 10, ub04.Field81c.Code1); - AddBlock(page, 48, 62, 12, ub04.Field81c.Code2); - AddBlock(page, 32, 63, 2, ub04.Field81d.Qualifier); - AddBlock(page, 35, 63, 10, ub04.Field81d.Code1); - AddBlock(page, 48, 63, 12, ub04.Field81d.Code2); - + AddBlock(page, 32, 60, 2, ub04.Field81a.Qualifier, debugOutFileName:fn); + AddBlock(page, 35, 60, 10, ub04.Field81a.Code1, debugOutFileName:fn); + AddBlock(page, 48, 60, 12, ub04.Field81a.Code2, debugOutFileName:fn); + AddBlock(page, 32, 61, 2, ub04.Field81b.Qualifier, debugOutFileName:fn); + AddBlock(page, 35, 61, 10, ub04.Field81b.Code1, debugOutFileName:fn); + AddBlock(page, 48, 61, 12, ub04.Field81b.Code2, debugOutFileName:fn); + AddBlock(page, 32, 62, 2, ub04.Field81c.Qualifier, debugOutFileName:fn); + AddBlock(page, 35, 62, 10, ub04.Field81c.Code1, debugOutFileName:fn); + AddBlock(page, 48, 62, 12, ub04.Field81c.Code2, debugOutFileName:fn); + AddBlock(page, 32, 63, 2, ub04.Field81d.Qualifier, debugOutFileName:fn); + AddBlock(page, 35, 63, 10, ub04.Field81d.Code1, debugOutFileName:fn); + AddBlock(page, 48, 63, 12, ub04.Field81d.Code2, debugOutFileName:fn); // reorder by locations; page.Blocks = page.Blocks.OrderBy(bl => bl.Top).ToList(); } } + + DebugFile(this, fn); return pages; } diff --git a/src/X12.Hipaa/Properties/Resources.Designer.cs b/src/X12.Hipaa/Properties/Resources.Designer.cs index ec077160..5eaf7ec5 100644 --- a/src/X12.Hipaa/Properties/Resources.Designer.cs +++ b/src/X12.Hipaa/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace X12.Hipaa.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/X12.Hipaa/X12.Hipaa.csproj b/src/X12.Hipaa/X12.Hipaa.csproj index 6a46bed0..41d00550 100644 --- a/src/X12.Hipaa/X12.Hipaa.csproj +++ b/src/X12.Hipaa/X12.Hipaa.csproj @@ -10,7 +10,7 @@ Properties X12.Hipaa X12.Hipaa - v4.6.1 + v4.7.2 512 %24/x12parser/trunk/src/OopFactory.X12.Hipaa . @@ -38,8 +38,40 @@ false + + ..\..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.8\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.10.0.8\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\..\packages\Microsoft.Extensions.Logging.Abstractions.10.0.8\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\..\packages\NLog.6.1.3\lib\net46\NLog.dll + + + ..\..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll + + + + ..\..\packages\System.Diagnostics.DiagnosticSource.10.0.8\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll + + + + ..\..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + ..\..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll + @@ -87,6 +119,7 @@ + @@ -166,6 +199,7 @@ Always + diff --git a/src/X12.Hipaa/packages.config b/src/X12.Hipaa/packages.config new file mode 100644 index 00000000..f0f9c545 --- /dev/null +++ b/src/X12.Hipaa/packages.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/X12.ImportX12/App.config b/src/X12.ImportX12/App.config index 934eb855..f09adf9f 100644 --- a/src/X12.ImportX12/App.config +++ b/src/X12.ImportX12/App.config @@ -20,7 +20,7 @@ - + @@ -31,4 +31,4 @@ - + diff --git a/src/X12.ImportX12/X12.ImportX12.csproj b/src/X12.ImportX12/X12.ImportX12.csproj index dd58772f..3617515b 100644 --- a/src/X12.ImportX12/X12.ImportX12.csproj +++ b/src/X12.ImportX12/X12.ImportX12.csproj @@ -10,7 +10,7 @@ Properties X12.ImportX12 X12.ImportX12 - v4.6.1 + v4.7.2 512 diff --git a/src/X12.Parsing/Properties/Resources.Designer.cs b/src/X12.Parsing/Properties/Resources.Designer.cs index ab29041e..9059b783 100644 --- a/src/X12.Parsing/Properties/Resources.Designer.cs +++ b/src/X12.Parsing/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace X12.Parsing.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/X12.Parsing/X12.Parsing.csproj b/src/X12.Parsing/X12.Parsing.csproj index 18d4957c..7cf2cfdb 100644 --- a/src/X12.Parsing/X12.Parsing.csproj +++ b/src/X12.Parsing/X12.Parsing.csproj @@ -9,8 +9,9 @@ Properties X12.Parsing X12.Parsing - v4.6.1 + v4.7.2 512 + true diff --git a/src/X12.Parsing/X12StreamReader.cs b/src/X12.Parsing/X12StreamReader.cs index 6169fa35..68d2ee1d 100644 --- a/src/X12.Parsing/X12StreamReader.cs +++ b/src/X12.Parsing/X12StreamReader.cs @@ -22,12 +22,16 @@ public class X12StreamReader : IDisposable /// used for reading /// used for properly reading the stream /// Array of characters to be ignored while reading + /// + + public X12StreamReader(Stream stream, Encoding encoding, char[] ignoredChars) { this.reader = new StreamReader(stream, encoding); var header = new char[106]; if (this.reader.Read(header, 0, 106) < 106) { + throw new ArgumentException(Resources.X12ReaderInvalidHeader); } diff --git a/src/X12.Shared/Models/HierarchicalLoop.cs b/src/X12.Shared/Models/HierarchicalLoop.cs index b5910781..7ae1b244 100644 --- a/src/X12.Shared/Models/HierarchicalLoop.cs +++ b/src/X12.Shared/Models/HierarchicalLoop.cs @@ -1,101 +1,87 @@ -namespace X12.Shared.Models -{ - using System.Collections.Generic; - using System.Linq; - using System.Xml.Serialization; - - using X12.Specifications; - - public class HierarchicalLoop : HierarchicalLoopContainer - { - /// - /// Initializes a new instance of the class with the provided parameters - /// - /// Parent container - /// Delimiter set indicating how to segregate segments and elements - /// Segment string for the loop - internal HierarchicalLoop(Container parent, X12DelimiterSet delimiters, string segment) - : base(parent, delimiters, segment) - { - } - - public HierarchicalLoopSpecification Specification { get; internal set; } - - internal override IList AllowedChildLoops => - this.Specification != null ? this.Specification.LoopSpecifications : new List(); - - internal override IList AllowedChildSegments => - this.Specification != null ? this.Specification.SegmentSpecifications : new List(); - - [XmlAttribute("Id")] - public string Id => this.GetElement(1); - - [XmlAttribute("ParentId")] - public string ParentId => this.GetElement(2); - - public string LevelCode => this.GetElement(3); - - public string HierarchicalChildCode - { - get { return this.GetElement(4); } - internal set { this.SetElement(4, value); } - } - - public override bool AllowsHierarchicalLoop(string levelCode) - { - return true; - } - - public override HierarchicalLoop AddHLoop(string id, string levelCode, bool? willHoldChildHLoops) - { - var hloop = base.AddHLoop(string.Format("HL{0}{1}{0}{2}{0}{3}{0}", this.DelimiterSet.ElementSeparator, id, this.Id, levelCode)); - if (willHoldChildHLoops.HasValue) - { - hloop.HierarchicalChildCode = willHoldChildHLoops.Value ? "1" : "0"; - } - - return hloop; - } - - internal override IEnumerable TrailerSegmentIds - { - get - { - var list = new List(); - - foreach (var spec in this.Specification.SegmentSpecifications.Where(ss => ss.Trailer)) - { - list.Add(spec.SegmentId); - } - - return list; - } - } - - internal override void WriteXml(System.Xml.XmlWriter writer) - { - if (!string.IsNullOrEmpty(this.SegmentId)) - { - writer.WriteStartElement("HierarchicalLoop"); - - if (this.Specification != null) - { - writer.WriteAttributeString("LoopId", this.Specification.LoopId); - writer.WriteAttributeString("LoopName", this.Specification.Name); - } - - writer.WriteAttributeString("Id", this.Id); - writer.WriteAttributeString("ParentId", this.ParentId); - - base.WriteXml(writer); - - writer.WriteEndElement(); - } - } - - public override string ToString() - { - return $"Loop(Id={this.Id},ParentId={this.ParentId},Level={this.LevelCode},ChildLoops={this.Loops.Count()}, ChildSegments={this.Segments.Count})"; - } - } -} +namespace X12.Shared.Models { + using System.Collections.Generic; + using System.Linq; + using System.Xml.Serialization; + + using X12.Specifications; + + public class HierarchicalLoop : HierarchicalLoopContainer { + /// + /// Initializes a new instance of the class with the provided parameters + /// + /// Parent container + /// Delimiter set indicating how to segregate segments and elements + /// Segment string for the loop + internal HierarchicalLoop(Container parent, X12DelimiterSet delimiters, string segment) + : base(parent, delimiters, segment) { + } + + public HierarchicalLoopSpecification Specification { get; internal set; } + + internal override IList AllowedChildLoops => + this.Specification != null ? this.Specification.LoopSpecifications : new List(); + + internal override IList AllowedChildSegments => + this.Specification != null ? this.Specification.SegmentSpecifications : new List(); + + [XmlAttribute("Id")] + public string Id => this.GetElement(1); + + [XmlAttribute("ParentId")] + public string ParentId => this.GetElement(2); + + public string LevelCode => this.GetElement(3); + + public string HierarchicalChildCode { + get { return this.GetElement(4); } + internal set { this.SetElement(4, value); } + } + + public override bool AllowsHierarchicalLoop(string levelCode) { + return true; + } + + public override HierarchicalLoop AddHLoop(string id, string levelCode, bool? willHoldChildHLoops) { + var hloop = base.AddHLoop(string.Format("HL{0}{1}{0}{2}{0}{3}{0}", this.DelimiterSet.ElementSeparator, id, this.Id, levelCode)); + if (willHoldChildHLoops.HasValue) { + hloop.HierarchicalChildCode = willHoldChildHLoops.Value ? "1" : "0"; + } + + return hloop; + } + + internal override IEnumerable TrailerSegmentIds { + get { + var list = new List(); + + foreach (var spec in this.Specification.SegmentSpecifications.Where(ss => ss.Trailer)) { + list.Add(spec.SegmentId); + } + + return list; + } + } + + internal override void WriteXml(System.Xml.XmlWriter writer) { + if (!string.IsNullOrEmpty(this.SegmentId)) { + writer.WriteStartElement("HierarchicalLoop"); + + if (this.Specification != null) { + writer.WriteAttributeString("LoopId", this.Specification.LoopId); + writer.WriteAttributeString("LoopName", this.Specification.Name); + } + + writer.WriteAttributeString("Id", this.Id); + writer.WriteAttributeString("ParentId", this.ParentId); + + base.WriteXml(writer); + + writer.WriteEndElement(); + } + } + + public override string ToString() { + return $"Loop(Id={this.Id},ParentId={this.ParentId},Level={this.LevelCode},ChildLoops={this.Loops.Count()}, ChildSegments={this.Segments.Count})"; + } + } + } diff --git a/src/X12.Shared/Properties/Resources.Designer.cs b/src/X12.Shared/Properties/Resources.Designer.cs index 57b3cacb..870ddbef 100644 --- a/src/X12.Shared/Properties/Resources.Designer.cs +++ b/src/X12.Shared/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace X12.Shared.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/X12.Shared/X12.Shared.csproj b/src/X12.Shared/X12.Shared.csproj index 27546544..d08559ed 100644 --- a/src/X12.Shared/X12.Shared.csproj +++ b/src/X12.Shared/X12.Shared.csproj @@ -9,8 +9,9 @@ Properties X12.Shared X12.Shared - v4.6.1 + v4.7.2 512 + true diff --git a/src/X12.Specifications/Properties/Resources.Designer.cs b/src/X12.Specifications/Properties/Resources.Designer.cs index 211bfa7c..4929beaf 100644 --- a/src/X12.Specifications/Properties/Resources.Designer.cs +++ b/src/X12.Specifications/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace X12.Specifications.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/X12.Specifications/Resource/GeogiaPacific-856-4010-Specification.xml b/src/X12.Specifications/Resource/GeogiaPacific-856-4010-Specification.xml new file mode 100644 index 00000000..125a7b3a --- /dev/null +++ b/src/X12.Specifications/Resource/GeogiaPacific-856-4010-Specification.xml @@ -0,0 +1,186 @@ + + + + + + + SHIPMENT + + + + + + + + + + + + + + + + + + + Bill-To-Party + + + + + + + + + + + + Intermedicate Consignee + + + + + + + + + + + + Supplier + + + + + + + + + + + + Ship To + + + + + + + + + + + + Ship From + + + + + + + + + + + + Selling Party + + + + + + + + + + + + Buying Party + + + + + + + + + + + + Service, Promotion, Allowance, or Charge + + + + + + ORDER + + + + + + + Service, Promotion, Allowance, or Charge + + + + + Buying Party + + + + + + + + + + + + + TARE + + + + PACK + + + + + + DETAIL + + + + + + + + ITEM + + + + + + + + + + + + + + + + + + + + + LOAD DETAIL + + + + + + \ No newline at end of file diff --git a/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.dtd b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.dtd new file mode 100644 index 00000000..2fdf64f8 --- /dev/null +++ b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.dtd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xml b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xml new file mode 100644 index 00000000..4bec47ec --- /dev/null +++ b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xml @@ -0,0 +1,477 @@ + + + + + SUBMITTER NAME + + + + + + + RECEIVER NAME + + + + + + BILLING PROVIDER HIERARCHICAL LEVEL + + + + BILLING PROVIDER NAME + + + + + + + + + + PAY-TO PROVIDER'S NAME + + + + + + + + PAY-TO PLAN NAME + + + + + + + + + + + SUBSCRIBER HIERARCHICAL LOOP + + + SUBSCRIBER NAME + + + + + + + + + + PAYER NAME + + + + + + + + + CLAIM INFORMATION + + + + + + + + + + + + + + + + ATTENDING PHYSICIAN NAME + + + + + + + + OPERATING PHYSICIAN NAME + + + + + + + OTHER OPERATING PHYSICIAN NAME + + + + + + + RENDERING PROVIDER NAME + + + + + + + SERVICE FACILITY LOCATION NAME + + + + + + + + + REFERRING PROVIDER NAME + + + + + + + OTHER SUBSCRIBER INFORMATION + + + + + + + + + + OTHER SUBSCRIBER NAME + + + + + + + + + OTHER PAYER NAME + + + + + + + + + + + + OTHER PAYER ATTENDING PROVIDER + + + + + + + OTHER PAYER OPERATING PHYSICIAN + + + + + + + OTHER PAYER OTHER OPERATING PHYSICIAN + + + + + + + OTHER PAYER SERVICE FACILITY LOCATION + + + + + + + OTHER PAYER RENDERING PROVIDER NAME + + + + + + + OTHER PAYER REFERRING PROVIDER + + + + + + + OTHER PAYER BILLING PROVIDER + + + + + + + + SERVICE LINE + + + + + + + + + + DRUG IDENTIFICATION + + + + + + OPERATION PHYSICIAN NAME + + + + + + + OTHER OPERATING PHYSICIAN NAME + + + + + + + RENDERING PROVIDER NAME + + + + + + + REFERRING PROVIDER NAME + + + + + + + Service Line Adjudication Information + + + + + + + + + + PATIENT HIERARCHICAL LOOP + + + PATIENT NAME + + + + + + + + + + CLAIM INFORMATION + + + + + + + + + + + + + + + + ATTENDING PHYSICIAN NAME + + + + + + + + OPERATING PHYSICIAN NAME + + + + + + + OTHER OPERATING PHYSICIAN NAME + + + + + + + RENDERING PROVIDER NAME + + + + + + + SERVICE FACILITY LOCATION NAME + + + + + + + + + REFERRING PROVIDER NAME + + + + + + + OTHER SUBSCRIBER INFORMATION + + + + + + + + + + OTHER SUBSCRIBER NAME + + + + + + + + + OTHER PAYER NAME + + + + + + + + + + + + OTHER PAYER ATTENDING PROVIDER + + + + + + + OTHER PAYER OPERATING PHYSICIAN + + + + + + + OTHER PAYER OTHER OPERATING PHYSICIAN + + + + + + + OTHER PAYER SERVICE FACILITY LOCATION + + + + + + + OTHER PAYER RENDERING PROVIDER NAME + + + + + + + OTHER PAYER REFERRING PROVIDER + + + + + + + OTHER PAYER BILLING PROVIDER + + + + + + + + SERVICE LINE + + + + + + + + + + DRUG IDENTIFICATION + + + + + + OPERATION PHYSICIAN NAME + + + + + + + OTHER OPERATING PHYSICIAN NAME + + + + + + + RENDERING PROVIDER NAME + + + + + + + REFERRING PROVIDER NAME + + + + + + + Service Line Adjudication Information + + + + + + + + + \ No newline at end of file diff --git a/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xsd b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xsd new file mode 100644 index 00000000..cb64b3de --- /dev/null +++ b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xsd @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + For Property & Casualty Claim For Property & Casualty Claim + + + + + DMG not in spec, but in example within spec Professional Segments DMG not in spec, but in example within spec Professional Segments + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xsd.xml b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xsd.xml new file mode 100644 index 00000000..24a93e6b --- /dev/null +++ b/src/X12.Specifications/Resource/MyCustom/Ansi-837I-5010Specification.xsd.xml @@ -0,0 +1,37 @@ + + string + + + string + + claustra + + string + mollitque + + + string + + + + + + PATIENT HIERARCHICAL LOOP + + string + + + string + + ac + + string + claustra + + + string + + + + + \ No newline at end of file diff --git a/src/X12.Specifications/X12.Specifications.csproj b/src/X12.Specifications/X12.Specifications.csproj index 34293f00..bf059d82 100644 --- a/src/X12.Specifications/X12.Specifications.csproj +++ b/src/X12.Specifications/X12.Specifications.csproj @@ -9,8 +9,9 @@ Properties X12.Specifications X12.Specifications - v4.6.1 + v4.7.2 512 + true @@ -823,9 +824,6 @@ Designer - - - @@ -1060,5 +1058,8 @@ Always + + + \ No newline at end of file diff --git a/src/X12.Sql/Properties/Resources.Designer.cs b/src/X12.Sql/Properties/Resources.Designer.cs index 0536fdbf..853bbad8 100644 --- a/src/X12.Sql/Properties/Resources.Designer.cs +++ b/src/X12.Sql/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace X12.Sql.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/X12.Sql/X12.Sql.csproj b/src/X12.Sql/X12.Sql.csproj index 6e7c5f0b..d7a033ee 100644 --- a/src/X12.Sql/X12.Sql.csproj +++ b/src/X12.Sql/X12.Sql.csproj @@ -10,7 +10,7 @@ Properties X12.Sql X12.Sql - v4.6.1 + v4.7.2 512 diff --git a/src/X12.TransformToX12/X12.TransformToX12.csproj b/src/X12.TransformToX12/X12.TransformToX12.csproj index d265a4e8..6550ee7c 100644 --- a/src/X12.TransformToX12/X12.TransformToX12.csproj +++ b/src/X12.TransformToX12/X12.TransformToX12.csproj @@ -10,7 +10,7 @@ Properties X12.TransformToX12 TransformToX12 - v4.6.1 + v4.7.2 512 diff --git a/src/X12.TransformToX12/app.config b/src/X12.TransformToX12/app.config index 3dbff35f..312bb3f2 100644 --- a/src/X12.TransformToX12/app.config +++ b/src/X12.TransformToX12/app.config @@ -1,3 +1,3 @@ - + diff --git a/src/X12.Transformations/X12.Transformations.csproj b/src/X12.Transformations/X12.Transformations.csproj index aa1af15c..454caa8f 100644 --- a/src/X12.Transformations/X12.Transformations.csproj +++ b/src/X12.Transformations/X12.Transformations.csproj @@ -9,8 +9,9 @@ Properties X12.Transformations X12.Transformations - v4.6.1 + v4.7.2 512 + true diff --git a/src/X12.UnbundleX12/X12.UnbundleX12.csproj b/src/X12.UnbundleX12/X12.UnbundleX12.csproj index d4705282..6147083a 100644 --- a/src/X12.UnbundleX12/X12.UnbundleX12.csproj +++ b/src/X12.UnbundleX12/X12.UnbundleX12.csproj @@ -10,7 +10,7 @@ Properties X12.UnbundleX12 UnbundleX12 - v4.6.1 + v4.7.2 512 diff --git a/src/X12.UnbundleX12/app.config b/src/X12.UnbundleX12/app.config index 3dbff35f..312bb3f2 100644 --- a/src/X12.UnbundleX12/app.config +++ b/src/X12.UnbundleX12/app.config @@ -1,3 +1,3 @@ - + diff --git a/src/X12.Validation/X12.Validation.csproj b/src/X12.Validation/X12.Validation.csproj index c370cceb..62f91118 100644 --- a/src/X12.Validation/X12.Validation.csproj +++ b/src/X12.Validation/X12.Validation.csproj @@ -10,7 +10,7 @@ Properties X12.Validation X12.Validation - v4.6.1 + v4.7.2 512 SAK SAK diff --git a/src/X12.X12Parser/Properties/Resources.Designer.cs b/src/X12.X12Parser/Properties/Resources.Designer.cs index cc7d6b20..72384fa3 100644 --- a/src/X12.X12Parser/Properties/Resources.Designer.cs +++ b/src/X12.X12Parser/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace X12.X12Parser.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/X12.X12Parser/X12.X12Parser.csproj b/src/X12.X12Parser/X12.X12Parser.csproj index 6c229ebf..ca628ca9 100644 --- a/src/X12.X12Parser/X12.X12Parser.csproj +++ b/src/X12.X12Parser/X12.X12Parser.csproj @@ -10,7 +10,7 @@ Properties X12.X12Parser X12Parser - v4.6.1 + v4.7.2 512 @@ -41,6 +41,9 @@ false + + ..\..\packages\Fonet.1.0\lib\net20\Fonet.dll + @@ -61,6 +64,7 @@ + diff --git a/src/X12.X12Parser/app.config b/src/X12.X12Parser/app.config index f59cc1d2..2d5091a4 100644 --- a/src/X12.X12Parser/app.config +++ b/src/X12.X12Parser/app.config @@ -1,10 +1,24 @@ - + + + - + + + + + + + + + + + + + diff --git a/src/X12.X12Parser/packages.config b/src/X12.X12Parser/packages.config index ab7e0f18..b1ec2543 100644 --- a/src/X12.X12Parser/packages.config +++ b/src/X12.X12Parser/packages.config @@ -1,5 +1,6 @@  + diff --git a/tests/X12.Hipaa.Tests.Unit/Claims/ClaimFormTester.cs b/tests/X12.Hipaa.Tests.Unit/Claims/ClaimFormTester.cs index 13f2720c..17fc5d17 100644 --- a/tests/X12.Hipaa.Tests.Unit/Claims/ClaimFormTester.cs +++ b/tests/X12.Hipaa.Tests.Unit/Claims/ClaimFormTester.cs @@ -49,15 +49,15 @@ public void X12ToClaimModelTest() // send the x12 stream in to obtain a claim object var document = service.Transform837ToClaimDocument(stream); var hcfaclaim = service.TransformClaimToHcfa1500(document.Claims.First()); - Assert.AreEqual("SMITH, TED", hcfaclaim.Field02_PatientsName); + Assert.AreEqual("Sterling, Joe", hcfaclaim.Field02_PatientsName); Assert.IsFalse(hcfaclaim.Field01_TypeOfCoverageIsMedicare); Assert.IsFalse(hcfaclaim.Field01_TypeOfCoverageIsMedicaid); Assert.IsFalse(hcfaclaim.Field03_PatientsSexFemale); Assert.IsTrue(hcfaclaim.Field03_PatientsSexMale); - Assert.AreEqual("99213", hcfaclaim.Field24_ServiceLines.First().ProcedureCode); - Assert.AreEqual("87070", hcfaclaim.Field24_ServiceLines[1].ProcedureCode); - Assert.AreEqual("99214", hcfaclaim.Field24_ServiceLines[2].ProcedureCode); - Assert.AreEqual("86663", hcfaclaim.Field24_ServiceLines[3].ProcedureCode); + Assert.AreEqual("89313", hcfaclaim.Field24_ServiceLines.First().ProcedureCode); + Assert.AreEqual("77070", hcfaclaim.Field24_ServiceLines[1].ProcedureCode); + Assert.AreEqual("96213", hcfaclaim.Field24_ServiceLines[2].ProcedureCode); + Assert.AreEqual("56663", hcfaclaim.Field24_ServiceLines[3].ProcedureCode); } /// @@ -79,6 +79,7 @@ public void X12ToHcfaPdfTest() var fonetDocument = new XmlDocument(); string fonetXml = service.TransformClaimDocumentToFoXml(document); fonetDocument.LoadXml(fonetXml); + } /// diff --git a/tests/X12.Hipaa.Tests.Unit/Claims/TestData/InstitutionalClaim4010.txt b/tests/X12.Hipaa.Tests.Unit/Claims/TestData/InstitutionalClaim4010.txt index 8f0a961c..0645a8d7 100644 --- a/tests/X12.Hipaa.Tests.Unit/Claims/TestData/InstitutionalClaim4010.txt +++ b/tests/X12.Hipaa.Tests.Unit/Claims/TestData/InstitutionalClaim4010.txt @@ -4,21 +4,21 @@ BHT*0019*00*0123*19960918*0932*CH~ REF*87*004010X096~ NM1*40*2*MEDICARE*****46*00120~ - PER*IC*JANE DOE*TE*9005555555~ - NM1*41*2*JONES HOSPITAL*****46*12345~ + PER*IC*Upwork Joe*TE*9005555555~ + NM1*41*2*Janes HOSPITAL*****46*12345~ HL*1**20*1~ PRV*BI*ZZ*203BA0200N~ - NM1*85*2*JONES HOSPITAL*****XX*330127~ + NM1*85*2*Upwork HOSPITAL*****XX*330127~ PRV*AT*ZZ*363LP0200N~ N3*225 MAIN STREET BARKLEY BUILDING~ - N4*CENTERVILLE*PA*17111~ + N4*Sterling*VA*17111~ REF*G2*987654080~ REF*EI*123456789~ HL*2*1*22*0~ SBR*P*18*******MB~ - NM1*IL*1*DOE*JOHN*T***MI*030005074A~ + NM1*IL*1*UPWORK*JOHN*T***MI*030005074A~ N3*125 CITY AVENUE~ - N4*CENTERVILLE*PA*17111~ + N4*Sterling*VA*17111~ DMG*D8*19261111*M~ NM1*PR*2*MEDICARE B*****PI*00435~ CLM*756048Q*89.93***14:A:1**Y*Y*Y~ diff --git a/tests/X12.Hipaa.Tests.Unit/X12.Hipaa.Tests.Unit.csproj b/tests/X12.Hipaa.Tests.Unit/X12.Hipaa.Tests.Unit.csproj index 282a9b87..c614b107 100644 --- a/tests/X12.Hipaa.Tests.Unit/X12.Hipaa.Tests.Unit.csproj +++ b/tests/X12.Hipaa.Tests.Unit/X12.Hipaa.Tests.Unit.csproj @@ -13,7 +13,7 @@ Properties X12.Hipaa.Tests.Unit X12.Hipaa.Tests.Unit - v4.6.1 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} SAK diff --git a/tests/X12.Tests.Integration/X12.Tests.Integration.csproj b/tests/X12.Tests.Integration/X12.Tests.Integration.csproj index a6589750..8dd3f776 100644 --- a/tests/X12.Tests.Integration/X12.Tests.Integration.csproj +++ b/tests/X12.Tests.Integration/X12.Tests.Integration.csproj @@ -13,7 +13,7 @@ Properties X12.Tests.Integration X12.Tests.Integration - v4.6.1 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} SAK diff --git a/tests/X12.Tests.Unit/X12.Tests.Unit.csproj b/tests/X12.Tests.Unit/X12.Tests.Unit.csproj index b81abea1..9f63ad65 100644 --- a/tests/X12.Tests.Unit/X12.Tests.Unit.csproj +++ b/tests/X12.Tests.Unit/X12.Tests.Unit.csproj @@ -13,7 +13,7 @@ Properties X12.Tests.Unit X12.Tests.Unit - v4.6.1 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} SAK diff --git a/tests/X12.Validation.Tests.Unit/X12.Validation.Tests.Unit.csproj b/tests/X12.Validation.Tests.Unit/X12.Validation.Tests.Unit.csproj index c14539f8..856dd641 100644 --- a/tests/X12.Validation.Tests.Unit/X12.Validation.Tests.Unit.csproj +++ b/tests/X12.Validation.Tests.Unit/X12.Validation.Tests.Unit.csproj @@ -13,7 +13,7 @@ Properties X12.Validation.Tests.Unit X12.Validation.Tests.Unit - v4.6.1 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} SAK