Beispiel #1
0
 // Process a DICOM file.
 private void process(DicomObject dicomObject) {
   try {
     dicomObject.setExtension(".dcm");
     // get the document for this study or create it if necessary
     MircDocument td = new MircDocument(dicomObject);
     // Put in the object and store the updated document.
     // Note that since all http imports should have been
     // anonymized before transmission over the internet,
     // we assume that is the case. There is no way to tell.
     td.insert(dicomObject, TrialConfig.allowOverwrite(), true, null, null);
     // export the image via DICOM if in auto mode
     dicomExportDirectories = TrialConfig.getDicomExportDirectories();
     dicomExportDirectoryFiles = TrialConfig.getDicomExportDirectoryFiles();
     if (TrialConfig.getDicomExportMode().equals("auto") && (dicomExportDirectoryFiles != null)) {
       for (int i = 0; i < dicomExportDirectoryFiles.length; i++) {
         try {
           ExportQueueElement eqe = ExportQueueElement.createEQE(dicomObject);
           eqe.queue(dicomExportDirectoryFiles[i]);
         } catch (Exception e) {
           String name = dicomObject.getFile().getName();
           Log.message(
               processorServiceName
                   + ": "
                   + dicomExportDirectories[i]
                   + " DICOM export failed:"
                   + name);
           logger.warn(dicomExportDirectories[i] + " DICOM export failed:" + name);
         }
       }
     }
     // log the object if logging is enabled
     makeTrialLogEntry("http-import", dicomObject);
   } catch (Exception notDicom) {
   }
 }
Beispiel #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());
 }