Search in sources :

Example 6 with AuditDetails

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;
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) RMObject(com.nedap.archie.rm.RMObject) AuditDetails(com.nedap.archie.rm.generic.AuditDetails) UnexpectedSwitchCaseException(org.ehrbase.api.exception.UnexpectedSwitchCaseException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 7 with AuditDetails

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);
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) AuditDetailsAccess(org.ehrbase.dao.access.jooq.AuditDetailsAccess) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DvText(com.nedap.archie.rm.datavalues.DvText) PersistedPartyProxy(org.ehrbase.dao.access.jooq.party.PersistedPartyProxy) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) AuditDetails(com.nedap.archie.rm.generic.AuditDetails)

Aggregations

AuditDetails (com.nedap.archie.rm.generic.AuditDetails)7 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)4 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)3 DvText (com.nedap.archie.rm.datavalues.DvText)3 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)3 Attestation (com.nedap.archie.rm.generic.Attestation)3 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)3 RMObject (com.nedap.archie.rm.RMObject)2 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)1 Version (com.nedap.archie.rm.changecontrol.Version)1 Composition (com.nedap.archie.rm.composition.Composition)1 DvEHRURI (com.nedap.archie.rm.datavalues.DvEHRURI)1 DvMultimedia (com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia)1 VersionedComposition (com.nedap.archie.rm.ehr.VersionedComposition)1 RevisionHistoryItem (com.nedap.archie.rm.generic.RevisionHistoryItem)1 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)1