Package org.ehrbase.dao.access.jooq
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
Created by Christian Chevalley on 4/17/2015.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEhrAccess.PARTY_MODE
-
Field Summary
Fields Modifier and Type Field Description static StringCOULD_NOT_RETRIEVE_EHR_FOR_IDstatic StringCOULD_NOT_RETRIEVE_EHR_FOR_PARTYstatic StringEXCEPTIONstatic StringJSONB-
Fields inherited from interface org.ehrbase.dao.access.interfaces.I_DomainAccess
DBCP2_POOL, KEY_AUTO_RECONNECT, KEY_CONNECTION_MODE, KEY_DATABASE, KEY_DIALECT, KEY_HOST, KEY_INITIAL_CONNECTIONS, KEY_INTROSPECT_CACHE, KEY_KNOWLEDGE, KEY_LOG_ABANDONNED, KEY_LOGIN, KEY_MAX_ACTIVE, KEY_MAX_CONNECTION, KEY_MAX_IDLE, KEY_PASSWORD, KEY_PORT, KEY_REMOVE_ABANDONNED, KEY_REMOVE_ABANDONNED_TIMEOUT, KEY_SCHEMA, KEY_SET_MAX_PREPARED_STATEMENTS, KEY_SET_POOL_PREPARED_STATEMENTS, KEY_TEST_ON_BORROW, KEY_URL, KEY_WAIT_MS, PG_POOL
-
Fields inherited from interface org.ehrbase.dao.access.interfaces.I_EhrAccess
TAG_TEMPLATE_ID
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadminDeleteEhr()Invoke physical deletion.UUIDcommit()Deprecated.UUIDcommit(Timestamp transactionTime)storeComposition a new entry in the DBUUIDcommit(UUID committerId, UUID systemId, String description)Integerdelete()Deprecated.static Map<String,Object>fetchSubjectIdentifiers(I_DomainAccess domainAccess, UUID ehrId)retrieve the list of identifiers for a subject owning an Ehr
the identifiers are formatted as: "CODE:ISSUER"UUIDgetAccessId()StringgetArchetypeNodeId()static Map<String,Map<String,String>>getCompositionList(I_DomainAccess domainAccess, UUID ehrId)FIXME: check this method.I_ContributionAccessgetContributionAccess()DataAccessgetDataAccess()UUIDgetDirectoryId()EhrRecordgetEhrRecord()UUIDgetId()com.nedap.archie.rm.datastructures.ItemStructuregetOtherDetails()UUIDgetParty()com.nedap.archie.rm.ehr.EhrStatusgetStatus()Gets latest EHR_STATUS, which is attached to this EHR instance after retrieving it.I_StatusAccessgetStatusAccess()UUIDgetStatusId()UUIDgetSystemId()static booleanhasEhr(I_DomainAccess domainAccess, UUID ehrId)Check for existence of given ID as EHR.BooleanisModifiable()booleanisNew()check if Ehr is newly created (uncommitted)BooleanisQueryable()UUIDreload()TODO: doc or is this one really not needed anymore? delete if so.static booleanremoveDirectory(I_DomainAccess domainAccess, UUID ehrId)Removes the directory row value by setting it to 'NULL'.I_EhrAccessretrieve(UUID id)static I_EhrAccessretrieveInstance(I_DomainAccess domainAccess, UUID ehrId)Retrieve the Ehr entry from its ID (incl latest STATUS).static I_EhrAccessretrieveInstanceByStatus(I_DomainAccess domainAccess, UUID ehrId, UUID status, Integer version)static UUIDretrieveInstanceBySubject(I_DomainAccess domainAccess, String subjectId, String issuerSpace)// 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.static UUIDretrieveInstanceBySubject(I_DomainAccess domainAccess, UUID subjectUuid)// 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.static UUIDretrieveInstanceBySubjectExternalRef(I_DomainAccess domainAccess, String subjectId, String issuerSpace)// 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.voidsetAccess(UUID access)set access idvoidsetArchetypeNodeId(String archetypeNodeId)voidsetContributionAccess(I_ContributionAccess contributionAccess)voidsetDirectory(UUID directory)set directory idvoidsetModifiable(Boolean modifiable)voidsetName(com.nedap.archie.rm.datavalues.DvCodedText name)voidsetName(com.nedap.archie.rm.datavalues.DvText name)voidsetOtherDetails(com.nedap.archie.rm.datastructures.ItemStructure otherDetails, String templateId)voidsetParty(UUID partyId)voidsetQueryable(Boolean queryable)voidsetStatus(com.nedap.archie.rm.ehr.EhrStatus status)voidsetStatusAccess(I_StatusAccess statusAccess)voidsetSystem(UUID system)set system IdBooleanupdate()Deprecated.Booleanupdate(Boolean force)Deprecated.Booleanupdate(Timestamp transactionTime)updateComposition the current entry
depending on the implementation, records are updated only if one or more field(s) have been changedBooleanupdate(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.Booleanupdate(UUID committerId, UUID systemId, UUID contributionId, ContributionDef.ContributionState state, I_ConceptAccess.ContributionChangeType contributionChangeType, String description)Updates the whole EHR access in the DB, e.g.-
Methods inherited from class org.ehrbase.dao.access.support.DataAccess
getConnection, getContext, getDialect, getIntrospectService, getKnowledgeManager, getServerConfig, releaseConnection
-
-
-
-
Field Detail
-
JSONB
public static final String JSONB
- See Also:
- Constant Field Values
-
EXCEPTION
public static final String EXCEPTION
- See Also:
- Constant Field Values
-
COULD_NOT_RETRIEVE_EHR_FOR_ID
public static final String COULD_NOT_RETRIEVE_EHR_FOR_ID
- See Also:
- Constant Field Values
-
COULD_NOT_RETRIEVE_EHR_FOR_PARTY
public static final String COULD_NOT_RETRIEVE_EHR_FOR_PARTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EhrAccess
public EhrAccess(org.jooq.DSLContext context, ServerConfig serverConfig, UUID partyId, UUID systemId, UUID directoryId, UUID accessId, UUID ehrId)- Throws:
InternalServerException- if creating or retrieving system failed
-
-
Method Detail
-
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 accesssubjectUuid- 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 accesssubjectId- the subject code or numberissuerSpace- 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 accesssubjectId- the subject code or numberissuerSpace- 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_EhrAccessRetrieve the Ehr entry from its ID (incl latest STATUS).- Parameters:
domainAccess- SQL accessehrId- 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_EhrAccessretrieve the list of identifiers for a subject owning an Ehr
the identifiers are formatted as: "CODE:ISSUER"- Parameters:
domainAccess- SQL accessehrId- 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 accessehrId- - Target EHR id- Returns:
- Setting NULL value succeeded
-
getDataAccess
public DataAccess getDataAccess()
- Specified by:
getDataAccessin interfaceI_DomainAccess
-
setAccess
public void setAccess(UUID access)
Description copied from interface:I_EhrAccessset access id- Specified by:
setAccessin interfaceI_EhrAccess- Parameters:
access- UUID
-
setDirectory
public void setDirectory(UUID directory)
Description copied from interface:I_EhrAccessset directory id- Specified by:
setDirectoryin interfaceI_EhrAccess- Parameters:
directory- UUID
-
setSystem
public void setSystem(UUID system)
Description copied from interface:I_EhrAccessset system Id- Specified by:
setSystemin interfaceI_EhrAccess- Parameters:
system- UUID
-
setModifiable
public void setModifiable(Boolean modifiable)
- Specified by:
setModifiablein interfaceI_EhrAccess
-
setArchetypeNodeId
public void setArchetypeNodeId(String archetypeNodeId)
- Specified by:
setArchetypeNodeIdin interfaceI_EhrAccess
-
getArchetypeNodeId
public String getArchetypeNodeId()
- Specified by:
getArchetypeNodeIdin interfaceI_EhrAccess
-
setName
public void setName(com.nedap.archie.rm.datavalues.DvText name)
- Specified by:
setNamein interfaceI_EhrAccess
-
setName
public void setName(com.nedap.archie.rm.datavalues.DvCodedText name)
- Specified by:
setNamein interfaceI_EhrAccess
-
setQueryable
public void setQueryable(Boolean queryable)
- Specified by:
setQueryablein interfaceI_EhrAccess
-
commit
public UUID commit(Timestamp transactionTime)
Description copied from interface:I_SimpleCRUDstoreComposition a new entry in the DB- Specified by:
commitin interfaceI_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_SimpleCRUDstoreComposition a new entry in the DB, using a default transaction time
only implemented with "root" tables: ehr, contribution and composition!- Specified by:
commitin interfaceI_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:
commitin interfaceI_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:
updatein interfaceI_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:
updatein interfaceI_SimpleCRUD- Returns:
- Throws:
InvalidApiParameterException- when marshalling of EHR_STATUS / OTHER_DETAILS failed
-
update
@Deprecated public Boolean update()
Deprecated.Description copied from interface:I_SimpleCRUDupdateComposition 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:
updatein interfaceI_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_SimpleCRUDupdateComposition 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:
updatein interfaceI_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_EhrAccessUpdates the whole EHR access in the DB, e.g. to update the status. Embeds contribution and audit handling.- Specified by:
updatein interfaceI_EhrAccess- Parameters:
committerId- ID of committersystemId- ID of committing systemcontributionId- Optional custom contribution ID, can be nullstate- State of contributioncontributionChangeType- Change type of contributiondescription- Description field- Returns:
- True for success
-
delete
@Deprecated public Integer delete()
Deprecated.Description copied from interface:I_SimpleCRUDdelete the Versioned Object associated with the instance implementing this Data Access Interface. Relies on ON DELETE CASCADE- Specified by:
deletein interfaceI_SimpleCRUD- Returns:
- Throws:
InternalServerException- because inherited interface function isn't implemented in this class
-
reload
public UUID reload()
Description copied from interface:I_EhrAccessTODO: doc or is this one really not needed anymore? delete if so.- Specified by:
reloadin interfaceI_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:
getEhrRecordin interfaceI_EhrAccess
-
isNew
public boolean isNew()
Description copied from interface:I_EhrAccesscheck if Ehr is newly created (uncommitted)- Specified by:
isNewin interfaceI_EhrAccess- Returns:
- true if new, false otherwise
-
getParty
public UUID getParty()
- Specified by:
getPartyin interfaceI_EhrAccess
-
setParty
public void setParty(UUID partyId)
- Specified by:
setPartyin interfaceI_EhrAccess
-
getId
public UUID getId()
- Specified by:
getIdin interfaceI_EhrAccess
-
isModifiable
public Boolean isModifiable()
- Specified by:
isModifiablein interfaceI_EhrAccess
-
isQueryable
public Boolean isQueryable()
- Specified by:
isQueryablein interfaceI_EhrAccess
-
getSystemId
public UUID getSystemId()
- Specified by:
getSystemIdin interfaceI_EhrAccess
-
getStatusId
public UUID getStatusId()
- Specified by:
getStatusIdin interfaceI_EhrAccess
-
getDirectoryId
public UUID getDirectoryId()
- Specified by:
getDirectoryIdin interfaceI_EhrAccess
-
getAccessId
public UUID getAccessId()
- Specified by:
getAccessIdin interfaceI_EhrAccess
-
setOtherDetails
public void setOtherDetails(com.nedap.archie.rm.datastructures.ItemStructure otherDetails, String templateId)- Specified by:
setOtherDetailsin interfaceI_EhrAccess
-
getOtherDetails
public com.nedap.archie.rm.datastructures.ItemStructure getOtherDetails()
- Specified by:
getOtherDetailsin interfaceI_EhrAccess
-
getContributionAccess
public I_ContributionAccess getContributionAccess()
-
setContributionAccess
public void setContributionAccess(I_ContributionAccess contributionAccess)
- Specified by:
setContributionAccessin interfaceI_EhrAccess
-
getStatusAccess
public I_StatusAccess getStatusAccess()
- Specified by:
getStatusAccessin interfaceI_EhrAccess
-
setStatusAccess
public void setStatusAccess(I_StatusAccess statusAccess)
- Specified by:
setStatusAccessin interfaceI_EhrAccess
-
setStatus
public void setStatus(com.nedap.archie.rm.ehr.EhrStatus status)
- Specified by:
setStatusin interfaceI_EhrAccess
-
getStatus
public com.nedap.archie.rm.ehr.EhrStatus getStatus()
Description copied from interface:I_EhrAccessGets latest EHR_STATUS, which is attached to this EHR instance after retrieving it.- Specified by:
getStatusin interfaceI_EhrAccess- Returns:
- Latest EHR_STATUS
-
adminDeleteEhr
public void adminDeleteEhr()
Description copied from interface:I_EhrAccessInvoke physical deletion.- Specified by:
adminDeleteEhrin interfaceI_EhrAccess
-
hasEhr
public static boolean hasEhr(I_DomainAccess domainAccess, UUID ehrId)
Description copied from interface:I_EhrAccessCheck for existence of given ID as EHR.- Parameters:
domainAccess- ContextehrId- EHR ID to check- Returns:
- true or false
-
-