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;
}
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;
}
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");
}
}
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);
}
}
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");
}
}
}
Aggregations