From 12bc66a052fc652a1039c62801c2d4410910684d Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Tue, 14 Sep 2021 14:40:06 -0600 Subject: [PATCH 1/8] Add DataReqyurementsProcessor from cqframework elm --- pom.xml | 2 +- .../providers/DataRequirementsProvider.java | 59 ++++++++++++++ .../providers/MeasureOperationsProvider.java | 80 ++++++++++++++++++- 3 files changed, 138 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 62a72e0fe..a42c2995e 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ 1.3.1-SNAPSHOT 1.5.2-SNAPSHOT 1.2.1-SNAPSHOT - 1.5.3 + 1.5.4-SNAPSHOT 1.3.1-SNAPSHOT 1.7.30 diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java index fbbc32674..1d5f7ffab 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java @@ -9,10 +9,13 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; +import java.util.Set; +import java.util.HashSet; import java.util.stream.Collectors; import javax.inject.Inject; @@ -32,8 +35,10 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import org.cqframework.cql.cql2elm.CqlTranslator; +import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; +import org.cqframework.cql.cql2elm.model.TranslatedLibrary; import org.cqframework.cql.elm.execution.CodeDef; import org.cqframework.cql.elm.execution.CodeSystemDef; import org.cqframework.cql.elm.execution.ExpressionDef; @@ -42,9 +47,11 @@ import org.cqframework.cql.elm.execution.Library; import org.cqframework.cql.elm.execution.ValueSetDef; import org.cqframework.cql.elm.execution.VersionedIdentifier; +import org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor; import org.cqframework.cql.tools.formatter.CqlFormatterVisitor; import org.cqframework.cql.tools.formatter.CqlFormatterVisitor.FormatResult; import org.hl7.elm.r1.ValueSetRef; +import org.hl7.fhir.convertors.VersionConvertor_40_50; import org.hl7.fhir.r4.model.Attachment; import org.hl7.fhir.r4.model.Base64BinaryType; import org.hl7.fhir.r4.model.CodeableConcept; @@ -56,12 +63,17 @@ import org.hl7.fhir.r4.model.ParameterDefinition; import org.hl7.fhir.r4.model.RelatedArtifact; import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r5.model.CanonicalType; +import org.hl7.fhir.r5.model.Extension; +import org.hl7.fhir.r5.model.Meta; import org.opencds.cqf.common.helpers.TranslatorHelper; import org.opencds.cqf.cql.engine.execution.LibraryLoader; import org.opencds.cqf.tooling.measure.r4.CodeTerminologyRef; import org.opencds.cqf.tooling.measure.r4.CqfMeasure; import org.opencds.cqf.tooling.measure.r4.TerminologyRef; import org.opencds.cqf.tooling.measure.r4.TerminologyRef.TerminologyRefType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import ca.uhn.fhir.cql.common.provider.LibraryResolutionProvider; @@ -72,14 +84,44 @@ @Component public class DataRequirementsProvider { + private static final Logger logger = LoggerFactory.getLogger(DataRequirementsProvider.class); private LibraryHelper libraryHelper; @Inject public DataRequirementsProvider(LibraryHelper libraryHelper) { this.libraryHelper = libraryHelper; + } + + public org.hl7.fhir.r4.model.Library getModuleDefinitionLibrary(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options){ + + org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); + + Set expressionList = getExpressions(measureToUse); + DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor(); + + org.hl7.fhir.r5.model.Library libraryR5 = dqReqTrans.gatherDataRequirements(libraryManager, translatedLibrary, options, expressionList, true); + org.hl7.fhir.r4.model.Library library = (org.hl7.fhir.r4.model.Library) VersionConvertor_40_50.convertResource(libraryR5); + + return library; + } + private Set getExpressions(org.hl7.fhir.r5.model.Measure measureToUse) { + Set expressionSet = new HashSet<>(); + measureToUse.getSupplementalData().forEach(supData->{ + expressionSet.add(supData.getCriteria().getExpression()); + }); + measureToUse.getGroup().forEach(groupMember->{ + groupMember.getPopulation().forEach(population->{ + expressionSet.add(population.getCriteria().getExpression()); + }); + groupMember.getStratifier().forEach(stratifier->{ + expressionSet.add(stratifier.getCriteria().getExpression()); + }); + }); + return expressionSet; } + // For creating the CQF measure we need to: // 1. Find the Primary Library Resource // 2. Load the Primary Library as ELM. This will recursively load the dependent @@ -96,6 +138,23 @@ public CqfMeasure createCqfMeasure(Measure measure, return this.createCqfMeasure(measure, libraryMap); } + public org.hl7.fhir.r4.model.Library getLibraryFromMeasure(Measure measure, + LibraryResolutionProvider libraryResourceProvider) { + + org.hl7.fhir.r4.model.Library primaryLibrary = null; + Iterator var6 = measure.getLibrary().iterator(); + + String library= null; + while(var6.hasNext()) { + org.hl7.fhir.r4.model.CanonicalType ref = (org.hl7.fhir.r4.model.CanonicalType) var6.next(); + library = (String) ref.getValue(); + + } + primaryLibrary = libraryHelper.resolveLibraryReference(libraryResourceProvider, library); + + return primaryLibrary; + } + private Map> createLibraryMap(Measure measure, LibraryResolutionProvider libraryResourceProvider) { LibraryLoader libraryLoader = this.libraryHelper.createLibraryLoader(libraryResourceProvider); diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java index 6aab78451..4dc7f9969 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java @@ -1,7 +1,10 @@ package org.opencds.cqf.r4.providers; +import java.io.InputStream; +import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Arrays; +import java.util.Base64; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -13,14 +16,20 @@ import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; +import ca.uhn.fhir.jpa.rp.r4.LibraryResourceProvider; import com.google.common.base.Strings; +import org.cqframework.cql.cql2elm.CqlTranslator; +import org.cqframework.cql.cql2elm.CqlTranslatorOptions; +import org.cqframework.cql.cql2elm.LibraryManager; +import org.cqframework.cql.cql2elm.ModelManager; import org.hibernate.cfg.NotYetImplementedException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; +import org.hl7.fhir.r4.model.Attachment; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.CanonicalType; @@ -32,6 +41,7 @@ import org.hl7.fhir.r4.model.Group; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Identifier; +import org.hl7.fhir.r4.model.Library; import org.hl7.fhir.r4.model.ListResource; import org.hl7.fhir.r4.model.Measure; import org.hl7.fhir.r4.model.MeasureReport; @@ -49,6 +59,8 @@ import org.opencds.cqf.common.config.HapiProperties; import org.opencds.cqf.common.evaluation.EvaluationProviderFactory; import org.opencds.cqf.common.helpers.DateHelper; +import org.opencds.cqf.common.helpers.TranslatorHelper; +import org.opencds.cqf.common.providers.LibraryContentProvider; import org.opencds.cqf.cql.engine.execution.LibraryLoader; import org.opencds.cqf.r4.evaluation.MeasureEvaluation; import org.opencds.cqf.r4.evaluation.MeasureEvaluationSeed; @@ -95,7 +107,7 @@ public class MeasureOperationsProvider { private static final Logger logger = LoggerFactory.getLogger(MeasureOperationsProvider.class); @Inject - public MeasureOperationsProvider(DaoRegistry registry, EvaluationProviderFactory factory, + public MeasureOperationsProvider(DaoRegistry registry, EvaluationProviderFactory factory, LibraryResourceProvider libraryResourceProvider, NarrativeProvider narrativeProvider, HQMFProvider hqmfProvider, LibraryResolutionProvider libraryResolutionProvider, MeasureResourceProvider measureResourceProvider, DataRequirementsProvider dataRequirementsProvider, LibraryHelper libraryHelper) { @@ -110,6 +122,28 @@ public MeasureOperationsProvider(DaoRegistry registry, EvaluationProviderFactory this.libraryHelper = libraryHelper; } + private ModelManager getModelManager() { + return new ModelManager(); + } + + private LibraryManager getLibraryManager(ModelManager modelManager) { + LibraryManager libraryManager = new LibraryManager(modelManager); + libraryManager.getLibrarySourceLoader().clearProviders(); + libraryManager.getLibrarySourceLoader().registerProvider(getLibrarySourceProvider()); + + return libraryManager; + } + + private LibraryContentProvider librarySourceProvider; + + private LibraryContentProvider getLibrarySourceProvider() { + if (librarySourceProvider == null) { + librarySourceProvider = new LibraryContentProvider( + this.libraryResolutionProvider, x -> x.getContent(), x -> x.getContentType(), x -> x.getData()); + } + return librarySourceProvider; + } + @Operation(name = "$hqmf", idempotent = true, type = Measure.class) public Parameters hqmf(@IdParam IdType theId) { Measure theResource = this.measureResourceProvider.getDao().read(theId); @@ -880,7 +914,49 @@ public org.hl7.fhir.r4.model.Library dataRequirements(@IdParam IdType theId, @OperationParam(name = "endPeriod") String endPeriod) throws InternalErrorException, FHIRException { Measure measure = this.measureResourceProvider.getDao().read(theId); - return this.dataRequirementsProvider.getDataRequirements(measure, this.libraryResolutionProvider); + + ModelManager modelManager = this.getModelManager(); + LibraryManager libraryManager = this.getLibraryManager(modelManager); + + Library library = dataRequirementsProvider.getLibraryFromMeasure(measure, libraryResolutionProvider); + + if (library == null) { + throw new RuntimeException("Could not load measure library."); + } + + CqlTranslator translator = TranslatorHelper.getTranslator(getContentStream(library), libraryManager, modelManager); + + if (translator.getErrors().size() > 0) { + throw new RuntimeException("Errors during library compilation."); + } + + return this.dataRequirementsProvider.getModuleDefinitionLibrary(measure, libraryManager, translator.getTranslatedLibrary(), getTranslatorOptions()); + } + + + private CqlTranslatorOptions getTranslatorOptions() { + CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions(); + cqlTranslatorOptions.getFormats().add(CqlTranslator.Format.JSON); + cqlTranslatorOptions.getOptions().add(CqlTranslator.Options.EnableAnnotations); + cqlTranslatorOptions.setAnalyzeDataRequirements(true); + cqlTranslatorOptions.setCollapseDataRequirements(true); + return cqlTranslatorOptions; + } + + private InputStream getContentStream(org.hl7.fhir.r4.model.Library library) { + Attachment cql = null; + for (Attachment a : library.getContent()) { + if (a.getContentType().equals("text/cql")) { + cql = a; + break; + } + } + + if (cql == null) { + return null; + } + + return new ByteArrayInputStream(Base64.getDecoder().decode(cql.getDataElement().getValueAsString())); } @SuppressWarnings("unchecked") From d9afc02411af94ec158f9bb8f6c1bf838c3e9091 Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Tue, 14 Sep 2021 14:47:27 -0600 Subject: [PATCH 2/8] Add measure functions --- .../providers/DataRequirementsProvider.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java index 1d5f7ffab..930772f91 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -93,6 +94,28 @@ public DataRequirementsProvider(LibraryHelper libraryHelper) { this.libraryHelper = libraryHelper; } + /* + public org.hl7.fhir.r5.model.Measure createMeasure(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + + org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); + + org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(measureToUse, libraryManager, translatedLibrary, options); + measureToUse.setDate(new Date()); + setMeta(measureToUse, moduleDefinitionLibrary); + clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"); + clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"); + clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"); + clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"); + clearRelatedArtifacts(measureToUse); + setParameters(measureToUse, moduleDefinitionLibrary); + setDataRequirements(measureToUse, moduleDefinitionLibrary); + setDirectReferenceCode(measureToUse, moduleDefinitionLibrary); + setLogicDefinition(measureToUse, moduleDefinitionLibrary); + measureToUse.setRelatedArtifact(moduleDefinitionLibrary.getRelatedArtifact()); + + return measureToUse; + } +*/ public org.hl7.fhir.r4.model.Library getModuleDefinitionLibrary(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options){ org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); @@ -122,6 +145,68 @@ private Set getExpressions(org.hl7.fhir.r5.model.Measure measureToUse) { return expressionSet; } + private void clearMeasureExtensions(org.hl7.fhir.r5.model.Measure measure, String extensionUrl) { + List extensionsToRemove = measure.getExtensionsByUrl(extensionUrl); + measure.getExtension().removeAll(extensionsToRemove); + } + + private void clearRelatedArtifacts(org.hl7.fhir.r5.model.Measure measure) { + measure.getRelatedArtifact().removeIf(r -> r.getType() == org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + } + + private void setLogicDefinition(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + moduleDefinitionLibrary.getExtension().forEach(extension -> { + if (extension.getUrl().equalsIgnoreCase("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition")) { + measureToUse.addExtension(extension); + } + }); + } + + private void setDirectReferenceCode(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + moduleDefinitionLibrary.getExtension().forEach(extension -> { + if(extension.getUrl().equalsIgnoreCase("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode")) { + measureToUse.addExtension(extension); + } + }); + } + + private void setDataRequirements(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + moduleDefinitionLibrary.getDataRequirement().forEach(dataRequirement -> { + Extension dataReqExtension = new Extension(); + dataReqExtension.setUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"); + dataReqExtension.setValue(dataRequirement); + measureToUse.addExtension(dataReqExtension); + }); + } + + private void setParameters(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + Set parameterName = new HashSet<>(); + moduleDefinitionLibrary.getParameter().forEach(parameter->{ + if(!parameterName.contains(parameter.getName())) { + Extension parameterExtension = new Extension(); + parameterExtension.setUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"); + parameterExtension.setValue(parameter); + measureToUse.addExtension(parameterExtension); + parameterName.add(parameter.getName()); + } + }); + } + + private void setMeta(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary){ + if (measureToUse.getMeta() == null) { + measureToUse.setMeta(new Meta()); + } + boolean hasProfileMarker = false; + for (CanonicalType canonical : measureToUse.getMeta().getProfile()) { + if ("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm".equals(canonical.getValue())) { + hasProfileMarker = true; + } + } + if (!hasProfileMarker) { + measureToUse.getMeta().addProfile("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"); + } + } + // For creating the CQF measure we need to: // 1. Find the Primary Library Resource // 2. Load the Primary Library as ELM. This will recursively load the dependent From f8e2dcec6c879720a72d7ebce5f207cbf9f85eca Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Tue, 14 Sep 2021 18:45:12 -0600 Subject: [PATCH 3/8] refactor functions --- .../cqf/common/helpers/TranslatorHelper.java | 10 ++++ .../opencds/cqf/r4/helpers/LibraryHelper.java | 18 +++++++ .../providers/DataRequirementsProvider.java | 53 +++++++++++-------- .../providers/MeasureOperationsProvider.java | 42 +++------------ 4 files changed, 65 insertions(+), 58 deletions(-) diff --git a/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java b/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java index 53607fa17..4a019c92f 100644 --- a/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java +++ b/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java @@ -10,6 +10,7 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.CqlTranslatorException; +import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.cqframework.cql.elm.execution.Library; @@ -81,4 +82,13 @@ public static Library translateLibrary(InputStream cqlStream, LibraryManager lib public static Library translateLibrary(CqlTranslator translator) { return readLibrary(new ByteArrayInputStream(translator.toXml().getBytes(StandardCharsets.UTF_8))); } + + public static CqlTranslatorOptions getTranslatorOptions() { + CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions(); + cqlTranslatorOptions.getFormats().add(CqlTranslator.Format.JSON); + cqlTranslatorOptions.getOptions().add(CqlTranslator.Options.EnableAnnotations); + cqlTranslatorOptions.setAnalyzeDataRequirements(true); + cqlTranslatorOptions.setCollapseDataRequirements(true); + return cqlTranslatorOptions; + } } \ No newline at end of file diff --git a/r4/src/main/java/org/opencds/cqf/r4/helpers/LibraryHelper.java b/r4/src/main/java/org/opencds/cqf/r4/helpers/LibraryHelper.java index 971142be6..a75216de5 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/helpers/LibraryHelper.java +++ b/r4/src/main/java/org/opencds/cqf/r4/helpers/LibraryHelper.java @@ -1,5 +1,8 @@ package org.opencds.cqf.r4.helpers; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Base64; import java.util.Collections; import java.util.List; import java.util.Map; @@ -99,4 +102,19 @@ protected Boolean translatorOptionsMatch(Library library) { } }; } + + public static InputStream extractContentStream(org.hl7.fhir.r4.model.Library library) { + Attachment cql = null; + for (Attachment a : library.getContent()) { + if (a.getContentType().equals("text/cql")) { + cql = a; + break; + } + } + + if (cql == null) { + return null; + } + return new ByteArrayInputStream(Base64.getDecoder().decode(cql.getDataElement().getValueAsString())); + } } diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java index 930772f91..aed3ad912 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java @@ -87,6 +87,12 @@ public class DataRequirementsProvider { private static final Logger logger = LoggerFactory.getLogger(DataRequirementsProvider.class); + private static String EXTENSION_URL_PARAMETER = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"; + private static String EXTENSION_URL_DATA_REQUIREMENT = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"; + private static String EXTENSION_URL_REFERENCE_CODE = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"; + private static String EXTENSION_URL_LOGIC_DEFINITION = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"; + private static String EXTENSION_URL_COMPUTABLE_MEASURE = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"; + private LibraryHelper libraryHelper; @Inject @@ -94,28 +100,31 @@ public DataRequirementsProvider(LibraryHelper libraryHelper) { this.libraryHelper = libraryHelper; } - /* - public org.hl7.fhir.r5.model.Measure createMeasure(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + + public Measure createMeasure(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); + org.hl7.fhir.r4.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(r4Measure, libraryManager, translatedLibrary, options); + + org.hl7.fhir.r5.model.Library moduleDefinitionLibraryR5 = (org.hl7.fhir.r5.model.Library) VersionConvertor_40_50.convertResource(moduleDefinitionLibrary); - org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(measureToUse, libraryManager, translatedLibrary, options); measureToUse.setDate(new Date()); - setMeta(measureToUse, moduleDefinitionLibrary); - clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"); - clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"); - clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"); - clearMeasureExtensions(measureToUse, "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"); + setMeta(measureToUse, moduleDefinitionLibraryR5); + clearMeasureExtensions(measureToUse, EXTENSION_URL_PARAMETER); + clearMeasureExtensions(measureToUse, EXTENSION_URL_DATA_REQUIREMENT); + clearMeasureExtensions(measureToUse, EXTENSION_URL_REFERENCE_CODE); + clearMeasureExtensions(measureToUse, EXTENSION_URL_LOGIC_DEFINITION); clearRelatedArtifacts(measureToUse); - setParameters(measureToUse, moduleDefinitionLibrary); - setDataRequirements(measureToUse, moduleDefinitionLibrary); - setDirectReferenceCode(measureToUse, moduleDefinitionLibrary); - setLogicDefinition(measureToUse, moduleDefinitionLibrary); - measureToUse.setRelatedArtifact(moduleDefinitionLibrary.getRelatedArtifact()); - - return measureToUse; + setParameters(measureToUse, moduleDefinitionLibraryR5); + setDataRequirements(measureToUse, moduleDefinitionLibraryR5); + setDirectReferenceCode(measureToUse, moduleDefinitionLibraryR5); + setLogicDefinition(measureToUse, moduleDefinitionLibraryR5); + measureToUse.setRelatedArtifact(moduleDefinitionLibraryR5.getRelatedArtifact()); + + org.hl7.fhir.r4.model.Measure measureR4 = (org.hl7.fhir.r4.model.Measure) VersionConvertor_40_50.convertResource(measureToUse); + return measureR4; } -*/ + public org.hl7.fhir.r4.model.Library getModuleDefinitionLibrary(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options){ org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); @@ -156,7 +165,7 @@ private void clearRelatedArtifacts(org.hl7.fhir.r5.model.Measure measure) { private void setLogicDefinition(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { moduleDefinitionLibrary.getExtension().forEach(extension -> { - if (extension.getUrl().equalsIgnoreCase("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition")) { + if (extension.getUrl().equalsIgnoreCase(EXTENSION_URL_LOGIC_DEFINITION)) { measureToUse.addExtension(extension); } }); @@ -164,7 +173,7 @@ private void setLogicDefinition(org.hl7.fhir.r5.model.Measure measureToUse, org. private void setDirectReferenceCode(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { moduleDefinitionLibrary.getExtension().forEach(extension -> { - if(extension.getUrl().equalsIgnoreCase("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode")) { + if(extension.getUrl().equalsIgnoreCase(EXTENSION_URL_REFERENCE_CODE)) { measureToUse.addExtension(extension); } }); @@ -173,7 +182,7 @@ private void setDirectReferenceCode(org.hl7.fhir.r5.model.Measure measureToUse, private void setDataRequirements(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { moduleDefinitionLibrary.getDataRequirement().forEach(dataRequirement -> { Extension dataReqExtension = new Extension(); - dataReqExtension.setUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"); + dataReqExtension.setUrl(EXTENSION_URL_DATA_REQUIREMENT); dataReqExtension.setValue(dataRequirement); measureToUse.addExtension(dataReqExtension); }); @@ -184,7 +193,7 @@ private void setParameters(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.f moduleDefinitionLibrary.getParameter().forEach(parameter->{ if(!parameterName.contains(parameter.getName())) { Extension parameterExtension = new Extension(); - parameterExtension.setUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"); + parameterExtension.setUrl(EXTENSION_URL_PARAMETER); parameterExtension.setValue(parameter); measureToUse.addExtension(parameterExtension); parameterName.add(parameter.getName()); @@ -198,12 +207,12 @@ private void setMeta(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5 } boolean hasProfileMarker = false; for (CanonicalType canonical : measureToUse.getMeta().getProfile()) { - if ("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm".equals(canonical.getValue())) { + if (EXTENSION_URL_COMPUTABLE_MEASURE.equals(canonical.getValue())) { hasProfileMarker = true; } } if (!hasProfileMarker) { - measureToUse.getMeta().addProfile("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"); + measureToUse.getMeta().addProfile(EXTENSION_URL_COMPUTABLE_MEASURE); } } diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java index 4dc7f9969..6be7bb751 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java @@ -1,10 +1,7 @@ package org.opencds.cqf.r4.providers; -import java.io.InputStream; -import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Base64; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -16,11 +13,9 @@ import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; -import ca.uhn.fhir.jpa.rp.r4.LibraryResourceProvider; import com.google.common.base.Strings; import org.cqframework.cql.cql2elm.CqlTranslator; -import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; import org.hibernate.cfg.NotYetImplementedException; @@ -107,7 +102,7 @@ public class MeasureOperationsProvider { private static final Logger logger = LoggerFactory.getLogger(MeasureOperationsProvider.class); @Inject - public MeasureOperationsProvider(DaoRegistry registry, EvaluationProviderFactory factory, LibraryResourceProvider libraryResourceProvider, + public MeasureOperationsProvider(DaoRegistry registry, EvaluationProviderFactory factory, NarrativeProvider narrativeProvider, HQMFProvider hqmfProvider, LibraryResolutionProvider libraryResolutionProvider, MeasureResourceProvider measureResourceProvider, DataRequirementsProvider dataRequirementsProvider, LibraryHelper libraryHelper) { @@ -909,7 +904,7 @@ else if (values.get(0) instanceof Reference // TODO - this needs a lot of work @Operation(name = "$data-requirements", idempotent = true, type = Measure.class) - public org.hl7.fhir.r4.model.Library dataRequirements(@IdParam IdType theId, + public Library dataRequirements(@IdParam IdType theId, @OperationParam(name = "startPeriod") String startPeriod, @OperationParam(name = "endPeriod") String endPeriod) throws InternalErrorException, FHIRException { @@ -919,45 +914,20 @@ public org.hl7.fhir.r4.model.Library dataRequirements(@IdParam IdType theId, LibraryManager libraryManager = this.getLibraryManager(modelManager); Library library = dataRequirementsProvider.getLibraryFromMeasure(measure, libraryResolutionProvider); - if (library == null) { throw new RuntimeException("Could not load measure library."); } - CqlTranslator translator = TranslatorHelper.getTranslator(getContentStream(library), libraryManager, modelManager); - + CqlTranslator translator = TranslatorHelper.getTranslator( + org.opencds.cqf.r4.helpers.LibraryHelper.extractContentStream(library), libraryManager, modelManager); if (translator.getErrors().size() > 0) { throw new RuntimeException("Errors during library compilation."); } - return this.dataRequirementsProvider.getModuleDefinitionLibrary(measure, libraryManager, translator.getTranslatedLibrary(), getTranslatorOptions()); - } - - - private CqlTranslatorOptions getTranslatorOptions() { - CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions(); - cqlTranslatorOptions.getFormats().add(CqlTranslator.Format.JSON); - cqlTranslatorOptions.getOptions().add(CqlTranslator.Options.EnableAnnotations); - cqlTranslatorOptions.setAnalyzeDataRequirements(true); - cqlTranslatorOptions.setCollapseDataRequirements(true); - return cqlTranslatorOptions; + return this.dataRequirementsProvider.getModuleDefinitionLibrary(measure, libraryManager, + translator.getTranslatedLibrary(), TranslatorHelper.getTranslatorOptions()); } - private InputStream getContentStream(org.hl7.fhir.r4.model.Library library) { - Attachment cql = null; - for (Attachment a : library.getContent()) { - if (a.getContentType().equals("text/cql")) { - cql = a; - break; - } - } - - if (cql == null) { - return null; - } - - return new ByteArrayInputStream(Base64.getDecoder().decode(cql.getDataElement().getValueAsString())); - } @SuppressWarnings("unchecked") @Operation(name = "$submit-data", idempotent = true, type = Measure.class) From ef4a89d5178fd37844e7729ce24346335e3d0c49 Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Thu, 30 Sep 2021 14:11:17 -0600 Subject: [PATCH 4/8] refactor data requirements to PR comments --- .../CommonDataRequirementsProvider.java | 140 +++++++++++++++ .../providers/DataRequirementsProvider.java | 161 +++--------------- .../providers/MeasureOperationsProvider.java | 32 +--- 3 files changed, 171 insertions(+), 162 deletions(-) create mode 100644 common/src/main/java/org/opencds/cqf/common/providers/CommonDataRequirementsProvider.java diff --git a/common/src/main/java/org/opencds/cqf/common/providers/CommonDataRequirementsProvider.java b/common/src/main/java/org/opencds/cqf/common/providers/CommonDataRequirementsProvider.java new file mode 100644 index 000000000..96374b77f --- /dev/null +++ b/common/src/main/java/org/opencds/cqf/common/providers/CommonDataRequirementsProvider.java @@ -0,0 +1,140 @@ +package org.opencds.cqf.common.providers; + +import org.cqframework.cql.cql2elm.CqlTranslatorOptions; +import org.cqframework.cql.cql2elm.LibraryManager; +import org.cqframework.cql.cql2elm.model.TranslatedLibrary; +import org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor; +import org.hl7.fhir.r5.model.CanonicalType; +import org.hl7.fhir.r5.model.Extension; +import org.hl7.fhir.r5.model.Library; +import org.hl7.fhir.r5.model.Measure; +import org.hl7.fhir.r5.model.Meta; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@Component +public class CommonDataRequirementsProvider { + + private static final Logger logger = LoggerFactory.getLogger(CommonDataRequirementsProvider.class); + + private static String EXTENSION_URL_PARAMETER = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"; + private static String EXTENSION_URL_DATA_REQUIREMENT = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"; + private static String EXTENSION_URL_REFERENCE_CODE = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"; + private static String EXTENSION_URL_LOGIC_DEFINITION = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"; + private static String EXTENSION_URL_COMPUTABLE_MEASURE = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"; + + + public Measure createMeasure(Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + + Library moduleDefinitionLibrary = getModuleDefinitionLibrary(measureToUse, libraryManager, translatedLibrary, options); + + measureToUse.setDate(new Date()); + setMeta(measureToUse, moduleDefinitionLibrary); + clearMeasureExtensions(measureToUse, EXTENSION_URL_PARAMETER); + clearMeasureExtensions(measureToUse, EXTENSION_URL_DATA_REQUIREMENT); + clearMeasureExtensions(measureToUse, EXTENSION_URL_REFERENCE_CODE); + clearMeasureExtensions(measureToUse, EXTENSION_URL_LOGIC_DEFINITION); + clearRelatedArtifacts(measureToUse); + setParameters(measureToUse, moduleDefinitionLibrary); + setDataRequirements(measureToUse, moduleDefinitionLibrary); + setDirectReferenceCode(measureToUse, moduleDefinitionLibrary); + setLogicDefinition(measureToUse, moduleDefinitionLibrary); + measureToUse.setRelatedArtifact(moduleDefinitionLibrary.getRelatedArtifact()); + + return measureToUse; + } + + public Library getModuleDefinitionLibrary(org.hl7.fhir.r5.model.Measure measureToUse, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + + Set expressionList = getExpressions(measureToUse); + DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor(); + + Library library = dqReqTrans.gatherDataRequirements(libraryManager, translatedLibrary, options, expressionList, true); + return library; + } + + private Set getExpressions(Measure measureToUse) { + Set expressionSet = new HashSet<>(); + measureToUse.getSupplementalData().forEach(supData -> { + expressionSet.add(supData.getCriteria().getExpression()); + }); + measureToUse.getGroup().forEach(groupMember -> { + groupMember.getPopulation().forEach(population -> { + expressionSet.add(population.getCriteria().getExpression()); + }); + groupMember.getStratifier().forEach(stratifier -> { + expressionSet.add(stratifier.getCriteria().getExpression()); + }); + }); + return expressionSet; + } + + private void clearMeasureExtensions(Measure measure, String extensionUrl) { + List extensionsToRemove = measure.getExtensionsByUrl(extensionUrl); + measure.getExtension().removeAll(extensionsToRemove); + } + + private void clearRelatedArtifacts(Measure measure) { + measure.getRelatedArtifact().removeIf(r -> r.getType() == org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); + } + + private void setLogicDefinition(Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + moduleDefinitionLibrary.getExtension().forEach(extension -> { + if (extension.getUrl().equalsIgnoreCase(EXTENSION_URL_LOGIC_DEFINITION)) { + measureToUse.addExtension(extension); + } + }); + } + + private void setDirectReferenceCode(Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + moduleDefinitionLibrary.getExtension().forEach(extension -> { + if (extension.getUrl().equalsIgnoreCase(EXTENSION_URL_REFERENCE_CODE)) { + measureToUse.addExtension(extension); + } + }); + } + + private void setDataRequirements(Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + moduleDefinitionLibrary.getDataRequirement().forEach(dataRequirement -> { + Extension dataReqExtension = new Extension(); + dataReqExtension.setUrl(EXTENSION_URL_DATA_REQUIREMENT); + dataReqExtension.setValue(dataRequirement); + measureToUse.addExtension(dataReqExtension); + }); + } + + private void setParameters(Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + Set parameterName = new HashSet<>(); + moduleDefinitionLibrary.getParameter().forEach(parameter -> { + if (!parameterName.contains(parameter.getName())) { + Extension parameterExtension = new Extension(); + parameterExtension.setUrl(EXTENSION_URL_PARAMETER); + parameterExtension.setValue(parameter); + measureToUse.addExtension(parameterExtension); + parameterName.add(parameter.getName()); + } + }); + } + + private void setMeta(Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { + if (measureToUse.getMeta() == null) { + measureToUse.setMeta(new Meta()); + } + boolean hasProfileMarker = false; + for (CanonicalType canonical : measureToUse.getMeta().getProfile()) { + if (EXTENSION_URL_COMPUTABLE_MEASURE.equals(canonical.getValue())) { + hasProfileMarker = true; + } + } + if (!hasProfileMarker) { + measureToUse.getMeta().addProfile(EXTENSION_URL_COMPUTABLE_MEASURE); + } + } + +} diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java index aed3ad912..1ac28759d 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/DataRequirementsProvider.java @@ -8,15 +8,12 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; -import java.util.Set; -import java.util.HashSet; import java.util.stream.Collectors; import javax.inject.Inject; @@ -48,7 +45,6 @@ import org.cqframework.cql.elm.execution.Library; import org.cqframework.cql.elm.execution.ValueSetDef; import org.cqframework.cql.elm.execution.VersionedIdentifier; -import org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor; import org.cqframework.cql.tools.formatter.CqlFormatterVisitor; import org.cqframework.cql.tools.formatter.CqlFormatterVisitor.FormatResult; import org.hl7.elm.r1.ValueSetRef; @@ -64,10 +60,8 @@ import org.hl7.fhir.r4.model.ParameterDefinition; import org.hl7.fhir.r4.model.RelatedArtifact; import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.r5.model.CanonicalType; -import org.hl7.fhir.r5.model.Extension; -import org.hl7.fhir.r5.model.Meta; import org.opencds.cqf.common.helpers.TranslatorHelper; +import org.opencds.cqf.common.providers.CommonDataRequirementsProvider; import org.opencds.cqf.cql.engine.execution.LibraryLoader; import org.opencds.cqf.tooling.measure.r4.CodeTerminologyRef; import org.opencds.cqf.tooling.measure.r4.CqfMeasure; @@ -87,133 +81,49 @@ public class DataRequirementsProvider { private static final Logger logger = LoggerFactory.getLogger(DataRequirementsProvider.class); - private static String EXTENSION_URL_PARAMETER = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-parameter"; - private static String EXTENSION_URL_DATA_REQUIREMENT = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-dataRequirement"; - private static String EXTENSION_URL_REFERENCE_CODE = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"; - private static String EXTENSION_URL_LOGIC_DEFINITION = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-logicDefinition"; - private static String EXTENSION_URL_COMPUTABLE_MEASURE = "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/computable-measure-cqfm"; - private LibraryHelper libraryHelper; + private CommonDataRequirementsProvider dataRequirementsProvider; @Inject - public DataRequirementsProvider(LibraryHelper libraryHelper) { + public DataRequirementsProvider(CommonDataRequirementsProvider dataRequirementsProvider, + LibraryHelper libraryHelper) { + this.dataRequirementsProvider = dataRequirementsProvider; this.libraryHelper = libraryHelper; } + public Measure createMeasure(Measure measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + org.hl7.fhir.r5.model.Measure measureR5 = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(measure); + org.hl7.fhir.r5.model.Measure convertedMeasure = dataRequirementsProvider.createMeasure(measureR5, libraryManager, translatedLibrary, options); + org.hl7.fhir.r4.model.Measure measureR4 = (org.hl7.fhir.r4.model.Measure) VersionConvertor_40_50.convertResource(convertedMeasure); - public Measure createMeasure(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { - - org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); - org.hl7.fhir.r4.model.Library moduleDefinitionLibrary = getModuleDefinitionLibrary(r4Measure, libraryManager, translatedLibrary, options); - - org.hl7.fhir.r5.model.Library moduleDefinitionLibraryR5 = (org.hl7.fhir.r5.model.Library) VersionConvertor_40_50.convertResource(moduleDefinitionLibrary); - - measureToUse.setDate(new Date()); - setMeta(measureToUse, moduleDefinitionLibraryR5); - clearMeasureExtensions(measureToUse, EXTENSION_URL_PARAMETER); - clearMeasureExtensions(measureToUse, EXTENSION_URL_DATA_REQUIREMENT); - clearMeasureExtensions(measureToUse, EXTENSION_URL_REFERENCE_CODE); - clearMeasureExtensions(measureToUse, EXTENSION_URL_LOGIC_DEFINITION); - clearRelatedArtifacts(measureToUse); - setParameters(measureToUse, moduleDefinitionLibraryR5); - setDataRequirements(measureToUse, moduleDefinitionLibraryR5); - setDirectReferenceCode(measureToUse, moduleDefinitionLibraryR5); - setLogicDefinition(measureToUse, moduleDefinitionLibraryR5); - measureToUse.setRelatedArtifact(moduleDefinitionLibraryR5.getRelatedArtifact()); - - org.hl7.fhir.r4.model.Measure measureR4 = (org.hl7.fhir.r4.model.Measure) VersionConvertor_40_50.convertResource(measureToUse); return measureR4; } - public org.hl7.fhir.r4.model.Library getModuleDefinitionLibrary(Measure r4Measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options){ - - org.hl7.fhir.r5.model.Measure measureToUse = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(r4Measure); + public org.hl7.fhir.r4.model.Library getModuleDefinitionLibrary(Measure measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + org.hl7.fhir.r5.model.Measure measureR5 = (org.hl7.fhir.r5.model.Measure) VersionConvertor_40_50.convertResource(measure); - Set expressionList = getExpressions(measureToUse); - DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor(); - - org.hl7.fhir.r5.model.Library libraryR5 = dqReqTrans.gatherDataRequirements(libraryManager, translatedLibrary, options, expressionList, true); - org.hl7.fhir.r4.model.Library library = (org.hl7.fhir.r4.model.Library) VersionConvertor_40_50.convertResource(libraryR5); - - return library; + org.hl7.fhir.r5.model.Library libraryR5 = dataRequirementsProvider.getModuleDefinitionLibrary(measureR5, libraryManager, translatedLibrary, options); + org.hl7.fhir.r4.model.Library libraryR4 = (org.hl7.fhir.r4.model.Library) VersionConvertor_40_50.convertResource(libraryR5); + return libraryR4; } - private Set getExpressions(org.hl7.fhir.r5.model.Measure measureToUse) { - Set expressionSet = new HashSet<>(); - measureToUse.getSupplementalData().forEach(supData->{ - expressionSet.add(supData.getCriteria().getExpression()); - }); - measureToUse.getGroup().forEach(groupMember->{ - groupMember.getPopulation().forEach(population->{ - expressionSet.add(population.getCriteria().getExpression()); - }); - groupMember.getStratifier().forEach(stratifier->{ - expressionSet.add(stratifier.getCriteria().getExpression()); - }); - }); - return expressionSet; - } - - private void clearMeasureExtensions(org.hl7.fhir.r5.model.Measure measure, String extensionUrl) { - List extensionsToRemove = measure.getExtensionsByUrl(extensionUrl); - measure.getExtension().removeAll(extensionsToRemove); - } - - private void clearRelatedArtifacts(org.hl7.fhir.r5.model.Measure measure) { - measure.getRelatedArtifact().removeIf(r -> r.getType() == org.hl7.fhir.r5.model.RelatedArtifact.RelatedArtifactType.DEPENDSON); - } - - private void setLogicDefinition(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { - moduleDefinitionLibrary.getExtension().forEach(extension -> { - if (extension.getUrl().equalsIgnoreCase(EXTENSION_URL_LOGIC_DEFINITION)) { - measureToUse.addExtension(extension); - } - }); - } - - private void setDirectReferenceCode(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { - moduleDefinitionLibrary.getExtension().forEach(extension -> { - if(extension.getUrl().equalsIgnoreCase(EXTENSION_URL_REFERENCE_CODE)) { - measureToUse.addExtension(extension); - } - }); - } - - private void setDataRequirements(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { - moduleDefinitionLibrary.getDataRequirement().forEach(dataRequirement -> { - Extension dataReqExtension = new Extension(); - dataReqExtension.setUrl(EXTENSION_URL_DATA_REQUIREMENT); - dataReqExtension.setValue(dataRequirement); - measureToUse.addExtension(dataReqExtension); - }); - } + public org.hl7.fhir.r4.model.Library getLibraryFromMeasure(Measure measure, + LibraryResolutionProvider libraryResourceProvider) { + org.hl7.fhir.r4.model.Library primaryLibrary = null; + Iterator var6 = measure.getLibrary().iterator(); - private void setParameters(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary) { - Set parameterName = new HashSet<>(); - moduleDefinitionLibrary.getParameter().forEach(parameter->{ - if(!parameterName.contains(parameter.getName())) { - Extension parameterExtension = new Extension(); - parameterExtension.setUrl(EXTENSION_URL_PARAMETER); - parameterExtension.setValue(parameter); - measureToUse.addExtension(parameterExtension); - parameterName.add(parameter.getName()); - } - }); - } + String library = null; + //use the first library + while (var6.hasNext() && library == null) { + org.hl7.fhir.r4.model.CanonicalType ref = (org.hl7.fhir.r4.model.CanonicalType) var6.next(); - private void setMeta(org.hl7.fhir.r5.model.Measure measureToUse, org.hl7.fhir.r5.model.Library moduleDefinitionLibrary){ - if (measureToUse.getMeta() == null) { - measureToUse.setMeta(new Meta()); - } - boolean hasProfileMarker = false; - for (CanonicalType canonical : measureToUse.getMeta().getProfile()) { - if (EXTENSION_URL_COMPUTABLE_MEASURE.equals(canonical.getValue())) { - hasProfileMarker = true; + if(ref != null) { + library = (String) ref.getValue(); } } - if (!hasProfileMarker) { - measureToUse.getMeta().addProfile(EXTENSION_URL_COMPUTABLE_MEASURE); - } + primaryLibrary = libraryHelper.resolveLibraryReference(libraryResourceProvider, library); + + return primaryLibrary; } // For creating the CQF measure we need to: @@ -232,23 +142,6 @@ public CqfMeasure createCqfMeasure(Measure measure, return this.createCqfMeasure(measure, libraryMap); } - public org.hl7.fhir.r4.model.Library getLibraryFromMeasure(Measure measure, - LibraryResolutionProvider libraryResourceProvider) { - - org.hl7.fhir.r4.model.Library primaryLibrary = null; - Iterator var6 = measure.getLibrary().iterator(); - - String library= null; - while(var6.hasNext()) { - org.hl7.fhir.r4.model.CanonicalType ref = (org.hl7.fhir.r4.model.CanonicalType) var6.next(); - library = (String) ref.getValue(); - - } - primaryLibrary = libraryHelper.resolveLibraryReference(libraryResourceProvider, library); - - return primaryLibrary; - } - private Map> createLibraryMap(Measure measure, LibraryResolutionProvider libraryResourceProvider) { LibraryLoader libraryLoader = this.libraryHelper.createLibraryLoader(libraryResourceProvider); diff --git a/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java b/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java index 6be7bb751..494d47443 100644 --- a/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java +++ b/r4/src/main/java/org/opencds/cqf/r4/providers/MeasureOperationsProvider.java @@ -24,7 +24,6 @@ import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; -import org.hl7.fhir.r4.model.Attachment; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.CanonicalType; @@ -55,10 +54,10 @@ import org.opencds.cqf.common.evaluation.EvaluationProviderFactory; import org.opencds.cqf.common.helpers.DateHelper; import org.opencds.cqf.common.helpers.TranslatorHelper; -import org.opencds.cqf.common.providers.LibraryContentProvider; import org.opencds.cqf.cql.engine.execution.LibraryLoader; import org.opencds.cqf.r4.evaluation.MeasureEvaluation; import org.opencds.cqf.r4.evaluation.MeasureEvaluationSeed; +import org.opencds.cqf.r4.helpers.LibraryHelper; import org.opencds.cqf.tooling.library.r4.NarrativeProvider; import org.opencds.cqf.tooling.measure.r4.CqfMeasure; import org.slf4j.Logger; @@ -67,7 +66,6 @@ import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.cql.common.provider.LibraryResolutionProvider; -import ca.uhn.fhir.cql.r4.helper.LibraryHelper; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.rp.r4.MeasureResourceProvider; @@ -117,28 +115,6 @@ public MeasureOperationsProvider(DaoRegistry registry, EvaluationProviderFactory this.libraryHelper = libraryHelper; } - private ModelManager getModelManager() { - return new ModelManager(); - } - - private LibraryManager getLibraryManager(ModelManager modelManager) { - LibraryManager libraryManager = new LibraryManager(modelManager); - libraryManager.getLibrarySourceLoader().clearProviders(); - libraryManager.getLibrarySourceLoader().registerProvider(getLibrarySourceProvider()); - - return libraryManager; - } - - private LibraryContentProvider librarySourceProvider; - - private LibraryContentProvider getLibrarySourceProvider() { - if (librarySourceProvider == null) { - librarySourceProvider = new LibraryContentProvider( - this.libraryResolutionProvider, x -> x.getContent(), x -> x.getContentType(), x -> x.getData()); - } - return librarySourceProvider; - } - @Operation(name = "$hqmf", idempotent = true, type = Measure.class) public Parameters hqmf(@IdParam IdType theId) { Measure theResource = this.measureResourceProvider.getDao().read(theId); @@ -910,8 +886,8 @@ public Library dataRequirements(@IdParam IdType theId, Measure measure = this.measureResourceProvider.getDao().read(theId); - ModelManager modelManager = this.getModelManager(); - LibraryManager libraryManager = this.getLibraryManager(modelManager); + ModelManager modelManager = libraryHelper.getModelManager(); + LibraryManager libraryManager = libraryHelper.getLibraryManager(libraryResolutionProvider); Library library = dataRequirementsProvider.getLibraryFromMeasure(measure, libraryResolutionProvider); if (library == null) { @@ -919,7 +895,7 @@ public Library dataRequirements(@IdParam IdType theId, } CqlTranslator translator = TranslatorHelper.getTranslator( - org.opencds.cqf.r4.helpers.LibraryHelper.extractContentStream(library), libraryManager, modelManager); + LibraryHelper.extractContentStream(library), libraryManager, modelManager); if (translator.getErrors().size() > 0) { throw new RuntimeException("Errors during library compilation."); } From da3381ac305a5721b37caef28a599d98e4fd5c8d Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Thu, 30 Sep 2021 14:45:54 -0600 Subject: [PATCH 5/8] use same translator everywhere --- .../cqf/common/helpers/TranslatorHelper.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java b/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java index 4a019c92f..df1c928eb 100644 --- a/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java +++ b/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java @@ -5,6 +5,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.List; import javax.xml.bind.JAXBException; @@ -48,16 +49,21 @@ public static CqlTranslator getTranslator(String cql, LibraryManager libraryMana modelManager); } - public static CqlTranslator getTranslator(InputStream cqlStream, LibraryManager libraryManager, - ModelManager modelManager) { + public static List generateDefaultTranslatorOptions() { ArrayList options = new ArrayList<>(); options.add(CqlTranslator.Options.EnableAnnotations); options.add(CqlTranslator.Options.EnableLocators); options.add(CqlTranslator.Options.DisableListDemotion); options.add(CqlTranslator.Options.DisableListPromotion); - options.add(CqlTranslator.Options.DisableMethodInvocation); + return options; + } + + public static CqlTranslator getTranslator(InputStream cqlStream, LibraryManager libraryManager, + ModelManager modelManager) { + CqlTranslator translator; try { + List options = generateDefaultTranslatorOptions(); translator = CqlTranslator.fromStream(cqlStream, modelManager, libraryManager, options.toArray(new CqlTranslator.Options[options.size()])); } catch (IOException e) { @@ -85,8 +91,7 @@ public static Library translateLibrary(CqlTranslator translator) { public static CqlTranslatorOptions getTranslatorOptions() { CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions(); - cqlTranslatorOptions.getFormats().add(CqlTranslator.Format.JSON); - cqlTranslatorOptions.getOptions().add(CqlTranslator.Options.EnableAnnotations); + cqlTranslatorOptions.getOptions().addAll(generateDefaultTranslatorOptions()); cqlTranslatorOptions.setAnalyzeDataRequirements(true); cqlTranslatorOptions.setCollapseDataRequirements(true); return cqlTranslatorOptions; From a496ad65d5e5424aef1abe9da82098da3386e5d2 Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Thu, 30 Sep 2021 15:15:12 -0600 Subject: [PATCH 6/8] set default options as before --- .../java/org/opencds/cqf/common/helpers/TranslatorHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java b/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java index df1c928eb..eb2459e8c 100644 --- a/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java +++ b/common/src/main/java/org/opencds/cqf/common/helpers/TranslatorHelper.java @@ -55,6 +55,7 @@ public static List generateDefaultTranslatorOptions() { options.add(CqlTranslator.Options.EnableLocators); options.add(CqlTranslator.Options.DisableListDemotion); options.add(CqlTranslator.Options.DisableListPromotion); + options.add(CqlTranslator.Options.DisableMethodInvocation); return options; } From 835597bd43cefe4e2a3a30dc1c9b819402a4b76b Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Fri, 1 Oct 2021 12:56:32 -0600 Subject: [PATCH 7/8] dstu3 data requirements update --- .../cqf/dstu3/helpers/LibraryHelper.java | 18 +++++++++ .../providers/DataRequirementsProvider.java | 38 ++++++++++++++++++- .../providers/MeasureOperationsProvider.java | 22 ++++++++++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/dstu3/src/main/java/org/opencds/cqf/dstu3/helpers/LibraryHelper.java b/dstu3/src/main/java/org/opencds/cqf/dstu3/helpers/LibraryHelper.java index 204c905a9..34ded0a14 100644 --- a/dstu3/src/main/java/org/opencds/cqf/dstu3/helpers/LibraryHelper.java +++ b/dstu3/src/main/java/org/opencds/cqf/dstu3/helpers/LibraryHelper.java @@ -1,5 +1,8 @@ package org.opencds.cqf.dstu3.helpers; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Base64; import java.util.Collections; import java.util.List; import java.util.Map; @@ -89,6 +92,21 @@ protected Boolean translatorOptionsMatch(Library library) { }; } + public static InputStream extractContentStream(org.hl7.fhir.dstu3.model.Library library) { + org.hl7.fhir.dstu3.model.Attachment cql = null; + for (org.hl7.fhir.dstu3.model.Attachment a : library.getContent()) { + if (a.getContentType().equals("text/cql")) { + cql = a; + break; + } + } + + if (cql == null) { + return null; + } + return new ByteArrayInputStream(Base64.getDecoder().decode(cql.getDataElement().getValueAsString())); + } + // @Override // public org.opencds.cqf.cql.engine.execution.LibraryLoader createLibraryLoader( // org.cqframework.cql.cql2elm.LibrarySourceProvider provider) { diff --git a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java index 47d7d0507..fcabc9dab 100644 --- a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java +++ b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java @@ -9,6 +9,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -31,8 +32,10 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import org.cqframework.cql.cql2elm.CqlTranslator; +import org.cqframework.cql.cql2elm.CqlTranslatorOptions; import org.cqframework.cql.cql2elm.LibraryManager; import org.cqframework.cql.cql2elm.ModelManager; +import org.cqframework.cql.cql2elm.model.TranslatedLibrary; import org.cqframework.cql.elm.execution.CodeDef; import org.cqframework.cql.elm.execution.CodeSystemDef; import org.cqframework.cql.elm.execution.ExpressionDef; @@ -44,6 +47,7 @@ import org.cqframework.cql.tools.formatter.CqlFormatterVisitor; import org.cqframework.cql.tools.formatter.CqlFormatterVisitor.FormatResult; import org.hl7.elm.r1.ValueSetRef; +import org.hl7.fhir.convertors.VersionConvertor_30_50; import org.hl7.fhir.dstu3.model.Attachment; import org.hl7.fhir.dstu3.model.Base64BinaryType; import org.hl7.fhir.dstu3.model.CodeableConcept; @@ -62,6 +66,7 @@ import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.dstu3.model.Type; import org.opencds.cqf.common.helpers.TranslatorHelper; +import org.opencds.cqf.common.providers.CommonDataRequirementsProvider; import org.opencds.cqf.cql.engine.execution.LibraryLoader; import org.opencds.cqf.tooling.measure.stu3.CodeTerminologyRef; import org.opencds.cqf.tooling.measure.stu3.CqfMeasure; @@ -78,12 +83,43 @@ public class DataRequirementsProvider { private LibraryHelper libraryHelper; + private CommonDataRequirementsProvider dataRequirementsProvider; @Inject - public DataRequirementsProvider(LibraryHelper libraryHelper) { + public DataRequirementsProvider(CommonDataRequirementsProvider dataRequirementsProvider, + LibraryHelper libraryHelper) { + this.dataRequirementsProvider = dataRequirementsProvider; this.libraryHelper = libraryHelper; } + + public org.hl7.fhir.dstu3.model.Library getModuleDefinitionLibrary(org.hl7.fhir.dstu3.model.Measure measure, LibraryManager libraryManager, TranslatedLibrary translatedLibrary, CqlTranslatorOptions options) { + org.hl7.fhir.r5.model.Measure measureR5 = (org.hl7.fhir.r5.model.Measure) VersionConvertor_30_50.convertResource(measure); + + org.hl7.fhir.r5.model.Library libraryR5 = dataRequirementsProvider.getModuleDefinitionLibrary(measureR5, libraryManager, translatedLibrary, options); + org.hl7.fhir.dstu3.model.Library libraryDstu3 = (org.hl7.fhir.dstu3.model.Library) VersionConvertor_30_50.convertResource(libraryR5); + return libraryDstu3; + } + + public org.hl7.fhir.dstu3.model.Library getLibraryFromMeasure(org.hl7.fhir.dstu3.model.Measure measure, + LibraryResolutionProvider libraryResourceProvider) { + org.hl7.fhir.dstu3.model.Library primaryLibrary = null; + Iterator var6 = measure.getLibrary().iterator(); + + String id = null; + //use the first library + while (var6.hasNext() && id == null) { + Reference ref = (Reference)var6.next(); + id = ref.getReferenceElement().getIdPart(); + if (id.startsWith("#")) { + id = id.substring(1); + } + } + primaryLibrary = (org.hl7.fhir.dstu3.model.Library)libraryResourceProvider.resolveLibraryById(id); + + return primaryLibrary; + } + // For creating the CQF measure we need to: // 1. Find the Primary Library Resource // 2. Load the Primary Library as ELM. This will recursively load the dependent diff --git a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/MeasureOperationsProvider.java b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/MeasureOperationsProvider.java index c7c54ba76..148776b7e 100644 --- a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/MeasureOperationsProvider.java +++ b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/MeasureOperationsProvider.java @@ -12,6 +12,9 @@ import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; +import org.cqframework.cql.cql2elm.CqlTranslator; +import org.cqframework.cql.cql2elm.LibraryManager; +import org.cqframework.cql.cql2elm.ModelManager; import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.CodeableConcept; @@ -42,6 +45,7 @@ import org.opencds.cqf.common.config.HapiProperties; import org.opencds.cqf.common.evaluation.EvaluationProviderFactory; import org.opencds.cqf.common.helpers.DateHelper; +import org.opencds.cqf.common.helpers.TranslatorHelper; import org.opencds.cqf.cql.engine.data.DataProvider; import org.opencds.cqf.cql.engine.execution.LibraryLoader; import org.opencds.cqf.dstu3.evaluation.MeasureEvaluation; @@ -721,7 +725,23 @@ public org.hl7.fhir.dstu3.model.Library dataRequirements(@IdParam IdType theId, @OperationParam(name = "endPeriod") String endPeriod) throws InternalErrorException, FHIRException { Measure measure = this.measureResourceProvider.getDao().read(theId); - return this.dataRequirementsProvider.getDataRequirements(measure, this.libraryResolutionProvider); + + ModelManager modelManager = libraryHelper.getModelManager(); + LibraryManager libraryManager = libraryHelper.getLibraryManager(libraryResolutionProvider); + + Library library = this.dataRequirementsProvider.getLibraryFromMeasure(measure, libraryResolutionProvider); + if (library == null) { + throw new RuntimeException("Could not load measure library."); + } + + CqlTranslator translator = TranslatorHelper.getTranslator( + LibraryHelper.extractContentStream(library), libraryManager, modelManager); + if (translator.getErrors().size() > 0) { + throw new RuntimeException("Errors during library compilation."); + } + + return this.dataRequirementsProvider.getModuleDefinitionLibrary(measure, libraryManager, + translator.getTranslatedLibrary(), TranslatorHelper.getTranslatorOptions()); } @SuppressWarnings("unchecked") From c6e186cf4dbc374aabb6c6419a41a8d0f65c608a Mon Sep 17 00:00:00 2001 From: mdnazmulkarim Date: Fri, 1 Oct 2021 12:59:47 -0600 Subject: [PATCH 8/8] remove unused method --- .../cqf/dstu3/providers/DataRequirementsProvider.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java index fcabc9dab..10b9f78ce 100644 --- a/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java +++ b/dstu3/src/main/java/org/opencds/cqf/dstu3/providers/DataRequirementsProvider.java @@ -534,13 +534,6 @@ private String markdownToHtml(Parser parser, HtmlRenderer renderer, String markd return renderer.render(document); } - public org.hl7.fhir.dstu3.model.Library getDataRequirements(Measure measure, - LibraryResolutionProvider libraryResourceProvider) { - Map> libraryMap = this - .createLibraryMap(measure, libraryResourceProvider); - return this.getDataRequirements(measure, libraryMap.values().stream().map(x -> x.getRight()) - .filter(x -> x != null).collect(Collectors.toList())); - } private org.hl7.fhir.dstu3.model.Library getDataRequirements(Measure measure, Collection libraries) {