use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class DefaultRestEhrFieldsEndpointIT method testUpdateEhrStatus.
@Test
public void testUpdateEhrStatus() throws IOException {
ehr = openEhrClient.ehrEndpoint().createEhr();
EhrStatus ehrStatus = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
ehrStatus.setQueryable(false);
ehrStatus.setModifiable(false);
HierObjectId subjectId = new HierObjectId("6ee110de-08f8-4fac-8372-820650f150a9");
ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
String value = IOUtils.toString(ItemStruktureTestDataCanonicalJson.SIMPLE_EHR_OTHER_Details.getStream(), UTF_8);
ehrStatus.setOtherDetails(new CanonicalJson().unmarshal(value, ItemTree.class));
ehrStatus.getOtherDetails().setArchetypeNodeId("other-details-test");
ehrStatus.getOtherDetails().setName(new DvText("test"));
openEhrClient.ehrEndpoint().updateEhrStatus(ehr, ehrStatus);
EhrStatus actual = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
assertThat(actual.getSubject().getExternalRef().getId()).isEqualTo(subjectId);
assertThat(actual.isModifiable()).isEqualTo(ehrStatus.isModifiable());
assertThat(actual.isQueryable()).isEqualTo(ehrStatus.isQueryable());
assertThat(actual.getOtherDetails()).isNotNull();
assertThat(actual.getOtherDetails().getItems()).size().isEqualTo(ehrStatus.getOtherDetails().getItems().size());
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class InstructionDetailsRMUnmarshaller method handle.
/**
* {@inheritDoc}
*/
@Override
public void handle(String currentTerm, InstructionDetails rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
if (currentValues.keySet().stream().anyMatch(k -> List.of("instruction_uid", "wt_path", "instruction_index").contains(k.getLast().getAttributeName()))) {
throw new SdkException(String.format("Calculation of Path from instruction_uid, wt_path or instruction_index is not supported. Provide |path at %s ", currentTerm));
}
if (currentValues.keySet().stream().anyMatch(k -> List.of("activity_index").contains(k.getLast().getAttributeName()))) {
throw new SdkException(String.format("Calculation of activity_id from activity_index is not supported. Provide |activity_id at %s ", currentTerm));
}
setValue(currentTerm, "activity_id", currentValues, rmObject::setActivityId, String.class, consumedPaths);
rmObject.setInstructionId(new LocatableRef());
rmObject.getInstructionId().setNamespace("local");
rmObject.getInstructionId().setType("INSTRUCTION");
setValue(currentTerm, "composition_uid", currentValues, s -> Optional.ofNullable(s).ifPresent(p -> rmObject.getInstructionId().setId(new HierObjectId(p))), String.class, consumedPaths);
setValue(currentTerm, "path", currentValues, s -> rmObject.getInstructionId().setPath(s), String.class, consumedPaths);
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method marshallEhr.
@Test
public void marshallEhr() {
List<ObjectRef<? extends ObjectId>> compositions = new ArrayList<>();
compositions.add(new ObjectRef<>(new HierObjectId("COMPOSITION"), "local", "b5c4aaed-2adc-4c56-9005-e21ff3cca62a::local.ehrbase.org::2"));
List<ObjectRef<? extends ObjectId>> contributions = new ArrayList<>();
contributions.add(new ObjectRef<>(new HierObjectId("COMPOSITION"), "local", "b5c4aaed-2adc-4c56-9005-e21ff3cca62a::local.ehrbase.org::2"));
List<ObjectRef<? extends ObjectId>> folders = new ArrayList<>();
folders.add(new ObjectRef<>(new HierObjectId("COMPOSITION"), "local", "b5c4aaed-2adc-4c56-9005-e21ff3cca62a::local.ehrbase.org::2"));
Ehr expected = new Ehr();
expected.setCompositions(compositions);
expected.setContributions(contributions);
expected.setFolders(folders);
CanonicalJson cut = new CanonicalJson();
String json = cut.marshal(expected);
Ehr actual = cut.unmarshal(json, Ehr.class);
Assert.assertEquals(actual, expected);
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method marshallContribution.
@Test
public void marshallContribution() {
List<ObjectRef<? extends ObjectId>> versions = new ArrayList<>();
versions.add(new ObjectRef<>(new HierObjectId("COMPOSITION"), "local", "b5c4aaed-2adc-4c56-9005-e21ff3cca62a::local.ehrbase.org::2"));
Contribution expected = new Contribution();
expected.setUid(new HierObjectId("bbf60d27-9200-4995-a950-279f889d1050"));
expected.setVersions(versions);
CanonicalJson cut = new CanonicalJson();
String json = cut.marshal(expected);
Contribution actual = cut.unmarshal(json, Contribution.class);
Assert.assertEquals(actual, expected);
}
use of com.nedap.archie.rm.support.identification.HierObjectId in project openEHR_SDK by ehrbase.
the class Unflattener method unflatten.
public RMObject unflatten(Object dto) {
Template template = dto.getClass().getAnnotation(Template.class);
WebTemplate introspect = templateProvider.buildIntrospect(template.value()).orElseThrow(() -> new SdkException(String.format("Can not find Template: %s", template.value())));
Composition generate = WebTemplateSkeletonBuilder.build(introspect, false);
new DtoToCompositionWalker().walk(generate, findEntity(dto), introspect, defaultValuesProvider.provide(dto), template.value());
Optional<VersionUid> versionUid = extractVersionUid(dto);
if (versionUid.isPresent()) {
generate.setUid(new HierObjectId(versionUid.get().toString()));
}
return generate;
}
Aggregations