use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class RecordedDvDateTimeTest method testDecodeDvDateTime.
@Test
public void testDecodeDvDateTime() {
ZoneOffset zoneId = ZoneOffset.of("-06:00");
Instant now = Instant.now();
DvDateTime dateTime;
dateTime = new RecordedDvDateTime().decodeDvDateTime(Timestamp.valueOf(LocalDateTime.ofInstant(now, zoneId)), zoneId.getId());
assertEquals(OffsetDateTime.ofInstant(now, zoneId), dateTime.getValue());
dateTime = new RecordedDvDateTime().decodeDvDateTime(Timestamp.from(now), null);
assertEquals(LocalDateTime.ofInstant(now, ZoneId.systemDefault()), dateTime.getValue());
dateTime = new RecordedDvDateTime().decodeDvDateTime(Timestamp.from(now), zoneId.getId());
assertNotEquals(OffsetDateTime.ofInstant(now, ZoneOffset.UTC), dateTime.getValue());
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class EhrServiceImp method getCreationTime.
/**
* Fetches time of creation of specific EHR record
*
* @param ehrId
* @return LocalDateTime instance of timestamp from DB
*/
public DvDateTime getCreationTime(UUID ehrId) {
// pre-step: check for valid ehrId
if (!hasEhr(ehrId)) {
throw new ObjectNotFoundException("ehr", "No EHR found with given ID: " + ehrId.toString());
}
try {
I_EhrAccess ehrAccess = I_EhrAccess.retrieveInstance(getDataAccess(), ehrId);
OffsetDateTime offsetDateTime = OffsetDateTime.from(LocalDateTime.from(ehrAccess.getEhrRecord().getDateCreated().toLocalDateTime()).atZone(ZoneId.of(ehrAccess.getEhrRecord().getDateCreatedTzid())));
return new DvDateTime(offsetDateTime);
} catch (Exception e) {
logger.error(e.getMessage());
throw new InternalServerException(e);
}
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime 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.quantity.datetime.DvDateTime 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.quantity.datetime.DvDateTime 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);
}
Aggregations