Sha256: 90876f816083cc91572f675a67ad44bae396e1866c90fbc7384ce03c5eae4395

Contents?: true

Size: 1.36 KB

Versions: 41

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Inferno
  class TerminologyConfiguration
    class << self
      def config
        @config =
          if File.file? File.join('config', 'terminology_config.yml')
            YAML.load_file(File.join('config', 'terminology_config.yml')).presence || {}
          else
            {}
          end
      end

      def allowed_systems_metadata
        @allowed_systems_metadata ||=
          Terminology.code_system_metadata
            .select { |url, _metadata| system_allowed?(url) }
      end

      def prohibited_systems
        @prohibited_systems ||=
          Terminology.code_system_metadata
            .reject { |url, _metadata| system_allowed?(url) }
            .keys
      end

      def prohibited_license_restriction_levels
        config[:exclude_license_restriction_levels] || []
      end

      def explicitly_allowed_systems
        config[:include] || []
      end

      def explicitly_prohibited_systems
        config[:exclude] || []
      end

      def system_allowed?(url)
        return true if explicitly_allowed_systems.include?(url)
        return false if explicitly_prohibited_systems.include?(url)

        !prohibited_license_restriction_levels.include?(Terminology.code_system_metadata.dig(url, :restriction_level))
      end

      def system_prohibited?(url)
        !system_allowed?(url)
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
onc_certification_g10_test_kit-7.0.1 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-7.0.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-6.0.3 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-6.0.2 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-6.0.1 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-6.0.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-5.4.2 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-5.4.1 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-5.3.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-5.2.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-5.1.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-5.0.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-4.1.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-4.0.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-3.8.1 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-3.8.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-3.7.2 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-3.7.1 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-3.7.0 lib/inferno/terminology/terminology_configuration.rb
onc_certification_g10_test_kit-3.6.0 lib/inferno/terminology/terminology_configuration.rb