Search in sources :

Example 11 with HierObjectId

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());
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) ItemStruktureTestDataCanonicalJson(org.ehrbase.test_data.item_structure.ItemStruktureTestDataCanonicalJson) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) ItemTree(com.nedap.archie.rm.datastructures.ItemTree) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 12 with HierObjectId

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);
}
Also used : InstructionDetails(com.nedap.archie.rm.composition.InstructionDetails) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) Context(org.ehrbase.serialisation.walker.Context) List(java.util.List) SdkException(org.ehrbase.util.exception.SdkException) Map(java.util.Map) LocatableRef(com.nedap.archie.rm.support.identification.LocatableRef) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Optional(java.util.Optional) Set(java.util.Set) SdkException(org.ehrbase.util.exception.SdkException) LocatableRef(com.nedap.archie.rm.support.identification.LocatableRef) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Example 13 with HierObjectId

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);
}
Also used : ObjectId(com.nedap.archie.rm.support.identification.ObjectId) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) ArrayList(java.util.ArrayList) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) Ehr(com.nedap.archie.rm.ehr.Ehr) Test(org.junit.Test)

Example 14 with HierObjectId

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);
}
Also used : ObjectId(com.nedap.archie.rm.support.identification.ObjectId) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) ArrayList(java.util.ArrayList) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) Contribution(com.nedap.archie.rm.changecontrol.Contribution) Test(org.junit.Test)

Example 15 with HierObjectId

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;
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) VersionUid(org.ehrbase.client.openehrclient.VersionUid) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) SdkException(org.ehrbase.util.exception.SdkException) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) Template(org.ehrbase.client.annotations.Template) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate)

Aggregations

HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)22 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)12 DvText (com.nedap.archie.rm.datavalues.DvText)8 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)7 PartySelf (com.nedap.archie.rm.generic.PartySelf)7 UUID (java.util.UUID)7 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)6 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)5 ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)5 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)4 Composition (com.nedap.archie.rm.composition.Composition)3 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)3 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)3 SdkException (org.ehrbase.util.exception.SdkException)3 Test (org.junit.Test)3 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)2 VersionedComposition (com.nedap.archie.rm.ehr.VersionedComposition)2 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)2 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)2 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)2