use of com.nedap.archie.rm.generic.PartyIdentified in project fhir-bridge by ehrbase.
the class ReferenceToPartyIdentifiedConverter method convert.
@Override
public PartyIdentified convert(Reference source) {
if (source == null) {
return null;
}
PartyIdentified partyIdentified = new PartyIdentified();
DvIdentifier identifier = new DvIdentifier();
if (source.hasReference()) {
identifier.setId(source.getReference());
} else if (source.hasIdentifier()) {
identifier.setAssigner(source.getIdentifier().getSystem());
identifier.setId(source.getIdentifier().getValue());
} else {
throw new ConversionException("Reference should have either a reference or an identifier");
}
partyIdentified.addIdentifier(identifier);
return partyIdentified;
}
use of com.nedap.archie.rm.generic.PartyIdentified 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.PartyIdentified 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.PartyIdentified in project openEHR_SDK by ehrbase.
the class DefaultRestCompositionEndpointIT method testSaveCompositionEntityWithAnyProxy.
@Test
public void testSaveCompositionEntityWithAnyProxy() {
ehr = openEhrClient.ehrEndpoint().createEhr();
GECCOSerologischerBefundComposition composition1 = new GECCOSerologischerBefundComposition();
composition1.setLanguage(Language.DE);
composition1.setTerritory(Territory.DE);
composition1.setCategoryDefiningCode(org.ehrbase.client.classgenerator.shareddefinition.Category.EVENT);
composition1.setSettingDefiningCode(Setting.NURSING_HOME_CARE);
composition1.setComposer(new PartyIdentified(null, "Test", null));
composition1.setStartTimeValue(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
composition1.setParticipations(new ArrayList<>());
composition1.setBefund(new ArrayList<>());
Enhancer enhancerObservation = new Enhancer();
enhancerObservation.setSuperclass(BefundObservation.class);
enhancerObservation.setCallback((MethodInterceptor) (obj, method, args, proxy) -> {
if (method.getDeclaringClass() != Object.class && method.getName().equals("getLanguage")) {
return Language.EN;
} else {
return proxy.invokeSuper(obj, args);
}
});
BefundObservation befundObservation = (BefundObservation) enhancerObservation.create();
composition1.getBefund().add(befundObservation);
befundObservation.setSubject(new PartySelf());
befundObservation.setJedesEreignis(new ArrayList<>());
// Read will be overwritten by enhancerObservation
befundObservation.setLanguage(Language.DE);
befundObservation.setAnforderungDefiningCode(AnforderungDefiningCode.SARS_COV2_COVID19_AB_PANEL_SERUM_OR_PLASMA_BY_IMMUNOASSAY);
befundObservation.setOriginValue(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
BefundJedesEreignisPointEvent event = new BefundJedesEreignisPointEvent();
event.setTimeValue(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
event.setLabortestBezeichnungDefiningCode(LabortestBezeichnungDefiningCode.SEROLOGIC_TEST_PROCEDURE);
event.setVirusnachweistestDefiningCode(VirusnachweistestDefiningCode.SARS_COV2_COVID19_AB_PRESENCE_IN_SERUM_OR_PLASMA_BY_IMMUNOASSAY);
event.setErgebnisStatusValue("registered");
befundObservation.getJedesEreignis().add(event);
Enhancer enhancerProAnalytQuantitativesErgebnisDvCount = new Enhancer();
enhancerProAnalytQuantitativesErgebnisDvCount.setSuperclass(ProAnalytQuantitativesErgebnisDvCount.class);
enhancerProAnalytQuantitativesErgebnisDvCount.setCallback((MethodInterceptor) (obj, method, args, proxy) -> {
if (method.getDeclaringClass() != Object.class && method.getName().equals("getQuantitativesErgebnisMagnitude")) {
return 33l;
} else {
return proxy.invokeSuper(obj, args);
}
});
ProAnalytQuantitativesErgebnisDvCount quantitativesErgebnis = (ProAnalytQuantitativesErgebnisDvCount) enhancerProAnalytQuantitativesErgebnisDvCount.create();
quantitativesErgebnis.setQuantitativesErgebnisMagnitude(22l);
event.setQuantitativesErgebnis(quantitativesErgebnis);
GECCOSerologischerBefundComposition composition = composition1;
composition = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(composition);
Optional<GECCOSerologischerBefundComposition> actual = openEhrClient.compositionEndpoint(ehr).find(composition.getVersionUid().getUuid(), GECCOSerologischerBefundComposition.class);
assertThat(actual).isPresent();
assertThat(actual.get().getBefund()).size().isEqualTo(1);
BefundObservation actualObservation = actual.get().getBefund().get(0);
assertThat(actualObservation.getLanguage()).isEqualTo(Language.EN);
assertThat(actualObservation.getJedesEreignis()).size().isEqualTo(1);
assertThat(actualObservation.getJedesEreignis().get(0).getQuantitativesErgebnis()).isNotNull();
assertThat(actualObservation.getJedesEreignis().get(0).getQuantitativesErgebnis().getClass()).isEqualTo(ProAnalytQuantitativesErgebnisDvCount.class);
assertThat(((ProAnalytQuantitativesErgebnisDvCount) actualObservation.getJedesEreignis().get(0).getQuantitativesErgebnis()).getQuantitativesErgebnisMagnitude()).isEqualTo(33L);
}
use of com.nedap.archie.rm.generic.PartyIdentified in project openEHR_SDK by ehrbase.
the class DefaultRestCompositionEndpointIT method testFind.
@Test
public void testFind() {
ehr = openEhrClient.ehrEndpoint().createEhr();
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
CompositionEndpoint compositionEndpoint = openEhrClient.compositionEndpoint(ehr);
EhrbaseBloodPressureSimpleDeV0Composition version1 = compositionEndpoint.mergeCompositionEntity(bloodPressureSimpleDeV0);
Optional<EhrbaseBloodPressureSimpleDeV0Composition> actual = compositionEndpoint.find(version1.getVersionUid().getUuid(), EhrbaseBloodPressureSimpleDeV0Composition.class);
assertTrue(actual.isPresent());
assertThat(actual.get().getComposer()).isNotNull().extracting(Object::getClass).isEqualTo(PartyIdentified.class);
PartyIdentified composer = (PartyIdentified) actual.get().getComposer();
assertThat(composer.getName()).isEqualTo("Test");
assertThat(actual.get().getBloodPressureTrainingSample()).size().isEqualTo(1);
assertThat(actual.get().getBloodPressureTrainingSample().get(0).getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
assertThat(actual.get().getBloodPressureTrainingSample().get(0).getSystolicMagnitude()).isEqualTo(22d);
assertThat(actual.get().getBloodPressureTrainingSample().get(0).getSystolicUnits()).isEqualTo("mm[Hg]");
assertThat(actual.get().getBloodPressureTrainingSample().get(0).getKorotkoffSoundsDefiningCode()).isEqualTo(KorotkoffSoundsDefiningCode.FIFTH_SOUND);
}
Aggregations