Search in sources :

Example 6 with DvIdentifier

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;
}
Also used : HashMap(java.util.HashMap) DvMultimedia(com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia) DvParsable(com.nedap.archie.rm.datavalues.encapsulated.DvParsable) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier)

Example 7 with DvIdentifier

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");
}
Also used : OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Language(org.ehrbase.client.classgenerator.shareddefinition.Language) Composition(com.nedap.archie.rm.composition.Composition) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) GenericId(com.nedap.archie.rm.support.identification.GenericId) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) ZoneOffset(java.time.ZoneOffset) FlatJsonUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.FlatJsonUnmarshaller) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) Tuple(org.assertj.core.groups.Tuple) TemplateDocument(org.openehr.schemas.v1.TemplateDocument) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) Iterator(java.util.Iterator) OperationalTemplateTestData(org.ehrbase.test_data.operationaltemplate.OperationalTemplateTestData) CompositionTestDataSimSDTJson(org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson) Test(org.junit.Test) IOException(java.io.IOException) JacksonUtil(org.ehrbase.serialisation.jsonencoding.JacksonUtil) StandardCharsets(java.nio.charset.StandardCharsets) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) IOUtils(org.apache.commons.io.IOUtils) Observation(com.nedap.archie.rm.composition.Observation) XmlException(org.apache.xmlbeans.XmlException) OffsetDateTime(java.time.OffsetDateTime) OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Composition(com.nedap.archie.rm.composition.Composition) GenericId(com.nedap.archie.rm.support.identification.GenericId) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) Observation(com.nedap.archie.rm.composition.Observation) FlatJsonUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.FlatJsonUnmarshaller) Tuple(org.assertj.core.groups.Tuple) Test(org.junit.Test)

Example 8 with DvIdentifier

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");
}
Also used : OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Language(org.ehrbase.client.classgenerator.shareddefinition.Language) Composition(com.nedap.archie.rm.composition.Composition) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HashMap(java.util.HashMap) GenericId(com.nedap.archie.rm.support.identification.GenericId) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) ZoneOffset(java.time.ZoneOffset) FlatJsonUnmarshaller(org.ehrbase.serialisation.flatencoding.std.umarshal.FlatJsonUnmarshaller) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) Tuple(org.assertj.core.groups.Tuple) TemplateDocument(org.openehr.schemas.v1.TemplateDocument) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) Iterator(java.util.Iterator) OperationalTemplateTestData(org.ehrbase.test_data.operationaltemplate.OperationalTemplateTestData) CompositionTestDataSimSDTJson(org.ehrbase.test_data.composition.CompositionTestDataSimSDTJson) Test(org.junit.Test) IOException(java.io.IOException) JacksonUtil(org.ehrbase.serialisation.jsonencoding.JacksonUtil) StandardCharsets(java.nio.charset.StandardCharsets) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) IOUtils(org.apache.commons.io.IOUtils) Observation(com.nedap.archie.rm.composition.Observation) XmlException(org.apache.xmlbeans.XmlException) OffsetDateTime(java.time.OffsetDateTime) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) HashMap(java.util.HashMap) JsonNode(com.fasterxml.jackson.databind.JsonNode) HashMap(java.util.HashMap) Map(java.util.Map) Tuple(org.assertj.core.groups.Tuple) Test(org.junit.Test)

Example 9 with DvIdentifier

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());
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) Element(com.nedap.archie.rm.datastructures.Element) JsonElement(com.google.gson.JsonElement) ItemTree(com.nedap.archie.rm.datastructures.ItemTree) FeederAuditAttributes(org.ehrbase.serialisation.attributes.FeederAuditAttributes) Map(java.util.Map) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) Test(org.junit.Test)

Example 10 with DvIdentifier

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;
}
Also used : BefundObservation(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservation) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ProbeCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProbeCluster) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) FallidentifikationCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.FallidentifikationCluster) KulturCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.KulturCluster) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) ProVirusCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusCluster) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartySelf(com.nedap.archie.rm.generic.PartySelf)

Aggregations

DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)21 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)10 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Composition (com.nedap.archie.rm.composition.Composition)4 Observation (com.nedap.archie.rm.composition.Observation)3 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)3 PartySelf (com.nedap.archie.rm.generic.PartySelf)3 GenericId (com.nedap.archie.rm.support.identification.GenericId)3 IOException (java.io.IOException)3 StandardCharsets (java.nio.charset.StandardCharsets)3 OffsetDateTime (java.time.OffsetDateTime)3 ZoneOffset (java.time.ZoneOffset)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 IOUtils (org.apache.commons.io.IOUtils)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Tuple (org.assertj.core.groups.Tuple)3 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)3