We now have the basic time types in the Foundation types spec. Both Duration and Iso8601_Duration are defined. For the archetype spec, the former is assumed, because ISO8601 syntax representation is used in archetypes.
The specification is much better (but different) in AOM2.
that's true, but in databases and XML it is, and it is mostly treated like a primitive data type - i.e. a non-identified, instance-only type - in most language libraries. Note - here I am talking about a primitive type 'Duration' (also Iso8601_duration), not types like DV_DURATION. For AOM2, we treat it and the other date/time primitives as proper primitive types, also Uri, etc, and it makes life much easier.
First: I agree with the distinction in datatypes between AOM and RM. The AOM should live as much as possible independent from the RM (I prefer completely independent), the RM should only deal with data-constructions and datatypes to describe target-data in.
Second: The archetype should be independent from the used computer language to build the AOM in. In many languages Duration is a valid datatype.
Java has it, Golang has it, C++ has it. And if it is not in a programming language, that language should be extended by a library which delivers the datatype.
But I’m a 1.0.2 implementer and I guess there are others. As far as I can see, there is no Duration class for 1.0.2. I would be good to add a disclaimer or errata comment for 1.0.2 maybe guiding to use ISO8601_DURATION or DV_DURATION in CDuration.
DV_DURATION has never been the target type of C_DURATION - DV_DURATION is a complex type in the DV_ORDERED hierarchy (i.e. a sibling more or less of DV_QUANTITY). I don’t know why they do that - that is not what the spec says. - thomas
Hi Thomas, the definition of DV_DURATION is clear to me
The issue is on the 1.0.2 specs, I guess they used DV_DURATION in C_DURATION because the referenced Duration class in C_DURATION was not included on the specs. This is the issue I’m pointing to, the missing class.
Clarifying that on an errata addendum would help to avoid such implementation mistakes, that are really caused by the missing information on the spec + interpretation to fill the gap.
BTW, this is one case that I detected because I’m doing research for a new course. There might be issues like this on other areas of 1.0.2, I mean missing classes referenced from AOM or AOP. I didn’t do a complete review of the specs.
I would love to migrate everything to baseline spec and use AOM2, but I can’t afford the cost right now. I’m sure others are on my same position.
Right - the ADL/AOM 1.4 specs made the assumption that each primitive constrainer type i.e. C_INTEGER, C_STRING, C_DATE, C_DURATION etc, constrained a same- or similarly named primitive type like Integer, String, Date, Duration etc that are assumed to be part of the technology environment. THey are normally part of the programming language, DB, or serialisation formalisms. I think this probably was not as clear as it should have been in that spec. In the AOM2/ADL2 specs, we have clarified this so that the same types (C_INTEGER etc) now refer to types that are defined in the Foundation spec of the BASE component. agree, we should do this - can you create a PR for this? Or add to an existing PR. hopefully that will change soon, because ADL2 is more regular and simpler than ADL1.4 - the ADL2 OPT for example is much easier to process. I’d be interested to know what the real costs are and to see what we can do to make the transition simpler, because staying with ADL1.4 is limiting system functionality for the future. the is now fixed. - thomas
Also will double check if the same happens with other types, but I think the only “odd” one that might not be correct to assume, is the Duration. For instance, Java 8 added the Duration as a base type, but it only handles day to seconds duration expressions, year, month, week are not supported. Each technology has it’s own quirks
Java 8 has a Duration for hours, minutes and seconds, and Period for years, months and days. Both implement a few interfaces with which you can abstract them.
No idea why they chose this, it’s quite annoying to work with. You can relatively easily implement your own variant of ChronoPeriof that supports all of the options.
But this is not about anything Java specific, just giving an example why Duration might not be good for an assumed type on the openEHR specs
On the other hand… (re)thinking: assumed types should not be considered as “supported by a programming language”, but “supported by a programming language or application” ***. For instance, it is not so difficult to create a Duration class ourselves on any programming language, or even use one of the many available libraries that deal with Duration types and are compatible with ISO8601 durations.
Considering that, we might need to clarify:
What “assumed type” really is (it seems most tend to think that should be supported by a programming language, need to double check the specs to see how this is defined, maybe is clearly defined but not highlighted enough).
Clarify the use of the Duration class from CDuration where Duration is not on the specs (we can say it is assumed considering assumed as the definition ***)
Complementing 2. we can propose support for Duration on many programming languages by recommending certain libraries or core types. This can be an ITS or just an addendum/errata to v1.0.2 specs.
I think those points will solve all the issues mentioned on this thread.
The Java 8 duration is indeed diffrent, but you can still use the Joda duration, or you can write your own duration class. In Golang the duration class is also limited, it is build around nanoseconds, but I wrote my own which is conform the OpenEhr specs, which was not that hard.
Maybe it is a good idea for the OpenEhr community to study the duration type again to see why in two major programming languages there is another approach build around nanoseconds and having conversions to hours, etc. Maybe there is another trend coming up. Maybe it is interesting to conform to these trends
Now I come to think about it, I remember reading somewhere that conversion durations to number of years or months is no longer desired because years and months do not have always the same number of nanoseconds.
Of course conversions to days and weeks is easy, although they are also not always the same, but that can be ignored, it is one second every few years.
We can revisit all the types we want, but we shouldn’t forget that types will be used for medical data, and maybe we don’t really need nanosecond precision.
There is in medical context need of a datatypes to express: “do this one time a month, for example on a specific date”.
But technically seen, this is not a duration, the maybe a need for another datatype to express this.
Using the duration for this may be a handy shortcut in specs, but it is not right. It is in fact misusing a datatype which does not support this expression. The ISO string should also be changed accordingly.