Search in sources :

Example 21 with DvCodedText

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");
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Test(org.junit.Test)

Example 22 with DvCodedText

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) {
    }
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Test(org.junit.Test)

Example 23 with DvCodedText

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);
    }
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvText(com.nedap.archie.rm.datavalues.DvText)

Example 24 with DvCodedText

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

Example 25 with DvCodedText

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())));
    }
}
Also used : DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto)

Aggregations

DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)74 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)56 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)50 Test (org.junit.jupiter.api.Test)25 DvText (com.nedap.archie.rm.datavalues.DvText)17 Test (org.junit.Test)15 Composition (com.nedap.archie.rm.composition.Composition)9 ArrayList (java.util.ArrayList)9 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)8 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)8 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)7 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)7 List (java.util.List)7 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 IOException (java.io.IOException)6 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)6 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)6 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)6 EventContext (com.nedap.archie.rm.composition.EventContext)4 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)4