Search in sources :

Example 21 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class ElementAttributes method toMap.

/**
 * map the value or null_flavour of an Element
 * @param element
 * @return
 */
public Map<String, Object> toMap(Element element) {
    Map<String, Object> ltree = map;
    // to deal with ITEM_SINGLE initial value
    if (element.getName().getValue().startsWith(INITIAL_DUMMY_PREFIX)) {
        if (allElements) {
            // strip the prefix since it is for an example
            DvText elementName = element.getName();
            elementName.setValue(elementName.getValue().substring(INITIAL_DUMMY_PREFIX.length()));
            element.setName(elementName);
        } else
            return ltree;
    }
    // contains value or null_flavor
    Map<String, Object> valuemap = buildValueMap(element);
    ltree.put(TAG_VALUE, valuemap);
    return ltree;
}
Also used : DvText(com.nedap.archie.rm.datavalues.DvText)

Example 22 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class IsmTransitionAttributes 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 (ismTransition == null)
        return null;
    if (ismTransition.getReason() != null) {
        List<Map<String, Object>> reasons = new ArrayList<>();
        for (DvText reason : ismTransition.getReason()) {
            valuemap.put(TAG_CLASS, new SimpleClassName(reason).toString());
            valuemap.put("value", reason.getValue());
            reasons.add(valuemap);
        }
        valuemap.put("reason", reasons);
    }
    if (ismTransition.getCareflowStep() != null) {
        valuemap.put("careflow_step", ismTransition.getCareflowStep());
    }
    if (ismTransition.getCurrentState() != null) {
        valuemap.put("current_state", ismTransition.getCurrentState());
    }
    if (ismTransition.getTransition() != null) {
        valuemap.put("transition", ismTransition.getTransition());
    }
    return valuemap;
}
Also used : ArrayList(java.util.ArrayList) SimpleClassName(org.ehrbase.serialisation.dbencoding.SimpleClassName) Map(java.util.Map) PathMap(org.ehrbase.serialisation.dbencoding.PathMap) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 23 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class DvTextPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, DvText rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    FlatHelper.extractMultiValuedFullPath(term, "_mapping", values).entrySet().stream().map(e -> {
        TermMapping termMapping = new TermMapping();
        callUnmarshal(term, "/_mapping:" + e.getKey(), termMapping, e.getValue(), consumedPaths, context, context.getNodeDeque().peek().findChildById("mappings").orElse(buildDummyChild("mappings", context.getNodeDeque().peek())));
        callPostProcess(term, "/_mapping:" + e.getKey(), termMapping, e.getValue(), consumedPaths, context, context.getNodeDeque().peek().findChildById("mappings").orElse(buildDummyChild("mappings", context.getNodeDeque().peek())));
        return termMapping;
    }).forEach(rmObject::addMapping);
    FlatHelper.consumeAllMatching(term + "/_mapping", values, consumedPaths, false);
    Map<FlatPathDto, String> language = FlatHelper.filter(values, term + "/_language", false);
    if (!language.isEmpty()) {
        rmObject.setLanguage(new CodePhrase());
        handleRmAttribute(term, rmObject.getLanguage(), language, consumedPaths, context, "language");
    }
    Map<FlatPathDto, String> encoding = FlatHelper.filter(values, term + "/_encoding", false);
    if (!encoding.isEmpty()) {
        rmObject.setEncoding(new CodePhrase());
        handleRmAttribute(term, rmObject.getEncoding(), encoding, consumedPaths, context, "encoding");
    }
}
Also used : Context(org.ehrbase.serialisation.walker.Context) FlatHelper(org.ehrbase.serialisation.walker.FlatHelper) DvText(com.nedap.archie.rm.datavalues.DvText) Map(java.util.Map) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) FlatHelper.buildDummyChild(org.ehrbase.serialisation.walker.FlatHelper.buildDummyChild) Set(java.util.Set) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) TermMapping(com.nedap.archie.rm.datavalues.TermMapping) TermMapping(com.nedap.archie.rm.datavalues.TermMapping) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto)

