Search in sources :

Example 51 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId 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());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) ConstraintViolation(org.ehrbase.validation.ConstraintViolation) ConstraintViolationException(org.ehrbase.validation.ConstraintViolationException) Test(org.junit.jupiter.api.Test)

Example 52 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId 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));
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FhirTerminologyValidation(org.ehrbase.validation.terminology.FhirTerminologyValidation) Test(org.junit.jupiter.api.Test)

Example 53 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId 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());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) ConstraintViolation(org.ehrbase.validation.ConstraintViolation) ConstraintViolationException(org.ehrbase.validation.ConstraintViolationException) Test(org.junit.jupiter.api.Test)

Example 54 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.

the class DvCodedTextTest method testFailOnError_Enabled.

@Test
void testFailOnError_Enabled() 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));
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) FhirTerminologyValidation(org.ehrbase.validation.terminology.FhirTerminologyValidation) Test(org.junit.jupiter.api.Test)

Example 55 with TerminologyId

use of com.nedap.archie.rm.support.identification.TerminologyId in project openEHR_SDK by ehrbase.

the class DvCodedTextTest method testValidate.

@Test
void testValidate() throws Exception {
    var validator = new DvCodedTextValidator();
    var node = parseNode("/webtemplate_nodes/dv_codedtext.json");
    var dvCodedText = new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0028"));
    var result = validator.validate(dvCodedText, node);
    assertTrue(result.isEmpty());
    dvCodedText = new DvCodedText("Test", new CodePhrase(new TerminologyId("local"), "at0028"));
    result = validator.validate(dvCodedText, node);
    assertEquals(1, result.size());
    dvCodedText = new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0029"));
    result = validator.validate(dvCodedText, node);
    assertEquals(1, result.size());
}
Also used : 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)

Aggregations

TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)62 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)60 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)50 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)13 DvText (com.nedap.archie.rm.datavalues.DvText)10 Composition (com.nedap.archie.rm.composition.Composition)8 ArrayList (java.util.ArrayList)7 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)6 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)5 RMObject (com.nedap.archie.rm.RMObject)4 EventContext (com.nedap.archie.rm.composition.EventContext)4 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)4 List (java.util.List)4 Locatable (com.nedap.archie.rm.archetyped.Locatable)3 Entry (com.nedap.archie.rm.composition.Entry)3 DvURI (com.nedap.archie.rm.datavalues.DvURI)3 DvOrdinal (com.nedap.archie.rm.datavalues.quantity.DvOrdinal)3 PartyRelated (com.nedap.archie.rm.generic.PartyRelated)3