https://github.com/DBCG/connectathon/blob/master/fhir401/input/pagecontent/cql/MATGlobalCommonFunctions-5.0.000.cql#L224 does not check that Encounter.diagnosis.use is 'billing' http://hl7.org/fhir/us/qicore/STU4/StructureDefinition-qicore-encounter-definitions.html#Encounter.diagnosis.use It also does not match pattern at http://hl7.org/fhir/us/qicore/STU4/patterns.html#322-inpatient-encounter-with-principal-diagnosis (which is wrong, should be D.use instead of D.role)