Search in sources :

Example 6 with ObjectRef

use of com.nedap.archie.rm.support.identification.ObjectRef in project openEHR_SDK by ehrbase.

the class CareEntryPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, CareEntry rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    Map<FlatPathDto, String> guidelineValues = FlatHelper.filter(values, term + "/_guideline_id", false);
    if (!guidelineValues.isEmpty()) {
        ObjectRef<GenericId> guidelineId = new ObjectRef<>();
        guidelineId.setId(new GenericId());
        setValue(term + "/_guideline_id", "type", guidelineValues, guidelineId::setType, String.class, consumedPaths);
        setValue(term + "/_guideline_id", "namespace", guidelineValues, guidelineId::setNamespace, String.class, consumedPaths);
        setValue(term + "/_guideline_id", "id", guidelineValues, s -> guidelineId.getId().setValue(s), String.class, consumedPaths);
        setValue(term + "/_guideline_id", "id_scheme", guidelineValues, s -> guidelineId.getId().setScheme(s), String.class, consumedPaths);
        rmObject.setGuidelineId(guidelineId);
    }
}
Also used : GenericId(com.nedap.archie.rm.support.identification.GenericId) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef)

Example 7 with ObjectRef

use of com.nedap.archie.rm.support.identification.ObjectRef in project openEHR_SDK by ehrbase.

the class ParticipationConfig method buildChildValues.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Object> buildChildValues(String currentTerm, Participation rmObject, Context<Map<String, Object>> context) {
    Map<String, Object> result = new HashMap<>();
    addValue(result, currentTerm, "id", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(ObjectRef::getId).map(ObjectId::getValue).orElse(null));
    addValue(result, currentTerm, "id_namespace", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(ObjectRef::getNamespace).orElse(null));
    addValue(result, currentTerm, "id_scheme", Optional.of(rmObject).map(Participation::getPerformer).map(PartyProxy::getExternalRef).map(PartyRef::getId).filter(cls -> GenericId.class.isAssignableFrom(cls.getClass())).map(GenericId.class::cast).map(GenericId::getScheme).orElse(null));
    addValue(result, currentTerm, "name", Optional.of(rmObject).map(Participation::getPerformer).filter(p -> PartyIdentified.class.isAssignableFrom(p.getClass())).map(PartyIdentified.class::cast).map(PartyIdentified::getName).orElse(null));
    addValue(result, currentTerm, "mode", Optional.of(rmObject).map(Participation::getMode).map(DvText::getValue).orElse(null));
    addValue(result, currentTerm, "function", Optional.of(rmObject).map(Participation::getFunction).map(DvText::getValue).orElse(null));
    List<DvIdentifier> dvIdentifiers = Optional.of(rmObject).map(Participation::getPerformer).filter(p -> PartyIdentified.class.isAssignableFrom(p.getClass())).map(PartyIdentified.class::cast).map(PartyIdentified::getIdentifiers).orElse(Collections.emptyList());
    IntStream.range(0, dvIdentifiers.size()).forEach(i -> {
        DvIdentifier identifier = dvIdentifiers.get(i);
        addValue(result, currentTerm, "identifiers_id:" + i, identifier.getId());
        addValue(result, currentTerm, "identifiers_issuer:" + i, identifier.getIssuer());
        addValue(result, currentTerm, "identifiers_assigner:" + i, identifier.getAssigner());
        addValue(result, currentTerm, "identifiers_type:" + i, identifier.getType());
    });
    return result;
}
Also used : DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) IntStream(java.util.stream.IntStream) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Context(org.ehrbase.serialisation.walker.Context) java.util(java.util) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) DvText(com.nedap.archie.rm.datavalues.DvText) GenericId(com.nedap.archie.rm.support.identification.GenericId) Participation(com.nedap.archie.rm.generic.Participation) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) Participation(com.nedap.archie.rm.generic.Participation) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) DvText(com.nedap.archie.rm.datavalues.DvText) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef)

Example 8 with ObjectRef

use of com.nedap.archie.rm.support.identification.ObjectRef in project openEHR_SDK by ehrbase.

