use of com.nedap.archie.rm.generic.Attestation in project ehrbase by ehrbase.
the class CompositionServiceImp method getOriginalVersionComposition.
@Override
public Optional<OriginalVersion<Composition>> getOriginalVersionComposition(UUID versionedObjectUid, int version) {
// check for valid version parameter
if ((version == 0) || I_CompositionAccess.getLastVersionNumber(getDataAccess(), versionedObjectUid) < version) {
throw new ObjectNotFoundException("versioned_composition", "No VERSIONED_COMPOSITION with given version: " + version);
}
// retrieve requested object
I_CompositionAccess compositionAccess = I_CompositionAccess.retrieveCompositionVersion(getDataAccess(), versionedObjectUid, version);
if (compositionAccess == null) {
return Optional.empty();
}
// create data for output, i.e. fields of the OriginalVersion<Composition>
ObjectVersionId versionId = new ObjectVersionId(versionedObjectUid + "::" + getServerConfig().getNodename() + "::" + version);
DvCodedText lifecycleState = new DvCodedText("complete", new CodePhrase(// TODO: once lifecycle state is supported, get it here dynamically
"532"));
AuditDetails commitAudit = compositionAccess.getAuditDetailsAccess().getAsAuditDetails();
ObjectRef<HierObjectId> contribution = new ObjectRef<>(new HierObjectId(compositionAccess.getContributionId().toString()), "openehr", "contribution");
List<UUID> attestationIdList = I_AttestationAccess.retrieveListOfAttestationsByRef(getDataAccess(), compositionAccess.getAttestationRef());
List<Attestation> attestations = // as default, gets content if available in the following lines
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));
}
Optional<CompositionDto> compositionDto = retrieve(versionedObjectUid, version);
Composition composition = null;
if (compositionDto.isPresent()) {
composition = compositionDto.get().getComposition();
}
OriginalVersion<Composition> versionComposition = new OriginalVersion<>(versionId, precedingVersionId, composition, lifecycleState, commitAudit, contribution, null, null, attestations);
return Optional.of(versionComposition);
}
use of com.nedap.archie.rm.generic.Attestation in project ehrbase by ehrbase.
the class CompositionServiceImp method revisionHistoryItemFromComposition.
private RevisionHistoryItem revisionHistoryItemFromComposition(OriginalVersion<Composition> composition) {
ObjectVersionId objectVersionId = composition.getUid();
// Note: is List but only has more than one item when there are contributions regarding this
// object of change type attestation
List<AuditDetails> auditDetailsList = new ArrayList<>();
// retrieving the audits
auditDetailsList.add(composition.getCommitAudit());
// add retrieval of attestations, if there are any
if (composition.getAttestations() != null) {
for (Attestation a : composition.getAttestations()) {
AuditDetails newAudit = new AuditDetails(a.getSystemId(), a.getCommitter(), a.getTimeCommitted(), a.getChangeType(), a.getDescription());
auditDetailsList.add(newAudit);
}
}
return new RevisionHistoryItem(objectVersionId, auditDetailsList);
}
use of com.nedap.archie.rm.generic.Attestation in project ehrbase by ehrbase.
the class AttestationAccess method getAsAttestation.
@Override
public Attestation getAsAttestation() {
// take most values from super class entry
AuditDetails audit = auditDetailsAccess.getAsAuditDetails();
String systemId = audit.getSystemId();
PartyProxy committer = audit.getCommitter();
DvDateTime time = audit.getTimeCommitted();
DvCodedText changeType = audit.getChangeType();
DvText description = audit.getDescription();
// FIXME VERSIONED_OBJECT_POC: implement retrieval from "attested_view" table
DvMultimedia attestedView = null;
String proof = attestationRecord.getProof();
// FIXME VERSIONED_OBJECT_POC: implement?! seems to be completely unsupported right now
List<DvEHRURI> items = null;
DvText reason = new DvText(attestationRecord.getReason());
boolean isPending = attestationRecord.getIsPending();
return new Attestation(systemId, committer, time, changeType, description, attestedView, proof, items, reason, isPending);
}
Aggregations