Search in sources :

Example 26 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvOrdinalRMUnmarshaller method handle.

/**
 * {@inheritDoc}
 */
@Override
public void handle(String currentTerm, DvOrdinal rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
    rmObject.setSymbol(new DvCodedText());
    rmObject.getSymbol().setDefiningCode(new CodePhrase());
    // TerminologyId is fixed local for DvOrdinal
    rmObject.getSymbol().getDefiningCode().setTerminologyId(new TerminologyId("local"));
    FlatHelper.consumeAllMatching(currentTerm + "|terminology", currentValues, consumedPaths, true);
    setValue(currentTerm, "code", currentValues, rmObject.getSymbol().getDefiningCode()::setCodeString, String.class, consumedPaths);
    if (rmObject.getSymbol().getDefiningCode().getCodeString() == null) {
        setValue(currentTerm, null, currentValues, rmObject.getSymbol().getDefiningCode()::setCodeString, String.class, consumedPaths);
    }
    var codeString = rmObject.getSymbol().getDefiningCode().getCodeString();
    var matchingInput = context.getNodeDeque().peek().getInputs().get(0).getList().stream().filter(inputValue -> inputValue.getValue().equals(codeString)).findFirst();
    if (matchingInput.isPresent()) {
        rmObject.setValue(Long.valueOf(matchingInput.get().getOrdinal()));
        consumedPaths.add(currentTerm + "|ordinal");
        rmObject.getSymbol().setValue(matchingInput.get().getLabel());
        consumedPaths.add(currentTerm + "|value");
    } else {
        setValue(currentTerm, "ordinal", currentValues, rmObject::setValue, Long.class, consumedPaths);
        setValue(currentTerm, "value", currentValues, rmObject.getSymbol()::setValue, String.class, consumedPaths);
    }
}
Also used : Context(org.ehrbase.serialisation.walker.Context) FlatHelper(org.ehrbase.serialisation.walker.FlatHelper) DvOrdinal(com.nedap.archie.rm.datavalues.quantity.DvOrdinal) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) Map(java.util.Map) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase)

Example 27 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvCodedTextIT method testValidate_FhirValueSet_WrongCode.

@Test
void testValidate_FhirValueSet_WrongCode() throws Exception {
    var codePhrase = new CodePhrase(new TerminologyId("http://terminology.hl7.org/CodeSystem/v3-EntityNameUseR2"), "UKN");
    var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_valueset.json");
    var result = validator.validate(new DvCodedText("Anonymous", codePhrase), node);
    assertEquals(1, result.size());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Test(org.junit.jupiter.api.Test) AbstractRMObjectValidatorTest(org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)

Example 28 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvCodedTextIT method testValidate_FhirValueSet_WrongTerminologyId.

@Test
void testValidate_FhirValueSet_WrongTerminologyId() throws Exception {
    var codePhrase = new CodePhrase(new TerminologyId("http://snomed.info/sct"), "ANON");
    var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_valueset.json");
    var result = validator.validate(new DvCodedText("Anonymous", codePhrase), node);
    assertEquals(1, result.size());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Test(org.junit.jupiter.api.Test) AbstractRMObjectValidatorTest(org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)

Example 29 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvOrdinalValidatorTest method testValidate_List.

@Test
void testValidate_List() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_ordinal_list.json");
    var symbol = new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0043"));
    var result = validator.validate(new DvOrdinal(1L, symbol), node);
    assertTrue(result.isEmpty());
    symbol = new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0001"));
    result = validator.validate(new DvOrdinal(1L, symbol), node);
    assertEquals(1, result.size());
    symbol = new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0043"));
    result = validator.validate(new DvOrdinal(2L, symbol), node);
    assertEquals(1, result.size());
}
Also used : DvOrdinal(com.nedap.archie.rm.datavalues.quantity.DvOrdinal) 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.jupiter.api.Test)

Example 30 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvOrdinalValidatorTest method testValidate.

@Test
void testValidate() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_ordinal.json");
    var symbol = new DvCodedText("Test", new CodePhrase(new TerminologyId("local"), "at0010"));
    var result = validator.validate(new DvOrdinal(1L, symbol), node);
    assertTrue(result.isEmpty());
}
Also used : DvOrdinal(com.nedap.archie.rm.datavalues.quantity.DvOrdinal) 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.jupiter.api.Test)

Aggregations

CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)71 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)60 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)56 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)16 Composition (com.nedap.archie.rm.composition.Composition)12 DvText (com.nedap.archie.rm.datavalues.DvText)12 ArrayList (java.util.ArrayList)8 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 RMObject (com.nedap.archie.rm.RMObject)5 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)5 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)5 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)4 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)4 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)4 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)4 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)4 Entry (com.nedap.archie.rm.composition.Entry)3