This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #330 from onc-healthit/development
Version 2.7.0
- Loading branch information
Showing
436 changed files
with
29,640 additions
and
2,752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib/app/modules/uscore_v*/* linguist-generated=true | ||
resources/terminology/validators/* linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'erb' | ||
require 'pry' | ||
require 'fileutils' | ||
require 'net/http' | ||
require 'fhir_models' | ||
|
||
module Inferno | ||
module Generator | ||
class Base | ||
attr_accessor :path, :extras, :resource_by_path, :resources_by_type, | ||
:claimed_test_id_prefixes | ||
|
||
def initialize(path, extras) | ||
@path = path | ||
@extras = extras | ||
@claimed_test_id_prefixes = Set.new | ||
load_resources | ||
end | ||
|
||
def load_resources | ||
@resource_by_path = Hash.new {} | ||
@resources_by_type = Hash.new { |h, k| h[k] = [] } | ||
Dir.glob("#{resource_file_path}/**/*.*") do |resource| # note one extra "*" | ||
if File.file?(resource) && resource.end_with?('json', 'xml') | ||
|
||
# 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)) | ||
new_resource = FHIR.from_contents(File.read(resource)) | ||
resource_by_path[resource_path(new_resource)] = new_resource_json | ||
type = new_resource.class.name.demodulize | ||
type = 'CapabilityStatement' if type == 'Conformance' | ||
resources_by_type[type].push(new_resource_json) | ||
end | ||
end | ||
end | ||
|
||
def ig_resource | ||
resources_by_type['ImplementationGuide'].first | ||
end | ||
|
||
def capability_statement(mode = 'server') | ||
resources_by_type['CapabilityStatement'].find do |capability_statement_resource| | ||
capability_statement_resource['rest'].any? { |r| r['mode'] == mode } | ||
end | ||
end | ||
|
||
def resource_path(resource) | ||
"#{resource.class.name.demodulize}/#{resource.id}" | ||
end | ||
|
||
def format_output | ||
system("rubocop -x --display-only-fail-level-offenses #{sequence_out_path}") | ||
end | ||
|
||
def run | ||
generate | ||
format_output | ||
end | ||
|
||
# subclass must implement the following | ||
def generate | ||
raise StandardError('Method not implemented.') | ||
end | ||
|
||
def sequence_prefix | ||
version = ig_resource['version'].delete('.') | ||
name = ig_metadata['name'] | ||
"#{version}#{name}" | ||
end | ||
|
||
def module_yml_out_path | ||
File.expand_path('./lib/app/modules/') | ||
end | ||
|
||
def sequence_out_path | ||
File.expand_path("#{module_yml_out_path}/#{path}") | ||
end | ||
|
||
def resource_file_path | ||
File.expand_path("./resources/#{path}") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.