Skip to content

Commit

Permalink
Updated translator to 3.3.2
Browse files Browse the repository at this point in the history
Added skip-packages option to refresh ig operation
Removed operation processing for narrative refresh operations and drools operation
NOTE: This is known not to compile at this point, I've removed all the code related to the narrative refresh and drools operations locally, and have published a release based on that local code. This is in anticipation of a reorganization of the tooling that moves different operations into different packages, so I'm committing the changes here that are released as 2.6.0 from my local compile.
  • Loading branch information
brynrhodes committed Oct 29, 2023
1 parent 26701a1 commit 2685f46
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 62 deletions.
11 changes: 5 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@

<groupId>org.opencds.cqf</groupId>
<artifactId>tooling-parent</artifactId>
<version>2.5.0</version>

<version>2.6.0</version>

<packaging>pom</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<cql-engine.version>2.9.0</cql-engine.version>
<cql-engine.version>3.3.2</cql-engine.version>
<cql-evaluator.version>2.6.0</cql-evaluator.version>
<cqframework.version>2.9.0</cqframework.version>
<hapi.version>6.0.1</hapi.version>
<core.version>5.6.36</core.version>
<cqframework.version>3.3.2</cqframework.version>
<hapi.version>6.8.0</hapi.version>
<core.version>6.0.22</core.version>
<spring-boot.version>2.1.5.RELEASE</spring-boot.version>
<log4j2-version>2.17.1</log4j2-version>
</properties>
Expand Down
6 changes: 3 additions & 3 deletions tooling-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<groupId>org.opencds.cqf</groupId>
<artifactId>tooling-parent</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
</parent>

<groupId>org.opencds.cqf</groupId>
<artifactId>tooling-cli</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
<packaging>jar</packaging>

