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

          # With only a quick glance at X222, it appears that 2300 is a child of
          # the 2000C HL loop. But there is a little note that reads:
          #
          #   For the purposes of this documentation, the claim detail information
          #   is presented only in the dependent level. Specific claim detail
          #   information can be given in either the subscriber or the dependent
          #   hierarchical level. Because of this, the claim information is said
          #   to "float." Claim information is positioned in the same hierarchical
          #   level that describes its owner-participant, either the subscriber or
          #   the dependent. In other words, the claim information, Loop 2300, is
          #   placed in the hierarchical level when the patient is the subscriber,
          #   or it is placed at the patient/dependent hierarchical level when the
          #   patient is the dependent of the subscriber as shown here. When the
          #   patient is the subscriber, loops 2000C and 2010CA are not sent. See
          #   1.4.3.2.2.1, HL Segment, for details.
          #
          # So here we build the 2300 LoopDef and later copy it as a child of the
          # 2000B and 2000C loops. The actual transaction set begins below with
          # the line that starts HC837 = ...

          loop2300 =
            d::LoopDef.build("2300 CLAIM INFORMATION", d::RepeatCount.bounded(100),
                b::Segment(1300, s::CLM, "Claim Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Patient Control Number", b::MaxLength(20)),
                  b::Element(e::Required,    "Total Claim Charge Amount"),
                  b::Element(e::NotUsed,     "Claim Filing Indicator Code"),
                  b::Element(e::NotUsed,     "Non-Institutional Claim Type Code"),
                  b::Element(e::Required,    "HEALTH CARE SERVICE LOCATION INFORMATION",
                    b::Element(e::Required,    "Place of Service Code"),
                    b::Element(e::Required,    "Facility Code Qualifier", b::Values("B")),
                    b::Element(e::Required,    "Claim Frequency Code")),
                  b::Element(e::Required,    "Provider or Supplier Signature Indicator", b::Values("N", "Y")),
                  b::Element(e::Required,    "Assignment or Plan Participation Code", b::Values("A", "B", "C")),
                  b::Element(e::Required,    "Benefits Assignment Certification Indicator", b::Values("N", "W", "Y")),
                  b::Element(e::Required,    "Release of Information Code", b::Values("I", "Y")),
                  b::Element(e::Situational, "Patient Signature Source Code", b::Values("P")),
                  b::Element(e::Situational, "RELATED CAUSES INFORMATION",
                    b::Element(e::Required,    "Related Causes Code", b::Values("AA", "EM", "OA")),
                    b::Element(e::Situational, "Related Causes Code", b::Values("AA", "EM", "OA")),
                    b::Element(e::NotUsed,     "Related Causes Code"),
                    b::Element(e::Situational, "Auto Accident State or Province Code"),
                    b::Element(e::Situational, "Country Code")),
                  b::Element(e::Situational, "Special Program Indicator", b::Values("02", "03", "05", "09")),
                  b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                  b::Element(e::NotUsed,     "Level of Service Code"),
                  b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                  b::Element(e::NotUsed,     "Provider Agreement Code"),
                  b::Element(e::NotUsed,     "Claim Status Code"),
                  b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                  b::Element(e::NotUsed,     "Claim Submission Reason Code"),
                  b::Element(e::Situational, "Delay Reason Code", b::Values("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "15"))),
                b::Segment(1350, s::DTP, "Onset of Current Illness or Symptom", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("431")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Onset of Current Illness or Injury Date")),
                b::Segment(1350, s::DTP, "Initial Treatment Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("454")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Initial Treatment Date")),
                b::Segment(1350, s::DTP, "Last Seen Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("304")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Last Seen Date")),
                b::Segment(1350, s::DTP, "Acute Manifestation Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("453")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Acute Manifestation Date")),
                b::Segment(1350, s::DTP, "Accident Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("439")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Accident Date")),
                b::Segment(1350, s::DTP, "Last Menstrual Period Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("484")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Last Menstrual Period Date")),
                b::Segment(1350, s::DTP, "Last X-ray Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("455")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Last X-ray Date")),
                b::Segment(1350, s::DTP, "Hearing and Vision Prescription Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("471")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Prescription Date")),
                b::Segment(1350, s::DTP, "Disability Dates", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("314", "360", "361")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8", "RD8")),
                  b::Element(e::Required,    "Disability From Date")),
                b::Segment(1350, s::DTP, "Last Worked Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("297")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Last Worked Date")),
                b::Segment(1350, s::DTP, "Authorized Return to Work Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("296")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Work Return Date")),
                b::Segment(1350, s::DTP, "Admission Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("435")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Related Hospitalization Admission Date")),
                b::Segment(1350, s::DTP, "Discharge Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("096")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Related Hospitalization Discharge Date")),
                b::Segment(1350, s::DTP, "Assumed and Relinquished Care Dates", r::Situational, d::RepeatCount.bounded(2),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("090", "091")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Asumed or Relinquished Care Date")),
                b::Segment(1350, s::DTP, "Property and Casualty Date of First Contact", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("444")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Date")),
                b::Segment(1350, s::DTP, "Repricer Received Date", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Date Time Qualifier", b::Values("050")),
                  b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Required,    "Repricer Received Date")),
                b::Segment(1550, s::PWK, "Claim Supplemental Information", r::Situational, d::RepeatCount.bounded(10),
                  b::Element(e::Required,    "Report Type Code", b::Values("03", "04", "05", "06", "07", "08", "09", "10", "11", "13", "15", "21", "A3", "A4", "AM", "AS", "B2", "B3", "B4", "BR", "BS", "BT", "CB", "CK", "CT", "D2", "DA", "DB", "DG", "DJ", "DS", "EB", "HC", "HR", "I5", "IR", "LA", "M1", "MT", "NN", "OB", "OC", "OD", "OE", "OX", "OZ", "P4", "P5", "PE", "PN", "PO", "PQ", "PY", "PZ", "RB", "RR", "RT", "RX", "SG", "V5", "XP")),
                  b::Element(e::Required,    "Attachment Transmission Code", b::Values("AA", "BM", "EL", "EM", "FT", "FX")),
                  b::Element(e::NotUsed,     "Report Copies Needed"),
                  b::Element(e::NotUsed,     "Entity Identifier Code"),
                  b::Element(e::Situational, "Identification Code Qualifier", b::Values("AC")),
                  b::Element(e::Situational, "Attachment Control Number", b::MaxLength(50)),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "ACTIONS INDICATED"),
                  b::Element(e::NotUsed,     "Request Category Code")),
                b::Segment(1600, s::CN1, "Contract Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Contract Type Code", b::Values("01", "02", "03", "04", "05", "06", "09")),
                  b::Element(e::Situational, "Contract Amount"),
                  b::Element(e::Situational, "Contract Percentage"),
                  b::Element(e::Situational, "Contract Code"),
                  b::Element(e::Situational, "Terms Discount Percentage"),
                  b::Element(e::Situational, "Contract Version Number")),
                b::Segment(1750, s::AMT, "Patient Amount Paid", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Amount Qualifier Code", b::Values("F5")),
                  b::Element(e::Required,    "Patient Amount Paid"),
                  b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                b::Segment(1800, s::REF, "Service Authorization Exception Code", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("4N")),
                  b::Element(e::Required,    "Service Authorization Exception Code", b::Values("1", "2", "3", "4", "5", "6", "7")),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Mandatory Medicare (Section 4081) Crossover Indicator", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("F5")),
                  b::Element(e::Required,    "Medicare Section 4081 Indicator", b::Values("Y", "N")),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Mammography Certification Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("EW")),
                  b::Element(e::Required,    "Mammography Certification Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Referral Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9F")),
                  b::Element(e::Required,    "Referral Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Prior Authorization", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("G1")),
                  b::Element(e::Required,    "Prior Authorization Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Payer Claim Control Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("F8")),
                  b::Element(e::Required,    "Payer Claim Control Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Clinical Laboratory Improvement Amendment (CLIA) Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("X4")),
                  b::Element(e::Required,    "Clinical Laboratory Improvement Amendment Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Repriced Claim Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9A")),
                  b::Element(e::Required,    "Repriced Claim Reference Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Adjusted Repriced Claim Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9C")),
                  b::Element(e::Required,    "Adjusted Repriced Claim Reference Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Investigational Device Exemption Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("LX")),
                  b::Element(e::Required,    "Investigational Device Exemption Identifier"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Claim Identifier for Transmission Intermediaries", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("D9")),
                  b::Element(e::Required,    "Value Added Network Trace Number", b::MaxLength(20)),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Medical Record Number", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("EA")),
                  b::Element(e::Required,    "Medical Record Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Demonstration Project Identifier", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("P4")),
                  b::Element(e::Required,    "Demonstration Project Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1800, s::REF, "Care Plan Oversight", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Reference Identification Qualifier", b::Values("1J")),
                  b::Element(e::Required,    "Care Plan Oversight Number"),
                  b::Element(e::NotUsed,     "Description"),
                  b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                b::Segment(1850, s::K3, "File Information", r::Situational, d::RepeatCount.bounded(10),
                  b::Element(e::Required,    "Fixed Format Information"),
                  b::Element(e::NotUsed,     "Record Format Code"),
                  b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE")),
                b::Segment(1900, s::NTE, "Claim Note", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Note Reference Code", b::Values("ADD", "CER", "DCP", "DGN", "TPO")),
                  b::Element(e::Required,    "Claim Note Text")),
                b::Segment(1950, s::CR1, "Ambulance Transportation Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Situational, "Unit or Basis of Measure", b::Values("LB")),
                  b::Element(e::Situational, "Patient Weight"),
                  b::Element(e::NotUsed,     "Ambulance Transport Code"),
                  b::Element(e::Required,    "Ambulance Transport Reason Code", b::Values("A", "B", "C", "D", "E")),
                  b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("DH")),
                  b::Element(e::Required,    "Transport Distance"),
                  b::Element(e::NotUsed,     "Address Information"),
                  b::Element(e::NotUsed,     "Address Information"),
                  b::Element(e::Situational, "Round Trip Purpose Description"),
                  b::Element(e::Situational, "Stretcher Purpose Description")),
                b::Segment(2000, s::CR2, "Spinal Manipulation Service Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::NotUsed,     "Count"),
                  b::Element(e::NotUsed,     "Quantity"),
                  b::Element(e::NotUsed,     "Sublaxation Level Code"),
                  b::Element(e::NotUsed,     "Sublaxation Level Code"),
                  b::Element(e::NotUsed,     "Unit or Basis for Measurement Code"),
                  b::Element(e::NotUsed,     "Quantity"),
                  b::Element(e::NotUsed,     "Quantity"),
                  b::Element(e::Required,    "Nature of Condition Code", b::Values("A", "C", "D", "E", "F", "G", "M")),
                  b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                  b::Element(e::Situational, "Patient Condition Description"),
                  b::Element(e::Situational, "Patient Condition Description"),
                  b::Element(e::NotUsed,     "Yes/No Condition or Response Code")),
                b::Segment(2200, s::CRC, "Ambulance Certification", r::Situational, d::RepeatCount.bounded(3),
                  b::Element(e::Required,    "Code Category", b::Values("07")),
                  b::Element(e::Required,    "Certification Condition Indicator", b::Values("Y", "N")),
                  b::Element(e::Required,    "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                  b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                  b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                  b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                  b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12"))),
                b::Segment(2200, s::CRC, "Patient Condition Information: Vision", r::Situational, d::RepeatCount.bounded(3),
                  b::Element(e::Required,    "Code Category", b::Values("E1", "E2", "E3")),
                  b::Element(e::Required,    "Certification Condition Indicator", b::Values("Y", "N")),
                  b::Element(e::Required,    "Condition Code", b::Values("L1", "L2", "L3", "L4", "L5")),
                  b::Element(e::Situational, "Condition Code", b::Values("L1", "L2", "L3", "L4", "L5")),
                  b::Element(e::Situational, "Condition Code", b::Values("L1", "L2", "L3", "L4", "L5")),
                  b::Element(e::Situational, "Condition Code", b::Values("L1", "L2", "L3", "L4", "L5")),
                  b::Element(e::Situational, "Condition Code", b::Values("L1", "L2", "L3", "L4", "L5"))),
                b::Segment(2200, s::CRC, "Homebound Indicator", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Code Category", b::Values("E1", "E2", "E3")),
                  b::Element(e::Required,    "Certification Condition Indicator", b::Values("Y")),
                  b::Element(e::Required,    "Condition Code", b::Values("IH")),
                  b::Element(e::NotUsed,     "Condition Indicator"),
                  b::Element(e::Situational, "Condition Indicator"),
                  b::Element(e::Situational, "Condition Indicator"),
                  b::Element(e::Situational, "Condition Indicator")),
                b::Segment(2200, s::CRC, "EPSDT Referral", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Code Category", b::Values("ZZ")),
                  b::Element(e::Required,    "Certification Condition Indicator", b::Values("Y", "N")),
                  b::Element(e::Required,    "Condition Code", b::Values("AV", "NU", "S2", "ST")),
                  b::Element(e::Situational, "Condition Code", b::Values("AV", "NU", "S2", "ST")),
                  b::Element(e::Situational, "Condition Code", b::Values("AV", "NU", "S2", "ST")),
                  b::Element(e::NotUsed,     "Condition Indicator"),
                  b::Element(e::NotUsed,     "Condition Indicator")),
                b::Segment(2310, s::HI, "Health Care Diagnosis Code", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code")),
                  b::Element(e::Situational, "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier 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 Code"))),
                b::Segment(2310, s::HI, "Anesthesia Related Procedure", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier Code", b::Values("BP")),
                    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,    "Code List Qualifier Code", b::Values("BO")),
                    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::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::Element(e::NotUsed,       "HEALTH CARE CODE INFORMATION"),
                  b::Element(e::NotUsed,       "HEALTH CARE CODE INFORMATION")),
                b::Segment(2310, s::HI, "Condition Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "HEALTH CARE CODE INFORMATION",
                    b::Element(e::Required,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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,    "Code List Qualifier Code", b::Values("BG")),
                    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::Segment(2410, s::HCP, "Claim Pricing/Repricing Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Pricing Methodology", b::Values("00", "01", "02", "03", "04", "05", "07", "08", "09", "10", "11", "12", "13", "14")),
                  b::Element(e::Required,    "Repriced Allowed Amount"),
                  b::Element(e::Situational, "Repriced Saving Amount"),
                  b::Element(e::Situational, "Repricing Organization Identifier"),
                  b::Element(e::Situational, "Repricing Per Diem or Flat Rate Amount"),
                  b::Element(e::Situational, "Repriced Approved Ambulatory Patient Group Code"),
                  b::Element(e::Situational, "Repriced Approved Ambulatory Patient Group Amount"),
                  b::Element(e::NotUsed,     "Product/Service ID"),
                  b::Element(e::NotUsed,     "Product/Service Qualifier"),
                  b::Element(e::NotUsed,     "Product/Service ID"),
                  b::Element(e::NotUsed,     "Unit or Basis of Measurement Code"),
                  b::Element(e::NotUsed,     "Quantity"),
                  b::Element(e::Situational, "Reject Reason Code", b::Values("T1", "T2", "T3", "T4", "T5", "T6")),
                  b::Element(e::Situational, "Policy Compliance Code", b::Values("1", "2", "3", "4", "5")),
                  b::Element(e::Situational, "Exception Code", b::Values("1", "2", "3", "4", "5", "6"))),

                d::LoopDef.build("2310A REFERRING PROVIDER NAME", d::RepeatCount.bounded(2),
                  b::Segment(2500, s::NM1, "Referring Provider Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("DN", "P3")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                    b::Element(e::Required,    "Referring Provider Last Name"),
                    b::Element(e::Situational, "Referring Provider First Name"),
                    b::Element(e::Situational, "Referring Provider Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Referring Provider Name Suffix"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                    b::Element(e::Situational, "Referring Provider 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(2710, s::REF, "Referring Provider Specialty Information", r::Situational, d::RepeatCount.bounded(3),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2")),
                    b::Element(e::Required,    "Referring Provider Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                d::LoopDef.build("2310B RENDERING PROVIDER NAME", d::RepeatCount.bounded(1),
                  b::Segment(2500, s::NM1, "Rendering Provider Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("82")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::Required,    "Rendering Provider Last Name"),
                    b::Element(e::Situational, "Rendering Provider First Name"),
                    b::Element(e::Situational, "Rendering Provider Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Rendering Provider Name Suffix"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                    b::Element(e::Situational, "Rendering Provider 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(2550, s::PRV, "Rendering Provider Specialty Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Provider Code", b::Values("PE")),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("PXC")),
                    b::Element(e::Required,    "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(2710, s::REF, "Rendering Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(4),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2", "LU")),
                    b::Element(e::Required,    "Reference Identification"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                d::LoopDef.build("2310C SERVICE FACILITY LOCATION NAME", d::RepeatCount.bounded(1),
                  b::Segment(2500, s::NM1, "Service Facility Location Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("77")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("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::Situational, "Identification Code Qualifier", b::Values("XX")),
                    b::Element(e::Situational, "Laboratory or Facility 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(2650, s::N3, "Service Facility Location Address", r::Required, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Laboratory or Facility Address Line"),
                    b::Element(e::Situational, "Laboratory or Facility Address Line")),
                  b::Segment(2700, s::N4, "Service Facility Location City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Laboratory or Facility City Name"),
                    b::Element(e::Situational, "Laboratory or Facility Province Code"),
                    b::Element(e::Situational, "Laboratory or Facility 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(2710, s::REF, "Service Facility Location Secondary Identification", r::Situational, d::RepeatCount.bounded(3),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "G2", "LU")),
                    b::Element(e::Required,    "Laboratory or Facility Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(2750, s::PER, "Service Facility Contact Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                    b::Element(e::Situational, "Name"),
                    b::Element(e::Required,    "Communication Number Qualifier", b::Values("TE")),
                    b::Element(e::Required,    "Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EX")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::NotUsed,     "Communication Number Qualifier"),
                    b::Element(e::NotUsed,     "Communication Number"),
                    b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

                d::LoopDef.build("2310D SUPERVISING PROVIDER NAME", d::RepeatCount.bounded(1),
                  b::Segment(2500, s::NM1, "Supervising Provider Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("DQ")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                    b::Element(e::Required,    "Supervising Provider Last Name"),
                    b::Element(e::Situational, "Supervising Provider First Name"),
                    b::Element(e::Situational, "Supervising Provider Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Supervising Provider Name Suffix"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                    b::Element(e::Situational, "Supervising Provider 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(2710, s::REF, "Supervising Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(4),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2", "LU")),
                    b::Element(e::Required,    "Supervising Provider Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                d::LoopDef.build("2310E AMBULANCE PICK-UP LOCATION", d::RepeatCount.bounded(1),
                  b::Segment(2500, s::NM1, "Ambulance Pick-up Location", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("PW")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                    b::Element(e::NotUsed,     "Name Last or Organization Name"),
                    b::Element(e::NotUsed,     "Name First"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::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(2650, s::N3, "Ambulance Pick-up Location Address", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Ambulance Pick-up Address Line"),
                    b::Element(e::Situational, "Ambulance Pick-up Address Line")),
                  b::Segment(2700, s::N4, "Ambulance Pick-up Location City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Ambulance Pick-up City Name"),
                    b::Element(e::Situational, "Ambulance Pick-up State or Province Code"),
                    b::Element(e::Situational, "Ambulance Pick-up 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"))),

                d::LoopDef.build("2310F AMBULANCE DROP-OFF LOCATION", d::RepeatCount.bounded(1),
                  b::Segment(2500, s::NM1, "Ambulance Drop-off Location", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("45")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                    b::Element(e::Situational, "Ambulance Drop-off Location"),
                    b::Element(e::NotUsed,     "Name First"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::NotUsed,     "Identification Code Qualifier", b::Values("XX")),
                    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(2650, s::N3, "Ambulance Drop-off Location Address", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Ambulance Drop-off Address Line"),
                    b::Element(e::Situational, "Ambulance Drop-off Address Line")),
                  b::Segment(2700, s::N4, "Ambulance Drop-off Location City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Ambulance Drop-off City Name"),
                    b::Element(e::Situational, "Ambulance Drop-off State or Province Code"),
                    b::Element(e::Situational, "Ambulance Drop-off 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"))),

                d::LoopDef.build("2320 OTHER SUBSCRIBER INFORMATION", d::RepeatCount.bounded(10),
                  b::Segment(2900, s::SBR, "Other Subscriber Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Payer Responsibility Sequence Number", b::Values("A", "B", "C", "D", "E", "F", "G", "H", "P", "S", "T", "U")),
                    b::Element(e::Required,    "Individual Relationship Code", b::Values("01", "18", "19", "20", "21", "39", "40", "53", "G8")),
                    b::Element(e::Situational, "Insured Group or Policy Number"),
                    b::Element(e::Situational, "Other Insured Group Name"),
                    b::Element(e::Situational, "Insurance Type Code", b::Values("12", "13", "14", "15", "16", "41", "42", "43", "47")),
                    b::Element(e::NotUsed,     "Coordination of Benefits Code"),
                    b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                    b::Element(e::NotUsed,     "Employment Status Code"),
                    b::Element(e::Situational, "Claim Filing Indicator Code", b::Values("11", "12", "13", "14", "15", "16", "17", "AM", "BL", "CH", "CI", "DS", "FI", "HM", "LM", "MA", "MB", "MC", "OF", "TV", "VA", "WC", "ZZ"))),
                  b::Segment(2950, s::CAS, "Claim Level Adjustments", r::Situational, d::RepeatCount.bounded(5),
                    b::Element(e::Required,    "Claim Adjustment Group Code", b::Values("CO", "CR", "OA", "PI", "PR")),
                    b::Element(e::Required,    "Adjustment Reason Code"),
                    b::Element(e::Required,    "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity"),
                    b::Element(e::Situational, "Adjustment Reason Code"),
                    b::Element(e::Situational, "Adjustment Amount"),
                    b::Element(e::Situational, "Adjustment Quantity")),
                  b::Segment(3000, s::AMT, "Coordination of Benefits (COB) Payer Paid Amount", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Amount Qualifier Code", b::Values("D")),
                    b::Element(e::Required,    "Payer Paid Amount"),
                    b::Element(e::NotUsed,     "Credit/Debit Flag")),
                  b::Segment(3000, s::AMT, "Coordination of Benefits (COB) Total Non-Covered Amount", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Amount Qualifier Code", b::Values("A8")),
                    b::Element(e::Required,    "Non-Covered Charge Amount"),
                    b::Element(e::NotUsed,     "Credit/Debit Flag")),
                  b::Segment(3000, s::AMT, "Remaining Patient Liability", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Amount Qualifier Code", b::Values("EAF")),
                    b::Element(e::Required,    "Remaining Patient Liability"),
                    b::Element(e::NotUsed,     "Credit/Debit Flag")),
                  b::Segment(3100, s::OI, "Other Insurance Coverage Information", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::NotUsed,     "Claim Filing Indicator Code"),
                    b::Element(e::NotUsed,     "Claim Submission Reason Code"),
                    b::Element(e::Required,    "Benefits Assignment Certification Indicator", b::Values("N", "W", "Y")),
                    b::Element(e::Situational, "Patient Signature Source Code", b::Values("P")),
                    b::Element(e::NotUsed,     "Provider Agreement Code"),
                    b::Element(e::Required,    "Release of Information Code", b::Values("I", "Y"))),
                  b::Segment(3200, s::MOA, "Outpatient Adjudication Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Situational, "Reimbursement Rate"),
                    b::Element(e::Situational, "HCPCS Payable Amount"),
                    b::Element(e::Situational, "Claim Payment Remark Code"),
                    b::Element(e::Situational, "Claim Payment Remark Code"),
                    b::Element(e::Situational, "Claim Payment Remark Code"),
                    b::Element(e::Situational, "Claim Payment Remark Code"),
                    b::Element(e::Situational, "Claim Payment Remark Code"),
                    b::Element(e::Situational, "End Stage Renal Disease Payment Amount"),
                    b::Element(e::Situational, "Non-Payable Professional Component Billed Amount")),

                  d::LoopDef.build("2330A OTHER SUBSCRIBER NAME", d::RepeatCount.bounded(1),
                    b::Segment(3250, s::NM1, "Other 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::Required,    "Other Insured Last Name"),
                      b::Element(e::Situational, "Other Insured First Name"),
                      b::Element(e::Situational, "Other Insured Middle Name"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Other Insured Name Suffix"),
                      b::Element(e::Required,    "Identification Code Qualifier", b::Values("II", "MI")),
                      b::Element(e::Required,    "Other Insured 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(3320, s::N3, "Other Subscriber Address", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Other Subscriber Address Line"),
                      b::Element(e::Situational, "Other Subscriber Address Line")),
                    b::Segment(3400, s::N4, "Other Subscriber City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Other Subscriber City Name"),
                      b::Element(e::Situational, "Other Subscriber State or Province Code"),
                      b::Element(e::Situational, "Other 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(3550, s::REF, "Other Subscriber Secondary Identification", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("SY")),
                      b::Element(e::Required,    "Other Insured Additional Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2330B OTHER PAYER NAME", d::RepeatCount.bounded(1),
                    b::Segment(3250, s::NM1, "Other Payer Name", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("PR")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                      b::Element(e::Required,    "Other Payer Organization Name"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::Required,    "Identification Code Qualifier", b::Values("PI", "XV")),
                      b::Element(e::Required,    "Other Payer 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(3320, s::N3, "Other Payer Address", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Other Payer Address Line"),
                      b::Element(e::Situational, "Other Payer Address Line")),
                    b::Segment(3400, s::N4, "Other Payer City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Other Payer City Name"),
                      b::Element(e::Situational, "Other Payer State or Province Code"),
                      b::Element(e::Situational, "Other Payer 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(3500, s::DTP, "Claim Check or Remittance Date", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Date Time Qualifier", b::Values("573")),
                      b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                      b::Element(e::Required,    "Adjudication or Payment Date")),
                    b::Segment(3550, s::REF, "Other Payer Secondary Identifier", r::Situational, d::RepeatCount.bounded(2),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U", "EI", "FY", "NF")),
                      b::Element(e::Required,    "Other Payer Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(3550, s::REF, "Other Payer Prior Authorization Number", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("G1")),
                      b::Element(e::Required,    "Other Payer Prior Authorization Number"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(3550, s::REF, "Other Payer Referral Number", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9F")),
                      b::Element(e::Required,    "Other Payer Prior Authorization or Referral Number"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(3550, s::REF, "Other Payer Claim Adjustment Indicator", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("T4")),
                      b::Element(e::Required,    "Other Payer Claim Adjustment Indicator", b::Values("Y")),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                    b::Segment(3550, s::REF, "Other Payer Claim Control Number", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("F8")),
                      b::Element(e::Required,    "Other Payer's Claim Control Number"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2330C OTHER PAYER REFERRING PROVIDER", d::RepeatCount.bounded(2),
                    b::Segment(3250, s::NM1, "Other Payer Referring Provider", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("DN", "P3")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                      b::Element(e::NotUsed,     "Name Last"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::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(3550, s::REF, "Other Payer Referring Provider Secondary Identification", r::Required, d::RepeatCount.bounded(3),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2")),
                      b::Element(e::Required,    "Other Payer Referring Provider Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2330D OTHER PAYER RENDERING PROVIDER", d::RepeatCount.bounded(1),
                    b::Segment(3250, s::NM1,  "Other Payer Rendering Provider", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("82")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                      b::Element(e::NotUsed,     "Name Last"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::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(3550, s::REF, "Other Payer Rendering Provider Secondary Identification", r::Required, d::RepeatCount.bounded(3),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2", "LU")),
                      b::Element(e::Required,    "Other Payer Rendering Provider Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2330E OTHER PAYER SERVICE FACILITY LOCATION", d::RepeatCount.bounded(1),
                    b::Segment(3250, s::NM1, "Other Payer Service Facility Location", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("77")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                      b::Element(e::NotUsed,     "Name Last"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::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(3550, s::REF, "Other Payer Service Facility Location Secondary Identification", r::Required, d::RepeatCount.bounded(3),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "G2", "LU")),
                      b::Element(e::Required,    "Other Payer Service Facility Location Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2330F OTHER PAYER SUPERVISING PROVIDER", d::RepeatCount.bounded(1),
                    b::Segment(3250, s::NM1, "Other Payer Supervising Provider", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("DQ")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                      b::Element(e::NotUsed,     "Name Last"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::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(3550, s::REF, "Other Payer Supervising Provider Secondary Identification", r::Required, d::RepeatCount.bounded(3),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2", "LU")),
                      b::Element(e::Required,    "Other Payer Supervising Provider Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2330G OTHER PAYER BILLING PROVIDER", d::RepeatCount.bounded(1),
                    b::Segment(3250, s::NM1, "Other Payer Billing Provider", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("85")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                      b::Element(e::NotUsed,     "Name L"),
                      b::Element(e::NotUsed,     "Name F"),
                      b::Element(e::NotUsed,     "Name M"),
                      b::Element(e::NotUsed,     "Name P"),
                      b::Element(e::NotUsed,     "Name S"),
                      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(3550, s::REF, "Other Payer Billing Provider Secondary Identification", r::Required, d::RepeatCount.bounded(2),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("G2", "LU")),
                      b::Element(e::Required,    "Other Payer Billing Provider Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")))),

                d::LoopDef.build("2400 SERVICE LINE NUMBER", d::RepeatCount.bounded(50),
                  b::Segment(3650, s::LX, "Service Line Number", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Assigned Number")),
                  b::Segment(3700, s::SV1, "Professional Service", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                      b::Element(e::Required,    "Product or Service ID Qualifier", b::Values("ER", "HC", "IV", "WK")),
                      b::Element(e::Required,    "Procedure Code"),
                      b::Element(e::Situational, "Procedure Modifier"),
                      b::Element(e::Situational, "Procedure Modifier"),
                      b::Element(e::Situational, "Procedure Modifier"),
                      b::Element(e::Situational, "Procedure Modifier"),
                      b::Element(e::Situational, "Description"),
                      b::Element(e::NotUsed,     "Product/Service ID")),
                    b::Element(e::Required,    "Line Item Charge Amount"),
                    b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("MJ", "UN")),
                    b::Element(e::Required,    "Service Unit Count", b::MaxLength(8), b::MaxPrecision(3)),
                    b::Element(e::Situational, "Place of Service Code"),
                    b::Element(e::NotUsed,     "Service Type Code"),
                    b::Element(e::Required,    "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::Element(e::NotUsed,     "Monetary Amount"),
                    b::Element(e::Situational, "Emergency Indicator", b::Values("Y")),
                    b::Element(e::NotUsed,     "Multiple Procedure Code"),
                    b::Element(e::Situational, "EPSDT Indicator", b::Values("Y")),
                    b::Element(e::Situational, "Family Planning Indicator", b::Values("Y")),
                    b::Element(e::NotUsed,     "Review Code"),
                    b::Element(e::NotUsed,     "National or Local Assigned Review Value"),
                    b::Element(e::Situational, "Co-Pay Status Code", b::Values("0")),
                    b::Element(e::NotUsed,     "Health Care Professional Shortage Area Code"),
                    b::Element(e::NotUsed,     "Reference Identification"),
                    b::Element(e::NotUsed,     "Postal Code"),
                    b::Element(e::NotUsed,     "Monetary Amount"),
                    b::Element(e::NotUsed,     "Level of Care Code"),
                    b::Element(e::NotUsed,     "Provider Agreement Code")),
                  b::Segment(4000, s::SV5, "Durable Medical Equipment Service", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                      b::Element(e::Required,    "Procedure Identifier", b::Values("HC")),
                      b::Element(e::Required,    "Procedure Code"),
                      b::Element(e::NotUsed,     "Procedure Modifier"),
                      b::Element(e::NotUsed,     "Procedure Modifier"),
                      b::Element(e::NotUsed,     "Procedure Modifier"),
                      b::Element(e::NotUsed,     "Procedure Modifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "Product/Service ID")),
                    b::Element(e::Required,    "Unit or Basis for Measurement Code"),
                    b::Element(e::Required,    "Length of Medical Necessity"),
                    b::Element(e::Required,    "DME Rental Price"),
                    b::Element(e::Required,    "DME Purchase Price"),
                    b::Element(e::Required,    "Rental Unit Price Indicator", b::Values("1", "4", "6")),
                    b::Element(e::NotUsed,     "Prognosis Code")),
                  b::Segment(4200, s::PWK, "Line Supplemental Information", r::Situational, d::RepeatCount.bounded(10),
                    b::Element(e::Required,    "Attachment Report Type Code", b::Values("03", "04", "05", "06", "07", "08", "09", "10", "11", "13", "15", "21", "A3", "A4", "AM", "AS", "B2", "B4", "BR", "BS", "BT", "CB", "CK", "CT", "D2", "DA", "DA", "DB", "DG", "DJ", "DS", "EB", "HC", "HR", "I5", "IR", "LA", "M1", "MT", "NN", "OB", "OC", "OD", "OE", "OX", "OZ", "P4", "P5", "PE", "PN", "PO", "PQ", "PY", "PZ", "RB", "RR", "RT", "RX", "SG", "V5", "XP")),
                    b::Element(e::Required,    "Attachment Transmission Code", b::Values("AA", "BM", "EL", "EM", "FT", "FX")),
                    b::Element(e::NotUsed,     "Report Copies Needed"),
                    b::Element(e::NotUsed,     "Entity Identifier Code"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("AC")),
                    b::Element(e::Situational, "Attachment Control Number", b::MaxLength(50)),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "ACTIONS INDICATED"),
                    b::Element(e::NotUsed,     "Request Category Code")),
                  b::Segment(4200, s::PWK, "Durable Medical Equipment Certification of Medical Necessity Indicator", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Attachment Report Type Code", b::Values("CT")),
                    b::Element(e::Required,    "Attachment Transmission Code", b::Values("AB", "AD", "AF", "AG", "NS")),
                    b::Element(e::NotUsed,     "Report Copies Needed"),
                    b::Element(e::NotUsed,     "Entity Identifier Code"),
                    b::Element(e::NotUsed,     "Identification Code Qualifier"),
                    b::Element(e::NotUsed,     "Identification Code"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "ACTIONS INDICATED"),
                    b::Element(e::NotUsed,     "Request Category Code")),
                  b::Segment(4250, s::CR1, "Ambulance Transport Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Situational, "Unit or Basis for Measurement Code", b::Values("LB")),
                    b::Element(e::Situational, "Patient Weight"),
                    b::Element(e::NotUsed,     "Ambulance Transport Code"),
                    b::Element(e::Required,    "Ambulance Transport Reason Code", b::Values("A", "B", "C", "D", "E")),
                    b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("DH")),
                    b::Element(e::Required,    "Transport Distance"),
                    b::Element(e::NotUsed,     "Address Information"),
                    b::Element(e::NotUsed,     "Address Information"),
                    b::Element(e::Situational, "Round Trip Purpose Description"),
                    b::Element(e::Situational, "Stretcher Purpose Description")),
                  b::Segment(4350, s::CR3, "Durable Medical Equipment Certification", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Certification Type Code", b::Values("I", "R", "S")),
                    b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("MO")),
                    b::Element(e::Required,    "Durable Medical Equipment Duration"),
                    b::Element(e::NotUsed,     "Insulin Dependent Code"),
                    b::Element(e::NotUsed,     "Description")),
                  b::Segment(4500, s::CRC, "Ambulance Certification", r::Situational, d::RepeatCount.bounded(3),
                    b::Element(e::Required,    "Code Category", b::Values("07")),
                    b::Element(e::Required,    "Certification Condition Indicator", b::Values("N", "Y")),
                    b::Element(e::Required,    "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                    b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                    b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                    b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12")),
                    b::Element(e::Situational, "Condition Code", b::Values("01", "04", "05", "06", "07", "08", "09", "12"))),
                  b::Segment(4500, s::CRC, "Hospice Employee Indicator", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Code Category", b::Values("70")),
                    b::Element(e::Required,    "Hospice Employed Provider Indicator", b::Values("N", "Y")),
                    b::Element(e::Required,    "Condition Indicator", b::Values("65")),
                    b::Element(e::NotUsed,     "Condition Indicator"),
                    b::Element(e::NotUsed,     "Condition Indicator"),
                    b::Element(e::NotUsed,     "Condition Indicator"),
                    b::Element(e::NotUsed,     "Condition Indicator")),
                  b::Segment(4500, s::CRC, "Condition Indicator/Durable Medical Equipment", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Code Category", b::Values("09")),
                    b::Element(e::Required,    "Certification Condition Indicator", b::Values("Y", "N")),
                    b::Element(e::Required,    "Condition Indicator", b::Values("38", "ZV")),
                    b::Element(e::Situational, "Condition Indicator", b::Values("38", "ZV")),
                    b::Element(e::NotUsed,     "Condition Indicator"),
                    b::Element(e::NotUsed,     "Condition Indicator"),
                    b::Element(e::NotUsed,     "Condition Indicator")),
                  b::Segment(4550, s::DTP, "Service Date", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("472")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8", "RD8")),
                    b::Element(e::Required,    "Service Date")),
                  b::Segment(4550, s::DTP, "Prescription Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("471")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Prescription Date")),
                  b::Segment(4550, s::DTP, "Certification Revision/Recertification Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("607")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Certification Revision or Recertification Date")),
                  b::Segment(4550, s::DTP, "Begin Therapy Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("463")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Begin Therapy Date")),
                  b::Segment(4550, s::DTP, "Last Certification Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("461")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Last Certification Date")),
                  b::Segment(4550, s::DTP, "Last Seen Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("304")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Treatment or Therapy Date")),
                  b::Segment(4550, s::DTP, "Test Date", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("738", "739")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Test Performed Date")),
                  b::Segment(4550, s::DTP, "Shipped Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("011")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Shipped Date")),
                  b::Segment(4550, s::DTP, "Last X-ray Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("455")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Last X-ray Date")),
                  b::Segment(4550, s::DTP, "Initial Treatment Date", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Qualifier", b::Values("454")),
                    b::Element(e::Required,    "Date Time Period Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Initial Treatment Date")),
                  b::Segment(4600, s::QTY, "Ambulance Patient Count", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Quantity Qualifier", b::Values("PT")),
                    b::Element(e::Required,    "Ambulance Patient Count"),
                    b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE"),
                    b::Element(e::NotUsed,     "Free-form Information")),
                  b::Segment(4600, s::QTY, "Obstetric Anesthesia Additional Units", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Quantity Qualifier", b::Values("FL")),
                    b::Element(e::Required,    "Obstetric Additional Units"),
                    b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE"),
                    b::Element(e::NotUsed,     "Free-form Information")),
                  b::Segment(4620, s::MEA, "Test Result", r::Situational, d::RepeatCount.bounded(5),
                    b::Element(e::Required,    "Measurement Reference Identification Code", b::Values("OG", "TR")),
                    b::Element(e::Required,    "Measurement Qualifier", b::Values("HT", "R1", "R2", "R3", "R4")),
                    b::Element(e::Required,    "Test Results"),
                    b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE"),
                    b::Element(e::NotUsed,     "Range Minimum"),
                    b::Element(e::NotUsed,     "Range Maximum"),
                    b::Element(e::NotUsed,     "Measurement Significance Code"),
                    b::Element(e::NotUsed,     "Measurement Attribute Code"),
                    b::Element(e::NotUsed,     "Surface/Layer/Position Code"),
                    b::Element(e::NotUsed,     "Measurement Method or Device"),
                    b::Element(e::NotUsed,     "Code List Qualifier Code"),
                    b::Element(e::NotUsed,     "Industry Code")),
                  b::Segment(4650, s::CN1, "Contract Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Contract Type Code", b::Values("01", "02", "03", "04", "05", "06", "09")),
                    b::Element(e::Required,    "Contract Amount"),
                    b::Element(e::Situational, "Contract Percentage"),
                    b::Element(e::Situational, "Contract Code"),
                    b::Element(e::Situational, "Terms Discount Percentage"),
                    b::Element(e::Situational, "Contract Version Identifier")),
                  b::Segment(4700, s::REF, "Repriced Line Item Reference Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9B")),
                    b::Element(e::Required,    "Repriced Line Item Reference Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Adjusted Repriced Line Item Reference Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9D")),
                    b::Element(e::Required,    "Adjusted Repriced Line Item Reference Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Prior Authorization", r::Situational, d::RepeatCount.bounded(5),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("G1")),
                    b::Element(e::Required,    "Prior Authorization or Referral Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::Situational, "REFERENCE IDENTIFIER",
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                      b::Element(e::Required,    "Other Payer Primary Identifier"),
                      b::Element(e::NotUsed,     "Reference Identifier Qualifier"),
                      b::Element(e::NotUsed,     "Reference Identification"),
                      b::Element(e::NotUsed,     "Reference Identifier Qualifier"),
                      b::Element(e::NotUsed,     "Reference Identification"))),
                  b::Segment(4700, s::REF, "Line Item Control Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("6R")),
                    b::Element(e::Required,    "Line Item Control Number", b::MaxLength(30)),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Mammography Certification Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("EW")),
                    b::Element(e::Required,    "Mammography Certification Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Clinical Laboratory Improvement Amendment (CLIA) Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("X4")),
                    b::Element(e::Required,    "Clinical Laboratory Improvement Amendment Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Referring Clinical Laboratory Improvement Amendment (CLIA) Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("F4")),
                    b::Element(e::Required,    "Referring CLIA Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Immunization Batch Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("BT")),
                    b::Element(e::Required,    "Immunization Batch Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(4700, s::REF, "Referral Number", r::Situational, d::RepeatCount.bounded(5),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("9F")),
                    b::Element(e::Required,    "Referral Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::Situational, "REFERENCE IDENTIFIER",
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                      b::Element(e::Required,    "Other Payer Primary Identifier"),
                      b::Element(e::NotUsed,     "Reference Identifier Qualifier"),
                      b::Element(e::NotUsed,     "Reference Identification"),
                      b::Element(e::NotUsed,     "Reference Identifier Qualifier"),
                      b::Element(e::NotUsed,     "Reference Identification"))),
                  b::Segment(4750, s::AMT, "Sales Tax Amount", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Amount Qualifier Code", b::Values("T")),
                    b::Element(e::Required,    "Sales Tax Amount"),
                    b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                  b::Segment(4750, s::AMT, "Postage Claimed Amount", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Amount Qualifier Code", b::Values("F4")),
                    b::Element(e::Required,    "Postage Claimed Amount"),
                    b::Element(e::NotUsed,     "Credit/Debit Flag Code")),
                  b::Segment(4800, s::K3, "File Information", r::Situational, d::RepeatCount.bounded(10),
                    b::Element(e::Required,    "Fixed Format Identification"),
                    b::Element(e::NotUsed,     "Record Format Code"),
                    b::Element(e::NotUsed,     "COMPOSITE UNIT OF MEASURE")),
                  b::Segment(4850, s::NTE, "Line Note", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Note Reference Code", b::Values("ADD", "DCP")),
                    b::Element(e::Required,    "Line Note Text")),
                  b::Segment(4850, s::NTE, "Third Party Organization Notes", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Note Reference Code", b::Values("TPO")),
                    b::Element(e::Required,    "Line Note Text")),
                  b::Segment(4880, s::PS1, "Purchased Service Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Purchased Service Provider Identifier"),
                    b::Element(e::Required,    "Purchased Service Charge Amount"),
                    b::Element(e::NotUsed,     "State or Province Code")),
                  b::Segment(4920, s::HCP, "Line Pricing/Repricing Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Pricing Methodology", b::Values("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14")),
                    b::Element(e::Required,    "Repriced Allowed Amount"),
                    b::Element(e::Situational, "Repciced Saving Amount"),
                    b::Element(e::Situational, "Repricing Organization Identifier"),
                    b::Element(e::Situational, "Repricing Per Diem or Flat Rate Amount"),
                    b::Element(e::Situational, "Repriced Approved Ambulatory Patient Group Code"),
                    b::Element(e::Situational, "Repriced Approved Ambulatory Patient Group Amount"),
                    b::Element(e::NotUsed,     "Product/Service ID"),
                    b::Element(e::Situational, "Product or Service ID", b::Values("ER", "HC", "IV", "WK")),
                    b::Element(e::Situational, "Repriced Approved HCPCS Code"),
                    b::Element(e::Situational, "Unit or Basis for Measurement Code", b::Values("MJ", "UN")),
                    b::Element(e::Situational, "Repriced Approved Service Unit Count", b::MaxLength(8), b::MaxPrecision(3)),
                    b::Element(e::Situational, "Reject Reason Code", b::Values("T1", "T2", "T3", "T4", "T5", "T6")),
                    b::Element(e::Situational, "Policy Compliance Code", b::Values("1", "2", "3", "4", "5")),
                    b::Element(e::Situational, "Exception Code", b::Values("1", "2", "3", "4", "5", "6"))),

                  d::LoopDef.build("2410 DRUG IDENTIFICATION", d::RepeatCount.bounded(1),
                    b::Segment(4930, s::LIN, "Drug Identification", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::NotUsed,     "Assigned Identification"),
                      b::Element(e::Required,    "Product or Service ID Qualifier", b::Values("N4", "EN", "EO", "HI", "ON", "UK", "UP")),
                      b::Element(e::Required,    "National Drug Code or Universal Product Number"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::NotUsed,     "Product/Service ID Qualifier"),
                      b::Element(e::NotUsed,     "Product/Service ID")),
                    b::Segment(4940, s::CTP, "Drug Quantity", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::NotUsed,     "Class of Trade Code"),
                      b::Element(e::NotUsed,     "Price Identifier Code"),
                      b::Element(e::NotUsed,     "Unit Price"),
                      b::Element(e::Required,    "National Drug Unit Count"),
                      b::Element(e::Required,    "COMPOSITE UNIT OF MEASURE",
                        b::Element(e::Required,    "Unit or Basis for Measurement Code", b::Values("F2", "GR", "ME", "ML", "UN")),
                        b::Element(e::NotUsed,     "Exponent"),
                        b::Element(e::NotUsed,     "Multiplier"),
                        b::Element(e::NotUsed,     "Unit or Basis for Measurement Code"),
                        b::Element(e::NotUsed,     "Exponent"),
                        b::Element(e::NotUsed,     "Multiplier"),
                        b::Element(e::NotUsed,     "Unit or Basis for Measurement Code"),
                        b::Element(e::NotUsed,     "Exponent"),
                        b::Element(e::NotUsed,     "Multiplier"),
                        b::Element(e::NotUsed,     "Unit or Basis for Measurement Code"),
                        b::Element(e::NotUsed,     "Exponent"),
                        b::Element(e::NotUsed,     "Multiplier"),
                        b::Element(e::NotUsed,     "Unit or Basis for Measurement Code"),
                        b::Element(e::NotUsed,     "Exponent"),
                        b::Element(e::NotUsed,     "Multiplier")),
                      b::Element(e::NotUsed,     "Price Multiplier Qualifier"),
                      b::Element(e::NotUsed,     "Multiplier"),
                      b::Element(e::NotUsed,     "Monetary Amount"),
                      b::Element(e::NotUsed,     "Basis of Unit Price Code"),
                      b::Element(e::NotUsed,     "Condition Value"),
                      b::Element(e::NotUsed,     "Multiple Price Quantity")),
                    b::Segment(4950, s::REF, "Rendering Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("VY", "XZ")),
                      b::Element(e::Required,    "Prescription Number"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2420A RENDERING PROVIDER NAME", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Rendering Provider Name", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("82")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                      b::Element(e::Required,    "Rendering Provider Last Name"),
                      b::Element(e::Situational, "Rendering Provider First Name"),
                      b::Element(e::Situational, "Rendering Provider Middle Name or Initial"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Rendering Provider Suffix"),
                      b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                      b::Element(e::Situational, "Rendering Provider 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(5050, s::PRV, "Rendering Provider Specialty Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Provider Code", b::Values("PE")),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("PXC")),
                      b::Element(e::Required,    "Provider Taxonmy 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(5250, s::REF, "Rendering Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(20),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2", "LU")),
                      b::Element(e::Required,    "Rendering Provider Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                  d::LoopDef.build("2420B PURCHASED SERVICE PROVIDER NAME", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Purchased Service Provider Name", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("QB")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                      b::Element(e::NotUsed,     "Name Last"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                      b::Element(e::Situational, "Purchased Service Provider 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(5250, s::REF, "Purchased Service Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(20),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2")),
                      b::Element(e::Required,    "Purchased Service Provider Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::Situational, "REFERENCE IDENTIFIER",
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                        b::Element(e::Required,    "Other Payer Primary Identifier"),
                        b::Element(e::NotUsed,     "Reference Identifier Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identifier"),
                        b::Element(e::NotUsed,     "Reference Identifier Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identifier")))),

                  d::LoopDef.build("2420C SERVICE FACILITY LOCATION NAME", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Service Facility Location Name", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("77")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                      b::Element(e::Required,    "Laboratory or Facility Name"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                      b::Element(e::Situational, "Laboratory or Facility 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(5140, s::N3, "Service Facility Location Address", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Laboratory or Facility Address Line"),
                      b::Element(e::Situational, "Laboratory or Facility Address Line")),
                    b::Segment(5200, s::N4, "Service Facility Location City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Laboratory or Facility City Name"),
                      b::Element(e::Situational, "Laboratory or Facility State or Province Code"),
                      b::Element(e::Situational, "Laboratory or Facility 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(5250, s::REF, "Service Facility Location Secondary Identification", r::Situational, d::RepeatCount.bounded(3),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("G2", "LU")),
                      b::Element(e::Required,    "Service Facility Location Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::Situational, "REFERENCE IDENTIFIER",
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                        b::Element(e::Required,    "Other Payer Primary Identifier"),
                        b::Element(e::NotUsed,     "Reference Identification Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identification"),
                        b::Element(e::NotUsed,     "Reference Identification Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identification")))),

                  d::LoopDef.build("2420D SUPERVISING PROVIDER NAME", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Supervising Provider Name", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("DQ")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                      b::Element(e::Required,    "Supervising Provider Last"),
                      b::Element(e::Situational, "Supervising Provider First"),
                      b::Element(e::Situational, "Supervising Provider Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Supervising Provider Suffix"),
                      b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                      b::Element(e::Situational, "Supervising Provider 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(5250, s::REF, "Supervising Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(20),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2", "LU")),
                      b::Element(e::Required,    "Supervising Provider Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::Situational, "REFERENCE IDENTIFIER",
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                        b::Element(e::Required,    "Other Payer Primary Identifier"),
                        b::Element(e::Required,    "Reference Identification Qualifier"),
                        b::Element(e::Required,    "Reference Identification"),
                        b::Element(e::Required,    "Reference Identification Qualifier"),
                        b::Element(e::Required,    "Reference Identification")))),

                  d::LoopDef.build("2420E ORDERING PROVIDER NAME", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Ordering Provider Name", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("DK")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                      b::Element(e::Required,    "Ordering Provider Last"),
                      b::Element(e::Situational, "Ordering Provider First"),
                      b::Element(e::Situational, "Ordering Provider Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Ordering Provider Suffix"),
                      b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                      b::Element(e::Situational, "Ordering Provider 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(5140, s::N3, "Ordering Provider Address", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Ordering Provider Address Line"),
                      b::Element(e::Situational, "Ordering Provider Address Line")),
                    b::Segment(5200, s::N4, "Ordering Provider City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Ordering Provider City Name"),
                      b::Element(e::Situational, "Ordering Provider State or Province Code"),
                      b::Element(e::Situational, "Ordering Provider 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(5250, s::REF, "Ordering Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(20),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2")),
                      b::Element(e::Required,    "Ordering Provider Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::Situational, "REFERENCE IDENTIFIER",
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                        b::Element(e::Required,    "Other Payer Primary Identifier"),
                        b::Element(e::NotUsed,     "Reference Identification Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identification"),
                        b::Element(e::NotUsed,     "Reference Identification Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identification"))),
                    b::Segment(5300, s::PER, "Ordering Provider Contact Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                      b::Element(e::Situational, "Ordering Provider Contact Name"),
                      b::Element(e::Required,    "Communication Number Qualifier", b::Values("EM", "FX", "TE")),
                      b::Element(e::Required,    "Communication Number"),
                      b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                      b::Element(e::Situational, "Communication Number"),
                      b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                      b::Element(e::Situational, "Communication Number"),
                      b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

                  d::LoopDef.build("2420F REFERRING PROVIDER NAME", d::RepeatCount.bounded(2),
                    b::Segment(5000, s::NM1, "Referring Provider Name", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("DN", "P3")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                      b::Element(e::Required,    "Referring Provider Last"),
                      b::Element(e::Situational, "Referring Provider First"),
                      b::Element(e::Situational, "Referring Provider Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::Situational, "Referring Provider Suffix"),
                      b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                      b::Element(e::Situational, "Referring Provider 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(5250, s::REF, "Referring Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(20),
                      b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G", "G2")),
                      b::Element(e::Required,    "Referring Provider Secondary Identifier"),
                      b::Element(e::NotUsed,     "Description"),
                      b::Element(e::Situational, "REFERENCE IDENTIFIER",
                        b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U")),
                        b::Element(e::Required,    "Other Payer Primary Identifier"),
                        b::Element(e::NotUsed,     "Reference Identification Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identification"),
                        b::Element(e::NotUsed,     "Reference Identification Qualifier"),
                        b::Element(e::NotUsed,     "Reference Identification")))),

                  d::LoopDef.build("2420G AMBULANCE PICK-UP LOCATION", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Ambulance Pick-up Location", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("PW")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                      b::Element(e::NotUsed,     "Name Last"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::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(5140, s::N3, "Ambulance Pick-up Location Address", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Ambulance Pick-up Address Line"),
                      b::Element(e::Situational, "Ambulance Pick-up Address Line")),
                    b::Segment(5200, s::N4, "Ambulance Pick-up Location City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Ambulance Pick-up City Name"),
                      b::Element(e::Situational, "Ambulance Pick-up State or Province Code"),
                      b::Element(e::Situational, "Ambulance Pick-up 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"))),

                  d::LoopDef.build("2420H AMBULANCE DROP-OFF LOCATION", d::RepeatCount.bounded(1),
                    b::Segment(5000, s::NM1, "Ambulance Drop-off Location", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Entity Identifier Code", b::Values("45")),
                      b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                      b::Element(e::Situational, "Ambulance Drop-off Location"),
                      b::Element(e::NotUsed,     "Name First"),
                      b::Element(e::NotUsed,     "Name Middle"),
                      b::Element(e::NotUsed,     "Name Prefix"),
                      b::Element(e::NotUsed,     "Name Suffix"),
                      b::Element(e::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(5140, s::N3, "Ambulance Drop-off Location Address", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Ambulance Drop-off Address Line"),
                      b::Element(e::Situational, "Ambulance Drop-off Address Line")),
                    b::Segment(5200, s::N4, "Ambulance Drop-off Location City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Ambulance Drop-off City Name"),
                      b::Element(e::Situational, "Ambulance Drop-off State or Province Code"),
                      b::Element(e::Situational, "Ambulance Drop-off 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"))),

                  d::LoopDef.build("2430 LINE ADJUDICATION INFORMATION", d::RepeatCount.bounded(15),
                    b::Segment(5400, s::SVD, "Line Adjudication Information", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Other Payer Primary Identifier"),
                      b::Element(e::Required,    "Service Line Paid Amount"),
                      b::Element(e::Required,    "COMPOSITE MEDICAL PROCEDURE IDENTIFIER",
                        b::Element(e::Required,    "Product or Service ID Qualifier", b::Values("ER", "HC", "IV", "WK")),
                        b::Element(e::Required,    "Procedure Code"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Modifier"),
                        b::Element(e::Situational, "Procedure Code Description"),
                        b::Element(e::NotUsed,     "Product/Service ID")),
                      b::Element(e::NotUsed,     "Product/Service ID"),
                      b::Element(e::Required,    "Paid Service Unit Count", b::MaxLength(8), b::MaxPrecision(3)),
                      b::Element(e::Situational, "Bundled or Unbundled Line Number")),
                    b::Segment(5450, s::CAS, "Line Adjustment", r::Situational, d::RepeatCount.bounded(5),
                      b::Element(e::Required,    "Claim Adjustment Group Code", b::Values("CO", "CR", "OA", "PI", "PR")),
                      b::Element(e::Required,    "Adjustment Reason Code"),
                      b::Element(e::Required,    "Adjustment Amount"),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount"),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount"),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount"),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount"),
                      b::Element(e::Situational, "Adjustment Quantity"),
                      b::Element(e::Situational, "Adjustment Reason Code"),
                      b::Element(e::Situational, "Adjustment Amount"),
                      b::Element(e::Situational, "Adjustment Quantity")),
                    b::Segment(5500, s::DTP, "Line Check or Remittance Date", r::Required, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Date Time Qualifier", b::Values("573")),
                      b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                      b::Element(e::Required,    "Adjudication or Payment Date")),
                    b::Segment(5505, s::AMT, "Remaining Patient Liability", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Amount Qualifier Code"),
                      b::Element(e::Required,    "Remaining Patient Liability"),
                      b::Element(e::NotUsed,     "Credit/Debit Flag Code"))),

                  d::LoopDef.build("2440 FORM IDENTIFICATION CODE", d::RepeatCount.unbounded,
                    b::Segment(5510, s::LQ, "Form Identification Code", r::Situational, d::RepeatCount.bounded(1),
                      b::Element(e::Required,    "Code List Qualifier Code", b::Values("AS", "UT")),
                      b::Element(e::Required,    "Form Identifier")),
                    b::Segment(5520, s::FRM, "Supporting Documentation", r::Required, d::RepeatCount.bounded(99),
                      b::Element(e::Required,    "Question Number/Letter"),
                      b::Element(e::Situational, "Question Response", b::Values("N", "W", "Y")),
                      b::Element(e::Situational, "Question Response"),
                      b::Element(e::Situational, "Question Response"),
                      b::Element(e::Situational, "Question Response")))))

          HC837 = b.build("HC", "837", "",
            d::TableDef.header("1 - Header",
              b::Segment(50, s::ST, "Transaction Set Header", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Transaction Set Identifier Code", b::Values("837")),
                b::Element(e::Required,    "Transaction Set Control Number"),
                b::Element(e::Required,    "Implementation Guide Version Name", b::Values("005010X222A1"))),
              b::Segment(100, s::BHT, "Beginning of Hierarchical Transaction", r::Required, d::RepeatCount.bounded(1),
                b::Element(e::Required,    "Hierarchical Structure Code", b::Values("0019")),
                b::Element(e::Required,    "Transaction Set Purpose Code", b::Values("00", "18")),
                b::Element(e::Required,    "Originator Application Transaction Identifier", b::MaxLength(30)),
                b::Element(e::Required,    "Transaction Set Creation Date"),
                b::Element(e::Required,    "Transaction Set Creation Time"),
                b::Element(e::Required,    "Claim or Encounter Identifier", b::Values("31", "CH", "RP"))),

              d::LoopDef.build("1000A SUBMITTER NAME", d::RepeatCount.bounded(1),
                b::Segment(200, s::NM1, "Submitter Name", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Entity Identifier Code", b::Values("41")),
                  b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                  b::Element(e::Required,    "Submitter Last or Organization Name"),
                  b::Element(e::Situational, "Submitter First Name"),
                  b::Element(e::Situational, "Submitter Middle Name or Initial"),
                  b::Element(e::NotUsed,     "Name Prefix"),
                  b::Element(e::NotUsed,     "Name Suffix"),
                  b::Element(e::Required,    "Identification Qualifier Code", b::Values("46")),
                  b::Element(e::Required,    "Submitter 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(450, s::PER, "Submitter EDI Contact Information", r::Required, d::RepeatCount.bounded(2),
                  b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                  b::Element(e::Situational, "Submitter Contact Name"),
                  b::Element(e::Required,    "Communication Number Qualifier", b::Values("EM", "FX", "TE")),
                  b::Element(e::Required,    "Communication Number"),
                  b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                  b::Element(e::Situational, "Communication Number"),
                  b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                  b::Element(e::Situational, "Communication Number"),
                  b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

              d::LoopDef.build("1000B RECEIVER NAME", d::RepeatCount.bounded(1),
                b::Segment(200, s::NM1, "Receiver Name", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Entity Identifier Code", b::Values("40")),
                  b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                  b::Element(e::Required,    "Receiver Name"),
                  b::Element(e::NotUsed,     "Name First"),
                  b::Element(e::NotUsed,     "Name Last"),
                  b::Element(e::NotUsed,     "Name Prefix"),
                  b::Element(e::NotUsed,     "Name Suffix"),
                  b::Element(e::Required,    "Identification Code Qualifier", b::Values("46")),
                  b::Element(e::Required,    "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")))),

            d::TableDef.detail("2 - Billing Provider Detail",
              d::LoopDef.build("2000A BILLING PROVIDER HIERARCHICAL LEVEL", d::RepeatCount.unbounded,
                b::Segment(10, s::HL, "Billing Provider Hierarchical 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,    "Hierachical Child Code")),
                b::Segment(30, s::PRV, "Billing Provider Specialty Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Provider Code", b::Values("BI")),
                  b::Element(e::Required,    "Reference Identification Number", b::Values("PXC")),
                  b::Element(e::Required,    "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(100, s::CUR, "Foreign Currency Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Entity Identifier Code", b::Values("85")),
                  b::Element(e::Required,    "Currency Code"),
                  b::Element(e::NotUsed,     "Exchange Rate"),
                  b::Element(e::NotUsed,     "Entity Identifier Code"),
                  b::Element(e::NotUsed,     "Currency Code"),
                  b::Element(e::NotUsed,     "Currency Market/Exchange Code"),
                  b::Element(e::NotUsed,     "Date/Time Qualifier"),
                  b::Element(e::NotUsed,     "Date"),
                  b::Element(e::NotUsed,     "Time"),
                  b::Element(e::NotUsed,     "Date/Time Qualifier"),
                  b::Element(e::NotUsed,     "Date"),
                  b::Element(e::NotUsed,     "Time"),
                  b::Element(e::NotUsed,     "Date/Time Qualifier"),
                  b::Element(e::NotUsed,     "Date"),
                  b::Element(e::NotUsed,     "Time"),
                  b::Element(e::NotUsed,     "Date/Time Qualifier"),
                  b::Element(e::NotUsed,     "Date"),
                  b::Element(e::NotUsed,     "Time"),
                  b::Element(e::NotUsed,     "Date/Time Qualifier"),
                  b::Element(e::NotUsed,     "Date"),
                  b::Element(e::NotUsed,     "Time")),

                d::LoopDef.build("2010AA BILLING PROVIDER NAME", d::RepeatCount.bounded(1),
                  b::Segment(150, s::NM1, "Billing Provider Name", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("85")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::Required,    "Billing Provider Last or Organizational Name"),
                    b::Element(e::Situational, "Billing Provider First Name"),
                    b::Element(e::Situational, "Billing Provider Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Billing Provider Name Suffix"),
                    b::Element(e::Situational, "Identification Code Qualifier", b::Values("XX")),
                    b::Element(e::Situational, "Billing Provider 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(250, s::N3, "Billing Provider Address", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Billing Provider Address Line"),
                    b::Element(e::Situational, "Billing Provider Address Line")),
                  b::Segment(300, s::N4, "Billing Provider City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Billing Provider City Name"),
                    b::Element(e::Situational, "Billing Provider State or Province Code"),
                    b::Element(e::Situational, "Billing Provider 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(350, s::REF, "Billing Provider Tax Identification", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("EI", "SY")),
                    b::Element(e::Required,    "Billing Provider Tax Identification Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(350, s::REF, "Billing Provider UPIN/License Information", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("0B", "1G")),
                    b::Element(e::Required,    "Billing Provider License and/or UPIN Information"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(400, s::PER, "Billing Provider Contact Information", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                    b::Element(e::Situational, "Billing Provider Contact Name"),
                    b::Element(e::Required,    "Communication Number Qualifier", b::Values("EM", "FX", "TE")),
                    b::Element(e::Required,    "Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EM", "EX", "FX", "TE")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

                d::LoopDef.build("2010AB PAY-TO ADDRESS NAME", d::RepeatCount.bounded(1),
                  b::Segment(150, s::NM1, "Pay-to Address Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("87")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1", "2")),
                    b::Element(e::NotUsed,     "Name Last or Organizational Name"),
                    b::Element(e::NotUsed,     "Name First"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::NotUsed,     "Identification Code Qualifier"),
                    b::Element(e::NotUsed,     "Identifier 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(250, s::N3, "Pay-to Address - ADDRESS", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Pay-To Address Line"),
                    b::Element(e::Situational, "Pay-To Address Line")),
                  b::Segment(300, s::N4, "Pay-To Address City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Pay-to City Name"),
                    b::Element(e::Situational, "Pay-to State or Province Code"),
                    b::Element(e::Situational, "Pay-to 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"))),

                d::LoopDef.build("2010AC PAY-TO PLAN NAME", d::RepeatCount.bounded(1),
                  b::Segment(150, s::NM1, "Pay-To Plan Name", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("PE")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                    b::Element(e::Required,    "Pay-To Plan Organizational Name"),
                    b::Element(e::NotUsed,     "Name First"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("PI", "XV")),
                    b::Element(e::Required,    "Pay-To Plan 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(250, s::N3, "Pay-to Plan Address", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Pay-To Plan Address Line"),
                    b::Element(e::Situational, "Pay-To Plan Address Line")),
                  b::Segment(300, s::N4, "Pay-To Plan City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Pay-to Plan City Name"),
                    b::Element(e::Situational, "Pay-to Plan State or Province Code"),
                    b::Element(e::Situational, "Pay-to Plan 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(350, s::REF, "Pay-to Plan Secondary Identification", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U", "FY", "NF")),
                    b::Element(e::Required,    "Pay-to Plan Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(350, s::REF, "Pay-to Plan Tax Identification Number", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("EI")),
                    b::Element(e::Required,    "Pay-to Plan Tax Identification Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))))),

            d::TableDef.detail("2 - Subscriber Detail",
              d::LoopDef.build("2000B SUBSCRIBER HIERARCHICAL LEVEL", d::RepeatCount.unbounded,
                b::Segment(10, s::HL, "Subscriber Hierarchical 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,    "Hierachical Child values", b::Values("0", "1"))),
                b::Segment(50, s::SBR, "Subscriber Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Payer Responsibility Sequence Number", b::Values("A", "B", "C", "D", "E", "F", "G", "H", "P", "S", "T", "U")),
                  b::Element(e::Situational, "Individual Relationship Code", b::Values("18")),
                  b::Element(e::Situational, "Subscriber Group or Policy Number"),
                  b::Element(e::Situational, "Subscriber Group Name"),
                  b::Element(e::Situational, "Insurance Type Code", b::Values("12", "13", "14", "15", "16", "41", "42", "43", "47")),
                  b::Element(e::NotUsed,     "Coordination of Benefits Code"),
                  b::Element(e::NotUsed,     "Yes/No Condition or Response Code"),
                  b::Element(e::NotUsed,     "Employment Status Code"),
                  b::Element(e::Situational, "Claim Filing Indicator Code", b::Values("11", "12", "13", "14", "15", "16", "17", "AM", "BL", "CH", "CI", "DS", "FI", "HM", "LM", "MA", "MB", "MC", "OF", "TV", "VA", "WC", "ZZ"))),
                b::Segment(70, s::PAT, "Patient Information", r::Situational, d::RepeatCount.bounded(1),
                  b::Element(e::NotUsed,     "Individual Relationship Code"),
                  b::Element(e::NotUsed,     "Patient Location Code"),
                  b::Element(e::NotUsed,     "Employment Status Code"),
                  b::Element(e::NotUsed,     "Student Status Code"),
                  b::Element(e::Situational, "Date Time Period Format Qualifier", b::Values("D8")),
                  b::Element(e::Situational, "Patient Death Date"),
                  b::Element(e::Situational, "Unit or Basis for Measurement Code", b::Values("01")),
                  b::Element(e::Situational, "Patient Weight"),
                  b::Element(e::Situational, "Pregnancy Indicator", b::Values("Y"))),

                d::LoopDef.build("2010BA SUBSCRIBER NAME", d::RepeatCount.bounded(1),
                  b::Segment(150, 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(250, 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(300, 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(320, s::DMG, "Subscriber Demographic Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Subscriber Birth Date"),
                    b::Element(e::Required,    "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(350, s::REF, "Subscriber Secondary Identification", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("SY")),
                    b::Element(e::Required,    "Subscriber Supplemental Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(350, s::REF, "Property and Casualty Claim Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("Y4")),
                    b::Element(e::Required,    "Property Casualty Claim Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(400, s::PER, "Property and Casualty Subscriber Contact Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Contact Fuction Code", b::Values("IC")),
                    b::Element(e::Situational, "Name"),
                    b::Element(e::Required,    "Communication Qualifier Number", b::Values("TE")),
                    b::Element(e::Required,    "Communication Number"),
                    b::Element(e::Situational, "Communication Qualifier Number", b::Values("TE", "EX")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::NotUsed,     "Communication Qualifier Number"),
                    b::Element(e::NotUsed,     "Communication Number"),
                    b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

                d::LoopDef.build("2010BB PAYER NAME", d::RepeatCount.bounded(10),
                  b::Segment(150, s::NM1, "Payer Name", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Identifier Code", b::Values("PR")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("2")),
                    b::Element(e::Required,    "Payer Name"),
                    b::Element(e::NotUsed,     "Name Last"),
                    b::Element(e::NotUsed,     "Name Middle"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::NotUsed,     "Name Suffix"),
                    b::Element(e::Required,    "Identification Code Qualifier", b::Values("PI", "XV")),
                    b::Element(e::Required,    "Payer Identification"),
                    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(250, s::N3, "Payer Address", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Payer Address Line"),
                    b::Element(e::Situational, "Payer Address Line")),
                  b::Segment(300, s::N4, "Payer City, State, ZIP Code", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Payer City Name"),
                    b::Element(e::Situational, "Payer State or Province Code"),
                    b::Element(e::Situational, "Payer 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(350, s::REF, "Payer Secondary Identification", r::Situational, d::RepeatCount.bounded(3),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("2U", "EI", "FY", "NF")),
                    b::Element(e::Required,    "Payer Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(350, s::REF, "Billing Provider Secondary Identification", r::Situational, d::RepeatCount.bounded(2),
                    b::Element(e::Required,    "Reference Identification Qualifier", b::Values("G2", "LU")),
                    b::Element(e::Required,    "Billing Provider Secondary Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER"))),

                loop2300)),

            d::TableDef.detail("2 - Patient Detail",
              d::LoopDef.build("2000C PATIENT HIERARCHICAL LEVEL", d::RepeatCount.unbounded,
                b::Segment(10, s::HL, "Patient Hierachical 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(70, s::PAT, "Patient Information", r::Required, d::RepeatCount.bounded(1),
                  b::Element(e::Required,    "Individual Relationship Code", b::Values("01", "19", "20", "21", "39", "40", "53", "G8")),
                  b::Element(e::NotUsed,     "Patient Location Code"),
                  b::Element(e::NotUsed,     "Employment Status Code"),
                  b::Element(e::NotUsed,     "Student Status Code"),
                  b::Element(e::Situational, "Date Time Period Format Qualifier"),
                  b::Element(e::Situational, "Patient Death Date"),
                  b::Element(e::Situational, "Unit Basis for Measurement Code", b::Values("01")),
                  b::Element(e::Situational, "Patient Weight"),
                  b::Element(e::Situational, "Pregnancy Indicator", b::Values("Y"))),

                d::LoopDef.build("2010CA PATIENT NAME", d::RepeatCount.bounded(1),
                  b::Segment(150, s::NM1, "Patient Name", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Entity Qualifier Code", b::Values("QC")),
                    b::Element(e::Required,    "Entity Type Qualifier", b::Values("1")),
                    b::Element(e::Required,    "Patient Last Name"),
                    b::Element(e::Situational, "Patient First Name"),
                    b::Element(e::Situational, "Patient Middle Name or Initial"),
                    b::Element(e::NotUsed,     "Name Prefix"),
                    b::Element(e::Situational, "Patient Name Suffix"),
                    b::Element(e::NotUsed,     "Identification Code Qualifier"),
                    b::Element(e::NotUsed,     "Identification Code"),
                    b::Element(e::NotUsed,     "Entity Relationship Code"),
                    b::Element(e::NotUsed,     "Entity Identification Code"),
                    b::Element(e::NotUsed,     "Name Last or Organization Name")),
                  b::Segment(250, s::N3, "Patient Address", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Patient Address Line"),
                    b::Element(e::Situational, "Patient Address Line")),
                  b::Segment(300, s::N4, "Patient City, State, ZIP Code", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Patient City Name"),
                    b::Element(e::Situational, "Patient State Code"),
                    b::Element(e::Situational, "Patient 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(320, s::DMG, "Patient Demographic Information", r::Required, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Date Time Period Format Qualifier", b::Values("D8")),
                    b::Element(e::Required,    "Patient Birth Date"),
                    b::Element(e::Required,    "Patient 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(350, s::REF, "Property and Casualty Claim Number", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identifier Qualifier", b::Values("Y4")),
                    b::Element(e::Required,    "Property Casualty Claim Number"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(350, s::REF, "Property and Casualty Patient Identifier", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Reference Identifier Qualifier", b::Values("1W", "SY")),
                    b::Element(e::Required,    "Property Casualty Patient Identifier"),
                    b::Element(e::NotUsed,     "Description"),
                    b::Element(e::NotUsed,     "REFERENCE IDENTIFIER")),
                  b::Segment(400, s::PER, "Property and Casualty Patient Contact Information", r::Situational, d::RepeatCount.bounded(1),
                    b::Element(e::Required,    "Contact Function Code", b::Values("IC")),
                    b::Element(e::Situational, "Name"),
                    b::Element(e::Required,    "Communication Number Qualifier", b::Values("TE")),
                    b::Element(e::Required,    "Communication Number"),
                    b::Element(e::Situational, "Communication Number Qualifier", b::Values("EX")),
                    b::Element(e::Situational, "Communication Number"),
                    b::Element(e::NotUsed,     "Communication Number Qualifier"),
                    b::Element(e::NotUsed,     "Communication Number"),
                    b::Element(e::NotUsed,     "Contact Inquiry Reference"))),

                loop2300)),

            # 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
