use of org.ehrbase.rest.ehrscape.responsedata.ActionRestResponseData in project ehrbase by ehrbase.
the class CompositionController method update.
@PutMapping(path = "/{uid}")
public ResponseEntity<ActionRestResponseData> update(@PathVariable("uid") String compositionUid, @RequestParam(value = "format", defaultValue = "XML") CompositionFormat format, @RequestParam(value = "templateId", required = false) String templateId, @RequestBody String content) {
if ((format == CompositionFormat.FLAT || format == CompositionFormat.STRUCTURED || format == CompositionFormat.ECISFLAT) && StringUtils.isEmpty(templateId)) {
throw new InvalidApiParameterException(String.format("Template Id needs to specified for format %s", format));
}
ObjectVersionId objectVersionId = getObjectVersionId(compositionUid);
UUID compositionIdentifier = getCompositionIdentifier(compositionUid);
UUID ehrId = getEhrId(compositionIdentifier);
var compoObj = compositionService.buildComposition(content, format, templateId);
// Actual update
Optional<CompositionDto> dtoOptional = compositionService.update(ehrId, objectVersionId, compoObj);
var compositionVersionUid = dtoOptional.orElseThrow(() -> new InternalServerException("Failed to create composition")).getComposition().getUid().toString();
ActionRestResponseData responseData = new ActionRestResponseData();
responseData.setAction(Action.UPDATE);
responseData.setMeta(buildMeta(compositionVersionUid));
return ResponseEntity.ok(responseData);
}
use of org.ehrbase.rest.ehrscape.responsedata.ActionRestResponseData in project ehrbase by ehrbase.
the class CompositionController method delete.
@DeleteMapping(path = "/{uid}")
public ResponseEntity<ActionRestResponseData> delete(@PathVariable("uid") String compositionUid) {
ObjectVersionId objectVersionId = getObjectVersionId(compositionUid);
UUID compositionIdentifier = getCompositionIdentifier(compositionUid);
UUID ehrId = getEhrId(compositionIdentifier);
compositionService.delete(ehrId, objectVersionId);
ActionRestResponseData responseData = new ActionRestResponseData();
responseData.setAction(Action.DELETE);
responseData.setMeta(buildMeta(""));
return ResponseEntity.ok(responseData);
}
Aggregations