Search in sources :

Example 11 with EhrStatus

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

the class EhrController method createEhr.

@PostMapping
@ResponseStatus(value = HttpStatus.CREATED)
public // overwrites default 200, fixes the wrong listing of 200 in swagger-ui (EHR-56)
ResponseEntity<EhrResponseData> createEhr(@RequestParam(value = "subjectId", required = false) String subjectId, @RequestParam(value = "subjectNamespace", required = false) String subjectNamespace, @RequestParam(value = "committerId", required = false) String committerId, @RequestParam(value = "committerName", required = false) String committerName, @RequestHeader(value = "Content-Type", required = false) String contentType, @RequestBody(required = false) String content) {
    // subjectId and subjectNamespace are not required by EhrScape spec but without those parameters a 400 error shall be returned
    if ((subjectId == null) || (subjectNamespace == null)) {
        throw new InvalidApiParameterException("subjectId or subjectNamespace missing");
    } else if ((subjectId.isEmpty()) || (subjectNamespace.isEmpty())) {
        throw new InvalidApiParameterException("subjectId or subjectNamespace emtpy");
    }
    EhrStatus ehrStatus = extractEhrStatus(content);
    PartySelf partySelf = new PartySelf(new PartyRef(new HierObjectId(subjectId), subjectNamespace, null));
    ehrStatus.setSubject(partySelf);
    UUID ehrId = ehrService.create(ehrStatus, null);
    // TODO: use config file or alike to set the basic api path
    URI url = URI.create(getBaseEnvLinkURL() + "/rest/ecis/v1/ehr/" + ehrId.toString());
    return Optional.ofNullable(ehrId).flatMap(i -> buildEhrResponseData(i, Action.CREATE, contentType)).map(ResponseEntity.created(url)::body).orElse(ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build());
}
Also used : InvalidApiParameterException(org.ehrbase.api.exception.InvalidApiParameterException) PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) UUID(java.util.UUID) URI(java.net.URI) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 12 with EhrStatus

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

the class DefaultRestEhrFieldsEndpointIT method testCreateEhrWithStatus.

@Test
public void testCreateEhrWithStatus() {
    EhrStatus ehrStatus = new EhrStatus();
    ehrStatus.setQueryable(false);
    ehrStatus.setModifiable(false);
    HierObjectId subjectId = new HierObjectId(UUID.randomUUID().toString());
    ehrStatus.setSubject(new PartySelf(new PartyRef(subjectId, "default", "PERSON")));
    ehrStatus.setArchetypeNodeId("just-a-status");
    ehrStatus.setName(new DvText("Status"));
    ehr = openEhrClient.ehrEndpoint().createEhr(ehrStatus);
    assertThat(ehr).isNotNull();
    EhrStatus actual = openEhrClient.ehrEndpoint().getEhrStatus(ehr).get();
    assertThat(actual.getSubject().getExternalRef().getId()).isEqualTo(subjectId);
}
Also used : PartyRef(com.nedap.archie.rm.support.identification.PartyRef) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) PartySelf(com.nedap.archie.rm.generic.PartySelf) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 13 with EhrStatus

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

the class CanonicalUtilTest method testGetAttributeInRmObject.

@Test
public void testGetAttributeInRmObject() {
    EhrStatus ehrStatus = (EhrStatus) toRmObject(ehrStatusTest, EhrStatus.class);
    assertThat(attributeValueAt(ehrStatus, "name/value")).isEqualTo("EHR Status");
    assertThat(attributeValueAt(ehrStatus, "archetype_node_id")).isEqualTo("openEHR-EHR-EHR_STATUS.generic.v1");
    assertThat(attributeValueAt(ehrStatus, "is_modifiable")).isEqualTo(true);
    assertThat(attributeValueAt(ehrStatus, "subject/external_ref/id/value")).isEqualTo("10101010-1010-1010-1010-101010101010");
}
Also used : EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) Test(org.junit.Test)

Example 14 with EhrStatus

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

the class EhrComparator method compare.

public Object compare(Map<String, Object> actualEhrMap) {
    String type = (String) actualEhrMap.get("_type");
    HierObjectId ehrId = (HierObjectId) toRmObject((Map<String, Object>) actualEhrMap.get("ehr_id"), HierObjectId.class);
    EhrStatus ehrStatus = (EhrStatus) toRmObject((Map<String, Object>) actualEhrMap.get("ehr_status"), EhrStatus.class);
    HierObjectId systemId = (HierObjectId) toRmObject((Map<String, Object>) actualEhrMap.get("system_id"), HierObjectId.class);
    DvDateTime timeCreated = (DvDateTime) toRmObject((Map<String, Object>) actualEhrMap.get("time_created"), DvDateTime.class);
    // high level attributes
    assertThat(type).isEqualTo("EHR");
    new CompareCanonicalHierObjects(ehrId).isExpectedEqualToCanonicalUsing(ehrUUID.toString());
    new CompareCanonicalHierObjects(systemId).isExpectedEqualToCanonicalUsing("local.ehrbase.org");
    new CompareCanonicalDvDateTime(timeCreated).setCompareDateOnly(true).isExpectedEqualToCanonicalUsing(transactionDateTime);
    EhrStatusComparator.compare(ehrStatus, referenceEhrStatus);
    return null;
}
Also used : EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) CompareCanonicalDvDateTime(org.ehrbase.client.openehrclient.defaultrestclient.systematic.comparator.datetime.CompareCanonicalDvDateTime) Map(java.util.Map) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) CompareCanonicalDvDateTime(org.ehrbase.client.openehrclient.defaultrestclient.systematic.comparator.datetime.CompareCanonicalDvDateTime)

Example 15 with EhrStatus

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

the class EhrStatusComparator method compare.

public static void compare(Map<String, Object> actualEhrStatusMap, EhrStatus referenceEhrStatus) {
    EhrStatus ehrStatus = (EhrStatus) toRmObject(actualEhrStatusMap, EhrStatus.class);
    compare(ehrStatus, referenceEhrStatus);
}
Also used : EhrStatus(com.nedap.archie.rm.ehr.EhrStatus)

Aggregations

EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)23 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)12 UUID (java.util.UUID)11 PartySelf (com.nedap.archie.rm.generic.PartySelf)9 DvText (com.nedap.archie.rm.datavalues.DvText)8 PartyRef (com.nedap.archie.rm.support.identification.PartyRef)7 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)6 InvalidApiParameterException (org.ehrbase.api.exception.InvalidApiParameterException)5 ObjectNotFoundException (org.ehrbase.api.exception.ObjectNotFoundException)5 HttpHeaders (org.springframework.http.HttpHeaders)5 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)4 URI (java.net.URI)4 InternalServerException (org.ehrbase.api.exception.InternalServerException)4 Test (org.junit.Test)4 MediaType (org.springframework.http.MediaType)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 Timestamp (java.sql.Timestamp)3 Optional (java.util.Optional)3 EhrService (org.ehrbase.api.service.EhrService)3 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)3