use of com.nedap.archie.rm.support.identification.PartyRef in project openEHR_SDK by ehrbase.
the class DefaultRestEhrFieldsEndpointIT method testCreateEhrWithStatus.
@Test
public void testCreateEhrWithStatus() {
EhrStatus ehrStatus = new EhrStatus();
ehrStatus.setQueryable(false);
ehrStatus.setModifiable(false);
HierObjectId subjectId = new HierObjectId(UUID.randomUUID().toString());
ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
ehrStatus.setArchetypeNodeId("just-a-status");
ehrStatus.setName(new DvText("Status"));
ehr = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
assertThat(ehr).isNotNull();
EhrStatus actual = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
assertThat(actual.getSubject().getExternalRef().getId()).isEqualTo(subjectId);
}
use of com.nedap.archie.rm.support.identification.PartyRef in project openEHR_SDK by ehrbase.
the class DefaultValues method buildParticipation.
public static Participation buildParticipation(Collection<Map.Entry<String, String>> subValues) {
Participation participation = new Participation();
participation.setPerformer(new PartyIdentified());
extractExact(subValues, "id", s -> {
participation.getPerformer().setExternalRef(new PartyRef());
participation.getPerformer().getExternalRef().setType("PARTY");
GenericId id = new GenericId();
id.setValue(s);
participation.getPerformer().getExternalRef().setId(id);
});
extract(subValues, "name", ((PartyIdentified) participation.getPerformer())::setName);
if (participation.getPerformer().getExternalRef() != null) {
extract(subValues, "id_namespace", n -> participation.getPerformer().getExternalRef().setNamespace(n));
extract(subValues, "id_scheme", ((GenericId) participation.getPerformer().getExternalRef().getId())::setScheme);
}
extract(subValues, "function", s -> participation.setFunction(new DvText(s)));
extract(subValues, "mode", s -> {
ParticipationMode participationMode = findEnumValueOrThrow(s, ParticipationMode.class);
participation.setMode(new DvCodedText());
participation.getMode().setValue(participationMode.getValue());
participation.getMode().setDefiningCode(participationMode.toCodePhrase());
});
((PartyIdentified) participation.getPerformer()).setIdentifiers(splitByIndex(filter(subValues.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), DefaultValuePath.PARTICIPATION.getPath() + "_" + "identifiers")).values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
return participation;
}
use of com.nedap.archie.rm.support.identification.PartyRef in project openEHR_SDK by ehrbase.
the class AbstractValueInserter method buildPartyIdentified.
protected PartyIdentified buildPartyIdentified(DefaultValues defaultValues, DefaultValuePath<String> name, DefaultValuePath<String> id, PartyProxy partyProxy) {
if (partyProxy == null || !PartyIdentified.class.isAssignableFrom(partyProxy.getClass())) {
partyProxy = new PartyIdentified();
}
if (defaultValues.containsDefaultValue(name)) {
((PartyIdentified) partyProxy).setName(defaultValues.getDefaultValue(name));
}
if (defaultValues.containsDefaultValue(id)) {
PartyRef partyRef = new PartyRef();
partyRef.setNamespace(defaultValues.getDefaultValue(DefaultValuePath.ID_NAMESPACE));
partyRef.setType("PARTY");
partyRef.setId(new GenericId(defaultValues.getDefaultValue(id), defaultValues.getDefaultValue(DefaultValuePath.ID_SCHEME)));
partyProxy.setExternalRef(partyRef);
}
addSchemeNamespace(partyProxy.getExternalRef(), defaultValues);
return (PartyIdentified) partyProxy;
}
use of com.nedap.archie.rm.support.identification.PartyRef in project openEHR_SDK by ehrbase.
the class PartyIdentifiedRMUnmarshaller method handle.
@Override
public void handle(String currentTerm, PartyIdentified rmObject, Map<FlatPathDto, String> currentValues, Context<Map<FlatPathDto, String>> context, Set<String> consumedPaths) {
setValue(currentTerm, "name", currentValues, rmObject::setName, String.class, consumedPaths);
if (rmObject.getName() == null) {
// betters implementation uses /name or /_name instead of |name for subject
setValue(currentTerm + "/name", null, currentValues, rmObject::setName, String.class, consumedPaths);
if (rmObject.getName() == null) {
setValue(currentTerm + "/_name", null, currentValues, rmObject::setName, String.class, consumedPaths);
}
}
rmObject.setExternalRef(new PartyRef());
rmObject.getExternalRef().setType("PARTY");
rmObject.getExternalRef().setId(new GenericId());
setValue(currentTerm, "id", currentValues, rmObject.getExternalRef().getId()::setValue, String.class, consumedPaths);
setValue(currentTerm, "id_scheme", currentValues, ((GenericId) rmObject.getExternalRef().getId())::setScheme, String.class, consumedPaths);
setValue(currentTerm, "id_namespace", currentValues, rmObject.getExternalRef()::setNamespace, String.class, consumedPaths);
// remove if not set
if (rmObject.getExternalRef().getId() == null || StringUtils.isBlank(rmObject.getExternalRef().getId().getValue())) {
rmObject.setExternalRef(null);
}
Map<Integer, Map<String, String>> identifiers = extractMultiValued(currentTerm, "_identifier", currentValues);
rmObject.setIdentifiers(identifiers.values().stream().map(DefaultValues::toDvIdentifier).collect(Collectors.toList()));
consumeAllMatching(currentTerm + PATH_DIVIDER + "_identifier", currentValues, consumedPaths, false);
}
use of com.nedap.archie.rm.support.identification.PartyRef in project fhir-bridge by ehrbase.
the class EhrLookupProcessor method createEhr.
/**
* Creates an EHR for the given patient ID.
*
* @param patientId the given patient ID
* @return the EHR ID
*/
private UUID createEhr(IIdType patientId) {
Patient patient = patientDao.read(patientId);
Identifier pseudonym = PatientUtils.getPseudonym(patient);
PartySelf subject = new PartySelf(new PartyRef(new HierObjectId(pseudonym.getValue()), "DEMOGRAPHIC", "PERSON"));
EhrStatus ehrStatus = new EhrStatus(ARCHETYPE_NODE_ID, new DvText("EHR Status"), subject, true, true, null);
UUID ehrId = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
PatientEhr patientEhr = new PatientEhr(patientId.getIdPart(), ehrId);
patientEhrRepository.save(patientEhr);
LOG.debug("Created PatientEhr: patientId={}, ehrId={}", patientEhr.getPatientId(), patientEhr.getEhrId());
return ehrId;
}
Aggregations