use of org.dcm4chee.arc.conf.RSOperation in project dcm4chee-arc-light by dcm4che.
the class PamRS method updatePatient.
@PUT
@Path("/patients/{priorPatientID}")
@Consumes("application/dicom+json,application/json")
public void updatePatient(@PathParam("priorPatientID") IDWithIssuer priorPatientID, @QueryParam("merge") @Pattern(regexp = "true|false") @DefaultValue("false") String merge, InputStream in) {
ArchiveAEExtension arcAE = getArchiveAE();
PatientMgtContext ctx = patientMgtCtx(in);
ctx.setArchiveAEExtension(arcAE);
IDWithIssuer targetPatientID = ctx.getPatientID();
if (targetPatientID == null)
throw new WebApplicationException(errResponse("missing Patient ID in message body", Response.Status.BAD_REQUEST));
boolean mergePatients = Boolean.parseBoolean(merge);
boolean patientMatch = priorPatientID.equals(targetPatientID);
if (patientMatch && mergePatients)
throw new WebApplicationException(errResponse("Circular Merge of Patients not allowed.", Response.Status.BAD_REQUEST));
RSOperation rsOp = RSOperation.CreatePatient;
String msgType = "ADT^A28^ADT_A05";
try {
if (patientMatch) {
patientService.updatePatient(ctx);
if (ctx.getEventActionCode().equals(AuditMessages.EventActionCode.Update)) {
rsOp = RSOperation.UpdatePatient;
msgType = "ADT^A31^ADT_A05";
}
} else {
ctx.setPreviousAttributes(priorPatientID.exportPatientIDWithIssuer(null));
if (mergePatients) {
msgType = "ADT^A40^ADT_A39";
rsOp = RSOperation.MergePatient2;
patientService.mergePatient(ctx);
} else {
msgType = "ADT^A47^ADT_A30";
rsOp = RSOperation.ChangePatientID2;
patientService.changePatientID(ctx);
}
}
if (ctx.getEventActionCode().equals(AuditMessages.EventActionCode.Read))
return;
rsForward.forward(rsOp, arcAE, ctx.getAttributes(), request);
notifyHL7Receivers(msgType, ctx);
} catch (PatientAlreadyExistsException | NonUniquePatientException | PatientTrackingNotAllowedException | CircularPatientMergeException e) {
throw new WebApplicationException(errResponse(e.getMessage(), Response.Status.CONFLICT));
} catch (PatientMergedException 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.RSOperation in project dcm4chee-arc-light by dcm4che.
the class RSClientImpl method request.
@Override
public Outcome request(String rsOp, String requestURI, String requestQueryString, String webAppName, String patientID, boolean tlsAllowAnyHostname, boolean tlsDisableTrustManager, byte[] content) throws Exception {
RSOperation rsOperation = RSOperation.valueOf(rsOp);
WebApplication webApplication;
Task.Status status = Task.Status.WARNING;
try {
webApplication = iWebAppCache.findWebApplication(webAppName);
} catch (Exception e) {
LOG.warn(e.getMessage());
return new Outcome(status, "No such Web Application found: " + webAppName);
}
String targetURI = targetURI(rsOperation, requestURI, webApplication, patientID);
if (targetURI == null)
return new Outcome(status, "Target URL not available.");
if (targetURI.equals(requestURI))
return new Outcome(status, "Target URL same as Source Request URL!");
if (requestQueryString != null)
targetURI += "?" + requestQueryString;
Response response = toResponse(getMethod(rsOperation), targetURI, tlsAllowAnyHostname, tlsDisableTrustManager, content, accessTokenFromWebApp(webApplication));
Outcome outcome = buildOutcome(Response.Status.fromStatusCode(response.getStatus()), response.getStatusInfo());
response.close();
return outcome;
}
Aggregations