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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations