use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidationSymbol.
@Test
public void testSimpleValidationSymbol() {
DvCodedText symbol = new DvCodedText("autogenerated (node doesn't have a constraint)", new CodePhrase(new TerminologyId("http://hl7.org/fhir/contact-point-use"), "BCDWXMEORP"));
org.ehrbase.validation.terminology.validator.DvOrdinal.validate(localizedTerminologies.locale("en"), codesetMapping, "symbol", symbol, "en");
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidationWrongValue.
@Test
public void testSimpleValidationWrongValue() throws Exception {
DvCodedText category = new DvCodedText("not quite sure what to put here", new CodePhrase(new TerminologyId("openehr"), "433"));
try {
org.ehrbase.validation.terminology.validator.DvCodedText.validate(localizedTerminologies.locale("en"), codesetMapping, "category", category, "en");
fail("should have detected a wrong value");
} catch (Exception e) {
}
}
use of com.nedap.archie.rm.datavalues.DvCodedText 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.DvCodedText 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");
}
}
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class PartyRelatedPostprocessor method process.
/**
* {@inheritDoc}
*/
@Override
public void process(String term, PartyRelated rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
Map<FlatPathDto, String> relationshipValues = FlatHelper.filter(values, term + "/relationship", false);
if (!relationshipValues.isEmpty()) {
rmObject.setRelationship(new DvCodedText());
callUnmarshal(term, "relationship", rmObject.getRelationship(), relationshipValues, consumedPaths, context, context.getNodeDeque().peek().findChildById("relationship").orElse(buildDummyChild("relationship", context.getNodeDeque().peek())));
callPostProcess(term, "relationship", rmObject.getRelationship(), relationshipValues, consumedPaths, context, context.getNodeDeque().peek().findChildById("relationship").orElse(buildDummyChild("relationship", context.getNodeDeque().peek())));
}
}
Aggregations