Ejemplo n.º 1
0
        protected override ValidationResult IsValid(object value, ValidationContext context)
        {
            N4     n4value  = (N4)context.ObjectType.GetProperty("N4").GetValue(context.ObjectInstance);
            NM1    nm1Value = (NM1)value;
            string ErrorString;

            if (nm1Value.NM12 == "1")
            {
                ErrorString = ValidateElement.GetValidation(nm1Value.NM13, Element.Required, 1, 60, "NM103") + ValidateElement.GetValidation(nm1Value.NM14, Element.Required, 1, 35, "NM104") + ValidateElement.GetValidation(nm1Value.NM15, Element.Required, 1, 25, "NM105") + ValidateElement.GetValidation(nm1Value.NM17, Element.Required, 1, 10, "NM107");
            }
            else if (nm1Value.NM12 == "2")
            {
                ErrorString = ValidateElement.GetValidation(nm1Value.NM13, Element.Required, 1, 60, "NM103") + ValidateElement.GetValidation(nm1Value.NM14, Element.Situational, 1, 35, "NM104") + ValidateElement.GetValidation(nm1Value.NM15, Element.Situational, 1, 25, "NM105") + ValidateElement.GetValidation(nm1Value.NM17, Element.Situational, 1, 10, "NM107");
            }
            else
            {
                ErrorString = "NM102 should be 1 or 2 ";
            }
            if (n4value.N44 == null || n4value.N44 == string.Empty)
            {
                ErrorMessage = ErrorString + (nm1Value.NM18 == "XX" ? "" : "NM108 should be XX ") + ValidateElement.GetValidation(nm1Value.NM19, Element.Required, 2, 80, "NM109");
            }
            if (ErrorString == string.Empty)
            {
                return(null);
            }
            return(new ValidationResult(ErrorString));
        }
Ejemplo n.º 2
0
 void Start()
 {
     SetDefault();
     N1 = Random.Range(0, 9);
     N2 = Random.Range(0, 9);
     N3 = Random.Range(0, 9);
     N4 = Random.Range(0, 9);
     Debug.Log(N1.ToString() + " " + N2.ToString() + " " + N3.ToString() + " " + N4.ToString());
 }
Ejemplo n.º 3
0
        ///<Summary>
        ///<CreatedOn>03/01/2018</CreatedOn>
        ///<Author>Sunny Bhardwaj</Author>
        ///<Description>Get N4 segment for All</Description>
        ///</Summary>
        ///
        public static N4 GetN4(string N401, string N402, string N403)
        {
            N4 N4 = new N4();

            N4.N401 = CreateString(N401, (int)SegmentLength.Two, (int)SegmentLength.Thirty, ' ', true);    //City
            N4.N402 = CreateString(N402, (int)SegmentLength.Two, (int)SegmentLength.Two, ' ', true);       //State
            N4.N403 = CreateString(N403, (int)SegmentLength.Three, (int)SegmentLength.Fifteen, ' ', true); //ZipCode
            return(N4);
        }
Ejemplo n.º 4
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            N4     n4Value     = (N4)value;
            string ErrorString = ValidateElement.GetValidation(n4Value.N41, Element.Required, 2, 30, "N401") + ValidateElement.GetValidation(n4Value.N42, Element.Situational, 2, 2, "N402") + ValidateElement.GetValidation(n4Value.N43, Element.Situational, 3, 15, "N403") + ValidateElement.GetValidation(n4Value.N44, Element.Situational, 2, 3, "N404") + ValidateElement.GetValidation(n4Value.N47, Element.Situational, 1, 3, "N407");

            if (ErrorString == string.Empty)
            {
                return(null);
            }
            return(new ValidationResult("Billing Provider Name:" + ErrorString));
        }
Ejemplo n.º 5
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            N4 n4Value = (N4)value;

            if (n4Value == null)
            {
                return(new ValidationResult("Pay To Address:N4 segment is required"));
            }
            string ErrorString = string.Empty;

            ErrorString = ValidateElement.GetValidation(n4Value.N41, Element.Required, 2, 30, "N401") + ValidateElement.GetValidation(n4Value.N42, Element.Situational, 2, 2, "N402") + ValidateElement.GetValidation(n4Value.N43, Element.Situational, 3, 15, "N403") + ValidateElement.GetValidation(n4Value.N44, Element.Situational, 2, 3, "N404") + ValidateElement.GetValidation(n4Value.N47, Element.Situational, 1, 3, "N407");
            if (ErrorString == string.Empty)
            {
                return(null);
            }
            return(new ValidationResult(ErrorString));
        }
