Interface I_CompositionAccess

  • All Superinterfaces:
    I_SimpleCRUD
    All Known Implementing Classes:
    CompositionAccess

    public interface I_CompositionAccess
    extends I_SimpleCRUD
    Composition Access Layer Interface
    Interface CRUD and specific methods
    • Method Detail

      • getNewInstance

        static I_CompositionAccess getNewInstance​(I_DomainAccess domain,
                                                  com.nedap.archie.rm.composition.Composition composition,
                                                  UUID ehrId)
        Get a new Composition Access Instance
        Parameters:
        domain - SQL context, knowledge
        composition - a valid RM composition
        ehrId - the EHR holding this instance
        Returns:
        I_CompositionAccess object of the new access instance
        Throws:
        IllegalArgumentException - when retrieval failed because of wrong input
      • getVersionFromTimeStamp

        static int getVersionFromTimeStamp​(I_DomainAccess domainAccess,
                                           UUID vCompositionUid,
                                           Timestamp timeCommitted)
        Calculate the version corresponding to a VersionedComposition which is the closest in time (before) the Timestamp provided.
        Parameters:
        domainAccess - The I_DomainAccess containing the persistence information and DB connection parameters for persisting a composition.
        vCompositionUid - The UUID corresponding to a VersionedComposition
        timeCommitted - Timestamp of commit
        Returns:
        version number
        Throws:
        IllegalArgumentException - if no version is available for the Timestamp provided.
        InternalServerException - when SQL statements fail due to internal problems.
      • retrieveInstanceByTimestamp

        static I_CompositionAccess retrieveInstanceByTimestamp​(I_DomainAccess domainAccess,
                                                               UUID compositionUid,
                                                               Timestamp timeCommitted)
        Returns the instance of a VersionedComposition corresponding to the version which is the closest in time before the timeCommitted provided.
        Parameters:
        domainAccess - I_DomainAccess with the persistence SQL Context and knowledge cache
        compositionUid - UUID that identifies the composition.
        timeCommitted - {java.sql.Timestamp} that indicates the point in time to search version for the composition backwards.
        Returns:
        the number of the version that is the closest in time (before) the timeCommitted parameter provided. If a null timeCommitted is provided the latest composition will be returned.
        Throws:
        IllegalArgumentException
        InternalServerException
        ObjectNotFoundException
      • retrieveInstance

        static I_CompositionAccess retrieveInstance​(I_DomainAccess domainAccess,
                                                    UUID id)
        Retrieve a composition access instance from the persistence layer
        Parameters:
        domainAccess - SQL context, knowledge
        id - a composition uuid
        Returns:
        a valid I_CompositionAccess
      • retrieveInstancesInContribution

        static Map<I_CompositionAccess,​Integer> retrieveInstancesInContribution​(I_DomainAccess domainAccess,
                                                                                      UUID contributionId)
        Retrieve a map of composition accesses for all compositions referencing a contribution
        Parameters:
        domainAccess - SQL context, knowledge
        contributionId - contribution object uuid
        Returns:
        a map of I_CompositionAccess and their version number, that match the condition
        Throws:
        IllegalArgumentException - on DB inconsistency
      • hasPreviousVersion

        static boolean hasPreviousVersion​(I_DomainAccess domainAccess,
                                          UUID compositionId)
        check if a composition has a previous version in history
        Parameters:
        domainAccess -
        compositionId -
        Returns:
      • getVersionMapOfComposition

        static Map<I_CompositionAccess,​Integer> getVersionMapOfComposition​(I_DomainAccess domainAccess,
                                                                                 UUID compositionId)
        Creates Map containing all versions as their Access object with their matching version number.
        Parameters:
        domainAccess - Data Access
        compositionId - Given composition ID
        Returns:
        Map referencing all versions and their version number
      • getLastVersionNumber

        static Integer getLastVersionNumber​(I_DomainAccess domainAccess,
                                            UUID compositionId)
        retrieve the number of versions for this composition or 1 if no history present
        Parameters:
        domainAccess -
        compositionId -
        Returns:
      • isValidLanguageCode

        static boolean isValidLanguageCode​(I_DomainAccess domainAccess,
                                           String languageCode)
      • commitWithCustomContribution

        UUID commitWithCustomContribution​(UUID committerId,
                                          UUID systemId,
                                          String description)
        Unlike the basic commit it is necessary to set the contribution manually beforehand, here. This allows committing with a specific contribution ID, which could be used to process several objects at once.
        Parameters:
        committerId - Committer ID (PartyIdentified)
        description - Description text
        systemId - System ID
        Returns:
        ID of committed object
        Throws:
        IllegalArgumentException - when content couldn't be committed
      • updateWithCustomContribution

        Boolean updateWithCustomContribution​(UUID committerId,
                                             UUID systemId,
                                             I_ConceptAccess.ContributionChangeType contributionChangeType,
                                             String description)
        Unlike the basic update it is necessary to set the contribution manually beforehand, here. This allows updating with a specific contribution ID, which could be used to process several objects at once.
        Parameters:
        committerId - Committer of this change
        systemId - System of origin of this change
        contributionChangeType - Change type of this change
        description - Updated description or NULL
        Returns:
        Boolean to indicate success or failure of update
      • delete

        Integer delete​(UUID committerId,
                       UUID systemId,
                       String description)
        Delete a composition
        Delete by simulating an SQL CASCADE wherever appropriate
        • delete entry first
        • delete the corresponding version entry
        • delete the composition record
        Returns:
      • deleteWithCustomContribution

        Integer deleteWithCustomContribution​(UUID committerId,
                                             UUID systemId,
                                             String description)
        Unlike the basic delete it is necessary to set the contribution manually beforehand, here. This allows deleting with a specific contribution ID, which could be used to process several objects at once.
        Parameters:
        committerId - Committer of this change
        systemId - System of origin of this change
        description - Updated description or NUL
        Returns:
        Rows affected by delete
      • getSysTransaction

        Timestamp getSysTransaction()
      • getTimeCommitted

        Timestamp getTimeCommitted()
        Gets time_committed from contribution of composition.
        Returns:
        Timestamp of time of commitment
      • getId

        UUID getId()
        get the composition Id
        Returns:
      • getEhrid

        UUID getEhrid()
        get the EHR id to which this composition belongs to
        Returns:
        UUID
      • setEhrid

        void setEhrid​(UUID ehrId)
        set the EHR id
        Parameters:
        ehrId - UUID
      • getComposerId

        UUID getComposerId()
        get the composer Id
        Returns:
        UUID
      • setComposerId

        void setComposerId​(UUID composerId)
        set the composer id
        Parameters:
        composerId - UUID
      • getContextId

        Optional<UUID> getContextId()
        get the event context id
        Returns:
        Optional with ID if it exists, otherwise empty Optional
      • getContributionId

        UUID getContributionId()
        get the contribution id
        Returns:
        UUID
      • getLanguageCode

        String getLanguageCode()
        get the language code for this composition (eg. 'en', 'fr' etc.)
        Returns:
        language code as string
      • setLanguageCode

        void setLanguageCode​(String code)
        set the language code
        Parameters:
        code - String
      • getTerritoryCode

        Integer getTerritoryCode()
        FIXME: bug? comment says 2-letter while methods are saying Integer get the 2-letters country code
        Returns:
      • setTerritoryCode

        void setTerritoryCode​(Integer code)
        FIXME: bug? comment says 2-letter while methods are saying Integer set the 2-letters territory code
        Parameters:
        code - String
      • getContentIds

        List<UUID> getContentIds()
        get the list of entry Ids for this composition
        Returns:
        a list of entry UUIDs
      • setContextCompositionId

        void setContextCompositionId​(UUID contextId)
        set the event context id
        Parameters:
        contextId - UUID
        Throws:
        org.jooq.exception.DataAccessException - on problem updating context
      • addContent

        int addContent​(I_EntryAccess entry)
        add an entry to the composition
        Parameters:
        entry - I_EntryAccess instance
        Returns:
        >0 success
      • setContributionId

        void setContributionId​(UUID contributionId)
        set the contribution id for this composition
        Parameters:
        contributionId -
      • setCompositionRecord

        void setCompositionRecord​(CompositionHistoryRecord record)
        Set the record via converting from a history record.
        Parameters:
        record - History record
      • setCompositionRecord

        void setCompositionRecord​(org.jooq.Result<?> records)
        Throws:
        IllegalArgumentException - when handling of record failed
      • setComposition

        void setComposition​(com.nedap.archie.rm.composition.Composition composition)
      • updateCompositionData

        void updateCompositionData​(com.nedap.archie.rm.composition.Composition newComposition)
        Throws:
        IllegalArgumentException - when seeking language code, territory code or composer ID failed
      • setContext

        void setContext​(com.nedap.archie.rm.composition.EventContext historicalEventContext)
      • getAuditDetailsId

        UUID getAuditDetailsId()
      • setAuditDetailsId

        void setAuditDetailsId​(UUID auditId)
      • exists

        static boolean exists​(I_DomainAccess domainAccess,
                              UUID versionedObjectId)
        Checks if the given versionedObjectID points to an existing composition.
        Parameters:
        domainAccess - Data access object
        versionedObjectId - ID to be checked
        Returns:
        True if exists
        Throws:
        ObjectNotFoundException - if ID does not exist
      • isDeleted

        static boolean isDeleted​(I_DomainAccess domainAccess,
                                 UUID versionedObjectId)
        Checks if given composition ID is ID of a logically deleted composition.
        Parameters:
        domainAccess - Data access object
        versionedObjectId - ID to be checked
        Returns:
        True if deleted, false if not
        Throws:
        ObjectNotFoundException - If no composition entries at all can be found
        InternalServerException - If DB is inconsistent or some other problem occurs