Stream: Covid-19 Response
Topic: Validation for MeasureReport
Keith Boone (Apr 19 2020 at 15:52):
I'm trying to track down the source of errors in the Build reported for my MeasureReport examples. I'm about to push a build that will show these errors. I cannot seem to track down where/why they are generated. It's not that I don't understand the logic, what I'm trying to figure out is WHERE these constraints are coming from, because I cannot find them in the Resource definitions. I'm guessing there's some custom validation code for resources which reference definitions. @Grahame Grieve @Eric Haas @Bryn Rhodes
Grahame Grieve (Apr 19 2020 at 22:24):
yes there is additional validation that enforces rules stated or implied by the definitions that are not explicitly stated. These are work in progress - do you think they're wrong?
Keith Boone (Apr 20 2020 at 00:56):
There are actually two problems:
- The Validator converts the resource to R5, and I'm getting an error from the R4 to R5 converter due to our use of of data-absent-reason. We report a count or a score that is in the measure, but indicate that the reason why @value is missing. The converter doesn't like this. As a result, several missing count/score values are being reported as in error by the validator, even though the element is present.
- We have several population measures (measure-population) in a group, further clarified with addition code values. They are each in fact a different, non-stratified measure-population from the same initial-population in a measure. I could make them measure-observation I guess, but they are just different counts of a population. Stratifier isn't appropriate because CDC doesn't want all possible ways the data could be stratified across the two facets, just two of the strata are reported: IP = Hospitalized Patients, MP1 = Hospitalized Patients in ICU, and MP2 = ICU patients on a ventilator, and CDC isn't interested in the ratios (they can compute that from the MPs if they choose).
Keith Boone (Apr 20 2020 at 01:00):
Here's the exception for the conversion error on count.
java.lang.NullPointerException
at org.hl7.fhir.convertors.VersionConvertor_40_50.convertInteger(VersionConvertor_40_50.java:249)
at org.hl7.fhir.convertors.VersionConvertor_40_50.convertType(VersionConvertor_40_50.java:3668)
at org.hl7.fhir.igtools.publisher.Publisher$TypeParserR4.parseType(Publisher.java:442)
at org.hl7.fhir.r5.utils.NarrativeGenerator.parseType(NarrativeGenerator.java:1146)
at org.hl7.fhir.r5.utils.NarrativeGenerator$BaseWrapperMetaElement.getBase(NarrativeGenerator.java:679)
at org.hl7.fhir.r5.utils.NarrativeGenerator.renderLeaf(NarrativeGenerator.java:1531)
at org.hl7.fhir.r5.utils.NarrativeGenerator.generateByProfile(NarrativeGenerator.java:1330)
at org.hl7.fhir.r5.utils.NarrativeGenerator.generateByProfile(NarrativeGenerator.java:1352)
at org.hl7.fhir.r5.utils.NarrativeGenerator.generateByProfile(NarrativeGenerator.java:1352)
at org.hl7.fhir.r5.utils.NarrativeGenerator.generate(NarrativeGenerator.java:1248)
at org.hl7.fhir.r5.utils.NarrativeGenerator.generate(NarrativeGenerator.java:1231)
at org.hl7.fhir.igtools.publisher.Publisher.generateNarratives(Publisher.java:938)
at org.hl7.fhir.igtools.publisher.Publisher.loadConformance(Publisher.java:3480)
at org.hl7.fhir.igtools.publisher.Publisher.createIg(Publisher.java:813)
at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:674)
at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:7103)
Grahame Grieve (Apr 20 2020 at 02:07):
this is reproducible in what is committed?
Keith Boone (Apr 20 2020 at 04:36):
Yes.
Keith Boone (Apr 20 2020 at 04:37):
I can probably create an even simpler example.
Keith Boone (Apr 20 2020 at 04:56):
public static org.hl7.fhir.r5.model.IntegerType convertInteger(org.hl7.fhir.r4.model.IntegerType src) throws FHIRException { org.hl7.fhir.r5.model.IntegerType tgt = new org.hl7.fhir.r5.model.IntegerType(src.getValue()); copyElement(src, tgt); return tgt; }
Does not check for null value in src.
problem could be related to Java unboxing? getValue() returns java.lang.Integer, but called constructor would be IntegerType(int value), and so null pointer error
Keith Boone (Apr 20 2020 at 05:27):
/** Demonstrate conversion failure */
package com.ainq.kboone.tools;
import org.hl7.fhir.convertors.VersionConvertor_40_50;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r5.model.IntegerType;
public class TestIntegerTypeConversion {
public static void main(String[] args) { testConversion(); } public static void testConversion() { IntegerType t2 = null; org.hl7.fhir.r4.model.IntegerType t = new org.hl7.fhir.r4.model.IntegerType(); t.addExtension().setUrl("http://example.com/Any-Value").setValue(new StringType("A String Extension")); t2 = VersionConvertor_40_50.convertInteger(t); }
}
Keith Boone (Apr 20 2020 at 05:29):
Initialization of tgt should probably be something like:
org.hl7.fhir.r5.model.IntegerType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.IntegerType(src.getValue()) : new org.hl7.fhir.r5.model.IntegerType();
Keith Boone (Apr 20 2020 at 09:45):
I have this fixed on a local branch, it was fairly straightforward:
Perform a file search/replace operation:
Search for:
org\.hl7\.fhir\.(dstu2|dstu3|r4|r5)\.model\.([A-Za-z0-9]+)Type tgt = new org\.hl7\.fhir\.(dstu2|dstu3|r4|r5)\.model\.([A-Za-z0-9]+)Type\(src\.getValue\(\)\);
Replace With:
org.hl7.fhir.$1.model.$2Type tgt = src.hasValue ?
new org.hl7.fhir.$3.model.$4Type(src.getValue()) :
new org.hl7.fhir.$3.model.$4Type();
Add the following test to VersionConverter_10_30Test:
@Test
public void testConvertEmptyValuedUnsignedInt() {
org.hl7.fhir.dstu2.model.UnsignedIntType input = new org.hl7.fhir.dstu2.model.UnsignedIntType();
input.addExtension().setUrl("http://example.com/AnyValue").setValue(new org.hl7.fhir.dstu2.model.StringType("A value"));
org.hl7.fhir.dstu3.model.UnsignedIntType output;
output = (org.hl7.fhir.dstu3.model.UnsignedIntType)VersionConvertor_10_30.convertType(input);
assertNull(output.getValue());
}
Grahame Grieve (Apr 20 2020 at 11:51):
@Mark Iantorno I'm way behind right now - can you look at this?
Mark Iantorno (Apr 20 2020 at 19:20):
Fix is here: https://github.com/hapifhir/org.hl7.fhir.core/pull/177
Last updated: Apr 12 2022 at 19:14 UTC