Search in sources :

Example 11 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvOrderedPostprocessor method process.

/**
 * {@inheritDoc} Adds the encoding information
 */
@Override
public void process(String term, DvOrdered rmObject, Map<String, Object> values, Context<Map<String, Object>> context) {
    if (rmObject.getNormalRange() != null) {
        handleRange(term + "/_normal_range", values, rmObject.getNormalRange(), context);
    }
    IntStream.range(0, rmObject.getOtherReferenceRanges().size()).forEach(i -> {
        ReferenceRange referenceRange = (ReferenceRange) rmObject.getOtherReferenceRanges().get(i);
        if (referenceRange.getMeaning() != null) {
            callMarshal(term, "_other_reference_ranges:" + i + "/meaning", referenceRange.getMeaning(), values, context, context.getNodeDeque().peek().findChildById("meaning").orElse(null));
            callPostprocess(term, "_other_reference_ranges:" + i + "/meaning", referenceRange.getMeaning(), values, context, context.getNodeDeque().peek().findChildById("meaning").orElse(null));
        }
        if (referenceRange.getRange() != null) {
            handleRange(term + "/_other_reference_ranges:" + i, values, referenceRange.getRange(), context);
        }
    });
    addValue(values, term, "normal_status", Optional.ofNullable(rmObject.getNormalStatus()).map(CodePhrase::getCodeString).orElse(null));
}
Also used : CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) ReferenceRange(com.nedap.archie.rm.datavalues.quantity.ReferenceRange)

Example 12 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class TermMappingTestOverwritten method testTermMappingFromJson.

@Override
@Test
public void testTermMappingFromJson() throws Exception {
    String template = this.getFileContent("/res/Demo Vitals.xml");
    String rawJson = this.getFileContent("/res/TmComposition.json");
    Composition unmarshal = new CanonicalJson().unmarshal(rawJson.replace("\"@class\"", "\"_type\""), Composition.class);
    String structuredJson = getFlatJson(template, FlatFormat.STRUCTURED).marshal(unmarshal);
    Composition actualComposition = getFlatJson(template, FlatFormat.STRUCTURED).unmarshal(structuredJson);
    List<TermMapping> termMappings = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/data/items[at0.63]/value").get(0)).getMappings();
    assertThat(termMappings).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "21794005", "SNOMED-CT", null), new Tuple('=', "W.11.7", "RTX", null));
    List<TermMapping> termMappings2 = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/state/items[at0041]/value").get(0)).getMappings();
    assertThat(termMappings2).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "99.1", "IAXA", new DvCodedText("Purpose 1", new CodePhrase(new TerminologyId("Purposes"), "p.0.63.1"))));
}
Also used : TermMapping(com.nedap.archie.rm.datavalues.TermMapping) Tuple(org.assertj.core.groups.Tuple) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DvText(com.nedap.archie.rm.datavalues.DvText) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.jupiter.api.Test) TermMappingTest(care.better.platform.web.template.TermMappingTest) List(java.util.List) Helper.getFlatJson(org.ehrbase.conformance_test.extern.Helper.getFlatJson) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) TermMapping(com.nedap.archie.rm.datavalues.TermMapping) FlatFormat(org.ehrbase.serialisation.flatencoding.FlatFormat) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Tuple(org.assertj.core.groups.Tuple) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.jupiter.api.Test) TermMappingTest(care.better.platform.web.template.TermMappingTest)

Example 13 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class CodeSetAccessTest method testCodeSetAccess.

@Test
public void testCodeSetAccess() throws Exception {
    TerminologyInterface simpleTerminologyInterface = new SimpleTerminologyInterface("en");
    CodeSetAccess codeSetAccess = simpleTerminologyInterface.codeSetForId(OpenEHRCodeSetIdentifiers.INTEGRITY_CHECK_ALGORITHMS);
    assertEquals("openehr_integrity_check_algorithms", codeSetAccess.id());
    assertEquals(2, codeSetAccess.allCodes().size());
    assertTrue(codeSetAccess.hasCode(new CodePhrase(new TerminologyId("openehr_integrity_check_algorithms"), "SHA-1")));
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) TerminologyInterface(org.ehrbase.terminology.openehr.TerminologyInterface) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) CodeSetAccess(org.ehrbase.terminology.openehr.CodeSetAccess) Test(org.junit.Test)

Example 14 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvCodedTextTest method testValidate_FhirCodeSystem.

@Test
void testValidate_FhirCodeSystem() throws Exception {
    var codePhrase = new CodePhrase(new TerminologyId("http://hl7.org/fhir/observation-status"), "final");
    // Mockito initialization
    Mockito.when(fhirTerminologyValidationMock.supports("//fhir.hl7.org/CodeSystem?url=http://hl7.org/fhir/observation-status")).thenReturn(true);
    Mockito.doNothing().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("Final", codePhrase), node);
    assertTrue(result.isEmpty());
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) Test(org.junit.jupiter.api.Test)

Example 15 with CodePhrase

use of com.nedap.archie.rm.datatypes.CodePhrase in project openEHR_SDK by ehrbase.

the class DvCodedTextTest method testValidate_UnsupportedExternalTerminology.

@Test
void testValidate_UnsupportedExternalTerminology() throws Exception {
    Mockito.when(fhirTerminologyValidationMock.supports("ICD10")).thenReturn(false);
    var node = parseNode("/webtemplate_nodes/dv_codedtext_unsupported.json");
    var dvCodedText = new DvCodedText("Iodine-deficiency related thyroid disorders and allied conditions", new CodePhrase(new TerminologyId("ICD10"), "E01"));
    var result = new DvCodedTextValidator(fhirTerminologyValidationMock).validate(dvCodedText, node);
    assertTrue(result.isEmpty());
}
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

CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)71 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)60 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)56 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)16 Composition (com.nedap.archie.rm.composition.Composition)12 DvText (com.nedap.archie.rm.datavalues.DvText)12 ArrayList (java.util.ArrayList)8 AbstractRMObjectValidatorTest (org.ehrbase.validation.webtemplate.AbstractRMObjectValidatorTest)7 RMObject (com.nedap.archie.rm.RMObject)5 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)5 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)5 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)4 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)4 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)4 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)4 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)4 Entry (com.nedap.archie.rm.composition.Entry)3