The first issue 'no codes’please, is a real requirement and we shoukd fi d a way to make it work without a breaking change.
Ive certainly had situations where ineed to exclude particular datatypes but I dont feel that the current situation is a problem. Id always want to work by including specifically. It is very easy in AD to include all then exclude specifics.
Yes! We have been working a lot with demographic archetypes lately for the MPI functionalities supported by Atomik, there we need to define comparisons for certain fields to detect duplicated patient demographic records. All the DV_TEXT node comparisons need an extra DV_CODED_TEXT comparison, since that’s allowed by the model because of the inheritance.
Today while testing the MPI I tried to specify “this will be a DV_TEXT and won’t be a DV_CODED_TEXT” in the archetype/template, but I realized there is no way to do it, at least through the Archetype Designer, then I wasn’t sure if the AOM/ADL 1.4 actually supported that at all.
not matches would help, do you know if that’s formally supported in 1.4?
@ian.mcnicoll though the cases are different, it’s the same requirement conceptually: how to say “no”.
I understand the second case is just a shortcut.
I’m also thinking about “what’s not defined is allowed”. Consider a case of a compo with a slot to observation. That’s saying “we allow an observation here” but it’s not saying “we don’t allow anything else as a sibling of the observation”. This is a third case. It’s kind of the “final/finalized” classes and, IIRC, I think we discussed that with @thomas.beale some time ago (there might be a thing in ADL2 about that).
I am somewhat clear on that use case, the second one is more abstract. I am separating because the first could also be solved by a way of declaring that no specialisations are allowed.
This is where not matches or ~matches is declared, with a note that this is mainly relevant for leaves:
In practice applying this to data types may be challenging.
I remember thinking about not matches a very long time ago, and I think some of us even discussed it, but no-one’s ever asked for it for clinical modelling. It wouldn’t be that hard to implement, but of course the problem is that no current tools actually do, so there would have to be a new release of everything just to handle this now. Probably a good idea to put it in things like Archie though.
I don’t think that will work … the relationship between each constaint has always been an ??assumed OR and the DV_TEXT could always be re-constrained as
ELEMENT\[at0004\] occurrences matches {0..1} matches { – My cool element with types not allowed
value matches {
DV_CODED_TEXT matches *{\*}*
*DV_CODED_TEXT occurrences matches {0} matches {\*}*
}
}
In any case this would be quite a considerable change at archetype level, which we need to do, but it might be worth doing it more explicitly.
But the moment you go and check validity against the archetype you would find that the type you got was indeed not allowed, even if it could naturally occur by inheritance. In fact I would argue that if that would be the default interpretation, then any data type would be allowed anywhere as they would be still OR even if you constraint it to a specific type
To me this is where having node_id in the data type level would come in handy, because you could easily specialize those and leave the data type with no node_id for generic constraints on what types are allowed (or say things like “you can specialize the valueset all you want, but if you create your own valueset on the template it has to come from snomedct”)
Validators in general will check data passes ANY of the alternative type constraints, so the first that passes, the whole thing passes (the OR thing).
But this case from @yampeku is different, because the second constraint overlaps the first because of the inheritance of DV_CODED_TEXT from DV_TEXT. So if we consider the semantics of the underlying OO RM, after validating the data against the DV_TEXT constraint, validators should check if there is an alternative DV_CODED_TEXT constraint that overlaps the DV_TEXT constraint, and also validate against that, which is the support for the inheritance.
So maybe the OR thing works in 99% of the cases, but in this specific case it doesn’t.
My gut tells me this doesn’t require any spec change, but a clarification/guide for data validation, and maybe a case for conformance validation, that the inheritance on alternative types plays a role in data validation.
@thomas.beale you know the models inside out, what do you think?
@ian.mcnicoll I also agree that a specific notation for this kind of constraint would be a great shorthand addition for ADL, though I think the way Diego proposed to solve this case is also valid.
I already have in my To-Do list for this week, to test this specific case with the RM validator we have in the SDK to see its behavior and maybe correct it.
Ideally we don’t want to have to have any specific notation, because the requirement can be fixed generically, but it does require a long-discussed change to the RM, which is to add DV_PLAIN_TEXT, i.e. the RM should look like:
DV_TEXT // abstract class
DV_PLAIN_TEXT
DV_CODED_TEXT
We don’t have DV_PLAIN_TEXT today, but (as noted by @yampeku and @ian.mcnicoll above) you can get rid of specific subtypes (see ADL2 spec) by constraining instances of that type to 0-occurrences:
value ∈ {
DV_TEXT[at0003] ∈ {/.+/} -- non-empty string or whatever you want
DV_CODED_TEXT[at0005] occurrences ∈ {0}
}
You can’t redefine DV_TEXT in the above, in a template to be DV_CODED_TEXTbecause the parent still contains DV_CODED_TEXT[at0005] occurrences ∈ {0}, and if your redefinition would allow data that would violate the/any parent archetype, i.e. breaking the fundamental law of constraint specialisation.
@thomas.beale just to confirm: is the same solution you showed for ADL2 is still valid for ADL1.4? (I mean without the node_ids for the types as Diego proposed).
That is: even if the data at that path has a DV_CODED_TEXT, it will validate first against the exact same type DV_CODED_TEXT constraint, and will fail because of the occurrences 0..0. Then if only a DV_TEXT alternative is there, and a DV_CODED_TEXT value comes in the data for that path, it’ll only validate against the DV_TEXT, because of the inheritance, validating the DV_TEXT part of the coded text.
I don’t see any example or discussion of occurrences ∈ {0} in the ADL1.4 spec, but it’s clearly legal, and the interpretation of the kind of constraint I and others showed is clear. You’d probably have to test some tools in ADL1.4 mode and see what they do.
Very soon, we’ll be in a position to use only ADL2 tooling but write out OPT1.4 files, which should help all modelling activities get away from ADL1.4.