use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidationWrongCode.
@Test
public void testSimpleValidationWrongCode() throws Exception {
DvCodedText category = new DvCodedText("event", new CodePhrase(new TerminologyId("openehr"), "999"));
try {
org.ehrbase.validation.terminology.validator.DvCodedText.validate(localizedTerminologies.locale("en"), codesetMapping, "category", category, "en");
fail("should have detected a bad code");
} catch (Exception e) {
}
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidation.
@Test
public void testSimpleValidation() throws Exception {
DvCodedText category = new DvCodedText("event", new CodePhrase(new TerminologyId("openehr"), "433"));
org.ehrbase.validation.terminology.validator.DvCodedText.validate(localizedTerminologies.locale("en"), codesetMapping, "category", category, "en");
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class DvCodedTextTest method testValidate_FhirValueSet_WrongTerminologyId.
@Test
void testValidate_FhirValueSet_WrongTerminologyId() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://snomed.info/sct"), "ANON");
// Mockito initialization
Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/ValueSet/$expand?url=http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2")).thenReturn(true);
Mockito.doThrow(new ConstraintViolationException(List.of(new ConstraintViolation("/test/dv_coded_text_fhir_value_set", "The terminology http://snomed.info/sct must be http://terminology.hl7.org/CodeSystem/v3-EntityNameUseR2")))).when(fhirTerminologyValidationMock).validate("/test/dv_coded_text_fhir_value_set", "//fhir.hl7.org/ValueSet/$expand?url=http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2", codePhrase);
var validator = new DvCodedTextValidator(fhirTerminologyValidationMock);
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 DvCodedTextTest method testFailOnError_Disabled.
@Test
void testFailOnError_Disabled() throws Exception {
var validationSupport = new FhirTerminologyValidation("https://wrong.terminology.server/fhir");
var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/observation-status"), "B");
var dvCodedText = new DvCodedText("Buccal", codePhrase);
var validator = new DvCodedTextValidator(validationSupport);
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_valueset.json");
assertThrows(ExternalTerminologyValidationException.class, () -> validator.validate(dvCodedText, node));
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class DvCodedTextTest 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");
// Mockito initialization
Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/ValueSet/$expand?url=http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2")).thenReturn(true);
Mockito.doThrow(new ConstraintViolationException(List.of(new ConstraintViolation("/test/dv_coded_text_fhir_value_set", "The value UKN does not match any option from value set http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2")))).when(fhirTerminologyValidationMock).validate("/test/dv_coded_text_fhir_value_set", "//fhir.hl7.org/ValueSet/$expand?url=http://terminology.hl7.org/ValueSet/v3-EntityNameUseR2", codePhrase);
var validator = new DvCodedTextValidator(fhirTerminologyValidationMock);
var node = parseNode("/webtemplate_nodes/dv_codedtext_fhir_valueset.json");
var result = validator.validate(new DvCodedText("Anonymous", codePhrase), node);
assertEquals(1, result.size());
}
Aggregations