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