<commit_before>module Crucible
  module Tests
    class ArgonautProviderConnectathonTest < BaseSuite
      def id
        'ArgonautProviderConnectathonTest'
      end

      def description
        'Test suite for the Argonaut Provider Directory Virtual Connectathon'
      end

      def initialize(client1, client2 = nil)
        super(client1, client2)
      end

      def setup

      end

      test 'APCT01', 'Test Ability to locate a Practitioner\'s Telecom/Physical Address' do
        
      end
    end
  end
end<commit_msg>Implemented first scenario (plus a test to get a provider with roles)<commit_after>module Crucible
  module Tests
    class ArgonautProviderConnectathonTest < BaseSuite
      def id
        'ArgonautProviderConnectathonTest'
      end

      def description
        'Test suite for the Argonaut Provider Directory Virtual Connectathon'
      end

      def initialize(client1, client2 = nil)
        super(client1, client2)
      end

      def setup
        @tags.append('provider')
        @category = {id: 'argonaut', title: 'Argonaut'}
      end

      test 'APCT01', 'GET A set of practitioners to test' do
        metadata {
          links "#{REST_SPEC_LINK}#read"
          links "#{REST_SPEC_LINK}#search"
          requires resource: 'Practitioner', methods: ['read', 'search']
          validates resource: 'Practitioner', methods: ['read', 'search']
        }

        # Basically just get a group of 10 Practitioners
        options = {
            :search => {
              :flag => true,
              :compartment => nil,
              :parameters => {
                _count: 100
              }
            }
          }
          @practitioners = @client.search(FHIR::Practitioner, options).resource.try(:entry)
          assert @practitioners, 'No Practitioners found'
          @practitioner_id = @practitioners.select{ |p| !p.resource.practitionerRole.empty? }.sample.try(:resource).try(:id)
          assert @practitioner_id, 'No practitioner found with a PractitionerRole'
      end

      test 'APCT02', 'Test Ability to locate a Practitioner\'s Telecom/Physical Address' do
        metadata {
          links "#{REST_SPEC_LINK}#read"
          requires resource: 'Practitioner', methods: ['read']
          validates resource: 'Practitioner', methods: ['read']
        }

        skip if !@practitioner_id

        @practitioner = @client.read(FHIR::Practitioner, @practitioner_id).try(:resource)

        assert @practitioner, "No Practitioner found for ID #{@practitioner_id}"

        assert @practitioner.practitionerRole.select{ |pr| !pr.location.empty? }.size >= 1, "No Locations found for Practitioner #{@practitioner.identifier}"

        assert @practitioner.practitionerRole.select{ |pr| !pr.location.select {|loc| loc.address != nil }.empty? }.size >= 1, "No addresses found for Practitioner #{@practitioner.identifier}"

        assert @practitioner.practitionerRole.select{ |pr| !pr.telecom.empty? }.size >= 1, "No telecoms found for Practitioner #{@practitioner.identifier}"

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09710945112049367, 'fraction_numerical': 0.0071451770055212735, 'mean_word_length': 2.5443037974683542, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4149880', 'n_tokens_mistral': 935, 'n_tokens_neox': 876, 'n_words': 245}