fhir_client 1.6.2 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -3
- data/fhir_client.gemspec +5 -4
- data/lib/client_interface.rb +19 -13
- data/lib/ext/bundle.rb +0 -1
- data/lib/fhir_client.rb +0 -2
- data/lib/model/client_reply.rb +12 -3
- data/lib/resource_address.rb +10 -6
- data/lib/resource_format.rb +5 -2
- data/lib/sections/crud.rb +2 -2
- data/lib/sections/feed.rb +1 -1
- data/lib/sections/history.rb +11 -11
- data/lib/sections/search.rb +5 -5
- data/lib/tasks/tasks.rake +14 -2
- data/test/unit/bundle_test.rb +1 -1
- metadata +46 -6
- data/Gemfile.lock +0 -101
- data/lib/feed_format.rb +0 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 15449e3ef2e088da8def1b3996ccc17d4a1a333d
         | 
| 4 | 
            +
              data.tar.gz: 83cecd3899ccdd1c8672de9fd5d8c283e497e9d6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f3d906ae7896baee562592e678c1396266ff6cb0d3f9c3d9973ed84e576820e2b998de1eac61e0b8d502a9a5ff7beba04580c2e19d61ed1cd2e1ce4428557c8f
         | 
| 7 | 
            +
              data.tar.gz: a0d986ea2a72d00af5c41e22f052863b99e1abc0b2c34d9c07d67f32fbed9091081fae0a925ccb2a78841d026bb42f7710d2af81a11a4b088e5c2b10ee6fd630
         | 
    
        data/.gitignore
    CHANGED
    
    | @@ -26,9 +26,9 @@ build/ | |
| 26 26 |  | 
| 27 27 | 
             
            # for a library or gem, you might want to ignore these files since the code is
         | 
| 28 28 | 
             
            # intended to run in multiple environments; otherwise, check them in:
         | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 29 | 
            +
            Gemfile.lock
         | 
| 30 | 
            +
            .ruby-version
         | 
| 31 | 
            +
            .ruby-gemset
         | 
| 32 32 |  | 
| 33 33 | 
             
            # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
         | 
| 34 34 | 
             
            .rvmrc
         | 
    
        data/fhir_client.gemspec
    CHANGED
    
    | @@ -7,7 +7,7 @@ Gem::Specification.new do |s| | |
| 7 7 | 
             
              s.email = "aquina@mitre.org"
         | 
| 8 8 | 
             
              s.homepage = "https://github.com/hl7-fhir/fhir-svn"
         | 
| 9 9 | 
             
              s.authors = ["Andre Quina", "Jason Walonoski", "Janoo Fernandes"]
         | 
| 10 | 
            -
              s.version = '1.6. | 
| 10 | 
            +
              s.version = '1.6.3'
         | 
| 11 11 |  | 
| 12 12 | 
             
              s.files = s.files = `git ls-files`.split("\n")
         | 
| 13 13 |  | 
| @@ -17,8 +17,9 @@ Gem::Specification.new do |s| | |
| 17 17 | 
             
              s.add_dependency 'oauth2', '~> 1.1'
         | 
| 18 18 | 
             
              s.add_dependency 'activesupport', '>= 3'
         | 
| 19 19 | 
             
              s.add_dependency 'addressable', '>= 2.3'
         | 
| 20 | 
            -
              s.add_dependency 'rack', '~> 1. | 
| 20 | 
            +
              s.add_dependency 'rack', '~> 1.5'
         | 
| 21 | 
            +
              s.add_dependency 'nokogiri'
         | 
| 21 22 | 
             
              s.add_development_dependency 'pry'
         | 
| 23 | 
            +
              s.add_development_dependency 'minitest'
         | 
| 24 | 
            +
              s.add_development_dependency 'test-unit'
         | 
| 22 25 | 
             
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
    
        data/lib/client_interface.rb
    CHANGED
    
    | @@ -19,7 +19,6 @@ module FHIR | |
| 19 19 | 
             
                attr_accessor :client
         | 
| 20 20 |  | 
| 21 21 | 
             
                attr_accessor :default_format
         | 
| 22 | 
            -
                attr_accessor :default_format_bundle
         | 
| 23 22 |  | 
| 24 23 | 
             
                attr_accessor :cached_conformance
         | 
| 25 24 |  | 
| @@ -34,10 +33,17 @@ module FHIR | |
| 34 33 | 
             
                @baseServiceUrl = baseServiceUrl
         | 
| 35 34 | 
             
                @use_format_param = false
         | 
| 36 35 | 
             
                @default_format = FHIR::Formats::ResourceFormat::RESOURCE_XML
         | 
