Interface IHostApplicationServices

All Known Implementing Classes:
BaseHostServices, LiquidEngine, Runner

public interface IHostApplicationServices
This interface allows the application making use of a FHIRPathEngine to provide additional services that can be used in the FHIRPath statements. The services fall into two categories: extending the FHIRPath engine with types, constants and functions, and performing work that the FHIRPath engine doesn't know how to do itself Functionality: * resolveConstant()/resolveConstantType() - register constants * log() - do something when .log() is used in the FHIRPath statement * resolveFunction() / checkFunction() / executeFunction() - allow the application to define FHIRPath functions of it's own * resolveReference() - called when a FHIRPath statement uses 'resolve()' so the host application can attempt to resolve the reference * resolveValueSet() - called when memberOf() is used * conformsToProfile() - check that the content conforms to the stated profile. Used by the ValidationEngine - not generally suitable for applications to provide their own interface * paramIsType() - used when the FHIRPath statement Note that his used to be called IEvaluationContext in the FHIRPathEngine class, but was renamed due to a broken interface - see comments at https://github.com/hapifhir/org.hl7.fhir.core/releases/tag/6.6.0
  • Method Details

    • resolveConstant

      List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode mode) throws org.hl7.fhir.exceptions.PathEngineException
      A constant reference - e.g. a reference to a name that must be resolved in context. resolveConstant is invoked under 3 different circumstances, which are reflected in the mode parameter: * an explicit constant of the form %{token}, where the token isn't a known internal constant * every evaluation of any expression to allow the Host Application to decide whether to interpret the expression as a constant even if it is not explicitly a constant * at the start of evaluating an expression if the focus provided by the application when invoking the expression is {} The return value is a List - a collection, though most constants are singleton values note that variables created using defineVariable() in the FHIRPath expressions will not be processed by resolveConstant (or resolveConstantType)
      Parameters:
      appContext - - application context passed into the FHIRPath engine when first executed
      name - - name reference to resolve. if mode = EXPLICIT, the % will NOT be in the name
      mode - - what situation the reference comes from - see the documentation for @FHIRPathConstantEvaluationMode
      Returns:
      the value of the constant , or an empty list, though the host application can choose to throw an exception
      Throws:
      org.hl7.fhir.exceptions.PathEngineException
    • resolveConstantType

      TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode mode) throws org.hl7.fhir.exceptions.PathEngineException
      Compile time support for a constant reference - e.g. a reference to a name that must be resolved in context. resolveConstant is invoked under 3 different circumstances, which are reflected in the mode parameter: * an explicit constant of the form %{token}, where the token isn't a known internal constant * every evaluation of any expression to allow the Host Application to decide whether to interpret the expression as a constant even if it is not explicitly a constant * at the start of evaluating an expression if the focus provided by the application when invoking the expression is {} The return value is a TypeDetails - a collection, though most constants are singleton values note that variables created using defineVariable() in the FHIRPath expressions will not be processed by resolveConstant (or resolveConstantType)
      Parameters:
      appContext - - application context passed into the FHIRPath engine when first executed
      name - - name reference to resolve. if mode = EXPLICIT, the % will NOT be in the name
      mode - - what situation the reference comes from - see the documentation for @FHIRPathConstantEvaluationMode
      Returns:
      the type of the constant, or null, though the host application can choose to throw an exception
      Throws:
      org.hl7.fhir.exceptions.PathEngineException
    • log

      boolean log(String argument, List<Base> focus)
      when the .log() function is called
      Parameters:
      argument -
      focus -
      Returns:
    • resolveFunction

      Parameters:
      functionName -
      Returns:
      null if the function is not known
    • checkFunction

      TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws org.hl7.fhir.exceptions.PathEngineException
      Check the function parameters, and throw an error if they are incorrect, or return the type for the function
      Parameters:
      functionName -
      parameters -
      Returns:
      Throws:
      org.hl7.fhir.exceptions.PathEngineException
    • executeFunction

      List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters)
      Parameters:
      appContext -
      functionName -
      parameters -
      Returns:
    • resolveReference

      Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Identifier identifier, Base refContext) throws org.hl7.fhir.exceptions.FHIRException
      Implementation of resolve() function. Passed a string/identifier, return matching resource, if one is known - else null The signature of this method was changed as of version 6.8.2+. We could have added another routine, but that would make implementation really difficult where you might resolve either with url or identifier, and you'd still have to make the same amount of changes. If you don't use logical references, just ignore the identifier
      Parameters:
      engine - - the FHIRPath engine that is the operational context of the request
      appContext - - the application provided context when FHIRPath was invoked
      url - - the reference (Reference.reference or the value of the canonical)
      identifier - - the identifier, if one was present (from Reference.identifier)
      refContext - - the object that contained the reference - this can be used to help resolve the reference
      Returns:
      A Base that is the resource being referenced
      Throws:
      org.hl7.fhir.exceptions.FHIRException
    • conformsToProfile

      boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws org.hl7.fhir.exceptions.FHIRException
      Throws:
      org.hl7.fhir.exceptions.FHIRException
    • resolveValueSet

      ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url)
    • paramIsType

      boolean paramIsType(String name, int index)
      For the moment, there can only be one parameter if it's a type parameter
      Parameters:
      name -
      Returns:
      true if it's a type parameter