Search in sources :

Example 1 with RMTypeInfo

use of com.nedap.archie.rminfo.RMTypeInfo in project openEHR_SDK by ehrbase.

the class DefaultNamingStrategy method isEntityAttribute.

private boolean isEntityAttribute(ClassGeneratorContext context, WebTemplateNode node) {
    FlatPath relativPath = new FlatPath(context.nodeDeque.peek().buildRelativePath(node));
    RMTypeInfo typeInfo = RM_INFO_LOOKUP.getTypeInfo(context.nodeDeque.peek().getRmType());
    return relativPath.getChild() == null && typeInfo != null && typeInfo.getAttributes().containsKey(relativPath.getName());
}
Also used : RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo) FlatPath(org.ehrbase.webtemplate.parser.FlatPath)

Example 2 with RMTypeInfo

use of com.nedap.archie.rminfo.RMTypeInfo in project openEHR_SDK by ehrbase.

the class OPTParser method addInContext.

private void addInContext(WebTemplateNode node, WebTemplateNode child) {
    Map<Class<?>, List<String>> contextAttributes = Map.of(Locatable.class, List.of("language"), Action.class, List.of("time"), Activity.class, List.of("timing", "action_archetype_id"), Instruction.class, List.of("narrative"), IsmTransition.class, List.of("current_state", "careflow_step", "transition"), History.class, List.of("origin"), Event.class, List.of("time"), Entry.class, List.of("language", "provider", "other_participations", "subject", "encoding"), EventContext.class, List.of("start_time", "end_time", "location", "setting", "healthCareFacility", "participations"), Composition.class, List.of("language", "territory", "composer", "category"));
    RMTypeInfo typeInfo = ARCHIE_RM_INFO_LOOKUP.getTypeInfo(node.getRmType());
    if (typeInfo != null) {
        contextAttributes.forEach((k, v) -> {
            if (k.isAssignableFrom(typeInfo.getJavaClass()) && v.contains(child.getId())) {
                child.setInContext(true);
            }
        });
    }
}
Also used : RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo) NodeList(org.w3c.dom.NodeList)

Example 3 with RMTypeInfo

use of com.nedap.archie.rminfo.RMTypeInfo in project openEHR_SDK by ehrbase.

the class FlatHelper method isNonMandatoryRmAttribute.

public boolean isNonMandatoryRmAttribute(WebTemplateNode node, WebTemplateNode parent) {
    RMTypeInfo typeInfo = Walker.ARCHIE_RM_INFO_LOOKUP.getTypeInfo(parent.getRmType());
    boolean nonMandatoryRmAttribute = typeInfo.getAttributes().containsKey(node.getName()) && node.getMin() == 0;
    boolean mandatoryNotInWebTemplate = List.of("name", "archetype_node_id", "origin", "media_type", "upper_included", "lower_included", "upper_unbounded", "lower_unbounded").contains(node.getName());
    boolean nonMandatoryInWebTemplate = typeInfo.getRmName().equals("ACTIVITY") && node.getName().equals("timing") || typeInfo.getRmName().equals("INSTRUCTION") && node.getName().equals("expiry_time") || typeInfo.getRmName().equals("INTERVAL_EVENT") && node.getName().equals("width") || typeInfo.getRmName().equals("INTERVAL_EVENT") && node.getName().equals("math_function") || typeInfo.getRmName().equals(ISM_TRANSITION) && node.getName().equals("transition");
    return (nonMandatoryRmAttribute || mandatoryNotInWebTemplate) && !nonMandatoryInWebTemplate;
}
Also used : RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo)

Example 4 with RMTypeInfo

use of com.nedap.archie.rminfo.RMTypeInfo in project openEHR_SDK by ehrbase.

the class FlattFilter method skip.

