use of com.nedap.archie.rm.datavalues.DvCodedText 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.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class IsmTransitionValueInserter method insert.
@Override
public void insert(IsmTransition rmObject, DefaultValues defaultValues) {
if (RMHelper.isEmpty(rmObject.getCurrentState()) && defaultValues.containsDefaultValue(DefaultValuePath.ACTION_ISM_TRANSITION_CURRENT_STATE)) {
State defaultValue = defaultValues.getDefaultValue(DefaultValuePath.ACTION_ISM_TRANSITION_CURRENT_STATE);
rmObject.setCurrentState(new DvCodedText(defaultValue.getValue(), defaultValue.toCodePhrase()));
}
}
use of com.nedap.archie.rm.datavalues.DvCodedText 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.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class DefaultValues method buildParticipation.
public static Participation buildParticipation(Collection<Map.Entry<String, String>> subValues) {
Participation participation = new Participation();
participation.setPerformer(new PartyIdentified());
extractExact(subValues, "id", s -> {
participation.getPerformer().setExternalRef(new PartyRef());
participation.getPerformer().getExternalRef().setType("PARTY");
GenericId id = new GenericId();
id.setValue(s);
participation.getPerformer().getExternalRef().setId(id);
});
extract(subValues, "name", ((PartyIdentified) participation.getPerformer())::setName);
if (participation.getPerformer().getExternalRef() != null) {
extract(subValues, "id_namespace", n -> participation.getPerformer().getExternalRef().setNamespace(n));
extract(subValues, "id_scheme", ((GenericId) participation.getPerformer().getExternalRef().getId())::setScheme);
}
extract(subValues, "function", s -> participation.setFunction(new DvText(s)));
extract(subValues, "mode", s -> {
ParticipationMode participationMode = findEnumValueOrThrow(s, ParticipationMode.class);
participation.setMode(new DvCodedText());
participation.getMode().setValue(participationMode.getValue());
participation.getMode().setDefiningCode(participationMode.toCodePhrase());
});
((PartyIdentified) participation.getPerformer()).setIdentifiers(splitByIndex(filter(subValues.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), DefaultValuePath.PARTICIPATION.getPath() + "_" + "identifiers")).values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
return participation;
}
use of com.nedap.archie.rm.datavalues.DvCodedText 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