Search in sources :

Example 31 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 32 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 33 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 34 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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 35 with DvCodedText

use of com.nedap.archie.rm.datavalues.DvCodedText 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

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