Jim Alateras wrote:
> Rong,
>
> I have a several questions related to the lifecycle of archetypes once
> they are created.
>
> Question 1
> ==========
>
> I use The following code fragment to create an object from an archetype
>
> rmobj = archetype.buildRMObject(valueMap, errorMap, sysmap());
>
> One of my constraints for this archetype is optional, as shown below
>
> ELEMENT[at0004] occurrences matches {0..1} matches {
> value matches {
> DVTEXT matches {
> value matches {/.+/}
> }
> }
>
> In the valueMap I don't supply a value for this element and therefore it
> is not created. The 'rmobj' instance is created as expected.
>
> At some later stage, I want to record a value against ELEMENT[at0004].
> Do I need to manipulate the 'rmobj directly as shown below
>
> Account account = (Account)rmobj;
> Element element = new Element("isDebitAccount",
> new DvText("isDebitAccount"), isDebitAccount);
> account.getDetails().items().add(element);
You can manipulate the in-memory object as you normally do in
non-archetype based software. But by doing that you take the risk to
leave logic specific to certain archetypes in your code, which would
break the constraints with the archetype if e.g the details is changed
in new definition of the archetype. The result is that your software
can't be as much adaptive as it could be with dependency to certain
archetype.
>
> or can I create it using a path expression?
Such feature doesn't exist now.
Instead of modify the object directly, you should perhaps create a new
one instead by using archetype.buildRMObject(). The reasons are:
1, you don't want to have any specific knowledge of details of certain
archetypes.
2, since the high level objects, Composition, Party, EHR etc, are always
versioned, you can always create new ones instead of overwriting the old
ones.
>
>
> Question 2
> ==========
> Is there a programmatic way to validate that an object conforms to the
> constraints of an archetype?
It seems to be a useful feature that doesn't exist right now, perhaps it
should be included as standard API in the aom specification. Something
like this in Archetype or CObject will be nice:
public boolean valid(Object value);
Then again, if you always create new objects instead of modifying you
wouldn't need this.
>
> Question 3
> ==========
> This relates to an earlier question. Can you explain the how "|" works
> in a path expression?
The separator should be "/". There are path syntax and examples in the
data_structures_im document.
>
>
>
> -
> If you have any questions about using this list,
> please send a message to d.lloyd at openehr.org
>
-
If you have any questions about using this list,
please send a message to d.lloyd at openehr.org