use of com.nedap.archie.rm.support.identification.ObjectId 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;
}
use of com.nedap.archie.rm.support.identification.ObjectId 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");
}
use of com.nedap.archie.rm.support.identification.ObjectId 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");
}
use of com.nedap.archie.rm.support.identification.ObjectId in project openEHR_SDK by ehrbase.
the class WorkflowIdTestOverwrite method workflowIdInCtxAndDirect.
@Override
@Test
public void workflowIdInCtxAndDirect() 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").put("vitals/vitals/haemoglobin_a1c:1/any_event/test_status|terminology", "local").put("vitals/vitals/haemoglobin_a1c:1/any_event/test_status|code", "at0037").put("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|id", "1").put("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|id_scheme", "x").put("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|namespace", "y").put("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|type", "wf").build();
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
Entry contentItem1 = (Entry) ((Section) composition.getContent().get(0)).getItems().get(0);
ObjectRef<? extends ObjectId> workflowId1 = contentItem1.getWorkflowId();
assertThat(workflowId1).isNotNull();
assertThat(workflowId1.getId()).hasSameClassAs(new GenericId()).extracting(ObjectId::getValue, i -> ((GenericId) i).getScheme()).containsExactly("wf_id", "wf_scheme");
assertThat(workflowId1.getNamespace()).isEqualTo("wf_ns");
assertThat(workflowId1.getType()).isEqualTo("wf_type");
Entry contentItem2 = (Entry) ((Section) composition.getContent().get(0)).getItems().get(1);
ObjectRef<? extends ObjectId> workflowId2 = contentItem2.getWorkflowId();
assertThat(workflowId2).isNotNull();
assertThat(workflowId2.getId()).hasSameClassAs(new GenericId()).extracting(ObjectId::getValue, i -> ((GenericId) i).getScheme()).containsExactly("1", "x");
assertThat(workflowId2.getNamespace()).isEqualTo("y");
assertThat(workflowId2.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", "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").containsEntry("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|id", "1").containsEntry("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|id_scheme", "x").containsEntry("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|type", "wf").containsEntry("vitals/vitals/haemoglobin_a1c:1/_work_flow_id|namespace", "y");
}
use of com.nedap.archie.rm.support.identification.ObjectId 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);
}
Aggregations