Class Actions


  • public abstract class Actions
    extends java.lang.Object
    The Actions class represents the set of all actions the Flexporter can perform. The entry point is the applyMapping function which invokes the appropriate method. Unlike the State class where each state type is a subclass, this uses a method to represent each action. At some point it may be refactored to be more like State.
    • Constructor Summary

      Constructors 
      Constructor Description
      Actions()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.hl7.fhir.r4.model.Bundle applyAction​(org.hl7.fhir.r4.model.Bundle bundle, java.util.Map<java.lang.String,​java.lang.Object> action, Person person, FlexporterJavascriptContext fjContext)
      Apply the given single Action to the provided Bundle.
      static org.hl7.fhir.r4.model.Bundle applyMapping​(org.hl7.fhir.r4.model.Bundle bundle, Mapping mapping, Person person, FlexporterJavascriptContext fjContext)
      Apply the given Mapping to the provided Bundle.
      static void applyProfile​(org.hl7.fhir.r4.model.Resource resource, java.lang.String profileURL)
      Helper function to add a single profile URL to a resource, and set the Meta if not already set.
      static void applyProfiles​(org.hl7.fhir.r4.model.Bundle bundle, java.util.List<java.util.Map<java.lang.String,​java.lang.String>> items)
      Apply a profile to resources matching certain rules.
      static void createResource​(org.hl7.fhir.r4.model.Bundle bundle, java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> resourcesToCreate, Person person, FlexporterJavascriptContext fjContext)
      Create new resources to add to the Bundle, either a single resource or a resource based on other instances of existing resources.
      static void deleteResources​(org.hl7.fhir.r4.model.Bundle bundle, java.util.List<java.lang.String> list)
      Filter the Bundle by removing selected resources.
      static org.hl7.fhir.r4.model.Bundle executeScript​(java.util.List<java.util.Map<java.lang.String,​java.lang.String>> scripts, org.hl7.fhir.r4.model.Bundle bundle, FlexporterJavascriptContext fjContext)
      Execute scripts against the given Bundle.
      static void setValues​(org.hl7.fhir.r4.model.Bundle bundle, java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> items, Person person, FlexporterJavascriptContext fjContext)
      Set values on existing resources within the Bundle, based on rules.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Actions

        public Actions()
    • Method Detail

      • applyMapping

        public static org.hl7.fhir.r4.model.Bundle applyMapping​(org.hl7.fhir.r4.model.Bundle bundle,
                                                                Mapping mapping,
                                                                Person person,
                                                                FlexporterJavascriptContext fjContext)
        Apply the given Mapping to the provided Bundle.
        Parameters:
        bundle - FHIR bundle
        mapping - Flexporter mapping
        person - Synthea Person object that was used to create the Bundle. This will be null if running the flexporter standalone from the run_flexporter task.
        fjContext - Flexporter Javascript Context associated with this run
        Returns:
        the Bundle after all transformations have been applied. Important: in many cases it will be the same Bundle object as passed in, but not always!
      • applyAction

        public static org.hl7.fhir.r4.model.Bundle applyAction​(org.hl7.fhir.r4.model.Bundle bundle,
                                                               java.util.Map<java.lang.String,​java.lang.Object> action,
                                                               Person person,
                                                               FlexporterJavascriptContext fjContext)
        Apply the given single Action to the provided Bundle.
        Parameters:
        bundle - FHIR bundle
        action - Flexporter action
        person - Synthea Person object that was used to create the Bundle. This will be null if running the flexporter standalone from the run_flexporter task.
        fjContext - Flexporter Javascript Context associated with this run
        Returns:
        the Bundle after the transformation has been applied. Important: in many cases it will be the same Bundle object as passed in, but not always!
      • applyProfiles

        public static void applyProfiles​(org.hl7.fhir.r4.model.Bundle bundle,
                                         java.util.List<java.util.Map<java.lang.String,​java.lang.String>> items)
        Apply a profile to resources matching certain rules. Note this only adds the profile URL to resource.meta.profile, it does not apply any other transformations or checking. Resources to apply the profile to are selected by FHIRPath. (Or simply resource type)
        Parameters:
        bundle - Bundle to apply profiles to
        items - List of rule definitions for applying profiles. Each item should have a "profile" for the URL and "applicability" for the FHIRPath to select resources.
      • applyProfile

        public static void applyProfile​(org.hl7.fhir.r4.model.Resource resource,
                                        java.lang.String profileURL)
        Helper function to add a single profile URL to a resource, and set the Meta if not already set.
        Parameters:
        resource - FHIR resource
        profileURL - Profile URL to add, if not already present
      • setValues

        public static void setValues​(org.hl7.fhir.r4.model.Bundle bundle,
                                     java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> items,
                                     Person person,
                                     FlexporterJavascriptContext fjContext)
        Set values on existing resources within the Bundle, based on rules.
        Parameters:
        bundle - Bundle to apply rules to
        items - List of rules. Rules include "applicability" to select which resources to apply values to, and "fields" which are "location" and "value" pairs defining which field to set and what value to put there.
        person - Synthea person object to fetch values from (e.g, attributes). May be null
        fjContext - Javascript context for this run
      • createResource

        public static void createResource​(org.hl7.fhir.r4.model.Bundle bundle,
                                          java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> resourcesToCreate,
                                          Person person,
                                          FlexporterJavascriptContext fjContext)
        Create new resources to add to the Bundle, either a single resource or a resource based on other instances of existing resources. Fields on the resource as well as the "based on" resource will be set based on rules.
        Parameters:
        bundle - Bundle to add resources to
        resourcesToCreate - List of rules. Rules include a "resourceType", optionally a "based_on" FHIRPath to select resources to base the new one off of, and "fields" which are "location" and "value" pairs defining which field to set and what value.
        person - Synthea person object to fetch values from (e.g, attributes). May be null
        fjContext - Javascript context for this run
      • deleteResources

        public static void deleteResources​(org.hl7.fhir.r4.model.Bundle bundle,
                                           java.util.List<java.lang.String> list)
        Filter the Bundle by removing selected resources. Resources that reference deleted resources will also be deleted, and so on. TODO: Support different methods for handling references: Cascade (current), Delete reference field but leave object, Do nothing
        Parameters:
        bundle - FHIR Bundle to filter
        list - List of resource types or FHIRPath to delete, other types not listed will be kept
      • executeScript

        public static org.hl7.fhir.r4.model.Bundle executeScript​(java.util.List<java.util.Map<java.lang.String,​java.lang.String>> scripts,
                                                                 org.hl7.fhir.r4.model.Bundle bundle,
                                                                 FlexporterJavascriptContext fjContext)
        Execute scripts against the given Bundle.
        Parameters:
        scripts - Script definitions, containing a definition of one or more JS functions, the name of the function to invoke, and whether it applies to the bundle as a whole, or to the individual resources.
        bundle - FHIR bundle to apply scripts against
        fjContext - Javascript context for this run
        Returns:
        The new Bundle. IMPORTANT - using the JS context will always result in a new bundle, not modify the existing one in-place.