Skip to content

Commit 4cbcfc0

Browse files
authored
Introduce clinical-reasoning changes to support HEDIS measures. (#683)
* Introduce clinical-reasoning changes to support HEDIS measures. Take the substance of the changes from the jp-cli-2 branch and ensure they work with the latest CR master with, among other things, the repository changes. All tests pass but need to do cleanup. * Cleanup. Remove comments. Remove sysouts. Remove useless logging. Make sure we use jdk17 idioms. Fix Sonar issues. Spotless. * More Sonar. * Add traces to debug Linux test failures. * Add more debug info. * Try capitalizing first letter and lowercasing the rest for fhir types and see if that works. * Try making a case-insensitive subdirectory match. * Use case-insensitive resolve pattern for the entire class. * Fix path verified by unit test to use the correct spacing for all layers of directories. * Revert to some case-sensitive FS operations in order to fix LibraryEngineTests and see how it reacts on Linux. * Rename the "Patient" test folder to "patient". Revert to previous file path resolves. * Rename another patient test directory. * Add more logging. * Make Compartment lowercase in the IgRepository compartment. Rename Component to IgRepositoryCompartment. Fix path in unit test to correspond to new lowercase "patient". * Clean up logging. First round of ni2 refactoring. * Finish nio2 refactoring. Spotless. * Spotless. * Optimize CqlCommand code for nio2 and use of Streams to join strings. Also, delete HedisCliTest, which seems to be used only for ad-hoc testing. * Spotless. * Fix Sonar issues. * Small tweaks. * Add testing for measure reports and txtresults files to CliTest. Also, delete NdjsonBundleExtractor.java.
1 parent 936933d commit 4cbcfc0

31 files changed

Lines changed: 1264 additions & 279 deletions

File tree

.vscode/launch.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,18 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
6-
"configurations": []
6+
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "Launch Java Program",
10+
"request": "launch",
11+
"mainClass": "org.opencds.cqf.fhir.cr.cli.Main",
12+
"projectName": "cqf-fhir-cr-cli",
13+
"args": [
14+
"argfile",
15+
"args.txt"
16+
],
17+
}
18+
19+
]
720
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.EnumSet;
44
import java.util.Set;
5+
import java.util.StringJoiner;
56
import org.opencds.cqf.cql.engine.execution.CqlEngine;
67

78
// TODO: Eventually, the cql-engine needs to expose these itself.
@@ -12,6 +13,7 @@ public class CqlEngineOptions {
1213
private Integer pageSize;
1314
private Integer maxCodesPerQuery;
1415
private Integer queryBatchThreshold;
16+
private boolean enableHedisCompatibilityMode = false;
1517

1618
public Set<CqlEngine.Options> getOptions() {
1719
return this.options;
@@ -61,9 +63,30 @@ public void setQueryBatchThreshold(Integer value) {
6163
this.queryBatchThreshold = value;
6264
}
6365

66+
public void setEnableHedisCompatibilityMode(boolean enableHedisCompatibilityMode) {
67+
this.enableHedisCompatibilityMode = enableHedisCompatibilityMode;
68+
}
69+
70+
public boolean isEnableHedisCompatibilityMode() {
71+
return this.enableHedisCompatibilityMode;
72+
}
73+
6474
public static CqlEngineOptions defaultOptions() {
6575
CqlEngineOptions result = new CqlEngineOptions();
6676
result.options.add(CqlEngine.Options.EnableExpressionCaching);
6777
return result;
6878
}
79+
80+
@Override
81+
public String toString() {
82+
return new StringJoiner(", ", CqlEngineOptions.class.getSimpleName() + "[", "]")
83+
.add("options=" + options)
84+
.add("isDebugLoggingEnabled=" + isDebugLoggingEnabled)
85+
.add("shouldExpandValueSets=" + shouldExpandValueSets)
86+
.add("pageSize=" + pageSize)
87+
.add("maxCodesPerQuery=" + maxCodesPerQuery)
88+
.add("queryBatchThreshold=" + queryBatchThreshold)
89+
.add("enableHedisCompatibilityMode=" + enableHedisCompatibilityMode)
90+
.toString();
91+
}
6992
}

cqf-fhir-cql/src/main/java/org/opencds/cqf/fhir/cql/engine/retrieve/RepositoryRetrieveProvider.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import ca.uhn.fhir.context.FhirContext;
66
import ca.uhn.fhir.model.api.IQueryParameterType;
77
import ca.uhn.fhir.repository.IRepository;
8+
import java.util.Collections;
89
import java.util.HashMap;
910
import java.util.List;
1011
import java.util.Map;
@@ -16,6 +17,7 @@
1617
import org.opencds.cqf.cql.engine.runtime.Interval;
1718
import org.opencds.cqf.cql.engine.terminology.TerminologyProvider;
1819
import org.opencds.cqf.fhir.utility.iterable.BundleMappingIterable;
20+
import org.opencds.cqf.fhir.utility.repository.ig.IgRepository;
1921

2022
public class RepositoryRetrieveProvider extends BaseRetrieveProvider {
2123
private final IRepository repository;
@@ -54,12 +56,23 @@ public Iterable<Object> retrieve(
5456
this.configureProfile(config, dataType, templateId);
5557
this.configureDates(config, dataType, datePath, dateLowPath, dateHighPath, dateRange);
5658

57-
var resources = this.repository.search(bt, resourceType, config.searchParams);
59+
Map<String, String> headers = headersForContext(context, contextValue);
60+
61+
var resources = this.repository.search(bt, resourceType, config.searchParams, headers);
5862

5963
var iter = new BundleMappingIterable<>(repository, resources, p -> p.getResource());
6064
return iter.toStream().filter(config.filter).collect(Collectors.toList());
6165
}
6266

67+
// Create headers for the FHIR compartment search (e.g. X-FHIR-Compartment: Patient/123)
68+
private Map<String, String> headersForContext(String context, Object contextValue) {
69+
if (context == null || contextValue == null) {
70+
return Collections.emptyMap();
71+
}
72+
73+
return Map.of(IgRepository.FHIR_COMPARTMENT_HEADER, context + "/" + contextValue.toString());
74+
}
75+
6376
private void configureProfile(SearchConfig config, String dataType, String templateId) {
6477
var mode = this.getRetrieveSettings().getSearchParameterMode();
6578
switch (mode) {

cqf-fhir-cr-cli/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
<version>3.23.0-SNAPSHOT</version>
7373
<scope>test</scope>
7474
</dependency>
75+
<dependency>
76+
<groupId>org.opencds.cqf.fhir</groupId>
77+
<artifactId>cqf-fhir-cr</artifactId>
78+
<version>3.23.0-SNAPSHOT</version>
79+
<scope>compile</scope>
80+
</dependency>
7581
</dependencies>
7682

7783
<build>

0 commit comments

Comments
 (0)