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

          HB271 = b.build("HB", "271", "",
            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("271")),
                b::Element(e::Required,    "Transaction Set Control Number"),
                b::Element(e::Required,    "Implementation Convention Reference", b::Values("005010X279A1"))),
              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("06", "11")),
                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::NotUsed,     "Transaction Type Code"))),

            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("0", "1"))),
                b::Segment(250, s::AAA, "Request Validation", r::Situational, d::RepeatCount.bounded(9),
                  b::Element(e::Required,    "Valid Request Indicator", b::Values("Y", "N")),
                  b::Element(e::NotUsed,     "Agency Qualifier Code"),
                  b::Element(e::Required,    "Reject Reason Code", b::Values("04", "41", "42", "79")),
                  b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "P", "R", "S", "Y"))),

                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,    "Name Last or Organization Name"),
                    b::Element(e::Situational, "Name First"),
                    b::Element(e::Situational, "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("24", "46", "FI", "NI", "PI", "XV", "XX")),
                    b::Element(e::Required,    "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(800, s::PER, "Information Source Contact Information", r::Situational, d::RepeatCount.bounded(3),
                    b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                    b::Element(e::Situational, "Information Source Contact Name"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "FX", "TE", "UR")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "EX", "FX", "TE", "UR")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "EX", "FX", "TE", "UR")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::NotUsed,     "Contact Inquiry Reference")),
                  b::Segment(850, s::AAA, "Request Validation", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Valid Request Indicator", b::Values("N", "Y")),
                    b::Element(e::NotUsed,     "Agency Qualifier Code"),
                    b::Element(e::Required,    "Reject Reason Code", b::Values("04", "41", "42", "79", "80", "T4")),
                    b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "P", "R", "S", "W", "X", "Y")))))),

            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::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("21")),
                  b::Element(e::Required,    "Hierarchical Child Code", b::Values("0", "1"))),

                d::LoopDef.build("2100B INFORMATION RECEIVER NAME", d::RepeatCount.unbounded,
                  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::Situational, "Information Receiver Last or Organization Name"),
                    b::Element(e::Situational, "Information Receiver First Name"),
                    b::Element(e::Situational, "Information Receiver Name Middle"),
                    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,    "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, "Information Receiver Additional Identification", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1C", "1D", "1J", "4A", "CT", "EL", "EO", "HPI", "JD", "N5", "N7", "Q4", "SY", "TJ")),
                    b::Element(e::Required,    "Reference Identification"),
                    b::Element(e::Situational, "Information Receiver Addtional 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 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(850, s::AAA, "Information Receiver Request Validation", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Valid Request Indicator", b::Values("N", "Y")),
                    b::Element(e::NotUsed,     "Agency Qualifier Code"),
                    b::Element(e::Required,    "Reject Reason Code", b::Values("15", "41", "43", "44", "45", "46", "47", "48", "50", "51", "79", "97", "T4")),
                    b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "R", "S", "W", "X", "Y"))),
                  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, "Information 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::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("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(3),
                  b::Element(e::Required,    "Trace Type Code", b::Values("1", "2")),
                  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", "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::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 Information", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("18", "1L", "1W", "3H", "49", "6P", "CE", "CT", "EA", "EJ", "F6", "GH", "HJ", "IF", "IG", "N6", "NQ", "Q4", "SY", "Y4")),
                    b::Element(e::Required,    "Subscriber Supplemental Identifier"),
                    b::Element(e::Situational, "Plan, Group or Plan Network Name"),
                    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, "Subscriber Country Code"),
                    b::Element(e::NotUsed,     "Location Qualifier"),
                    b::Element(e::NotUsed,     "Location Identifier"),
                    b::Element(e::Situational, "Subscriber Country Subdivision Code")),
                  b::Segment(850, s::AAA, "Subscriber Request Validation", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Valid Request Indicator", b::Values("N", "Y")),
                    b::Element(e::NotUsed,     "Agency Qualifier Code"),
                    b::Element(e::Required,    "Reject Reason Code", b::Values("15", "35", "42", "43", "45", "47", "48", "49", "51", "52", "56", "57", "58", "60", "61", "62", "63", "71", "72", "73", "74", "75", "76", "78")),
                    b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "R", "S", "W", "X", "Y"))),
                  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 Identifier", b::Values("PXC")),
                    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", "U")),
                    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, "Subscriber Relationship", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Insured Indicator", b::Values("Y")),
                    b::Element(e::Required,    "Individual Relationsihp Code", b::Values("18")),
                    b::Element(e::Situational, "Maintenance Type Code", b::Values("001")),
                    b::Element(e::Situational, "Maintenance Reason Code", b::Values("25")),
                    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"),
                    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, "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(9),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("096", "102", "152", "291", "307", "318", "340", "341", "342", "343", "346", "347", "356", "357", "382", "435", "442", "458", "472", "539", "540", "636", "771")),
                    b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                    b::Element(e::Required,    "Date Time Period")),
                  b::Segment(1275, s::MPI, "Subscriber Military Personnel Information", r::Situational, d::RepeatCount.bounded(9),
                    b::Element(e::Required,    "Information Status Code", b::Values("A", "C", "L", "O", "P", "S", "T")),
                    b::Element(e::Required,    "Employment Status Code", b::Values("AE", "AO", "AS", "AT", "AU", "CC", "DD", "HD", "IR", "LX", "PE", "RE", "RM", "RR", "RU")),
                    b::Element(e::Required,    "Government Service Affiliation Code", b::Values("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "Q", "R", "S", "U", "W")),
                    b::Element(e::Situational, "Descrption"),
                    b::Element(e::Situational, "Military Service Rank", b::Values("A1", "A2", "A3", "B1", "B2", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "E1", "F1", "F2", "F3", "F4", "G1", "G4", "L1", "L2", "L3", "L4", "L5", "L6", "M1", "M2", "M3", "M4", "M5", "M6", "P1", "P2", "P3", "P4", "P5", "R1", "R2", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "SA", "SB", "SC", "T1", "V1", "W1")),
                    b::Element(e::Situational, "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                    b::Element(e::Situational, "Date Time Period")),

                  d::LoopDef.build("2110C SUBSCRIBER ELIGIBILITY OR BENEFIT INFORMATION", d::RepeatCount.unbounded,
                    b::Segment(1300, s::EB, "Subscriber Eligibility or Benefit Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Eligibility or Benefit Information", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "A", "B", "C", "CB", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "MC", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y")),
                      b::Element(e::Situational, "Benefit Coverage Level Code", b::Values("CHD", "DEP", "ECH", "EMP", "ESP", "FAM", "IND", "SPC", "SPO")),
                      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", "IC", "MH", "NI", "ON", "PT", "PU", "RN", "RT", "TC", "TN", "UC")),
                      b::Element(e::Situational, "Insurance Type Code", b::Values("12", "13", "14", "15", "16", "41", "42", "43", "47", "AP", "C1", "CO", "CP", "D", "DB", "EP", "FF", "GP", "HM", "HN", "HS", "IN", "IP", "LC", "LD", "LI", "LT", "MA", "MB", "MC", "MH", "MI", "MP", "OT", "PE", "PL", "PP", "PR", "PS", "QM", "RP", "SP", "TF", "WC", "WU")),
                      b::Element(e::Situational, "Plan Coverage Description"),
                      b::Element(e::Situational, "Time Period Qualifier", b::Values("6", "7", "13", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36")),
                      b::Element(e::Situational, "Monetary Amount"),
                      b::Element(e::Situational, "Benefit Percent"),
                      b::Element(e::Situational, "Quantity Qualifier", b::Values("8H", "99", "CA", "CE", "D3", "DB", "DY", "HS", "LA", "LE", "M2", "MN", "P6", "QA", "S7", "S8")),
                      b::Element(e::Situational, "Benefit Quantity"),
                      b::Element(e::Situational, "Authorization or Certification Indicator", b::Values("N", "U", "Y")),
                      b::Element(e::Situational, "In Plan Network Indicator", b::Values("N", "U", "W", "Y")),
                      b::Element(e::Situational, "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                        b::Element(e::Required,    "Product or 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::Situational, "Product or Service ID")),
                      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::HSD, "Health Care Services Delivery", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Situational, "Quantity Qualifier", b::Values("DY", "FL", "HS", "MN", "VS")),
                      b::Element(e::Situational, "Benefit Quantity"),
                      b::Element(e::Situational, "Unit or Basis for Measurement Code", b::Values("DA", "MO", "VS", "WK", "YR")),
                      b::Element(e::Situational, "Sample Selection Modulus"),
                      b::Element(e::Situational, "Time Period Qualifier", b::Values("6", "7", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35")),
                      b::Element(e::Situational, "Period Count"),
                      b::Element(e::Situational, "Delivery Frequency Code", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "SG", "SL", "SP", "SX", "SY", "SZ", "T", "U", "V", "W", "X", "Y")),
                      b::Element(e::Situational, "Delivery Pattern Time Code", b::Values("A", "B", "C", "D", "E", "F", "G", "Y"))),
                    b::Segment(1400, s::REF, "Subscriber Additional Identification", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Reference Identifier Qualifier", b::Values("18", "1L", "1W", "49", "6P", "9F", "ALS", "CLI", "F6", "FO", "G1", "IG", "M7", "N6", "NQ")),
                      b::Element(e::Required,    "Subscriber Eligibility or Benefit Identifier"),
                      b::Element(e::Situational, "Plan, Group or Plan Network Name"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(1500, s::DTP, "Subscriber Eligibility/Benefit Date", r::Situational, d::RepeatCount.bounded(20),
                      b::Element(e::Required,    "Date Time Qualifier", b::Values("096", "193", "194", "198", "290", "291", "292", "295", "304", "307", "318", "346", "348", "349", "356", "357", "435", "472", "636", "771")),
                      b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8", "RD8")),
                      b::Element(e::Required,    "Eligibility or Benefit Date Time Period")),
                    b::Segment(1600, s::AAA, "Subscriber Request Validation", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Valid Request Indicator", b::Values("N", "Y")),
                      b::Element(e::NotUsed,     "Agency Qualifier Code"),
                      b::Element(e::Required,    "Reject Reason Code", b::Values("15", "33", "52", "53", "54", "55", "56", "57", "60", "61", "62", "63", "69", "70", "98", "AA", "AE", "AF", "AG", "AO", "CI", "E8", "IA", "MA")),
                      b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "R", "W", "X", "Y"))),
                    b::Segment(2500, s::MSG, "Message Text", r::Situational, d::RepeatCount.bounded(10),
                      b::Element(e::Required,    "Free Form Message Text"),
                      b::Element(e::NotUsed,     "Printer Carriage Control Code"),
                      b::Element(e::NotUsed,     "Number")),

                    d::LoopDef.build("2115C SUBSCRIBER ELIGIBILITY OR BENEFIT ADDITIONAL INFORMATION", d::RepeatCount.bounded(10),
                      b::Segment(2600, s::III, "Subscriber Eligibility or Benefit Additional Information", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Situational, "Code List Qualifier Code", b::Values("GR", "NI", "ZZ")),
                        b::Element(e::Situational, "Industry Code"),
                        b::Element(e::Situational, "Code Category", b::Values("44")),
                        b::Element(e::Situational, "Injured Body Part Name"),
                        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"))),

                    # The X12 standard and X279 specification place the LS and LE segments
                    # at the same depth as 2115C and 2120C loops. This is not supported by
                    # Stupidedi -- loops must be contain zero or more header segments, followed
                    # by zero or more child loops, finally followed by zero or more trailer
                    # segments.
                    #
                    # To work around this issue, we've constructed the "2120C LOOP HEADER"
                    # merely to serve as a container for the LS and LE segments.
                    #
                    d::LoopDef.build("2120C LOOP HEADER", d::RepeatCount.bounded(1),
                      b::Segment(3300, s::LS, "Loop Header", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Loop Identifier Code", b::Values("2120"))),

                      d::LoopDef.build("2120C SUBSCRIBER BENEFIT RELATED ENTITY NAME", d::RepeatCount.bounded(23),
                        b::Segment(3400, s::NM1, "Subscriber Benefit Related Entity Name", r::Situational, d::RepeatCount.bounded(1),
                          b::Element(e::Required,    "Entity Code Identifier", b::Values("13", "1I", "1P", "2B", "36", "73", "FA", "GP", "GW", "I3", "IL", "LR", "OC", "P3", "P4", "P5", "PR", "PRP", "SEP", "TTP", "VER", "VN", "VY", "X3", "Y2")),
                          b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                          b::Element(e::Situational, "Benefit Related Entity Last or Organization Name"),
                          b::Element(e::Situational, "Benefit Related Entity First Name"),
                          b::Element(e::Situational, "Benefit Related Entity Middle Name"),
                          b::Element(e::NotUsed,     "Name Prefix"),
                          b::Element(e::Situational, "Benefit Related Entity Name Suffix"),
                          b::Element(e::Situational, "Identification Code Qualifier", b::Values("24", "34", "46", "FA", "FI", "II", "MI", "NI", "PI", "PP", "SV", "XV", "XX")),
                          b::Element(e::Situational, "Identification Code"),
                          b::Element(e::Situational, "Benefit Related Entity Relationsihp Code", b::Values("01", "02", "27", "41", "48", "65", "72")),
                          b::Element(e::NotUsed,     "Entity Identifier Code"),
                          b::Element(e::NotUsed,     "Name Last or Organization Name")),
                        b::Segment(3600, s::N3, "Subscriber Benefit Related Entity Address", r::Situational, d::RepeatCount.bounded(1),
                          b::Element(e::Required,    "Benefit Related Entity Address Line"),
                          b::Element(e::Situational, "Benefit Related Entity Address Line")),
                        b::Segment(3700, s::N4, "Subscriber Benefit Related Entity City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                          b::Element(e::Required,    "Benefit Related Entity City Name"),
                          b::Element(e::Situational, "Benefit Related Entity State Code"),
                          b::Element(e::Situational, "Benefit Related Entity Postal Zone or ZIP Code"),
                          b::Element(e::Situational, "Benefit Related Entity Country Code"),
                          b::Element(e::Situational, "Benefit Related Entity Location Qualifier", b::Values("RJ")),
                          b::Element(e::Situational, "Benefit Related Entity DOD Health Service Region"),
                          b::Element(e::Situational, "Benefit Related Entity Country Subdivision Code")),
                        b::Segment(3800, s::PER, "Subscriber Benefit Related Entity Contact Information", r::Situational, d::RepeatCount.bounded(3),
                          b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                          b::Element(e::Situational, "Benefit Related Entity Contact Name"),
                          b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "FX", "TE", "UR", "WP")),
                          b::Element(e::Situational, "Benefit Related Entity Communication Number"),
                          b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "EX", "FX", "TE", "UR", "WP")),
                          b::Element(e::Situational, "Communication Number"),
                          b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "EX", "FX", "TE", "UR", "WP")),
                          b::Element(e::Situational, "Communication Number"),
                          b::Element(e::NotUsed,     "Contact Inquiry Reference")),
                        b::Segment(3900, s::PRV, "Subscriber Benefit Related 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, "Benefit Related Entity 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"))),

                      b::Segment(4000, s::LE, "Loop Trailer", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Loop Identifier Code", b::Values("2120")))))))),

              d::TableDef.detail("2 - Dependent Detail",
                d::LoopDef.build("2000D DEPENDENT DETAIL", 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(3),
                    b::Element(e::Required,    "Trace Type Code", b::Values("1", "2")),
                    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("2100D DEPENDENT NAME", d::RepeatCount.unbounded,
                    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 Type 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", "1W", "49", "6P", "CE", "CT", "EA", "EJ", "F6", "GH", "HJ", "IF", "IG", "MRC", "N6", "NQ", "Q4", "SY", "Y4")),
                      b::Element(e::Required,    "Dependent Supplemental Identfier"),
                      b::Element(e::Situational, "Plan, Group or Plan Network Name"),
                      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, "Dependent Country Code"),
                      b::Element(e::NotUsed,     "Location Qualifier"),
                      b::Element(e::NotUsed,     "Location Identifier"),
                      b::Element(e::Situational, "Dependent Country Subdivision Code")),
                    b::Segment(850, s::AAA, "Dependent Request Validation", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Valid Request Indicator", b::Values("Y", "N")),
                      b::Element(e::NotUsed,     "Agency Qualifier Code"),
                      b::Element(e::Required,    "Reject Reason Code", b::Values("15", "35", "42", "43", "45", "47", "48", "49", "51", "52", "56", "57", "58", "60", "61", "62", "63", "64", "65", "66", "67", "68", "71", "77")),
                      b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "R", "S", "W", "X", "Y"))),
                    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("PXC")),
                      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::Values("F", "M", "U")),
                      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", "20", "21", "39", "40", "53", "G8")),
                      b::Element(e::Situational, "Maintenance Type Code", b::Values("001")),
                      b::Element(e::Situational, "Maintenance Reason Code", b::Values("25")),
                      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,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                        b::Element(e::Required,    "Diagnosis Type Code", 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")),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFROMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFROMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFROMATION"),
                      b::Element(e::NotUsed,     "HEALTH CARE CODE INFROMATION")),
                    b::Segment(1200, s::DTP, "Dependent Date", r::Situational, d::RepeatCount.bounded(9),
                      b::Element(e::Required,    "Date Time Qualifier", b::Values("096", "102", "152", "291", "307", "318", "340", "341", "342", "343", "346", "347", "356", "357", "382", "435", "442", "458", "472", "539", "540", "636", "771")),
                      b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                      b::Element(e::Required,    "Date Time Period")),
                    b::Segment(1275, s::MPI, "Dependent Military Personnel Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Information Status Code", b::Values("A", "C", "L", "O", "P", "S", "T")),
                      b::Element(e::Required,    "Employment Status Code", b::Values("AE", "AO", "AS", "AT", "AU", "CC", "DD", "HD", "IR", "LX", "PE", "RE", "RM", "RR", "RU")),
                      b::Element(e::Required,    "Government Service Affilition Code", b::Values("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "Q", "R", "S", "U", "W")),
                      b::Element(e::Situational, "Description"),
                      b::Element(e::Situational, "Military Service Rank", b::Values("A1", "A2", "A3", "B1", "B2", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "E1", "F1", "F2", "F3", "F4", "G1", "G4", "L1", "L2", "L3", "L4", "L5", "L6", "M1", "M2", "M3", "M4", "M5", "M6", "P1", "P2", "P3", "P4", "P5", "R1", "R2", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "SA", "SB", "SC", "T1", "V1", "W1")),
                      b::Element(e::Situational, "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                      b::Element(e::Situational, "Date Time Period")),

                    d::LoopDef.build("2110D DEPENDENT ELIGIBILITY OR BENEFIT INFORMATION", d::RepeatCount.unbounded,
                      b::Segment(1300, s::EB, "Dependent Eligibility or Benefit Information", r::Situational, d::RepeatCount.bounded(1),
                        b::Element(e::Required,    "Eligibility or Benefit Information", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "A", "B", "C", "CB", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "MC", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y")),
                        b::Element(e::Situational, "Benefit Coverage Level Code", b::Values("CHD", "DEP", "ECH", "ESP", "FAM", "IND", "SPC", "SPO")),
                        b::Element(e::Situational, "Service Type Code", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "3", "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", "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", "IC", "MH", "NI", "ON", "PT", "PU", "RN", "RT", "TN", "UC")),
                        b::Element(e::Situational, "Insurance Type Code", b::Values("12", "13", "14", "15", "16", "41", "42", "43", "47", "AP", "C1", "CO", "CP", "D", "DB", "EP", "FF", "GP", "HM", "HN", "HS", "IN", "IP", "LC", "LD", "LI", "LT", "MA", "MB", "MC", "MH", "MI", "MP", "OT", "PE", "PL", "PP", "PR", "PS", "QM", "RP", "SP", "TF", "WC", "WU")),
                        b::Element(e::Situational, "Plan Coverage Description"),
                        b::Element(e::Situational, "Time Period Qualifier", b::Values("6", "7", "13", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36")),
                        b::Element(e::Situational, "Benefit Amount"),
                        b::Element(e::Situational, "Benefit Percent"),
                        b::Element(e::Situational, "Quantity Qualifier", b::Values("8H", "99", "CA", "CE", "D3", "DB", "DY", "HS", "LA", "LE", "M2", "MN", "P6", "QA", "S7", "S8", "VS", "YY")),
                        b::Element(e::Situational, "Benefit Quantity"),
                        b::Element(e::Situational, "Authorization or Certification Indicator", b::Values("N", "U", "Y")),
                        b::Element(e::Situational, "In Plan Network Indicator", b::Values("N", "U", "W", "Y")),
                        b::Element(e::Situational, "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                          b::Element(e::Required,    "Produce or 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::Situational, "Product or Service ID")),
                        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::HSD, "Health Care Services Delivery", r::Situational, d::RepeatCount.bounded(9),
                        b::Element(e::Situational, "Quantity Qualifier", b::Values("DY", "FL", "HS", "MN", "VS")),
                        b::Element(e::Situational, "Benefit Quantity"),
                        b::Element(e::Situational, "Unit or Basis for Measurement Code", b::Values("DA", "MO", "VS", "WK", "YR")),
                        b::Element(e::Situational, "Sample Selection Modulus"),
                        b::Element(e::Situational, "Time Period Qualifier", b::Values("6", "7", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35")),
                        b::Element(e::Situational, "Period Count"),
                        b::Element(e::Situational, "Delivery Frequency Code", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "SG", "SL", "SP", "SX", "SY", "SZ", "T", "U", "V", "W", "X", "Y")),
                        b::Element(e::Situational, "Delivery Pattern Time Code", b::Values("A", "B", "C", "D", "E", "F", "G", "Y"))),
                      b::Segment(1400, s::REF, "Dependent Additional Identification", r::Situational, d::RepeatCount.bounded(9),
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("18", "1L", "1W", "49", "6P", "9F", "ALS", "CLI", "F6", "FO", "G1", "IG", "N6", "NQ")),
                        b::Element(e::Required,    "Dependent Eligibility or Benefit Identifier"),
                        b::Element(e::Situational, "Plan, Group or Plan Network Name"),
                        b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                      b::Segment(1500, s::DTP, "Dependent Eligibility/Benefit Date", r::Situational, d::RepeatCount.bounded(20),
                        b::Element(e::Required,    "Date Time Qualifier", b::Values("096", "193", "194", "198", "290", "291", "292", "295", "304", "307", "318", "346", "348", "349", "356", "357", "435", "472", "636", "771")),
                        b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                        b::Element(e::Required,    "Eligibility or Benefit Date Time Period")),
                      b::Segment(1600, s::AAA, "Dependent Request Validation", r::Situational, d::RepeatCount.bounded(9),
                        b::Element(e::Required,    "Valid Request Indicator", b::Values("N", "Y")),
                        b::Element(e::NotUsed,     "Agency Qualifier Code"),
                        b::Element(e::Required,    "Reject Reason Code", b::Values("15", "33", "52", "53", "54", "55", "56", "57", "60", "61", "62", "63", "69", "70", "98", "AA", "AE", "AF", "AG", "AO", "CI", "E8", "IA", "MA")),
                        b::Element(e::Required,    "Follow-up Action Code", b::Values("C", "N", "R", "W", "X", "Y"))),
                      b::Segment(2500, s::MSG, "Message Text", r::Situational, d::RepeatCount.bounded(10),
                        b::Element(e::Required,    "Free Form Message Text"),
                        b::Element(e::NotUsed,     "Printer Carriage Control Code"),
                        b::Element(e::NotUsed,     "Number")),

                      d::LoopDef.build("2115D DEPENDENT ELIGIBILITY OR BENEFIT ADDITIONAL INFORMATION", d::RepeatCount.unbounded,
                        b::Segment(2600, s::III, "Dependent Eligibility or Benefit Additional Information", r::Situational, d::RepeatCount.bounded(1),
                          b::Element(e::Situational,     "Code List Qualifier Code", b::Values("GR", "NI", "ZZ")),
                          b::Element(e::Situational,     "Industry Code"),
                          b::Element(e::Situational,     "Code Category", b::Values("44")),
                          b::Element(e::Situational,     "Injured Body Part Name"),
                          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"))),

                      # The X12 standard and X279 specification place the LS and LE segments
                      # at the same depth as 2115D and 2120D loops. This is not supported by
                      # stupidedi -- loops must be contain zero or more header segments, followed
                      # by zero or more child loops, finally followed by zero or more trailer
                      # segments.
                      #
                      # To work around this issue, we've constructed the "2120D LOOP HEADER"
                      # merely to serve as a container for the LS and LE segments.
                      #
                      d::LoopDef.build("2120D LOOP HEADER", d::RepeatCount.bounded(1),
                        b::Segment(3300, s::LS, "Loop Header", r::Situational, d::RepeatCount.bounded(1),
                          b::Element(e::Required,    "Loop Identifier Code", b::Values("2120"))),

                        d::LoopDef.build("2120D DEPENDENT BENEFIT RELATED ENTITY NAME", d::RepeatCount.unbounded,
                          b::Segment(3400, s::NM1, "Dependent Benefit Related Entity Name", r::Situational, d::RepeatCount.bounded(1),
                            b::Element(e::Required,    "Entity Identifier Code", b::Values("13", "1I", "1P", "2B", "36", "73", "FA", "GP", "GW", "I3", "IL", "LR", "OC", "P3", "P4", "P5", "PR", "PRP", "SEP", "TTP", "VER", "VN", "VY", "X3", "Y2")),
                            b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                            b::Element(e::Situational, "Benefit Related Entity Last or Organization Name"),
                            b::Element(e::Situational, "Benefit Related Entity First Name"),
                            b::Element(e::Situational, "Benefit Related Entity Middle Name"),
                            b::Element(e::Situational, "Benefit Related Entity Name Suffix"),
                            b::Element(e::NotUsed,     "Name Prefix"),
                            b::Element(e::Situational, "Identification Code Qualifier", b::Values("24", "34", "46", "FA", "FI", "II", "MI", "NI", "PI", "PP", "SV", "XV", "XX")),
                            b::Element(e::Situational, "Benefit Related Entity Identifier"),
                            b::Element(e::Situational, "Benefit Related Entity Relationship Code", b::Values("01", "02", "27", "41", "48", "65", "72")),
                            b::Element(e::NotUsed,     "Entity Identifier Code"),
                            b::Element(e::NotUsed,     "Name Last or Organization Name")),
                          b::Segment(3600, s::N3, "Dependent Benefit Related Entity Address", r::Situational, d::RepeatCount.bounded(1),
                            b::Element(e::Required,    "Benefit Related Entity Address Line"),
                            b::Element(e::Situational, "Benefit Related Entity Address Line")),
                          b::Segment(3700, s::N4, "Dependent Benefit Related Entity City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                            b::Element(e::Required,    "Benefit Related Entity City Name"),
                            b::Element(e::Situational, "Benefit Related Entity State Code"),
                            b::Element(e::Situational, "Benefit Related Entity Postal Zone or ZIP Code"),
                            b::Element(e::Situational, "Benefit Related Entity Country Code"),
                            b::Element(e::Situational, "Benefit Related Entity Location Qualifier", b::Values("RJ")),
                            b::Element(e::Situational, "Benefit Related Entity DOD Health Service Region"),
                            b::Element(e::Situational, "Benefit Related Entity Country Subdivision Code")),
                          b::Segment(3800, s::PER, "Dependent Benefit Related Entity Contact Information", r::Situational, d::RepeatCount.bounded(3),
                            b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                            b::Element(e::Situational, "Benefit Related Entity Contact Name"),
                            b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "FX", "TE", "UR", "WP")),
                            b::Element(e::Situational, "Benefit Related Entity Communication Number"),
                            b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "EX", "FX", "TE", "UR", "WP")),
                            b::Element(e::Situational, "Benefit Related Entity Communication Number"),
                            b::Element(e::Situational, "Communication Number Qualifier", b::Values("ED", "EM", "EX", "FX", "TE", "UR", "WP")),
                            b::Element(e::Situational, "Benefit Related Entity Communication Number"),
                            b::Element(e::NotUsed,     "Contact Inquiry Reference")),
                          b::Segment(3900, s::PRV, "Dependent Benefit Related 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, "Benefit Related Entity 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"))),

                        b::Segment(4000, s::LE, "Loop Trailer", r::Situational, d::RepeatCount.bounded(1),
                          b::Element(e::Required,    "Loop Identifier Code", b::Values("2120")))))))),

            # 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(4100, 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
