diff --git a/util/ValueSetHelper.ts b/util/ValueSetHelper.ts index b3781c1..4f094ca 100644 --- a/util/ValueSetHelper.ts +++ b/util/ValueSetHelper.ts @@ -111,25 +111,9 @@ export function minimizeTestCaseResources( codeInfo.primaryCodePath ) as fhir4.CodeableConcept[]; if (primaryCodeValue) { - if (matchingDRType.valueSets.length > 0) { - const vsCodesAndSystems = getValueSetCodes(matchingDRType.valueSets, measureBundle); - primaryCodeValue.forEach(pcv => { - if ( - vsCodesAndSystems.find(vscas => - pcv.coding?.find(c => c.code === vscas.code && c.system === vscas.system) - ) - ) { - newResources.push(r); - } - }); - } - if (matchingDRType.directCodes.length > 0) { - primaryCodeValue.forEach(pcv => { - if (matchingDRType.directCodes.find(dc => pcv.coding?.find(c => c.code === dc.code))) { - newResources.push(r); - } - }); - } + primaryCodeValue.forEach(pcv => { + checkCodesAndValueSets(pcv, matchingDRType, measureBundle, r, newResources); + }); } } else { const primaryCodeValue = fhirpath.evaluate( @@ -150,7 +134,14 @@ export function minimizeTestCaseResources( `${codeInfo.primaryCodePath}Coding` ) as fhir4.Coding; if (primaryCodeValue) { - if (matchingDRType.valueSets.length > 0) { + if ( + matchingDRType.directCodes.length > 0 && + matchingDRType.directCodes.find( + dc => dc.code === primaryCodeValue.code && dc.system === primaryCodeValue.system + ) + ) { + newResources.push(r); + } else if (matchingDRType.valueSets.length > 0) { const vsCodesAndSystems = getValueSetCodes(matchingDRType.valueSets, measureBundle); if ( vsCodesAndSystems.find( @@ -160,15 +151,6 @@ export function minimizeTestCaseResources( newResources.push(r); } } - if (matchingDRType.directCodes.length > 0) { - if ( - matchingDRType.directCodes.find( - dc => dc.code === primaryCodeValue.code && dc.system === primaryCodeValue.system - ) - ) { - newResources.push(r); - } - } } } } else {