Skip to content

Commit 24b43bb

Browse files
committed
Add support for Search CQL Library by URL (and Version) from repository
1 parent cadb818 commit 24b43bb

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

cqf-fhir-cql/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6-
<groupId>org.opencds.cqf.fhir</groupId>
6+
<groupId>org.smartregister</groupId>
77
<artifactId>cqf-fhir-cql</artifactId>
8-
<version>3.8.0</version>
8+
<version>3.8.0-OpenSRP-2-SNAPSHOT</version>
99
<name>FHIR Clinical Reasoning (CQL)</name>
1010
<description>Tools, utilities, code gen to support CQL in FHIR Clinical Reasoning operations</description>
1111

cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/LibraryEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public IBaseParameters evaluate(
7777
var cqlFhirParametersConverter = Engines.getCqlFhirParametersConverter(repository.fhirContext());
7878
var engine = Engines.forRepositoryAndSettings(settings, repository, additionalData, npmProcessor, true);
7979
var evaluationParameters = cqlFhirParametersConverter.toCqlParameters(parameters);
80-
var result = engine.evaluate(id.getId(), expressions, buildContextParameter(patientId), evaluationParameters);
80+
var result = engine.evaluate(id, expressions, buildContextParameter(patientId), evaluationParameters, null);
8181

8282
return cqlFhirParametersConverter.toFhirParameters(result);
8383
}

cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/VersionedIdentifiers.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public static VersionedIdentifier forUrl(String url) {
3232
versionedIdentifier.setId(cqlName);
3333
}
3434

35+
versionedIdentifier.setSystem(urlSplit.length == 2 ? urlSplit[0] + "Library/" : null);
36+
3537
return versionedIdentifier;
3638
}
3739
}

cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/cql2elm/content/RepositoryFhirLibrarySourceProvider.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,29 @@ protected IBaseResource getLibrary(VersionedIdentifier libraryIdentifier) {
4343
this.fhirContext.getResourceDefinition("Bundle").getImplementingClass();
4444
var lt = this.fhirContext.getResourceDefinition("Library").getImplementingClass();
4545

46-
var libs = repository.search(
47-
bt, lt, Searches.byNameAndVersion(libraryIdentifier.getId(), libraryIdentifier.getVersion()));
46+
IBaseBundle libs;
47+
48+
if (libraryIdentifier.getSystem() != null
49+
&& libraryIdentifier.getId() != null
50+
&& libraryIdentifier.getVersion() != null) {
51+
libs =
52+
repository.search(
53+
bt,
54+
lt,
55+
Searches.byUrlAndVersion(
56+
libraryIdentifier.getSystem() + libraryIdentifier.getId(),
57+
libraryIdentifier.getVersion()));
58+
} else if (libraryIdentifier.getSystem() != null && libraryIdentifier.getId() != null) {
59+
libs =
60+
repository.search(
61+
bt, lt, Searches.byUrl(libraryIdentifier.getSystem() + libraryIdentifier.getId()));
62+
} else {
63+
libs =
64+
repository.search(
65+
bt,
66+
lt,
67+
Searches.byNameAndVersion(libraryIdentifier.getId(), libraryIdentifier.getVersion()));
68+
}
4869

4970
var iter = new BundleIterable<>(repository, libs).iterator();
5071

0 commit comments

Comments
 (0)