<description>CQF Tooling CLI</description>
Expand All @@ -20,7 +20,7 @@
<dependency>
<groupId>org.opencds.cqf</groupId>
<artifactId>tooling</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
<!-- <packaging>jar</packaging> -->
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.opencds.cqf.tooling.Operation;
import org.opencds.cqf.tooling.acceleratorkit.DTProcessor;
import org.opencds.cqf.tooling.acceleratorkit.Processor;
import org.opencds.cqf.tooling.library.r4.LibraryGenerator;
import org.opencds.cqf.tooling.measure.r4.RefreshR4MeasureOperation;
import org.opencds.cqf.tooling.measure.stu3.RefreshStu3MeasureOperation;
import org.opencds.cqf.tooling.modelinfo.StructureDefinitionToModelInfo;
Expand Down Expand Up @@ -54,22 +53,12 @@ static Operation createOperation(String operationName) {
return new EnsureExecutableValueSetOperation();
case "ToJsonValueSetDb":
return new ToJsonValueSetDbOperation();
case "CqlToSTU3Library":
return new org.opencds.cqf.tooling.library.stu3.LibraryGenerator();
case "CqlToR4Library":
return new LibraryGenerator();
case "UpdateSTU3Cql":
return new org.opencds.cqf.tooling.library.stu3.LibraryGenerator();
case "UpdateR4Cql":
return new LibraryGenerator();
case "JsonSchemaGenerator":
// return new SchemaGenerator();
case "BundleIg":
return new IgBundler();
// case "PackageIG":
// return new PackageOperation();
case "GenerateCQLFromDrool":
return new GenerateCQLFromDroolOperation();
case "VmrToFhir":
return new VmrToFhirOperation();
case "RefreshIG":
Expand Down
26 changes: 20 additions & 6 deletions tooling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>org.opencds.cqf</groupId>
<artifactId>tooling-parent</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>

</parent>

<groupId>org.opencds.cqf</groupId>
<artifactId>tooling</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down Expand Up @@ -179,6 +179,7 @@
</dependency>

<!-- Narrative Generation -->
<!--
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
Expand All @@ -187,15 +188,16 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.4.1</version>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.9.1</version>
</dependency>

-->
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<!--
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
Expand All @@ -205,7 +207,7 @@
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.13.2</version>
<version>2.14.2</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -225,7 +227,7 @@
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>

-->
<!--redirects apache commons-logging to slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -278,6 +280,18 @@
<version>${cql-evaluator.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<artifactId>model-jaxb</artifactId>
<version>${cql-engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<artifactId>elm-jaxb</artifactId>
<version>${cql-engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<artifactId>engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private Measure refreshGeneratedContent(Measure measure) {
String libraryUrl = ResourceUtils.getPrimaryLibraryUrl(measure, fhirContext);
VersionedIdentifier primaryLibraryIdentifier = CanonicalUtils.toVersionedIdentifier(libraryUrl);
List<CqlCompilerException> errors = new ArrayList<CqlCompilerException>();
CompiledLibrary CompiledLibrary = libraryManager.resolveLibrary(primaryLibraryIdentifier, cqlTranslatorOptions, errors);
CompiledLibrary CompiledLibrary = libraryManager.resolveLibrary(primaryLibraryIdentifier, errors);
boolean hasErrors = false;
if (errors.size() > 0) {
for (CqlCompilerException e : errors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Measure refreshMeasure(Measure measureToUse, LibraryManager libraryManage
private Library getModuleDefinitionLibrary(Measure measureToUse, LibraryManager libraryManager, CompiledLibrary CompiledLibrary, CqlTranslatorOptions options){
Set<String> expressionList = getExpressions(measureToUse);
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
return dqReqTrans.gatherDataRequirements(libraryManager, CompiledLibrary, options, expressionList, true);
return dqReqTrans.gatherDataRequirements(libraryManager, CompiledLibrary, options.getCqlCompilerOptions(), expressionList, true);
}

private Set<String> getExpressions(Measure measureToUse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public NpmPackageManager(ImplementationGuide sourceIg, String version) {
try {
// userMode indicates whether the packageCache is within the working directory
// or in the user home
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
pcm = new FilesystemPackageCacheManager(true);
} catch (IOException e) {
throw new NpmPackageManagerException("error creating the FilesystemPackageCacheManager", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class RefreshIGParameters {
public String rootDir;
public String igPath;
public IOUtils.Encoding outputEncoding;
public Boolean skipPackages;
public Boolean includeELM;
public Boolean includeDependencies;
public Boolean includeTerminology;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,9 @@ public void logMessage(String msg) {
public void logDebugMessage(IWorkerContext.ILoggingService.LogCategory category, String msg) {
logger.debug("Category: {} Message: {}", category.name(), msg);
}

@Override
public boolean isDebugLogging() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ private void translateFolder(String folder) {
// Construct FhirLibrarySourceProvider
ModelManager modelManager = new ModelManager();
LibraryManager libraryManager = new LibraryManager(modelManager);
if (options.getCqlCompilerOptions().getValidateUnits()) {
libraryManager.setUcumService(ucumService);
}
if (packages != null) {
modelManager.getModelInfoLoader().registerModelInfoProvider(new NpmModelInfoProvider(packages, reader, logger), true);
libraryManager.getLibrarySourceLoader().registerProvider(new NpmLibrarySourceProvider(packages, reader, logger));
Expand All @@ -273,7 +276,7 @@ private void translateFolder(String folder) {
boolean hadCqlFiles = false;
for (File file : new File(folder).listFiles(getCqlFilenameFilter())) {
hadCqlFiles = true;
translateFile(modelManager, libraryManager, file, options);
translateFile(libraryManager, file, options);
}

if (hadCqlFiles) {
Expand Down Expand Up @@ -339,16 +342,15 @@ public static ValidationMessage exceptionToValidationMessage(File file, CqlCompi
}
}

private void translateFile(ModelManager modelManager, LibraryManager libraryManager, File file, CqlTranslatorOptions options) {
private void translateFile(LibraryManager libraryManager, File file, CqlTranslatorOptions options) {
logger.logMessage(String.format("Translating CQL source in file %s", file.toString()));
CqlSourceFileInformation result = new CqlSourceFileInformation();
fileMap.put(file.getAbsoluteFile().toString(), result);

try {

// translate toXML
CqlTranslator translator = CqlTranslator.fromFile(namespaceInfo, file, modelManager, libraryManager,
options.getValidateUnits() ? ucumService : null, options);
CqlTranslator translator = CqlTranslator.fromFile(namespaceInfo, file, libraryManager);

// record errors and warnings
for (CqlCompilerException exception : translator.getExceptions()) {
Expand Down Expand Up @@ -376,13 +378,12 @@ private void translateFile(ModelManager modelManager, LibraryManager libraryMana

// Add the translated library to the library manager (NOTE: This should be a "cacheLibrary" call on the LibraryManager, available in 1.5.3+)
// Without this, the data requirements processor will try to load the current library, resulting in a re-translation
CompiledLibrary CompiledLibrary = translator.getTranslatedLibrary();
String libraryPath = NamespaceManager.getPath(CompiledLibrary.getIdentifier().getSystem(), CompiledLibrary.getIdentifier().getId());
libraryManager.getCompiledLibraries().put(libraryPath, CompiledLibrary);
CompiledLibrary compiledLibrary = translator.getTranslatedLibrary();
libraryManager.getCompiledLibraries().put(compiledLibrary.getIdentifier(), compiledLibrary);

DataRequirementsProcessor drp = new DataRequirementsProcessor();
org.hl7.fhir.r5.model.Library requirementsLibrary =
drp.gatherDataRequirements(libraryManager, translator.getTranslatedLibrary(), options, null, false);
drp.gatherDataRequirements(libraryManager, translator.getTranslatedLibrary(), options.getCqlCompilerOptions(), null, false);

// TODO: Report context, requires 1.5 translator (ContextDef)
// NOTE: In STU3, only Patient context is supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public IGProcessor(IGBundleProcessor igBundleProcessor, LibraryProcessor library
}
//mega ig method
public void publishIG(RefreshIGParameters params) {
if (params.skipPackages == null) {
params.skipPackages = false;
}
requireNonNull(params.includeDependencies, "includeDependencies can not be null");
requireNonNull(params.includeELM, "includeELM can not be null");
requireNonNull(params.includePatientScenarios, "includePatientScenarios can not be null");
Expand All @@ -58,6 +61,7 @@ public void publishIG(RefreshIGParameters params) {
}

Encoding encoding = params.outputEncoding;
Boolean skipPackages = params.skipPackages;
Boolean includeELM = params.includeELM;
Boolean includeDependencies = params.includeDependencies;
Boolean includeTerminology = params.includeTerminology;
Expand Down Expand Up @@ -98,8 +102,22 @@ public void publishIG(RefreshIGParameters params) {
//Use case 3
//package everything
LogUtils.info("IGProcessor.publishIG - bundleIg");
igBundleProcessor.bundleIg(refreshedResourcesNames, rootDir, getBinaryPaths(), encoding, includeELM, includeDependencies, includeTerminology, includePatientScenarios,
versioned, addBundleTimestamp, fhirContext, fhirUri);
if (!skipPackages) {
igBundleProcessor.bundleIg(
refreshedResourcesNames,
rootDir,
getBinaryPaths(),
encoding,
includeELM,
includeDependencies,
includeTerminology,
includePatientScenarios,
versioned,
addBundleTimestamp,
fhirContext,
fhirUri
);
}
//test everything
//IGTestProcessor.testIg(IGTestParameters);
//Publish?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class RefreshIGArgumentProcessor {
public static final String[] ROOT_DIR_OPTIONS = {"root-dir"};
public static final String[] IG_PATH_OPTIONS = {"ip", "ig-path"};
public static final String[] IG_OUTPUT_ENCODING = {"e", "encoding"};

public static final String[] SKIP_PACKAGES_OPTIONS = {"s", "skip-packages"};
public static final String[] INCLUDE_ELM_OPTIONS = {"elm", "include-elm"};
public static final String[] INCLUDE_DEPENDENCY_LIBRARY_OPTIONS = {"d", "include-dependencies"};
public static final String[] INCLUDE_TERMINOLOGY_OPTIONS = {"t", "include-terminology"};
Expand Down Expand Up @@ -70,6 +72,7 @@ public OptionParser build() {
OptionSpec<String> fhirUri = fhirUriBuilder.withOptionalArg().describedAs("uri of fhir server");

parser.acceptsAll(asList(OPERATION_OPTIONS),"The operation to run.");
parser.acceptsAll(asList(SKIP_PACKAGES_OPTIONS), "Specifies whether to skip packages building.");
parser.acceptsAll(asList(INCLUDE_ELM_OPTIONS),"If omitted ELM will not be produced or packaged.");
parser.acceptsAll(asList(INCLUDE_DEPENDENCY_LIBRARY_OPTIONS),"If omitted only the primary CQL library will be packaged.");
parser.acceptsAll(asList(INCLUDE_TERMINOLOGY_OPTIONS),"If omitted terminology will not be packaged.");
Expand Down Expand Up @@ -107,6 +110,7 @@ public RefreshIGParameters parseAndConvert(String[] args) {
if (igEncoding != null) {
outputEncodingEnum = Encoding.parse(igEncoding.toLowerCase());
}
Boolean skipPackages = options.has(SKIP_PACKAGES_OPTIONS[0]);
Boolean includeELM = options.has(INCLUDE_ELM_OPTIONS[0]);
Boolean includeDependencies = options.has(INCLUDE_DEPENDENCY_LIBRARY_OPTIONS[0]);
Boolean includeTerminology = options.has(INCLUDE_TERMINOLOGY_OPTIONS[0]);
Expand Down Expand Up @@ -152,6 +156,7 @@ public RefreshIGParameters parseAndConvert(String[] args) {
ip.rootDir = rootDir;
ip.igPath = igPath;
ip.outputEncoding = outputEncodingEnum;
ip.skipPackages = skipPackages;
ip.includeELM = includeELM;
ip.includeDependencies = includeDependencies;
ip.includeTerminology = includeTerminology;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,7 @@ public static CqlTranslator translate(String cqlContentPath, ModelManager modelM
// options.add(CqlTranslatorOptions.Options.EnableDateRangeOptimization);

translator =
CqlTranslator.fromFile(
cqlFile,
modelManager,
libraryManager,
null, options);
CqlTranslator.fromFile(cqlFile, libraryManager);

if (translator.getErrors().size() > 0) {
//System.err.println("Translation failed due to errors:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ public static CqlTranslatorOptions getTranslatorOptions(String folder) {
}
else {
options = CqlTranslatorOptions.defaultOptions();
if (!options.getFormats().contains(CqlTranslator.Format.XML)) {
options.getFormats().add(CqlTranslator.Format.XML);
if (!options.getFormats().contains(CqlTranslatorOptions.Format.XML)) {
options.getFormats().add(CqlTranslatorOptions.Format.XML);
}
logger.debug("cql-options not found. Using default options.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ public void logMessage(String msg) {
public void logDebugMessage(IWorkerContext.ILoggingService.LogCategory category, String msg) {
logMessage(msg);
}

@Override
public boolean isDebugLogging() {
return false;
}
}
Loading

0 comments on commit 2685f46

Please sign in to comment.