From dd6c19c8ef017f2b253d0c3cbcb64bfbf2c6b9bf Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Fri, 22 Mar 2024 14:23:53 -0400 Subject: [PATCH] Removed unused HAPIFhir method and tests --- .../hapi/HapiFhirImplementationTest.groovy | 68 ------------------- .../external/hapi/HapiFhirImplementation.java | 14 ---- .../wrappers/HapiFhir.java | 4 -- 3 files changed, 86 deletions(-) diff --git a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementationTest.groovy b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementationTest.groovy index 5f61006a5..fb2f91d3e 100644 --- a/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementationTest.groovy +++ b/etor/src/test/groovy/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementationTest.groovy @@ -38,74 +38,6 @@ class HapiFhirImplementationTest extends Specification { bundle.addEntry(entry2) } - def "evaluate returns the correct resource if it's available"() { - given: - def path = "Bundle.entry.resource.ofType(DiagnosticReport)[0]" - - when: - def result = fhir.evaluate(bundle as IBaseResource, path) - - then: - result.size() == 1 - result.first().class == DiagnosticReport.class - (result.first() as DiagnosticReport).id == diaReport.id - } - - def "evaluate returns empty list on bad extension names"() { - given: - def path = "Bundle.extension('blah').value" - - when: - def result = fhir.evaluate(bundle as IBaseResource, path) - - then: - result.isEmpty() - } - - def "evaluate throws FhirPathExecutionException on empty path"() { - given: - def path = "" - - when: - fhir.evaluate(bundle as IBaseResource, path) - - then: - thrown(FhirPathExecutionException) - } - - def "evaluate returns true on successful boolean checks"() { - given: - def path = "Bundle.entry.resource.ofType(DiagnosticReport)[0].exists()" - - when: - def result = fhir.evaluate(bundle as IBaseResource, path) - - then: - result[0].primitiveValue() == "true" - } - - def "evaluate returns false on unsuccessful boolean checks"() { - given: - def path = "Bundle.entry.resource.ofType(Practitioner)[0].exists()" - - when: - def result = fhir.evaluate(bundle as IBaseResource, path) - - then: - result[0].primitiveValue() == "false" - } - - def "evaluate throws FhirPathExecutionException on invalid boolean checks"() { - given: - def path = "Bundle.entry.resource.ofType(SomeFakeType)[0].exists()" - - when: - fhir.evaluate(bundle as IBaseResource, path) - - then: - thrown(FhirPathExecutionException) - } - def "evaluateCondition returns true on finding existing value"() { given: def path = "Bundle.id.exists()" diff --git a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementation.java b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementation.java index 7876f6f8e..d458b3926 100644 --- a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementation.java +++ b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/external/hapi/HapiFhirImplementation.java @@ -5,9 +5,7 @@ import ca.uhn.fhir.parser.IParser; import gov.hhs.cdc.trustedintermediary.wrappers.FhirParseException; import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir; -import java.util.List; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.Base; import org.hl7.fhir.r4.model.BooleanType; /** Concrete implementation that calls the Hapi FHIR library. */ @@ -49,18 +47,6 @@ public String encodeResourceToJson(Object resource) { return encodeResourceParser.encodeResourceToString((IBaseResource) resource); } - /** - * Evaluate a FHIR Path expression for a given Resource to find matching elements. - * - * @param root FHIR resource the evaluation starts from. - * @param expression FHIR Path statement to run evaluations on. - * @return A list of matching Resources within root for the given expression. - */ - @Override - public List evaluate(IBaseResource root, String expression) { - return PATH_ENGINE.evaluate(root, expression, Base.class); - } - /** * Evaluate a FHIR Path expression for a given Resource to find if the expression has matches * diff --git a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/wrappers/HapiFhir.java b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/wrappers/HapiFhir.java index 266bd1137..2c326fc51 100644 --- a/shared/src/main/java/gov/hhs/cdc/trustedintermediary/wrappers/HapiFhir.java +++ b/shared/src/main/java/gov/hhs/cdc/trustedintermediary/wrappers/HapiFhir.java @@ -1,8 +1,6 @@ package gov.hhs.cdc.trustedintermediary.wrappers; -import java.util.List; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.Base; /** * An interface that wraps around the Hapi FHIR library. It is Hapi-specific because making it @@ -16,7 +14,5 @@ T parseResource(String fhirResource, Class clazz) String encodeResourceToJson(Object resource); - List evaluate(IBaseResource root, String expression); - Boolean evaluateCondition(IBaseResource root, String expression); }