use of org.ehrbase.webtemplate.model.WebTemplateInputValue in project openEHR_SDK by ehrbase.
the class OPTParserTest method parseAllTypes.
@Test
public void parseAllTypes() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.ALL_TYPES.getStream()).getTemplate();
OPTParser cut = new OPTParser(template);
WebTemplate actual = cut.parse();
actual = new Filter().filter(actual);
assertThat(actual).isNotNull();
ObjectMapper objectMapper = new ObjectMapper();
WebTemplate expected = objectMapper.readValue(IOUtils.toString(WebTemplateTestData.ALL_TYPES.getStream(), StandardCharsets.UTF_8), WebTemplate.class);
List<WebTemplateNode> dvOrdinalList = actual.getTree().findMatching(n -> n.getRmType().equals("DV_ORDINAL"));
assertThat(dvOrdinalList).size().isEqualTo(1);
assertThat(dvOrdinalList.get(0).getInputs()).flatExtracting(WebTemplateInput::getList).extracting(WebTemplateInputValue::getLabel, WebTemplateInputValue::getValue, WebTemplateInputValue::getOrdinal).containsExactlyInAnyOrder(new Tuple("ord1", "at0014", 0), new Tuple("ord1", "at0015", 1), new Tuple("ord3", "at0016", 2));
List<WebTemplateNode> dvQuantityList = actual.getTree().findMatching(n -> n.getRmType().equals("DV_QUANTITY"));
assertThat(dvQuantityList).flatExtracting(WebTemplateNode::getInputs).flatExtracting(WebTemplateInput::getList).extracting(WebTemplateInputValue::getLabel, WebTemplateInputValue::getValue).containsExactlyInAnyOrder(new Tuple("mg", "mg"), new Tuple("kg", "kg"), new Tuple("mm[H20]", "mm[H20]"), new Tuple("mm[Hg]", "mm[Hg]"));
List<WebTemplateNode> dvCodedTextList = actual.getTree().findMatching(n -> n.getRmType().equals("DV_CODED_TEXT"));
assertThat(dvCodedTextList).flatExtracting(WebTemplateNode::getInputs).extracting(WebTemplateInput::getTerminology, i -> i.getList().stream().map(v -> v.getValue() + ":" + v.getLabel()).collect(Collectors.joining(";"))).containsExactlyInAnyOrder(new Tuple("openehr", "433:event"), new Tuple("local", "at0006:value1;at0007:value2;at0008:value3"), new Tuple("local", ""), new Tuple("local", ""), new Tuple("SNOMED-CT", ""), new Tuple("SNOMED-CT", ""), new Tuple("local", "at0003:Planned;at0004:Active;at0005:Completed"), new Tuple("openehr", "526:planned;245:active;532:completed"), new Tuple(null, ""), new Tuple(null, ""), new Tuple(null, ""), new Tuple(null, ""));
List<String> errors = compareWebTemplate(actual, expected);
checkErrors(errors, new String[] { "LocalizedNames not equal [en=active] != [] in inputValue.code:245 id=current_state aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]/ism_transition/current_state", "LocalizedNames not equal [en=completed] != [] in inputValue.code:532 id=current_state aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]/ism_transition/current_state", "LocalizedNames not equal [en=planned] != [] in inputValue.code:526 id=current_state aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]/ism_transition/current_state", "LocalizedDescriptions not equal {en=*} != {} in inputValue.code:at0005 id=careflow_step aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]/ism_transition/careflow_step", "LocalizedDescriptions not equal {en=*} != {} in inputValue.code:at0004 id=careflow_step aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]/ism_transition/careflow_step", "LocalizedDescriptions not equal {en=*} != {} in inputValue.code:at0003 id=careflow_step aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-ACTION.test_all_types.v1]/ism_transition/careflow_step", "InContext not equal true != null in id=action_archetype_id aql=/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-INSTRUCTION.test_all_types.v1]/activities[at0001]/action_archetype_id" });
}
use of org.ehrbase.webtemplate.model.WebTemplateInputValue in project openEHR_SDK by ehrbase.
the class DvOrdinalConfig method buildChildValues.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> buildChildValues(String currentTerm, DvOrdinal rmObject, Context<Map<String, Object>> context) {
Map<String, Object> result = new HashMap<>();
String codeString = Optional.of(rmObject).map(DvOrdinal::getSymbol).map(DvCodedText::getDefiningCode).map(CodePhrase::getCodeString).orElse(null);
addValue(result, currentTerm, "code", codeString);
WebTemplateInputValue value = context.getNodeDeque().peek().getInputs().get(0).getList().stream().filter(o -> o.getValue().equals(codeString)).findAny().orElseThrow(() -> new SdkException(String.format("Unknown Ordinal with code %s", codeString)));
addValue(result, currentTerm, "ordinal", value.getOrdinal());
addValue(result, currentTerm, "value", value.getLabel());
return result;
}
Aggregations