# #Eligibility
#
# Reference for developers
#
# OpenAPI spec version: v3
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
# Swagger Codegen version: 2.4.17
#

require 'date'

module ChangeHealthcare
  module Eligibility
    module SwaggerClient
      class Loop2000CD2100CDSegmentNM1REFDMGINSMPIPRVNotesResponseMember
        # Loop: 2000[C|D]/2100[C|D], Segment: N3 and N4 Element: INS04, Notes: Maintenance Reason Code
        attr_accessor :address

        # Loop: 2000[C|D]/2100[C|D], Segment: INS, Element: INS17, Notes: Birth Sequence Number Use to indicate the birth order in the event of multiple births in association with the birth date supplied in DMG02
        attr_accessor :birth_sequence_number

        # Loop: 2000[C|D]/2100[C|D], Segment: DMG, Element: DMG02, Notes: Date of Birth
        attr_accessor :date_of_birth

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI07, Notes: MPI106=D8 Date Time Period
        attr_accessor :date_time_period

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI06, Notes: Date Time Period Format Qualifier
        attr_accessor :date_time_period_format_qualifier

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI04, Notes: Description
        attr_accessor :description

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI02, Notes: Employment Status Code
        attr_accessor :employment_status_code

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI08, Notes: MPI106=RD8 Date Time Period
        attr_accessor :end_date_time_period

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM101, Notes: entityIdentifier
        attr_accessor :entity_identifier

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM102, Notes: entityType
        attr_accessor :entity_type

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM104, Notes: First Name
        attr_accessor :first_name

        # Loop: 2000[C|D]/2100[C|D], Segment: DMG, Element: DMG03, Notes: gender
        attr_accessor :gender

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI03, Notes: Government Service Affiliation Code
        attr_accessor :government_service_affiliation_code

        # Loop: 2000[C|D]/2100[C|D], Segment: REF, Element: REF02, Notes: REF01=6P Group Number
        attr_accessor :group_number

        attr_accessor :health_care_diagnosis_codes

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI01, Notes: Information Status Code
        attr_accessor :information_status_code

        # Loop: 2000[C|D]/2100[C|D], Segment: INS, Element: INS01, Notes: Insured Indicator
        attr_accessor :insured_indicator

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM103, Notes: Last Name
        attr_accessor :last_name

        # Loop: 2000[C|D]/2100[C|D], Segment: INS, Element: INS04, Notes: Maintenance Reason Code
        attr_accessor :maintenance_reason_code

        # Loop: 2000[C|D]/2100[C|D], Segment: INS, Element: INS03, Notes: Maintenance Type Code
        attr_accessor :maintenance_type_code

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM109, Notes: NM108=MI Member Identification Number
        attr_accessor :member_id

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1 Element: NM105, Notes: Middle Name
        attr_accessor :middle_name

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI05, Notes: Military Service Rank Code
        attr_accessor :military_service_rank_code

        # Loop: 2000[C|D]/2100[C|D], Segment: REF, Element: REF02, Notes: REF01=18 Plan Number
        attr_accessor :plan_number

        # Loop: 2000[C|D]/2100[C|D], Segment: PRV, Notes: Provider Information
        attr_accessor :provider

        # Loop: 2000[C|D]/2100[C|D], Segment: INS, Element: INS02, Notes: Individual Relationship Code
        attr_accessor :relation_to_subscriber

        # Loop: 2000[C|D]/2100[C|D], Segment: INS, Element: INS02, Notes: Individual Relationship Code
        attr_accessor :relation_to_subscriber_code

        # Loop: 2000[C|D]/2100[C|D], Segment: REF, Element: REF02, Notes: REF01=SY Social Security Number
        attr_accessor :ssn

        # Loop: 2000[C|D]/2100[C|D], Segment: MPI, Element: MPI08, Notes: MPI106=RD8 Date Time Period
        attr_accessor :start_date_time_period

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM107, Notes: suffix
        attr_accessor :suffix

        # Loop: 2000[C|D]/2100[C|D], Segment: NM1, Element: NM109, Notes: NM108=II uniqueHealthIdentifier
        attr_accessor :unique_health_identifier

        # Attribute mapping from ruby-style variable name to JSON key.
        def self.attribute_map
          {
            'address': :address,
            'birth_sequence_number': :birthSequenceNumber,
            'date_of_birth': :dateOfBirth,
            'date_time_period': :dateTimePeriod,
            'date_time_period_format_qualifier': :dateTimePeriodFormatQualifier,
            'description': :description,
            'employment_status_code': :employmentStatusCode,
            'end_date_time_period': :endDateTimePeriod,
            'entity_identifier': :entityIdentifier,
            'entity_type': :entityType,
            'first_name': :firstName,
            'gender': :gender,
            'government_service_affiliation_code': :governmentServiceAffiliationCode,
            'group_number': :groupNumber,
            'health_care_diagnosis_codes': :healthCareDiagnosisCodes,
            'information_status_code': :informationStatusCode,
            'insured_indicator': :insuredIndicator,
            'last_name': :lastName,
            'maintenance_reason_code': :maintenanceReasonCode,
            'maintenance_type_code': :maintenanceTypeCode,
            'member_id': :memberId,
            'middle_name': :middleName,
            'military_service_rank_code': :militaryServiceRankCode,
            'plan_number': :planNumber,
            'provider': :provider,
            'relation_to_subscriber': :relationToSubscriber,
            'relation_to_subscriber_code': :relationToSubscriberCode,
            'ssn': :ssn,
            'start_date_time_period': :startDateTimePeriod,
            'suffix': :suffix,
            'unique_health_identifier': :uniqueHealthIdentifier
          }
        end

        # Attribute type mapping.
        def self.swagger_types
          {
            'address': :Address,
            'birth_sequence_number': :String,
            'date_of_birth': :Date,
            'date_time_period': :String,
            'date_time_period_format_qualifier': :String,
            'description': :String,
            'employment_status_code': :String,
            'end_date_time_period': :String,
            'entity_identifier': :String,
            'entity_type': :String,
            'first_name': :String,
            'gender': :String,
            'government_service_affiliation_code': :String,
            'group_number': :String,
            'health_care_diagnosis_codes': :'Array<HealthCareDiagnosisCode>',
            'information_status_code': :String,
            'insured_indicator': :String,
            'last_name': :String,
            'maintenance_reason_code': :String,
            'maintenance_type_code': :String,
            'member_id': :String,
            'middle_name': :String,
            'military_service_rank_code': :String,
            'plan_number': :String,
            'provider': :Loop2100BCDSegmentNM1PRVNotesProvider,
            'relation_to_subscriber': :String,
            'relation_to_subscriber_code': :String,
            'ssn': :String,
            'start_date_time_period': :String,
            'suffix': :String,
            'unique_health_identifier': :String
          }
        end

        # Initializes the object
        # @param [Hash] attributes Model attributes in the form of hash
        def initialize(attributes = {})
          return unless attributes.is_a?(Hash)

          # convert string to symbol for hash key
          attributes = attributes.transform_keys(&:to_sym)

          self.address = attributes[:address] if attributes.key?(:address)

          self.birth_sequence_number = attributes[:birthSequenceNumber] if attributes.key?(:birthSequenceNumber)

          self.date_of_birth = attributes[:dateOfBirth] if attributes.key?(:dateOfBirth)

          self.date_time_period = attributes[:dateTimePeriod] if attributes.key?(:dateTimePeriod)

          self.date_time_period_format_qualifier = attributes[:dateTimePeriodFormatQualifier] if attributes.key?(:dateTimePeriodFormatQualifier)

          self.description = attributes[:description] if attributes.key?(:description)

          self.employment_status_code = attributes[:employmentStatusCode] if attributes.key?(:employmentStatusCode)

          self.end_date_time_period = attributes[:endDateTimePeriod] if attributes.key?(:endDateTimePeriod)

          self.entity_identifier = attributes[:entityIdentifier] if attributes.key?(:entityIdentifier)

          self.entity_type = attributes[:entityType] if attributes.key?(:entityType)

          self.first_name = attributes[:firstName] if attributes.key?(:firstName)

          self.gender = attributes[:gender] if attributes.key?(:gender)

          self.government_service_affiliation_code = attributes[:governmentServiceAffiliationCode] if attributes.key?(:governmentServiceAffiliationCode)

          self.group_number = attributes[:groupNumber] if attributes.key?(:groupNumber)

          if attributes.key?(:healthCareDiagnosisCodes)
            if (value = attributes[:healthCareDiagnosisCodes]).is_a?(Array)
              self.health_care_diagnosis_codes = value
            end
          end

          self.information_status_code = attributes[:informationStatusCode] if attributes.key?(:informationStatusCode)

          self.insured_indicator = attributes[:insuredIndicator] if attributes.key?(:insuredIndicator)

          self.last_name = attributes[:lastName] if attributes.key?(:lastName)

          self.maintenance_reason_code = attributes[:maintenanceReasonCode] if attributes.key?(:maintenanceReasonCode)

          self.maintenance_type_code = attributes[:maintenanceTypeCode] if attributes.key?(:maintenanceTypeCode)

          self.member_id = attributes[:memberId] if attributes.key?(:memberId)

          self.middle_name = attributes[:middleName] if attributes.key?(:middleName)

          self.military_service_rank_code = attributes[:militaryServiceRankCode] if attributes.key?(:militaryServiceRankCode)

          self.plan_number = attributes[:planNumber] if attributes.key?(:planNumber)

          self.provider = attributes[:provider] if attributes.key?(:provider)

          self.relation_to_subscriber = attributes[:relationToSubscriber] if attributes.key?(:relationToSubscriber)

          self.relation_to_subscriber_code = attributes[:relationToSubscriberCode] if attributes.key?(:relationToSubscriberCode)

          self.ssn = attributes[:ssn] if attributes.key?(:ssn)

          self.start_date_time_period = attributes[:startDateTimePeriod] if attributes.key?(:startDateTimePeriod)

          self.suffix = attributes[:suffix] if attributes.key?(:suffix)

          self.unique_health_identifier = attributes[:uniqueHealthIdentifier] if attributes.key?(:uniqueHealthIdentifier)
        end

        # Show invalid properties with the reasons. Usually used together with valid?
        # @return Array for valid properties with the reasons
        def list_invalid_properties
          []
        end

        # Check to see if the all the properties in the model are valid
        # @return true if the model is valid
        def valid?
          true
        end

        # Checks equality by comparing each attribute.
        # @param [Object] Object to be compared
        def ==(o)
          return true if equal?(o)

          self.class == o.class &&
            address == o.address &&
            birth_sequence_number == o.birth_sequence_number &&
            date_of_birth == o.date_of_birth &&
            date_time_period == o.date_time_period &&
            date_time_period_format_qualifier == o.date_time_period_format_qualifier &&
            description == o.description &&
            employment_status_code == o.employment_status_code &&
            end_date_time_period == o.end_date_time_period &&
            entity_identifier == o.entity_identifier &&
            entity_type == o.entity_type &&
            first_name == o.first_name &&
            gender == o.gender &&
            government_service_affiliation_code == o.government_service_affiliation_code &&
            group_number == o.group_number &&
            health_care_diagnosis_codes == o.health_care_diagnosis_codes &&
            information_status_code == o.information_status_code &&
            insured_indicator == o.insured_indicator &&
            last_name == o.last_name &&
            maintenance_reason_code == o.maintenance_reason_code &&
            maintenance_type_code == o.maintenance_type_code &&
            member_id == o.member_id &&
            middle_name == o.middle_name &&
            military_service_rank_code == o.military_service_rank_code &&
            plan_number == o.plan_number &&
            provider == o.provider &&
            relation_to_subscriber == o.relation_to_subscriber &&
            relation_to_subscriber_code == o.relation_to_subscriber_code &&
            ssn == o.ssn &&
            start_date_time_period == o.start_date_time_period &&
            suffix == o.suffix &&
            unique_health_identifier == o.unique_health_identifier
        end

        # @see the `==` method
        # @param [Object] Object to be compared
        def eql?(o)
          self == o
        end

        # Calculates hash code according to all attributes.
        # @return [Fixnum] Hash code
        def hash
          [address, birth_sequence_number, date_of_birth, date_time_period, date_time_period_format_qualifier, description, employment_status_code, end_date_time_period, entity_identifier, entity_type, first_name, gender, government_service_affiliation_code, group_number, health_care_diagnosis_codes, information_status_code, insured_indicator, last_name, maintenance_reason_code, maintenance_type_code, member_id, middle_name, military_service_rank_code, plan_number, provider, relation_to_subscriber, relation_to_subscriber_code, ssn, start_date_time_period, suffix, unique_health_identifier].hash
        end

        # Builds the object from hash
        # @param [Hash] attributes Model attributes in the form of hash
        # @return [Object] Returns the model itself
        def build_from_hash(attributes)
          return nil unless attributes.is_a?(Hash)

          self.class.swagger_types.each_pair do |key, type|
            if type =~ /\AArray<(.*)>/i
              # check to ensure the input is an array given that the attribute
              # is documented as an array but the input is not
              if attributes[self.class.attribute_map[key]].is_a?(Array)
                send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
              end
            elsif !attributes[self.class.attribute_map[key]].nil?
              send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
            end # or else data not found in attributes(hash), not an issue as the data can be optional
          end

          self
        end

        # Deserializes the data based on type
        # @param string type Data type
        # @param string value Value to be deserialized
        # @return [Object] Deserialized data
        def _deserialize(type, value)
          case type.to_sym
          when :DateTime
            DateTime.parse(value)
          when :Date
            Date.parse(value)
          when :String
            value.to_s
          when :Integer
            value.to_i
          when :Float
            value.to_f
          when :BOOLEAN
            if value.to_s =~ /\A(true|t|yes|y|1)\z/i
              true
            else
              false
            end
          when :Object
            # generic object (usually a Hash), return directly
            value
          when /\AArray<(?<inner_type>.+)>\z/
            inner_type = Regexp.last_match[:inner_type]
            value.map { |v| _deserialize(inner_type, v) }
          when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
            k_type = Regexp.last_match[:k_type]
            v_type = Regexp.last_match[:v_type]
            {}.tap do |hash|
              value.each do |k, v|
                hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
              end
            end
          else # model
            temp_model = SwaggerClient.const_get(type).new
            temp_model.build_from_hash(value)
          end
        end

        # Returns the string representation of the object
        # @return [String] String presentation of the object
        def to_s
          to_hash.to_s
        end

        # to_body is an alias to to_hash (backward compatibility)
        # @return [Hash] Returns the object in the form of hash
        def to_body
          to_hash
        end

        # Returns the object in the form of hash
        # @return [Hash] Returns the object in the form of hash
        def to_hash
          hash = {}
          self.class.attribute_map.each_pair do |attr, param|
            value = send(attr)
            next if value.nil?

            hash[param] = _to_hash(value)
          end
          hash
        end

        # Outputs non-array value in the form of hash
        # For object, use to_hash. Otherwise, just return the value
        # @param [Object] value Any valid value
        # @return [Hash] Returns the value in the form of hash
        def _to_hash(value)
          if value.is_a?(Array)
            value.compact.map { |v| _to_hash(v) }
          elsif value.is_a?(Hash)
            {}.tap do |hash|
              value.each { |k, v| hash[k] = _to_hash(v) }
            end
          elsif value.respond_to? :to_hash
            value.to_hash
          else
            value
          end
        end
      end
    end
  end
end