Search in sources :

Example 36 with DvDateTime

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);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EventContext(com.nedap.archie.rm.composition.EventContext) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DateTime(org.joda.time.DateTime) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 37 with DvDateTime

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);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EventContext(com.nedap.archie.rm.composition.EventContext) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) GenericId(com.nedap.archie.rm.support.identification.GenericId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) DateTime(org.joda.time.DateTime) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 38 with DvDateTime

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());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Timestamp(java.sql.Timestamp) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 39 with DvDateTime

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));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) InternalServerException(org.ehrbase.api.exception.InternalServerException) URI(java.net.URI) ObjectNotFoundException(org.ehrbase.api.exception.ObjectNotFoundException) StateConflictException(org.ehrbase.api.exception.StateConflictException) InternalServerException(org.ehrbase.api.exception.InternalServerException) InvalidApiParameterException(org.ehrbase.api.exception.InvalidApiParameterException) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) MediaType(org.springframework.http.MediaType) EhrResponseData(org.ehrbase.response.openehr.EhrResponseData) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId)

Example 40 with DvDateTime

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;
}
Also used : InternalServerException(org.ehrbase.api.exception.InternalServerException) CompositionDto(org.ehrbase.response.ehrscape.CompositionDto) I_CompositionAccess(org.ehrbase.dao.access.interfaces.I_CompositionAccess) VersionedComposition(com.nedap.archie.rm.ehr.VersionedComposition) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Aggregations

DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)44 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)11 Test (org.junit.Test)10 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)8 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)7 EventContext (com.nedap.archie.rm.composition.EventContext)6 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)5 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)5 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)5 Composition (com.nedap.archie.rm.composition.Composition)4 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)4 Participation (com.nedap.archie.rm.generic.Participation)4 TemporalAccessor (java.time.temporal.TemporalAccessor)4 Objects (java.util.Objects)4 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)3 DvText (com.nedap.archie.rm.datavalues.DvText)3 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)3 AuditDetails (com.nedap.archie.rm.generic.AuditDetails)3 UUID (java.util.UUID)3 Test (org.junit.jupiter.api.Test)3