Search in sources :

Example 1 with DvOrdinal

use of com.nedap.archie.rm.datavalues.quantity.DvOrdinal in project openEHR_SDK by ehrbase.

the class StatusesTestOverwrite method ordinalN.

@Override
@Test
public void ordinalN() throws Exception {
    String template = this.getFileContent("/res/test_statuses.opt");
    Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/id_scheme", "ispek", "ctx/id_namespace", "ispek", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/ordinal", "at0006", "test_statuses/test_statuses:0/ordinal|normal_status", "N");
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    DvOrdinal ordinal = (DvOrdinal) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value");
    assertThat(ordinal.getNormalStatus()).isNotNull();
    assertThat(ordinal.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
    assertThat(ordinal.getNormalStatus().getCodeString()).isEqualTo("N");
    Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
    assertThat(value).containsEntry("test_statuses/test_statuses:0/ordinal|normal_status", "N");
}
Also used : DvOrdinal(com.nedap.archie.rm.datavalues.quantity.DvOrdinal) Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 2 with DvOrdinal

use of com.nedap.archie.rm.datavalues.quantity.DvOrdinal 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 3 with DvOrdinal

use of com.nedap.archie.rm.datavalues.quantity.DvOrdinal 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 4 with DvOrdinal

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

Example 5 with DvOrdinal

use of com.nedap.archie.rm.datavalues.quantity.DvOrdinal in project openEHR_SDK by ehrbase.

the class StatusesTestOverwrite method ordinal.

@Override
@Test
public void ordinal() throws Exception {
    String template = this.getFileContent("/res/test_statuses.opt");
    Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/id_scheme", "ispek", "ctx/id_namespace", "ispek", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/ordinal", "at0006", "test_statuses/test_statuses:0/ordinal|normal_status", "L");
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    DvOrdinal ordinal = (DvOrdinal) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value");
    assertThat(ordinal.getNormalStatus()).isNotNull();
    assertThat(ordinal.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
    assertThat(ordinal.getNormalStatus().getCodeString()).isEqualTo("L");
    Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
    assertThat(value).containsEntry("test_statuses/test_statuses:0/ordinal|normal_status", "L");
}
Also used : DvOrdinal(com.nedap.archie.rm.datavalues.quantity.DvOrdinal) Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Aggregations

DvOrdinal (com.nedap.archie.rm.datavalues.quantity.DvOrdinal)5 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)3 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)3 StatusesTest (care.better.platform.web.template.StatusesTest)2 Composition (com.nedap.archie.rm.composition.Composition)2 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)2 Test (org.junit.Test)2 Test (org.junit.jupiter.api.Test)2 Map (java.util.Map)1 Set (java.util.Set)1 Context (org.ehrbase.serialisation.walker.Context)1 FlatHelper (org.ehrbase.serialisation.walker.FlatHelper)1 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)1