Consistently support negative durations

Description

For DV_DURATION it says in the spec:

"A sign may be used to indicate the duration is backwards in time rather than forwards."

But then it insists on its value being ISO8601 which (in its pure version at least) doesn’t allow negatives.

However, negative durations are supported in various places, e.g. "-P1D" This is what the xml duration is doing as well (base on ISO8601 but allow negative), see https://www.w3.org/TR/xmlschema-2/#duration . Java and I believe .NET as well are doing similar things.

Seems like there is a little inconsistency in the spec and we should fix the spec

  • to indicate ISO8601 plus a ‘deviation for negation, in line with W3C etc etc’;

  • add Heather’s example of a negative adjusted age somewhere in the text to indicate the negation possibility.

Example/Use case from Heather Leslie
There is a clinical situation where you can have a negative ‘adjusted age’ where there is a premature infant, now chronologically 2 months old but born 3 months premature - they are said to have an adjusted, or corrected, age of -1 month. Clinically this is important when related to expected development/behaviour/functional capacity. If they were 3 months premature then you would only worry about their development related to their adjusted age, not their chronological age. By the age of 2 or 3, the difference has usually disappeared and adjusted age becomes less relevant.
So a negative (type of) age, which is clearly not permitted with DV_DURATION, is clinically necessary. And it should be able to be expressed in a combo of weeks, months +/- years.
It makes sense for both the chronological age and adjusted age to use the same data type.

For more details see the related discussion at https://discourse.openehr.org/t/duration-data-type/621

Activity

Show:
Sebastian Garde
September 9, 2020, 2:42 PM

If you insist on putting it in the pattern, what you suggest is reasonable in my view.

The interval approach just works though as soon as you allow negative numbers as well.

I find it less confusing; it keeps the interval orthogonal to the pattern… otherwise you have to start interpreting/validating:

  • Which of your 3 options contain a duration of 0?

  • What does {-PYMWD/|>=P1Y|} mean…do you want to run validations on that because it can never be fulfilled?

  • What does {PYMWD/|<=P1Y|} mean in constrast to {-PYMWD/|<=P1Y|} and {(+|-)PYMWD/|<=P1Y|} mean…arguably they mean the following: 1st: 0..1, 2nd: <=0y(!) including all negatives; 3rd: <= 1y.
    It just seems to be potentially very confusing.

It is also slightly inconsistent in that each of YMWD in the above pattern is used optionally (you don’t need to specify a week for example, you just can), whereas the “-” in -PYMWD would not be optional.

Thomas Beale
September 9, 2020, 4:43 PM

Good points, but how do we specify -ve when only the pattern is present?

Sebastian Garde
September 9, 2020, 5:56 PM

The pattern never excludes negatives as a possibility in my thinking. If you really ever only want negatives (or more likely: positives) you need to constrain the interval. It is a limitation for sure, but is it a problem?

Thomas Beale
September 9, 2020, 6:24 PM

Ah I see - I had missed you were thinking like that. I think that does make sense.

Ok, so we don’t really need to do anything in ADL other than include some examples, since negation is already available as an operator on all quantity-like primitive types (i.e. not date, time, date/time).

Bjørn Næss
September 21, 2020, 10:41 AM

We support this change and that it is defined as either negative or positive. Not some mixed way with minus within the duration expression.

Reporter

Sebastian Garde

Raised By

Sebastian Garde
Thomas Beale

Components

Affects versions

Configure