use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class DvStateValidatorTest method testValidate.
@Test
void testValidate() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_state.json");
var dvState = new DvState();
dvState.setValue(new DvCodedText("Test", new CodePhrase(new TerminologyId("local"), "at0010")));
var result = validator.validate(dvState, node);
assertTrue(result.isEmpty());
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class DvStateValidatorTest method testValidate_List.
@Test
void testValidate_List() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_state_codedtext.json");
var dvState = new DvState();
dvState.setValue(new DvCodedText("First", new CodePhrase(new TerminologyId("local"), "at0028")));
var result = validator.validate(dvState, node);
assertTrue(result.isEmpty());
dvState.setValue(new DvCodedText("Test", new CodePhrase(new TerminologyId("local"), "at0010")));
result = validator.validate(dvState, node);
assertEquals(1, result.size());
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project fhir-bridge by ehrbase.
the class KontaktActionConverter method mapContactWithInfected.
private void mapContactWithInfected(Boolean hadContact) {
DvCodedText dvCodedText = new DvCodedText("Done", new CodePhrase(new TerminologyId("local"), "at0016"));
kontaktAction.setCurrentState(dvCodedText);
if (hadContact) {
kontaktAction.setKontaktZuEinemBestaetigtenFallDefiningCode(AelterOderGleich65JahreAltDefiningCode.JA);
} else {
kontaktAction.setKontaktZuEinemBestaetigtenFallDefiningCode(AelterOderGleich65JahreAltDefiningCode.NEIN);
}
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenEhrbaseMultiOccurrenceDeV1.
@Test
public void testUnflattenEhrbaseMultiOccurrenceDeV1() {
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
EhrbaseMultiOccurrenceDeV1Composition dto = TestData.buildEhrbaseMultiOccurrenceDeV1();
Composition rmObject = (Composition) cut.unflatten(dto);
assertThat(rmObject).isNotNull();
assertThat(rmObject.getArchetypeDetails().getTemplateId().getValue()).isEqualTo("ehrbase_multi_occurrence.de.v1");
List<Object> observationList = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.body_temperature.v2]");
assertThat(observationList).size().isEqualTo(2);
Observation observation1 = (Observation) observationList.get(0);
List<Object> objects = observation1.itemsAtPath("/data[at0002]/events");
assertThat(objects).extracting(o -> ((PointEvent) o)).extracting(p -> (DvQuantity) p.itemAtPath("/data[at0001]/items[at0004]/value")).extracting(DvQuantity::getMagnitude).containsExactlyInAnyOrder(11d, 22d);
DvCodedText dvCodedText = (DvCodedText) observation1.itemAtPath("/protocol[at0020]/items[at0021]/value");
assertThat(dvCodedText.getValue()).isEqualTo("Forehead");
Observation observation2 = (Observation) observationList.get(1);
DvText dvText = (DvText) observation2.itemAtPath("/protocol[at0020]/items[at0021]/value");
assertFalse(dvText instanceof DvCodedText);
assertThat(dvText.getValue()).isEqualTo("location");
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class StdToCompositionWalker method postHandle.
@Override
protected void postHandle(Context<Map<FlatPathDto, String>> context) {
super.postHandle(context);
if (isRaw(context)) {
handleRaw(context);
}
WebTemplateNode currentNode = context.getNodeDeque().peek();
currentNode.getChildren().forEach(childNode -> {
// Check for Raw in optional (skipped Nodes)
if (context.getFlatHelper().skip(childNode, currentNode)) {
context.getNodeDeque().push(childNode);
context.getRmObjectDeque().push(new RMObject() {
});
String path = context.getFlatHelper().buildNamePath(context, true);
Map<FlatPathDto, String> subValues = context.getObjectDeque().peek().entrySet().stream().filter(e -> e.getKey().startsWith(path + "/_" + childNode.getId())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
context.getObjectDeque().push(subValues);
if (isRaw(context)) {
handleRaw(context);
}
context.getNodeDeque().poll();
context.getRmObjectDeque().poll();
context.getObjectDeque().poll();
}
});
List<? extends UnmarshalPostprocessor<? extends RMObject>> postprocessor = findUnmarshalPostprocessors(context.getRmObjectDeque().peek().getClass());
String namePath = buildNamePathWithElementHandling(context);
if (Entry.class.isAssignableFrom(context.getRmObjectDeque().peek().getClass())) {
if (((Entry) context.getRmObjectDeque().peek()).getSubject() instanceof PartyRelated) {
Optional.ofNullable(context.getNodeDeque().peek()).flatMap(c -> c.findChildById("subject")).flatMap(c -> c.findChildById("relationship")).stream().map(WebTemplateNode::getInputs).flatMap(List::stream).filter(i -> "code".equals(i.getSuffix())).map(WebTemplateInput::getList).map(l -> l.size() == 1 ? l.get(0) : null).filter(Objects::nonNull).findAny().ifPresent(v -> ((PartyRelated) ((Entry) context.getRmObjectDeque().peek()).getSubject()).setRelationship(new DvCodedText(v.getLabel(), new CodePhrase(new TerminologyId("openehr"), v.getValue()))));
}
}
postprocessor.forEach(p -> ((UnmarshalPostprocessor) p).process(namePath, context.getRmObjectDeque().peek(), context.getObjectDeque().peek(), consumedPaths, context));
}
Aggregations