use of com.nedap.archie.rm.datavalues.DvCodedText 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.datavalues.DvCodedText in project ehrbase by ehrbase.
the class EhrAccess method getStatus.
// get latest status
@Override
public EhrStatus getStatus() {
EhrStatus status = new EhrStatus();
status.setModifiable(isModifiable());
status.setQueryable(isQueryable());
// set otherDetails if available
if (getStatusAccess().getStatusRecord().getOtherDetails() != null) {
status.setOtherDetails(getStatusAccess().getStatusRecord().getOtherDetails());
}
// Locatable attribute
status.setArchetypeNodeId(getArchetypeNodeId());
Object name = new RecordedDvCodedText().fromDB(getStatusAccess().getStatusRecord(), STATUS.NAME);
status.setName(name instanceof DvText ? (DvText) name : (DvCodedText) name);
UUID statusId = getStatusAccess().getStatusRecord().getId();
status.setUid(new HierObjectId(statusId.toString() + "::" + getServerConfig().getNodename() + "::" + I_StatusAccess.getLatestVersionNumber(this, statusId)));
PartySelf partySelf = (PartySelf) new PersistedPartyProxy(this).retrieve(getParty());
status.setSubject(partySelf);
return status;
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project ehrbase by ehrbase.
the class AttestationAccess method getAsAttestation.
@Override
public Attestation getAsAttestation() {
// take most values from super class entry
AuditDetails audit = auditDetailsAccess.getAsAuditDetails();
String systemId = audit.getSystemId();
PartyProxy committer = audit.getCommitter();
DvDateTime time = audit.getTimeCommitted();
DvCodedText changeType = audit.getChangeType();
DvText description = audit.getDescription();
// FIXME VERSIONED_OBJECT_POC: implement retrieval from "attested_view" table
DvMultimedia attestedView = null;
String proof = attestationRecord.getProof();
// FIXME VERSIONED_OBJECT_POC: implement?! seems to be completely unsupported right now
List<DvEHRURI> items = null;
DvText reason = new DvText(attestationRecord.getReason());
boolean isPending = attestationRecord.getIsPending();
return new Attestation(systemId, committer, time, changeType, description, attestedView, proof, items, reason, isPending);
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project ehrbase by ehrbase.
the class AuditDetailsAccess method getAsAuditDetails.
@Override
public AuditDetails getAsAuditDetails() {
String systemId = getSystemId().toString();
PartyProxy party = new PersistedPartyProxy(this).retrieve(getCommitter());
DvDateTime time = new DvDateTime(getTimeCommitted().toLocalDateTime());
DvCodedText changeType = new DvCodedText(getChangeType().getLiteral(), new CodePhrase(new TerminologyId("openehr"), Integer.toString(I_ConceptAccess.ContributionChangeType.valueOf(getChangeType().getLiteral().toUpperCase()).getCode())));
DvText description = new DvText(getDescription());
return new AuditDetails(systemId, party, time, changeType, description);
}
use of com.nedap.archie.rm.datavalues.DvCodedText in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenEhrbaseBloodPressureSimpleDeV0.
@Test
public void testUnflattenEhrbaseBloodPressureSimpleDeV0() {
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
EhrbaseBloodPressureSimpleDeV0Composition dto = buildEhrbaseBloodPressureSimpleDeV0();
Composition rmObject = (Composition) cut.unflatten(dto);
assertThat(rmObject).isNotNull();
assertThat(rmObject.getContext().getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getFunction().getValue()).containsExactlyInAnyOrder(new Tuple("Test", "Pos1"), new Tuple("Test2", "Pos2"));
assertThat(rmObject.getLanguage()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("de", "ISO_639-1");
assertThat(rmObject.getArchetypeDetails().getTemplateId().getValue()).isEqualTo("ehrbase_blood_pressure_simple.de.v0");
assertThat(rmObject.itemAtPath("/context/start_time/value")).isEqualTo(dto.getStartTimeValue());
List<Object> observationList = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]");
assertThat(observationList).size().isEqualTo(1);
Observation observation = (Observation) observationList.get(0);
DvCodedText expected = new DvCodedText("Fifth sound", new CodePhrase(new TerminologyId("local"), "at1012"));
assertThat(observation.itemAtPath("/protocol[at0011]/items[at1010]/value")).isEqualTo(expected);
assertThat(observation.getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
}
Aggregations