Problem displaying a self constructed archetype

Hi,

I have constructed a archetype, not following any known schema but on syntax correct, I believe.
I constructed it using objects and methods.

It is a very simple archetype, with one CComplexObject, called “AD”, a attribute-list, and there only one CAttribute, and there only one Element, a DvBoolean, and no ontology.

If I do a archetype.toString() it shows all the things, a bit on Java-level, which are in it. I printed it below in a fixed width character (for readability), the DvBoolean at is the end is recognizable

Bert Verhees wrote:

Hi,

I have constructed a archetype, not following any known schema but on syntax correct, I believe.
I constructed it using objects and methods.

It is a very simple archetype, with one CComplexObject, called “AD”, a attribute-list, and there only one CAttribute, and there only one Element, a DvBoolean, and no ontology.

If I do a archetype.toString() it shows all the things, a bit on Java-level, which are in it. I printed it below in a fixed width character (for readability), the DvBoolean at is the end is recognizable

definition=
org.openehr.am.archetype.constraintmodel.CComplexObject@d1e7c2
[
attributes=
[
org.openehr.am.archetype.constraintmodel.CMultipleAttribute@b51404
[
cardinality=org.openehr.am.archetype.constraintmodel.Cardinality@94cb8b
logger=org.apache.log4j.Logger@bf1d3b
rmAttributeName=complexContent
existence=REQUIRED
children=
[
org.openehr.am.archetype.constraintmodel.CPrimitiveObject@cc0e01
[
**item=org.openehr.am.archetype.constraintmodel.primitive.CBoolean@1a1c42f**

Hi Bert,
this line indicates that it is a C_BOOLEAN, not a constrained on a DV_BOOLEAN - a DV_BOOLEAN is a constructed type, whereas a C_BOOLEAN is a constraint on a primitive type Boolean.

**logger=org.apache.log4j.Logger@1570945**
**rmTypeName=DvBoolean**
**occurrences=<null>**
**nodeID=<null>**
**anyAllowed=false**
**path==/[at00001]/complexContent[at10000]/**
]
]
anyAllowed=false
path=/[at00001]/.complexContent
]
]
invariants=<null>
logger=org.apache.log4j.Logger@9fa8f
rmTypeName=AD
occurrences=<null>
nodeID=at00001
anyAllowed=false
path=/[at00001]/
]

Now I print the same with ADLOutputter, a Java class, and the DvBoolean does not show up, can someone please explain this to me?

definition
AD[at00001] matches {
complexContent cardinality matches {1..1; unordered} matches {true, false}
}

this is correct; the ADL for what you want, if you are using a DV_BOOLEAN, would look like this:

definition matches {
AD[at0001] matches {
complexContent existence matches {1..1; unordered} matches
BOOLEAN matches {
value matches {true, false}
}
}
}

It depends on what your reference model says: if it says that complexContent is of type Boolean, then your ADL is correct; if it says that it is of type DV_BOOLEAN, then the ADL I have given above is correct.

Note that unless AD is a container, it can’t have “cardinality”, only “existence” (I am assuming in the above it is not a container).

hope this helps,

  • thomas

this is correct; the ADL for what you want, if you are using a
DV_BOOLEAN, would look like this:

definition matches {
    AD[at0001] matches {
       complexContent existence matches {1..1; unordered} matches
          BOOLEAN matches {
             value matches {true, false}
          }
    }
}

It depends on what your reference model says: if it says that
complexContent is of type Boolean, then your ADL is correct; if it
says that it is of type DV_BOOLEAN, then the ADL I have given above is
correct.

Thanks, Thomas, your answer is very helpful, it is in fact the
CompexContent is not a Boolean. ComplexContent is XSD-syntax telling
that the complex content of a complex type will be described from this
point. In this case, a boolean is part of the complex content of the
type AD (which is address in HL7)

<explanation of why I do this>
I read in your documents that there is a match for almost all HL7
datatypes to OpenEhr datatypes, except for addresses, names, and a few
more. That is why I create archetypes for them (I generate them from
XSD-files), so that I can automatically convert from HL7 to OpenEhr
datatypes, and as I planned, start with a one to one storage from HL7
PrimaryCare DMIM in OpenEhr, and later move to a OpenEhr reference
model, and being able to do that step by step, and having an application
running in a few weeks, with 90% of the code of it generated
</explanation of why I do this>

Note that unless AD is a container, it can't have "cardinality", only
"existence" (I am assuming in the above it is not a container).

AD is the name of the HL7 type which is reflected here. So it is a
container, I did not want to use OpenEhr terminology to be clear what
the meaning is.

regards
Bert

definition
AD[at0001] matches {
complexContent existence matches {1..1} cardinality matches {1..1; unordered} matches{
BOOLEAN matches {
value matches {true, false}
}
}
}

Hi Thomas, please allow me another question, I know I always use a lot of words, but maybe this long question is fully satisfied with a short answer.

First, excuse me for using colours in this email, which messes up the email for flat-text email-agents. It was necessary in this case for readability

I created the archetype you sketched above, and I run it, and printed it toString()
I get following result (that is where I have a few questions about, and what I did not understand) (it is from 0.95-version, I changed it a bit for readability)

I found the step I missed, insert another CComplexObject and call it with rmTypeName=BOOLEAN. I never understood from the documentation that a CComplexObject was also meant to reflect a type.

I wonder, how does the parser know, is it because of the rmTypeName?
I could not find this in the documentation. But maybe I missed it.
I wonder, because words like BOOLEAN or TEXT are reserved words, it is not possible to use these words for other purposes as rmTypeName. I expected to find it in the ADL document, because one should know when writing an ADL-file, I was thinking.

I hope it is not too much trouble to help me find a answer to this question.

Thanks
Bert

org.openehr.am.archetype.constraintmodel.CComplexObject@10e1513
[
invariants=<null>
rmTypeName=AD
occurrences=<null>
nodeID=at0001
anyAllowed=false
path=/[at0001]/
attributes=
[
org.openehr.am.archetype.constraintmodel.CMultipleAttribute@b31a7c
[
anyAllowed=false
path=/[at0001]/.complexContent
cardinality=org.openehr.am.archetype.constraintmodel.Cardinality@dfc362
rmAttributeName=complexContent
existence=REQUIRED
children=
[
**org.openehr.am.archetype.constraintmodel.CComplexObject@17a7706**
**[**
**invariants=<null>**
**rmTypeName=BOOLEAN**
**occurrences=<null>**
**nodeID=<null>**
**anyAllowed=false**
**path=/[at0001]/complexContent/**
**attributes=**
[
org.openehr.am.archetype.constraintmodel.CSingleAttribute@11c55bb
[
anyAllowed=false
path=/[at0001]/complexContent/.value
rmAttributeName=value
existence=REQUIRED
children=
[
org.openehr.am.archetype.constraintmodel.CPrimitiveObject@1248f2b
[
item=org.openehr.am.archetype.constraintmodel.primitive.CBoolean@1e536d6
rmTypeName=DvBoolean
occurrences=<null>
nodeID=<null>
anyAllowed=false
path=/[at0001]/complexContent/value
]
]
]
]
]
]
]
]
]

Bert Verhees wrote:

definition
    AD[at0001] matches {
       complexContent existence matches {1..1} cardinality matches
{1..1; unordered} matches{
          BOOLEAN matches {
             value matches {true, false}
          }
    }
}

Hi Thomas, please allow me another question, I know I always use a lot
of words, but maybe this long question is fully satisfied with a short
answer.

First, excuse me for using colours in this email, which messes up the
email for flat-text email-agents. It was necessary in this case for
readability

no need to apologise, I love colours...

I created the archetype you sketched above, and I run it, and printed
it toString()
I get following result (that is where I have a few questions about,
and what I did not understand) (it is from 0.95-version, I changed it
a bit for readability)

I can see some 0.95-isms that should be gone in the current version:
* the paths no longer include /[atnnnn]/ at the front, they always start
with /attr_name
* paths no longer ever have "." characters in them

I found the step I missed, insert another CComplexObject and call it
with rmTypeName=BOOLEAN. I never understood from the documentation
that a CComplexObject was also meant to reflect a type.

based on the idea that every "object" must have a type in an OO system...

I wonder, how does the parser know, is it because of the rmTypeName?

Not sure about the Java parser, but the Eiffel one does differentiate
between names that start in upper case (types) and names that start in
lower case (attributes). You can sill use whichever convention you like
e.g. like I do with SECTION/items or in the Java way Section/items. It
is stated early in the cADL section of the document. I am pretty sure
that the Java parser also does this check. I know it is something that
should not strictly be necessary, but since every programming language
today seems to use first-letter-upper-case for type/class names, and
first-letter-lower-case for attribute and function names, I think it is
a reasonable simplification for the parser-writers.

I could not find this in the documentation. But maybe I missed it.
I wonder, because words like BOOLEAN or TEXT are reserved words, it is
not possible to use these words for other purposes as rmTypeName. I
expected to find it in the ADL document, because one should know when
writing an ADL-file, I was thinking.

these are not reserved words in ADL - the only reserved words are things
like "cardinality" and so on. Note that we tend to drop the "Dv" from
the DV_ types (or "DvXxxx" types in Java/C#) to make the archetypes more
readable for everyone, and to make them more re-usable outside a strict
openEHR environment. So - where I used "BOOLEAN" before, it is shorthand
for DV_BOOLEAN (or DvBoolean;-) - which is the openEHR data type of that
name, not the built-in "boolean" of programming languages. The openEHR
DvBoolean has a boolean value, and also inherits from DATA_VALUE, making
it usable as an openEHR "data type", e.g. in Element.value (of type
DataValue). You never need to mention built-in type names like String,
Integer, Boolean etc, since they are inferred by the parser looking at
their values - these are the leaf values in ADL. This,
{123} is constraint on an integer (must = 123)
{|100..200|} is a constraint on integer (must be between 100 and 200)
{123.456} is a real / or float constraint
{true} is a boolean
{"something"} is a string
{/..*/} is a regex pattern constraining a string

so you never see the words "integer" or "string" or "boolean" anywhere.

The boolean / DvBoolean types can be confusing, and it is one of the
reasons why we have the "Dv" in openEHR.

hope this helps.

- thomas