Search in sources :

Example 21 with HierObjectId

use of com.nedap.archie.rm.support.identification.HierObjectId in project ehrbase by ehrbase.

the class EhrServiceImp method getVersionedEhrStatus.

@Override
public VersionedEhrStatus getVersionedEhrStatus(UUID ehrUid) {
    // FIXME VERSIONED_OBJECT_POC: Pre_has_ehr: has_ehr (an_ehr_id)
    // FIXME VERSIONED_OBJECT_POC: Pre_has_ehr_status_version: has_ehr_status_version (an_ehr_id, a_version_uid)
    Optional<EhrStatus> ehrStatus = getEhrStatus(ehrUid);
    VersionedEhrStatus versionedEhrStatus = new VersionedEhrStatus();
    if (ehrStatus.isPresent()) {
        versionedEhrStatus.setUid(new HierObjectId(ehrStatus.get().getUid().getRoot().getValue()));
        versionedEhrStatus.setOwnerId(new ObjectRef<>(new HierObjectId(ehrUid.toString()), "local", "EHR"));
        I_EhrAccess ehrAccess = I_EhrAccess.retrieveInstance(getDataAccess(), ehrUid);
        versionedEhrStatus.setTimeCreated(new DvDateTime(OffsetDateTime.of(ehrAccess.getStatusAccess().getInitialTimeOfVersionedEhrStatus().toLocalDateTime(), OffsetDateTime.now().getOffset())));
    }
    return versionedEhrStatus;
}
Also used : VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 22 with HierObjectId

use of com.nedap.archie.rm.support.identification.HierObjectId in project ehrbase by ehrbase.

the class EhrServiceImp method getEhrStatusAtVersion.

@Override
public Optional<OriginalVersion<EhrStatus>> getEhrStatusAtVersion(UUID ehrUuid, UUID versionedObjectUid, int version) {
    // pre-step: check for valid ehrId
    if (!hasEhr(ehrUuid)) {
        throw new ObjectNotFoundException("ehr", "No EHR found with given ID: " + ehrUuid.toString());
    }
    if ((version == 0) || (I_StatusAccess.getLatestVersionNumber(getDataAccess(), versionedObjectUid) < version)) {
        throw new ObjectNotFoundException("versioned_ehr_status", "No VERSIONED_EHR_STATUS with given version: " + version);
    }
    I_StatusAccess statusAccess = I_StatusAccess.getVersionMapOfStatus(getDataAccess(), versionedObjectUid).get(version);
    ObjectVersionId versionId = new ObjectVersionId(versionedObjectUid + "::" + getServerConfig().getNodename() + "::" + version);
    // TODO: once lifecycle state is supported, get it here dynamically
    DvCodedText lifecycleState = new DvCodedText("complete", new CodePhrase("532"));
    AuditDetails commitAudit = statusAccess.getAuditDetailsAccess().getAsAuditDetails();
    ObjectRef<HierObjectId> contribution = new ObjectRef<>(new HierObjectId(statusAccess.getStatusRecord().getInContribution().toString()), "openehr", "contribution");
    List<UUID> attestationIdList = I_AttestationAccess.retrieveListOfAttestationsByRef(getDataAccess(), statusAccess.getStatusRecord().getAttestationRef());
    // as default, gets content if available in the following lines
    List<Attestation> attestations = null;
    if (!attestationIdList.isEmpty()) {
        attestations = new ArrayList<>();
        for (UUID id : attestationIdList) {
            I_AttestationAccess a = new AttestationAccess(getDataAccess()).retrieveInstance(id);
            attestations.add(a.getAsAttestation());
        }
    }
    ObjectVersionId precedingVersionId = null;
    // check if there is a preceding version and set it, if available
    if (version > 1) {
        // in the current scope version is an int and therefore: preceding = current - 1
        precedingVersionId = new ObjectVersionId(versionedObjectUid + "::" + getServerConfig().getNodename() + "::" + (version - 1));
    }
    OriginalVersion<EhrStatus> versionStatus = new OriginalVersion<>(versionId, precedingVersionId, statusAccess.getStatus(), lifecycleState, commitAudit, contribution, null, null, attestations);
    return Optional.of(versionStatus);
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) AttestationAccess(org.ehrbase.dao.access.jooq.AttestationAccess) ObjectVersionId(com.nedap.archie.rm.support.identification.ObjectVersionId) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) UUID(java.util.UUID) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Aggregations

HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)22 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)12 DvText (com.nedap.archie.rm.datavalues.DvText)8 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)7 PartySelf (com.nedap.archie.rm.generic.PartySelf)7 UUID (java.util.UUID)7 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)6 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)5 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)5 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)4 Composition (com.nedap.archie.rm.composition.Composition)3 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)3 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)3 SdkException (org.ehrbase.util.exception.SdkException)3 Test (org.junit.Test)3 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)2 VersionedComposition (com.nedap.archie.rm.ehr.VersionedComposition)2 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)2 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2