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(")");
}
Aggregations