Skip to content

generate FHIR::Resource and FHIR::DomainResource, include by inheritance #6

Description

@asross

For some of the things it might be nice to do with FHIR::Reference resources, it might be helpful to reproduce some of the inheritance hierarchy specified in the XML schemas / FHIR docs, kind of like this:

module FHIR
  # core FHIR::Model supersuperclass
  class Model
    # anything we want available on every resource
  end

  class Element < FHIR::Model
    attr_accessor :id                   # 0-1 id
    attr_accessor :extension            # 0-* [ Extension ]
  end

  class BackboneElement < FHIR::Element
    attr_accessor :modifierExtension    # 0-* [ Extension ]
  end

  # generated Resource and DomainResource superclasses
  class Resource < FHIR::Model
    attr_accessor :id                   # 0-1 id
    attr_accessor :meta                 # 0-1 Meta
    attr_accessor :implicitRules        # 0-1 uri
    attr_accessor :language             # 0-1 code
  end

  class DomainResource < FHIR::Model
    attr_accessor :text                 # 0-1 Narrative
    attr_accessor :contained            # 0-* [ Resource ]
    attr_accessor :extension            # 0-* [ Extension ]
    attr_accessor :modifierExtension    # 0-* [ Extension ]
  end

   # generated resource classes
   class Bundle < FHIR::Resource
    attr_accessor :type          # 1-1 code
    attr_accessor :total         # 0-1 unsignedInt
    attr_accessor :link          # 0-* [ Bundle::Link ]
    attr_accessor :entry         # 0-* [ Bundle::Entry ]
    # ...

     class Link < FHIR::BackboneElement
        # ...
     end
   end

   class Patient < FHIR::DomainResource
    attr_accessor :identifier           # 0-* [ Identifier ]
    attr_accessor :active               # 0-1 boolean
    attr_accessor :name                 # 0-* [ HumanName ]
    attr_accessor :telecom              # 0-* [ ContactPoint ]
    # ...

    class Contact < FHIR::BackboneElement
      # ...
    end
   end
end

I'm not sure how challenging this would be to implement -- my intuition is that it could actually make some of the generation code simpler, because there would be more of a 1-1 mapping between the XML schemas and the generated model files -- but it might be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions