Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
catch json parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase authored and radamson committed Aug 6, 2020
1 parent 755a88c commit 31020e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion generator/generator_base.rb
Expand Up @@ -27,7 +27,13 @@ def load_resources

# We should consider using the native Ruby models instead of JSON
# There were problems with round-tripping certain SearchParameters though
new_resource_json = JSON.parse(File.read(resource))

begin
new_resource_json = JSON.parse(File.read(resource))
rescue JSON::ParserError # failed to parse json
next
end

new_resource = FHIR.from_contents(File.read(resource))
next unless new_resource.present?

Expand Down
5 changes: 5 additions & 0 deletions generator/sequence_metadata.rb
Expand Up @@ -25,12 +25,15 @@ class SequenceMetadata
def initialize(profile, all_search_parameter_metadata, capability_statement = nil)
@profile = profile
@tests = []
@search_parameter_metadata = []
return unless capability_statement.present?

@capabilities = capability_statement['rest']
.find { |rest| rest['mode'] == 'server' }['resource']
.find { |resource| resource['type'] == profile['type'] }

return unless capabilities.present?

@search_parameter_metadata = capabilities['searchParam']&.map do |param|
all_search_parameter_metadata.find { |param_metadata| param_metadata.url == param['definition'] }
end
Expand Down Expand Up @@ -100,6 +103,8 @@ def basic_searches_from_capability_statement
end

def search_combinations_from_capability_statement
return [] unless capabilities.present?

search_combo_url = 'http://hl7.org/fhir/StructureDefinition/capabilitystatement-search-parameter-combination'
capabilities['extension']
&.select { |ext| ext['url'] == search_combo_url }
Expand Down

0 comments on commit 31020e7

Please sign in to comment.