Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ protected Library refreshGeneratedContent(Library sourceLibrary) {
var translatorOptions = getCqlProcessor().getCqlTranslatorOptions();
var formats = translatorOptions.getFormats();
CqlProcessor.CqlSourceFileInformation info = getCqlProcessor().getFileInformation(attachment.getUrl());
if (this.parentContext != null && this.parentContext.getCanonicalBase() != null) {
attachment.setUrl(this.parentContext.getCanonicalBase() + "/" + fileName);
Comment thread
c-schuler marked this conversation as resolved.
}
if (info != null) {
if (info.getElm() != null && emptyIfNull(formats).contains(Format.XML)) {
sourceLibrary.addContent().setContentType("application/elm+xml").setData(info.getElm());
Expand Down Expand Up @@ -379,9 +382,7 @@ private Attachment loadFile(String fn) throws IOException {
Attachment att = new Attachment();
att.setContentType("text/cql");
att.setData(TextFile.fileToBytes(f));
if (this.parentContext != null && this.parentContext.getCanonicalBase() != null) {
att.setUrl(this.parentContext.getCanonicalBase() + "/Library-" + f.getName());
}
att.setUrl(f.getAbsolutePath());
Comment thread
c-schuler marked this conversation as resolved.
return att;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public Measure refreshMeasure(Measure measureToUse, LibraryManager libraryManage
clearRelatedArtifacts(measureToUse);

Library moduleDefinitionLibrary = getModuleDefinitionLibrary(measureToUse, libraryManager, compiledLibrary, options);
removeModelInfoDependencies(moduleDefinitionLibrary);
measureToUse.setDate(new Date());
// http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/measure-cqfm
setMeta(measureToUse, moduleDefinitionLibrary);
Expand All @@ -51,6 +52,24 @@ public Measure refreshMeasure(Measure measureToUse, LibraryManager libraryManage
return measureToUse;
}

private void removeModelInfoDependencies(Library moduleDefinitionLibrary) {
Comment thread
c-schuler marked this conversation as resolved.
// NOTE: see similar logic in CqlProcessor.translateFile
if (moduleDefinitionLibrary.hasRelatedArtifact()) {
for (int i = moduleDefinitionLibrary.getRelatedArtifact().size() - 1; i >= 0; i--) {
RelatedArtifact relatedArtifact = moduleDefinitionLibrary.getRelatedArtifact().get(i);
if (relatedArtifact != null && relatedArtifact.hasResource() && (
relatedArtifact.getResource().startsWith("http://hl7.org/fhir/Library/QICore-ModelInfo")
|| relatedArtifact.getResource().startsWith("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo")
|| relatedArtifact.getResource().startsWith("http://hl7.org/fhir/Library/USCore-ModelInfo")
)) {
// Do not report dependencies on model info loaded from the translator, or
// from CQF Common (because these should be loaded from Using CQL now)
moduleDefinitionLibrary.getRelatedArtifact().remove(i);
}
}
}
}

private Library getModuleDefinitionLibrary(Measure measureToUse, LibraryManager libraryManager, CompiledLibrary compiledLibrary, CqlCompilerOptions options){
Set<String> expressionList = getExpressions(measureToUse);
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,18 @@ public void output() {

if (isIncludeTests() && testPackage != null) {
logger.info("Packaging {} Tests...", testPackage.getTests().size());
if (testPackage.getGroup() != null) {
IOUtils.writeResource(testPackage.getGroup(), measureFilesOutputPath, IOUtils.Encoding.JSON, getFhirContext(),
true, "Group-" + testPackage.getGroup().getIdElement().getIdPart());
}
testPackage.getTests().forEach(
test -> {
dependencies.addAll(BundleUtils.getR4ResourcesFromBundle((Bundle) test));
IOUtils.writeBundle(test, measureFilesOutputPath, IOUtils.Encoding.JSON,
getFhirContext(), test.getIdElement().getIdPart());
}
);
if (testPackage.getGroup() != null) {
dependencies.add(testPackage.getGroup());
IOUtils.writeResource(testPackage.getGroup(), measureFilesOutputPath, IOUtils.Encoding.JSON, getFhirContext(),
true, "Group-" + testPackage.getGroup().getIdElement().getIdPart());
}
}

dependencies.add(mainArtifact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,20 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler
//result.extension.addAll(requirementsLibrary.getExtensionsByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"));

// Extract relatedArtifact data (models, libraries, code systems, and value sets)
result.relatedArtifacts.addAll(requirementsLibrary.getRelatedArtifact());
for (RelatedArtifact relatedArtifact : requirementsLibrary.getRelatedArtifact()) {
// NOTE: see similar logic in MeasureRefreshProcessor.removeModelInfoDependencies
if (relatedArtifact.hasResource() && (
relatedArtifact.getResource().startsWith("http://hl7.org/fhir/Library/QICore-ModelInfo")
|| relatedArtifact.getResource().startsWith("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo")
|| relatedArtifact.getResource().startsWith("http://hl7.org/fhir/Library/USCore-ModelInfo")
)) {
// Do not report dependencies on model info loaded from the translator, or
// from CQF Common (because these should be loaded from Using CQL now)
continue;
}

result.relatedArtifacts.add(relatedArtifact);
}

// Extract parameter data and validate result types are supported types
result.parameters.addAll(requirementsLibrary.getParameter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class IGProcessorTest extends RefreshTest {
private final String BUNDLE_TYPE = "Bundle";
private final String LIB_TYPE = "Library";
private final String MEASURE_TYPE = "Measure";
private final String GROUP_TYPE = "Group";

private final String INI_LOC = "target" + separator + "refreshIG" + separator + "ig.ini";

Expand Down Expand Up @@ -136,10 +137,11 @@ void testRefreshIG() throws Exception {
// ensure "resourceType" exists
if (map.containsKey(RESOURCE_TYPE)) {
String parentResourceType = (String) map.get(RESOURCE_TYPE);
// if Library, resource will produce a "Measure" in main bundled file:
// if Library, resource will produce a "Measure" and a "Group" in main bundled file:
if (parentResourceType.equalsIgnoreCase(LIB_TYPE)) {
resourceTypeMap.put(MEASURE_TYPE + "_" + map.get(ID), MEASURE_TYPE);
resourceTypeMap.put(LIB_TYPE + "_" + map.get(ID), LIB_TYPE);
resourceTypeMap.put(GROUP_TYPE + "_" + map.get(ID), GROUP_TYPE);
} else if (parentResourceType.equalsIgnoreCase(BUNDLE_TYPE)) {
// file is a bundle type, loop through resources in entry list, build up map of
// <id, resourceType>:
Expand Down
Loading