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