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());
}
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);
}
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");
}
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;
}
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);
}
Aggregations