# General modeling question for DV\_QUANTITY with multiple properties

**URL:** <https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647>\
**Category:** Clinical\
**Created:** [24 May 2022 04:04 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647 "2022-05-24T04:04:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)\
**Post date:** [24 May 2022 04:04 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/1 "2022-05-24T04:04:51Z")

</div>

I was creating some examples for my clinical modeling students, and one example that I wanted to create was to allow recording different units for different physical properties in the same DV\_QUANTITY, then realized the Archetype Editor didn’t allow multiple “properties” in the same DV\_QUANTITY.

Spec-wise, in general, without considering any specific use case, would it be possible to create such archetype / ADL?

I think it’s not possible if using the archetype\_profile class C\_DV\_QUANTITY since it has only one field `property`, so multiple C\_DV\_QUANTITY objects would be needed to define the alternative `properties`, but that would also generate more node\_ids, making the paths to each C\_OBJECT different. Without using C\_DV\_QUANTITY and using just a C\_COMPLEX\_OBJECT I think it’s possible since the alternatives for the same path would be on C\_ATTRIBUTE, though the Archetype Editor doesn’t support that alternative definition.

---

<div class="post-metadata">

**Author:** ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)\
**Post date:** [29 May 2022 01:06 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/2 "2022-05-29T01:06:47Z")

</div>

I believe this pattern of having a DV\_QUANTITY constraint in AOM with multiple `property` values is not possible in the current AOM Profile model.

Though it made me think: even though we have AOM Profile classes, is it valid to use C\_COMPLEX\_OBJECTs to constraint DV\_QUANTITY? Because modeling tools don’t seem to support both C\_DV\_QUANTITY and C\_COMPLEX\_OBJECT.

Thanks.

---

<div class="post-metadata">

**Author:** ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)\
**Post date:** [31 May 2022 17:29 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/3 "2022-05-31T17:29:17Z")

</div>

> [@pablo](#):
>
> Spec-wise, in general, without considering any specific use case, would it be possible to create such archetype / ADL?

I think it’s a bit odd to want to do it, but it could be done in ADL2, which uses tuples for this kind of thing. You can [see an example here](https://github.com/openEHR/adl-archetypes/blob/master/ADL2-reference/features/aom_structures/tuples/openEHR-EHR-CLUSTER.lab_analyte-triglycerides.v0.0.1.adls).

The Quantity bit is:

```auto
value matches {
	DV_QUANTITY[id0.16] matches {
		property matches {[at0.0.1]}
		[magnitude, units] matches {
			[{|0.0..1000.0|}, {"mg/dL"}],
			[{|0.0..20.0|}, {"mmol/L"}]
		}
	}
}

```

This only varies on units and magnitude. Formally, a 3-tuple ca be formed with property as well.

However, I would think it is clearer to do it using alternatives for the different properties and then tuples for the units:

```auto
value matches {
	DV_QUANTITY[id0.16] matches {  
		property matches {[at0.0.1]} -- concentration
		[magnitude, units] matches {
			[{|0.0..1000.0|}, {"mg/dL"}],
			[{|0.0..20.0|}, {"mmol/L"}]
		}
	}
	DV_QUANTITY[id0.17] matches {
		property matches {[at0.0.2]} -- mass
		[magnitude, units] matches {
			[{|0.0..45.0|}, {"mg"}],
			[{|0.0..0.0015|}, {"oz"}]
		}
	}
}

```

---

<div class="post-metadata">

**Author:** ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)\
**Post date:** [31 May 2022 19:40 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/4 "2022-05-31T19:40:42Z")

</div>

Thanks @thomas.beale when I asked my first question I was thinking about a lab result archetype, when the numeric result could have many properties (concentration, volume, weight), or even a medication prescription where dosage could have also many different properties associated. IT seems by using the archetype profile C\_DV\_QUANTITY class in the archetype it is no possible to do that at the same node (have one path with many property units associated).

My second question is if it’s valid to constraint a DV\_QUANTITY using a C\_COMPLEX\_OBJECT from the AOM instead of a C\_DV\_QUANTITY from the archetype profile. Would an editor supporting both be compliant with openEHR?

All modeling tools I tried use the profile classes and don’t have an alternative for C\_COMPLEX\_OBJECT when constraining DV\_QUANTITY.

Thanks!

---

<div class="post-metadata">

**Author:** ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)\
**Post date:** [31 May 2022 20:19 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/5 "2022-05-31T20:19:55Z")

</div>

