diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/service/EffectiveDataRequirementService.java b/src/main/java/gov/cms/mat/cql_elm_translation/service/EffectiveDataRequirementService.java index 59340b1..f5a8a4f 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/service/EffectiveDataRequirementService.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/service/EffectiveDataRequirementService.java @@ -7,15 +7,19 @@ import gov.cms.madie.cql_elm_translator.utils.cql.data.RequestData; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.cqframework.cql.cql2elm.CqlCompilerOptions; import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.LibraryBuilder; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.model.CompiledLibrary; import org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor; +import org.hl7.elm.r1.ExpressionDef; import org.springframework.stereotype.Service; import gov.cms.madie.cql_elm_translator.service.CqlLibraryService; +import java.util.stream.Collectors; + @Slf4j @Service @RequiredArgsConstructor @@ -64,6 +68,15 @@ public org.hl7.fhir.r5.model.Library getEffectiveDataRequirements( options.setCollapseDataRequirements(true); // removing duplicate data requirements options.setSignatureLevel(LibraryBuilder.SignatureLevel.Overloads); + // null indicates Included Library, pass all CQL Definitions to DataRequirementsProcessor + if (libraryDetails.getExpressions() == null) { + libraryDetails.setExpressions( + translatedLibrary.getLibrary().getStatements().getDef().stream() + .map(ExpressionDef::getName) + .filter(defName -> !StringUtils.equalsIgnoreCase(defName, "patient")) + .collect(Collectors.toSet())); + } + org.hl7.fhir.r5.model.Library effectiveDataRequirements = dqReqTrans.gatherDataRequirements( libraryManager,