hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.04k stars 1.33k forks source link

6.4.x FHIRPathEngine fails several operations #4794

Open XcrigX opened 1 year ago

XcrigX commented 1 year ago

Several FHIRPath operations fail under 6.4.0, more under 6.4.4. Such as: Observation.value.as(string)

ca.uhn.fhir.fhirpath.FhirPathExecutionException: HAPI-0255: org.hl7.fhir.exceptions.PathEngineException: The type FHIR.string is not valid
    at org.hl7.fhir.r4.hapi.fluentpath.FhirPathR4.evaluate(FhirPathR4.java:42)

I created a minimal test project here to illustrate the errors I'm seeing on 6.4.4: https://github.com/XcrigX/hapi644-test. It simply imports the HAPI 6.4.4 libs and has a single unit test which is a copy of the test from the base project here: https://github.com/hapifhir/hapi-fhir/blob/master/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java

see also: https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/HAPI.206.2E4.2Ex.20FHIRPath.20errorshttps://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/HAPI.206.2E4.2Ex.20FHIRPath.20errors

XcrigX commented 1 year ago

It turns out that adding a dependency for the validation resources clear up these issues. i.e. a dependency such as:

        <dependency>
              <groupId>ca.uhn.hapi.fhir</groupId>
              <artifactId>hapi-fhir-validation-resources-r4</artifactId>
              <version>${hapifhir.version}</version>
           </dependency>

I'm not convinced that these shouldn't be loaded transitively, or throw some error when a FhirPathEngine is instantiated when they are missing, or something. It wasn't clear to me this dependency was needed to evaluate FhirPath expressions.

jamesagnew commented 1 year ago

Ahhh interesting. I'd agree, that's a really unhelpful error message. Will see what we can do about that.

On Fri, May 26, 2023 at 2:24 PM craig mcclendon @.***> wrote:

It turns out that adding a dependency for the validation resources clear up these issues. i.e. a dependency such as:

  <dependency>
        <groupId>ca.uhn.hapi.fhir</groupId>
        <artifactId>hapi-fhir-validation-resources-r4</artifactId>
        <version>${hapifhir.version}</version>
     </dependency>

I'm not convinced that these shouldn't be loaded transitively, or throw some error when a FhirPathEngine is instantiated when they are missing, or something. It wasn't clear to me this dependency was needed to evaluate FhirPath expressions.

— Reply to this email directly, view it on GitHub https://github.com/hapifhir/hapi-fhir/issues/4794#issuecomment-1564762843, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2N7HMTSEBLMNQO45EAVYDXIDYMHANCNFSM6AAAAAAXRZK3LA . You are receiving this because you are subscribed to this thread.Message ID: @.***>