Forcing MDHT to serialize the default unit of "1" for PQ data types

25 views
Skip to first unread message

Jeff Cardenas

unread,
Feb 24, 2026, 3:06:56 PM (4 days ago) Feb 24
to Edge Test Tool (ETT)
I'm getting an error like this when validating a CCDA against the SITE Validator:

The node '@unit' does not exist at the expected path /ClinicalDocument[1]/component[1]/structuredBody[1]/component[17]/section[1]/entry[1]/organizer[1]/component[3]/observation[1]/value[1] but is required as per the specification: If Observation/value is a physical quantity (xsi:type="PQ"), the unit of measure SHALL be selected from ValueSet UnitsOfMeasureCaseSensitive 2.16.840.1.113883.1.11.12839 DYNAMIC (CONF:1198-31484).

The value looks like this:
<value xsi:type="PQ" value="1.015"/>

So it's complaining that a unit isn't explicitly set like this:
<value xsi:type="PQ" value="1.015" unit="1"/>

This works when I manually change the XML test file I'm using, but the problem is I'm using MDHT.

When MDHT serializes the ClinicalDocument model, it leaves off the unit if it's "1" because that's what the default value is.
default-unit.png

Example code for reference:
PQ pq = DatatypesFactory.eINSTANCE.createPQ();
pq.setUnit("1"); // This gets left off during the serialization process
pq.setValue(new BigDecimal("1.015"));

Has anyone else that's using MDHT figured out a workaround for this? Is there an option that can be set somewhere so that it includes this default unit if it's set explicitly?

Jeff Cardenas

unread,
Feb 24, 2026, 8:37:58 PM (4 days ago) Feb 24
to Edge Test Tool (ETT)
It doesn't look like the CDAUtil class exposes any sort of options parameter for customizing the serialization process:
cda-util.png

So I extended the PQImpl class so it no longer thinks "1" is the default value for the unit:

public class PQImpl2 extends PQImpl {

    public PQImpl2() {
        super();
        this.unit = null;
    }

    @Override
    public boolean eIsSet(int featureId) {
        return featureId == DatatypesPackage.PQ__UNIT ? this.unit != null : super.eIsSet(featureId);
    }

}

And then instead of calling:
DatatypesFactory.eINSTANCE.createPQ(); 

I just return a new instance of PQImpl2. I created a utility class for this so that if I have to change the implementation in the future I'll just have to do it in one place.

I also had to create sub classes for the other PQ data types in this same way:
- IVL_PQ
- IVXB_PQ
- SXCM_PQ

With those changes, it properly serializes the data:

<value xsi:type="PQ" value="1.015" unit="1"/>

sean....@gmail.com

unread,
Feb 25, 2026, 9:55:11 AM (4 days ago) Feb 25
to Edge Test Tool (ETT)
Hi Jeff 

I have not seen too much  activity on MDHT developers and sorry that you ran into this conundrum 

The schema has a default of "1" for the unit concept 

The underlying runtime built ontop of ecore does not consider setting it to "1" as setting it
see below

but not sure that is the issue - are you able to post a snippet of the xml - which clinical statement you  are validating

It might be something to do with the vocabulary validation 

thanks

sean




@Override

public boolean eIsSet(int featureID) {

switch (featureID) {

case DatatypesPackage.PQ__VALUE:

return VALUE_EDEFAULT == null

? value != null

: !VALUE_EDEFAULT.equals(value);

case DatatypesPackage.PQ__UNIT:

return UNIT_EDEFAULT == null

? unit != null

: !UNIT_EDEFAULT.equals(unit);

case DatatypesPackage.PQ__TRANSLATION:

return translations != null && !translations.isEmpty();

}

return super.eIsSet(featureID);

}



Jeff Cardenas

unread,
Feb 25, 2026, 10:20:34 AM (4 days ago) Feb 25
to Edge Test Tool (ETT)
Hi Sean,

"The underlying runtime built ontop of ecore does not consider setting it to "1" as setting it"

I think this was the problem which is why I ended up just overriding it.

This was for the "Specific gravity of urine by test strip" lab result as outlined in 170.315_b1_toc_amb_svap_uscdiv3_sample1_v1.pdf.

I saw some other posts where people got around similar issues with dimensionless units where they just used string (ST) types instead, but I'm trying to make this part of my code generic where "Quantity" models are just converted to PQ.

Here's the observation that passes validation after my changes:

<observation classCode="OBS" moodCode="EVN">
    <templateId root="2.16.840.1.113883.10.20.22.4.2" extension="2023-05-01"/>
    <templateId root="2.16.840.1.113883.10.20.22.4.2" extension="2015-08-01"/>
    <templateId root="2.16.840.1.113883.10.20.22.4.2"/>
    <id root="2.16.840.1.12441" extension="result-organizer-1-observation-3"/>
    <code code="5811-5" codeSystem="2.16.840.1.113883.6.1" displayName="Specific gravity of urine by test strip">
        <originalText><reference value="#result-organizer-1-result-3-code"/></originalText>
    </code>
    <text><reference value="#result-organizer-1-result-3"/></text>
    <statusCode code="completed"/>
    <effectiveTime value="20150622"/>

    <value xsi:type="PQ" value="1.015" unit="1"/>
    <referenceRange>
        <observationRange>
            <value xsi:type="ST">1.005 – 1.030</value>
        </observationRange>
    </referenceRange>
</observation>
Reply all
Reply to author
Forward
0 new messages