Skip to content

Commit 9048d51

Browse files
authored
Br connectathon fixes (#584)
* Do not report dependencies on model info that is loaded from the translator, or from CQF Common * Fix attachment URL preventing CQL source file information lookup * Fixed measure packages not including Group resource * Fixed test case
1 parent d54a8f0 commit 9048d51

File tree

5 files changed

+45
-9
lines changed

5 files changed

+45
-9
lines changed

tooling/src/main/java/org/opencds/cqf/tooling/library/LibraryProcessor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ protected Library refreshGeneratedContent(Library sourceLibrary) {
236236
var translatorOptions = getCqlProcessor().getCqlTranslatorOptions();
237237
var formats = translatorOptions.getFormats();
238238
CqlProcessor.CqlSourceFileInformation info = getCqlProcessor().getFileInformation(attachment.getUrl());
239+
if (this.parentContext != null && this.parentContext.getCanonicalBase() != null) {
240+
attachment.setUrl(this.parentContext.getCanonicalBase() + "/" + fileName);
241+
}
239242
if (info != null) {
240243
if (info.getElm() != null && emptyIfNull(formats).contains(Format.XML)) {
241244
sourceLibrary.addContent().setContentType("application/elm+xml").setData(info.getElm());
@@ -379,9 +382,7 @@ private Attachment loadFile(String fn) throws IOException {
379382
Attachment att = new Attachment();
380383
att.setContentType("text/cql");
381384
att.setData(TextFile.fileToBytes(f));
382-
if (this.parentContext != null && this.parentContext.getCanonicalBase() != null) {
383-
att.setUrl(this.parentContext.getCanonicalBase() + "/Library-" + f.getName());
384-
}
385+
att.setUrl(f.getAbsolutePath());
385386
return att;
386387
}
387388
}

tooling/src/main/java/org/opencds/cqf/tooling/measure/MeasureRefreshProcessor.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public Measure refreshMeasure(Measure measureToUse, LibraryManager libraryManage
3838
clearRelatedArtifacts(measureToUse);
3939

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

55+
private void removeModelInfoDependencies(Library moduleDefinitionLibrary) {
56+
// NOTE: see similar logic in CqlProcessor.translateFile
57+
if (moduleDefinitionLibrary.hasRelatedArtifact()) {
58+
for (int i = moduleDefinitionLibrary.getRelatedArtifact().size() - 1; i >= 0; i--) {
59+
RelatedArtifact relatedArtifact = moduleDefinitionLibrary.getRelatedArtifact().get(i);
60+
if (relatedArtifact != null && relatedArtifact.hasResource() && (
61+
relatedArtifact.getResource().startsWith("http://hl7.org/fhir/Library/QICore-ModelInfo")
62+
|| relatedArtifact.getResource().startsWith("http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo")
63+
|| relatedArtifact.getResource().startsWith("http://hl7.org/fhir/Library/USCore-ModelInfo")
64+
)) {
65+
// Do not report dependencies on model info loaded from the translator, or
66+
// from CQF Common (because these should be loaded from Using CQL now)
67+
moduleDefinitionLibrary.getRelatedArtifact().remove(i);
68+
}
69+
}
70+
}
71+
}
72+
5473
private Library getModuleDefinitionLibrary(Measure measureToUse, LibraryManager libraryManager, CompiledLibrary compiledLibrary, CqlCompilerOptions options){
5574
Set<String> expressionList = getExpressions(measureToUse);
5675
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();

tooling/src/main/java/org/opencds/cqf/tooling/packaging/r4/PackageMeasure.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,18 @@ public void output() {
140140

141141
if (isIncludeTests() && testPackage != null) {
142142
logger.info("Packaging {} Tests...", testPackage.getTests().size());
143-
if (testPackage.getGroup() != null) {
144-
IOUtils.writeResource(testPackage.getGroup(), measureFilesOutputPath, IOUtils.Encoding.JSON, getFhirContext(),
145-
true, "Group-" + testPackage.getGroup().getIdElement().getIdPart());
146-
}
147143
testPackage.getTests().forEach(
148144
test -> {
149145
dependencies.addAll(BundleUtils.getR4ResourcesFromBundle((Bundle) test));
150146
IOUtils.writeBundle(test, measureFilesOutputPath, IOUtils.Encoding.JSON,
151147
getFhirContext(), test.getIdElement().getIdPart());
152148
}
153149
);
150+
if (testPackage.getGroup() != null) {
151+
dependencies.add(testPackage.getGroup());
152+
IOUtils.writeResource(testPackage.getGroup(), measureFilesOutputPath, IOUtils.Encoding.JSON, getFhirContext(),
153+
true, "Group-" + testPackage.getGroup().getIdElement().getIdPart());
154+
}
154155
}
155156

156157
dependencies.add(mainArtifact);

tooling/src/main/java/org/opencds/cqf/tooling/processor/CqlProcessor.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,20 @@ private void translateFile(LibraryManager libraryManager, File file, CqlCompiler
432432
//result.extension.addAll(requirementsLibrary.getExtensionsByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-directReferenceCode"));
433433

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

437450
// Extract parameter data and validate result types are supported types
438451
result.parameters.addAll(requirementsLibrary.getParameter());

tooling/src/test/java/org/opencds/cqf/tooling/processor/IGProcessorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class IGProcessorTest extends RefreshTest {
6161
private final String BUNDLE_TYPE = "Bundle";
6262
private final String LIB_TYPE = "Library";
6363
private final String MEASURE_TYPE = "Measure";
64+
private final String GROUP_TYPE = "Group";
6465

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

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

0 commit comments

Comments
 (0)