Search in sources :

Example 1 with TemplateId

use of com.nedap.archie.rm.archetyped.TemplateId in project openEHR_SDK by ehrbase.

the class ToCompositionWalker method postHandle.

@Override
protected void postHandle(Context<T> context) {
    RMObject currentRM = context.getRmObjectDeque().peek();
    WebTemplateNode currentNode = context.getNodeDeque().peek();
    if (currentRM instanceof Locatable) {
        org.ehrbase.webtemplate.parser.NodeId nodeId = new NodeId(currentNode.getNodeId());
        if (nodeId.isArchetypeId()) {
            Archetyped archetyped = new Archetyped();
            archetyped.setArchetypeId(new ArchetypeID(nodeId.getNodeId()));
            archetyped.setRmVersion(RM_VERSION_1_4_0);
            TemplateId templateId = new TemplateId();
            templateId.setValue(context.getTemplateId());
            archetyped.setTemplateId(templateId);
            ((Locatable) currentRM).setArchetypeDetails(archetyped);
            ((Locatable) currentRM).setArchetypeNodeId(nodeId.getNodeId());
        }
    }
    normalise(currentRM);
}
Also used : NodeId(org.ehrbase.webtemplate.parser.NodeId) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) NodeId(org.ehrbase.webtemplate.parser.NodeId) Archetyped(com.nedap.archie.rm.archetyped.Archetyped) TemplateId(com.nedap.archie.rm.archetyped.TemplateId) RMObject(com.nedap.archie.rm.RMObject) Locatable(com.nedap.archie.rm.archetyped.Locatable) ArchetypeID(com.nedap.archie.rm.support.identification.ArchetypeID)

Example 2 with TemplateId

use of com.nedap.archie.rm.archetyped.TemplateId in project openEHR_SDK by ehrbase.

the class WebTemplateSkeletonBuilder method build.

public static Composition build(WebTemplate template, boolean withChildren) {
    Composition composition = build(template.getTree(), withChildren, Composition.class);
    composition.setArchetypeDetails(new Archetyped());
    composition.getArchetypeDetails().setTemplateId(new TemplateId());
    composition.getArchetypeDetails().getTemplateId().setValue(template.getTemplateId());
    composition.getArchetypeDetails().setRmVersion(RM_VERSION_1_4_0);
    composition.getArchetypeDetails().setArchetypeId(new ArchetypeID(composition.getArchetypeNodeId()));
    return composition;
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) Archetyped(com.nedap.archie.rm.archetyped.Archetyped) TemplateId(com.nedap.archie.rm.archetyped.TemplateId) ArchetypeID(com.nedap.archie.rm.support.identification.ArchetypeID)

Example 3 with TemplateId

use of com.nedap.archie.rm.archetyped.TemplateId in project ehrbase by ehrbase.

the class EntryAccess method buildArchetypeDetails.

private static void buildArchetypeDetails(EntryAccess entryAccess) {
    Archetyped archetypeDetails = new Archetyped();
    TemplateId templateId = new TemplateId();
    templateId.setValue(entryAccess.getTemplateId());
    archetypeDetails.setTemplateId(templateId);
    archetypeDetails.setArchetypeId(new ArchetypeID(entryAccess.getArchetypeId()));
    archetypeDetails.setRmVersion(entryAccess.getRmVersion());
    entryAccess.composition.setArchetypeDetails(archetypeDetails);
}
Also used : Archetyped(com.nedap.archie.rm.archetyped.Archetyped) TemplateId(com.nedap.archie.rm.archetyped.TemplateId) ArchetypeID(com.nedap.archie.rm.support.identification.ArchetypeID)

Example 4 with TemplateId

use of com.nedap.archie.rm.archetyped.TemplateId in project ehrbase by ehrbase.

the class ContributionServiceImp method getListOfTemplates.

@Override
public Set<String> getListOfTemplates(String contribution, CompositionFormat format) {
    List<Version> versions = ContributionServiceHelper.parseVersions(contribution, format);
    Set<String> templates = new HashSet<>();
    for (Version version : versions) {
        Object versionData = version.getData();
        // the version contains the optional "data" attribute (i.e. payload), therefore has specific object type (composition, folder,...)
        if (versionData != null) {
            RMObject versionRmObject;
            if (versionData instanceof LinkedHashMap) {
                versionRmObject = ContributionServiceHelper.unmarshalMapContentToRmObject((LinkedHashMap) versionData, format);
            } else {
                throw new IllegalArgumentException("Contribution input can't be processed");
            }
            // switch to allow acting depending on exact type
            SupportedClasses versionClass;
            try {
                versionClass = SupportedClasses.valueOf(versionRmObject.getClass().getSimpleName().toUpperCase());
            } catch (Exception e) {
                throw new InvalidApiParameterException("Invalid version object in contribution. " + versionRmObject.getClass().getSimpleName().toUpperCase() + " not supported.");
            }
            switch(versionClass) {
                case COMPOSITION:
                    TemplateId templateId = ((Composition) versionRmObject).getArchetypeDetails().getTemplateId();
                    if (templateId != null) {
                        templates.add(templateId.getValue());
                    }
                    break;
                // TODO: might add later, if other_details support templated content
                case EHRSTATUS:
                case FOLDER:
                default:
                    throw new IllegalArgumentException("Contribution input contains invalid version class");
            }
        }
    }
    return templates;
}
Also used : Version(com.nedap.archie.rm.changecontrol.Version) RMObject(com.nedap.archie.rm.RMObject) TemplateId(com.nedap.archie.rm.archetyped.TemplateId) RMObject(com.nedap.archie.rm.RMObject)

Aggregations

TemplateId (com.nedap.archie.rm.archetyped.TemplateId)4 Archetyped (com.nedap.archie.rm.archetyped.Archetyped)3 ArchetypeID (com.nedap.archie.rm.support.identification.ArchetypeID)3 RMObject (com.nedap.archie.rm.RMObject)2 Locatable (com.nedap.archie.rm.archetyped.Locatable)1 Version (com.nedap.archie.rm.changecontrol.Version)1 Composition (com.nedap.archie.rm.composition.Composition)1 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)1 NodeId (org.ehrbase.webtemplate.parser.NodeId)1