-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate FHIR::Resource
and FHIR::DomainResource
, include by inheritance
#6
Comments
I spoke with @jawalonoski and @andrequina about doing this yesterday. The reason why this was implemented as a flat structure is that the order of the elements within the models is important for serialization/deserialization, and using inheritance caused problems with controlling that order. Is there a functional advantage to reorganizing the models to match the FHIR hierarchy that couldn't be solved with a simple workaround? Could the reference resolving issue that you have be solved by seeing if the model responds to I agree that it would be logically cleaner to use the same hierarchy, but there were some issues that came up when we did that, so I think we'd need some concrete benefits to justify tracking down those issues. What do you think? Let me know if I mischaracterized the problem @jawalonoski. |
Hmm, that makes sense, but could you explain what the element ordering problem is? At first glance it seems like it shouldn't matter. Although I'm realizing there might be an issue with constants (although I think it's resolvable).
We could definitely do a simple workaround. I think when I was testing I found that However, there might still be a functional advantage, e.g. if you wanted to define some methods just on |
I'm not sure if this would help solve the problem, but if the issue stems from the fact that the order is actually specified twice (once in class FHIR::Model
def self.attrs
@attrs ||= {}
end
def self.attr(name, metadata)
self.attr_accessor(name)
self.attrs[name] = metadata
end
def self.inherited(subclass)
subclass.instance_variable_set(:@attrs, @attrs.deep_dup)
end
end
class FHIR::Resource < FHIR::Model
attr 'id', 'type'=>'id', 'min'=>0, 'max'=>1
attr 'meta', 'type'=>'Meta', 'min'=>0, 'max'=>1
attr 'implicitRules', 'type'=>'uri', 'min'=>0, 'max'=>1
# ...
end It would make the models a bit more concise, although it might require removing the |
Sorry to throw out so many half-thought-through proposals, but could also consider module inheritance, maybe using module FHIR::Model
extend ActiveSupport::Concern
included do
attr 'id', 'type'=>'id', 'min'=>0, 'max'=>1
# ...
end
end
module FHIR::Resource
extend ActiveSupport::Concern
include FHIR::Model
end
module FHIR::DomainResource
extend ActiveSupport::Concern
include FHIR::Resource
end
module FHIR::BackboneElement
extend ActiveSupport::Concern
include FHIR::Model
end
class FHIR::Patient
include FHIR::DomainResource
end |
Unfortunately we don't have a ton of resources to put against giving this a shot right now. If you'd like to try some of these ideas out and open a PR, we'd happily merge it in if it doesn't cause any problems. |
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: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.
The text was updated successfully, but these errors were encountered: