Fan, Sarah wrote:
Hi Rong,
I am a Java Developer. As I am new to the API and very interested in exploring it, can I ask a very simple question? How do you construct a RM object based on the constraints defined in an archetype? Does the API has the function to do that, or the developer has to do it himself? Could you give me a simple code example?
Thank you in advance,
Fan,Yue
Hi Yue,
I will CC this to openehr-implementers list so others can follow the discussion as well, hope you don't mind. ![]()
Archetype based object creation is supported by this API, though the current implementation is not complete - e.g. archetype slot is not supported yet. We are constantly improving the status of the code as you can see from the bitkeeper logs. Any contribution in terms of bug report/patch/improvement is highly appreciated.
To try object creation, you need to:
1. create an Archetype definition in object form (normally it's done by the ADL parser parsing archetype definition in ADL syntax)
2. create a map for input values
3. create a map for system values - character setting, language etc
4. create a empty map for error message if any error occurs
5. finally call Archetype.buildRMObject()
Please see the unit test - org.openehr.am.ArchetypeTest for detailed usage demonstration. For more information regarding the design of archetype based object creation, see section 8 of the design document at http://www.openehr.org/repositories/kernel_java-dev/latest/docs/design.html
Please note that this specific part of the API for object creation is _NOT_ specified by the openEHR RM or AM spec docs, and it is still bit experimental. Therefore, it could change later on when more implementation experience is gained.
Since creation of archetype definition manually is a very tedious task, it limits the possibility to create complex archetype to use. One should use an ADL parser to create object form of archetype by parsing archetype in ADL form. We have done such a parser and will announce it very soon.
Regards,
Rong