How to delete a Study from dcm4chee

55 views Asked by At

I have to delete Dicom Studies from the PACS dcm4chee (files also must be deleted). Currently my code works fine, it executes two methods in sequence to delete a study:

public void deleteStudyByPatientIdAndStudyUid(String studyInstanceUid) {
    this.pacsClient.moveToTrashStudyByPatientIdAndStudyUid(studyInstanceUid);
    this.pacsClient.deleteFromTrashStudyByPatientIdAndStudyUid(studyInstanceUid);
}



 public void moveToTrashStudyByPatientIdAndStudyUid(String studyUid) {
    var qidoUrl = this.baseUrlForPacsAeTitle;
    final HttpURLConnection connection;
    try {
        qidoUrl = qidoUrl + "/studies/" + studyUid + "/reject/113039%5EDCM"; // 113039^DCM
        connection = (HttpURLConnection) new URL(qidoUrl).openConnection();
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setRequestMethod("POST");
        var respCode = connection.getResponseCode();
        log.debug("moveToTrashStudyByPatientIdAndStudyUid response code {} {}", respCode, studyUid);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

/**
 * dcm4chee docu: See http://mytaxon.smart-api.info/ui/be87344696148a41f577aca202ce84df#/IOCM-RS/DeleteStudy
 */
public void deleteFromTrashStudyByPatientIdAndStudyUid(String studyUid) {
    var qidoUrl = this.baseUrlForPacsAeTitleFullPathForDelete;
    final HttpURLConnection connection;
    try {
        qidoUrl = qidoUrl + "/studies/" + studyUid;
        connection = (HttpURLConnection) new URL(qidoUrl).openConnection();
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setRequestMethod("DELETE");
        var respCode = connection.getResponseCode();
        log.debug("deleteToTrashStudyByPatientIdAndStudyUid response code {} {}", respCode, studyUid);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}

Question 1: It this the correct way?

Question 2: I am worried that the second call could fail. I there a query to retrieve all rejected studies?

0

There are 0 answers