Skip to content

Commit

Permalink
More Sonar.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukedegruchy committed Mar 7, 2025
1 parent 3d61fdf commit f55f567
Show file tree
Hide file tree
Showing 29 changed files with 231 additions and 326 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package org.opencds.cqf.fhir.cr.measure.r4;

import java.io.IOException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given;

@SuppressWarnings("java:S2699")
class BloodPressureMeasureProcessorTest {

protected static Given given = Measure.given().repositoryFor("ControllingBloodPressureFHIR");

@Test
@Disabled("source bundle is missing needed data")
void exm165_singlePatient_numerator() throws IOException {
void exm165_singlePatient_numerator() {

given.when()
.measureId("ControllingBloodPressureFHIR")
Expand All @@ -31,7 +31,7 @@ void exm165_singlePatient_numerator() throws IOException {

@Test
@Disabled("source bundle is missing needed data")
void exm165_population() throws IOException {
void exm165_population() {

given.when()
.measureId("ControllingBloodPressureFHIR")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.opencds.cqf.fhir.cr.measure.r4;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opencds.cqf.fhir.cr.measure.constant.CareGapsConstants.CARE_GAPS_DETECTED_ISSUE_MR_GROUP_ID;
Expand Down Expand Up @@ -39,7 +40,6 @@
import org.opencds.cqf.fhir.cr.measure.CareGapsProperties;
import org.opencds.cqf.fhir.cr.measure.MeasureEvaluationOptions;
import org.opencds.cqf.fhir.cr.measure.common.MeasurePeriodValidator;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.SelectedReport;
import org.opencds.cqf.fhir.utility.repository.ig.IgRepository;

public class CareGaps {
Expand Down Expand Up @@ -303,6 +303,7 @@ public DetectedIssue resourceToDetectedIssue(Resource theResource) {
IParser parser = FhirContext.forR4Cached().newJsonParser();
return (DetectedIssue) parser.parseResource(parser.encodeResourceToString(theResource));
}

// Composition getters
public SelectedComposition composition() {
return this.composition(g -> resourceToComposition(g.getEntry().stream()
Expand All @@ -311,7 +312,6 @@ public SelectedComposition composition() {
.get()
.getResource()));
}
;

public SelectedComposition composition(Selector<Composition, Bundle> bundleSelector) {
var p = bundleSelector.select(value());
Expand All @@ -334,7 +334,6 @@ public SelectedBundle measureReportCount(int measureReportCount) {
.size());
return this;
}
;

public SelectedMeasureReport measureReport(Selector<MeasureReport, Bundle> bundleSelector) {
var p = bundleSelector.select(value());
Expand Down Expand Up @@ -388,7 +387,6 @@ public SelectedOrganization organization() {
.get()
.getResource()));
}
;

public SelectedOrganization organization(Selector<Organization, Bundle> bundleSelector) {
var p = bundleSelector.select(value());
Expand Down Expand Up @@ -433,7 +431,7 @@ public SelectedDetectedIssue hasImplicatedMeasureReference() {

public SelectedDetectedIssue hasContainedMeasureReport() {
var containedResource = detectedIssueReport().getContained().get(0);
assertTrue(containedResource instanceof MeasureReport);
assertInstanceOf(MeasureReport.class, containedResource);
return this;
}

Expand All @@ -447,9 +445,7 @@ public SelectedDetectedIssue hasContainedEvidenceReference() {
}

public SelectedDetectedIssue hasPatientReference(String patientRef) {
assertEquals(
patientRef,
detectedIssueReport().getPatient().getReference().toString());
assertEquals(patientRef, detectedIssueReport().getPatient().getReference());
return this;
}

Expand Down Expand Up @@ -484,12 +480,12 @@ public SelectedComposition hasSubjectReference(String subjectRef) {
return this;
}
// author
public SelectedComposition hasAuthor(String OrgReference) {
public SelectedComposition hasAuthor(String orgReference) {
// author not empty
assertNotNull(compositionReport().getAuthor().get(0));
// author was found
assertNotNull(compositionReport().getAuthor().stream()
.filter(x -> x.getReference().contains(OrgReference))
.filter(x -> x.getReference().contains(orgReference))
.findFirst()
.get());
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.junit.jupiter.api.Test;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given;

@SuppressWarnings("squid:S2699")
class DaVinciExtensionMeasureProcessorTest {

protected static Given given = Measure.given().repositoryFor("BreastCancerScreeningFHIR");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.opencds.cqf.fhir.cr.measure.r4;

import ca.uhn.fhir.context.FhirContext;
import java.io.IOException;
import org.hl7.fhir.r4.model.Bundle;
import org.junit.jupiter.api.Test;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given;

@SuppressWarnings("squid:S2699")
class DiabetesMeasureProcessorTest {

protected static Given given = Measure.given().repositoryFor("DiabetesHemoglobinA1cHbA1cPoorControl9FHIR");
Expand All @@ -29,7 +29,7 @@ void a1c_singlePatient_numerator() {
}

@Test
void a1c_population() throws IOException {
void a1c_population() {
given.when()
.measureId("DiabetesHemoglobinA1cHbA1cPoorControl9FHIR")
.periodStart("2019-01-01")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void evaluateThrowsErrorWhenLibraryUnavailable() {
.when()
.measureId("LibraryUnavailable")
.evaluate();
assertThrows(ResourceNotFoundException.class, () -> when.then());
assertThrows(ResourceNotFoundException.class, when::then);
}

@Test
Expand All @@ -36,7 +36,7 @@ void evaluateThrowsErrorWhenLibraryIsMissingContent() {
.when()
.measureId("LibraryMissingContent")
.evaluate();
var e = assertThrows(IllegalStateException.class, () -> when.then());
var e = assertThrows(IllegalStateException.class, when::then);
assertTrue(e.getMessage().contains("Unable to load CQL/ELM for library"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.opencds.cqf.fhir.cql.engine.terminology.TerminologySettings.VALUESET_EXPANSION_MODE;
import org.opencds.cqf.fhir.cr.measure.MeasureEvaluationOptions;

public class MeasureAdditionalDataAndCustomOptionsTests {
class MeasureAdditionalDataAndCustomOptionsTests {

private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.opencds.cqf.fhir.cr.measure.constant.MeasureConstants;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given;

@SuppressWarnings("squid:S2699")
public class MeasureConditionCategoryPOCTest {
protected static Given given = Measure.given().repositoryFor("ConditionCategoryPoc");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import jakarta.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -47,7 +48,7 @@
/**
* Test MeasureDefBuilder on different scenarios around group level Measure settings and if they are properly being set
*/
public class MeasureDefBuilderTest {
class MeasureDefBuilderTest {
private final CodeableConcept increase = new CodeableConcept(new Coding(
MeasureReportConstants.MEASUREREPORT_IMPROVEMENT_NOTATION_SYSTEM,
IMPROVEMENT_NOTATION_SYSTEM_INCREASE,
Expand Down Expand Up @@ -337,65 +338,37 @@ void BasisMeasureInvalid() {
}
}

@Test
void scoringMeasureScoringAndGroup() {
var def = measureDefBuilder(
null, "ratio", null, null, null, "proportion", null, null, "boolean", "cohort", decrease);

validateMeasureDef(
def,
true,
"boolean",
false,
"decrease",
MeasureScoring.RATIO,
null,
true,
"boolean",
false,
"decrease",
MeasureScoring.PROPORTION,
null);
}

@Test
void scoringMeasure() {
var def = measureDefBuilder(null, null, null, null, null, null, null, null, "boolean", "cohort", decrease);

validateMeasureDef(
def,
true,
"boolean",
false,
"decrease",
MeasureScoring.COHORT,
null,
true,
"boolean",
false,
"decrease",
MeasureScoring.COHORT,
null);
private static Stream<Arguments> scoringMeasureScoringAndGroupParams() {
return Stream.of(
Arguments.of("cohort", "ratio", "proportion", MeasureScoring.RATIO, MeasureScoring.PROPORTION),
Arguments.of("cohort", null, null, MeasureScoring.COHORT, MeasureScoring.COHORT),
Arguments.of(null, "ratio", "proportion", MeasureScoring.RATIO, MeasureScoring.PROPORTION));
}

@Test
void groupScoring() {
var def =
measureDefBuilder(null, "ratio", null, null, null, "proportion", null, null, "boolean", null, decrease);
@ParameterizedTest
@MethodSource("scoringMeasureScoringAndGroupParams")
void scoringMeasureScoringAndGroup(
String measureScoring,
@Nullable String group1Scoring,
@Nullable String group2Scoring,
MeasureScoring expectedGroup1MeasureScoring,
MeasureScoring expectedGroup2MeasureScoring) {
var def = measureDefBuilder(
null, group1Scoring, null, null, null, group2Scoring, null, null, "boolean", measureScoring, decrease);

validateMeasureDef(
def,
true,
"boolean",
false,
"decrease",
MeasureScoring.RATIO,
expectedGroup1MeasureScoring,
null,
true,
"boolean",
false,
"decrease",
MeasureScoring.PROPORTION,
expectedGroup2MeasureScoring,
null);
}

Expand Down Expand Up @@ -477,27 +450,6 @@ void groupImprovementNotation() {
null);
}

@Test
void measureImprovementNotation() {
var def =
measureDefBuilder(null, "ratio", null, null, null, "proportion", null, null, "boolean", null, decrease);

validateMeasureDef(
def,
true,
"boolean",
false,
"decrease",
MeasureScoring.RATIO,
null,
true,
"boolean",
false,
"decrease",
MeasureScoring.PROPORTION,
null);
}

@Test
void noImprovementNotation() {
var def = measureDefBuilder(null, "ratio", null, null, null, "proportion", null, null, "boolean", null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* * populations (ex: initial-population), which include stratifiers
* No duplicate references in evaluated resources
*/
public class MeasureEvaluatedResourcesTest {
@SuppressWarnings("squid:S2699")
class MeasureEvaluatedResourcesTest {
private static final String CLASS_PATH = "org/opencds/cqf/fhir/cr/measure/r4";
private static final Repository repository = new IgRepository(
FhirContext.forR4Cached(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import org.opencds.cqf.fhir.cr.measure.r4.utils.TestDataGenerator;
import org.opencds.cqf.fhir.utility.repository.ig.IgRepository;

public class MeasureImprovementNotationTest {
@SuppressWarnings("squid:S2699")
class MeasureImprovementNotationTest {
// undefined improvementNotation
// measure defined
// group defined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.junit.jupiter.params.provider.CsvSource;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given;

public class MeasureMultipleSdeTest {
class MeasureMultipleSdeTest {
private static final Given GIVEN_MULTIPLE_SDE_MEASURE_REPO =
Measure.given().repositoryFor("BreastCancerScreeningFHIR");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import jakarta.annotation.Nullable;
import java.util.stream.Stream;
import org.hl7.fhir.r4.model.MeasureReport;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.opencds.cqf.fhir.utility.r4.Parameters;

public class MeasureProcessorCQLParameterTest {
class MeasureProcessorCQLParameterTest {

private static Stream<Arguments> simpleParametersParams() {
return Stream.of(
Expand All @@ -31,7 +30,6 @@ private static Stream<Arguments> simpleParametersParams() {
Arguments.of(Parameters.parameters(Parameters.part("encounterParam", "SimpleCqlParamsEncounter1")), 1));
}

@Disabled
@ParameterizedTest
@MethodSource("simpleParametersParams")
void simpleParameters(@Nullable org.hl7.fhir.r4.model.Parameters parameters, int expectedMeasureCount) {
Expand Down Expand Up @@ -65,13 +63,14 @@ private void assertPopulation(
assertTrue(population.getCode().getCodingFirstRep().hasCode());
String code = population.getCode().getCodingFirstRep().getCode();
switch (code) {
case "initial-population":
case "denominator":
case "initial-population", "denominator":
assertEquals(1, population.getCount());
break;
case "numerator":
assertEquals(expectedMeasureCount, population.getCount());
break;
default:
throw new IllegalArgumentException("Unexpected population code: " + code);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* has correct status
* has period
*/
public class MeasureReportTypeIndividualTest {
class MeasureReportTypeIndividualTest {
private static final String CLASS_PATH = "org/opencds/cqf/fhir/cr/measure/r4";
private static final Repository repository = new IgRepository(
FhirContext.forR4Cached(),
Expand Down
Loading

0 comments on commit f55f567

Please sign in to comment.