Rails Multi Table Inheritance, Polymorphic association or Single Table Inheritance?
I am trying to implement the OpenEHR reference model in Rails (ActiveRecord), but I am finding some problems as it works with many different classes,
Here is the Composition chart :
As you can see, many classes "inherit" an attribute pair from Locatable
or Pathable
* (the whole reference is huge and almost every class inherits from it).
Also, it sets data_types like other classes, for example in the same composition class, language
is a class CODE_PHRASE
that has two attributes ( link ).
Therefore, I am facing two problems: 1) how can I inherit attributes from abstract classes, and 2) how can I "include" the "needed" classes.
For the first problem, I was thinking about using polymorphic associations.
For a second I thought about using the STI, but quickly find a set of almost similar models (they are actually the same): CompositionLanguage
, CompositionTerritory
, EntrySetting
, EntryEncoding
, that I use only attribute type
to "back links", for example: the composition class can have up to three attributes CODE_PHRASE
as all three links have a different attribute (language, scope and category), I thought I needed to know for associations (it makes no sense to know that a composition has 3 code_phrases, but I didn't know which one is the corresponding attribute). On the other hand, a class Entry
has an attribute setting
and encoding
( link ).
I understand there could be different approaches, but I'd really like to know if it might not be Rails (or ActiveRecord) for this. Or maybe I am missing conceptual information.
source to share
The openEHR RM specification has deeply nested inheritance and composite templates with tree hierarchies.
I have not been able to implement this nested inheritance of ActiveRecord. The following implementation is an example for simulating openEHR RM. I would be very glad if this example could help you.
source to share
You have looked at this project. https://github.com/skoba/openehr-rails
I think Shinji is using Active Record.
Personally, given the complex structure of the openEHR RM, if I was starting out I could use something like MongoDB with an ORM.
I pointed the openehr technical community to your question via the openehr technical list to see if others can help.
Yang
source to share