use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.
the class WebTemplateSkeletonBuilder method extractDefault.
public static <T> Optional<T> extractDefault(WebTemplateNode node, Class<T> clazz) {
String rmclass = node.getRmType();
Object defaultValue = null;
switch(rmclass) {
case "DV_CODED_TEXT":
if (node.getMin() > 0) {
Optional<WebTemplateInput> code = node.getInputs().stream().filter(i -> i.getSuffix().equals("code")).filter(i -> i.getList().size() == 1).findAny();
if (code.isPresent()) {
defaultValue = new DvCodedText(code.get().getList().get(0).getLabel(), new CodePhrase(new TerminologyId(code.get().getTerminology()), code.get().getList().get(0).getValue()));
}
}
break;
default:
defaultValue = null;
}
return Optional.ofNullable((T) defaultValue);
}
use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.
the class DvCodedTextIT method testValidate_FhirCodeSystem_WrongTerminologyId.
@Test
void testValidate_FhirCodeSystem_WrongTerminologyId() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/name-use"), "usual");
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_codesystem.json");
var result = validator.validate(new DvCodedText("Usual", codePhrase), node);
assertEquals(1, result.size());
}
use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.
the class DvCodedTextIT method testValidate_FhirValueSet.
@Test
void testValidate_FhirValueSet() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://terminology.hl7.org/CodeSystem/v3-EntityNameUseR2"), "ANON");
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_valueset.json");
var result = validator.validate(new DvCodedText("Anonymous", codePhrase), node);
assertTrue(result.isEmpty());
}
use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.
the class DvCodedTextIT method testValidate_FhirCodeSystem_WrongCode.
@Test
void testValidate_FhirCodeSystem_WrongCode() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/observation-status"), "casual");
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_codesystem.json");
var result = validator.validate(new DvCodedText("Casual", codePhrase), node);
assertEquals(1, result.size());
}
use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.
the class DvCodedTextIT method testValidate_FhirCodeSystem.
@Test
void testValidate_FhirCodeSystem() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/observation-status"), "final");
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_codesystem.json");
var result = validator.validate(new DvCodedText("Final", codePhrase), node);
assertTrue(result.isEmpty());
}
Aggregations