Skip to content

Commit

Permalink
caregaps service testing coverage (#440)
Browse files Browse the repository at this point in the history
* caregaps service testing coverage

* spotless edits

* replace repository in tests to single

* edit properties for reporter in caregaps

* change repository path

* validate resources are present

* fix caregaps class references to measure, add logging

* Fixups for tests

* threading removal

---------

Co-authored-by: Jonathan Percival <[email protected]>
  • Loading branch information
Capt-Mac and JPercival committed Mar 19, 2024
1 parent 0d344ed commit a50e8eb
Show file tree
Hide file tree
Showing 69 changed files with 35,404 additions and 48,763 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
package org.opencds.cqf.fhir.cr.measure;

public class CareGapsProperties {
private boolean threadedCareGapsEnabled = true;
/**
* Implements the reporter element of the
* <a href= "https://www.hl7.org/fhir/measurereport.html">MeasureReport</a> FHIR Resource. This is
* required by the <a href=
* "http:https://hl7.org/fhir/us/davinci-deqm/StructureDefinition/indv-measurereport-deqm">DEQMIndividualMeasureReportProfile</a>
* profile found in the <a href="http:https://build.fhir.org/ig/HL7/davinci-deqm/index.html">Da Vinci
* DEQM FHIR Implementation Guide</a>.
**/
private String careGapsReporter;
/**
* Implements the author element of the
Expand All @@ -23,14 +14,6 @@ public class CareGapsProperties {

private String careGapsCompositionSectionAuthor;

public void setThreadedCareGapsEnabled(boolean threadedCareGapsEnabled) {
this.threadedCareGapsEnabled = threadedCareGapsEnabled;
}

public boolean isThreadedCareGapsEnabled() {
return threadedCareGapsEnabled;
}

public String getMyFhirBaseUrl() {
return fhirBaseUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
Expand All @@ -48,7 +46,6 @@
import org.hl7.fhir.r4.model.Meta;
import org.hl7.fhir.r4.model.Organization;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Resource;
Expand Down Expand Up @@ -89,8 +86,6 @@ public class R4CareGapsService {

private CareGapsProperties careGapsProperties;

private Executor cqlExecutor;

private String serverBase;

private final Map<String, Resource> configuredResources = new HashMap<>();
Expand All @@ -99,12 +94,10 @@ public R4CareGapsService(
CareGapsProperties careGapsProperties,
Repository repository,
MeasureEvaluationOptions measureEvaluationOptions,
Executor executor,
String serverBase) {
this.repository = repository;
this.careGapsProperties = careGapsProperties;
this.measureEvaluationOptions = measureEvaluationOptions;
this.cqlExecutor = executor;
this.serverBase = serverBase;
}

Expand Down Expand Up @@ -150,35 +143,25 @@ public Parameters getCareGapsReport(
Msg.code(2275) + "Only the subject parameter has been implemented.");
}

List<CompletableFuture<ParametersParameterComponent>> futures = new ArrayList<>();
Parameters result = initializeResult();
if (careGapsProperties.isThreadedCareGapsEnabled()) {
patients.forEach(patient -> {
Parameters.ParametersParameterComponent patientReports = patientReports(
periodStart.getValueAsString(),
periodEnd.getValueAsString(),
patient,
statuses,
measures,
organization);
futures.add(CompletableFuture.supplyAsync(() -> patientReports, cqlExecutor));
});

futures.forEach(x -> result.addParameter(x.join()));
} else {
patients.forEach(patient -> {
Parameters.ParametersParameterComponent patientReports = patientReports(
periodStart.getValueAsString(),
periodEnd.getValueAsString(),
patient,
statuses,
measures,
organization);
if (patientReports != null) {
result.addParameter(patientReports);
}
});
if (statuses.isEmpty()) {
throw new RuntimeException("CareGap 'statuses' parameter is empty");
}

checkValidStatusCode(statuses);

Parameters result = initializeResult();
patients.forEach(patient -> {
Parameters.ParametersParameterComponent patientReports = patientReports(
periodStart.getValueAsString(),
periodEnd.getValueAsString(),
patient,
statuses,
measures,
organization);
if (patientReports != null) {
result.addParameter(patientReports);
}
});
return result;
}

Expand Down Expand Up @@ -599,4 +582,15 @@ public static String getFullUrl(String serverAddress, String fhirType, String el
public CareGapsProperties getCareGapsProperties() {
return careGapsProperties;
}

public void checkValidStatusCode(List<String> statuses) {
for (int x = 0; x < statuses.size(); x++) {
var status = statuses.get(x);
if (!status.equals(CareGapsStatusCode.CLOSED_GAP.toString())
&& !status.equals(CareGapsStatusCode.OPEN_GAP.toString())
&& !status.equals(CareGapsStatusCode.NOT_APPLICABLE.toString())) {
throw new RuntimeException("CareGap status parameter: " + status + " is not an accepted value");
}
}
}
}
Loading

0 comments on commit a50e8eb

Please sign in to comment.