Search in sources :

Example 71 with CodePhrase

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

the class InvokeVisitorTest method shouldVisitInvokeExpressionExpandOperation.

@Test
public void shouldVisitInvokeExpressionExpandOperation() {
    // postman request for expansion is: GET https://r4.ontoserver.csiro.au/fhir/ValueSet/$expand?url=http://hl7.org/fhir/ValueSet/surface
    FhirTerminologyServerR4AdaptorImpl mock = mock(FhirTerminologyServerR4AdaptorImpl.class);
    when(mock.expandWithParameters(any(), any())).thenReturn(List.of(new DvCodedText("Occlusal", new CodePhrase("O")), new DvCodedText("Mesial", new CodePhrase("M")), new DvCodedText("Distoclusal", new CodePhrase("DO")), new DvCodedText("Lingual", new CodePhrase("L")), new DvCodedText("Incisal", new CodePhrase("I")), new DvCodedText("Ventral", new CodePhrase("V")), new DvCodedText("Mesioclusodistal", new CodePhrase("MOD")), new DvCodedText("Mesioclusal", new CodePhrase("MO")), new DvCodedText("Distal", new CodePhrase("D")), new DvCodedText("Distoincisal", new CodePhrase("DI")), new DvCodedText("Buccal", new CodePhrase("B"))));
    WhereVisitor cut = new WhereVisitor(mock);
    String aql = "SELECT o/data[at0002]/events[at0003] AS systolic " + "FROM EHR [ehr_id/value='1234'] " + "CONTAINS COMPOSITION c " + "CONTAINS OBSERVATION o [openEHR-EHR-OBSERVATION.blood_pressure.v1] " + "WHERE c/archetype_details/template_id/value matches {'Flormidal', TERMINOLOGY('expand','http://hl7.org/fhir/4.0','url=http://hl7.org/fhir/ValueSet/surface'), 'Kloralhidrat'}";
    ParseTree tree = QueryHelper.setupParseTree(aql);
    cut.visit(tree);
    List<Object> whereExpression = cut.getWhereExpression();
    assertThat(whereExpression).size().isEqualTo(29);
    I_VariableDefinition where1 = (I_VariableDefinition) whereExpression.get(0);
    I_VariableDefinition expected1 = I_VariableDefinitionHelper.build("archetype_details/template_id/value", null, "c", false, false, false);
    I_VariableDefinitionHelper.checkEqualWithoutFuncParameters(where1, expected1);
    assertThat(whereExpression.get(1)).isEqualTo(" IN ");
    assertThat(whereExpression.get(2)).isEqualTo("(");
    assertThat(whereExpression.get(3)).isEqualTo("'Flormidal'");
    assertThat(whereExpression.get(4)).isEqualTo(",");
    assertThat(whereExpression.get(5)).isEqualTo("'O'");
    assertThat(whereExpression.get(6)).isEqualTo(",");
    assertThat(whereExpression.get(7)).isEqualTo("'M'");
    assertThat(whereExpression.get(8)).isEqualTo(",");
    assertThat(whereExpression.get(9)).isEqualTo("'DO'");
    assertThat(whereExpression.get(10)).isEqualTo(",");
    assertThat(whereExpression.get(11)).isEqualTo("'L'");
    assertThat(whereExpression.get(12)).isEqualTo(",");
    assertThat(whereExpression.get(13)).isEqualTo("'I'");
    assertThat(whereExpression.get(14)).isEqualTo(",");
    assertThat(whereExpression.get(15)).isEqualTo("'V'");
    assertThat(whereExpression.get(16)).isEqualTo(",");
    assertThat(whereExpression.get(17)).isEqualTo("'MOD'");
    assertThat(whereExpression.get(18)).isEqualTo(",");
    assertThat(whereExpression.get(19)).isEqualTo("'MO'");
    assertThat(whereExpression.get(20)).isEqualTo(",");
    assertThat(whereExpression.get(21)).isEqualTo("'D'");
    assertThat(whereExpression.get(22)).isEqualTo(",");
    assertThat(whereExpression.get(23)).isEqualTo("'DI'");
    assertThat(whereExpression.get(24)).isEqualTo(",");
    assertThat(whereExpression.get(25)).isEqualTo("'B'");
    assertThat(whereExpression.get(26)).isEqualTo(",");
    assertThat(whereExpression.get(27)).isEqualTo("'Kloralhidrat'");
    assertThat(whereExpression.get(28)).isEqualTo(")");
}
Also used : FhirTerminologyServerR4AdaptorImpl(org.ehrbase.service.FhirTerminologyServerR4AdaptorImpl) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) I_VariableDefinition(org.ehrbase.aql.definition.I_VariableDefinition) ParseTree(org.antlr.v4.runtime.tree.ParseTree) Test(org.junit.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