Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions lib/inferno/dsl/must_support_metadata_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,7 @@ def save_pattern_slice(pattern_element, discriminator_path, metadata)
system: pattern_element.patternCoding.system
}
elsif pattern_element.patternIdentifier
{
type: 'patternIdentifier',
path: runtime_path,
system: pattern_element.patternIdentifier.system
}
save_pattern_identifier_slice(pattern_element.patternIdentifier, runtime_path)
elsif required_binding_pattern?(pattern_element)
{
type: 'requiredBinding',
Expand All @@ -222,6 +218,25 @@ def required_binding_pattern?(pattern_element)
pattern_element.binding&.strength == 'required' && pattern_element.binding&.valueSet
end

def save_pattern_identifier_slice(pattern_identifier, runtime_path)
identifier_type_coding = pattern_identifier.type&.coding&.first
if identifier_type_coding
type_path = runtime_path.present? ? "#{runtime_path}.type" : 'type'
{
type: 'patternCodeableConcept',
path: type_path,
code: identifier_type_coding.code,
system: identifier_type_coding.system
}
else
Comment on lines +221 to +231

@karlnaden karlnaden Jun 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to the top of this method explaining the special case and maybe pointing to an example profile and element. I think the gist is that this is a case where Inferno's handling of patterns diverges from FHIR's: In the FHIR representation, the pattern is an identifier with just the type present and it matches any identifier with the indicated type at a given path. from the PAS insurer profile:

    {
      "id" : "Organization.identifier:PI",
      "path" : "Organization.identifier",
      "sliceName" : "PI",
      ...
      "type" : [{
        "code" : "Identifier"
      }],
      "patternIdentifier" : {
        "type" : {
          "coding" : [{
            "system" : "http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBIdentifierType",
            "code" : "payerid"
          }]
        }
      },
      ...
    },

In Inferno, the case we have so far for identifiers is a match on the system, and so a match on the type wasn't working. However, this update (already implemented and used in PAS) represents an identifier pattern with type specified as a CodeableConcept pattern and adding type to the path. That works, and it is a divergence from the FHIR approach, which is a bit worrying. That may mean it is better to leave it as an override in PAS after all for now. At some point later, we could consider following the FHIR representation.

{
type: 'patternIdentifier',
path: runtime_path,
system: pattern_identifier.system
}
end
end

def extract_required_binding_values(pattern_element, metadata)
value_extractor = ValueExtractor.new(ig_resources, resource, profile_elements)

Expand Down
46 changes: 46 additions & 0 deletions spec/inferno/dsl/must_support_metadata_extractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,52 @@
}
)
end

it 'emits a patternCodeableConcept discriminator for a patternIdentifier slice with type.coding' do
discriminator = FHIR::ElementDefinition::Slicing::Discriminator.new(type: 'value', path: '$this')
slicing = FHIR::ElementDefinition::Slicing.new(discriminator: [discriminator])
identifier_type = FHIR::CodeableConcept.new(
coding: [FHIR::Coding.new(system: 'http://terminology.hl7.org/CodeSystem/v2-0203', code: 'PI')]
)
profile_elements = [
FHIR::ElementDefinition.new(
id: 'Organization.identifier',
path: 'Organization.identifier',
mustSupport: false,
slicing:
),
FHIR::ElementDefinition.new(
id: 'Organization.identifier:PI',
path: 'Organization.identifier',
sliceName: 'PI',
mustSupport: true,
patternIdentifier: FHIR::Identifier.new(type: identifier_type)
)
]
org_profile = instance_double(
FHIR::StructureDefinition,
baseDefinition: 'baseDefinition',
name: 'organization',
type: 'Organization',
version: '2.2.0'
)

slices = described_class.new(profile_elements, org_profile, 'Organization', ig_resources).value_slices

expect(slices).to contain_exactly(
{
slice_id: 'Organization.identifier:PI',
slice_name: 'PI',
path: 'identifier',
discriminator: {
type: 'patternCodeableConcept',
path: 'type',
code: 'PI',
system: 'http://terminology.hl7.org/CodeSystem/v2-0203'
}
}
)
end
end

describe '#must_support_elements' do
Expand Down
Loading