Example #1
0
 /**
  * The DicomEventListener implementation. Listen for an event from the SCP, log the file, and move
  * it to the dicom-import directory for anonymization and export.
  *
  * @param event the event identifying the file that was received.
  */
 public void dicomEventOccurred(DicomEvent event) {
   if ((event.getStatus() == 0)
       && event.serviceAsString(event.getService()).equals("C_STORE_RQ")) {
     File inFile = new File(event.getFilename());
     Log.message(dicomImportServiceName + ": Image received: " + inFile.getName());
     // Make the output directory in case it doesn't exist.
     File outDir = new File(TrialConfig.basepath + TrialConfig.dicomImportDir);
     outDir.mkdirs();
     // Put the new file in it, using the overwrite attribute of the trial to determine
     // whether duplicate SOPInstanceUIDs are to be renamed so as not to lose them.
     FileObject fileObject = new FileObject(inFile);
     fileObject.moveToDirectory(outDir, TrialConfig.allowOverwrite());
   } else if (event.getStatus() != 0xff00)
     Log.message(dicomImportServiceName + ": unexpected status: " + event.toStringNoPath());
 }
Example #2
0
 // Create a Log4J log file with a monthly rolling appender and populate
 // it with information from the dataset in a csv format so the log file
 // can be opened and processed with a spreadsheet.
 private void makeTrialLogEntry(String service, DicomObject dicomObject) {
   if (!TrialConfig.log()) return;
   if (processorLog == null) {
     try {
       processorLog = Logger.getLogger("trial");
       processorLog.setAdditivity(false);
       PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd},%d{HH:mm:ss},%m%n");
       File logs = new File(TrialConfig.basepath + TrialConfig.logDirectory);
       logs.mkdirs();
       DailyRollingFileAppender appender =
           new DailyRollingFileAppender(
               layout,
               TrialConfig.basepath
                   + TrialConfig.logDirectory
                   + File.separator
                   + TrialConfig.serviceName
                   + ".csv",
               "'.'yyyy-MM");
       processorLog.addAppender(appender);
       processorLog.setLevel((Level) Level.ALL);
     } catch (Exception e) {
       logger.warn("Unable to instantiate a trial logger");
       processorLog = null;
       return;
     }
   }
   processorLog.info(
       service
           + ","
           + dicomObject.getPatientName()
           + ","
           + dicomObject.getPatientID()
           + ","
           + dicomObject.getModality()
           + ","
           + dicomObject.getSeriesNumber()
           + ","
           + dicomObject.getAcquisitionNumber()
           + ","
           + dicomObject.getInstanceNumber());
 }