use of com.nedap.archie.rm.datatypes.CodePhrase 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.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvCodedTextRMUnmarshaller method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(String currentTerm, DvCodedText rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
setValue(currentTerm, "value", currentValues, rmObject::setValue, String.class, consumedPaths);
rmObject.setDefiningCode(new CodePhrase());
setValue(currentTerm, "code", currentValues, c -> rmObject.getDefiningCode().setCodeString(c), String.class, consumedPaths);
rmObject.getDefiningCode().setTerminologyId(new TerminologyId());
setValue(currentTerm, "terminology", currentValues, t -> rmObject.getDefiningCode().getTerminologyId().setValue(t), String.class, consumedPaths);
if (rmObject.getDefiningCode().getCodeString() == null && rmObject.getValue() == null) {
setValue(currentTerm, null, currentValues, c -> {
if (c != null) {
// try to interpret as code
setFromNode(rmObject, context, v -> Objects.equals(v.getValue(), c));
if (rmObject.getValue() == null) {
// try to interpret as value
setFromNode(rmObject, context, v -> Objects.equals(v.getLabel(), c));
}
}
}, String.class, consumedPaths);
} else if (rmObject.getDefiningCode().getCodeString() == null) {
setValue(currentTerm, null, currentValues, // It is the code
c -> rmObject.getDefiningCode().setCodeString(c), String.class, consumedPaths);
}
// Set terminology from Node
Optional.of(context.getNodeDeque().peek().getInputs()).stream().flatMap(List::stream).filter(i -> "code".equals(i.getSuffix())).findAny().map(WebTemplateInput::getTerminology).ifPresent(t -> rmObject.getDefiningCode().getTerminologyId().setValue(t));
// Set value from Node
setFromNode(rmObject, context, v -> Objects.equals(v.getValue(), rmObject.getDefiningCode().getCodeString()));
// set code from value if not set
if (rmObject.getDefiningCode().getCodeString() == null && rmObject.getValue() != null) {
setFromNode(rmObject, context, v -> Objects.equals(v.getLabel(), rmObject.getValue()));
}
setFromNode(rmObject, context, v -> Objects.equals(v.getValue(), rmObject.getDefiningCode().getCodeString()));
// consume strange legacy paths
if (rmObject.getDefiningCode() != null && rmObject.getDefiningCode().getCodeString() != null) {
currentValues.keySet().stream().map(FlatPathDto::format).filter(k -> StringUtils.substringAfter(k, "|").equals(rmObject.getDefiningCode().getCodeString())).forEach(consumedPaths::add);
}
setValue(currentTerm, "formatting", currentValues, rmObject::setFormatting, String.class, consumedPaths);
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvEncapsulatedPostprocessor method process.
/**
* {@inheritDoc}
*/
@Override
public void process(String term, DvEncapsulated rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
Map<FlatPathDto, String> languageValues = filter(values, term + "/_language", false);
if (!languageValues.isEmpty()) {
rmObject.setLanguage(new CodePhrase());
handleRmAttribute(term, rmObject.getLanguage(), languageValues, consumedPaths, context, "language");
}
Map<FlatPathDto, String> charsetValues = filter(values, term + "/_charset", false);
if (!charsetValues.isEmpty()) {
rmObject.setCharset(new CodePhrase());
handleRmAttribute(term, rmObject.getCharset(), charsetValues, consumedPaths, context, "charset");
}
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvOrderedPostprocessor method process.
/**
* {@inheritDoc}
*/
@Override
public void process(String term, DvOrdered rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
handleNormalRange(values, consumedPaths, context, term + "/_normal_range", rmObject::setNormalRange);
FlatHelper.extractMultiValuedFullPath(term, "_other_reference_ranges", values).forEach((k, v) -> {
ReferenceRange referenceRange = new ReferenceRange();
rmObject.addOtherReferenceRange(referenceRange);
Map<FlatPathDto, String> meaningValues = FlatHelper.filter(values, term + "/_other_reference_ranges:" + k + "/meaning", false);
if (!meaningValues.isEmpty()) {
final DvText meaning;
String meaningAttributeName = "meaning";
boolean isDvCodedText = isDvCodedText(meaningValues, term + "/_other_reference_ranges:" + k + "/meaning");
if (isDvCodedText) {
meaning = new DvCodedText();
} else {
meaning = new DvText();
}
referenceRange.setMeaning(meaning);
callUnmarshal(term + "/_other_reference_ranges:" + k, meaningAttributeName, meaning, meaningValues, consumedPaths, context, context.getNodeDeque().peek().findChildById(meaningAttributeName).orElse(buildDummyChild(meaningAttributeName, context.getNodeDeque().peek())));
callPostProcess(term + "/_other_reference_ranges:" + k, meaningAttributeName, meaning, meaningValues, consumedPaths, context, context.getNodeDeque().peek().findChildById(meaningAttributeName).orElse(buildDummyChild(meaningAttributeName, context.getNodeDeque().peek())));
}
handleNormalRange(v, consumedPaths, context, term + "/_other_reference_ranges:" + k, referenceRange::setRange);
});
setValue(term, "normal_status", values, s -> {
if (s != null) {
rmObject.setNormalStatus(new CodePhrase(new TerminologyId("openehr_normal_statuses"), s));
}
}, String.class, consumedPaths);
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class IsmTransitionRMUnmarshaller method handle.
@Override
public void handle(String currentTerm, IsmTransition rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
rmObject.setCurrentState(new DvCodedText());
rmObject.getCurrentState().setDefiningCode(new CodePhrase());
rmObject.getCurrentState().getDefiningCode().setTerminologyId(new TerminologyId());
setValue(currentTerm + "/current_state", "code", currentValues, rmObject.getCurrentState().getDefiningCode()::setCodeString, String.class, consumedPaths);
setValue(currentTerm + "/current_state", "value", currentValues, rmObject.getCurrentState()::setValue, String.class, consumedPaths);
setValue(currentTerm + "/current_state", "terminology", currentValues, rmObject.getCurrentState().getDefiningCode().getTerminologyId()::setValue, String.class, consumedPaths);
}
Aggregations