diff --git a/fhir_models.gemspec b/fhir_models.gemspec index bdd4c0bef..df75cd8d2 100644 --- a/fhir_models.gemspec +++ b/fhir_models.gemspec @@ -6,7 +6,7 @@ require 'fhir_models/version' Gem::Specification.new do |spec| spec.name = 'fhir_models' spec.version = FHIR::Models::VERSION - spec.authors = ['Jason Walonoski', 'Andre Quina', "Michael O'Keefe", 'Robert Scanlon'] + spec.authors = ['Jason Walonoski', 'Andre Quina', "Michael O'Keefe", 'Robert Scanlon', 'Reece Adamson'] spec.email = ['jwalonoski@mitre.org'] spec.summary = %q{A Gem for handling FHIR models in ruby} @@ -28,6 +28,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' spec.add_development_dependency 'pry' + spec.add_development_dependency 'pry-coolline' spec.add_development_dependency 'test-unit' spec.add_development_dependency 'rspec' spec.add_development_dependency 'simplecov' diff --git a/spec/unit/bootstrap/definitions_spec.rb b/spec/unit/bootstrap/definitions_spec.rb index f8d8763f1..cf368b544 100644 --- a/spec/unit/bootstrap/definitions_spec.rb +++ b/spec/unit/bootstrap/definitions_spec.rb @@ -13,7 +13,7 @@ context 'matching expansions' do it 'returns a matching expansion.contains value' do - expect(FHIR::Definitions.get_display(uri, code)).to eq 'Echography of kidney' + expect(FHIR::Definitions.get_display(uri, code)).to eq 'US kidneys' end end diff --git a/test/unit/equality_test.rb b/test/unit/equality_test.rb index 55403968d..c545604e1 100644 --- a/test/unit/equality_test.rb +++ b/test/unit/equality_test.rb @@ -29,8 +29,10 @@ class EqualityTest < Test::Unit::TestCase Dir.glob(example_json_files).each do |example_json_file| example_name = File.basename(example_json_file, '.json') example_xml_file = File.join(EXAMPLE_ROOT, 'xml', "#{example_name}.xml") - define_method("test_equality_#{example_name}") do - run_equality_test(example_json_file, example_xml_file, example_name) + if File.exist?(example_xml_file) + define_method("test_equality_#{example_name}") do + run_equality_test(example_json_file, example_xml_file, example_name) + end end end @@ -90,17 +92,17 @@ def run_xml_equality_test(example_file, example_name) def run_equality_test(example_json_file, example_xml_file, example_name) input_json = File.read(example_json_file) input_xml = File.read(example_xml_file) - instance_a = FHIR::Json.from_json(input_json) - instance_b = FHIR::Xml.from_xml(input_xml) + instance_json = FHIR::Json.from_json(input_json) + instance_xml = FHIR::Xml.from_xml(input_xml) exclude = ['div'] - if !instance_a.equals?(instance_b, exclude) || !instance_b.equals?(instance_a, exclude) - File.open("#{ERROR_DIR}/#{example_name}_A.json", 'w:UTF-8') { |file| file.write(instance_a.to_json) } - File.open("#{ERROR_DIR}/#{example_name}_B.json", 'w:UTF-8') { |file| file.write(instance_b.to_json) } - File.open("#{ERROR_DIR}/#{example_name}_A.xml", 'w:UTF-8') { |file| file.write(instance_a.to_xml) } - File.open("#{ERROR_DIR}/#{example_name}_B.xml", 'w:UTF-8') { |file| file.write(instance_b.to_xml) } + if !instance_json.equals?(instance_xml, exclude) || !instance_xml.equals?(instance_json, exclude) + File.open("#{ERROR_DIR}/#{example_name}_json.json", 'w:UTF-8') { |file| file.write(instance_json.to_json) } + File.open("#{ERROR_DIR}/#{example_name}_xml.json", 'w:UTF-8') { |file| file.write(instance_xml.to_json) } + File.open("#{ERROR_DIR}/#{example_name}_json.xml", 'w:UTF-8') { |file| file.write(instance_json.to_xml) } + File.open("#{ERROR_DIR}/#{example_name}_xml.xml", 'w:UTF-8') { |file| file.write(instance_xml.to_xml) } end - assert instance_a.equals?(instance_b, exclude), 'Instance A should be equal to instance B.' - assert instance_b.equals?(instance_a, exclude), 'Instance B should be equal to instance A.' + assert instance_json.equals?(instance_xml, exclude), 'Instance JSON should be equal to instance XML.' + assert instance_xml.equals?(instance_json, exclude), 'Instance XML should be equal to instance JSON.' # check memory before = check_memory instance_a = nil diff --git a/test/unit/profile_validation_test.rb b/test/unit/profile_validation_test.rb index 7378d91fe..bd121a675 100644 --- a/test/unit/profile_validation_test.rb +++ b/test/unit/profile_validation_test.rb @@ -10,7 +10,7 @@ class ProfileValidationTest < Test::Unit::TestCase Dir.glob(us_core_ig).each do |definition| json = File.read(definition) resource = FHIR.from_contents(json) - PROFILES[resource.url] = resource + PROFILES[resource.url] = resource if resource end # Create a blank folder for the errors @@ -408,7 +408,7 @@ def test_valueset_binding # first 2 value sets are special cases element = FHIR::ElementDefinition.new('path' => 'mime', 'type' => [{ 'code' => 'string' }], 'min' => 1, 'max' => '1', - 'binding' => { 'valueSetUri' => 'http://hl7.org/fhir/ValueSet/content-type' }) + 'binding' => { 'valueSet' => 'http://hl7.org/fhir/ValueSet/mimetypes' }) sd.errors = [] sd.send(:check_binding_element, element, 'xml') assert_empty(sd.errors) @@ -420,7 +420,7 @@ def test_valueset_binding assert_equal("mime has invalid mime-type: 'jpeg'", sd.errors[0]) element = FHIR::ElementDefinition.new('path' => 'lang', 'type' => [{ 'code' => 'string' }], 'min' => 1, 'max' => '1', - 'binding' => { 'valueSetUri' => 'http://hl7.org/fhir/ValueSet/languages' }) + 'binding' => { 'valueSet' => 'http://hl7.org/fhir/ValueSet/languages' }) sd.errors = [] sd.send(:check_binding_element, element, 'en') assert_empty(sd.errors) @@ -435,7 +435,7 @@ def test_valueset_binding # use a valueset we don't have defined here element = FHIR::ElementDefinition.new('path' => 'problem', 'type' => [{ 'code' => 'string' }], 'min' => 1, 'max' => '1', - 'binding' => { 'valueSetUri' => 'http://standardhealthrecord.org/shr/problem/vs/ProblemCategoryVS' }) + 'binding' => { 'valueSet' => 'http://standardhealthrecord.org/shr/problem/vs/ProblemCategoryVS' }) sd.errors = [] sd.warnings = [] sd.send(:check_binding_element, element, 'disease') @@ -446,7 +446,7 @@ def test_valueset_binding # regular case, FHIR VS with nothing special about it # binding strength required => error if wrong element = FHIR::ElementDefinition.new('path' => 'county', 'type' => [{ 'code' => 'string' }], 'min' => 1, 'max' => '1', - 'binding' => { 'valueSetUri' => 'http://hl7.org/fhir/ValueSet/fips-county', + 'binding' => { 'valueSet' => 'http://hl7.org/fhir/ValueSet/fips-county', 'strength' => 'required' }) sd.errors = [] sd.warnings = [] @@ -462,7 +462,7 @@ def test_valueset_binding # binding strength example => warning if wrong element = FHIR::ElementDefinition.new('path' => 'county', 'type' => [{ 'code' => 'string' }], 'min' => 1, 'max' => '1', - 'binding' => { 'valueSetUri' => 'http://hl7.org/fhir/ValueSet/fips-county', + 'binding' => { 'valueSet' => 'http://hl7.org/fhir/ValueSet/fips-county', 'strength' => 'example' }) sd.errors = [] sd.warnings = []