Skip to content

Commit

Permalink
Removed unused HAPIFhir method and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-pabon-tf committed Mar 22, 2024
1 parent 5b3f7f6 commit dd6c19c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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<Base> 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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,7 +14,5 @@ <T extends IBaseResource> T parseResource(String fhirResource, Class<T> clazz)

String encodeResourceToJson(Object resource);

List<Base> evaluate(IBaseResource root, String expression);

Boolean evaluateCondition(IBaseResource root, String expression);
}

0 comments on commit dd6c19c

Please sign in to comment.