Skip to content
Open
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
7 changes: 0 additions & 7 deletions cqf-fhir-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-jackson</artifactId>
<version>3.28.0-SNAPSHOT</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down
12 changes: 0 additions & 12 deletions cqf-fhir-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@
<artifactId>cqf-fhir-cql</artifactId>
<version>3.28.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-jackson</artifactId>
<version>3.28.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-jaxb</artifactId>
<version>3.28.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-cr</artifactId>
Expand Down
31 changes: 14 additions & 17 deletions cqf-fhir-cql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,35 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<groupId>org.cqframework</groupId>
<artifactId>cql-to-elm</artifactId>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<artifactId>elm-fhir</artifactId>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<groupId>org.cqframework</groupId>
<artifactId>ucum</artifactId>
</dependency>
<dependency>
<groupId>org.cqframework</groupId>
<artifactId>elm-fhir</artifactId>
</dependency>
<dependency>
<groupId>org.cqframework</groupId>
<artifactId>quick</artifactId>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<groupId>org.cqframework</groupId>
<artifactId>engine</artifactId>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<groupId>org.cqframework</groupId>
<artifactId>engine-fhir</artifactId>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<groupId>org.cqframework</groupId>
<artifactId>cqf-fhir</artifactId>
</dependency>
<dependency>
<groupId>info.cqframework</groupId>
<groupId>org.cqframework</groupId>
<artifactId>cqf-fhir-npm</artifactId>
</dependency>
<dependency>
Expand All @@ -65,13 +69,6 @@
<version>3.28.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-jackson</artifactId>
<version>3.28.0-SNAPSHOT</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.valfirst</groupId>
<artifactId>slf4j-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private static CqlEngine createEngine(Environment environment, EvaluationSetting
environment, settings.getCqlOptions().getCqlEngineOptions().getOptions());
if (settings.getCqlOptions().getCqlEngineOptions().isDebugLoggingEnabled()) {
var map = new DebugMap();
map.setIsLoggingEnabled(true);
map.setLoggingEnabled(true);
engine.getState().setDebugMap(map);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.opencds.cqf.fhir.cql.cql2elm.content;

import static java.util.Objects.requireNonNull;
import static kotlinx.io.CoreKt.buffered;
import static kotlinx.io.JvmCoreKt.asSource;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import kotlinx.io.Source;
import org.cqframework.cql.cql2elm.LibraryContentType;
import org.cqframework.cql.cql2elm.LibrarySourceProvider;
import org.hl7.elm.r1.VersionedIdentifier;
Expand All @@ -26,7 +29,7 @@ protected BaseFhirLibrarySourceProvider(IAdapterFactory adapterFactory) {
}

@Override
public InputStream getLibraryContent(VersionedIdentifier libraryIdentifier, LibraryContentType libraryContentType) {
public Source getLibraryContent(VersionedIdentifier libraryIdentifier, LibraryContentType libraryContentType) {
requireNonNull(libraryIdentifier, "versionedIdentifier can not be null.");
requireNonNull(libraryContentType, "libraryContentType can not be null.");

Expand All @@ -35,7 +38,8 @@ public InputStream getLibraryContent(VersionedIdentifier libraryIdentifier, Libr
return null;
}

return this.getContentStream(library, libraryContentType.mimeType());
var inputStream = this.getContentStream(library, libraryContentType.mimeType());
return inputStream == null ? null : buffered(asSource(inputStream));
}

protected InputStream getContentStream(IBaseResource library, String contentType) {
Expand All @@ -56,7 +60,7 @@ protected InputStream getContentStream(IBaseResource library, String contentType
}

@Override
public InputStream getLibrarySource(VersionedIdentifier libraryIdentifier) {
public Source getLibrarySource(VersionedIdentifier libraryIdentifier) {
return getLibraryContent(libraryIdentifier, LibraryContentType.CQL);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.opencds.cqf.fhir.cql.cql2elm.content;

import static java.util.Objects.requireNonNull;
import static kotlinx.io.CoreKt.buffered;
import static kotlinx.io.JvmCoreKt.asSource;
import static org.hl7.elm_modelinfo.r1.serializing.XmlModelInfoReaderKt.parseModelInfoXml;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.repository.IRepository;
import java.io.IOException;
import java.util.ArrayList;
import org.hl7.cql.model.ModelIdentifier;
import org.hl7.elm.r1.VersionedIdentifier;
import org.hl7.elm_modelinfo.r1.ModelInfo;
import org.hl7.elm_modelinfo.r1.serializing.ModelInfoReaderFactory;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.opencds.cqf.fhir.cql.cql2elm.util.LibraryVersionSelector;
Expand Down Expand Up @@ -52,10 +53,9 @@ public ModelInfo load(ModelIdentifier modelIdentifier) {
return null;
}

var xmlReader = ModelInfoReaderFactory.getReader(ModelInfoContentType.XML.mimeType());
try {
return xmlReader.read(is);
} catch (IOException e) {
return parseModelInfoXml(buffered(asSource(is)));
} catch (Exception e) {
logger.error(
"Error encountered while loading model info for {}: {}", modelIdentifier.getId(), e.getMessage());
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public IBaseParameters toFhirParameters(EvaluationResult evaluationResult) {

IParametersAdapter pa = this.adapterFactory.createParameters(params);

for (Map.Entry<String, ExpressionResult> entry : evaluationResult.expressionResults.entrySet()) {
for (Map.Entry<String, ExpressionResult> entry :
evaluationResult.getExpressionResults().entrySet()) {
String name = entry.getKey();
Object value = entry.getValue().value();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void duplicateSettingsNpmProcessor() {

var engine = getEngine(settings);

assertTrue(engine.getState().getDebugMap().getIsLoggingEnabled());
assertTrue(engine.getState().getDebugMap().isLoggingEnabled());

assertDataProviders(engine);
}
Expand All @@ -124,7 +124,7 @@ void duplicateSettingsNullNpmProcessor() {

var engine = getEngine(settings);

assertTrue(engine.getState().getDebugMap().getIsLoggingEnabled());
assertTrue(engine.getState().getDebugMap().isLoggingEnabled());

assertDataProviders(engine);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ void debugLoggingEnabled() {
var settings = EvaluationSettings.getDefault();
settings.getCqlOptions().getCqlEngineOptions().setDebugLoggingEnabled(true);
var engine = getEngine(settings);
assertTrue(engine.getState().getDebugMap().getIsLoggingEnabled());
assertTrue(engine.getState().getDebugMap().isLoggingEnabled());

assertDataProviders(engine);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.opencds.cqf.fhir.cql;

import static kotlinx.io.CoreKt.buffered;
import static kotlinx.io.JvmCoreKt.asSource;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand All @@ -10,11 +12,11 @@
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.repository.IRepository;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Map;
import kotlinx.io.Source;
import org.cqframework.cql.cql2elm.LibraryContentType;
import org.cqframework.cql.cql2elm.LibrarySourceProvider;
import org.hl7.elm.r1.VersionedIdentifier;
Expand Down Expand Up @@ -140,15 +142,15 @@ void expressionWithLibraryResourceProvider() {
var libraryResourceProvider = new ArrayList<LibrarySourceProvider>();
libraryResourceProvider.add(new LibrarySourceProvider() {
@Override
public InputStream getLibrarySource(VersionedIdentifier libraryIdentifier) {
public Source getLibrarySource(VersionedIdentifier libraryIdentifier) {
return null;
}

@Override
public InputStream getLibraryContent(VersionedIdentifier libraryIdentifier, LibraryContentType type) {
public Source getLibraryContent(VersionedIdentifier libraryIdentifier, LibraryContentType type) {
if ("MyLibrary".equals(libraryIdentifier.getId()))
return new ByteArrayInputStream(libraryCql.getBytes(StandardCharsets.UTF_8));
else return LibrarySourceProvider.super.getLibraryContent(libraryIdentifier, type);
return buffered(asSource(new ByteArrayInputStream(libraryCql.getBytes(StandardCharsets.UTF_8))));
else return LibrarySourceProvider.DefaultImpls.getLibraryContent(this, libraryIdentifier, type);
}
});
var evaluationSettings = EvaluationSettings.getDefault().withLibrarySourceProviders(libraryResourceProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class RepositoryFhirModelInfoProviderTest {
private IRepository repository;
private IAdapterFactory adapterFactory;
private RepositoryFhirModelInfoProvider fixture;
private ModelIdentifier usCoreModelId =
new ModelIdentifier().withId("USCore").withVersion("7.0.0");
private ModelIdentifier usCoreModelId = new ModelIdentifier("USCore", null, "7.0.0");

@BeforeEach
void beforeEach() {
Expand Down Expand Up @@ -53,7 +52,7 @@ void testLoadModelInfo() {

@Test
void testLoadModelInfo_Exception() {
var actual = fixture.load(new ModelIdentifier().withId("Invalid").withVersion("1.0.0"));
var actual = fixture.load(new ModelIdentifier("Invalid", null, "1.0.0"));
assertNull(actual);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void evaluationResultToParameters() {
expected.addParameter().setName("Numerator").setValue(new BooleanType(true));

var testData = new EvaluationResult();
testData.expressionResults.put("Patient", new ExpressionResult(new Patient(), null));
testData.expressionResults.put("Numerator", new ExpressionResult(true, null));
testData.getExpressionResults().put("Patient", new ExpressionResult(new Patient(), null));
testData.getExpressionResults().put("Numerator", new ExpressionResult(true, null));

var actual = (Parameters) cqlFhirParametersConverter.toFhirParameters(testData);

Expand All @@ -79,8 +79,8 @@ void evaluationResultToEmptyListParameters() {
expected.addParameter().setName("Encounters").setValue(emptyListMarker());

var testData = new EvaluationResult();
testData.expressionResults.put("Patient", new ExpressionResult(new Patient(), null));
testData.expressionResults.put("Encounters", new ExpressionResult(Collections.emptyList(), null));
testData.getExpressionResults().put("Patient", new ExpressionResult(new Patient(), null));
testData.getExpressionResults().put("Encounters", new ExpressionResult(Collections.emptyList(), null));

Parameters actual = (Parameters) cqlFhirParametersConverter.toFhirParameters(testData);

Expand All @@ -98,7 +98,7 @@ void evalutionResultsWithListContainingNullValue() {
testList.add(5);

var testData = new EvaluationResult();
testData.expressionResults.put("NullInList", new ExpressionResult(testList, null));
testData.getExpressionResults().put("NullInList", new ExpressionResult(testList, null));

var actual = (Parameters) cqlFhirParametersConverter.toFhirParameters(testData);

Expand All @@ -112,8 +112,8 @@ void evaluationResultNullParameters() {
expected.addParameter().setName("Null").setValue(nullValueMarker());

var testData = new EvaluationResult();
testData.expressionResults.put("Patient", new ExpressionResult(new Patient(), null));
testData.expressionResults.put("Null", new ExpressionResult(null, null));
testData.getExpressionResults().put("Patient", new ExpressionResult(new Patient(), null));
testData.getExpressionResults().put("Null", new ExpressionResult(null, null));

var actual = (Parameters) cqlFhirParametersConverter.toFhirParameters(testData);

Expand Down
6 changes: 0 additions & 6 deletions cqf-fhir-cr-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
<artifactId>cqf-fhir-cql</artifactId>
<version>3.28.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-jackson</artifactId>
<version>3.28.0-SNAPSHOT</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public static Stream<SubjectAndResult> evaluate(CqlCommandArgument arguments) {
return arguments.parameters.context.stream().map(c -> {
var engine = Engines.forRepository(repository, evaluationSettings);
if (arguments.content.cqlPath != null) {
var provider = new DefaultLibrarySourceProvider(Path.of(arguments.content.cqlPath));
var provider = new DefaultLibrarySourceProvider(new kotlinx.io.files.Path(
Path.of(arguments.content.cqlPath).toFile()));
engine.getEnvironment()
.getLibraryManager()
.getLibrarySourceLoader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.stream.StreamSupport;
import org.cqframework.cql.cql2elm.CqlCompilerOptions.Options;
import org.cqframework.cql.cql2elm.CqlTranslatorOptions;
import org.cqframework.cql.cql2elm.CqlTranslatorOptionsMapper;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
import org.hl7.fhir.instance.model.api.IBaseResource;
Expand Down Expand Up @@ -57,7 +56,8 @@ public static EvaluationSettings createEvaluationSettings(String cqlPath, boolea

var optionPath = Path.of(cqlPath).resolve("cql-options.json");
if (Files.exists(optionPath)) {
CqlTranslatorOptions options = CqlTranslatorOptionsMapper.fromFile(optionPath.toString());
CqlTranslatorOptions options =
CqlTranslatorOptions.fromFile(new kotlinx.io.files.Path(optionPath.toFile()));
cqlOptions.setCqlCompilerOptions(options.getCqlCompilerOptions());
}

Expand Down Expand Up @@ -160,7 +160,8 @@ public static void writeResult(EvaluationResult result, OutputStream outputStrea
var writer = new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
try {
// Write the result to the output stream
for (Map.Entry<String, ExpressionResult> libraryEntry : result.expressionResults.entrySet()) {
for (Map.Entry<String, ExpressionResult> libraryEntry :
result.getExpressionResults().entrySet()) {
String key = libraryEntry.getKey();
Object value = Utilities.tempConvert(libraryEntry.getValue().value());
writer.write(key + "=" + value);
Expand Down
8 changes: 1 addition & 7 deletions cqf-fhir-cr-hapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.opencds.cqf.fhir</groupId>
<artifactId>cqf-fhir-jackson</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation</artifactId>
Expand Down Expand Up @@ -194,6 +187,7 @@
<include>org.opencds.cqf.cql:*</include>
<include>org.opencds.cqf.fhir:*</include>
<include>info.cqframework:*</include>
<include>org.cqframework:*</include>
</includes>
</requireReleaseDeps>
</rules>
Expand Down
Loading
Loading