Class FHIRPathEngine

    • Constructor Detail

      • FHIRPathEngine

        public FHIRPathEngine​(IWorkerContext worker)
        Parameters:
        worker - - used when validating paths (@check), and used doing value set membership when executing tests (once that's defined)
    • Method Detail

      • getChildrenByName

        protected void getChildrenByName​(Base item,
                                         String name,
                                         List<Base> result)
                                  throws org.hl7.fhir.exceptions.FHIRException
        Given an item, return all the children that conform to the pattern described in name Possible patterns: - a simple name (which may be the base of a name with [] e.g. value[x]) - a name with a type replacement e.g. valueCodeableConcept - * which means all children - ** which means all descendants
        Parameters:
        item -
        name -
        result -
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • setLegacyMode

        public void setLegacyMode​(boolean legacyMode)
      • check

        public TypeDetails check​(Object appContext,
                                 String resourceType,
                                 String context,
                                 ExpressionNode expr)
                          throws FHIRLexer.FHIRLexerException,
                                 org.hl7.fhir.exceptions.PathEngineException,
                                 org.hl7.fhir.exceptions.DefinitionException
        check that paths referred to in the ExpressionNode are valid xPathStartsWithValueRef is a hack work around for the fact that FHIR Path sometimes needs a different starting point than the xpath returns a list of the possible types that might be returned by executing the ExpressionNode against a particular context
        Parameters:
        context - - the logical type against which this path is applied
        Throws:
        org.hl7.fhir.exceptions.DefinitionException
        org.hl7.fhir.exceptions.PathEngineException
        FHIRLexer.FHIRLexerException
      • evaluate

        public List<Baseevaluate​(Base base,
                                   ExpressionNode ExpressionNode)
                            throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return the matching elements
        Parameters:
        base - - the object against which the path is being evaluated
        ExpressionNode - - the parsed ExpressionNode statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluate

        public List<Baseevaluate​(Base base,
                                   String path)
                            throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return the matching elements
        Parameters:
        base - - the object against which the path is being evaluated
        path - - the FHIR Path statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluate

        public List<Baseevaluate​(Object appContext,
                                   Resource focusResource,
                                   Resource rootResource,
                                   Base base,
                                   ExpressionNode ExpressionNode)
                            throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return the matching elements
        Parameters:
        base - - the object against which the path is being evaluated
        ExpressionNode - - the parsed ExpressionNode statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluate

        public List<Baseevaluate​(Object appContext,
                                   Base focusResource,
                                   Base rootResource,
                                   Base base,
                                   ExpressionNode expressionNode)
                            throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return the matching elements
        Parameters:
        base - - the object against which the path is being evaluated
        expressionNode - - the parsed ExpressionNode statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluate

        public List<Baseevaluate​(Object appContext,
                                   Resource focusResource,
                                   Resource rootResource,
                                   Base base,
                                   String path)
                            throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return the matching elements
        Parameters:
        base - - the object against which the path is being evaluated
        path - - the FHIR Path statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluateToBoolean

        public boolean evaluateToBoolean​(Resource focusResource,
                                         Resource rootResource,
                                         Base base,
                                         String path)
                                  throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return true or false (e.g. for an invariant)
        Parameters:
        base - - the object against which the path is being evaluated
        path - - the FHIR Path statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluateToBoolean

        public boolean evaluateToBoolean​(Resource focusResource,
                                         Resource rootResource,
                                         Base base,
                                         ExpressionNode node)
                                  throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return true or false (e.g. for an invariant)
        Parameters:
        base - - the object against which the path is being evaluated
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluateToBoolean

        public boolean evaluateToBoolean​(Object appInfo,
                                         Resource focusResource,
                                         Resource rootResource,
                                         Base base,
                                         ExpressionNode node)
                                  throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return true or false (e.g. for an invariant)
        Parameters:
        appInfo - - application context
        base - - the object against which the path is being evaluated
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluateToBoolean

        public boolean evaluateToBoolean​(Object appInfo,
                                         Base focusResource,
                                         Base rootResource,
                                         Base base,
                                         ExpressionNode node)
                                  throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and return true or false (e.g. for an invariant)
        Parameters:
        base - - the object against which the path is being evaluated
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • evaluateToString

        public String evaluateToString​(Base base,
                                       String path)
                                throws org.hl7.fhir.exceptions.FHIRException
        evaluate a path and a string containing the outcome (for display)
        Parameters:
        base - - the object against which the path is being evaluated
        path - - the FHIR Path statement to use
        Returns:
        Throws:
        org.hl7.fhir.exceptions.FHIRException
      • convertToString

        public String convertToString​(List<Base> items)
        worker routine for converting a set of objects to a string representation
        Parameters:
        items - - result from @evaluate
        Returns:
      • convertToBoolean

        public boolean convertToBoolean​(List<Base> items)
        worker routine for converting a set of objects to a boolean representation (for invariants)
        Parameters:
        items - - result from @evaluate
        Returns:
      • hasLog

        public boolean hasLog()
      • evaluateDefinition

        public ElementDefinition evaluateDefinition​(ExpressionNode expr,
                                                    StructureDefinition profile,
                                                    ElementDefinition element)
                                             throws org.hl7.fhir.exceptions.DefinitionException
        given an element definition in a profile, what element contains the differentiating fixed for the element, given the differentiating expresssion. The expression is only allowed to use a subset of FHIRPath
        Parameters:
        profile -
        element -
        Returns:
        Throws:
        org.hl7.fhir.exceptions.PathEngineException
        org.hl7.fhir.exceptions.DefinitionException