Skip to content

Commit

Permalink
FI-2673 Add Primitive Extension handling (#166)
Browse files Browse the repository at this point in the history
* generate metadata for must_supports.extensions.path

* Update navigator to handle primitive extension

* Fix fhir_navigator when the result is false

* coding style

* rubocop

* Add two unit test for primitive extension

* add another unit test

* handles if source_hash does not have specified key

* rubocop

* rubocop

* remove .rubocop.yml

* Update gitignore

* add unit tests for non primitive element

---------

Co-authored-by: Yunwei Wang <>
  • Loading branch information
yunwwang authored Apr 15, 2024
1 parent 6bdf1b2 commit 3533822
Show file tree
Hide file tree
Showing 30 changed files with 303 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
/docs/yard
.yardoc
node_modules
.rubocop.yml
12 changes: 11 additions & 1 deletion lib/us_core_test_kit/fhir_resource_navigation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module USCoreTestKit
module FHIRResourceNavigation
DAR_EXTENSION_URL = 'http://hl7.org/fhir/StructureDefinition/data-absent-reason'.freeze
PRIMITIVE_DATA_TYPES = FHIR::PRIMITIVES.keys

def resolve_path(elements, path)
elements = Array.wrap(elements)
Expand Down Expand Up @@ -64,12 +65,21 @@ def get_next_value(element, property)
slice = find_slice_via_discriminator(element, property)
slice
else
element.send(property)
result = element.send(property)
result = find_primitive_extension(element, property) if result.nil?
result
end
rescue NoMethodError
nil
end

def find_primitive_extension(element, property)
type = element.class::METADATA[property.to_s]['type']
source_value = element.source_hash["_#{property}"]

PRIMITIVE_DATA_TYPES.include?(type) && source_value.present? ? FHIR::Element.new(source_value) : nil
end

def find_slice_via_discriminator(element, property)
element_name = property.to_s.split(':')[0].gsub(/^class$/, 'local_class')
slice_name = property.to_s.split(':')[1].gsub(/^class$/, 'local_class')
Expand Down
3 changes: 3 additions & 0 deletions lib/us_core_test_kit/generated/v3.1.1/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/us_core_test_kit/generated/v3.1.1/patient/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/us_core_test_kit/generated/v4.0.0/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/us_core_test_kit/generated/v4.0.0/patient/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/us_core_test_kit/generated/v5.0.1/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/us_core_test_kit/generated/v5.0.1/patient/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions lib/us_core_test_kit/generated/v6.1.0/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/us_core_test_kit/generated/v6.1.0/patient/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/us_core_test_kit/generated/v7.0.0-ballot/metadata.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3533822

Please sign in to comment.