We're updating the issue view to help you get more done.Learn more

Allow both pattern and interval constraint on Duration in Archetypes

Currently there is no way to specify a constraint on Duration such that both of the following can be specified at once:
- the allowed units are specified, e.g. the current PWD constraint allows only weeks and days
- the time limit, e.g. the current |P0W..P50W| allows this

This constraint is needed at least for the common duration constraint for pregnancy.

The existing syntax strings must continue to parse as they do now:

Example can be found online in this test archetype: http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/basics/adl-test-ENTRY.basic_types.v1.adl?op=file&rev=0&sc=0 (see duration_attribute_101 - 207)





Thomas Beale

Raised By

(Sam Heard) inactive

Change Description

A new piece of syntax is needed in cADL to support this constraint. It takes the form of the following example: some_duration matches {PWD/|P0W..P50W|} The production rule added to an ADL parser is as follows: c_duration_constraint: duration_pattern | duration_pattern '/' duration_interval_value -- new rule | duration_value | duration_interval_value ; where duration_pattern is a rule like the following (this one is from the Eiffel reference ADL parser): duration_pattern: V_ISO8601_DURATION_CONSTRAINT_PATTERN { if valid_iso8601_duration_constraint_pattern ($1) then -- this function performs further validation on the pattern to ensure it is iso8601 compliant create c_duration.make_from_pattern ($1) else raise_error report_error ("invalid duration constraint pattern; legal pattern: P[Y|y][M|m][W|w][D|d][T[H|h][M|m][S|s]] or P[W|w]") abort end } ; And the token V_ISO8601_DURATION_CONSTRAINT_PATTERN has a lexer rule like the following: -- the following includes the openEHR deviation from ISO8601, to allow 'W' to be mixed in with -- other designators P[yY]?[mM]?[Ww]?[dD]?T[hH]?[mM]?[sS]? | P[yY]?[mM]?[Ww]?[dD]? { last_token := V_ISO8601_DURATION_CONSTRAINT_PATTERN last_string_value := text } In the AOM, the invariant of C_DURATION is relaxed to allow both range and pattern to be set at the same time.

Impact Analysis

This work has already been done in tooling, and is in use in archetypes for about 6 months. The only work required in the specifications is to add examples and the production rule to the documenation.


Thomas Beale
(Sam Heard) inactive
Peter Gummer

Approved By



Fix versions

Due date