> [@pablo](#):
>
> if it’s valid to constraint a DV\_QUANTITY using a C\_COMPLEX\_OBJECT from the AOM instead of a C\_DV\_QUANTITY from the archetype profile

It is, even in ADL1.4, and should be done for simple constraints that don’t need C\_DV\_QUANTITY.

> [@pablo](#):
>
> All modeling tools I tried use the profile classes and don’t have an alternative for C\_COMPLEX\_OBJECT when constraining DV\_QUANTITY

Definitely a tooling question. Might be interesting to manually edit an archetype to have a normal C\_COMPLEX\_OBJECT constraint, and read it into one of the tools and see what happens.

---

<div class="post-metadata">

**Author:** ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)\
**Post date:** [1 June 2022 06:52 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/6 "2022-06-01T06:52:27Z")

</div>

> [@thomas.beale](#):
>
> > [@pablo](#):
> >
> > if it’s valid to constraint a DV\_QUANTITY using a C\_COMPLEX\_OBJECT from the AOM instead of a C\_DV\_QUANTITY from the archetype profile
> 
> It is, even in ADL1.4, and should be done for simple constraints that don’t need C\_DV\_QUANTITY.

Great! I’m not sure this is clear to all modeling tool developers though.

One interesting thing about C\_DV\_QUANTITY is the `property` constraint is not actually a constraint over a RM attribute, but kind of a terminology set constraint over the DV\_QUANTITY.units (I know UCUM is not exactly a terminology, I mean the `property` defines which possible units from the UCUM system could be used, then further constraining could be done at the `units` level, now that being a RM attribute).

Back to the initial question, then from what you mentioned, with C\_COMPLEX\_OBJECT it would be possible to define constraints for DV\_QUANTITY.units without a `property` constraint.

@yampeku is it possible to constraint a DV\_QUANTITY with C\_COMPLEX\_OBJECT instead of C\_DV\_QUANTITY by using LinkEHR?

> [@thomas.beale](#):
>
> > [@pablo](#):
> >
> > All modeling tools I tried use the profile classes and don’t have an alternative for C\_COMPLEX\_OBJECT when constraining DV\_QUANTITY
> 
> Definitely a tooling question. Might be interesting to manually edit an archetype to have a normal C\_COMPLEX\_OBJECT constraint, and read it into one of the tools and see what happens.

I believe this will also affect CDR implementers! I need to build a test case for this in the Conformance Test Suites 🙂

---

<div class="post-metadata">

**Author:** ![yampeku](https://discourse.openehr.org/user_avatar/discourse.openehr.org/yampeku/32/25_2.png) [@yampeku](https://discourse.openehr.org/u/yampeku)\
**Post date:** [1 June 2022 07:09 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/7 "2022-06-01T07:09:41Z")

</div>

Yes, we ended up adding domain types in the end, but the default usage was to be able to constraint rm types directly. For mapping we always need to get the standard equivalent for the domain types in order to choose the right alternative when doing mapping tables

---

<div class="post-metadata">

**Author:** ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)\
**Post date:** [1 June 2022 08:25 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/8 "2022-06-01T08:25:12Z")

</div>

> [@pablo](#):
>
> `property` defines which possible units from the UCUM system could be used

It usually does so implicitly, but it is not necessarily the case. The original idea was that property on its own could be constrained (e.g. to ‘concentration’) without saying anything about units (i.e. use whatever concentration units your hospital / equipment uses).

> [@pablo](#):
>
> C\_COMPLEX\_OBJECT it would be possible to define constraints for DV\_QUANTITY.units without a `property` constraint

See that example on Github I linked above, and imagine the `property` constraint is gone.

> [@yampeku](#):
>
> Yes, we ended up adding domain types in the end

Did you implement tuples? With that, I don’t see any need for domain types.

---

<div class="post-metadata">

**Author:** ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)\
**Post date:** [1 June 2022 09:19 UTC](https://discourse.openehr.org/t/general-modeling-question-for-dv-quantity-with-multiple-properties/2647/9 "2022-06-01T09:19:58Z")

</div>

> [@thomas.beale](#):
>
> > [@pablo](#):
> >
> > `property` defines which possible units from the UCUM system could be used
> 
> It usually does so implicitly, but it is not necessarily the case. The original idea was that property on its own could be constrained (e.g. to ‘concentration’) without saying anything about units (i.e. use whatever concentration units your hospital / equipment uses).

That kind of breaks the `normal` way of constraining, because `property` is not a physical attribute in the RM but an implicit concept behind the `units`. I’m guessing that is why this pattern is actually defined in the Archetype Profile model and not in the AOM itself, because the AOM only works over physical/explicit attributes of the RM (declared in a RM class).

Interesting… never though about that.
