Search in sources :

Example 1 with FeederAuditDetails

use of com.nedap.archie.rm.archetyped.FeederAuditDetails in project fhir-bridge by ehrbase.

the class AbstractConverter method buildFeederAudit.

protected FeederAudit buildFeederAudit(@NonNull S resource) {
    FeederAudit result = new FeederAudit();
    String systemId = resource.getMeta().hasSource() ? resource.getMeta().getSource() : DEFAULT_SYSTEM_ID;
    result.setOriginatingSystemAudit(new FeederAuditDetails(systemId, null, null, null, null, null, null));
    List<DvIdentifier> identifiers = new ArrayList<>();
    if (resource.hasId()) {
        DvIdentifier identifier = new DvIdentifier();
        identifier.setId(resource.getId());
        identifier.setType("fhir_logical_id");
        identifiers.add(identifier);
    }
    identifiers.addAll(subjectIdentifiers(resource));
    result.setOriginatingSystemItemIds(identifiers);
    return result;
}
Also used : FeederAudit(com.nedap.archie.rm.archetyped.FeederAudit) FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) ArrayList(java.util.ArrayList) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier)

Example 2 with FeederAuditDetails

use of com.nedap.archie.rm.archetyped.FeederAuditDetails in project openEHR_SDK by ehrbase.

the class FeederAuditRMUnmarshaller method handle.

