use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class EventContextFactory method makeNull.
public EventContext makeNull() {
PartyRef partyRef = new PartyRef(new HierObjectId("ref"), "null", "null");
PartyIdentified healthcareFacility = new PartyIdentified(partyRef, "null", null);
DvCodedText concept = new DvCodedText("Other Care", new CodePhrase(new TerminologyId("openehr"), "238"));
return new EventContext(healthcareFacility, new DvDateTime(new DateTime(0L).toString()), null, null, null, concept, null);
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class EventContextFactory method makeDummy.
public EventContext makeDummy() {
PartyRef partyRef = new PartyRef(new GenericId("123456-123", "EHRBASE-SCHEME"), "DEMOGRAPHIC", "PARTY");
PartyIdentified healthcareFacility = new PartyIdentified(partyRef, "FACILITY", null);
DateTime timenow = DateTime.now();
DvCodedText concept = new DvCodedText("Other Care", new CodePhrase(new TerminologyId("openehr"), "238"));
return new EventContext(healthcareFacility, new DvDateTime(timenow.toString()), null, null, "TEST LAB", concept, null);
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class RecordedDvDateTimeTest method testToTimestamp.
@Test
public void testToTimestamp() {
OffsetDateTime now = OffsetDateTime.now();
Timestamp timestamp = new RecordedDvDateTime(new DvDateTime(now)).toTimestamp();
assertEquals(now.toInstant(), timestamp.toInstant());
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class OpenehrEhrController method buildEhrResponseData.
/**
* Builder method to prepare appropriate HTTP response. Flexible to either allow minimal or full representation of resource.
*
* @param factory Lambda function to constructor of desired object
* @param ehrId Current object's reference
* @param accept Requested content format
* @param headerList Requested headers that need to be set
* @param <T> Either EhrResponseData itself or more specific sub-class EhrResponseDataRepresentation
* @return
*/
private <T extends EhrResponseData> Optional<InternalResponse<T>> buildEhrResponseData(Supplier<T> factory, UUID ehrId, /*Action create,*/
String accept, List<String> headerList) {
// check for valid format header to produce content accordingly
MediaType contentType = resolveContentType(accept);
// Optional<EhrStatusDto> ehrStatus = ehrService.getEhrStatusEhrScape(ehrId, CompositionFormat.FLAT); // older, keep until rework of formatting
Optional<EhrStatus> ehrStatus = ehrService.getEhrStatus(ehrId);
if (ehrStatus.isEmpty()) {
return Optional.empty();
}
// create either null or maximum response data class
T minimalOrRepresentation = factory.get();
if (minimalOrRepresentation != null) {
// populate maximum response data
EhrResponseData objByReference = minimalOrRepresentation;
objByReference.setEhrId(new HierObjectId(ehrId.toString()));
objByReference.setEhrStatus(ehrStatus.get());
objByReference.setSystemId(new HierObjectId(ehrService.getSystemUuid().toString()));
DvDateTime timeCreated = ehrService.getCreationTime(ehrId);
objByReference.setTimeCreated(timeCreated.getValue().toString());
// objByReference.setCompositions(null); // TODO get actual data from service layer
// objByReference.setContributions(null); // TODO get actual data from service layer
}
// create and supplement headers with data depending on which headers are requested
HttpHeaders respHeaders = new HttpHeaders();
for (String header : headerList) {
switch(header) {
case CONTENT_TYPE:
if (// if response is going to have a body
minimalOrRepresentation != null)
respHeaders.setContentType(contentType);
break;
case LOCATION:
try {
URI url = new URI(getBaseEnvLinkURL() + "/rest/openehr/v1/ehr/" + ehrId);
respHeaders.setLocation(url);
} catch (Exception e) {
throw new InternalServerException(e.getMessage());
}
break;
case ETAG:
respHeaders.setETag("\"" + ehrId + "\"");
break;
case LAST_MODIFIED:
// TODO should be VERSION.commit_audit.time_committed.value which is not implemented yet - mock for now
respHeaders.setLastModified(123124442);
break;
default:
}
}
return Optional.of(new InternalResponse<>(minimalOrRepresentation, respHeaders));
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project ehrbase by ehrbase.
the class CompositionServiceImp method getVersionedComposition.
@Override
public VersionedComposition getVersionedComposition(UUID ehrId, UUID composition) {
Optional<CompositionDto> dto = retrieve(composition, 1);
VersionedComposition compo = new VersionedComposition();
if (dto.isPresent()) {
compo.setUid(new HierObjectId(dto.get().getUuid().toString()));
compo.setOwnerId(new ObjectRef<>(new HierObjectId(dto.get().getEhrId().toString()), "local", "ehr"));
Map<Integer, I_CompositionAccess> compos = I_CompositionAccess.getVersionMapOfComposition(getDataAccess(), composition);
if (compos.containsKey(1)) {
compo.setTimeCreated(new DvDateTime(OffsetDateTime.of(compos.get(1).getSysTransaction().toLocalDateTime(), OffsetDateTime.now().getOffset())));
} else {
throw new InternalServerException("Inconsistent composition data, no version 1 available");
}
}
return compo;
}
Aggregations