the class PartyIdentifiedStdConfig method buildChildValues.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Object> buildChildValues(String currentTerm, PartyIdentified rmObject, Context<Map<String, Object>> context) {
    Map<String, Object> result = new HashMap<>();
    addValue(result, currentTerm, "name", rmObject.getName());
    addValue(result, currentTerm, "id", Optional.of(rmObject).map(PartyProxy::getExternalRef).map(ObjectRef::getId).map(ObjectId::getValue).orElse(null));
    addValue(result, currentTerm, "id_namespace", Optional.of(rmObject).map(PartyProxy::getExternalRef).map(ObjectRef::getNamespace).orElse(null));
    GenericId genericId = Optional.of(rmObject).map(PartyProxy::getExternalRef).map(ObjectRef::getId).filter(i -> i.getClass().equals(GenericId.class)).map(i -> (GenericId) i).orElse(null);
    if (genericId != null) {
        addValue(result, currentTerm, "id_scheme", genericId.getScheme());
    }
    if (rmObject.getIdentifiers() != null) {
        IntStream.range(0, rmObject.getIdentifiers().size()).forEach(i -> result.putAll(DV_IDENTIFIER_CONFIG.buildChildValues(currentTerm + "/_identifier:" + i, rmObject.getIdentifiers().get(i), context)));
    }
    return result;
}
Also used : PartyProxy(com.nedap.archie.rm.generic.PartyProxy) IntStream(java.util.stream.IntStream) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Context(org.ehrbase.serialisation.walker.Context) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) GenericId(com.nedap.archie.rm.support.identification.GenericId) Map(java.util.Map) Optional(java.util.Optional) HashMap(java.util.HashMap) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) GenericId(com.nedap.archie.rm.support.identification.GenericId) HashMap(java.util.HashMap) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) PartyProxy(com.nedap.archie.rm.generic.PartyProxy) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef)

Example 9 with ObjectRef

use of com.nedap.archie.rm.support.identification.ObjectRef in project openEHR_SDK by ehrbase.

the class WorkflowIdTestOverwrite method workflowIdInCtx.

@Override
@Test
public void workflowIdInCtx() throws Exception {
    String template = this.getFileContent("/res/Demo Vitals.opt");
    Map<String, Object> flatComposition = ImmutableMap.<String, Object>builder().put("ctx/language", "sl").put("ctx/territory", "SI").put("ctx/composer_name", "Composer").put("ctx/id_scheme", "ispek").put("ctx/id_namespace", "ispek").put("ctx/end_time", "2016-01-01T12:30:30Z").put("ctx/work_flow_id|id", "wf_id").put("ctx/work_flow_id|namespace", "wf_ns").put("ctx/work_flow_id|id_scheme", "wf_scheme").put("ctx/work_flow_id|type", "wf_type").put("vitals/vitals/haemoglobin_a1c/any_event/test_status|terminology", "local").put("vitals/vitals/haemoglobin_a1c/any_event/test_status|code", "at0037").build();
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    Entry contentItem = (Entry) ((Section) composition.getContent().get(0)).getItems().get(0);
    ObjectRef<? extends ObjectId> workflowId = contentItem.getWorkflowId();
    assertThat(workflowId).isNotNull();
    assertThat(workflowId.getId()).hasSameClassAs(new GenericId()).extracting(ObjectId::getValue, i -> ((GenericId) i).getScheme()).containsExactly("wf_id", "wf_scheme");
    assertThat(workflowId.getNamespace()).isEqualTo("wf_ns");
    assertThat(workflowId.getType()).isEqualTo("wf_type");
    Map<String, Object> map = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
    assertThat(map).containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|id", "wf_id").containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|id_scheme", "wf_scheme").containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|type", "wf_type").containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|namespace", "wf_ns");
}
Also used : Entry(com.nedap.archie.rm.composition.Entry) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Composition(com.nedap.archie.rm.composition.Composition) ImmutableMap(com.google.common.collect.ImmutableMap) ZonedDateTime(java.time.ZonedDateTime) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) Section(com.nedap.archie.rm.composition.Section) ZoneId(java.time.ZoneId) WorkflowIdTest(care.better.platform.web.template.WorkflowIdTest) OffsetDateTime(java.time.OffsetDateTime) Helper.getFlatJson(org.ehrbase.conformance_test.extern.Helper.getFlatJson) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) GenericId(com.nedap.archie.rm.support.identification.GenericId) DateTimeFormatter(java.time.format.DateTimeFormatter) Map(java.util.Map) FlatFormat(org.ehrbase.serialisation.flatencoding.FlatFormat) Composition(com.nedap.archie.rm.composition.Composition) Entry(com.nedap.archie.rm.composition.Entry) GenericId(com.nedap.archie.rm.support.identification.GenericId) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) Section(com.nedap.archie.rm.composition.Section) Test(org.junit.Test) WorkflowIdTest(care.better.platform.web.template.WorkflowIdTest)

