Thomas Beale wrote: > Hi Jim, Rong, > > I am not yet up to speed on the Java code, but will give some generic > answers, based on our previous Australian kernel implementation (based > on the pre-openEHR GeHR models).
Thomas, Thanks for sharing this with us. > > Until we get a proper standardised API defined for this, you can do it > how you like - as long as the archetype is respected. In our GeHR > implementation, we had two ways of doing it, approximately as follows: > > 1. insert_at_path(some_path, an_element) > Note that the path here is the runtime path, which is always unique. You > can thus always insert exactly where you want. > > 2. routines which navigated a cursor through a structure and then > allowed an insert once you had arrived where you wanted. This kind of > API had a lot of routines, and was a lot like a data structure library. > > I now believe the path-based approach to be clearer, more concise (i.e. > smaller API) and more in line with how people think today (i.e due to > XML-indoctrination;-). But neither is more right technically speaking. > > The main thing is that the insert_at_path() (or whatever you call it) > call must check the relevant archetype node that the insertion is > allowable, and it should fail if it is not. Your code should always know > in advance what node this is, due to the choosing of archetypes > beforehand (e.g. by the GUI forms). This should work for single object node insertion since most of the object nodes with their runtime name are already created. But I start to wonder if runtime path is enough for data creation from scratch, which requires: 1. path is unique so it can be used as key to group input values; 2. link to the original archetype node; 1) is satisfied by using current runtime path, 2) is not fully satisfied, since runtime path consists of mainly data node names (LOCATABLE.name()) and node names could either be the text value in the local language of archetype_node_id code of the node or explicitly set by the user. If more than one data node should be created by the same archetype node, the name should include both the text value and a modifier to make it unique. The algorithm used for generating unique name modifier can be predefined so it is possible to find the original archetype node. But it will fail if the name is explicitly set by a user. Besides, it is preferred to have archetype node id as the direct link instead of some text values in local languages, which mainly is meant to be used by humans. Perhaps a combination of both archetype id and some kind of modifier based on simple algorithm, eg. a counter could be used to form the path for object creation. It is bit like archetype path, but it is unique and easier to process. Examples: Suppose the "occurrences" of an archetype node[at0004] is "0..*", meaning from from zero to many nodes can be created by this archetype node. The archetype path to this node is: /[at0001]/action[at0002]/representation[at0003]/items[at0004]/ The paths used to bind input data to the archetype node, notice "-1" and "-2" used as suffix of the archetype node id, which stands for the first and second object node created from the same archetype node. /[at0001]/action[at0002]/representation[at0003]/items[at0004]-1/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0004]-2/value/ And this should work well with multiple optional nodes from same level or different levels. paths for two data nodes created out of two archetype nodes from same level, respectively: /[at0001]/action[at0002]/representation[at0003]/items[at0004]-1/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0004]-2/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0005]-1/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0005]-2/value/ paths for two data nodes created out of two archetype nodes having different parent data nodes originally from the same archetype node, respectively: /[at0001]/action[at0002]/representation[at0003]/items[at0004]-1/items[at0005]-1/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0004]-1/items[at0005]-2/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0004]-2/items[at0006]-1/value/ /[at0001]/action[at0002]/representation[at0003]/items[at0004]-2/items[at0006]-2/value/ Cheers, Rong - If you have any questions about using this list, please send a message to d.lloyd at openehr.org

