Search in sources :

Example 1 with RmObjectEncoding

use of org.ehrbase.serialisation.dbencoding.RmObjectEncoding in project openEHR_SDK by ehrbase.

the class ActionAttributes method toMap.

public Map<String, Object> toMap(Action action) {
    if (action.getTime() != null && !action.getTime().equals(new DvDateTime())) {
        map = toMap(TAG_TIME, action.getTime(), action.getName());
    }
    if (action.getInstructionDetails() != null) {
        InstructionDetails instructionDetails = action.getInstructionDetails();
        map.put(TAG_INSTRUCTION_DETAILS, new RmObjectEncoding(instructionDetails).toMap());
    }
    if (action.getIsmTransition() != null) {
        IsmTransition ismTransition = action.getIsmTransition();
        if (ismTransition != null) {
            map.put(TAG_ISM_TRANSITION, new RmObjectEncoding(ismTransition).toMap());
        }
    }
    map = super.toMap(action);
    return map;
}
Also used : InstructionDetails(com.nedap.archie.rm.composition.InstructionDetails) RmObjectEncoding(org.ehrbase.serialisation.dbencoding.RmObjectEncoding) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) IsmTransition(com.nedap.archie.rm.composition.IsmTransition)

Example 2 with RmObjectEncoding

use of org.ehrbase.serialisation.dbencoding.RmObjectEncoding in project openEHR_SDK by ehrbase.

the class FeederAuditAttributes method toMap.

/**
 * encode the attributes lower snake case to comply with UML conventions and make is queryable
 * @return
 */
public Map<String, Object> toMap() {
    Map<String, Object> valuemap = PathMap.getInstance();
    valuemap.put(TAG_CLASS, new SimpleClassName(feederAudit).toString());
    if (feederAudit.getOriginatingSystemItemIds() != null && !feederAudit.getOriginatingSystemItemIds().isEmpty()) {
        valuemap.put("originating_system_item_ids", encodeDvIdentifiers(feederAudit.getOriginatingSystemItemIds()));
    }
    valuemap.put("feeder_system_audit", new FeederAuditDetailsAttributes(feederAudit.getFeederSystemAudit()).toMap());
    if (feederAudit.getFeederSystemItemIds() != null && !feederAudit.getFeederSystemItemIds().isEmpty()) {
        valuemap.put("feeder_system_item_ids", encodeDvIdentifiers(feederAudit.getFeederSystemItemIds()));
    }
    if (feederAudit.getOriginalContent() != null)
        valuemap.put("original_content", new RmObjectEncoding(feederAudit.getOriginalContent()).toMap());
    valuemap.put("originating_system_audit", new FeederAuditDetailsAttributes(feederAudit.getOriginatingSystemAudit()).toMap());
    return valuemap;
}
Also used : RmObjectEncoding(org.ehrbase.serialisation.dbencoding.RmObjectEncoding) SimpleClassName(org.ehrbase.serialisation.dbencoding.SimpleClassName)

Example 3 with RmObjectEncoding

use of org.ehrbase.serialisation.dbencoding.RmObjectEncoding in project openEHR_SDK by ehrbase.

the class FeederAuditDetailsAttributes method toMap.

/**
 * encode the attributes lower snake case to comply with UML conventions and make is queryable
 * @return
 */
public Map<String, Object> toMap() {
    Map<String, Object> valuemap = PathMap.getInstance();
    if (feederAuditDetails == null)
        return null;
    valuemap.put(I_DvTypeAdapter.AT_TYPE, new SnakeCase(FeederAuditDetails.class.getSimpleName()).camelToUpperSnake());
    if (feederAuditDetails.getLocation() != null) {
        valuemap.put("location", new RmObjectEncoding(feederAuditDetails.getLocation()).toMap());
    }
    if (feederAuditDetails.getProvider() != null) {
        valuemap.put("provider", new RmObjectEncoding(feederAuditDetails.getProvider()).toMap());
    }
    if (feederAuditDetails.getSubject() != null) {
        valuemap.put("subject", new RmObjectEncoding(feederAuditDetails.getSubject()).toMap());
    }
    if (feederAuditDetails.getSystemId() != null) {
        valuemap.put("system_id", feederAuditDetails.getSystemId());
    }
    if (feederAuditDetails.getTime() != null) {
        valuemap.put("time", new RmObjectEncoding(feederAuditDetails.getTime()).toMap());
    }
    if (feederAuditDetails.getVersionId() != null) {
        valuemap.put("version_id", feederAuditDetails.getVersionId());
    }
    if (feederAuditDetails.getOtherDetails() != null) {
        String dbEncoded = new CompositionSerializer().dbEncode(feederAuditDetails.getOtherDetails());
        Map<String, Object> asMap = new LightRawJsonEncoder(dbEncoded).encodeOtherDetailsAsMap();
        String nodeId = asMap.get("/archetype_node_id").toString();
        // make sure node id is wrapped in [ and ] and throw errors if invalid input
        if (!nodeId.startsWith("[")) {
            if (nodeId.endsWith("]"))
                throw new IllegalArgumentException("Invalid archetype node id");
            nodeId = "[" + nodeId + "]";
        } else if (!nodeId.endsWith("]")) {
            throw new IllegalArgumentException("Invalid archetype node id");
        }
        valuemap.put("other_details" + nodeId, asMap);
    }
    return valuemap;
}
Also used : FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) RmObjectEncoding(org.ehrbase.serialisation.dbencoding.RmObjectEncoding) CompositionSerializer(org.ehrbase.serialisation.dbencoding.CompositionSerializer)

Aggregations

RmObjectEncoding (org.ehrbase.serialisation.dbencoding.RmObjectEncoding)3 FeederAuditDetails (com.nedap.archie.rm.archetyped.FeederAuditDetails)1 InstructionDetails (com.nedap.archie.rm.composition.InstructionDetails)1 IsmTransition (com.nedap.archie.rm.composition.IsmTransition)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 CompositionSerializer (org.ehrbase.serialisation.dbencoding.CompositionSerializer)1 SimpleClassName (org.ehrbase.serialisation.dbencoding.SimpleClassName)1 LightRawJsonEncoder (org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder)1 SnakeCase (org.ehrbase.serialisation.util.SnakeCase)1