use of com.nedap.archie.rm.generic.AuditDetails in project ehrbase by ehrbase.
the class ContributionServiceHelper method parseAuditDetails.
/**
* Helper that parses the AuditDetails from the contribution input.
* @param content Plain string content
* @param format Format of content
* @return AuditDetails object
*/
public static AuditDetails parseAuditDetails(String content, CompositionFormat format) {
// extract both per standard parts of the content: data block containing versions & audit
Map<String, Object> splitContent = splitContent(content, format);
Object auditContent = splitContent.get("audit");
AuditDetails auditResult;
switch(format) {
case JSON:
try {
String json = JacksonUtil.getObjectMapper().writeValueAsString(auditContent);
auditResult = new CanonicalJson().unmarshal(json, AuditDetails.class);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Error while processing given json input: " + e.getMessage());
}
break;
case XML:
default:
throw new UnexpectedSwitchCaseException(format);
}
return auditResult;
}
use of com.nedap.archie.rm.generic.AuditDetails in project ehrbase by ehrbase.
the class ContributionServiceImp method retrieveAuditDetails.
/**
* retrieval and building of AuditDetails object attached to the given contribution context
* @param contributionId ID of contribution
* @return {@link AuditDetails} object from contribution
*/
private AuditDetails retrieveAuditDetails(UUID contributionId) {
UUID auditId = I_ContributionAccess.retrieveInstance(this.getDataAccess(), contributionId).getHasAuditDetails();
I_AuditDetailsAccess auditDetailsAccess = new AuditDetailsAccess(this.getDataAccess()).retrieveInstance(this.getDataAccess(), auditId);
String systemId = auditDetailsAccess.getSystemId().toString();
PartyProxy committer = new PersistedPartyProxy(this.getDataAccess()).retrieve(auditDetailsAccess.getCommitter());
DvDateTime timeCommitted = new DvDateTime(LocalDateTime.ofInstant(auditDetailsAccess.getTimeCommitted().toInstant(), ZoneId.of(auditDetailsAccess.getTimeCommittedTzId())));
int changeTypeCode = I_ConceptAccess.ContributionChangeType.valueOf(auditDetailsAccess.getChangeType().getLiteral().toUpperCase()).getCode();
// FIXME: what's the terminology ID of the official change type terminology?
DvCodedText changeType = new DvCodedText(auditDetailsAccess.getChangeType().getLiteral(), new CodePhrase(new TerminologyId("audit change type"), String.valueOf(changeTypeCode)));
DvText description = new DvText(auditDetailsAccess.getDescription());
return new AuditDetails(systemId, committer, timeCommitted, changeType, description);
}
Aggregations