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

          HS270 = b.build("HS", "270", "",
            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("270")),
                b::Element(e::Required,    "Transaction Set Control Number"),
                b::Element(e::Required,    "Implementation Convention Reference", b::Values("005010X279"))),
              b::Segment(200, s::BHT, "Beginning of Hierarchical Transaction", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Hierarchical Structure Code", b::Values("0022")),
                b::Element(e::Required,    "Transaction Set Purpose Code", b::Values("01", "13")),
                b::Element(e::Situational, "Submitter Transaction Identifier"),
                b::Element(e::Required,    "Transaction Set Creation Date"),
                b::Element(e::Required,    "Transaction Set Creation Time"),
                b::Element(e::Situational, "Transaction Type Code", b::Values("RT")))),

            d::TableDef.detail("2 - Information Source Detail",
              d::LoopDef.build("2000A INFORMATION SOURCE LEVEL", d::RepeatCount.unbounded,
                b::Segment(100, s::HL, "Information Source Level", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,  "Hierarchical ID Number"),
                  b::Element(e::NotUsed,   "Hierarchical Parent ID Number"),
                  b::Element(e::Required,  "Hierarchical Level Code", b::Values("20")),
                  b::Element(e::Required,  "Hierarchical Child Code", b::Values("1"))),

                  d::LoopDef.build("2100A INFORMATION SOURCE NAME", d::RepeatCount.bounded(1),
                    b::Segment(300, s::NM1, "Information Source Name", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("2B", "36", "GP", "P5", "PR")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                      b::Element(e::Required,    "Information Source Last or Organization Name"),
                      b::Element(e::Situational, "Information Source First Name"),
                      b::Element(e::Situational, "Information Source Middle Name"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Information Source Name Suffix"),
                      b::Element(e::Required,    "Identification Code Qualifier", b::Values("24", "46", "FI", "NI", "PI", "XV", "XX")),
                      b::Element(e::Required,    "Information Source Primary Identifier"),
                      b::Element(e::NotUsed,     "Entity Relationship Code"),
                      b::Element(e::NotUsed,     "Entity Identifier Code"),
                      b::Element(e::NotUsed,     "Name Last or Organization Name"))))),

            d::TableDef.detail("2 - Information Receiver Detail",
              d::LoopDef.build("2000B INFORMATION RECEIVER LEVEL", d::RepeatCount.unbounded,
                b::Segment(100, s::HL, "Information Receiver Level", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Hierarchical ID Number"),
                  b::Element(e::Required,    "Hierarchical Parent ID Number"),
                  b::Element(e::Required,    "Hierarchical Level Code", b::Values("21")),
                  b::Element(e::Required,    "Hierarchical Child Code", b::Values("1"))),

                d::LoopDef.build("2100B INFORMATION RECEIVER NAME", d::RepeatCount.bounded(1),
                  b::Segment(300, s::NM1, "Information Receiver Name", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("1P", "2B", "36", "80", "FA", "GP", "P5", "PR")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::Required,    "Information Receiver Last or Organization Name"),
                    b::Element(e::Situational, "Information Receiver First Name"),
                    b::Element(e::Situational, "Information Receiver Middle Name"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Information Receiver Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("24", "34", "FI", "PI", "PP", "SV", "XV", "XX")),
                    b::Element(e::Required,    "Information Receiver Primary Identifier"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identifier Code"),
                    b::Element(e::NotUsed,     "Name Last or Organization Name")),
                  b::Segment(400, s::REF, "Information Receiver Additional Identification", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Reference Identification Qualfier", b::Values("0B", "1C", "1D", "1J", "4A", "CT", "EL", "EO", "HPI", "JD", "N5", "N7", "Q4", "SY", "TJ")),
                    b::Element(e::Required,    "Information Receiver Additional Identifier"),
                    b::Element(e::Situational, "Information Receiver Additional Identifier State"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(600, s::N3, "Information Receiver Address", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Information Receiver Address Line"),
                    b::Element(e::Situational, "Information Receiver Additional Address Line")),
                  b::Segment(700, s::N4, "Information Receiver City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Information Receiver City Name"),
                    b::Element(e::Situational, "Information Receiver State Code"),
                    b::Element(e::Situational, "Information Receiver Postal Zode or ZIP Code"),
                    b::Element(e::Situational, "Country Code"),
                    b::Element(e::NotUsed,     "Location Qualifier"),
                    b::Element(e::NotUsed,     "Location Identifier"),
                    b::Element(e::Situational, "Country Subdivision Code")),
                  b::Segment(900, s::PRV, "Information Receiver Provider Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Provider Code", b::Values("AD", "AT", "BI", "CO", "CV", "H", "HH", "LA", "OT", "P1", "P2", "PC", "PE", "R", "RF", "SB", "SK", "SU")),
                    b::Element(e::Situational, "Reference Identification Qualifier", b::Values("PXC")),
                    b::Element(e::Situational, "Receiver Provider Taxonomy Code"),
                    b::Element(e::NotUsed,     "State or Province Code"),
                    b::Element(e::NotUsed,     "PROVIDER SPECIALTY INFORMATION"),
                    b::Element(e::NotUsed,     "Provider Organization Code"))))),

              d::TableDef.detail("2 - Subscriber Detail",
                d::LoopDef.build("2000C SUBSCRIBER LEVEL", d::RepeatCount.unbounded,
                  b::Segment(100, s::HL, "Subscriber Level", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Hierarchical ID Number"),
                    b::Element(e::Required,    "Hierarchical Parent ID Number"),
                    b::Element(e::Required,    "Hierarchical Level Code", b::Values("22")),
                    b::Element(e::Required,    "Hierarchical Child Code", b::Values("0", "1"))),
                  b::Segment(200, s::TRN, "Subscriber Trace Number", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Trace Type Code", b::Values("1")),
                    b::Element(e::Required,    "Trace Number"),
                    b::Element(e::Required,    "Trace Assigning Entity Identifier"),
                    b::Element(e::Situational, "Trace Assigning Entity Additional Identifier")),

                  d::LoopDef.build("2100C SUBSCRIBER NAME", d::RepeatCount.bounded(1),
                    b::Segment(300, s::NM1, "Subscriber Name", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("IL")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                      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::Situational, "Identification Code Qualifier", b::Values("II", "MI")),
                      b::Element(e::Situational, "Subscriber Primary Identifier"),
                      b::Element(e::NotUsed,     "Entity Relationship Code"),
                      b::Element(e::NotUsed,     "Entity Identifier Code"),
                      b::Element(e::NotUsed,     "Name Last or Organization Name")),
                    b::Segment(400, s::REF, "Subscriber Additional Identification", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("18", "1L", "1W", "3H", "6P", "CT", "EA", "EJ", "F6", "GH", "HJ", "IG", "N6", "NQ", "SY", "Y4")),
                      b::Element(e::Required,    "Subscriber Supplemental Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(600, s::N3, "Subscriber Address", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Subscriber Address Line"),
                      b::Element(e::Situational, "Subscriber Address Line")),
                    b::Segment(700, s::N4, "Subscriber City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Subscriber City Name"),
                      b::Element(e::Situational, "Subscriber State Code"),
                      b::Element(e::Situational, "Subscriber Postal Zone or ZIP Code"),
                      b::Element(e::Situational, "Country Code"),
                      b::Element(e::NotUsed,     "Location Qualifier"),
                      b::Element(e::NotUsed,     "Location Identifier"),
                      b::Element(e::Situational, "Country Subdivision Code")),
                    b::Segment(900, s::PRV, "Provider Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Provider Code", b::Values("AD", "AT", "BI", "CO", "CV", "H", "HH", "LA", "OT", "P1", "P2", "PC", "PE", "R", "RF", "SK", "SU")),
                      b::Element(e::Situational, "Reference Identification Qualifier", b::Values("9K", "D3", "EI", "HPI", "PXC", "SY", "TJ")),
                      b::Element(e::Situational, "Provider Identifier"),
                      b::Element(e::NotUsed,     "State or Province Code"),
                      b::Element(e::NotUsed,     "PROVIDER SPECIALTY INFORMATION"),
                      b::Element(e::NotUsed,     "Provider Organization Code")),
                    b::Segment(1000, s::DMG, "Subscriber Demographic Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Situational, "Date Time Period Format Qualifier"),
                      b::Element(e::Situational, "Subscriber Birth Date"),
                      b::Element(e::Situational, "Subscriber Gender Code", b::Values("F", "M")),
                      b::Element(e::NotUsed,     "Marital Status Code"),
                      b::Element(e::NotUsed,     "COMPOSITE RACE OR ETHNICITY INFORMATION"),
                      b::Element(e::NotUsed,     "Citizenship Status Code"),
                      b::Element(e::NotUsed,     "Country Code"),
                      b::Element(e::NotUsed,     "Basis of Verification Code"),
                      b::Element(e::NotUsed,     "Quantity"),
                      b::Element(e::NotUsed,     "Code List Qualifier Code"),
                      b::Element(e::NotUsed,     "Industry Code")),
                    b::Segment(1100, s::INS, "Multiple Birth Sequence Number", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Insured Indicator", b::Values("Y")),
                      b::Element(e::Required,    "Individual Relationship Code", b::Values("18")),
                      b::Element(e::NotUsed,     "Maintenance Type Code"),
                      b::Element(e::NotUsed,     "Maintenance Reason Code"),
                      b::Element(e::NotUsed,     "Benefit Status Code"),
                      b::Element(e::NotUsed,     "MEDICARE STATUS CODE"),
                      b::Element(e::NotUsed,     "Consolidated Omnibus Budget Reconciliation Act (CORBA) Qualifying"),
                      b::Element(e::NotUsed,     "Employement Status Code"),
                      b::Element(e::NotUsed,     "Student Status Code"),
                      b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                      b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                      b::Element(e::NotUsed,     "Date Time Period"),
                      b::Element(e::NotUsed,     "Confidentiality Code"),
                      b::Element(e::NotUsed,     "City Name"),
                      b::Element(e::NotUsed,     "State or Province Code"),
                      b::Element(e::NotUsed,     "Country Code"),
                      b::Element(e::Required,    "Birth Sequence Number")),
                    b::Segment(1150, s::HI, "Subscriber Health Care Diagnosis Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABK", "BK")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Code Type", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Diagnosis Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION")),
                    b::Segment(1200, s::DTP, "Subscriber Date", r::Situational, d::RepeatCount.bounded(2),
                      b::Element(e::Required,    "Date Time Qualifier", b::Values("102", "291")),
                      b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                      b::Element(e::Required,    "Date Time Period")),

                    d::LoopDef.build("2110C SUBSCRIBER ELIGIBILITY OR BENEFIT INQUIRY", d::RepeatCount.bounded(99),
                      b::Segment(1300, s::EQ, "Subscriber Eligibility or Benefit Inquiry", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Situational, "Service Type Code", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "30", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AQ", "AR", "B1", "B2", "B3", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ", "C1", "CA", "CB", "CD", "CE", "CF", "CG", "CH", "CI", "CJ", "CK", "CL", "CM", "CN", "CO", "CP", "CQ", "DG", "DM", "DS", "GF", "GN", "GY", "IC", "MH", "NI", "ON", "PT", "PU", "RN", "RT", "TC", "TN", "UC")),
                        b::Element(e::Situational, "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                          b::Element(e::Required,    "Product/Service ID Qualifier", b::Values("AD", "CJ", "HC", "ID", "IV", "N4", "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::NotUsed,     "Description"),
                          b::Element(e::NotUsed,     "Product/Service ID")),
                        b::Element(e::Situational, "Coverage Level Code", b::Values("FAM")),
                        b::Element(e::NotUsed,     "Insurance Type Code"),
                        b::Element(e::Situational, "COMPOSITE DIAGNOSIS CODE POINTER",
                          b::Element(e::Required,    "Diagnosis Code Pointer"),
                          b::Element(e::Situational, "Diagnosis Code Pointer"),
                          b::Element(e::Situational, "Diagnosis Code Pointer"),
                          b::Element(e::Situational, "Diagnosis Code Pointer"))),
                      b::Segment(1350, s::AMT, "Subscriber Spend Down Amount", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Amount Qualifier Code", b::Values("R")),
                        b::Element(e::Required,    "Spend Down Amount"),
                        b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                      b::Segment(1350, s::AMT, "Subscriber Spend Down Total Billed Amount", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Amount Qualifier Code", b::Values("PB")),
                        b::Element(e::Required,    "Spend Down Total Billed Amount"),
                        b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                      b::Segment(1700, s::III, "Subscriber Eligibility or Benefit Additional Inquiry Information", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Code List Qualifier Code", b::Values("ZZ")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Code Category"),
                        b::Element(e::NotUsed,     "Free-form Message Text"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE"),
                        b::Element(e::NotUsed,     "Surface/Layer/Position Code"),
                        b::Element(e::NotUsed,     "Surface/Layer/Position Code"),
                        b::Element(e::NotUsed,     "Surface/Layer/Position Code")),
                      b::Segment(1900, s::REF, "Subscriber Additional Information", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9F", "G1")),
                        b::Element(e::Required,    "Prior Authorization or Referral Number"),
                        b::Element(e::NotUsed,     "Description"),
                        b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                      b::Segment(2000, s::DTP, "Subscriber Eligibility/Benefit Date", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Date/Time Qualifier", b::Values("291")),
                        b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                        b::Element(e::Required,    "Date Time Period")))))),

              d::TableDef.detail("Dependent Detail",
                d::LoopDef.build("2000D DEPENDENT LEVEL", d::RepeatCount.unbounded,
                  b::Segment(100, s::HL, "Dependent Level", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Hierarchical ID Number"),
                    b::Element(e::Required,    "Hierarchical Parent ID Number"),
                    b::Element(e::Required,    "Hierarchical Level Code", b::Values("23")),
                    b::Element(e::Required,    "Hierarchical Child Code", b::Values("0"))),
                  b::Segment(200, s::TRN, "Dependent Trace Number", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Trace Type Code", b::Values("1")),
                    b::Element(e::Required,    "Trace Number"),
                    b::Element(e::Required,    "Trace Assigning Entity Identiier"),
                    b::Element(e::Situational, "Trace Assigning Entity Additional Identifier")),

                  d::LoopDef.build("2100D DEPENDENT NAME", d::RepeatCount.bounded(1),
                    b::Segment(300, s::NM1, "Dependent Name", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("03")),
                      b::Element(e::Required,    "Entity Typ Qualifier", b::Values("1")),
                      b::Element(e::Situational, "Dependent Last Name"),
                      b::Element(e::Situational, "Dependent First Name"),
                      b::Element(e::Situational, "Dependent Middle Name"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Dependent Name Suffix"),
                      b::Element(e::NotUsed,     "Identification Code Qualifier"),
                      b::Element(e::NotUsed,     "Identification Code"),
                      b::Element(e::NotUsed,     "Entity Relationship Code"),
                      b::Element(e::NotUsed,     "Entity Identifier Code"),
                      b::Element(e::NotUsed,     "Name Last or Organization Name")),
                    b::Segment(400, s::REF, "Dependent Additional Identification", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("18", "1L", "6P", "CT", "EA", "EJ", "F6", "GH", "HJ", "IF", "IG", "MRC", "N6", "SY", "Y4")),
                      b::Element(e::Required,    "Dependent Supplemental Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(600, s::N3, "Dependent Address", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Dependent Address Line"),
                      b::Element(e::Situational, "Dependent Address Line")),
                    b::Segment(700, s::N4, "Dependent City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Dependent City Name"),
                      b::Element(e::Situational, "Dependent State Code"),
                      b::Element(e::Situational, "Dependent Postal Zone or ZIP Code"),
                      b::Element(e::Situational, "Country Code"),
                      b::Element(e::NotUsed,     "Location Qualifier"),
                      b::Element(e::NotUsed,     "Location Identifier"),
                      b::Element(e::Situational, "Country Subdivision Code")),
                    b::Segment(900, s::PRV, "Provider Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Provider Code", b::Values("AD", "AT", "BI", "CO", "CV", "H", "HH", "LA", "OT", "P1", "P2", "PC", "PE", "R", "RF", "SK", "SU")),
                      b::Element(e::Situational, "Reference Identification Qualifier", b::Values("9K", "D3", "EI", "HPI", "PXC", "SY", "TJ")),
                      b::Element(e::Situational, "Provider Identifier"),
                      b::Element(e::NotUsed,     "State or Province Code"),
                      b::Element(e::NotUsed,     "PROVIDER SPECIALTY INFORMATION"),
                      b::Element(e::NotUsed,     "Provider Organization Code")),
                    b::Segment(1000, s::DMG, "Dependent Demographic Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Situational, "Date Time Period Format Qualifier", b::Values("D8")),
                      b::Element(e::Situational, "Dependent Birth Date"),
                      b::Element(e::Situational, "Dependent Gender Code"),
                      b::Element(e::NotUsed,     "Marital Status Code"),
                      b::Element(e::NotUsed,     "COMPOSITE RACE OR ETHNICITY INFORMATION"),
                      b::Element(e::NotUsed,     "Citizenship Status Code"),
                      b::Element(e::NotUsed,     "Country Code"),
                      b::Element(e::NotUsed,     "Basis of Verification Code"),
                      b::Element(e::NotUsed,     "Quantity"),
                      b::Element(e::NotUsed,     "Code LIst Qualifier Code"),
                      b::Element(e::NotUsed,     "Industry Code")),
                    b::Segment(1100, s::INS, "Dependent Relationship", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Insured Indicator", b::Values("N")),
                      b::Element(e::Required,    "Individual Relationship Code", b::Values("01", "19", "34")),
                      b::Element(e::NotUsed,     "Maintenance Type Code"),
                      b::Element(e::NotUsed,     "Maintenance Reason Code"),
                      b::Element(e::NotUsed,     "Benefit Status Code"),
                      b::Element(e::NotUsed,     "MEDICARE STATUS CODE"),
                      b::Element(e::NotUsed,     "Consolidated Omnibus Budget Reconciliation Act (CORBA) Qualifying"),
                      b::Element(e::NotUsed,     "Employment Status Code"),
                      b::Element(e::NotUsed,     "Student Status Code"),
                      b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                      b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                      b::Element(e::NotUsed,     "Date Time Period"),
                      b::Element(e::NotUsed,     "Confidentiality Code"),
                      b::Element(e::NotUsed,     "City Name"),
                      b::Element(e::NotUsed,     "State or Province Code"),
                      b::Element(e::NotUsed,     "Country Code"),
                      b::Element(e::Situational, "Birth Sequence Number")),
                    b::Segment(1150, s::HI, "Dependent Health Care Diagnosis Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABK", "BK")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Code List Quailfier Code", b::Values("ABF", "BF")),
                        b::Element(e::Required,    "Industry Code"),
                        b::Element(e::NotUsed,     "Date Time Period Format Qualifier"),
                        b::Element(e::NotUsed,     "Date Time Period"),
                        b::Element(e::NotUsed,     "Monetary Amount"),
                        b::Element(e::NotUsed,     "Quantity"),
                        b::Element(e::NotUsed,     "Version Identifier"),
                        b::Element(e::NotUsed,     "Industry Code"),
                        b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFORMATION")),
                    b::Segment(1200, s::DTP, "Dependent Date", r::Situational, d::RepeatCount.bounded(2),
                      b::Element(e::Required,    "Date/Time Qualifier", b::Values("102", "291")),
                      b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                      b::Element(e::Required,    "Date Time Period")),

                    d::LoopDef.build("2110D DEPENDENT ELIGIBILITY OR BENEFIT INQUIRY", d::RepeatCount.bounded(99),
                      b::Segment(1300, s::EQ, "Dependent Eligibility or Benefit Inquiry", r::Required, d::RepeatCount.bounded(1),
                        b::Element(e::Situational, "Service Type Code", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "30", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AQ", "AR", "B1", "B2", "B3", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ", "C1", "CA", "CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", "CJ", "CK", "CL", "CM", "CN", "CO", "CP", "CQ", "DG", "DM", "DS", "GF", "GN", "GY", "IC", "MH", "NI", "PT", "PU", "RN", "RT", "TN", "UC")),
                        b::Element(e::Situational, "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                          b::Element(e::Required,    "Product/Service ID Qualifier", b::Values("AD", "CJ", "HC", "ID", "IV", "N4", "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::NotUsed,     "Description"),
                          b::Element(e::NotUsed,     "Product/Service ID")),
                        b::Element(e::NotUsed,     "Coverage Level Code"),
                        b::Element(e::NotUsed,     "Insurance Type Code"),
                        b::Element(e::Situational, "COMPOSITE DIAGNOSIS CODE POINTER",
                          b::Element(e::Required,    "Diagnosis Code Pointer"),
                          b::Element(e::Situational, "Diagnosis Code Pointer"),
                          b::Element(e::Situational, "Diagnosis Code Pointer"),
                          b::Element(e::Situational, "Diagnosis Code Pointer"))),
                      b::Segment(1700, s::III, "Dependent Eligibility or Benefit Additional Inquiry Information", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,   "Code List Qualifier Code", b::Values("ZZ")),
                        b::Element(e::Required,   "Industry Code"),
                        b::Element(e::NotUsed,    "Code Category"),
                        b::Element(e::NotUsed,    "Free-form Message Text"),
                        b::Element(e::NotUsed,    "Quantity"),
                        b::Element(e::NotUsed,    "COMPOSITE UNIT OF MEASURE"),
                        b::Element(e::NotUsed,    "Surface/Layer/Position Code"),
                        b::Element(e::NotUsed,    "Surface/Layer/Position Code"),
                        b::Element(e::NotUsed,    "Surface/Layer/Position Code")),
                      b::Segment(1900, s::REF, "Dependent Additional Information", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9F", "G1")),
                        b::Element(e::Required,    "Prior Authorization or Referral Number"),
                        b::Element(e::NotUsed,     "Description"),
                        b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                      b::Segment(2000, s::DTP, "Dependent Eligibility/Benefit Date", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Date Time Qualifier", b::Values("291")),
                        b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                        b::Element(e::Required,    "Date Time Period")))))),

            # This structure doesn't match the specification, but it does ensure
            # that the first occurrence of SE terminates the transaction set.
            d::TableDef.summary("3 - Summary",
              b::Segment(5550, s::SE, "Transaction Set Trailer", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Number of Included Segments"),
                b::Element(e::Required,    "Transaction Set Control Number"))))

        end
      end
    end
  end
end
