Building RMObject objects from Archetype objects

Hi all,
I looked at the packages in the TRUNK folder. After using the ADLParser
class to get an Archetype object from an adl file, my next wish was to
build a RMObject from that Archetype. I looked at the org.openehr.build
package but it does not seem to be using Archetype objects.
Basically I wonder if there is something like this class (that I called
RMArchetypedObjectBuilder) currently:
Archetype myArchetype = ....;
RMObject rmObject = RMArchetypedObjectBuilder.build(myArchetype); //
rmObject had the structure constraint defined in myArchetype
Thanks for your help,
Fabrice

This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie

Hi Fabrice,

Once there was a similar function in the old version of the Java kernel (http://www.openehr.org/svn/ref_impl_java/BRANCHES/Release-0.95/libraries/src/java/org/openehr/am/archetype/Archetype.java). There was some limitations of the implementation and it also become obvious such RM object construction should probably be done by a component close to the UI where the data entry occurs. Currently this logic for building RM objects is separated from the RM/AOM implementation and part of it becomes the current rm-builder.

Actually I think it’s quite straight-forward to create sample RM objects based on what’s defined in the archetype. Basically it’s a task of stepping through the AOM object tree and create the corespondent RM objects along the way. To make sure that valid RM object can be created, some default values need to defined and constraints from the archetype can also provide hints for sample values. With some rules to take different sample values from archetype constraints, this tool can be used to generate test-fixtures useful for archetype-testing.

Cheers,
Rong

Rong Chen wrote:

Hi Fabrice,

Once there was a similar function in the old version of the Java kernel (http://www.openehr.org/svn/ref_impl_java/BRANCHES/Release-0.95/libraries/src/java/org/openehr/am/archetype/Archetype.java). There was some limitations of the implementation and it also become obvious such RM object construction should probably be done by a component close to the UI where the data entry occurs. Currently this logic for building RM objects is separated from the RM/AOM implementation and part of it becomes the current rm-builder.

Actually I think it’s quite straight-forward to create sample RM objects based on what’s defined in the archetype. Basically it’s a task of stepping through the AOM object tree and create the corespondent RM objects along the way. To make sure that valid RM object can be created, some default values need to defined and constraints from the archetype can also provide hints for sample values. With some rules to take different sample values from archetype constraints, this tool can be used to generate test-fixtures useful for archetype-testing.

The name of this function in the ADL 1.5 spec has changed to prototype_value from default_value (the latter is used in the new templates). We have implemented this in the past in older kernels in Eiffel and VB, and the only data type that is difficult to invent a prototype value for is C_STRING based on a regular expression constraint - i.e. the tehcnical problem is how to generate a safe value from a regex pattern that actually satisfies that pattern. All the other data types are easy. No default values are needed (in the sense of template 'default’values); the prototype values can be completely generated from the constraint values. Note that it is only useful to do this once archetypes have been put into templates, and nodes of the type ARCHETYPE_SLOT and ARCHETYPE_INTERNAL_REF have disappeared (replaced by their reference targets). The only type that is special is CONSTRAINT_REF, for which you just generate some default fixed term (since you can’t know what the value set is until runtime, unless pre-populated)

  • thomas beale