@Override
public void handle(String currentTerm, FeederAudit rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
    Map<FlatPathDto, String> originalContentValues = FlatHelper.filter(currentValues, currentTerm + "/original_content", false);
    if (!originalContentValues.isEmpty()) {
        rmObject.setOriginalContent(new DvParsable());
        DV_PARSABLE_RM_UNMARSHALLER.handle(currentTerm + "/original_content", (DvParsable) rmObject.getOriginalContent(), originalContentValues, context, consumedPaths);
    }
    Map<FlatPathDto, String> originalContentMultimediaValues = FlatHelper.filter(currentValues, currentTerm + "/original_content_multimedia", false);
    if (!originalContentMultimediaValues.isEmpty()) {
        rmObject.setOriginalContent(new DvMultimedia());
        DV_MULTIMEDIA_RM_UNMARSHALLER.handle(currentTerm + "/original_content_multimedia", (DvMultimedia) rmObject.getOriginalContent(), originalContentMultimediaValues, context, consumedPaths);
    }
    Map<FlatPathDto, String> originatingSystemAuditValues = FlatHelper.filter(currentValues, currentTerm + "/originating_system_audit", false);
    if (!originatingSystemAuditValues.isEmpty()) {
        rmObject.setOriginatingSystemAudit(new FeederAuditDetails());
        FEEDER_AUDIT_DETAILS_RM_UNMARSHALLER.handle(currentTerm + "/originating_system_audit", rmObject.getOriginatingSystemAudit(), currentValues, context, consumedPaths);
    }
    Map<Integer, Map<String, String>> feederSystemIds = extractMultiValued(currentTerm, "feeder_system_item_id", currentValues);
    rmObject.getFeederSystemItemIds().addAll(feederSystemIds.values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
    consumeAllMatching(currentTerm + PATH_DIVIDER + "feeder_system_item_id", currentValues, consumedPaths, false);
    Map<Integer, Map<String, String>> originatingSystemIds = extractMultiValued(currentTerm, "originating_system_item_id", currentValues);
    rmObject.getOriginatingSystemItemIds().addAll(originatingSystemIds.values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
    consumeAllMatching(currentTerm + PATH_DIVIDER + "originating_system_item_id", currentValues, consumedPaths, false);
}
Also used : FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) DvMultimedia(com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia) DvParsable(com.nedap.archie.rm.datavalues.encapsulated.DvParsable) Map(java.util.Map)

Example 3 with FeederAuditDetails

use of com.nedap.archie.rm.archetyped.FeederAuditDetails in project openEHR_SDK by ehrbase.

the class FeederAuditDetailsAttributesTest method toMap.

@Test
public void toMap() throws Exception {
    String value = IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), UTF_8);
    CanonicalJson cut = new CanonicalJson();
    Composition composition = cut.unmarshal(value, Composition.class);
    assertNotNull(composition);
    assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
    // with real data
    FeederAuditDetailsAttributes attributes = new FeederAuditDetailsAttributes(composition.getFeederAudit().getFeederSystemAudit());
    Map<String, Object> map = attributes.toMap();
    assertNotNull(map);
    assertNotNull(map.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]"));
    // valid fabricated data without brackets
    FeederAuditDetails details = new FeederAuditDetails();
    ItemSingle single = new ItemSingle("test", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    map = attributes.toMap();
    assertNotNull(map.get("other_details[test]"));
    // valid fabricated data with brackets
    details = new FeederAuditDetails();
    single = new ItemSingle("[test]", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    map = attributes.toMap();
    assertNotNull(map.get("other_details[test]"));
    // invalid data with one [
    details = new FeederAuditDetails();
    single = new ItemSingle("[test", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    assertThrows(IllegalArgumentException.class, attributes::toMap);
    // invalid data with one ]
    details = new FeederAuditDetails();
    single = new ItemSingle("test]", new DvCodedText("text", new CodePhrase("string")), new Element("node", new DvText("name"), null));
    details.setOtherDetails(single);
    details.setSystemId("system");
    attributes = new FeederAuditDetailsAttributes(details);
    assertThrows(IllegalArgumentException.class, attributes::toMap);
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Element(com.nedap.archie.rm.datastructures.Element) DvText(com.nedap.archie.rm.datavalues.DvText) FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) ItemSingle(com.nedap.archie.rm.datastructures.ItemSingle) Test(org.junit.Test)

Example 4 with FeederAuditDetails

use of com.nedap.archie.rm.archetyped.FeederAuditDetails in project openEHR_SDK by ehrbase.

the class TestData method buildEpisodeOfCareComposition.

public static EpisodeOfCareComposition buildEpisodeOfCareComposition() {
    EpisodeOfCareComposition episode = new EpisodeOfCareComposition();
    episode.setComposer(new PartyIdentified(null, "Test", null));
    episode.setCategoryDefiningCode(Category.EVENT);
    episode.setLanguage(Language.DE);
    episode.setTerritory(Territory.DE);
    episode.setEpisodeofcare(new ArrayList<>());
    episode.setStartTimeValue(OffsetDateTime.now());
    episode.setSettingDefiningCode(Setting.NURSING_HOME_CARE);
    FeederAudit audit = new FeederAudit();
    audit.setFeederSystemAudit(new FeederAuditDetails());
    audit.getFeederSystemAudit().setSystemId("System 1");
    audit.setOriginatingSystemAudit(new FeederAuditDetails());
    audit.getOriginatingSystemAudit().setSystemId("System 2");
    episode.setFeederAudit(audit);
    EpisodeofcareAdminEntry episodeofcareAdminEntry = new EpisodeofcareAdminEntry();
    episodeofcareAdminEntry.setUpperValue(OffsetDateTime.now());
    episodeofcareAdminEntry.setLowerValue(OffsetDateTime.now());
    episodeofcareAdminEntry.setLanguage(Language.DE);
    episodeofcareAdminEntry.setSubject(new PartySelf());
    episodeofcareAdminEntry.setIdentifier(new ArrayList<>());
    EpisodeofcareIdentifierElement identifierElement = new EpisodeofcareIdentifierElement();
    DvIdentifier value = new DvIdentifier();
    value.setId("123");
    identifierElement.setValue(value);
    episodeofcareAdminEntry.getIdentifier().add(identifierElement);
    EpisodeofcareIdentifierElement identifierElement2 = new EpisodeofcareIdentifierElement();
    DvIdentifier value2 = new DvIdentifier();
    value2.setId("456");
    identifierElement2.setValue(value2);
    episodeofcareAdminEntry.getIdentifier().add(identifierElement2);
    episodeofcareAdminEntry.setTeam(new ArrayList<>());
    EpisodeofcareTeamElement teamElement1 = new EpisodeofcareTeamElement();
    teamElement1.setValue(URI.create("https://github.com/ehrbase"));
    episodeofcareAdminEntry.getTeam().add(teamElement1);
    episode.getEpisodeofcare().add(episodeofcareAdminEntry);
    return episode;
}
Also used : FeederAudit(com.nedap.archie.rm.archetyped.FeederAudit) EpisodeofcareIdentifierElement(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareIdentifierElement) EpisodeofcareTeamElement(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareTeamElement) FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) EpisodeofcareAdminEntry(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier)

Example 5 with FeederAuditDetails

use of com.nedap.archie.rm.archetyped.FeederAuditDetails in project openEHR_SDK by ehrbase.

the class FeederAuditDetailsAttributes method toMap.

/**
 * encode the attributes lower snake case to comply with UML conventions and make is queryable
 * @return
 */
public Map<String, Object> toMap() {
    Map<String, Object> valuemap = PathMap.getInstance();
    if (feederAuditDetails == null)
        return null;
    valuemap.put(I_DvTypeAdapter.AT_TYPE, new SnakeCase(FeederAuditDetails.class.getSimpleName()).camelToUpperSnake());
    if (feederAuditDetails.getLocation() != null) {
        valuemap.put("location", new RmObjectEncoding(feederAuditDetails.getLocation()).toMap());
    }
    if (feederAuditDetails.getProvider() != null) {
        valuemap.put("provider", new RmObjectEncoding(feederAuditDetails.getProvider()).toMap());
    }
    if (feederAuditDetails.getSubject() != null) {
        valuemap.put("subject", new RmObjectEncoding(feederAuditDetails.getSubject()).toMap());
    }
    if (feederAuditDetails.getSystemId() != null) {
        valuemap.put("system_id", feederAuditDetails.getSystemId());
    }
    if (feederAuditDetails.getTime() != null) {
        valuemap.put("time", new RmObjectEncoding(feederAuditDetails.getTime()).toMap());
    }
    if (feederAuditDetails.getVersionId() != null) {
        valuemap.put("version_id", feederAuditDetails.getVersionId());
    }
    if (feederAuditDetails.getOtherDetails() != null) {
        String dbEncoded = new CompositionSerializer().dbEncode(feederAuditDetails.getOtherDetails());
        Map<String, Object> asMap = new LightRawJsonEncoder(dbEncoded).encodeOtherDetailsAsMap();
        String nodeId = asMap.get("/archetype_node_id").toString();
        // make sure node id is wrapped in [ and ] and throw errors if invalid input
        if (!nodeId.startsWith("[")) {
            if (nodeId.endsWith("]"))
                throw new IllegalArgumentException("Invalid archetype node id");
            nodeId = "[" + nodeId + "]";
        } else if (!nodeId.endsWith("]")) {
            throw new IllegalArgumentException("Invalid archetype node id");
        }
        valuemap.put("other_details" + nodeId, asMap);
    }
    return valuemap;
}
Also used : FeederAuditDetails(com.nedap.archie.rm.archetyped.FeederAuditDetails) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) RmObjectEncoding(org.ehrbase.serialisation.dbencoding.RmObjectEncoding) CompositionSerializer(org.ehrbase.serialisation.dbencoding.CompositionSerializer)

Aggregations

FeederAuditDetails (com.nedap.archie.rm.archetyped.FeederAuditDetails)5 FeederAudit (com.nedap.archie.rm.archetyped.FeederAudit)2 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)2 Composition (com.nedap.archie.rm.composition.Composition)1 Element (com.nedap.archie.rm.datastructures.Element)1 ItemSingle (com.nedap.archie.rm.datastructures.ItemSingle)1 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)1 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)1 DvText (com.nedap.archie.rm.datavalues.DvText)1 DvMultimedia (com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia)1 DvParsable (com.nedap.archie.rm.datavalues.encapsulated.DvParsable)1 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)1 PartySelf (com.nedap.archie.rm.generic.PartySelf)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 EpisodeOfCareComposition (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition)1 EpisodeofcareAdminEntry (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareAdminEntry)1 EpisodeofcareIdentifierElement (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareIdentifierElement)1 EpisodeofcareTeamElement (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.definition.EpisodeofcareTeamElement)1 CompositionSerializer (org.ehrbase.serialisation.dbencoding.CompositionSerializer)1