use of com.nedap.archie.rm.datavalues.DvIdentifier in project openEHR_SDK by ehrbase.
the class FeederAuditConfig method buildChildValues.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> buildChildValues(String currentTerm, FeederAudit rmObject, Context<Map<String, Object>> context) {
Map<String, Object> result = new HashMap<>();
if (rmObject.getOriginalContent() instanceof DvParsable) {
result.putAll(DV_PARSABLE_CONFIG.buildChildValues(currentTerm + "/original_content", (DvParsable) rmObject.getOriginalContent(), context));
} else if (rmObject.getOriginalContent() instanceof DvMultimedia) {
result.putAll(DV_MULTIMEDIA_CONFIG.buildChildValues(currentTerm + "/original_content_multimedia", (DvMultimedia) rmObject.getOriginalContent(), context));
}
IntStream.range(0, rmObject.getFeederSystemItemIds().size()).forEach(i -> {
DvIdentifier identifier = rmObject.getFeederSystemItemIds().get(i);
result.putAll(DV_IDENTIFIER_CONFIG.buildChildValues(currentTerm + "/feeder_system_item_id:" + i, identifier, context));
});
IntStream.range(0, rmObject.getOriginatingSystemItemIds().size()).forEach(i -> {
DvIdentifier identifier = rmObject.getOriginatingSystemItemIds().get(i);
result.putAll(DV_IDENTIFIER_CONFIG.buildChildValues(currentTerm + "/originating_system_item_id:" + i, identifier, context));
});
if (rmObject.getOriginatingSystemAudit() != null) {
result.putAll(FEEDER_AUDI_DETAILS_STD_CONFIG.buildChildValues(currentTerm + "/originating_system_audit", rmObject.getOriginatingSystemAudit(), context));
}
return result;
}
use of com.nedap.archie.rm.datavalues.DvIdentifier in project openEHR_SDK by ehrbase.
the class DefaultValuesTest method unmarshal.
@Test
public void unmarshal() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.CORONA_ANAMNESE.getStream()).getTemplate();
WebTemplate webTemplate = new OPTParser(template).parse();
FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
String flat = IOUtils.toString(CompositionTestDataSimSDTJson.CORONA_WITH_CONTEXT.getStream(), StandardCharsets.UTF_8);
Composition actual = cut.unmarshal(flat, webTemplate);
assertThat(actual).isNotNull();
assertThat(actual.getCategory()).isNotNull();
assertThat(actual.getCategory().getValue()).isEqualTo("event");
assertThat(actual.getLanguage()).isNotNull();
assertThat(actual.getLanguage().getCodeString()).isEqualTo(Language.DE.getCode());
assertThat(actual.getComposer()).isNotNull();
assertThat(actual.getComposer()).getClass().isAssignableFrom(PartyIdentified.class);
assertThat(((PartyIdentified) actual.getComposer()).getName()).isEqualTo("Silvia Blake");
assertThat(actual.getComposer().getExternalRef().getNamespace()).isEqualTo("HOSPITAL-NS");
assertThat(((GenericId) actual.getComposer().getExternalRef().getId()).getScheme()).isEqualTo("HOSPITAL-NS");
assertThat(((GenericId) actual.getComposer().getExternalRef().getId()).getValue()).isEqualTo("123");
assertThat(actual.getContext().getHealthCareFacility().getName()).isEqualTo("Hospital");
assertThat(actual.getContext().getStartTime()).isNotNull();
assertThat(actual.getContext().getStartTime().getValue()).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(actual.getContext().getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer())).flatExtracting(p -> p.getIdentifiers()).extracting(DvIdentifier::getAssigner, DvIdentifier::getId, DvIdentifier::getIssuer, DvIdentifier::getType).containsExactlyInAnyOrder(new Tuple("assigner1", "id1", "issuer1", "PERSON"), new Tuple("assigner2", "id2", "issuer2", "PERSON"), new Tuple("assigner3", "id3", "issuer3", "PERSON"), new Tuple("assigner4", "id4", "issuer4", "PERSON"));
Observation observation = actual.getContent().stream().filter(c -> Observation.class.isAssignableFrom(c.getClass())).map(Observation.class::cast).findAny().orElse(null);
assertThat(observation).isNotNull();
assertThat(observation.getData()).isNotNull();
assertThat(observation.getData().getOrigin().getValue()).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(observation.getData().getEvents().get(0).getTime().getValue()).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(observation.getOtherParticipations()).extracting(p -> p.getFunction().getValue(), p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getPerformer().getExternalRef().getNamespace()).containsExactlyInAnyOrder(new Tuple("requester", "Dr. Marcus Johnson", "HOSPITAL-NS"), new Tuple("performer", "Lara Markham", "HOSPITAL-NS"));
assertThat(observation.getOtherParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer())).flatExtracting(p -> p.getIdentifiers()).extracting(DvIdentifier::getAssigner, DvIdentifier::getId, DvIdentifier::getIssuer, DvIdentifier::getType).containsExactlyInAnyOrder(new Tuple("assigner1", "id1", "issuer1", "PERSON"), new Tuple("assigner2", "id2", "issuer2", "PERSON"), new Tuple("assigner3", "id3", "issuer3", "PERSON"), new Tuple("assigner4", "id4", "issuer4", "PERSON"));
assertThat(observation.getWorkflowId()).isNotNull();
assertThat(observation.getWorkflowId().getNamespace()).isEqualTo("HOSPITAL-NS");
assertThat(observation.getWorkflowId().getId().getValue()).isEqualTo("567");
assertThat(observation.getWorkflowId().getType()).isEqualTo("ORGANISATION");
}
use of com.nedap.archie.rm.datavalues.DvIdentifier in project openEHR_SDK by ehrbase.
the class DefaultValuesTest method test.
@Test
public void test() throws IOException {
Map<String, String> currentValues = new HashMap<>();
for (Iterator<Map.Entry<String, JsonNode>> it = JacksonUtil.getObjectMapper().readTree(IOUtils.toString(CompositionTestDataSimSDTJson.CORONA_WITH_CONTEXT.getStream(), StandardCharsets.UTF_8)).fields(); it.hasNext(); ) {
Map.Entry<String, JsonNode> e = it.next();
currentValues.put(e.getKey(), e.getValue().toString());
}
DefaultValues cut = new DefaultValues(currentValues);
assertThat(cut).isNotNull();
assertThat(cut.getDefaultValue(DefaultValuePath.LANGUAGE)).isEqualTo(Language.DE);
assertThat(cut.getDefaultValue(DefaultValuePath.COMPOSER_NAME)).isEqualTo("Silvia Blake");
assertThat(cut.getDefaultValue(DefaultValuePath.TIME)).isEqualTo(OffsetDateTime.of(2021, 4, 1, 12, 40, 31, 418954000, ZoneOffset.ofHours(2)));
assertThat(cut.getDefaultValue(DefaultValuePath.HEALTHCARE_FACILITY_NAME)).isEqualTo("Hospital");
assertThat(cut.getDefaultValue(DefaultValuePath.PARTICIPATION)).isNotNull();
assertThat(cut.getDefaultValue(DefaultValuePath.PARTICIPATION)).extracting(p -> p.getFunction().getValue(), p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getPerformer().getExternalRef().getNamespace()).containsExactlyInAnyOrder(new Tuple("requester", "Dr. Marcus Johnson", "HOSPITAL-NS"), new Tuple("performer", "Lara Markham", "HOSPITAL-NS"));
assertThat(cut.getDefaultValue(DefaultValuePath.PARTICIPATION)).extracting(p -> ((PartyIdentified) p.getPerformer())).flatExtracting(p -> p.getIdentifiers()).extracting(DvIdentifier::getAssigner, DvIdentifier::getId, DvIdentifier::getIssuer, DvIdentifier::getType).containsExactlyInAnyOrder(new Tuple("assigner1", "id1", "issuer1", "PERSON"), new Tuple("assigner2", "id2", "issuer2", "PERSON"), new Tuple("assigner3", "id3", "issuer3", "PERSON"), new Tuple("assigner4", "id4", "issuer4", "PERSON"));
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID)).isNotNull();
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID).getNamespace()).isEqualTo("HOSPITAL-NS");
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID).getId().getValue()).isEqualTo("567");
assertThat(cut.getDefaultValue(DefaultValuePath.WORKFLOW_ID).getType()).isEqualTo("ORGANISATION");
}
use of com.nedap.archie.rm.datavalues.DvIdentifier in project openEHR_SDK by ehrbase.
the class DBEncodeTest method compositionEncodingFeederAuditDetails.
@Test
public void compositionEncodingFeederAuditDetails() throws Exception {
String value = IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), UTF_8);
CanonicalJson cut = new CanonicalJson();
Composition composition = cut.unmarshal(value, Composition.class);
// check compo
assertNotNull(composition);
assertNotNull(composition.getFeederAudit().getFeederSystemAudit());
// other details
assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
assertEquals("family group", composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getName().getValue());
assertTrue(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails() instanceof ItemTree);
assertEquals(1, composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().size());
assertTrue(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().get(0) instanceof Element);
assertTrue(((Element) composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().get(0)).getValue() instanceof DvIdentifier);
// version id
assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getVersionId());
assertEquals("final", composition.getFeederAudit().getFeederSystemAudit().getVersionId());
// DB encode other details
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String dbEncoded = compositionSerializerRawJson.dbEncode(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
assertNotNull(dbEncoded);
// Convert encoded string into map to write to DB
Map<String, Object> asMap = new LightRawJsonEncoder(dbEncoded).encodeOtherDetailsAsMap();
assertNotNull(asMap);
assertEquals(4, asMap.size());
assertNotNull(asMap.get("/items[at0001]"));
// Attribute mapping and correct archetype node id path in naming
Map<String, Object> map = new FeederAuditAttributes(composition.getFeederAudit()).toMap();
assertNotNull(map);
assertNotNull(map.get("feeder_system_audit"));
Map<String, Object> feederMap = (Map) map.get("feeder_system_audit");
assertNotNull(feederMap);
assertNotNull(feederMap.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]"));
assertEquals(4, ((Map<String, Object>) feederMap.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]")).size());
}
use of com.nedap.archie.rm.datavalues.DvIdentifier in project openEHR_SDK by ehrbase.
the class TestData method buildTestVirologischerBefundComposition.
public static VirologischerBefundComposition buildTestVirologischerBefundComposition() {
// openEHR-EHR-COMPOSITION.report-result.v1
VirologischerBefundComposition virologischerBefundComposition = new VirologischerBefundComposition();
virologischerBefundComposition.setComposer(new PartyIdentified(null, "Test", null));
virologischerBefundComposition.setCategoryDefiningCode(Category.EVENT);
virologischerBefundComposition.setLanguage(Language.DE);
virologischerBefundComposition.setTerritory(Territory.DE);
virologischerBefundComposition.setStartTimeValue(OffsetDateTime.now());
virologischerBefundComposition.setSettingDefiningCode(Setting.SECONDARY_MEDICAL_CARE);
// context, other_context
FallidentifikationCluster fallidentifikationCluster = new FallidentifikationCluster();
fallidentifikationCluster.setFallKennungValue("9251377");
virologischerBefundComposition.setFallidentifikation(fallidentifikationCluster);
virologischerBefundComposition.setBerichtIdValue("15a69a62-1ea7-4111-98a5-28aeae854bcd");
virologischerBefundComposition.setStatusValue("Endbefund");
// openEHR-EHR-CLUSTER.specimen.v1
ProbeCluster probeCluster = new ProbeCluster();
probeCluster.setZeitpunktDerProbenentnahmeValue(new DvDateTime("2020-04-01T12:00:00Z").getValue());
probeCluster.setProbenartValue("Blut");
probeCluster.setZeitpunktDesProbeneingangsValue(new DvDateTime("2020-04-02T09:00:00Z").getValue());
probeCluster.setKommentarDesProbennehmersValue("Kommentar zur Probe");
probeCluster.setKommentarValue("Kommentar");
// openEHR-EHR-CLUSTER.laboratory_test_analyte.v1
ProVirusCluster proVirusCluster1 = new ProVirusCluster();
proVirusCluster1.setVirusValue("SARS-Cov-2");
proVirusCluster1.setAnalyseergebnisReihenfolgeMagnitude(Long.valueOf(32));
DvIdentifier identifier = new DvIdentifier();
identifier.setIssuer("Issuer");
identifier.setAssigner("Assigner");
identifier.setId("9a0e5173-07c8-443d-b414-24432b9d95ca");
identifier.setType("Prescription");
proVirusCluster1.setZugehorigeLaborprobe(identifier);
ProVirusCluster proVirusCluster2 = new ProVirusCluster();
proVirusCluster2.setVirusValue("SARS-Cov-2");
proVirusCluster2.setAnalyseergebnisReihenfolgeMagnitude(Long.valueOf(34));
proVirusCluster2.setZugehorigeLaborprobe(identifier);
// openEHR-EHR-CLUSTER.laboratory_test_panel.v0
KulturCluster kulturCluster = new KulturCluster();
kulturCluster.setProVirus(new ArrayList<>());
kulturCluster.getProVirus().add(proVirusCluster1);
kulturCluster.getProVirus().add(proVirusCluster2);
// openEHR-EHR-OBSERVATION.laboratory_test_result.v1
BefundObservation befundObservation = new BefundObservation();
// set clusters in observation
befundObservation.setKultur(new ArrayList<>());
befundObservation.getKultur().add(kulturCluster);
befundObservation.setProbe(new ArrayList<>());
befundObservation.getProbe().add(probeCluster);
befundObservation.setOriginValue(new DvDateTime("2020-04-02T12:00:00Z").getValue());
befundObservation.setTimeValue(new DvDateTime("2020-04-02T14:00:00Z").getValue());
befundObservation.setLabortestBezeichnungValue("Virologische Untersuchung");
befundObservation.setSubject(new PartySelf());
befundObservation.setLanguage(Language.DE);
virologischerBefundComposition.setBefund(befundObservation);
return virologischerBefundComposition;
}
Aggregations