Ejemplo n.º 6
0
        public static void ProvideRandDataSet(RichTextBox RTB)
        {
            int    N1, N2, N3, N4, N5;
            Random random = new Random();

            N1       = random.Next(0, 255);
            N2       = random.Next(0, 255);
            N3       = random.Next(0, 255);
            N4       = random.Next(0, 255);
            N5       = random.Next(0, 255);
            RTB.Text = N1.ToString() + ", " + N2.ToString() + ", " + N3.ToString() + ", " + N4.ToString() + ", " + N5.ToString();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Build purchase order.
        /// Original example from http://www.x12.org/examples/004010X357/tax-exempt-purchase-order/
        /// </summary>
        public static TS850 BuildPurchaseOrder(string controlNumber)
        {
            var result = new TS850();

            //  Indicates the start of a purchase order transaction set and assigns a control number.
            result.ST = new ST();
            result.ST.TransactionSetIdentifierCode_01 = "850";
            result.ST.TransactionSetControlNumber_02  = controlNumber.PadLeft(9, '0');

            //  Indicates that this is original purchase order number XX-1234, dated March 1, 2017, and that no acknowledgment is necessary.
            result.BEG = new BEG();
            result.BEG.TransactionSetPurposeCode_01 = "00";
            result.BEG.PurchaseOrderTypeCode_02     = "SA";
            result.BEG.PurchaseOrderNumber_03       = "XX-1234";
            result.BEG.Date_05 = "20170301";
            result.BEG.AcknowledgmentType_07 = "NA";

            //  Repeating PER
            result.PER = new List <PER>();

            //  Indicates that the name of the Buyer is Ed Smith, and his telephone number is (800) 123-4567.
            var per = new PER();

            per.ContactFunctionCode_01 = "BD";
            per.Name_02 = "ED SMITH";
            per.CommunicationNumberQualifier_03 = "TE";
            per.CommunicationNumber_04          = "8001234567";
            result.PER.Add(per);

            //  Repeating TAX
            result.TAX = new List <TAX>();

            //  Provides state tax exempt ID 53247765.
            var tax = new TAX();

            tax.TaxIdentificationNumber_01 = "53247765";
            tax.LocationQualifier_02       = "SP";
            tax.LocationIdentifier_03      = "CA";
            tax.TaxExemptCode_12           = "9";
            result.TAX.Add(tax);

            //  Repeating N1 Loops
            result.N1Loop = new List <Loop_N1_850>();

            //  Begin N1 Loop
            var n1Loop = new Loop_N1_850();

            //  Indicates that the buyer is ABC Aerospace. ABC's D-U-N-S+4 number is 123456789-0101.
            n1Loop.N1 = new N1();
            n1Loop.N1.EntityIdentifierCode_01 = "BY";
            n1Loop.N1.Name_02 = "ABC AEROSPACE";
            n1Loop.N1.IdentificationCodeQualifier_03 = "9";
            n1Loop.N1.IdentificationCode_04          = "1234567890101";

            //  Repeating N2
            n1Loop.N2 = new List <N2>();

            //  Provides additional name content for the buyer.
            var n2 = new N2();

            n2.Name_01 = "AIRCRAFT DIVISION";
            n1Loop.N2.Add(n2);

            //  Repeating N3
            n1Loop.N3 = new List <N3>();

            //  The buyer’s street address is 2000 Jet Blvd.
            var n3 = new N3();

            n3.AddressInformation_01 = "2000 JET BLVD";
            n1Loop.N3.Add(n3);

            //  Repeating N4
            n1Loop.N4 = new List <N4>();

            //  The buyer’s city, state, and ZIP is Fighter Town, CA 98898.
            var n4 = new N4();

            n4.CityName_01            = "FIGHTER TOWN";
            n4.StateorProvinceCode_02 = "CA";
            n4.PostalCode_03          = "98898";
            n1Loop.N4.Add(n4);

            //  End N1 Loop
            result.N1Loop.Add(n1Loop);

            //  Repeating PO1 Loops
            result.PO1Loop = new List <Loop_PO1_850>();

            //  Begin PO1 Loop
            var pO1Loop = new Loop_PO1_850();

            //  Indicates Baseline item 1 is a request to purchase 25 units, with a price of $36.00 each, of manufacturer's part number XYZ-1234.
            pO1Loop.PO1 = new PO1();
            pO1Loop.PO1.AssignedIdentification_01        = "1";
            pO1Loop.PO1.QuantityOrdered_02               = "25";
            pO1Loop.PO1.UnitorBasisforMeasurementCode_03 = "EA";
            pO1Loop.PO1.UnitPrice_04                 = "36";
            pO1Loop.PO1.BasisofUnitPriceCode_05      = "PE";
            pO1Loop.PO1.ProductServiceIDQualifier_06 = "MG";
            pO1Loop.PO1.ProductServiceID_07          = "XYZ-1234";

            //  Repeating MEA
            pO1Loop.MEA = new List <MEA>();

            //  Indicates that each unit in the order weighs 10 ounces.
            var mea = new MEA();

            mea.MeasurementReferenceIDCode_01 = "WT";
            mea.MeasurementQualifier_02       = "WT";
            mea.MeasurementValue_03           = "10";
            mea.CompositeUnitofMeasure_04     = new C001();
            mea.CompositeUnitofMeasure_04.UnitorBasisforMeasurementCode_01 = "OZ";
            pO1Loop.MEA.Add(mea);

            //  Indicates that no product substitution is allowed.
            pO1Loop.IT8 = new IT8();
            pO1Loop.IT8.ProductServiceSubstitutionCode_07 = "B0";

            //  Repeating SCH Loops
            pO1Loop.SCHLoop = new List <Loop_SCH_850>();

            //  Begin SCH Loop
            var schLoop = new Loop_SCH_850();

            //  Indicates that the 25 units are required to arrive by June 15, 2017.
            schLoop.SCH             = new SCH();
            schLoop.SCH.Quantity_01 = "25";
            schLoop.SCH.UnitorBasisforMeasurementCode_02 = "EA";
            schLoop.SCH.DateTimeQualifier_05             = "106";
            schLoop.SCH.Date_06 = "20170615";

            //  End SCH Loop
            pO1Loop.SCHLoop.Add(schLoop);

            //  End PO1 Loop
            result.PO1Loop.Add(pO1Loop);

            //  Begin CTT Loop
            result.CTTLoop = new Loop_CTT_850();

            //  Indicates that the purchase order contains 1 line item.
            result.CTTLoop.CTT = new CTT();
            result.CTTLoop.CTT.NumberofLineItems_01 = "1";

            //  Indicates that the total amount of the purchase order is $900.
            result.CTTLoop.AMT = new AMT();
            result.CTTLoop.AMT.AmountQualifierCode_01 = "TT";
            result.CTTLoop.AMT.MonetaryAmount_02      = "900";

            //  End CTT Loop

            return(result);
        }
Ejemplo n.º 8
0
 public string GetString()
 {
     return(N1.ToString() + "," + N2.ToString() + "," + N3.ToString() + "," + N4.ToString() + "," + N5.ToString());
 }
Ejemplo n.º 9
0
 public int GetInt()
 {
     return(int.Parse(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString() + "" + N5.ToString()));
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 改变数字
        /// </summary>
        /// <param name="num">数字</param>
        public void ChangeNum(double num)
        {
            if (num >= 0 && !IsPostive)
            {
                PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs {
                    OldValue = IsPostive, NewValue = true
                });
                IsPostive = true;
            }
            else if (num < 0 && IsPostive)
            {
                PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs {
                    OldValue = IsPostive, NewValue = false
                });
                IsPostive = false;
            }
            num = Math.Abs(num);
            string numstr = num.ToString();

            if (numstr.IndexOf("E+") >= 0)
            {
                string[] numstmp = Regex.Split(numstr, "E+");
                numstr = numstmp[0];
                int x = 1;
                if (numstmp[0].IndexOf(".") >= 0)
                {
                    numstr = numstr.Replace(".", "");
                    x      = numstmp[0].Length - numstmp[0].IndexOf(".");
                }
                for (int i = x - 1; i < int.Parse(numstmp[1]); i++)
                {
                    numstr += "0";
                }
            }
            int[] numids = new int[6];
            if (num >= 10000)
            {
                if (num >= 100000000)
                {
                    string tmp1 = numstr.Split('.')[0];
                    string tmp2 = tmp1.Substring(0, tmp1.Length - 8); //整数部分
                    string tmp3 = tmp1.Substring(tmp2.Length, 1);     //小数部分

                    numids[5] = -2;
                    numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3);

                    if (numids[4] >= 10)
                    {
                        numids[4] -= 10;
                        tmp2       = (int.Parse(tmp2) + 1).ToString();
                    }

                    for (int i = 1; i <= 4; i++)
                    {
                        if (tmp2.Length - i >= 0)
                        {
                            numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1));
                        }
                        else
                        {
                            if (4 - i == 3)
                            {
                                numids[3] = 0;
                            }
                            else
                            {
                                numids[4 - i] = -3;
                            }
                        }
                    }
                }
                else
                {
                    string tmp1 = numstr.Split('.')[0];
                    string tmp2 = tmp1.Substring(0, tmp1.Length - 4); //整数部分
                    string tmp3 = tmp1.Substring(tmp2.Length, 1);     //小数部分

                    numids[5] = -1;
                    numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3);

                    if (numids[4] >= 10)
                    {
                        numids[4] -= 10;
                        tmp2       = (int.Parse(tmp2) + 1).ToString();
                    }

                    for (int i = 1; i <= 4; i++)
                    {
                        if (tmp2.Length - i >= 0)
                        {
                            numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1));
                        }
                        else
                        {
                            numids[4 - i] = -3;
                        }
                    }
                }
            }
            else
            {
                string[] tmp1 = numstr.Split('.');
                for (int i = 1; i <= 4; i++)
                {
                    if (tmp1[0].Length - i >= 0)
                    {
                        numids[4 - i] = int.Parse(tmp1[0].Substring(tmp1[0].Length - i, 1));
                    }
                    else
                    {
                        numids[4 - i] = -3;
                    }
                }
                if (tmp1.Length > 1)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (tmp1[1].Length - i > 0)
                        {
                            numids[4 + i] = int.Parse(tmp1[1].Substring(i, 1));
                        }
                        else
                        {
                            numids[4 + i] = 0;
                        }
                    }
                }
            }
            N4.ChangeNum(numids[0]);
            N3.ChangeNum(numids[1]);
            N2.ChangeNum(numids[2]);
            N1.ChangeNum(numids[3]);
            if (numids[4] == 0 && numids[5] == 0)
            {
                numpoint.Visibility = Visibility.Hidden;
                P1.Visibility       = Visibility.Hidden;
                P2.Visibility       = Visibility.Hidden;
                ViewPanel.Margin    = new Thickness(30, 0, -28, 0);
            }
            else
            {
                numpoint.Visibility = Visibility.Visible;
                P1.Visibility       = Visibility.Visible;
                P2.Visibility       = Visibility.Visible;
                ViewPanel.Margin    = new Thickness(1, 0, 1, 0);
                P1.ChangeNum(numids[4]);
                P2.ChangeNum(numids[5]);
            }
        }
        public EDI835SchemaModel ParseEDI835(string fileText)
        {
            bool   payerSeg     = false;
            bool   payeeSeg     = false;
            string claimSegment = string.Empty;
            string segmentValue = string.Empty;

            string[] ediTextArray         = fileText.Split("~");
            CLP      clp                  = null;
            SVC      svc                  = null;
            bool     findNextCLP          = false;
            bool     isServiceLineVisited = false;

            foreach (string stringSegment in ediTextArray)
            {
                string[] segmentArray = stringSegment.Split("*");
                if (segmentArray != null)
                {
                    IEnumerable <string> values = Enum.GetValues(typeof(EDI835Segments))
                                                  .OfType <EDI835Segments>()
                                                  .Select(s => Convert.ToString(s));

                    if (values.Contains(segmentArray[0].TrimStart()))
                    {
                        if (segmentArray[0].TrimStart() != "CLP" && findNextCLP == true)
                        {
                            continue;
                        }
                        //else continue;
                        segmentValue = segmentArray[0].TrimStart();
                        if (claimSegment == "CLP")
                        {
                            segmentValue = "CLP";
                        }
                        switch (segmentValue)
                        {
                        case "ISA":
                        {
                            ISA ISA = GetSegmentInfo <ISA>(new ISA(), segmentArray);
                            ediSchemaModel.ISA = ISA;
                            break;
                        }

                        case "GS":
                        {
                            GS GS = GetSegmentInfo <GS>(new GS(), segmentArray);
                            ediSchemaModel.GS = GS;
                            break;
                        }

                        case "ST":
                        {
                            ST ST = GetSegmentInfo <ST>(new ST(), segmentArray);
                            ediSchemaModel.ST = ST;
                            break;
                        }

                        case "BPR":
                        {
                            BPR BPR = GetSegmentInfo <BPR>(new BPR(), segmentArray);
                            ediSchemaModel.BPR = BPR;
                            break;
                        }

                        case "TRN":
                        {
                            TRN TRN = GetSegmentInfo <TRN>(new TRN(), segmentArray);
                            ediSchemaModel.TRN = TRN;
                            break;
                        }

                        case "DTM":
                        {
                            DTM DTM = GetSegmentInfo <DTM>(new DTM(), segmentArray);
                            ediSchemaModel.DTM = DTM;
                            break;
                        }

                        case "N1":
                        {
                            if (segmentArray[1] == "PR")
                            {
                                N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray);
                                ediSchemaModel.PayerInfo = N1;
                                payerSeg = true;
                            }
                            else if (segmentArray[1] == "PE")
                            {
                                N1 N1 = GetSegmentInfo <N1>(new N1(), segmentArray);
                                ediSchemaModel.PayeeInfo = N1;
                                payeeSeg = true;
                            }
                            break;
                        }

                        case "N3":
                        {
                            if (payerSeg)
                            {
                                N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray);
                                ediSchemaModel.PayerAddress = N3;
                            }
                            else if (payeeSeg)
                            {
                                N3 N3 = GetSegmentInfo <N3>(new N3(), segmentArray);
                                ediSchemaModel.PayeeAddress = N3;
                            }

                            break;
                        }

                        case "N4":
                        {
                            if (payerSeg)
                            {
                                N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray);
                                ediSchemaModel.PayerCityStateZip = N4;
                                payerSeg = false;
                            }
                            else if (payeeSeg)
                            {
                                N4 N4 = GetSegmentInfo <N4>(new N4(), segmentArray);
                                ediSchemaModel.PayeeCityStateZip = N4;
                                payeeSeg = false;
                            }
                            break;
                        }

                        case "CLP":
                        {
                            claimSegment = "CLP";
                            switch (segmentArray[0].TrimStart())
                            {
                            case "CLP":
                            {
                                findNextCLP = false;
                                if (clp != null)
                                {
                                    ediSchemaModel.CLPList.Add(clp);
                                    isServiceLineVisited = false;
                                    clp = null;
                                }
                                clp = GetSegmentInfo <CLP>(new CLP(), segmentArray);
                                break;
                            }

                            case "SVC":
                            {
                                //if (svc != null)
                                //{
                                //    if (clp.SVCList == null) clp.SVCList = new List<SVC>();
                                //    clp.SVCList.Add(svc);
                                //    svc = null;
                                //}
                                svc = GetSegmentInfo <SVC>(new SVC(), segmentArray);
                                if (clp != null && clp.SVCList == null)
                                {
                                    clp.SVCList = new List <SVC>();
                                }

                                clp.SVCList.Add(svc);
                                isServiceLineVisited = true;
                                break;
                            }

                            case "CAS":
                            {
                                if (isServiceLineVisited)
                                {
                                    CAS CAS = GetSegmentInfo <CAS>(new CAS(), segmentArray);
                                    if (svc.SVCAdjList == null)
                                    {
                                        svc.SVCAdjList = new List <CAS>();
                                    }
                                    svc.SVCAdjList.Add(CAS);
                                    CAS = null;
                                }
                                break;
                            }

                            case "REF":
                            {
                                if (segmentArray[1].Trim() == "6R" && svc != null && svc.REF == null)
                                {
                                    svc.REF = new REF();
                                    svc.REF = GetSegmentInfo <REF>(new REF(), segmentArray);
                                }
                                break;
                            }

                            case "GE":
                            {
                                if (clp != null)
                                {
                                    ediSchemaModel.CLPList.Add(clp);
                                    isServiceLineVisited = false;
                                    clp         = null;
                                    findNextCLP = true;
                                }
                                break;
                            }

                            default:
                            {
                                break;
                            }
                            }
                            break;
                        }
                        }
                    }
                }
            }
            return(ediSchemaModel);
        }
        private static TS850 Import(string[] lines)
        {
            var result = new TS850();

            if (lines.Length < 2)
            {
                throw new Exception("Insufficient number of lines");
            }

            //  line[0] is the header
            var firstLine = lines[1];

            //  ST
            result.ST = new Core.Model.Edi.X12.ST();
            result.ST.TransactionSetIdentifierCode_01 = "850";
            result.ST.TransactionSetControlNumber_02  = "000000001";

            var firstLineItems = firstLine.Split(new[] { ',' });

            if (firstLineItems.Count() < 13)
            {
                throw new Exception("Insufficient number of columns");
            }

            //  BEG
            result.BEG = new BEG();
            result.BEG.TransactionSetPurposeCode_01 = "01";
            result.BEG.PurchaseOrderTypeCode_02     = "02";
            result.BEG.PurchaseOrderNumber_03       = firstLineItems[5];
            result.BEG.Date_05 = firstLineItems[6];

            //  Repeating N1 Loops
            result.N1Loop = new List <Loop_N1_850>();

            //  Begin N1 Loop
            var n1Loop = new Loop_N1_850();

            //  N1
            n1Loop.N1 = new N1();
            n1Loop.N1.EntityIdentifierCode_01 = "ST";
            n1Loop.N1.Name_02 = firstLineItems[7];
            n1Loop.N1.IdentificationCodeQualifier_03 = "ZZ";
            n1Loop.N1.IdentificationCode_04          = firstLineItems[8];

            //  Repeating N3
            n1Loop.N3 = new List <N3>();

            //  N3
            var n3 = new N3();

            n3.AddressInformation_01 = firstLineItems[9];
            n1Loop.N3.Add(n3);

            //  Repeating N4
            n1Loop.N4 = new List <N4>();

            //  N4
            var n4 = new N4();

            n4.CityName_01            = firstLineItems[10];
            n4.StateorProvinceCode_02 = firstLineItems[11];
            n4.PostalCode_03          = firstLineItems[12];
            n1Loop.N4.Add(n4);

            //  End N1 Loop
            result.N1Loop.Add(n1Loop);

            //  Repeating PO1 Loops
            result.PO1Loop = new List <Loop_PO1_850>();

            foreach (var line in lines.Skip(1))
            {
                var lineItems = line.Split(new[] { ',' });
                if (lineItems.Count() < 13)
                {
                    throw new Exception("Insufficient number of columns");
                }

                //  Begin PO1 Loop
                var po1Loop = new Loop_PO1_850();

                //  PO1
                po1Loop.PO1 = new PO1();
                po1Loop.PO1.AssignedIdentification_01        = lineItems[0];
                po1Loop.PO1.QuantityOrdered_02               = lineItems[2];
                po1Loop.PO1.UnitorBasisforMeasurementCode_03 = lineItems[4];
                po1Loop.PO1.UnitPrice_04 = lineItems[3];
                po1Loop.PO1.ProductServiceIDQualifier_06 = "UP";
                po1Loop.PO1.ProductServiceID_07          = lineItems[1];

                //  End PO1 Loop
                result.PO1Loop.Add(po1Loop);
            }

            return(result);
        }
        public string BuildEdi(List <Patient> patientList, InsuranceCompany insurance,
                               BillingProvider billingProvider)
        {
            var buildEdi = new StringBuilder();
            //Begin ISA
            var buildisa = new Isa();

            buildEdi.Append(buildisa.BuildIsa());

            //Begin GS
            var buildGs = new Gs();

            buildEdi.Append(buildGs.BuildGs());

            //Begin ST
            var buildSt = new St();

            buildEdi.Append(buildSt.BuildSt());

            //Begin BPR
            var buildBpr = new Bpr();

            buildEdi.Append(buildBpr.BuildBpr(insurance));

            //Build TRN
            var buildTrn = new Trn();

            buildEdi.Append(buildTrn.BuildTrn(insurance));

            //Ref Segment conditional, not included at this time
            //REF Receiver Identification
            //REF01 Receiver Reference Number
            //REF02 Receiver Reference Identification

            //Build DTM Loop Production Date
            var buildDtm = new Dtm();

            buildEdi.Append(buildDtm.BuildDtm(patientList));

            //Build N1 Insurance Company Identification Segment 1000A
            var buildNOne = new N1();

            buildEdi.Append(buildNOne.BuildNOne(insurance));

            //BuildN3 Insurance Company Identification Segment 1000A
            var buildNThree = new N3();

            buildEdi.Append(buildNThree.BuildNThree(insurance));

            // Build N4 Insurance Company Identification 1000A
            var buildNFour = new N4();

            buildEdi.Append(buildNFour.BuildN4(insurance));

            //Build Ref Insurance Company Identification 1000A
            var buildRef = new Ref();

            buildEdi.Append(buildRef.BuildRef());

            //Build Per Insurance Company Identification 1000A
            var buildPer = new Per();

            buildEdi.Append(buildPer.BuildPerPhone());

            //Build Per Insurance Company Website Information 1000A
            buildEdi.Append(buildPer.BuildPerWebSite());

            //Build N1 Provider Identifier Segment 1000B
            buildEdi.Append(buildNOne.BuildNOne(billingProvider));

            //Build N3 Provider Identifier Segment 1000B
            buildEdi.Append(buildNThree.BuildNThree(billingProvider));

            //Build N4 Provider Identifier Segment 1000B
            buildEdi.Append(buildNFour.BuildN4(billingProvider));

            //Build Ref Provider Identifier 1000B
            buildEdi.Append(buildRef.BuildRefAdditionalPayee());
            buildEdi.Append(buildRef.BuildRefAdditionalPayeeTwo());

            //LX Segment 2000B
            var buildLx = new Lx();

            buildEdi.Append(buildLx.BuildLx());

            //TS3 2000B NOT USED
            //TS2 2000B NOT USED
            //CLP Segment 2100

            foreach (Patient patient in patientList)
            {
                var buildClp = new Clp();
                buildEdi.Append(buildClp.BuildClp(patient));

                var buildNmOne = new Nm1();
                buildEdi.Append(buildNmOne.BuildNm1(patient));


                //MIA Inpatient Adjudication Information
                //MOA Outpatient Adjudication Information
                //REF Other CLaim Related Identification


                //Ref Rendering Provider Identifier 2100
                buildEdi.Append(buildRef.BuildRef(patient.Provider));

                //DTM Statement From or To Date 2100
                buildEdi.Append(buildDtm.BuildDtm(patient));

                //PER Claim Contact Information 2100

                //SVC Level 2110
                var buildSvc = new Svc();

                buildEdi.Append(buildSvc.BuildSvc(patient.Charge));
                buildEdi.Append(buildDtm.BuildDtm(patient.Charge));

                var buildCas = new Cas();
                if (patient.Charge.AdjustmentList != null)
                {
                    buildEdi.Append(buildCas.BuildCas(patient.Charge.AdjustmentList));
                    buildEdi.Append(buildCas.BuildCas(patient.Charge));
                }
                else
                {
                    buildEdi.Append(buildCas.BuildCas(patient.Charge));
                }
                buildEdi.Append(buildRef.BuildRefControlNumber());

                var buildAmt = new Amt();
                buildEdi.Append(buildAmt.BuildAmt(patient.Charge));
                //QTY 2110
                //LQ 2110
                //LQ01 Service Line Remittance Remark Code 1
                //LQ02 Service Line Remittance Remark Code 2

                foreach (AddonCharge addon in patient.Charge.AddonChargeList)
                {
                    buildEdi.Append(buildSvc.BuildSvc(addon));
                    buildEdi.Append(buildCas.BuildCas(addon.AdjustmentList));
                    buildEdi.Append(buildRef.BuildRefControlNumber());
                    buildEdi.Append(buildAmt.BuildAmt(addon));
                }
            }

            var buildSe = new Se();

            buildEdi.Append(buildSe.BuildSe());

            var buildGe = new Ge();

            buildEdi.Append(buildGe.BuildGe());

            var buildIea = new Iea();

            buildEdi.Append(buildIea.BuildIea());

            return(buildEdi.ToString());
        }