Example 10 with ObjectRef

use of com.nedap.archie.rm.support.identification.ObjectRef in project openEHR_SDK by ehrbase.

the class WorkflowIdTestOverwrite method workflowIdDirect.

@Override
@Test
public void workflowIdDirect() throws Exception {
    String template = this.getFileContent("/res/Demo Vitals.opt");
    OffsetDateTime dateTime = ZonedDateTime.of(2015, 1, 1, 10, 31, 16, 0, ZoneId.systemDefault()).toOffsetDateTime();
    Map<String, Object> flatComposition = ImmutableMap.<String, Object>builder().put("ctx/language", "sl").put("ctx/territory", "SI").put("ctx/composer_name", "Composer").put("ctx/id_scheme", "ispek").put("ctx/id_namespace", "ispek").put("ctx/end_time", "2016-01-01T12:30:30Z").put("vitals/vitals/haemoglobin_a1c/history_origin", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(dateTime)).put("vitals/vitals/haemoglobin_a1c/any_event/test_status|terminology", "local").put("vitals/vitals/haemoglobin_a1c/any_event/test_status|code", "at0037").put("vitals/vitals/haemoglobin_a1c/_work_flow_id|id", "1").put("vitals/vitals/haemoglobin_a1c/_work_flow_id|id_scheme", "x").put("vitals/vitals/haemoglobin_a1c/_work_flow_id|namespace", "y").put("vitals/vitals/haemoglobin_a1c/_work_flow_id|type", "wf").build();
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    Entry contentItem = (Entry) ((Section) composition.getContent().get(0)).getItems().get(0);
    ObjectRef<? extends ObjectId> workflowId = contentItem.getWorkflowId();
    assertThat(workflowId).isNotNull();
    assertThat(workflowId.getId()).hasSameClassAs(new GenericId()).extracting(ObjectId::getValue, i -> ((GenericId) i).getScheme()).containsExactly("1", "x");
    assertThat(workflowId.getNamespace()).isEqualTo("y");
    assertThat(workflowId.getType()).isEqualTo("wf");
    Map<String, Object> map = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
    assertThat(map).containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|id", "1").containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|id_scheme", "x").containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|type", "wf").containsEntry("vitals/vitals/haemoglobin_a1c:0/_work_flow_id|namespace", "y");
}
Also used : Entry(com.nedap.archie.rm.composition.Entry) ObjectRef(com.nedap.archie.rm.support.identification.ObjectRef) Composition(com.nedap.archie.rm.composition.Composition) ImmutableMap(com.google.common.collect.ImmutableMap) ZonedDateTime(java.time.ZonedDateTime) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) ObjectId(com.nedap.archie.rm.support.identification.ObjectId) Section(com.nedap.archie.rm.composition.Section) ZoneId(java.time.ZoneId) WorkflowIdTest(care.better.platform.web.template.WorkflowIdTest) OffsetDateTime(java.time.OffsetDateTime) Helper.getFlatJson(org.ehrbase.conformance_test.extern.Helper.getFlatJson) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) GenericId(com.nedap.archie.rm.support.identification.GenericId) DateTimeFormatter(java.time.format.DateTimeFormatter) Map(java.util.Map) FlatFormat(org.ehrbase.serialisation.flatencoding.FlatFormat) Composition(com.nedap.archie.rm.composition.Composition) Entry(com.nedap.archie.rm.composition.Entry) GenericId(com.nedap.archie.rm.support.identification.GenericId) OffsetDateTime(java.time.OffsetDateTime) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) Section(com.nedap.archie.rm.composition.Section) Test(org.junit.Test) WorkflowIdTest(care.better.platform.web.template.WorkflowIdTest)

Aggregations

ObjectRef (com.nedap.archie.rm.support.identification.ObjectRef)18 GenericId (com.nedap.archie.rm.support.identification.GenericId)7 ObjectId (com.nedap.archie.rm.support.identification.ObjectId)7 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)5 OffsetDateTime (java.time.OffsetDateTime)5 Map (java.util.Map)5 UUID (java.util.UUID)5 Test (org.junit.Test)5 Composition (com.nedap.archie.rm.composition.Composition)4 Entry (com.nedap.archie.rm.composition.Entry)4 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)4 ArrayList (java.util.ArrayList)4 WorkflowIdTest (care.better.platform.web.template.WorkflowIdTest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Section (com.nedap.archie.rm.composition.Section)3 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)3 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)3 ZoneId (java.time.ZoneId)3 ZonedDateTime (java.time.ZonedDateTime)3