use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class StudyMgtRS method updateSeries.
@PUT
@Path("/studies/{study}/series/{series}")
@Consumes("application/dicom+json,application/json")
@Produces("application/json")
public StreamingOutput updateSeries(@PathParam("study") String studyUID, @PathParam("series") String seriesUID, InputStream in) {
logRequest();
ArchiveAEExtension arcAE = getArchiveAE();
final Attributes attrs = toAttributes(in);
IDWithIssuer patientID = IDWithIssuer.pidOf(attrs);
if (patientID == null || !attrs.containsValue(Tag.SeriesInstanceUID))
throw new WebApplicationException(errResponse("Missing Patient ID or Series Instance UID in request payload", Response.Status.BAD_REQUEST));
if (!seriesUID.equals(attrs.getString(Tag.SeriesInstanceUID)))
throw new WebApplicationException(errResponse("Series UID in request does not match Series UID in request payload", Response.Status.BAD_REQUEST));
Patient patient = patientService.findPatient(patientID);
if (patient == null)
throw new WebApplicationException(errResponse("Patient[id=" + patientID + "] does not exist.", Response.Status.NOT_FOUND));
try {
StudyMgtContext ctx = studyService.createStudyMgtContextWEB(HttpServletRequestInfo.valueOf(request), arcAE.getApplicationEntity());
ctx.setPatient(patient);
ctx.setAttributes(attrs);
ctx.setStudyInstanceUID(studyUID);
ctx.setSeriesInstanceUID(seriesUID);
studyService.updateSeries(ctx);
rsForward.forward(RSOperation.UpdateSeries, arcAE, attrs, request);
return out -> {
try (JsonGenerator gen = Json.createGenerator(out)) {
arcAE.encodeAsJSONNumber(new JSONWriter(gen)).write(attrs);
}
};
} catch (StudyMissingException e) {
throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.NOT_FOUND));
} catch (PatientMismatchException e) {
throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.BAD_REQUEST));
} catch (Exception e) {
throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class StudyMgtRS method deleteStudy.
@DELETE
@Path("/studies/{StudyUID}")
public void deleteStudy(@PathParam("StudyUID") String studyUID, @QueryParam("retainObj") @Pattern(regexp = "true|false") @DefaultValue("false") String retainObj) {
logRequest();
ArchiveAEExtension arcAE = getArchiveAE();
try {
deletionService.deleteStudy(studyUID, HttpServletRequestInfo.valueOf(request), arcAE, Boolean.parseBoolean(retainObj));
rsForward.forward(RSOperation.DeleteStudy, arcAE, null, request);
} catch (StudyNotFoundException e) {
throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.NOT_FOUND));
} catch (StudyNotEmptyException e) {
throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.FORBIDDEN));
} catch (Exception e) {
throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class StudyMgtRS method moveStudyToPatient.
@POST
@Path("/studies/{study}/patient")
public Response moveStudyToPatient(@PathParam("study") String studyUID, @QueryParam("updatePolicy") @ValidValueOf(type = Attributes.UpdatePolicy.class, message = "Invalid attribute update policy") String updatePolicy) {
logRequest();
ArchiveAEExtension arcAE = getArchiveAE();
QueryAttributes queryAttrs = new QueryAttributes(uriInfo, null);
Attributes queryKeys = queryAttrs.getQueryKeys();
if (queryKeys.getString(Tag.PatientID) == null)
return errResponse("Missing Patient ID in query filters", Response.Status.BAD_REQUEST);
IDWithIssuer pid = IDWithIssuer.pidOf(queryKeys);
try {
PatientMgtContext ctx = patientService.createPatientMgtContextWEB(HttpServletRequestInfo.valueOf(request));
ctx.setAttributeUpdatePolicy(Attributes.UpdatePolicy.REPLACE);
ctx.setPatientID(pid);
ctx.setAttributes(queryKeys);
if (updatePolicy != null)
ctx.setAttributeUpdatePolicy(Attributes.UpdatePolicy.valueOf(updatePolicy));
studyService.moveStudyToPatient(studyUID, ctx);
rsForward.forward(RSOperation.MoveStudyToPatient, arcAE, null, request);
return Response.noContent().build();
} catch (StudyMissingException e) {
return errResponse(e.getMessage(), Response.Status.BAD_REQUEST);
} catch (NonUniquePatientException e) {
return errResponse(e.getMessage(), Response.Status.CONFLICT);
} catch (PatientMergedException e) {
return errResponse(e.getMessage(), Response.Status.FORBIDDEN);
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class ApplyRetentionPolicy method applyRetentionPolicy.
@POST
@Path("/series")
@Produces("application/json")
public Response applyRetentionPolicy() {
ApplicationEntity ae = device.getApplicationEntity(aet, true);
if (ae == null || !ae.isInstalled())
return errResponse("No such Application Entity: " + aet, Response.Status.NOT_FOUND);
try {
int count;
ArchiveAEExtension arcAE = ae.getAEExtensionNotNull(ArchiveAEExtension.class);
QueryContext ctx = queryContext(ae);
try (Query query = queryService.createQuery(ctx)) {
int queryMaxNumberOfResults = ctx.getArchiveAEExtension().queryMaxNumberOfResults();
if (queryMaxNumberOfResults > 0 && !ctx.containsUniqueKey() && query.fetchCount() > queryMaxNumberOfResults)
return errResponse("Request entity too large", Response.Status.BAD_REQUEST);
ExpireSeries es = new ExpireSeries(ae, query);
runInTx.execute(es);
count = es.getCount();
}
rsForward.forward(RSOperation.ApplyRetentionPolicy, arcAE, null, request);
return Response.ok("{\"count\":" + count + '}').build();
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class HL7PSUScheduler method onStore.
public void onStore(@Observes StoreContext ctx) {
if (ctx.getException() != null || ctx.getLocations().isEmpty() || ctx.getRejectionNote() != null)
return;
StoreSession session = ctx.getStoreSession();
ArchiveAEExtension arcAE = session.getArchiveAEExtension();
if (arcAE.hl7PSUOnStudy() && arcAE.hl7PSUConditions().match(session.getRemoteHostName(), session.getCallingAET(), session.getLocalHostName(), session.getCalledAET(), ctx.getAttributes())) {
try {
ejb.createOrUpdateHL7PSUTaskForStudy(arcAE, ctx);
} catch (Exception e) {
LOG.warn("{}: Failed to create or update HL7PSUTask:\n", ctx, e);
}
}
}
Aggregations