Hi Seref !
From: Seref Arikan
To: List for the development team for the reference implementation of openEHRin Java language and technologies.
Sent: Sunday, June 21, 2009 5:01 PM
Subject: Re: Get an instance of the RM from an Archetype
Hi Pablo,
I am not sure I can understand your approach clearly. For anyone interested in openEHR, it is vital to understand the differences and roles of different layers/component groups. There is a reason that AOM and RM are expressed differently, and they server different purposes. First of all, AOM is the result of a parsing action, it is the representation of an Archetype, so I can’t understand in which context you’d like to have it in a file??
The parsing action you describe is done by parsing an ADL file, I was talking about that file (I’m thinking of something like an ADL file that contains also the definition of the RM structure).
In OOP, this definition is like a class file where I declare fields and I can make instances from it.
For example if you see a domain class defined in GRAILS framework (http://grails.org/doc/1.1.x/ref/Domain%20Classes/constraints.html) tha constraints are defined in the same file (the class definition file) where is defined the class fields.
I just feel that if the definition of the RM structure and the constraints to that structure are done in diferent (ADL, XML, OWL, other) and separated ways (2 or more files), both can be inconsistent (may be a method for syntactic validation is required in the middle to check consistency between what is defined and the constraints over that definition), if you define both things in the same file, the parsing process can include this syntactic checking.
In the other hand I thought of the reusability of an archetype. If I define an RM structure (S) with the archetype (A), I force all other archetypes that have a reference to (A) to use the same RM structure (S). But I see that an archetype suggest a RM structure when it defines constraints, because it must constraint “something”, so anyway I have to use the structure suggested by the archetype. So when you reuse an archetype, I think you also reuse the RM structure that is constrained. I don’t know if my point is clear here… (sorry for my poor english :P)
I’m just brainstorming, all your tips and points of view are appreciated!
Here is a tip for you: do not try to invent generic methods, or in other words programmatic shortcuts when using openEHR. A lot of people reading the specs (including me) get the feeling that they can write some sort of code that can work in many dimensions and many cases. Somehow, it creates this illusion. This approach however, always ends up with frustration, since your generic method will start hitting more and more bumps on the way, due to increasing specialization in the leaf nodes of archetypes, in other words, RM types 
Good tip!
The only generic method I can think of now is the method that validates if the definition of the RM structure and the AOM (in ADL form) that constraints it are consistent. Later, with the ADL parser I can do the half of the job, and with an RM definition parser I can do the complete job.
Yes, you can write generic code for things like walking on an AOM structure, and some other things, but I can say that IMHO making an openEHR based system work requires you to write a lot of type specific, RM related code. I can’t see a magic way of coding to bypass this, and if there is someone out there who is willing to prove me wrong, I would love to hear them.
I don’t know if i’m trying this, I think I try to find a simple way to write all the type specific RM code having that “things can change” in mind, so make something that can change quickly with new medical knowledge or new requirements on the system. I also think that we have to write a lot of specific type code, this is the definition of the concepts in ours systems (a lot of concepts!!!)
So my suggestions are as follows:
Even if you are going to give a new method a try, start with the simpler approach. Assuming you are going to use Java, take a look at Rong’s excellent work in Java reference implementatation, especially check out unit test codes which create RM type instances, they will help you to get an understanding of how RM instances are created, and what they contain etc.
Great, I’ll look into those tests.
Start with this very simple task: read an ADL file, and use Rong’s unit test code to create values for the RM types you’ll encounter in AOM. Sounds very simple right? Just give it a try, and you’ll have an understanding of the differences of main parts.
If you can continously generalize a piece of code that satisfies your functional requirements, then I don’t think anyone can say that what you are doing is wrong. It is just that as you try to add new functionality, your approach may not handle the new cases, so be ready to throw away your code. There is a reason software is called software, it can change!
I agree
Regarding what you say about path, value method: it is the method that is used in Opereffa too, all I’m trying to say is, it gets more complicated than single name, value pairs, but the basic idea is usable, at least I’ve used it to create a piece of software, and it seems to work 
I went to the opereffa site but I can’t find what you tell me before (to see the relationships between RM, AOM and data) can you help me to find this?
Give me more details, and you’ll get clearer answers.
Great, thank you!
Cheers,
Pablo.
Kind regards
Seref