| 37 | 
            -
                @default_format_bundle = FHIR::Formats::FeedFormat::FEED_XML
         | 
| 38 36 | 
             
                set_no_auth
         | 
| 39 37 | 
             
              end
         | 
| 40 38 |  | 
| 39 | 
            +
              def default_json
         | 
| 40 | 
            +
                @default_format = FHIR::Formats::ResourceFormat::RESOURCE_JSON
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              def default_xml
         | 
| 44 | 
            +
                @default_format = FHIR::Formats::ResourceFormat::RESOURCE_XML
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 41 47 | 
             
              # Set the client to use no authentication mechanisms
         | 
| 42 48 | 
             
              def set_no_auth
         | 
| 43 49 | 
             
                FHIR.logger.info "Configuring the client to use no authentication."
         | 
| @@ -163,22 +169,22 @@ module FHIR | |
| 163 169 | 
             
              end
         | 
| 164 170 |  | 
| 165 171 | 
             
              def try_conformance_formats(default_format)
         | 
| 166 | 
            -
                formats = [ | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 172 | 
            +
                formats = [FHIR::Formats::ResourceFormat::RESOURCE_XML,
         | 
| 173 | 
            +
                           FHIR::Formats::ResourceFormat::RESOURCE_JSON,
         | 
| 174 | 
            +
                           FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2,
         | 
| 175 | 
            +
                           FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2,
         | 
| 176 | 
            +
                           'application/xml',
         | 
| 177 | 
            +
                           'application/json']
         | 
| 178 | 
            +
                formats.insert(0, default_format)
         | 
| 171 179 |  | 
| 172 180 | 
             
                @cached_conformance = nil
         | 
| 173 181 | 
             
                @default_format = nil
         | 
| 174 | 
            -
                @default_format_bundle = nil
         | 
| 175 182 |  | 
| 176 183 | 
             
                formats.each do |frmt|
         | 
| 177 184 | 
             
                  reply = get 'metadata', fhir_headers({format: frmt})
         | 
| 178 185 | 
             
                  if reply.code == 200
         | 
| 179 186 | 
             
                    @cached_conformance = parse_reply(FHIR::Conformance, frmt, reply)
         | 
| 180 187 | 
             
                    @default_format = frmt
         | 
| 181 | 
            -
                    @default_format_bundle = frmt
         | 
| 182 188 | 
             
                    break
         | 
| 183 189 | 
             
                  end
         | 
| 184 190 | 
             
                end
         | 
| @@ -243,10 +249,10 @@ module FHIR | |
| 243 249 | 
             
                # Extract the request payload in the specified format, defaults to XML
         | 
| 244 250 | 
             
                def request_payload(resource, headers)
         | 
| 245 251 | 
             
                  if headers
         | 
| 246 | 
            -
                     | 
| 247 | 
            -
                     | 
| 252 | 
            +
                    format_specified = headers[:format] || headers["format"]
         | 
| 253 | 
            +
                    if format_specified.downcase.include?('xml')
         | 
| 248 254 | 
             
                      resource.to_xml
         | 
| 249 | 
            -
                     | 
| 255 | 
            +
                    elsif format_specified.downcase.include?('json')
         | 
| 250 256 | 
             
                      resource.to_json
         | 
| 251 257 | 
             
                    else
         | 
| 252 258 | 
             
                      resource.to_xml
         | 
| @@ -289,7 +295,7 @@ module FHIR | |
| 289 295 | 
             
                end
         | 
| 290 296 |  | 
| 291 297 | 
             
                def get(path, headers)
         | 
| 292 | 
            -
                  url = URI(build_url(path)).to_s
         | 
| 298 | 
            +
                  url = URI(URI.escape(build_url(path))).to_s
         | 
| 293 299 | 
             
                  FHIR.logger.info "GETTING: #{url}"
         | 
| 294 300 | 
             
                  headers = clean_headers(headers)
         | 
| 295 301 | 
             
                  if @use_oauth2_auth
         | 
    
        data/lib/ext/bundle.rb
    CHANGED
    
    
    
        data/lib/fhir_client.rb
    CHANGED
    
    | @@ -1,6 +1,5 @@ | |
| 1 1 | 
             
            # Top level include file that brings in all the necessary code
         | 
| 2 2 | 
             
            require 'bundler/setup'
         | 
| 3 | 
            -
            require 'rubygems'
         | 
| 4 3 | 
             
            require 'yaml'
         | 
| 5 4 | 
             
            require 'nokogiri'
         | 
| 6 5 | 
             
            require 'fhir_models'
         | 
| @@ -21,7 +20,6 @@ end | |
| 21 20 | 
             
            require_relative File.join('.','client_interface.rb')
         | 
| 22 21 | 
             
            require_relative File.join('.','resource_address.rb')
         | 
| 23 22 | 
             
            require_relative File.join('.','resource_format.rb')
         | 
| 24 | 
            -
            require_relative File.join('.','feed_format.rb')
         | 
| 25 23 | 
             
            require_relative File.join('.','patch_format.rb')
         | 
| 26 24 | 
             
            require_relative File.join('.','model','client_reply.rb')
         | 
| 27 25 | 
             
            require_relative File.join('.','model','tag.rb')
         | 
    
        data/lib/model/client_reply.rb
    CHANGED
    
    | @@ -65,8 +65,17 @@ module FHIR | |
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 67 | 
             
                def version
         | 
| 68 | 
            -
                   | 
| 69 | 
            -
                   | 
| 68 | 
            +
                  version = nil
         | 
| 69 | 
            +
                  link = self_link
         | 
| 70 | 
            +
                  if link && link.include?('_history/')
         | 
| 71 | 
            +
                    begin
         | 
| 72 | 
            +
                      tokens = link.split('_history/')
         | 
| 73 | 
            +
                      version = tokens.last.split('/').first
         | 
| 74 | 
            +
                    rescue Exception => e
         | 
| 75 | 
            +
                      version = nil
         | 
| 76 | 
            +
                    end
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
                  version
         | 
| 70 79 | 
             
                end
         | 
| 71 80 |  | 
| 72 81 | 
             
                def self_link
         | 
| @@ -133,7 +142,7 @@ module FHIR | |
| 133 142 | 
             
                      end
         | 
| 134 143 | 
             
                    elsif (present=='optional' && value)
         | 
| 135 144 | 
             
                      errors << "#{name}: Malformed value for optional header #{header}: #{value}" if !(@@header_regexes[header] =~ value)
         | 
| 136 | 
            -
                      binding.pry if !(@@header_regexes[header] =~ value)
         | 
| 145 | 
            +
            #          binding.pry if !(@@header_regexes[header] =~ value)
         | 
| 137 146 | 
             
                    elsif !value.nil?
         | 
| 138 147 | 
             
                      errors << "#{name}: Should not have header: #{header}"
         | 
| 139 148 | 
             
                    end
         | 
    
        data/lib/resource_address.rb
    CHANGED
    
    | @@ -4,7 +4,7 @@ module FHIR | |
| 4 4 | 
             
                DEFAULTS = {
         | 
| 5 5 | 
             
                  id: nil,
         | 
| 6 6 | 
             
                  resource: nil,
         | 
| 7 | 
            -
                  format: 'application/xml | 
| 7 | 
            +
                  format: 'application/fhir+xml'
         | 
| 8 8 | 
             
                }
         | 
| 9 9 |  | 
| 10 10 | 
             
                DEFAULT_CHARSET = 'UTF-8'
         | 
| @@ -117,11 +117,15 @@ module FHIR | |
| 117 117 | 
             
                  id = nil
         | 
| 118 118 | 
             
                  if !resourceType.nil? && !url.nil?
         | 
| 119 119 | 
             
                    token = "#{resourceType}/"
         | 
| 120 | 
            -
                     | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 120 | 
            +
                    if url.index(token)
         | 
| 121 | 
            +
                      start = url.index(token) + token.length
         | 
| 122 | 
            +
                      t = url[start..-1]
         | 
| 123 | 
            +
                      stop = (t.index("/") || 0)-1
         | 
| 124 | 
            +
                      stop = -1 if stop.nil?
         | 
| 125 | 
            +
                      id = t[0..stop]
         | 
| 126 | 
            +
                    else
         | 
| 127 | 
            +
                      id = nil
         | 
| 128 | 
            +
                    end
         | 
| 125 129 | 
             
                  end
         | 
| 126 130 | 
             
                  id
         | 
| 127 131 | 
             
                end
         | 
    
        data/lib/resource_format.rb
    CHANGED
    
    | @@ -2,8 +2,11 @@ module FHIR | |
| 2 2 | 
             
              module Formats
         | 
| 3 3 | 
             
                class ResourceFormat
         | 
| 4 4 |  | 
| 5 | 
            -
                  RESOURCE_XML = "application/xml | 
| 6 | 
            -
                  RESOURCE_JSON = "application/json | 
| 5 | 
            +
                  RESOURCE_XML = "application/fhir+xml"
         | 
| 6 | 
            +
                  RESOURCE_JSON = "application/fhir+json"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  RESOURCE_XML_DSTU2 = "application/xml+fhir"
         | 
| 9 | 
            +
                  RESOURCE_JSON_DSTU2 = "application/json+fhir"
         | 
| 7 10 |  | 
| 8 11 | 
             
                end
         | 
| 9 12 | 
             
              end
         | 
    
        data/lib/sections/crud.rb
    CHANGED
    
    | @@ -17,7 +17,7 @@ module FHIR | |
| 17 17 | 
             
                  #
         | 
| 18 18 | 
             
                  # Read a resource bundle (an XML ATOM feed)
         | 
| 19 19 | 
             
                  #
         | 
| 20 | 
            -
                  def read_feed(klass, format=@ | 
| 20 | 
            +
                  def read_feed(klass, format=@default_format)
         | 
| 21 21 | 
             
                    options = { resource: klass, format: format }
         | 
| 22 22 | 
             
                    reply = get resource_url(options), fhir_headers(options)
         | 
| 23 23 | 
             
                    reply.resource = parse_reply(klass, format, reply)
         | 
| @@ -89,7 +89,7 @@ module FHIR | |
| 89 89 | 
             
                  #
         | 
| 90 90 | 
             
                  def partial_update(klass, id, patchset, options={}, format=@default_format)
         | 
| 91 91 | 
             
                    options = { resource: klass, id: id, format: format }.merge options
         | 
| 92 | 
            -
             | 
| 92 | 
            +
             | 
| 93 93 | 
             
                    if (format == FHIR::Formats::ResourceFormat::RESOURCE_XML)
         | 
| 94 94 | 
             
                      options[:format] = FHIR::Formats::PatchFormat::PATCH_XML
         | 
| 95 95 | 
             
                      options[:Accept] = format
         | 
    
        data/lib/sections/feed.rb
    CHANGED
    
    | @@ -12,7 +12,7 @@ module FHIR | |
| 12 12 | 
             
                    link = bundle.method(page).call
         | 
| 13 13 | 
             
                    return nil unless link
         | 
| 14 14 | 
             
                    reply = get strip_base(link.url), fhir_headers
         | 
| 15 | 
            -
                    reply.resource = parse_reply(current.resource_class, @ | 
| 15 | 
            +
                    reply.resource = parse_reply(current.resource_class, @default_format, reply)
         | 
| 16 16 | 
             
                    reply.resource_class = current.resource_class
         | 
| 17 17 | 
             
                    reply
         | 
| 18 18 | 
             
                  end
         | 
    
        data/lib/sections/history.rb
    CHANGED
    
    | @@ -4,17 +4,17 @@ module FHIR | |
| 4 4 | 
             
                  #
         | 
| 5 5 | 
             
                  # Create a new resource with a server assigned id. Return the newly created
         | 
| 6 6 | 
             
                  # resource with the id the server assigned. Associates tags with newly created resource.
         | 
| 7 | 
            -
                  # | 
| 7 | 
            +
                  #
         | 
| 8 8 | 
             
                  # @param resourceClass
         | 
| 9 9 | 
             
                  # @param resource
         | 
| 10 10 | 
             
                  # @return
         | 
| 11 11 | 
             
                  #
         | 
| 12 12 | 
             
                  # public <T extends Resource> AtomEntry<OperationOutcome> create(Class<T> resourceClass, T resource, List<AtomCategory> tags);
         | 
| 13 | 
            -
             | 
| 13 | 
            +
             | 
| 14 14 | 
             
                  #
         | 
| 15 | 
            -
                  # Retrieve the update history for a resource with given id since last update time. | 
| 15 | 
            +
                  # Retrieve the update history for a resource with given id since last update time.
         | 
| 16 16 | 
             
                  # Last update may be null TODO - ensure this is the case.
         | 
| 17 | 
            -
                  # | 
| 17 | 
            +
                  #
         | 
| 18 18 | 
             
                  # @param lastUpdate
         | 
| 19 19 | 
             
                  # @param resourceClass
         | 
| 20 20 | 
             
                  # @param id
         | 
| @@ -22,10 +22,10 @@ module FHIR | |
| 22 22 | 
             
                  #
         | 
| 23 23 | 
             
                  # public <T extends Resource> AtomFeed history(Calendar lastUpdate, Class<T> resourceClass, String id);
         | 
| 24 24 | 
             
                  # public <T extends Resource> AtomFeed history(DateAndTime lastUpdate, Class<T> resourceClass, String id);
         | 
| 25 | 
            -
             | 
| 25 | 
            +
             | 
| 26 26 | 
             
                  def history(options)
         | 
| 27 27 | 
             
                    reply = get resource_url(options), fhir_headers(options).except(:history)
         | 
| 28 | 
            -
                    reply.resource = parse_reply(options[:resource], @ | 
| 28 | 
            +
                    reply.resource = parse_reply(options[:resource], @default_format, reply)
         | 
| 29 29 | 
             
                    reply.resource_class = options[:resource]
         | 
| 30 30 | 
             
                    reply
         | 
| 31 31 | 
             
                  end
         | 
| @@ -33,7 +33,7 @@ module FHIR | |
| 33 33 | 
             
                  #
         | 
| 34 34 | 
             
                  # Retrieve the entire update history for a resource with the given id.
         | 
| 35 35 | 
             
                  # Last update may be null TODO - ensure this is the case.
         | 
| 36 | 
            -
                  # | 
| 36 | 
            +
                  #
         | 
| 37 37 | 
             
                  # @param resourceClass
         | 
| 38 38 | 
             
                  # @param id
         | 
| 39 39 | 
             
                  # @param lastUpdate
         | 
| @@ -54,18 +54,18 @@ module FHIR | |
| 54 54 | 
             
                  def resource_history_as_of(klass, lastUpdate)
         | 
| 55 55 | 
             
                    history(resource: klass, history:{since: lastUpdate})
         | 
| 56 56 | 
             
                  end
         | 
| 57 | 
            -
             | 
| 57 | 
            +
             | 
| 58 58 | 
             
                  #
         | 
| 59 59 | 
             
                  # Retrieve the update history for all resource types since the start of server records.
         | 
| 60 | 
            -
                  # | 
| 60 | 
            +
                  #
         | 
| 61 61 | 
             
                  def all_history
         | 
| 62 62 | 
             
                    history(history:{})
         | 
| 63 63 | 
             
                  end
         | 
| 64 64 |  | 
| 65 65 | 
             
                  #
         | 
| 66 66 | 
             
                  # Retrieve the update history for all resource types since a specific last update date/time.
         | 
| 67 | 
            -
                  # | 
| 68 | 
            -
                  # Note: | 
| 67 | 
            +
                  #
         | 
| 68 | 
            +
                  # Note:
         | 
| 69 69 | 
             
                  # @param lastUpdate
         | 
| 70 70 | 
             
                  # @return
         | 
| 71 71 | 
             
                  #
         | 
    
        data/lib/sections/search.rb
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            module FHIR
         | 
| 2 2 | 
             
              module Sections
         | 
| 3 3 | 
             
                module Search
         | 
| 4 | 
            -
             | 
| 4 | 
            +
             | 
| 5 5 | 
             
                  #
         | 
| 6 6 | 
             
                  # Search a set of resources of a given type.
         | 
| 7 | 
            -
                  # | 
| 7 | 
            +
                  #
         | 
| 8 8 | 
             
                  # @param klass The type of resource to be searched.
         | 
| 9 9 | 
             
                  # @param options A hash of options used to construct the search query.
         | 
| 10 10 | 
             
                  # @return FHIR::ClientReply
         | 
| 11 11 | 
             
                  #
         | 
| 12 | 
            -
                  def search(klass, options={}, format=@ | 
| 12 | 
            +
                  def search(klass, options={}, format=@default_format)
         | 
| 13 13 | 
             
                    options.merge!({ resource: klass, format: format })
         | 
| 14 14 |  | 
| 15 15 | 
             
                    if options[:search] && options[:search][:flag]
         | 
| @@ -23,7 +23,7 @@ module FHIR | |
| 23 23 | 
             
                    reply
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| 26 | 
            -
                  def search_existing(klass, id, options={}, format=@ | 
| 26 | 
            +
                  def search_existing(klass, id, options={}, format=@default_format)
         | 
| 27 27 | 
             
                    options.merge!({ resource: klass, id: id, format: format })
         | 
| 28 28 | 
             
                    #if options[:search][:flag]
         | 
| 29 29 | 
             
                    if options[:search] && options[:search][:flag]
         | 
| @@ -36,7 +36,7 @@ module FHIR | |
| 36 36 | 
             
                    reply
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| 39 | 
            -
                  def search_all(options={}, format=@ | 
| 39 | 
            +
                  def search_all(options={}, format=@default_format)
         | 
| 40 40 | 
             
                    options.merge!({ format: format })
         | 
| 41 41 | 
             
                    if options[:search] && options[:search][:flag]
         | 
| 42 42 | 
             
                      reply = post resource_url(options), nil, fhir_headers(options)
         | 
    
        data/lib/tasks/tasks.rake
    CHANGED
    
    | @@ -58,14 +58,26 @@ namespace :fhir do | |
| 58 58 | 
             
              task :clean, [:url] do |t, args|
         | 
| 59 59 | 
             
                client = FHIR::Client.new(args.url)
         | 
| 60 60 | 
             
                fhir_resources.each do | klass |
         | 
| 61 | 
            +
                  puts "Reading #{klass.name.demodulize}..."
         | 
| 62 | 
            +
                  skipped = []
         | 
| 61 63 | 
             
                  reply = client.read_feed(klass)
         | 
| 62 64 | 
             
                  while !reply.nil? && !reply.resource.nil? && reply.resource.total > 0
         | 
| 65 | 
            +
                    puts "  Cleaning #{reply.resource.entry.length} #{klass.name.demodulize} resources..."
         | 
| 63 66 | 
             
                    reply.resource.entry.each do |entry|
         | 
| 64 | 
            -
                       | 
| 67 | 
            +
                      unless entry.resource.nil?
         | 
| 68 | 
            +
                        del_reply = client.destroy(klass,entry.resource.id) 
         | 
| 69 | 
            +
                        skipped << "#{klass.name.demodulize}/#{entry.resource.id}" if [405,409].include?(del_reply.code)
         | 
| 70 | 
            +
                      end
         | 
| 71 | 
            +
                    end
         | 
| 72 | 
            +
                    if skipped.empty?
         | 
| 73 | 
            +
                      reply = client.read_feed(klass) 
         | 
| 74 | 
            +
                    else
         | 
| 75 | 
            +
                      puts "  *** Unable to delete some #{klass.name.demodulize}s ***"
         | 
| 76 | 
            +
                      reply = nil
         | 
| 65 77 | 
             
                    end
         | 
| 66 | 
            -
                    reply = client.read_feed(klass)
         | 
| 67 78 | 
             
                  end
         | 
| 68 79 | 
             
                end
         | 
| 80 | 
            +
                puts "Done cleaning."
         | 
| 69 81 | 
             
                Rake::Task['fhir:count'].invoke(args.url)
         | 
| 70 82 | 
             
              end
         | 
| 71 83 |  | 
    
        data/test/unit/bundle_test.rb
    CHANGED
    
    | @@ -13,7 +13,7 @@ class BundleTest < Test::Unit::TestCase | |
| 13 13 | 
             
                }
         | 
| 14 14 | 
             
                clientReply = FHIR::ClientReply.new('feed-test', response)
         | 
| 15 15 |  | 
| 16 | 
            -
                bundle = client.parse_reply(FHIR::Bundle, FHIR::Formats:: | 
| 16 | 
            +
                bundle = client.parse_reply(FHIR::Bundle, FHIR::Formats::ResourceFormat::RESOURCE_XML, clientReply)
         | 
| 17 17 |  | 
| 18 18 | 
             
                assert !bundle.nil?, "Failed to parse example Bundle."
         | 
| 19 19 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fhir_client
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.6. | 
| 4 | 
            +
              version: 1.6.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Andre Quina
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2016- | 
| 13 | 
            +
            date: 2016-09-20 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: fhir_models
         | 
| @@ -102,14 +102,28 @@ dependencies: | |
| 102 102 | 
             
                requirements:
         | 
| 103 103 | 
             
                - - ~>
         | 
| 104 104 | 
             
                  - !ruby/object:Gem::Version
         | 
| 105 | 
            -
                    version: '1. | 
| 105 | 
            +
                    version: '1.5'
         | 
| 106 106 | 
             
              type: :runtime
         | 
| 107 107 | 
             
              prerelease: false
         | 
| 108 108 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 109 109 | 
             
                requirements:
         | 
| 110 110 | 
             
                - - ~>
         | 
| 111 111 | 
             
                  - !ruby/object:Gem::Version
         | 
| 112 | 
            -
                    version: '1. | 
| 112 | 
            +
                    version: '1.5'
         | 
| 113 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 114 | 
            +
              name: nokogiri
         | 
| 115 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 116 | 
            +
                requirements:
         | 
| 117 | 
            +
                - - '>='
         | 
| 118 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 119 | 
            +
                    version: '0'
         | 
| 120 | 
            +
              type: :runtime
         | 
| 121 | 
            +
              prerelease: false
         | 
| 122 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 123 | 
            +
                requirements:
         | 
| 124 | 
            +
                - - '>='
         | 
| 125 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 126 | 
            +
                    version: '0'
         | 
| 113 127 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 114 128 | 
             
              name: pry
         | 
| 115 129 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -124,6 +138,34 @@ dependencies: | |
| 124 138 | 
             
                - - '>='
         | 
| 125 139 | 
             
                  - !ruby/object:Gem::Version
         | 
| 126 140 | 
             
                    version: '0'
         | 
| 141 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 142 | 
            +
              name: minitest
         | 
| 143 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 144 | 
            +
                requirements:
         | 
| 145 | 
            +
                - - '>='
         | 
| 146 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 147 | 
            +
                    version: '0'
         | 
| 148 | 
            +
              type: :development
         | 
| 149 | 
            +
              prerelease: false
         | 
| 150 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 151 | 
            +
                requirements:
         | 
| 152 | 
            +
                - - '>='
         | 
| 153 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 154 | 
            +
                    version: '0'
         | 
| 155 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 156 | 
            +
              name: test-unit
         | 
| 157 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 158 | 
            +
                requirements:
         | 
| 159 | 
            +
                - - '>='
         | 
| 160 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 161 | 
            +
                    version: '0'
         | 
| 162 | 
            +
              type: :development
         | 
| 163 | 
            +
              prerelease: false
         | 
| 164 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 165 | 
            +
                requirements:
         | 
| 166 | 
            +
                - - '>='
         | 
| 167 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 168 | 
            +
                    version: '0'
         | 
| 127 169 | 
             
            description: A Gem for handling FHIR client requests in ruby
         | 
| 128 170 | 
             
            email: aquina@mitre.org
         | 
| 129 171 | 
             
            executables: []
         | 
| @@ -134,7 +176,6 @@ files: | |
| 134 176 | 
             
            - .simplecov
         | 
| 135 177 | 
             
            - .travis.yml
         | 
| 136 178 | 
             
            - Gemfile
         | 
| 137 | 
            -
            - Gemfile.lock
         | 
| 138 179 | 
             
            - LICENSE
         | 
| 139 180 | 
             
            - README.md
         | 
| 140 181 | 
             
            - Rakefile
         | 
| @@ -144,7 +185,6 @@ files: | |
| 144 185 | 
             
            - lib/ext/bundle.rb
         | 
| 145 186 | 
             
            - lib/ext/model.rb
         | 
| 146 187 | 
             
            - lib/ext/reference.rb
         | 
| 147 | 
            -
            - lib/feed_format.rb
         | 
| 148 188 | 
             
            - lib/fhir_api_validation.json
         | 
| 149 189 | 
             
            - lib/fhir_client.rb
         | 
| 150 190 | 
             
            - lib/model/client_reply.rb
         | 
    
        data/Gemfile.lock
    DELETED
    
    | @@ -1,101 +0,0 @@ | |
| 1 | 
            -
            PATH
         | 
| 2 | 
            -
              remote: .
         | 
| 3 | 
            -
              specs:
         | 
| 4 | 
            -
                fhir_client (1.6.1)
         | 
| 5 | 
            -
                  activesupport (>= 3)
         | 
| 6 | 
            -
                  addressable (>= 2.3)
         | 
| 7 | 
            -
                  fhir_models (>= 1.6.1)
         | 
| 8 | 
            -
                  oauth2 (~> 1.1)
         | 
| 9 | 
            -
                  rack (~> 1.6)
         | 
| 10 | 
            -
                  rest-client (~> 1.8)
         | 
| 11 | 
            -
                  tilt (>= 1.1)
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            GEM
         | 
| 14 | 
            -
              remote: http://rubygems.org/
         | 
| 15 | 
            -
              specs:
         | 
| 16 | 
            -
                activesupport (4.0.13)
         | 
| 17 | 
            -
                  i18n (~> 0.6, >= 0.6.9)
         | 
| 18 | 
            -
                  minitest (~> 4.2)
         | 
| 19 | 
            -
                  multi_json (~> 1.3)
         | 
| 20 | 
            -
                  thread_safe (~> 0.1)
         | 
| 21 | 
            -
                  tzinfo (~> 0.3.37)
         | 
| 22 | 
            -
                addressable (2.4.0)
         | 
| 23 | 
            -
                ansi (1.5.0)
         | 
| 24 | 
            -
                awesome_print (1.6.1)
         | 
| 25 | 
            -
                bcp47 (0.3.3)
         | 
| 26 | 
            -
                  i18n
         | 
| 27 | 
            -
                coderay (1.1.1)
         | 
| 28 | 
            -
                date_time_precision (0.8.1)
         | 
| 29 | 
            -
                docile (1.1.5)
         | 
| 30 | 
            -
                domain_name (0.5.20160615)
         | 
| 31 | 
            -
                  unf (>= 0.0.5, < 1.0.0)
         | 
| 32 | 
            -
                faraday (0.9.2)
         | 
| 33 | 
            -
                  multipart-post (>= 1.2, < 3)
         | 
| 34 | 
            -
                fhir_models (1.6.2)
         | 
| 35 | 
            -
                  bcp47 (>= 0.3)
         | 
| 36 | 
            -
                  date_time_precision (>= 0.8)
         | 
| 37 | 
            -
                  mime-types (>= 1.16, < 3)
         | 
| 38 | 
            -
                  nokogiri (>= 1.6)
         | 
| 39 | 
            -
                  rake (>= 0.8.7)
         | 
| 40 | 
            -
                http-cookie (1.0.2)
         | 
| 41 | 
            -
                  domain_name (~> 0.5)
         | 
| 42 | 
            -
                i18n (0.7.0)
         | 
| 43 | 
            -
                json (2.0.2)
         | 
| 44 | 
            -
                jwt (1.5.4)
         | 
| 45 | 
            -
                method_source (0.8.2)
         | 
| 46 | 
            -
                mime-types (2.99.2)
         | 
| 47 | 
            -
                mini_portile2 (2.1.0)
         | 
| 48 | 
            -
                minitest (4.7.5)
         | 
| 49 | 
            -
                multi_json (1.12.1)
         | 
| 50 | 
            -
                multi_xml (0.5.5)
         | 
| 51 | 
            -
                multipart-post (2.0.0)
         | 
| 52 | 
            -
                netrc (0.11.0)
         | 
| 53 | 
            -
                nokogiri (1.6.8)
         | 
| 54 | 
            -
                  mini_portile2 (~> 2.1.0)
         | 
| 55 | 
            -
                  pkg-config (~> 1.1.7)
         | 
| 56 | 
            -
                oauth2 (1.2.0)
         | 
| 57 | 
            -
                  faraday (>= 0.8, < 0.10)
         | 
| 58 | 
            -
                  jwt (~> 1.0)
         | 
| 59 | 
            -
                  multi_json (~> 1.3)
         | 
| 60 | 
            -
                  multi_xml (~> 0.5)
         | 
| 61 | 
            -
                  rack (>= 1.2, < 3)
         | 
| 62 | 
            -
                pkg-config (1.1.7)
         | 
| 63 | 
            -
                pry (0.10.3)
         | 
| 64 | 
            -
                  coderay (~> 1.1.0)
         | 
| 65 | 
            -
                  method_source (~> 0.8.1)
         | 
| 66 | 
            -
                  slop (~> 3.4)
         | 
| 67 | 
            -
                rack (1.6.4)
         | 
| 68 | 
            -
                rake (11.2.2)
         | 
| 69 | 
            -
                rest-client (1.8.0)
         | 
| 70 | 
            -
                  http-cookie (>= 1.0.2, < 2.0)
         | 
| 71 | 
            -
                  mime-types (>= 1.16, < 3.0)
         | 
| 72 | 
            -
                  netrc (~> 0.7)
         | 
| 73 | 
            -
                simplecov (0.12.0)
         | 
| 74 | 
            -
                  docile (~> 1.1.0)
         | 
| 75 | 
            -
                  json (>= 1.8, < 3)
         | 
| 76 | 
            -
                  simplecov-html (~> 0.10.0)
         | 
| 77 | 
            -
                simplecov-html (0.10.0)
         | 
| 78 | 
            -
                slop (3.6.0)
         | 
| 79 | 
            -
                thread_safe (0.3.5)
         | 
| 80 | 
            -
                tilt (2.0.5)
         | 
| 81 | 
            -
                turn (0.9.7)
         | 
| 82 | 
            -
                  ansi
         | 
| 83 | 
            -
                  minitest (~> 4)
         | 
| 84 | 
            -
                tzinfo (0.3.51)
         | 
| 85 | 
            -
                unf (0.1.4)
         | 
| 86 | 
            -
                  unf_ext
         | 
| 87 | 
            -
                unf_ext (0.0.7.2)
         | 
| 88 | 
            -
             | 
| 89 | 
            -
            PLATFORMS
         | 
| 90 | 
            -
              ruby
         | 
| 91 | 
            -
             | 
| 92 | 
            -
            DEPENDENCIES
         | 
| 93 | 
            -
              awesome_print
         | 
| 94 | 
            -
              fhir_client!
         | 
| 95 | 
            -
              minitest (~> 4.0)
         | 
| 96 | 
            -
              pry
         | 
| 97 | 
            -
              simplecov
         | 
| 98 | 
            -
              turn
         | 
| 99 | 
            -
             | 
| 100 | 
            -
            BUNDLED WITH
         | 
| 101 | 
            -
               1.12.5
         |