use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class DvCodedTextTest method testValidate_FhirCodeSystem_WrongCode.
@Test
void testValidate_FhirCodeSystem_WrongCode() throws Exception {
var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/observation-status"), "casual");
// Mockito initialization
Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status")).thenReturn(true);
Mockito.doThrow(new ConstraintViolationException(List.of(new ConstraintViolation("/test/dv_coded_text_fhir_code_system", "The specified code 'casual' is not known to belong to the specified code system 'http://hl7.org/fhir/observation-status'")))).when(fhirTerminologyValidationMock).validate("/test/dv_coded_text_fhir_code_system", "//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status", codePhrase);
var validator = new DvCodedTextValidator(fhirTerminologyValidationMock);
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.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidationLanguage.
@Test
public void testSimpleValidationLanguage() throws Exception {
CodePhrase codePhrase = new CodePhrase(new TerminologyId("ISO_3166-1"), "AU");
org.ehrbase.validation.terminology.validator.CodePhrase.validate(localizedTerminologies.getDefault(), codesetMapping, "territory", codePhrase);
org.ehrbase.validation.terminology.validator.CodePhrase.validate(localizedTerminologies.getDefault(), codesetMapping, null, codePhrase);
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidationSymbol.
@Test
public void testSimpleValidationSymbol() {
DvCodedText symbol = new DvCodedText("autogenerated (node doesn't have a constraint)", new CodePhrase(new TerminologyId("http://hl7.org/fhir/contact-point-use"), "BCDWXMEORP"));
org.ehrbase.validation.terminology.validator.DvOrdinal.validate(localizedTerminologies.locale("en"), codesetMapping, "symbol", symbol, "en");
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class TerminologyCheckTest method testSimpleValidationWrongValue.
@Test
public void testSimpleValidationWrongValue() throws Exception {
DvCodedText category = new DvCodedText("not quite sure what to put here", new CodePhrase(new TerminologyId("openehr"), "433"));
try {
org.ehrbase.validation.terminology.validator.DvCodedText.validate(localizedTerminologies.locale("en"), codesetMapping, "category", category, "en");
fail("should have detected a wrong value");
} catch (Exception e) {
}
}
use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.
the class CodePhraseAdapter method write.
@Override
public void write(JsonWriter writer, CodePhrase codePhrase) throws IOException {
if (codePhrase == null) {
writer.nullValue();
return;
}
if (adapterType == I_DvTypeAdapter.AdapterType.PG_JSONB) {
writer.beginObject();
writer.name("codeString").value(codePhrase.getCodeString());
writer.name(I_DvTypeAdapter.TAG_CLASS_RAW_JSON).value(new SnakeCase(CodePhrase.class.getSimpleName()).camelToUpperSnake());
writer.name("terminologyId");
writer.beginObject();
writer.name("value").value(codePhrase.getTerminologyId().getValue());
writer.name(I_DvTypeAdapter.TAG_CLASS_RAW_JSON).value(new SnakeCase(TerminologyId.class.getSimpleName()).camelToUpperSnake());
writer.endObject();
writer.endObject();
} else if (adapterType == I_DvTypeAdapter.AdapterType.RAW_JSON) {
writer.beginObject();
writer.name(I_DvTypeAdapter.TAG_CLASS_RAW_JSON).value(new ObjectSnakeCase(codePhrase).camelToUpperSnake());
writer.name("code_string").value(codePhrase.getCodeString());
writer.name("terminology_id").value(gson.toJson(codePhrase.getTerminologyId()));
writer.endObject();
}
}
Aggregations