@Override
protected boolean skip(WebTemplateNode node, WebTemplate context, Deque<WebTemplateNode> deque) {
    WebTemplateNode parent = deque.peek();
    if (isTrivialNode(node, parent)) {
        return true;
    } else {
        if (parent != null) {
            RMTypeInfo typeInfo = ARCHIE_RM_INFO_LOOKUP.getTypeInfo(parent.getRmType());
            Set<String> attributeNames = Optional.ofNullable(configMap.get(typeInfo.getJavaClass())).map(RmIntrospectConfig::getNonTemplateFields).orElse(Collections.emptySet()).stream().map(s -> new SnakeCase(s).camelToSnake()).collect(Collectors.toSet());
            attributeNames.add("context");
            attributeNames.add("timing");
            attributeNames.add("expiry_time");
            attributeNames.add("lower");
            attributeNames.add("upper");
            attributeNames.add("ism_transition");
            attributeNames.add("location");
            attributeNames.add("lower_included");
            attributeNames.add("upper_included");
            attributeNames.add("sample_count");
            deque.poll();
            if (!isTrivialNode(parent, deque.peek()) && Locatable.class.isAssignableFrom(typeInfo.getJavaClass())) {
                attributeNames.add("feeder_audit");
            }
            deque.push(parent);
            if (config.isAddNullFlavor()) {
                attributeNames.add("null_flavour");
            }
            SetUtils.SetView<String> difference = SetUtils.difference(typeInfo.getAttributes().keySet(), attributeNames);
            if (difference.contains(node.getName())) {
                return true;
            }
        }
        return false;
    }
}
Also used : WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) ReflectionHelper(org.ehrbase.util.reflection.ReflectionHelper) RmIntrospectConfig(org.ehrbase.webtemplate.parser.config.RmIntrospectConfig) FlatPath(org.ehrbase.webtemplate.parser.FlatPath) java.util(java.util) Locatable(com.nedap.archie.rm.archetyped.Locatable) RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo) SetUtils(org.apache.commons.collections4.SetUtils) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) Collectors(java.util.stream.Collectors) Filter(org.ehrbase.webtemplate.filter.Filter) RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo) SetUtils(org.apache.commons.collections4.SetUtils) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) RmIntrospectConfig(org.ehrbase.webtemplate.parser.config.RmIntrospectConfig) Locatable(com.nedap.archie.rm.archetyped.Locatable)

Example 5 with RMTypeInfo

use of com.nedap.archie.rminfo.RMTypeInfo in project openEHR_SDK by ehrbase.

the class Filter method isNonMandatoryRmAttribute.

protected boolean isNonMandatoryRmAttribute(WebTemplateNode node, WebTemplateNode parent) {
    RMTypeInfo typeInfo = ARCHIE_RM_INFO_LOOKUP.getTypeInfo(parent.getRmType());
    boolean nonMandatoryRmAttribute = typeInfo.getAttributes().containsKey(node.getName()) && node.getMin() == 0;
    boolean mandatoryNotInWebTemplate = List.of("name", "archetype_node_id", "origin", "media_type", "upper_included", "lower_included", "upper_unbounded", "lower_unbounded").contains(node.getName());
    boolean nonMandatoryInWebTemplate = typeInfo.getRmName().equals("ACTIVITY") && node.getName().equals("timing") || typeInfo.getRmName().equals("INSTRUCTION") && node.getName().equals("expiry_time") || typeInfo.getRmName().equals("ISM_TRANSITION") && node.getName().equals("transition") || typeInfo.getRmName().equals("COMPOSITION") && node.getName().equals("context");
    return (nonMandatoryRmAttribute || mandatoryNotInWebTemplate) && !nonMandatoryInWebTemplate;
}
Also used : RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo)

Aggregations

RMTypeInfo (com.nedap.archie.rminfo.RMTypeInfo)5 FlatPath (org.ehrbase.webtemplate.parser.FlatPath)2 Locatable (com.nedap.archie.rm.archetyped.Locatable)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 SetUtils (org.apache.commons.collections4.SetUtils)1 SnakeCase (org.ehrbase.serialisation.util.SnakeCase)1 ReflectionHelper (org.ehrbase.util.reflection.ReflectionHelper)1 Filter (org.ehrbase.webtemplate.filter.Filter)1 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)1 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)1 RmIntrospectConfig (org.ehrbase.webtemplate.parser.config.RmIntrospectConfig)1 NodeList (org.w3c.dom.NodeList)1