Example 24 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class ElementPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, Element rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    Map<FlatPathDto, String> reasonValues = FlatHelper.filter(values, term + "/_null_reason", false);
    if (!reasonValues.isEmpty()) {
        if (FlatHelper.isDvCodedText(reasonValues, term + "_null_reason")) {
            rmObject.setNullReason(new DvCodedText());
        } else {
            rmObject.setNullReason(new DvText());
        }
        handleRmAttribute(term, rmObject.getNullReason(), reasonValues, consumedPaths, context, "null_reason");
    }
    setValue(term + PATH_DIVIDER + "_null_flavour", "value", values, s -> {
        if (StringUtils.isNotBlank(s)) {
            rmObject.setNullFlavour(FlatHelper.findEnumValueOrThrow(s, NullFlavour.class).toCodedText());
        }
    }, String.class, consumedPaths);
    setValue(term + PATH_DIVIDER + "_null_flavour", "code", values, s -> {
        if (StringUtils.isNotBlank(s)) {
            rmObject.setNullFlavour(FlatHelper.findEnumValueOrThrow(s, NullFlavour.class).toCodedText());
        }
    }, String.class, consumedPaths);
    FlatHelper.consumeAllMatching(term + PATH_DIVIDER + "_null_flavour|terminology", values, consumedPaths, false);
    if (rmObject.getNullFlavour() != null) {
        rmObject.setValue(null);
        FlatHelper.consumeAllMatching(term, values, consumedPaths, false);
    }
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 25 with DvText

use of com.nedap.archie.rm.datavalues.DvText in project openEHR_SDK by ehrbase.

the class LocatableUnmarshalPostprocessor method process.

/**
 * {@inheritDoc} Unmarshalls {@link Composition#setUid}
 */
@Override
public void process(String term, Locatable rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    if (RmConstants.ELEMENT.equals(context.getNodeDeque().peek().getRmType()) || !context.getFlatHelper().skip(context)) {
        setValue(term + PATH_DIVIDER + "_uid", null, values, s -> rmObject.setUid(new HierObjectId(s)), String.class, consumedPaths);
        Map<Integer, Map<String, String>> links = extractMultiValued(term, "_link", values);
        if (rmObject.getLinks() == null) {
            rmObject.setLinks(new ArrayList<>());
        }
        rmObject.getLinks().addAll(links.values().stream().map(DefaultValues::createLink).collect(Collectors.toList()));
        consumeAllMatching(term + PATH_DIVIDER + "_link", values, consumedPaths, false);
        Map<FlatPathDto, String> feederAuditValues = FlatHelper.filter(values, term + "/_feeder_audit", false);
        if (!feederAuditValues.isEmpty()) {
            rmObject.setFeederAudit(new FeederAudit());
            handleRmAttribute(term, rmObject.getFeederAudit(), feederAuditValues, consumedPaths, context, "feeder_audit");
        }
        Map<FlatPathDto, String> nameValues = FlatHelper.filter(values, term + "/_name", false);
        if (!nameValues.isEmpty()) {
            final DvText name;
            boolean isDvCodedText = nameValues.keySet().stream().anyMatch(e -> "code".equals(e.getLast().getAttributeName()) && "_name".equals(e.getLast().getName()));
            if (isDvCodedText) {
                name = new DvCodedText();
            } else {
                name = new DvText();
            }
            rmObject.setName(name);
            handleRmAttribute(term, rmObject.getName(), nameValues, consumedPaths, context, "name");
        }
    }
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvText(com.nedap.archie.rm.datavalues.DvText) FeederAudit(com.nedap.archie.rm.archetyped.FeederAudit) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) Map(java.util.Map) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Aggregations

DvText (com.nedap.archie.rm.datavalues.DvText)50 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)16 Test (org.junit.Test)14 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)11 PartySelf (com.nedap.archie.rm.generic.PartySelf)11 Composition (com.nedap.archie.rm.composition.Composition)10 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)9 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)9 ArrayList (java.util.ArrayList)9 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)9 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)8 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)8 UUID (java.util.UUID)8 Participation (com.nedap.archie.rm.generic.Participation)6 Optional (java.util.Optional)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 Folder (com.nedap.archie.rm.directory.Folder)5 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)5 URI (java.net.URI)5