Search in sources :

Example 1 with VersionedComposition

use of com.nedap.archie.rm.ehr.VersionedComposition in project openEHR_SDK by ehrbase.

the class DefaultRestVersionedCompositionEndpointIT method testFindValid.

@Test
public void testFindValid() {
    ehrId = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseBloodPressureSimpleDeV0Composition composition = TestData.buildEhrbaseBloodPressureSimpleDeV0();
    openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
    Optional<VersionedComposition> versionedComposition = openEhrClient.versionedCompositionEndpoint(ehrId).find(composition.getVersionUid().getUuid());
    Assert.assertTrue(versionedComposition.isPresent());
    Assert.assertEquals(composition.getVersionUid().getUuid().toString(), versionedComposition.get().getUid().getValue());
    Assert.assertEquals(ehrId.toString(), versionedComposition.get().getOwnerId().getId().getValue());
}
Also used : EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) VersionedComposition(com.nedap.archie.rm.ehr.VersionedComposition) Test(org.junit.Test)

Example 2 with VersionedComposition

use of com.nedap.archie.rm.ehr.VersionedComposition in project ehrbase by ehrbase.

the class OpenehrVersionedCompositionController method retrieveVersionedCompositionByVersionedObjectUid.

@GetMapping(path = "/{versioned_object_uid}")
@Override
public ResponseEntity<VersionedObjectResponseData<Composition>> retrieveVersionedCompositionByVersionedObjectUid(@RequestHeader(value = HttpHeaders.ACCEPT, required = false) String accept, @PathVariable(value = "ehr_id") String ehrIdString, @PathVariable(value = "versioned_object_uid") String versionedObjectUid) {
    UUID ehrId = getEhrUuid(ehrIdString);
    UUID versionedCompoUid = getCompositionVersionedObjectUidString(versionedObjectUid);
    // check if parameters are valid
    checkForValidEhrAndCompositionParameter(ehrId, versionedCompoUid);
    VersionedComposition versionedComposition = compositionService.getVersionedComposition(ehrId, versionedCompoUid);
    VersionedObjectResponseData<Composition> response = new VersionedObjectResponseData<>(versionedComposition);
    HttpHeaders respHeaders = new HttpHeaders();
    respHeaders.setContentType(resolveContentType(accept));
    return ResponseEntity.ok().headers(respHeaders).body(response);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) Composition(com.nedap.archie.rm.composition.Composition) VersionedComposition(com.nedap.archie.rm.ehr.VersionedComposition) VersionedObjectResponseData(org.ehrbase.response.openehr.VersionedObjectResponseData) UUID(java.util.UUID) VersionedComposition(com.nedap.archie.rm.ehr.VersionedComposition) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with VersionedComposition

use of com.nedap.archie.rm.ehr.VersionedComposition 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

VersionedComposition (com.nedap.archie.rm.ehr.VersionedComposition)3 Composition (com.nedap.archie.rm.composition.Composition)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)1 UUID (java.util.UUID)1 InternalServerException (org.ehrbase.api.exception.InternalServerException)1 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)1 I_CompositionAccess (org.ehrbase.dao.access.interfaces.I_CompositionAccess)1 CompositionDto (org.ehrbase.response.ehrscape.CompositionDto)1 VersionedObjectResponseData (org.ehrbase.response.openehr.VersionedObjectResponseData)1 Test (org.junit.Test)1 HttpHeaders (org.springframework.http.HttpHeaders)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1