Skip to content

Commit

Permalink
Merge pull request #33 from MeasureAuthoringTool/feature/mat-7966-use…
Browse files Browse the repository at this point in the history
…-dataRequirementsProcessor-with-incl-libs

[MAT-7966] Use DataRequirementsProcessor to build Include Libraries Data Requirements
  • Loading branch information
jkotanchik-SB authored Dec 4, 2024
2 parents 6ee4bff + ebf8429 commit 295a1be
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 295a1be

Please sign in to comment.