Class LibraryHelper


  • public class LibraryHelper
    extends java.lang.Object
    Helper methods for working with FHIR Library resources and specifically those that pertain to Clinical Quality Language (CQL) evaluation.
    • Constructor Summary

      Constructors 
      Constructor Description
      LibraryHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String canonicalUrl​(Library library)
      Helper method for building a canonical URL string from the relevant fields in a Library resource.
      static org.cqframework.cql.elm.execution.Library deserializeElm​(Library fhirLibrary, Attachment elm)
      Deserialize the contents of an application/elm+xml attachment.
      static java.io.InputStream getAttachmentData​(Attachment attachment)
      Helper method for converting an Attachment resource's contents into an InputStream
      static Coding getLibraryCoding​(java.lang.String code)
      Helper method for generating a Coding that contains the model-definition code.
      static Coding getLogicLibraryCoding()
      Helper method for generating a Coding that contains the logic-library code.
      static CodeableConcept getLogicLibraryConcept()
      Helper method for generating a CodeableConcept that contains the logic-library code.
      static Coding getModelDefinitionCoding()
      Helper method for generating a Coding that contains the model-definition code.
      static boolean isLibraryReference​(java.lang.String resource)
      Helper function for determining if a reference resource is a Library resource
      static boolean isLogicLibrary​(Library fhirLibrary)
      Helper function for determining if a Library resource contains CQL logic.
      static java.util.List<Library> loadLibraries​(Library fhirLibrary)
      Create a collection of the given library resource and all of its dependencies.
      protected static java.util.List<Library> loadLibraries​(Library fhirLibrary, java.util.Set<java.lang.String> visited)
      Create a collection of the given library resource and all of its dependencies.
      static java.util.List<org.cqframework.cql.elm.execution.Library> loadLibrary​(CqlTranslationProvider translator, Library fhirLibrary)
      Load the CQL Library from the attachment data associated with a FHIR Library resource.
      • Methods inherited from class java.lang.Object

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

      • LibraryHelper

        public LibraryHelper()
    • Method Detail

      • loadLibraries

        public static java.util.List<Library> loadLibraries​(Library fhirLibrary)
        Create a collection of the given library resource and all of its dependencies.
        Parameters:
        fhirLibrary - root library in the tree of dependencies
        Returns:
        List of Library resources corresponding to all dependencies.
      • loadLibraries

        protected static java.util.List<Library> loadLibraries​(Library fhirLibrary,
                                                               java.util.Set<java.lang.String> visited)
        Create a collection of the given library resource and all of its dependencies.
        Parameters:
        fhirLibrary - root library in the tree of dependencies
        visited - set of canonical URLs corresponding to the library resources that have already been loaded. This allows us to prevent infinite loops.
        Returns:
        List of Library resources corresponding to all dependencies.
      • loadLibrary

        public static java.util.List<org.cqframework.cql.elm.execution.Library> loadLibrary​(CqlTranslationProvider translator,
                                                                                            Library fhirLibrary)
        Load the CQL Library from the attachment data associated with a FHIR Library resource.
        Parameters:
        translator - CQL Translation Provider that will be used to translate CQL for Library resources with only CQL attachment data
        fhirLibrary - Library resource containing the attachment data to load
        Returns:
        List of CQL Libraries that were translated. A single CQL file might output multiple Library objects based on the include definitions in the CQL.
      • deserializeElm

        public static org.cqframework.cql.elm.execution.Library deserializeElm​(Library fhirLibrary,
                                                                               Attachment elm)
        Deserialize the contents of an application/elm+xml attachment.
        Parameters:
        fhirLibrary - FHIR Library that contains the attachment
        elm - Attachment that contains the ELM data
        Returns:
        CQL Library
      • isLibraryReference

        public static boolean isLibraryReference​(java.lang.String resource)
        Helper function for determining if a reference resource is a Library resource
        Parameters:
        resource - Resource reference
        Returns:
        true if the resource string refers to a library. Otherwise, false.
      • isLogicLibrary

        public static boolean isLogicLibrary​(Library fhirLibrary)
        Helper function for determining if a Library resource contains CQL logic. This is most correctly determined by the Library.type property, but, in the absence of a type field, any Library that contains a CQL or ELM attachment will be considered a logic library.
        Parameters:
        resource - Resource reference
        Returns:
        true if the resource string refers to a library. Otherwise, false.
      • getLogicLibraryConcept

        public static CodeableConcept getLogicLibraryConcept()
        Helper method for generating a CodeableConcept that contains the logic-library code.
        Returns:
        CodeableConcept containing the logic-library code
      • getLogicLibraryCoding

        public static Coding getLogicLibraryCoding()
        Helper method for generating a Coding that contains the logic-library code.
        Returns:
        Coding containing the logic-library code
      • getModelDefinitionCoding

        public static Coding getModelDefinitionCoding()
        Helper method for generating a Coding that contains the model-definition code.
        Returns:
        Coding containing the logic-library code
      • getLibraryCoding

        public static Coding getLibraryCoding​(java.lang.String code)
        Helper method for generating a Coding that contains the model-definition code.
        Returns:
        Coding containing the logic-library code
      • getAttachmentData

        public static java.io.InputStream getAttachmentData​(Attachment attachment)
                                                     throws java.io.IOException
        Helper method for converting an Attachment resource's contents into an InputStream
        Returns:
        InputStream for reading the attachment data
        Throws:
        java.io.IOException
      • canonicalUrl

        public static java.lang.String canonicalUrl​(Library library)
        Helper method for building a canonical URL string from the relevant fields in a Library resource.
        Returns:
        canonical URL