use of com.nedap.archie.rm.support.identification.GenericId in project fhir-bridge by ehrbase.
the class EhrController method createEHR.
@PostMapping
public ResponseEntity<String> createEHR(@RequestParam String pPatientId) {
try {
// taken from EhrBase tests
PartySelf subject = new PartySelf();
PartyRef externalRef = new PartyRef();
externalRef.setType("PARTY_REF");
externalRef.setNamespace("patients");
GenericId genericId = new GenericId();
genericId.setScheme("id_scheme");
genericId.setValue(pPatientId);
externalRef.setId(genericId);
subject.setExternalRef(externalRef);
DvText dvText = new DvText("any EHR status");
EhrStatus ehrStatus = new EhrStatus("openEHR-EHR-ITEM_TREE.generic.v1", dvText, subject, true, true, null);
return ResponseEntity.ok(openEhrClient.ehrEndpoint().createEhr(ehrStatus).toString());
} catch (Exception ex) {
return new ResponseEntity<>("Error while creating an EHR for patient id " + pPatientId, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
use of com.nedap.archie.rm.support.identification.GenericId in project ehrbase by ehrbase.
the class PartyRefValue method attributes.
/**
* extract the attributes of party_ref
* @return
*/
PartyRefValue attributes() {
if (// PartySelf f.e.
partyProxy.getExternalRef() == null)
return this;
PartyRef partyRef = partyProxy.getExternalRef();
namespace = partyRef != null ? partyRef.getNamespace() : null;
ObjectId objectId = partyRef.getId();
value = objectId != null ? objectId.getValue() : null;
if (objectId != null && objectId instanceof GenericId)
scheme = ((GenericId) objectId).getScheme();
type = partyRef != null ? partyRef.getType() : null;
objectIdType = partyRef != null ? PartyRefIdType.valueOf(new PersistedObjectId().objectIdClassSnakeCase(partyRef)) : PartyRefIdType.undefined;
return this;
}
use of com.nedap.archie.rm.support.identification.GenericId in project openEHR_SDK by ehrbase.
the class EntryMarshalPostprocessor method process.
/**
* {@inheritDoc} Adds the encoding information
*/
@Override
public void process(String term, Entry rmObject, Map<String, Object> values, Context<Map<String, Object>> context) {
values.put(term + PATH_DIVIDER + "encoding|code", "UTF-8");
values.put(term + PATH_DIVIDER + "encoding|terminology", "IANA_character-sets");
if (rmObject.getProvider() != null) {
PartyIdentifiedStdConfig partyIdentifiedStdConfig = new PartyIdentifiedStdConfig();
values.putAll(partyIdentifiedStdConfig.buildChildValues(term + PATH_DIVIDER + "_provider", (PartyIdentified) rmObject.getProvider(), null));
}
if (rmObject.getOtherParticipations() != null) {
IntStream.range(0, rmObject.getOtherParticipations().size()).forEach(i -> {
callMarshal(term, "_other_participation:" + i, rmObject.getOtherParticipations().get(i), values, context, context.getNodeDeque().peek().findChildById("participation").orElse(null));
callPostprocess(term, "_other_participation:" + i, rmObject.getOtherParticipations().get(i), values, context, context.getNodeDeque().peek().findChildById("participation").orElse(null));
});
}
if (rmObject.getWorkflowId() != null) {
addValue(values, term + "/_work_flow_id", "id", Optional.of(rmObject.getWorkflowId()).map(ObjectRef::getId).map(ObjectId::getValue).orElse(null));
addValue(values, term + "/_work_flow_id", "id_scheme", Optional.of(rmObject.getWorkflowId()).map(ObjectRef::getId).filter(i -> GenericId.class.isAssignableFrom(i.getClass())).map(GenericId.class::cast).map(GenericId::getScheme).orElse(null));
addValue(values, term + "/_work_flow_id", "namespace", rmObject.getWorkflowId().getNamespace());
addValue(values, term + "/_work_flow_id", "type", rmObject.getWorkflowId().getType());
}
}
use of com.nedap.archie.rm.support.identification.GenericId 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.support.identification.GenericId in project openEHR_SDK by ehrbase.
the class EntryPostprocessor method process.
/**
* {@inheritDoc}
*/
@Override
public void process(String term, Entry rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
consumedPaths.add(term + PATH_DIVIDER + "encoding|code");
consumedPaths.add(term + PATH_DIVIDER + "encoding|terminology");
Map<FlatPathDto, String> subjectValues = FlatHelper.filter(values, term + "/subject", false);
if (!subjectValues.isEmpty()) {
if (rmObject.getSubject() == null) {
// If it was PartyRelated it would be set by now do to the relationship and if it was
// PartySelf subjectValues would be empty
rmObject.setSubject(new PartyIdentified());
}
callUnmarshal(term, "subject", rmObject.getSubject(), values, consumedPaths, context, context.getNodeDeque().peek().findChildById("subject").orElse(buildDummyChild("subject", context.getNodeDeque().peek())));
}
PartyProxy subject = rmObject.getSubject();
if (subject == null || (subject instanceof PartyIdentified && ((PartyIdentified) subject).getName() == null && CollectionUtils.isEmpty(((PartyIdentified) subject).getIdentifiers()) && subject.getExternalRef() == null && (!(subject instanceof PartyRelated) || ((PartyRelated) subject).getRelationship() == null || StringUtils.isEmpty(((PartyRelated) subject).getRelationship().getValue())))) {
rmObject.setSubject(new PartySelf());
}
Map<FlatPathDto, String> providerList = values.entrySet().stream().filter(e -> e.getKey().startsWith(term + PATH_DIVIDER + "_provider")).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
if (!MapUtils.isEmpty(providerList)) {
if (!(rmObject.getProvider() instanceof PartyIdentified)) {
rmObject.setProvider(new PartyIdentified());
}
PartyIdentifiedRMUnmarshaller partyIdentifiedRMUnmarshaller = new PartyIdentifiedRMUnmarshaller();
partyIdentifiedRMUnmarshaller.handle(term + PATH_DIVIDER + "_provider", (PartyIdentified) rmObject.getProvider(), providerList, null, consumedPaths);
}
Map<Integer, Map<String, String>> other = extractMultiValued(term, "_other_participation", values);
other.values().stream().map(Map::entrySet).map(s -> s.stream().collect(Collectors.toMap(e -> "ctx/" + DefaultValuePath.PARTICIPATION.getPath() + "_" + e.getKey().replace("identifiers_", "identifiers|"), e -> StringUtils.wrap(e.getValue(), '"'))).entrySet()).map(DefaultValues::buildParticipation).forEach(rmObject::addOtherParticipant);
consumeAllMatching(term + PATH_DIVIDER + "_other_participation", values, consumedPaths, false);
Map<FlatPathDto, String> workflowIdValues = filter(values, term + "/_work_flow_id", false);
if (!workflowIdValues.isEmpty()) {
ObjectRef<GenericId> ref = new ObjectRef<>();
ref.setId(new GenericId());
rmObject.setWorkflowId(ref);
setValue(term + "/_work_flow_id", "id", workflowIdValues, s -> ref.getId().setValue(s), String.class, consumedPaths);
setValue(term + "/_work_flow_id", "id_scheme", workflowIdValues, s -> ref.getId().setScheme(s), String.class, consumedPaths);
setValue(term + "/_work_flow_id", "namespace", workflowIdValues, ref::setNamespace, String.class, consumedPaths);
setValue(term + "/_work_flow_id", "type", workflowIdValues, ref::setType, String.class, consumedPaths);
}
}
Aggregations