Class EhrAccess

java.lang.Object
org.ehrbase.dao.access.support.DataAccess
org.ehrbase.dao.access.jooq.EhrAccess
All Implemented Interfaces:
I_DomainAccess, I_EhrAccess, I_SimpleCRUD

public class EhrAccess extends DataAccess implements I_EhrAccess
Persistence operations on EHR.
Since:
1.0.0
Author:
Christian Chevalley, Jake Smolka, Luis Marco-Ruiz
  • Field Details

  • Constructor Details

  • Method Details

    • retrieveInstanceBySubject

      public static UUID retrieveInstanceBySubject(I_DomainAccess domainAccess, UUID subjectUuid)
      Description copied from interface: I_EhrAccess
      // TODO: keep! likely to be used by EHR controller retrieve an Ehr for a subject UUID
      a subject identification consists of the issuer identification (ex. NHS) and an identification code
      Parameters:
      domainAccess - SQL access
      subjectUuid - the subject uuid
      Returns:
      UUID of corresponding Ehr or null
      Throws:
      IllegalArgumentException - if retrieving failed for given input
    • retrieveInstanceBySubject

      public static UUID retrieveInstanceBySubject(I_DomainAccess domainAccess, String subjectId, String issuerSpace)
      Description copied from interface: I_EhrAccess
      // TODO: keep! likely to be used by EHR controller retrieve an Ehr for a subject identification with an identifier
      a subject identification consists of the issuer identification (ex. NHS) and an identification code
      Parameters:
      domainAccess - SQL access
      subjectId - the subject code or number
      issuerSpace - the issuer identifier
      Returns:
      UUID of corresponding Ehr or null
      Throws:
      IllegalArgumentException - if retrieving failed for given input
    • retrieveInstanceBySubjectExternalRef

      public static UUID retrieveInstanceBySubjectExternalRef(I_DomainAccess domainAccess, String subjectId, String issuerSpace)
      Description copied from interface: I_EhrAccess
      // TODO: keep! likely to be used by EHR controller retrieve an Ehr for a subject identification by external reference
      a subject identification consists of the issuer identification (ex. NHS) and an identification code
      Parameters:
      domainAccess - SQL access
      subjectId - the subject code or number
      issuerSpace - the namespace
      Returns:
      UUID of corresponding Ehr or null
      Throws:
      IllegalArgumentException - if retrieving failed for given input
    • retrieveInstanceByStatus

      public static I_EhrAccess retrieveInstanceByStatus(I_DomainAccess domainAccess, UUID ehrId, UUID status, Integer version)
    • retrieveInstance

      public static I_EhrAccess retrieveInstance(I_DomainAccess domainAccess, UUID ehrId)
      Description copied from interface: I_EhrAccess
      Retrieve the Ehr entry from its ID (incl latest STATUS).
      Parameters:
      domainAccess - SQL access
      ehrId - the Ehr UUID
      Returns:
      UUID of corresponding Ehr or null
      Throws:
      IllegalArgumentException - when either no EHR for ID, or problem with data structure of EHR, or DB inconsistency
    • fetchSubjectIdentifiers

      public static Map<String,Object> fetchSubjectIdentifiers(I_DomainAccess domainAccess, UUID ehrId)
      Description copied from interface: I_EhrAccess
      retrieve the list of identifiers for a subject owning an Ehr
      the identifiers are formatted as: "CODE:ISSUER"
      Parameters:
      domainAccess - SQL access
      ehrId - the Ehr Id to search the subject from
      Returns:
      a list of identifiers
      Throws:
      IllegalArgumentException - when no EHR found for ID
    • getCompositionList

      public static Map<String,Map<String,String>> getCompositionList(I_DomainAccess domainAccess, UUID ehrId)
      FIXME: check this method. appears to be needed later on. problematic: it actually gets a list of entries, not compositions. why only with three attributes? what about the unique key problem below?
      Returns:
      Throws:
      IllegalArgumentException - when no EHR found for ID
    • removeDirectory

      public static boolean removeDirectory(I_DomainAccess domainAccess, UUID ehrId)
      Removes the directory row value by setting it to 'NULL'. Usually his will be used after the deletion of a directories root folder.
      Parameters:
      domainAccess - - Database access
      ehrId - - Target EHR id
      Returns:
      Setting NULL value succeeded
    • getDataAccess

      public DataAccess getDataAccess()
      Specified by:
      getDataAccess in interface I_DomainAccess
    • setAccess

      public void setAccess(UUID access)
      Description copied from interface: I_EhrAccess
      set access id
      Specified by:
      setAccess in interface I_EhrAccess
      Parameters:
      access - UUID
    • setDirectory

      public void setDirectory(UUID directory)
      Description copied from interface: I_EhrAccess
      set directory id
      Specified by:
      setDirectory in interface I_EhrAccess
      Parameters:
      directory - UUID
    • setSystem

      public void setSystem(UUID system)
      Description copied from interface: I_EhrAccess
      set system Id
      Specified by:
      setSystem in interface I_EhrAccess
      Parameters:
      system - UUID
    • setModifiable

      public void setModifiable(Boolean modifiable)
      Specified by:
      setModifiable in interface I_EhrAccess
    • setArchetypeNodeId

      public void setArchetypeNodeId(String archetypeNodeId)
      Specified by:
      setArchetypeNodeId in interface I_EhrAccess
    • getArchetypeNodeId

      public String getArchetypeNodeId()
      Specified by:
      getArchetypeNodeId in interface I_EhrAccess
    • setName

      public void setName(com.nedap.archie.rm.datavalues.DvText name)
      Specified by:
      setName in interface I_EhrAccess
    • setName

      public void setName(com.nedap.archie.rm.datavalues.DvCodedText name)
      Specified by:
      setName in interface I_EhrAccess
    • setQueryable

      public void setQueryable(Boolean queryable)
      Specified by:
      setQueryable in interface I_EhrAccess
    • commit

      public UUID commit(Timestamp transactionTime)
      Description copied from interface: I_SimpleCRUD
      storeComposition a new entry in the DB
      Specified by:
      commit in interface I_SimpleCRUD
      Returns:
      the UUID of the newly created record
      Throws:
      InvalidApiParameterException - when input couldn't be processed, i.e. EHR not stored
    • commit

      @Deprecated public UUID commit()
      Deprecated.
      Description copied from interface: I_SimpleCRUD
      storeComposition a new entry in the DB, using a default transaction time
      only implemented with "root" tables: ehr, contribution and composition!
      Specified by:
      commit in interface I_SimpleCRUD
      Returns:
      the UUID of the newly created record
      Throws:
      InternalServerException - because inherited interface function isn't implemented in this class
    • commit

      public UUID commit(UUID committerId, UUID systemId, String description)
      Specified by:
      commit in interface I_EhrAccess
      Throws:
      IllegalArgumentException - when EHR couldn't be stored
    • update

      public Boolean update(Timestamp transactionTime)
      updateComposition the current entry
      depending on the implementation, records are updated only if one or more field(s) have been changed
      Specified by:
      update in interface I_SimpleCRUD
      Returns:
      Throws:
      InvalidApiParameterException - when marshalling of EHR_STATUS / OTHER_DETAILS failed
    • update

      public Boolean update(Timestamp transactionTime, boolean force)
      updateComposition the current entry even if the record is not modified
      intended to be used with temporal tables to ensure that a set of interdependent tables are updated in sync. This approach is used to simplify versions retrieval.
      Specified by:
      update in interface I_SimpleCRUD
      Returns:
      Throws:
      InvalidApiParameterException - when marshalling of EHR_STATUS / OTHER_DETAILS failed
    • update

      @Deprecated public Boolean update()
      Deprecated.
      Description copied from interface: I_SimpleCRUD
      updateComposition the current entry using time now as the system transaction time
      only implemented at root level object (contribution, composition, ehr). depending on the implementation, records are updated only if one or more field(s) have been changed
      Specified by:
      update in interface I_SimpleCRUD
      Returns:
      Throws:
      InternalServerException - because inherited interface function isn't implemented in this class
    • update

      @Deprecated public Boolean update(Boolean force)
      Deprecated.
      Description copied from interface: I_SimpleCRUD
      updateComposition the current entry using time now as the system transaction time
      only implemented at root level object (contribution, composition, ehr). depending on the implementation, records are updated only if one or more field(s) have been changed
      Specified by:
      update in interface I_SimpleCRUD
      Returns:
      Throws:
      InternalServerException - because inherited interface function isn't implemented in this class
    • update

      public Boolean update(UUID committerId, UUID systemId, UUID contributionId, ContributionDef.ContributionState state, I_ConceptAccess.ContributionChangeType contributionChangeType, String description)
      Description copied from interface: I_EhrAccess
      Updates the whole EHR access in the DB, e.g. to update the status. Embeds contribution and audit handling.
      Specified by:
      update in interface I_EhrAccess
      Parameters:
      committerId - ID of committer
      systemId - ID of committing system
      contributionId - Optional custom contribution ID, can be null
      state - State of contribution
      contributionChangeType - Change type of contribution
      description - Description field
      Returns:
      True for success
    • delete

      @Deprecated public Integer delete()
      Deprecated.
      Description copied from interface: I_SimpleCRUD
      delete the Versioned Object associated with the instance implementing this Data Access Interface. Relies on ON DELETE CASCADE
      Specified by:
      delete in interface I_SimpleCRUD
      Returns:
      Throws:
      InternalServerException - because inherited interface function isn't implemented in this class
    • reload

      public UUID reload()
      Description copied from interface: I_EhrAccess
      TODO: doc or is this one really not needed anymore? delete if so.
      Specified by:
      reload in interface I_EhrAccess
      Returns:
      Throws:
      IllegalArgumentException - when instance's EHR ID can't be matched to existing one
    • retrieve

      public I_EhrAccess retrieve(UUID id)
    • getEhrRecord

      public EhrRecord getEhrRecord()
      Specified by:
      getEhrRecord in interface I_EhrAccess
    • isNew

      public boolean isNew()
      Description copied from interface: I_EhrAccess
      check if Ehr is newly created (uncommitted)
      Specified by:
      isNew in interface I_EhrAccess
      Returns:
      true if new, false otherwise
    • getParty

      public UUID getParty()
      Specified by:
      getParty in interface I_EhrAccess
    • setParty

      public void setParty(UUID partyId)
      Specified by:
      setParty in interface I_EhrAccess
    • getId

      public UUID getId()
      Specified by:
      getId in interface I_EhrAccess
    • isModifiable

      public Boolean isModifiable()
      Specified by:
      isModifiable in interface I_EhrAccess
    • isQueryable

      public Boolean isQueryable()
      Specified by:
      isQueryable in interface I_EhrAccess
    • getSystemId

      public UUID getSystemId()
      Specified by:
      getSystemId in interface I_EhrAccess
    • getStatusId

      public UUID getStatusId()
      Specified by:
      getStatusId in interface I_EhrAccess
    • getDirectoryId

      public UUID getDirectoryId()
      Specified by:
      getDirectoryId in interface I_EhrAccess
    • getAccessId

      public UUID getAccessId()
      Specified by:
      getAccessId in interface I_EhrAccess
    • setOtherDetails

      public void setOtherDetails(com.nedap.archie.rm.datastructures.ItemStructure otherDetails, String templateId)
      Specified by:
      setOtherDetails in interface I_EhrAccess
    • getOtherDetails

      public com.nedap.archie.rm.datastructures.ItemStructure getOtherDetails()
      Specified by:
      getOtherDetails in interface I_EhrAccess
    • getContributionAccess

      public I_ContributionAccess getContributionAccess()
    • setContributionAccess

      public void setContributionAccess(I_ContributionAccess contributionAccess)
      Specified by:
      setContributionAccess in interface I_EhrAccess
    • getStatusAccess

      public I_StatusAccess getStatusAccess()
      Specified by:
      getStatusAccess in interface I_EhrAccess
    • setStatusAccess

      public void setStatusAccess(I_StatusAccess statusAccess)
      Specified by:
      setStatusAccess in interface I_EhrAccess
    • setStatus

      public void setStatus(com.nedap.archie.rm.ehr.EhrStatus status)
      Specified by:
      setStatus in interface I_EhrAccess
    • getStatus

      public com.nedap.archie.rm.ehr.EhrStatus getStatus()
      Description copied from interface: I_EhrAccess
      Gets latest EHR_STATUS, which is attached to this EHR instance after retrieving it.
      Specified by:
      getStatus in interface I_EhrAccess
      Returns:
      Latest EHR_STATUS
    • adminDeleteEhr

      public void adminDeleteEhr()
      Description copied from interface: I_EhrAccess
      Invoke physical deletion.
      Specified by:
      adminDeleteEhr in interface I_EhrAccess
    • hasEhr

      public static boolean hasEhr(I_DomainAccess domainAccess, UUID ehrId)
      Description copied from interface: I_EhrAccess
      Check for existence of given ID as EHR.
      Parameters:
      domainAccess - Context
      ehrId - EHR ID to check
      Returns:
      true or false
    • isModifiable

      public static boolean isModifiable(I_DomainAccess domainAccess, UUID ehrId)
      Description copied from interface: I_EhrAccess
      Check if the EHR identified by the given ID is marked as modifiable. Use this method if you do not need a full I_EhrAccess instance.
      Parameters:
      domainAccess - Context
      ehrId - EHR ID to check
      Returns:
      true if EHR.ehr_status.isModifiable, false otherwise (missing EHR will also return false)