use of com.nedap.archie.rm.generic.Participation in project ehrbase by ehrbase.
the class ContextAccess method mapRmEventContext.
/**
* @throws InternalServerException on failure of decoding DvText or DvDateTime
*/
@Override
public EventContext mapRmEventContext() {
// get the facility entry
PartyIdentifiedRecord partyIdentifiedRecord = getContext().fetchOne(PARTY_IDENTIFIED, PARTY_IDENTIFIED.ID.eq(eventContextRecord.getFacility()));
// facility identifiers
PartyIdentified healthCareFacility = null;
if (partyIdentifiedRecord != null) {
List<DvIdentifier> identifiers = new ArrayList<>();
getContext().fetch(IDENTIFIER, IDENTIFIER.PARTY.eq(partyIdentifiedRecord.getId())).forEach(record -> {
DvIdentifier dvIdentifier = new DvIdentifier();
dvIdentifier.setIssuer(record.getIssuer());
dvIdentifier.setAssigner(record.getAssigner());
dvIdentifier.setId(record.getIdValue());
dvIdentifier.setType(record.getTypeName());
identifiers.add(dvIdentifier);
});
// get PartyRef values from record
healthCareFacility = getPartyIdentifiedFromRecord(partyIdentifiedRecord, identifiers);
}
List<Participation> participationList = new ArrayList<>();
// get the participations
getContext().fetch(PARTICIPATION, PARTICIPATION.EVENT_CONTEXT.eq(eventContextRecord.getId())).forEach(record -> {
// retrieve performer
PartyProxy performer = new PersistedPartyProxy(this).retrieve(record.getPerformer());
DvInterval<DvDateTime> dvInterval = convertDvIntervalDvDateTimeFromRecord(record);
DvCodedText mode = convertModeFromRecord(record);
Participation participation = new Participation(performer, (DvText) new RecordedDvCodedText().fromDB(record, PARTICIPATION.FUNCTION), mode, dvInterval);
participationList.add(participation);
});
DvCodedText concept = (DvCodedText) new RecordedDvCodedText().fromDB(eventContextRecord, EVENT_CONTEXT.SETTING);
ItemStructure otherContext = null;
if (eventContextRecord.getOtherContext() != null) {
otherContext = new RawJson().unmarshal((eventContextRecord.getOtherContext().data()), ItemStructure.class);
}
return new EventContext(healthCareFacility, new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getStartTime(), eventContextRecord.getStartTimeTzid()), new RecordedDvDateTime().decodeDvDateTime(eventContextRecord.getEndTime(), eventContextRecord.getEndTimeTzid()), participationList.isEmpty() ? null : participationList, eventContextRecord.getLocation(), concept, otherContext);
}
use of com.nedap.archie.rm.generic.Participation in project openEHR_SDK by ehrbase.
the class DefaultRestCompositionEndpointIT method testSaveCompositionEntityCgiProxy.
@Test
public void testSaveCompositionEntityCgiProxy() {
ehr = openEhrClient.ehrEndpoint().createEhr();
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(EhrbaseBloodPressureSimpleDeV0Composition.class);
enhancer.setCallback((MethodInterceptor) (obj, method, args, proxy) -> {
if (method.getDeclaringClass() != Object.class && method.getName().equals("getLanguage")) {
return Language.EN;
} else {
return proxy.invokeSuper(obj, args);
}
});
EhrbaseBloodPressureSimpleDeV0Composition proxy = (EhrbaseBloodPressureSimpleDeV0Composition) enhancer.create();
proxy.setStartTimeValue(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
proxy.setEndTimeValue(OffsetDateTime.now());
proxy.setBloodPressureTrainingSample(new ArrayList<>());
proxy.setLanguage(Language.DE);
proxy.setTerritory(Territory.DE);
proxy.setCategoryDefiningCode(org.ehrbase.client.classgenerator.shareddefinition.Category.EVENT);
proxy.setSettingDefiningCode(Setting.NURSING_HOME_CARE);
proxy.setComposer(new PartyIdentified(null, "Test", null));
proxy.setParticipations(new ArrayList<>());
proxy.getParticipations().add(new Participation(new PartyIdentified(null, "Test", null), new DvText("Pos1"), null, null));
proxy.getParticipations().add(new Participation(new PartyIdentified(null, "Test2", null), new DvText("Pos2"), null, null));
proxy.setBloodPressureTrainingSample(bloodPressureSimpleDeV0.getBloodPressureTrainingSample());
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(proxy);
assertThat(proxy.getVersionUid()).isNotNull();
assertThat(proxy.getVersionUid().getVersion()).isEqualTo(1L);
EhrbaseBloodPressureSimpleDeV0Composition actual = openEhrClient.compositionEndpoint(ehr).find(proxy.getVersionUid().getUuid(), EhrbaseBloodPressureSimpleDeV0Composition.class).get();
assertThat(actual.getLanguage()).isEqualTo(Language.EN);
}
use of com.nedap.archie.rm.generic.Participation in project openEHR_SDK by ehrbase.
the class TestData method buildEhrbaseBloodPressureSimpleDeV0.
public static EhrbaseBloodPressureSimpleDeV0Composition buildEhrbaseBloodPressureSimpleDeV0() {
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = new EhrbaseBloodPressureSimpleDeV0Composition();
bloodPressureSimpleDeV0.setStartTimeValue(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
bloodPressureSimpleDeV0.setEndTimeValue(OffsetDateTime.now());
bloodPressureSimpleDeV0.setBloodPressureTrainingSample(new ArrayList<>());
bloodPressureSimpleDeV0.setLanguage(Language.DE);
bloodPressureSimpleDeV0.setTerritory(Territory.DE);
bloodPressureSimpleDeV0.setCategoryDefiningCode(Category.EVENT);
bloodPressureSimpleDeV0.setSettingDefiningCode(Setting.NURSING_HOME_CARE);
bloodPressureSimpleDeV0.setComposer(new PartyIdentified(null, "Test", null));
bloodPressureSimpleDeV0.setParticipations(new ArrayList<>());
bloodPressureSimpleDeV0.getParticipations().add(new Participation(new PartyIdentified(null, "Test", null), new DvText("Pos1"), null, null));
bloodPressureSimpleDeV0.getParticipations().add(new Participation(new PartyIdentified(null, "Test2", null), new DvText("Pos2"), null, null));
bloodPressureSimpleDeV0.getBloodPressureTrainingSample().add(buildBloodPressureTrainingSampleObservation());
return bloodPressureSimpleDeV0;
}
use of com.nedap.archie.rm.generic.Participation 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.generic.Participation in project openEHR_SDK by ehrbase.
the class DefaultRestCompositionEndpointIT method testSaveCompositionWithDefaultEntity.
@Test
public void testSaveCompositionWithDefaultEntity() throws URISyntaxException {
openEhrClient = setupDefaultRestClientWithDefaultProvider(o -> {
DefaultValues defaultValues = new DefaultValues();
defaultValues.addDefaultValue(DefaultValuePath.END_TIME, OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC));
Participation participation = new Participation(new PartyIdentified(null, "Dr. Peter", null), new DvText("Performer"), ParticipationMode.PHYSICALLY_PRESENT.toCodedText(), null);
defaultValues.addDefaultValue(DefaultValuePath.PARTICIPATION, new ArrayList<>(Collections.singleton(participation)));
return defaultValues;
});
ehr = openEhrClient.ehrEndpoint().createEhr();
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0WithEmptyFields();
// Not set during creation
assertThat(bloodPressureSimpleDeV0.getEndTimeValue()).isNull();
assertThat(bloodPressureSimpleDeV0.getParticipations()).isEmpty();
// during saving default values will be set
bloodPressureSimpleDeV0 = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(bloodPressureSimpleDeV0);
assertThat(bloodPressureSimpleDeV0.getEndTimeValue()).isEqualTo(OffsetDateTime.of(2019, 05, 03, 22, 00, 00, 00, ZoneOffset.UTC));
assertThat(bloodPressureSimpleDeV0.getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getMode().getValue()).containsExactlyInAnyOrder(new Tuple("Dr. Peter", "physically present"));
}
Aggregations