use of com.nedap.archie.rm.changecontrol.OriginalVersion in project ehrbase by ehrbase.
the class EhrServiceImp method getRevisionHistoryOfVersionedEhrStatus.
@Override
public RevisionHistory getRevisionHistoryOfVersionedEhrStatus(UUID ehrUid) {
I_EhrAccess ehrAccess = I_EhrAccess.retrieveInstance(getDataAccess(), ehrUid);
// get number of versions
int versions = I_StatusAccess.getLatestVersionNumber(getDataAccess(), ehrAccess.getStatusId());
// fetch each version
UUID versionedObjectUid = getEhrStatusVersionedObjectUidByEhr(ehrUid);
RevisionHistory revisionHistory = new RevisionHistory();
for (int i = 1; i <= versions; i++) {
Optional<OriginalVersion<EhrStatus>> ehrStatus = getEhrStatusAtVersion(ehrUid, versionedObjectUid, i);
// create RevisionHistoryItem for each version and append it to RevisionHistory
if (ehrStatus.isPresent())
revisionHistory.addItem(revisionHistoryItemFromEhrStatus(ehrStatus.get(), i));
}
if (revisionHistory.getItems().isEmpty()) {
// never should be empty; not valid
throw new InternalServerException("Problem creating RevisionHistory");
}
return revisionHistory;
}
Aggregations