# frozen_string_literal: true
module Stupidedi
  module TransactionSets
    module FortyTen
      module Implementations
        module X091A1
          b = Builder
          d = Schema
          r = SegmentReqs
          e = ElementReqs
          s = SegmentDefs

          HP835 = b.build("HP", "835", "",
            d::TableDef.header("1 - Header",
              b::Segment(100, s::ST, "Transaction Set Header", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Transaction Set Identifier Code", b::Values("835")),
                b::Element(e::Required,    "Transaction Set Control Number")),
              b::Segment(200, s::BPR, "Financial Information", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Transaction Handling Code", b::Values("C", "D", "H", "I", "P", "U", "X")),
                b::Element(e::Required,    "Total Actual Provider Payment Amount", b::MaxLength(11)),
                b::Element(e::Required,    "Credit or Debit Flag Code", b::Values("C", "D")),
                b::Element(e::Required,    "Payment Method Code", b::Values("ACH", "BOP", "CHK", "FWT", "NON")),
                b::Element(e::Situational, "Payment Format Code", b::Values("CCP", "CTX")),
                b::Element(e::Situational, "Depository Financial Institution (DFI) Identification Number Qualifier", b::Values("01", "04")),
                b::Element(e::Situational, "Sender DFI Number"),
                b::Element(e::Situational, "Account Number Qualifier", b::Values("DA")),
                b::Element(e::Situational, "Sender Bank Account Number"),
                b::Element(e::Situational, "Payer Identifier"),
                b::Element(e::Situational, "Originating Company Supplemental Code"),
                b::Element(e::Situational, "Depository Financial Institution (DFI) Identification Number Qualifier", b::Values("01", "04")),
                b::Element(e::Situational, "Receiver or Provider Bank ID Number"),
                b::Element(e::Situational, "Account Number Qualifier", b::Values("DA", "SG")),
                b::Element(e::Situational, "Receiver or Provider Account Number"),
                b::Element(e::Required,    "Check Issue or EFT Effective Date"),
                b::Element(e::NotUsed,     "Business Function Code"),
                b::Element(e::NotUsed,     "(DFI) ID Number Qualifier"),
                b::Element(e::NotUsed,     "(DFI) Identification Number"),
                b::Element(e::NotUsed,     "Account Number Qualifier"),
                b::Element(e::NotUsed,     "Account Number")),
              b::Segment(400, s::TRN, "Reassociation Trace Number", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Trace Type Code", b::Values("1")),
                b::Element(e::Required,    "Check or EFT Trace Number"),
                b::Element(e::Required,    "Payer Identifier"),
                b::Element(e::Situational, "Originating Company Supplemental Code")),
              b::Segment(500, s::CUR, "Foreign Currency Information", r::Situational, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Entity Identifier Code", b::Values("PR")),
                b::Element(e::Required,    "Currency Code"),
                b::Element(e::Situational, "Exchange Rate"),
                b::Element(e::NotUsed,     "Entity Identifier Code"),
                b::Element(e::NotUsed,     "Currency Code"),
                b::Element(e::NotUsed,     "Currency Market/Exchange Code"),
                b::Element(e::NotUsed,     "Date/Time Qualifier"),
                b::Element(e::NotUsed,     "Date"),
                b::Element(e::NotUsed,     "Time"),
                b::Element(e::NotUsed,     "Date/Time Qualifier"),
                b::Element(e::NotUsed,     "Date"),
                b::Element(e::NotUsed,     "Time"),
                b::Element(e::NotUsed,     "Date/Time Qualifier"),
                b::Element(e::NotUsed,     "Date"),
                b::Element(e::NotUsed,     "Time"),
                b::Element(e::NotUsed,     "Date/Time Qualifier"),
                b::Element(e::NotUsed,     "Date"),
                b::Element(e::NotUsed,     "Time"),
                b::Element(e::NotUsed,     "Date/Time Qualifier"),
                b::Element(e::NotUsed,     "Date"),
                b::Element(e::NotUsed,     "Time")),
              b::Segment(600, s::REF, "Receiver Identification", r::Situational, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Reference Identification Qualifier", b::Values("EV")),
                b::Element(e::Required,    "Receiver Identifier"),
                b::Element(e::NotUsed,     "Description"),
                b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
              b::Segment(600, s::REF, "Version Identification", r::Situational, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Reference Identification Qualifier", b::Values("F2")),
                b::Element(e::Required,    "Version Identification Code"),
                b::Element(e::NotUsed,     "Description"),
                b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
              b::Segment(700, s::DTM, "Production Date", r::Situational, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Date/Time Qualifier", b::Values("405")),
                b::Element(e::Required,    "Production Date"),
                b::Element(e::NotUsed,     "Time"),
                b::Element(e::NotUsed,     "Time Code"),
                b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                b::Element(e::NotUsed,     "Date Time Period")),

              d::LoopDef.build("1000A PAYER IDENTIFICATION", d::RepeatCount.bounded(1),
                b::Segment( 800, s::N1, "Payer Identification", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Entity Identifier Code", b::Values("PR")),
                  b::Element(e::Situational, "Payer Name"),
                  b::Element(e::Situational, "Identification Code Qualifier", b::Values("XV")),
                  b::Element(e::Situational, "Payer Identifier"),
                  b::Element(e::NotUsed,     "Entity Relationship Code"),
                  b::Element(e::NotUsed,     "Entity Identifier Code")),
                b::Segment(1000, s::N3, "Payer Address", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Payer Address Line"),
                  b::Element(e::Situational, "Payer Address Line")),
                b::Segment(1100, s::N4, "Payer City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Payer City Name"),
                  b::Element(e::Required,    "Payer State or Province Code"),
                  b::Element(e::Required,    "Payer Postal Zone or ZIP Code"),
                  b::Element(e::NotUsed, "Country Code"),
                  b::Element(e::NotUsed,     "Location Qualifier"),
                  b::Element(e::NotUsed,     "Location Identifier")),
                b::Segment(1200, s::REF, "Additional Payer Identification", r::Situational, d::RepeatCount.bounded(4),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U", "EO", "HI", "NF")),
                  b::Element(e::Required,    "Additional Payer Identifier"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1300, s::PER, "Payer Contact Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Contact Function Code", b::Values("CX")),
                  b::Element(e::Situational, "Payer Contact Name"),
                  b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "FX", "TE")),
                  b::Element(e::Situational, "Communication Number"),
                  b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                  b::Element(e::Situational, "Communication Number"),
                  b::Element(e::Situational, "Communication Number Qualifier", b::Values("EX")),
                  b::Element(e::Situational, "Communication Number"),
                  b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

              d::LoopDef.build("1000B PAYEE IDENTIFICATION", d::RepeatCount.bounded(1),
                b::Segment( 800, s::N1, "Payee Identification", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Entity Identifier Code", b::Values("PE")),
                  b::Element(e::Situational, "Payee Name"),
                  b::Element(e::Required,    "Identification Code Qualifier", b::Values("FI", "XX")),
                  b::Element(e::Required,    "Payee Identification Code"),
                  b::Element(e::NotUsed,     "Entity Relationship Code"),
                  b::Element(e::NotUsed,     "Entity Identifier Code")),
                b::Segment(1000, s::N3, "Payee Address", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Payee Address Line"),
                  b::Element(e::Situational, "Payee Address Line")),
                b::Segment(1100, s::N4, "Payee City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Payee City Name"),
                  b::Element(e::Required,    "Payee State or Province Code"),
                  b::Element(e::Required,    "Payee Postal Zone or ZIP Code"),
                  b::Element(e::Situational, "Country Code"),
                  b::Element(e::NotUsed,     "Location Qualifier"),
                  b::Element(e::NotUsed,     "Location Identifier")),
                b::Segment(1200, s::REF, "Payee Additional Identification", r::Situational, d::RepeatCount.unbounded,
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1A", "1B", "1C", "1E", "1F", "1G", "1H", "D3", "G2", "N5", "PQ", "TJ")),
                  b::Element(e::Required,    "Additional Payee Identifier"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")))),

            d::TableDef.detail("2 - Detail",
              d::LoopDef.build("2000 HEADER NUMBER", d::RepeatCount.unbounded,
                b::Segment(30, s::LX, "Header Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Assigned Number")),
                b::Segment(50, s::TS3, "Provider Summary Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Provider Identifier"),
                  b::Element(e::Required,    "Facility Type Code"),
                  b::Element(e::Required,    "Fiscal Period Date"),
                  b::Element(e::Required,    "Total Claim Count"),
                  b::Element(e::Required,    "Total Claim Charge Amount"),
                  b::Element(e::Situational, "Total Covered Charge Amount"),
                  b::Element(e::Situational, "Total Noncovered Charge Amount"),
                  b::Element(e::Situational, "Total Denied Charge Amount"),
                  b::Element(e::Situational, "Total Provider Payment Amount"),
                  b::Element(e::Situational, "Total Interest Amount"),
                  b::Element(e::Situational, "Total Contractual Adjustment Amount"),
                  b::Element(e::Situational, "Total Gramm-Rudman Reduction Amount"),
                  b::Element(e::Situational, "Total MSP Payer Amount"),
                  b::Element(e::Situational, "Total Blood Deductible Amount"),
                  b::Element(e::Situational, "Total Non-Lab Charge Amount"),
                  b::Element(e::Situational, "Total Coinsurance Amount"),
                  b::Element(e::Situational, "Total HCPCS Reported Charge Amount"),
                  b::Element(e::Situational, "Total HCPCS Payable Amount"),
                  b::Element(e::Situational, "Total Deductible Amount"),
                  b::Element(e::Situational, "Total Professional Component Amount"),
                  b::Element(e::Situational, "Total MSP Patient Liability Met Amount"),
                  b::Element(e::Situational, "Total Patient Reimbursement Amount"),
                  b::Element(e::Situational, "Total PIP Claim Count"),
                  b::Element(e::Situational, "Total PIP Adjustment Amount")),
                b::Segment(70, s::TS2, "Provider Supplemental Summary Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Situational,  "Total DRG Amount"),
                  b::Element(e::Situational,  "Total Federal Specific Amount"),
                  b::Element(e::Situational,  "Total Hospital Specific Amount"),
                  b::Element(e::Situational,  "Total Disproportionate Share Amount"),
                  b::Element(e::Situational,  "Total Capital Amount"),
                  b::Element(e::Situational,  "Total Indirect Medical Education Amount"),
                  b::Element(e::Situational,  "Total Outlier Day Count"),
                  b::Element(e::Situational,  "Total Day Outlier Amount"),
                  b::Element(e::Situational,  "Total Cost Outlier Amount"),
                  b::Element(e::Situational,  "Average DRG Length of Stay"),
                  b::Element(e::Situational,  "Total Discharge Count"),
                  b::Element(e::Situational,  "Total Cost Report Day Count"),
                  b::Element(e::Situational,  "Total Covered Day Count"),
                  b::Element(e::Situational,  "Total Noncovered Day Count"),
                  b::Element(e::Situational,  "Total MSP Pass-Through Amount"),
                  b::Element(e::Situational,  "Average DRG Weight"),
                  b::Element(e::Situational,  "Total PPS Capital FSP DRG Amount"),
                  b::Element(e::Situational,  "Total PPS Capital HSP DRG Amount"),
                  b::Element(e::Situational,  "Total PPS DSH DRG Amount")),

                d::LoopDef.build("2100 CLAIM PAYMENT INFORMATION", d::RepeatCount.unbounded,
                  b::Segment( 100, s::CLP, "Claim Payment Information", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Patient Control Number"),
                    b::Element(e::Required,    "Claim Status Code", b::Values("1", "2", "3", "4", "5", "10", "13", "15", "16", "17", "19", "20", "21", "22", "23", "25", "27")),
                    b::Element(e::Required,    "Total Claim Charge Amount"),
                    b::Element(e::Required,    "Claim Payment Amount"),
                    b::Element(e::Situational, "Patient Responsibility Amount"),
                    b::Element(e::Required,    "Claim Filing Indicator Code", b::Values("12", "13", "14", "15", "16", "AM", "CH", "DS", "HM", "LM", "MA", "MB", "MC", "OF", "TV", "VA", "WC")),
                    b::Element(e::Situational, "Payer Claim Control Number"),
                    b::Element(e::Situational, "Facility Type Code"),
                    b::Element(e::Situational, "Claim Frequency Code"),
                    b::Element(e::NotUsed,     "Patient Status Code"),
                    b::Element(e::Situational, "Diagnosis Related Group (DRG) Code"),
                    b::Element(e::Situational, "Diagnosis Related Group (DRG) Weight"),
                    b::Element(e::Situational, "Discharge Fraction")),
                  b::Segment( 200, s::CAS, "Claim Adjustment", r::Situational, d::RepeatCount.bounded(99),
                    b::Element(e::Required,    "Claim Adjustment Group Code", b::Values("CO", "CR", "OA", "PI", "PR")),
                    b::Element(e::Required,    "Adjustment Reason Code"),
                    b::Element(e::Required,    "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity")),
                  b::Segment( 300, s::NM1, "Patient Name", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("QC")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                    b::Element(e::Required,    "Patient Last Name"),
                    b::Element(e::Required,    "Patient First Name"),
                    b::Element(e::Situational, "Patient Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Patient Name Suffix"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("34", "HN", "II", "MI", "MR")),
                    b::Element(e::Situational, "Patient Identifier"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code")),
                  b::Segment( 300, s::NM1, "Insured Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("IL")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::Situational, "Subscriber Last Name"),
                    b::Element(e::Situational, "Subscriber First Name"),
                    b::Element(e::Situational, "Subscriber Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Subscriber Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("34", "HN", "MI")),
                    b::Element(e::Required,    "Subscriber Identifier"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code")),
                  b::Segment( 300, s::NM1, "Corrected Patient/Insured Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("74")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::Situational, "Corrected Patient or Insured Last Name"),
                    b::Element(e::Situational, "Corrected Patient or Insured First Name"),
                    b::Element(e::Situational, "Corrected Patient or Insured Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Corrected Patient or Insured Name Suffix"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("C")),
                    b::Element(e::Situational, "Corrected Insured Identification Indicator"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code")),
                  b::Segment( 300, s::NM1, "Service Provider Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("82")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::Situational, "Rendering Provider Last or Organization Name"),
                    b::Element(e::Situational, "Rendering Provider First Name"),
                    b::Element(e::Situational, "Rendering Provider Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Rendering Provider Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("BD", "BS", "FI", "MC", "PC", "SL", "UP", "XX")),
                    b::Element(e::Required,    "Rendering Provider Identifier"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code")),
                  b::Segment( 300, s::NM1, "Crossover Carrier Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("TT")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                    b::Element(e::Required,    "Coordination of Benefits Carrier Name"),
                    b::Element(e::NotUsed,     "Name First"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("AD", "FI", "NI", "PI", "PP", "XV")),
                    b::Element(e::Required,    "Coordination of Benefits Carrient Identifier"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code")),
                  b::Segment( 300, s::NM1, "Corrected Priority Payer Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("PR")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                    b::Element(e::Required,    "Corrected Priority Payer Name"),
                    b::Element(e::NotUsed,     "Name First"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("AD", "FI", "NI", "PI", "PP", "XV")),
                    b::Element(e::Required,    "Corrected Priority Payer Identification Number"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code")),
                  b::Segment( 330, s::MIA, "Inpatient Adjudication Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Covered Days or Visits Count"),
                    b::Element(e::Situational, "PPS Operating Outlier Amount"),
                    b::Element(e::Situational, "Lifetime Psychiatric Days Count"),
                    b::Element(e::Situational, "Claim DRG Amount"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Claim Disproportionate Share Amount"),
                    b::Element(e::Situational, "Claim MSP Pass-Through Amount"),
                    b::Element(e::Situational, "Claim PPS Capital Amount"),
                    b::Element(e::Situational, "PPS-Capital FSP DRG Amount"),
                    b::Element(e::Situational, "PPS-Capital HSP DRG Amount"),
                    b::Element(e::Situational, "PPS-Capital DSH DRG Amount"),
                    b::Element(e::Situational, "Old Capital Amount"),
                    b::Element(e::Situational, "PPS-Capital IME Amount"),
                    b::Element(e::Situational, "PPS-Operating Hospital Specific DRG Amount"),
                    b::Element(e::Situational, "Cost Report Day Count"),
                    b::Element(e::Situational, "PPS-Operating Federal Specific DRG Amount"),
                    b::Element(e::Situational, "Claim PPS Capital Outlier Amount"),
                    b::Element(e::Situational, "Claim Indirect Teaching Amount"),
                    b::Element(e::Situational, "Nonpayable Professional Component Amount"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "PPS-Capital Exception Amount")),
                  b::Segment( 350, s::MOA, "Outpatient Adjudication Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Situational, "Reimbursement Rate"),
                    b::Element(e::Situational, "Claim HCPCS Payable Amount"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Remark Code"),
                    b::Element(e::Situational, "Claim ESRD Payment Amount"),
                    b::Element(e::Situational, "Nonpayable Professional Component Amount")),
                  b::Segment( 400, s::REF, "Other Claim Related Identification", r::Situational, d::RepeatCount.bounded(5),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("1L", "1W", "9A", "9C", "A6", "BB", "CE", "EA", "F8", "G1", "G3", "IG", "SY")),
                    b::Element(e::Required,    "Other Claim Related Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment( 400, s::REF, "Rendering Provider Identification", r::Situational, d::RepeatCount.bounded(10),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("1A", "1B", "1C", "1D", "1G", "1H", "D3", "G2")),
                    b::Element(e::Required,    "Rendering Provider Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment( 500, s::DTM, "Claim Date", r::Situational, d::RepeatCount.bounded(4),
                    b::Element(e::Required,    "Date/Time Qualifier", b::Values("036", "050", "232", "233")),
                    b::Element(e::Required,    "Claim Date"),
                    b::Element(e::NotUsed,     "Time"),
                    b::Element(e::NotUsed,     "Time Code"),
                    b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                    b::Element(e::NotUsed,     "Date Time Period")),
                  b::Segment( 600, s::PER, "Claim Contact Information", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Contact Function Code", b::Values("CX")),
                    b::Element(e::Situational, "Claim Contact Name"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "FX", "TE")),
                    b::Element(e::Situational, "Claim Contact Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                    b::Element(e::Situational, "Claim Contact Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EX")),
                    b::Element(e::Situational, "Claim Contact Communication Number Extension"),
                    b::Element(e::NotUsed,     "Contact Inquiry Reference")),
                  b::Segment( 620, s::AMT, "Claim Supplemental Information", r::Situational, d::RepeatCount.bounded(13),
                    b::Element(e::Required,    "Amount Qualifier Code", b::Values("AU", "D8", "DY", "F5", "I", "NL", "T", "T2", "ZK", "ZL", "ZM", "ZN", "ZO", "ZZ")),
                    b::Element(e::Required,    "Claim Supplemental Information Amount"),
                    b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                  b::Segment( 640, s::QTY, "Claim Supplemental Information Quantity", r::Situational, d::RepeatCount.bounded(14),
                    b::Element(e::Required,    "Quantity Qualifier", b::Values("CA", "CD", "LA", "LE", "NA", "NE", "NR", "OU", "PS", "VS", "ZK", "ZL", "ZM", "ZN", "ZO")),
                    b::Element(e::Required,    "Claim Supplemental Information Quantity"),
                    b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE"),
                    b::Element(e::NotUsed,     "Free-Form Information")),

                  d::LoopDef.build("2110 SERVICE PAYMENT INFORMATION", d::RepeatCount.bounded(999),
                    b::Segment( 700, s::SVC, "Service Payment Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                        b::Element(e::Required,    "Product or Service ID Qualifier", b::Values("AD", "ER", "HC", "ID", "IV", "N1", "N2", "N3", "N4", "ND", "NU", "RB", "ZZ")),
                        b::Element(e::Required,    "Procedure Code"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Code Description")),
                      b::Element(e::Required,    "Line Item Charge Amount"),
                      b::Element(e::Required,    "Line Item Provider Payment Amount"),
                      b::Element(e::Situational, "National Uniform Billing Committee Revenue Code"),
                      b::Element(e::Situational, "Units of Service Paid Count"),
                      b::Element(e::Situational, "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                        b::Element(e::Required,    "Product or Service ID Qualifier", b::Values("AD", "ER", "HC", "ID", "IV", "N1", "N2", "N3", "N4", "ND", "NU", "RB", "ZZ")),
                        b::Element(e::Required,    "Procedure Code"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Code Description")),
                      b::Element(e::Situational, "Original Units of Service Count")),
                    b::Segment( 800, s::DTM, "Service Date", r::Situational, d::RepeatCount.bounded(2),
                      b::Element(e::Required,    "Date/Time Qualifier", b::Values("150", "151", "472")),
                      b::Element(e::Required,    "Service Date"),
                      b::Element(e::NotUsed,     "Time"),
                      b::Element(e::NotUsed,     "Time Code"),
                      b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                      b::Element(e::NotUsed,     "Date Time Period")),
                    b::Segment( 900, s::CAS, "Service Adjustment", r::Situational, d::RepeatCount.bounded(99),
                      b::Element(e::Required,    "Claim Adjustment Group Code", b::Values("CO", "CR", "OA", "PI", "PR")),
                      b::Element(e::Required,    "Adjustment Reason Code"),
                      b::Element(e::Required,    "Adjustment Amount", b::MaxLength(10)),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount", b::MaxLength(10)),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount", b::MaxLength(10)),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount", b::MaxLength(10)),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount", b::MaxLength(10)),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount", b::MaxLength(10)),
                      b::Element(e::Situational, "Adjustment Quantity")),
                    b::Segment(1000, s::REF, "Service Identification", r::Situational, d::RepeatCount.bounded(8),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("1S", "6R", "BB", "E9", "G1", "G3", "LU", "RB")),
                      b::Element(e::Required,    "Provider Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(1000, s::REF, "Rendering Provider Information", r::Situational, d::RepeatCount.bounded(10),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("1A", "1B", "1C", "1D", "1G", "1H", "1J", "HPI", "SY", "TJ")),
                      b::Element(e::Required,    "Rendering Provider Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(1100, s::AMT, "Service Supplemental Amount", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Amount Qualifier Code", b::Values("B6", "DY", "KH", "NE", "T", "T2", "ZK", "ZL", "ZM", "ZN", "ZO")),
                      b::Element(e::Required,    "Service Supplemental Amount", b::MaxLength(10)),
                      b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                    b::Segment(1200, s::QTY, "Service Supplemental Quantity", r::Situational, d::RepeatCount.bounded(6),
                      b::Element(e::Required,    "Quantity Qualifier", b::Values("NE", "ZK", "ZL", "ZM", "ZN", "ZO")),
                      b::Element(e::Required,    "Service Supplemental Quantity Count"),
                      b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE"),
                      b::Element(e::NotUsed,     "Free-Form Information")),
                    b::Segment(1300, s::LQ, "Health Care Remark Codes", r::Situational, d::RepeatCount.bounded(99),
                      b::Element(e::Required,    "Code List Qualifier Code", b::Values("HE", "RX")),
                      b::Element(e::Required,    "Remark Code")))))),

            d::TableDef.summary("3 - Summary",
              b::Segment(100, s::PLB, "Provider Adjustment", r::Situational, d::RepeatCount.unbounded,
                b::Element(e::Required,    "Provider Identifier"),
                b::Element(e::Required,    "Fiscal Period Date"),
                b::Element(e::Required,    "ADJUSTMENT IDENTIFIER",
                  b::Element(e::Required,    "Adjustment Reason Code", b::Values("50", "51", "72", "90", "AM", "AP", "B2", "B3", "BD", "BN", "C5", "CR", "CS", "CT", "CV", "CW", "DM", "E3", "FB", "FC", "GO", "IP", "IR", "IS", "J1", "L3", "L6", "LE", "LS", "OA", "OB", "PI", "PL", "RA", "RE", "SL", "TL", "WO", "WU", "ZZ")),
                  b::Element(e::Situational, "Provider Adjustment Identifier")),
                b::Element(e::Required,    "Provider Adjustment Amount", b::MaxLength(10)),
                b::Element(e::Situational, "ADJUSTMENT IDENTIFIER",
                  b::Element(e::Required,    "Adjustment Reason Code", b::Values("50", "51", "72", "90", "AM", "AP", "B2", "B3", "BD", "BN", "C5", "CR", "CS", "CT", "CV", "CW", "DM", "E3", "FB", "FC", "GO", "IP", "IR", "IS", "J1", "L3", "L6", "LE", "LS", "OA", "OB", "PI", "PL", "RA", "RE", "SL", "TL", "WO", "WU", "ZZ")),
                  b::Element(e::Situational, "Provider Adjustment Identifier")),
                b::Element(e::Situational, "Provider Adjustment Amount", b::MaxLength(10)),
                b::Element(e::Situational, "ADJUSTMENT IDENTIFIER",
                  b::Element(e::Required,    "Adjustment Reason Code", b::Values("50", "51", "72", "90", "AM", "AP", "B2", "B3", "BD", "BN", "C5", "CR", "CS", "CT", "CV", "CW", "DM", "E3", "FB", "FC", "GO", "IP", "IR", "IS", "J1", "L3", "L6", "LE", "LS", "OA", "OB", "PI", "PL", "RA", "RE", "SL", "TL", "WO", "WU", "ZZ")),
                  b::Element(e::Situational, "Provider Adjustment Identifier")),
                b::Element(e::Situational, "Provider Adjustment Amount", b::MaxLength(10)),
                b::Element(e::Situational, "ADJUSTMENT IDENTIFIER",
                  b::Element(e::Required,    "Adjustment Reason Code", b::Values("50", "51", "72", "90", "AM", "AP", "B2", "B3", "BD", "BN", "C5", "CR", "CS", "CT", "CV", "CW", "DM", "E3", "FB", "FC", "GO", "IP", "IR", "IS", "J1", "L3", "L6", "LE", "LS", "OA", "OB", "PI", "PL", "RA", "RE", "SL", "TL", "WO", "WU", "ZZ")),
                  b::Element(e::Situational, "Provider Adjustment Identifier")),
                b::Element(e::Situational, "Provider Adjustment Amount", b::MaxLength(10)),
                b::Element(e::Situational, "ADJUSTMENT IDENTIFIER",
                  b::Element(e::Required,    "Adjustment Reason Code", b::Values("50", "51", "72", "90", "AM", "AP", "B2", "B3", "BD", "BN", "C5", "CR", "CS", "CT", "CV", "CW", "DM", "E3", "FB", "FC", "GO", "IP", "IR", "IS", "J1", "L3", "L6", "LE", "LS", "OA", "OB", "PI", "PL", "RA", "RE", "SL", "TL", "WO", "WU", "ZZ")),
                  b::Element(e::Situational, "Provider Adjustment Identifier")),
                b::Element(e::Situational, "Provider Adjustment Amount", b::MaxLength(10)),
                b::Element(e::Situational, "ADJUSTMENT IDENTIFIER",
                  b::Element(e::Required,    "Adjustment Reason Code", b::Values("50", "51", "72", "90", "AM", "AP", "B2", "B3", "BD", "BN", "C5", "CR", "CS", "CT", "CV", "CW", "DM", "E3", "FB", "FC", "GO", "IP", "IR", "IS", "J1", "L3", "L6", "LE", "LS", "OA", "OB", "PI", "PL", "RA", "RE", "SL", "TL", "WO", "WU", "ZZ")),
                  b::Element(e::Situational, "Provider Adjustment Identifier")),
                b::Element(e::Situational, "Provider Adjustment Amount", b::MaxLength(10))),
              b::Segment(200, s::SE, "Transaction Set Trailer", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Transaction Segment Count"),
                b::Element(e::Required,    "Transaction Set Control Number"))))

        end
      end
    end
  end
end
