diff --git a/pom.xml b/pom.xml
index 70e15300..3dd59957 100644
--- a/pom.xml
+++ b/pom.xml
@@ -185,179 +185,90 @@
-
-
-
-net.imagej
-
-ij
-
-1.51s
-
-
-
-
-
-
-org.kie.modules
-
-org-apache-commons-lang3
-
-6.5.0.Final
-
-pom
-
-
-
-
-
-
-org.apache.commons
-
-commons-io
-
-1.3.2
-
-
-
-
-
-
-com.github.stephenc.java-iso-tools
-
-sabre
-
-2.0.1
-
-
-
-
-
-
-com.googlecode.json-simple
-
-json-simple
-
-1.1
-
-
-
-
-
-
-com.google.code.gson
-
-gson
-
-2.8.5
-
-
-
-
-
-
-com.github.stephenc.java-iso-tools
-
-iso9660-writer
-
-2.0.1
-
-
-
-
-
-
-com.github.lookfirst
-
-sardine
-
-5.7
-
-
-
-
-
-
-commons-vfs
-
-commons-vfs
-
-20050307052300
-
-
-
-
-
-
-commons-net
-
-commons-net
-
-3.6
-
-
-
-
-
-
-org.apache.commons
-
-commons-vfs2
-
-2.2
-
-
-
-
-
-
-org.apache.commons
-
-commons-csv
-
-1.5
-
-
-
-
-
-
-com.michaelbaranov
-
-microba
-
-0.4.4.3
-
-
-
-
-
-
-mysql
-
-mysql-connector-java
-
-5.1.14
-
-
-
-
-
-
-net.sf.packtag
-
-packtag-core
-
-3.8
-
-
-
-
- com.vnetpublishing.java
- super-user-application
- 0.0.5
-
-
+
+ net.imagej
+ ij
+ 1.51s
+
+
+
+ org.apache.commons
+ commons-io
+ 1.3.2
+
+
+
+ com.github.stephenc.java-iso-tools
+ sabre
+ 2.0.1
+
+
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1
+
+
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
+
+
+ com.github.stephenc.java-iso-tools
+ iso9660-writer
+ 2.0.1
+
+
+
+ com.github.lookfirst
+ sardine
+ 5.7
+
+
+
+ commons-net
+ commons-net
+ 3.6
+
+
+
+ org.apache.commons
+ commons-vfs2
+ 2.2
+
+
+
+ org.apache.commons
+ commons-csv
+ 1.5
+
+
+
+ com.michaelbaranov
+ microba
+ 0.4.4.3
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.14
+
+
+
+ net.sf.packtag
+ packtag-core
+ 3.8
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.8.1
+
+
\ No newline at end of file
diff --git a/src/Orthanc_Standalone/Orthanc.json b/src/Orthanc_Standalone/Orthanc.json
index 1d53a77a..d66916fe 100644
--- a/src/Orthanc_Standalone/Orthanc.json
+++ b/src/Orthanc_Standalone/Orthanc.json
@@ -40,7 +40,7 @@
// folders, in which case they will be scanned non-recursively to
// find shared libraries. Backslashes must be either escaped by
// doubling them, or replaced by forward slashes "/".
- "Plugins" : [
+ "Plugins" : ["./"
],
// Maximum number of processing jobs that are simultaneously running
diff --git a/src/Run_Pet_Ct.java b/src/Run_Pet_Ct.java
new file mode 100644
index 00000000..8cde8b4e
--- /dev/null
+++ b/src/Run_Pet_Ct.java
@@ -0,0 +1,40 @@
+
+
+import java.util.ArrayList;
+
+import ij.IJ;
+import ij.ImageJ;
+import ij.ImagePlus;
+
+public class Run_Pet_Ct {
+
+
+ public Run_Pet_Ct(ArrayList imagePlusList) {
+ String seriesUIDs = ChoosePetCt.buildSeriesUIDs(imagePlusList);
+ if( seriesUIDs == null) return;
+ if( seriesUIDs.startsWith("2CTs")) seriesUIDs = "";
+ IJ.runPlugIn("Pet_Ct_Viewer", seriesUIDs);
+ wait4bkgd();
+ }
+
+ private void wait4bkgd() {
+ Integer i = 0, j;
+ while( ChoosePetCt.loadingData == 1 || ChoosePetCt.loadingData == 3) {
+ mySleep(200);
+ i++;
+ if( (i % 20) == 0 && ChoosePetCt.loadingData == 1) {
+ ImageJ ij = IJ.getInstance();
+ if( ij != null) ij.toFront();
+ j = i/5;
+ IJ.showStatus("Loading data, please wait " + j.toString());
+ }
+ }
+ }
+
+ private void mySleep(int msec) {
+ try {
+ Thread.sleep(msec);
+ } catch (Exception e) { e.printStackTrace();}
+ }
+
+}
diff --git a/src/org/petctviewer/orthanc/CTP/CTP.java b/src/org/petctviewer/orthanc/CTP/CTP.java
index c695e60a..f4105a11 100644
--- a/src/org/petctviewer/orthanc/CTP/CTP.java
+++ b/src/org/petctviewer/orthanc/CTP/CTP.java
@@ -6,10 +6,13 @@
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
+import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import javax.swing.JOptionPane;
+
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@@ -27,11 +30,32 @@ public CTP(String username, String password, String serverAdress) {
this.username=username;
this.password=password;
this.serverAdress=serverAdress;
- getAvailableStudies();
//String authentication = Base64.getEncoder().encodeToString(("httpLogin" + ":" + "httpPassword").getBytes());
}
+ public boolean checkLogin() {
+ JSONObject jsonPost=new JSONObject();
+ jsonPost.put("username", username);
+ jsonPost.put("password", password);
+ String answser=makePostConnection("/Rest_Api/check_login.php",jsonPost.toString());
+ System.out.println(answser);
+ JSONObject response = null;
+ try {
+ response=(JSONObject) parser.parse(answser);
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if(!response.get("login").equals("Allowed") ) {
+ JOptionPane.showMessageDialog(null, response.get("login").toString(), "Login Error", JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+
+ return true;
+
+ }
+
@SuppressWarnings("unchecked")
public String[] getAvailableStudies(){
JSONObject jsonPost=new JSONObject();
@@ -42,7 +66,7 @@ public String[] getAvailableStudies(){
String answser=makePostConnection("/Rest_Api/get-studies.php",jsonPost.toString());
System.out.println(answser);
studies=(JSONArray) parser.parse(answser);
- } catch (IOException | ParseException e) {
+ } catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@@ -66,7 +90,7 @@ public String[] getAvailableVisits(String studyName) {
try {
String answser=makePostConnection("/Rest_Api/get-visits.php",jsonPost.toString());
visits=(JSONArray) parser.parse(answser);
- } catch (IOException | ParseException e) {
+ } catch ( ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@@ -96,7 +120,7 @@ public JSONArray getAvailableImports(String studyName, String visitName) {
try {
String answser=makePostConnection("/Rest_Api/get-possible-import.php", jsonPost.toString());
visits=(JSONArray) parser.parse(answser);
- } catch (IOException | ParseException e) {
+ } catch ( ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@@ -120,13 +144,16 @@ public boolean validateUpload(JSONArray studiesArray) {
System.out.println(jsonPost.toString());
JSONObject visits = null;
+
+ String answser=makePostConnection("/Rest_Api/validate-upload.php", jsonPost.toString());
+ System.out.println(answser);
try {
- String answser=makePostConnection("/Rest_Api/validate-upload.php", jsonPost.toString());
- System.out.println(answser);
visits=(JSONObject) parser.parse(answser);
- } catch (IOException | ParseException e) {
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
e.printStackTrace();
}
+
return (boolean) visits.get("recivedConfirmation");
@@ -134,39 +161,42 @@ public boolean validateUpload(JSONArray studiesArray) {
}
- private String makePostConnection(String apiUrl, String post) throws IOException {
+ private String makePostConnection(String apiUrl, String post) {
URL url = null;
+ StringBuilder sb=new StringBuilder();
try {
- url = new URL(serverAdress+apiUrl);
- } catch ( MalformedURLException ex) { }
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setDoOutput(true);
- conn.setRequestMethod("POST");
- if((serverAdress != null && serverAdress.contains("https")) ){
- try{
- HttpsTrustModifier.Trust(conn);
- }catch (Exception e){
- throw new IOException("Cannot allow self-signed certificates");
+ url = new URL(serverAdress+apiUrl);
+
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+ conn.setRequestMethod("POST");
+ if((serverAdress != null && serverAdress.contains("https")) ){
+ try{
+ HttpsTrustModifier.Trust(conn);
+ }catch (Exception e){
+
+ }
}
- }
- if(this.authentication != null){
- conn.setRequestProperty("Authorization", "Basic " + this.authentication);
- }
- OutputStream os = conn.getOutputStream();
- os.write(post.getBytes());
- os.flush();
- conn.getResponseMessage();
-
- StringBuilder sb=new StringBuilder();
- if (conn !=null) {
- BufferedReader br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- String output;
- while ((output = br.readLine()) != null) {
- sb.append(output);
+ if(this.authentication != null){
+ conn.setRequestProperty("Authorization", "Basic " + this.authentication);
}
- conn.disconnect();
- }
+ OutputStream os = conn.getOutputStream();
+ os.write(post.getBytes());
+ os.flush();
+ conn.getResponseMessage();
+
+
+ if (conn !=null) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ (conn.getInputStream())));
+ String output;
+ while ((output = br.readLine()) != null) {
+ sb.append(output);
+ }
+ conn.disconnect();
+ }
+ } catch ( IOException ex) { };
+
return sb.toString();
}
diff --git a/src/org/petctviewer/orthanc/CTP/CTP_Gui.java b/src/org/petctviewer/orthanc/CTP/CTP_Gui.java
index 31e6a9ad..826c341b 100644
--- a/src/org/petctviewer/orthanc/CTP/CTP_Gui.java
+++ b/src/org/petctviewer/orthanc/CTP/CTP_Gui.java
@@ -195,12 +195,19 @@ public void actionPerformed(ActionEvent arg0) {
comboBox_Visits.removeAllItems();
if (tablePatient.getModel().getRowCount()>0) modelTablePatient.setRowCount(0);
ctp=new CTP(CTP_Username.getText(), new String(CTP_Password.getPassword()), CTPAddress );
- String[] studies=ctp.getAvailableStudies();
- comboBox_Studies.addItem("Choose");
- for (int i=0; i/biplugins");
+ //private Preferences jprefer = Preferences.userRoot().node("/biplugins");
private Preferences jpreferPerso = Preferences.userRoot().node("/queryplugin");
private String fullAddress;
private String authentication;
@@ -52,11 +53,12 @@ public class ParametreConnexionHttp {
public ParametreConnexionHttp() {
- int curDb = jprefer.getInt("current database", 0);
- int typeDb = jprefer.getInt("db type" + curDb, 0);
+ //int curDb = jprefer.getInt("current database", 0);
+ //int typeDb = jprefer.getInt("db type" + curDb, 0);
String ip=null;
String port=null;
+ /*
if(typeDb == 5){
if(!jprefer.get("db path" + curDb, "none").equals("none") && !jprefer.get("db path" + curDb, "none").equals("")){
@@ -83,18 +85,14 @@ public ParametreConnexionHttp() {
authentication = Base64.getEncoder().encodeToString((jprefer.get("db user" + curDb, null) + ":" + jprefer.get("db pass" + curDb, null)).getBytes());
}
+ }*/
+
+ ip = jpreferPerso.get("ip", "http://localhost");
+ port = jpreferPerso.get("port", "8042");
+ this.fullAddress = ip + ":" + port;
+ if(jpreferPerso.get("username", null) != null && jpreferPerso.get("username", null) != null){
+ authentication = Base64.getEncoder().encodeToString((jpreferPerso.get("username", null) + ":" + jpreferPerso.get("password", null)).getBytes());
}
- else if (typeDb != 5 ){
- ip = jpreferPerso.get("ip", "http://localhost");
- port = jpreferPerso.get("port", "8042");
- this.fullAddress = ip + ":" + port;
- if(jpreferPerso.get("username", null) != null && jpreferPerso.get("username", null) != null){
- authentication = Base64.getEncoder().encodeToString((jpreferPerso.get("username", null) + ":" + jpreferPerso.get("password", null)).getBytes());
- }
-
-
- }
- System.out.println(ip+port);
}
@@ -130,6 +128,34 @@ public HttpURLConnection makeGetConnection(String apiUrl) {
return conn;
}
+
+public HttpURLConnection makeGetConnectionImage(String apiUrl) {
+
+ HttpURLConnection conn=null;
+ URL url = null;
+ try {
+ url = new URL(fullAddress+apiUrl);
+ conn = (HttpURLConnection) url.openConnection();
+ conn.setRequestProperty("Accept", "image/png");
+ conn.setDoOutput(true);
+ conn.setRequestMethod("GET");
+ if((fullAddress != null && fullAddress.contains("https"))){
+ HttpsTrustModifier.Trust(conn);
+ }
+ if(authentication != null){
+ conn.setRequestProperty("Authorization", "Basic " + authentication);
+ }
+ conn.getResponseMessage();
+
+ } catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+
+ return conn;
+
+ }
public StringBuilder makeGetConnectionAndStringBuilder(String apiUrl) {
HttpURLConnection conn = null;
@@ -235,6 +261,18 @@ public StringBuilder makePostConnectionAndStringBuilder(String apiUrl, String po
return sb;
}
+ public InputStream openImage(String apiUrl) {
+ HttpURLConnection conn = this.makeGetConnectionImage(apiUrl);
+
+ InputStream is=null;
+
+ try {
+ is = conn.getInputStream();
+ } catch(IOException e) { e.printStackTrace();}
+
+ return is;
+ }
+
public void makeDeleteConnection(String apiUrl) {
URL url = null;
@@ -261,14 +299,6 @@ public void makeDeleteConnection(String apiUrl) {
}
- private int ordinalIndexOf(String str, String substr, int n) {
-
- int pos = str.indexOf(substr);
- while (--n > 0 && pos != -1)
- pos = str.indexOf(substr, pos + 1);
- return pos;
- }
-
// Display Error message if connexion failed
public Boolean testConnexion() {
Boolean test=true;
@@ -295,6 +325,7 @@ public Boolean testConnexion() {
*/
private boolean isVersionAfter131() {
int test=versionCompare(orthancVersion, "1.3.1");
+ System.out.println("testVs1.3.1"+test);
if (test>0) return true; else return false;
}
diff --git a/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java b/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java
index 68fe5ba1..7351ee1d 100644
--- a/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java
+++ b/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java
@@ -39,7 +39,7 @@ public AboutBoxFrame(){
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel labelPanel = new JPanel();
labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
- JLabel title = new JLabel("Dicom Tools v.1.1");
+ JLabel title = new JLabel("Dicom Tools v.1.2");
title.setBorder(new EmptyBorder(3, 150, 3, 150));
labelPanel.add(title);
JLabel orthancSite = new JLabel("Based on Orthanc http://www.orthanc-server.com");
diff --git a/src/org/petctviewer/orthanc/anonymize/VueAnon.java b/src/org/petctviewer/orthanc/anonymize/VueAnon.java
index c6bde988..041863f5 100644
--- a/src/org/petctviewer/orthanc/anonymize/VueAnon.java
+++ b/src/org/petctviewer/orthanc/anonymize/VueAnon.java
@@ -39,6 +39,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.lang.reflect.Constructor;
import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
@@ -88,6 +89,7 @@
import com.michaelbaranov.microba.calendar.DatePicker;
+import ij.ImagePlus;
import ij.plugin.PlugIn;
import org.petctviewer.orthanc.*;
@@ -98,6 +100,7 @@
import org.petctviewer.orthanc.importdicom.ImportDCM;
import org.petctviewer.orthanc.monitoring.Monitoring_GUI;
import org.petctviewer.orthanc.query.*;
+import org.petctviewer.orthanc.reader.Read_Orthanc;
import org.petctviewer.orthanc.setup.ConnectionSetup;
import org.petctviewer.orthanc.setup.Run_Orthanc;
@@ -232,6 +235,9 @@ public class VueAnon extends JFrame implements PlugIn, ActionListener{
//CustomListener
AnonymizeListener anonymizeListener;
+ //
+ private boolean fijiEnvironement=false;
+
public VueAnon() {
super("Orthanc Tools");
@@ -1361,11 +1367,96 @@ protected void done() {
c.gridy = 0;
tablesPanel.add(jscp2,c);
+ JPanel panelTableauSeries=new JPanel(new BorderLayout());
JScrollPane jscp3 = new JScrollPane(tableauSeries);
jscp3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
c.gridx = 2;
c.gridy = 0;
- tablesPanel.add(jscp3,c);
+ panelTableauSeries.add(jscp3, BorderLayout.CENTER);
+ JPanel panelButton=new JPanel();
+ JButton btnReadSeries=new JButton("Open Images");
+ btnReadSeries.addActionListener(new ActionListener() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ int[] selectedListes=tableauSeries.getSelectedRows();
+
+ if(selectedListes.length==0) {
+ JOptionPane.showMessageDialog(gui, "Select Series to read", "No series", JOptionPane.ERROR_MESSAGE);
+ }
+ List ids=new ArrayList();
+ ArrayList imagestacks=new ArrayList();
+
+ boolean ct = false;
+ boolean pet = false;
+
+ for( int line : selectedListes) {
+ ids.add((String) tableauSeries.getValueAt(line, 4));
+ if(tableauSeries.getValueAt(line, 1).equals("PT")) pet=true;
+ if(tableauSeries.getValueAt(line, 1).equals("CT")) ct=true;
+
+ }
+
+ boolean startViewer=(pet && ct && fijiEnvironement);
+
+ SwingWorker worker = new SwingWorker(){
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ protected Void doInBackground() {
+ btnReadSeries.setText("Reading Series");
+ for(String id : ids) {
+ Read_Orthanc reader=new Read_Orthanc(connexionHttp);
+ ImagePlus ip=reader.readSerie(id);
+ imagestacks.add(ip);
+
+ }
+
+ if(startViewer) {
+ System.out.println("start viewer");
+ Class Run_Pet_Ct = null;
+ try {
+ Run_Pet_Ct = Class.forName("Run_Pet_Ct");
+ } catch (ClassNotFoundException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ try {
+ Constructor cs=Run_Pet_Ct.getDeclaredConstructor(ArrayList.class);
+ cs.newInstance(imagestacks);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+
+
+ return null;
+ }
+
+ @Override
+ public void done(){
+ btnReadSeries.setText("Open Images");
+
+ }
+ };
+
+ worker.execute();
+
+
+
+
+ }
+
+
+
+ });
+ panelButton.add(btnReadSeries);
+ panelTableauSeries.add(panelButton, BorderLayout.EAST);
+ tablesPanel.add(panelTableauSeries,c);
mainPanel.add(tablesPanel);
mainPanel.add(toolbox);
@@ -2953,9 +3044,9 @@ public static void main(String... args){
@Override
public void run(String string) {
- VueAnon anon=new VueAnon();
- anon.setLocationRelativeTo(null);
- anon.setVisible(true);
+ setLocationRelativeTo(null);
+ this.setVisible(true);
+ fijiEnvironement=true;
}
diff --git a/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java b/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java
index 2e5d9141..fa37be84 100644
--- a/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java
+++ b/src/org/petctviewer/orthanc/ctpimport/CTP_Import_GUI.java
@@ -52,7 +52,7 @@ public CTP_Import_GUI() {
listePeers.setVisible(false);
listeAETExport.setVisible(false);
- addressFieldCTP.setText("http://kanoun.fr/");
+ addressFieldCTP.setText("https://kanoun.fr/");
importCTP.addActionListener(new ActionListener() {
diff --git a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java
index 05e2f98c..3261820c 100644
--- a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java
+++ b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java
@@ -39,6 +39,8 @@
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
@SuppressWarnings("serial")
public class Burner_Settings extends JDialog {
@@ -60,7 +62,9 @@ public class Burner_Settings extends JDialog {
private String fijiDirectory;
private String burnerManifacturer;
private String suportType;
+ private JSpinner spinnerTiming;
private Boolean deleteStudies;
+ private int monitoringTime;
private JComboBox comboBoxSupportType, comboBoxBurnerManufacturer;
/**
@@ -240,6 +244,7 @@ public void actionPerformed(ActionEvent e) {
jPrefer.put("suportType", comboBoxSupportType.getSelectedItem().toString());
//On ajoute la string du format date
jPrefer.put("DateFormat", buttonGroup.getSelection().getActionCommand());
+ jPrefer.putInt("monitoringTime", (int) spinnerTiming.getValue());
//on dispose
dispose();
}
@@ -270,6 +275,21 @@ public void actionPerformed(ActionEvent arg0) {
comboBoxBurnerManufacturer.setSelectedItem(burnerManifacturer);
}
}
+ {
+ JLabel lblMonitorEachsec = new JLabel("Monitor Each (sec)");
+ lblMonitorEachsec.setHorizontalAlignment(SwingConstants.CENTER);
+ contentPanel.add(lblMonitorEachsec);
+ }
+ {
+ JPanel panel = new JPanel();
+ contentPanel.add(panel);
+
+ spinnerTiming = new JSpinner();
+ spinnerTiming.setModel(new SpinnerNumberModel(new Integer(90), new Integer(10), null, new Integer(1)));
+ spinnerTiming.setValue(monitoringTime);
+ panel.add(spinnerTiming);
+
+ }
}
@@ -282,6 +302,7 @@ public void setCDPreference() {
dateFormatChoix=jPrefer.get("DateFormat", null);
deleteStudies=jPrefer.getBoolean("deleteStudies", false);
suportType=jPrefer.get("suportType", "Auto");
+ monitoringTime=jPrefer.getInt("monitoringTime", 90);
}
diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java
index ff5db6db..627c6c8c 100644
--- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java
+++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java
@@ -35,12 +35,13 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.prefs.Preferences;
+import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.petctviewer.orthanc.ParametreConnexionHttp;
@@ -57,6 +58,7 @@ public class CD_Burner {
private String labelFile;
private String epsonDirectory;
private String fijiDirectory;
+ private int monitoringTime;
private Boolean deleteStudies;
private String suportType;
private JTable table_burning_history;
@@ -109,7 +111,7 @@ public void run() {
//running timer task as daemon thread
timer = new Timer(true);
//Toutes les 90 seconds
- timer.scheduleAtFixedRate(timerTask, 0, (90*1000));
+ timer.scheduleAtFixedRate(timerTask, 0, (monitoringTime*1000));
}
}
@@ -211,7 +213,7 @@ public void makeCD(List newStableStudyID) {
if (burnerManifacturer.equals("Epson")) {
//Generation du Dat
File dat = printDat(nom, id, formattedDateExamen, studyDescription, accessionNumber, formattedPatientDOB );
- robotRequestFile=createCdBurnerEpson(dat, discType);
+ robotRequestFile=createCdBurnerEpson(dat, discType, nom, formattedDateExamen);
}
@@ -293,35 +295,36 @@ private void unzip(File zipFile){
* @param studyDescription
* @param dat
*/
- private File createCdBurnerEpson(File dat, String discType){
-
+ private File createCdBurnerEpson(File dat, String discType, String name, String formattedStudyDate){
//REalisation du texte pour le Robot
- String txtRobot= "# Making data CD\n"
- //Peut definir le Job ID et le mettre le compteur dans registery si besoin de tracer les operation avec fichier STF
- + "#nombre de copies\n"
- + "COPIES=1\n"
- + "#CD ou DVD\n"
- + "DISC_TYPE="+discType+"\n"
- + "FORMAT=UDF102\n"
- + "DATA="+fijiDirectory+"\n"
- + "DATA="+folder+ File.separator+ "DICOM" +File.separator+"\n"
- + "#Instruction d'impression\n"
- + "LABEL="+labelFile+"\n"
- + "REPLACE_FIELD="+dat.getAbsolutePath().toString();
+ String txtRobot= "# Making data CD\n";
+ //Peut definir le Job ID et le mettre le compteur dans registery si besoin de tracer les operation avec fichier STF
+ if(createJobID(name, formattedStudyDate)!=null) txtRobot+="JOB_ID="+createJobID(name, formattedStudyDate)+"\n";
+ txtRobot+="#nombre de copies\n"
+ + "COPIES=1\n"
+ + "#CD ou DVD\n"
+ + "DISC_TYPE="+discType+"\n"
+ + "FORMAT=UDF102\n"
+ + "DATA="+fijiDirectory+"\n"
+ + "DATA="+folder+ File.separator+ "DICOM" +File.separator+"\n"
+ + "#Instruction d'impression\n"
+ + "LABEL="+labelFile+"\n"
+ + "REPLACE_FIELD="+dat.getAbsolutePath().toString();
+
// On ecrit le fichier JDF
- File f = new File(epsonDirectory + File.separator + "CD_"+dateFormat.format(datenow)+".JDF");
- PrintWriter pw = null;
- try {
- pw = new PrintWriter(f);
- pw.write(txtRobot);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- pw.close();
- }
-
- return f;
+ File f = new File(epsonDirectory + File.separator + "CD_"+dateFormat.format(datenow)+".JDF");
+ PrintWriter pw = null;
+ try {
+ pw = new PrintWriter(f);
+ pw.write(txtRobot);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ pw.close();
+ }
+
+ return f;
}
@@ -335,7 +338,11 @@ private File createCdBurnerEpson(File dat, String discType){
*/
private File createCdBurnerPrimera(String nom, String id, String date, String studyDescription, String accessionNumber, String patientDOB, String discType){
//Command Keys/Values for Primera Robot
- String txtRobot= "Copies = 1\n"
+ String txtRobot=new String();
+
+ if(createJobID(nom, date) != null) txtRobot +="JobID="+createJobID(nom,date)+"\n";
+
+ txtRobot+="Copies = 1\n"
+ "DataImageType = UDF\n"
+ "Data="+fijiDirectory+"\n"
+ "Data="+folder+ File.separator+ "DICOM\n"
@@ -379,9 +386,7 @@ private File createCdBurnerPrimera(String nom, String id, String date, String st
//Creer le fichier DAT pour injecter NOM, Date, Modalite
private File printDat(String nom, String id, String date, String studyDescription, String accessionNumber, String patientDOB) throws ParseException {
-
-
-
+
//On parse le nom pour enlever les ^ et passer le prenom en minuscule
int separationNomPrenom=nom.indexOf("^", 0);
if (separationNomPrenom!=-1) {
@@ -430,6 +435,8 @@ private void updateProgress() throws IOException {
}else if(extension.equals("DON")) {
table_burning_history.setValueAt("Burning Done", rowNubmer, 5);
FileUtils.deleteDirectory(tempFolder);
+ }else if(extension.equals("STP")) {
+ table_burning_history.setValueAt("Paused", rowNubmer, 5);
}
}
}
@@ -438,6 +445,34 @@ private void updateProgress() throws IOException {
+ }
+
+ private String createJobID(String name, String formattedStudyDate) {
+ String lastName = null;
+ String firstName= "";
+ //prepare JOB_ID string.
+ if(name.contains("^")) {
+ String[] names=name.split(Pattern.quote("^"));
+ //Get 10 first character of lastname and first name if input over 10 characters
+ if(names[0].length()>5) lastName=names[0].substring(0, 5); else lastName=names[0];
+ if(names[1].length()>5) firstName=names[1].substring(0, 5); else firstName=names[1];
+
+ }else {
+ if(!StringUtils.isEmpty(name)) {
+ if(name.length()>10) lastName=name.substring(0, 10); else lastName=name;
+ //No name information return null
+ }else {
+ return null;
+ }
+
+ }
+
+ String results=lastName+"_"+firstName+"_"+StringUtils.remove(formattedStudyDate, "/")+"_"+( (int) Math.round(Math.random()*1000));
+ //Remove Accent and space to match requirement of burners
+ results=StringUtils.stripAccents(results);
+ results=StringUtils.deleteWhitespace(results);
+
+ return results;
}
/**
@@ -473,6 +508,7 @@ public void setCDPreference() {
dateFormatChoix=jPrefer.get("DateFormat", null);
deleteStudies=jPrefer.getBoolean("deleteStudies", false);
suportType=jPrefer.get("suportType", "Auto");
+ monitoringTime=jPrefer.getInt("monitoringTime", 90);
}
diff --git a/src/org/petctviewer/orthanc/reader/Read_Orthanc.java b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java
new file mode 100644
index 00000000..0b284bf9
--- /dev/null
+++ b/src/org/petctviewer/orthanc/reader/Read_Orthanc.java
@@ -0,0 +1,254 @@
+package org.petctviewer.orthanc.reader;
+
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Scanner;
+
+import javax.imageio.ImageIO;
+
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.petctviewer.orthanc.ParametreConnexionHttp;
+
+import ij.IJ;
+import ij.ImagePlus;
+import ij.ImageStack;
+import ij.measure.Calibration;
+import ij.process.ColorProcessor;
+import ij.process.ImageProcessor;
+import ij.process.ShortProcessor;
+
+
+public class Read_Orthanc {
+
+ JSONParser parser=new JSONParser();
+ ParametreConnexionHttp connexion;
+
+ public Read_Orthanc(ParametreConnexionHttp connexion) {
+ this.connexion=connexion;
+
+ }
+
+ public ImagePlus readSerie(String uuid) {
+ StringBuilder sb=connexion.makeGetConnectionAndStringBuilder("/series/"+uuid);
+ JSONObject seriesDetails = null;
+ try {
+ seriesDetails=(JSONObject)parser.parse(sb.toString());
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ImageStack stack = null;
+
+ JSONArray instanceIDList=(JSONArray) seriesDetails.get("Instances");
+ boolean screenCapture=false;
+ for(int i=0 ; i tagsIndex = new ArrayList();
+ for (Object tag : tags.keySet()) {
+ tagsIndex.add((String) tag);
+ }
+
+ Collections.sort(tagsIndex);
+ for (String tag : tagsIndex) {
+ JSONObject value = (JSONObject) tags.get(tag);
+ type1 = (String) value.get("Type");
+ if (type1.equals("String")) {
+ info += (tag + " " + (String) value.get("Name")
+ + ": " + (String) value.get("Value") + "\n");
+ } else {
+ if( type1.equals("Sequence")) {
+ info = addSequence(info, value, tag);
+ }
+ }
+ }
+ return info;
+ }
+
+ private int seqDepth = 0;
+
+ private String addSequence(String info0, JSONObject value, Object tag) {
+ String type2, info = info0;
+ JSONArray seq0;
+ JSONObject seqVal, vals;
+ seq0 = (JSONArray)value.get("Value");
+ if( seq0 == null || seq0.isEmpty()) {
+ return info; // ignore empty sequences
+ }
+ info += tag + getIndent() + (String) value.get("Name") +"\n";
+ seqDepth++;
+ seqVal = (JSONObject) seq0.get(0);
+
+ ArrayList tagsIndex = new ArrayList();
+ for( Object tag0 : seqVal.keySet()) {
+ tagsIndex.add((String) tag0);
+ }
+ Collections.sort(tagsIndex);
+
+ for( Object tag1 : tagsIndex) {
+ vals = (JSONObject) seqVal.get(tag1);
+ type2 = (String) vals.get("Type");
+ if( type2.equals("String")) {
+ info += tag1 + getIndent() + (String) vals.get("Name")
+ + ": " + (String) vals.get("Value")+ "\n";
+ } else {
+ if(type2.equals("Sequence")) {
+ info = addSequence(info, vals, tag1);
+ }
+ }
+ }
+ seqDepth--;
+ return info;
+ }
+
+ private String getIndent() {
+ String indent = " ";
+ for( int i=0; i";
+ return indent;
+ }
+
+ private void updateCalibration( ImagePlus img) {
+ String meta=img.getStack().getSliceLabel(1);
+ double[] coeff = new double[2];
+ float[] spacing;
+ String tmp1;
+ tmp1 = getDicomValue(meta, "0028,1052");
+ if( tmp1 == null) return;
+ coeff[0] = Double.parseDouble(tmp1);
+ tmp1 = getDicomValue(meta, "0028,1053");
+ if( tmp1 == null) return;
+ coeff[1] = Double.parseDouble(tmp1);
+ img.getCalibration().setFunction(Calibration.STRAIGHT_LINE, coeff, "Gray Value");
+ tmp1 = getDicomValue(meta, "0028,0030");
+ if( tmp1 == null) return;
+ spacing = parseMultFloat(tmp1);
+ img.getCalibration().pixelWidth = spacing[0];
+ img.getCalibration().pixelHeight = spacing[1];
+ img.getCalibration().setUnit("mm");
+
+ img.setTitle(getDicomValue(meta, "0010,0010")+"-"+getDicomValue(meta, "0008,0022")+"-"+getDicomValue(meta, "0008,0103E"));
+ }
+
+ private String getDicomValue( String meta, String key1) {
+ String tmp1, key2 = key1, ret1 = null;
+ int k1, k0 = 0;
+ if( meta == null) return ret1;
+ if( key1 != null) {
+ k0 = meta.indexOf(key1);
+ if( k0 <= 0) key2 = key1.toLowerCase();
+ k0 = meta.indexOf(key2);
+ }
+ if( k0 > 0 || key2 == null) {
+ // here we have a problem that the key may appear more than once.
+ // for example a SeriesUID may appear in a sequence. Look for ">".
+ if( k0 > 0) {
+ tmp1 = meta.substring(k0+4, k0+16);
+ k1 = tmp1.indexOf(">");
+ while(k1 > 0) { // do search last value
+ k1 = meta.indexOf(key2, k0+4);
+ if( k1 > 0) k0 = k1;
+ }
+ }
+ k1 = meta.indexOf("\n", k0);
+ if( k1 < 0) return null;
+ tmp1 = meta.substring(k0, k1);
+ k1 = tmp1.indexOf(": ");
+ if( k1 > 0) ret1 = tmp1.substring(k1+2);
+ else ret1 = tmp1;
+ ret1 = ret1.trim();
+ if( ret1.isEmpty()) ret1 = null;
+ }
+ return ret1;
+ }
+
+ private float[] parseMultFloat( String tmp1) {
+ float [] ret1 = null;
+ double[] val = new double[32]; // arbitrary limit of 32
+ int i, n = 0;
+ if( tmp1 == null) return null;
+ String tmp2 = tmp1.replace("\\ ", "\\");
+ @SuppressWarnings("resource")
+ Scanner sc = new Scanner(tmp2).useDelimiter("\\\\");
+ sc.useLocale(Locale.US);
+ while(sc.hasNextDouble() && n < 32) {
+ val[n++] = sc.nextDouble();
+ }
+ sc.close();
+ if( n>0) {
+ ret1 = new float[n];
+ for( i=0; i resourceLibName=new ArrayList();
private boolean temp;
private ParametreConnexionHttp connexionHttp;
@@ -71,7 +71,6 @@ else if (System.getProperty("os.name").toLowerCase().startsWith("mac")){
else if (System.getProperty("os.name").toLowerCase().startsWith("linux")){
resourceName="Orthanc_Standalone/Orthanc-1.5.1-ReleaseLinux";
fileExecName="Orthanc-1.5.1-ReleaseLinux";
- resourceLibPath="Orthanc_Standalone/libOrthancWebViewer.so";
resourceLibName.add("libOrthancWebViewer.so");
resourceLibName.add("libOrthancTransfers.so");
@@ -81,7 +80,7 @@ else if (System.getProperty("os.name").toLowerCase().startsWith("linux")){
}
public String copyOrthanc(String installPath) throws Exception {
- String resourceNameJSON=resourceLibPath+File.separator+orthancJsonName;
+ String resourceNameJSON=resourceLibPath+orthancJsonName;
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
//Si pas de destination on met dans le temp directory
@@ -93,7 +92,6 @@ public String copyOrthanc(String installPath) throws Exception {
else file=Paths.get(installPath);
File FileExe=new File(file.toString()+File.separator+fileExecName);
- System.out.println(FileExe);
File FileJSON=new File(file.toString()+File.separator+orthancJsonName);
InputStream in = ClassLoader.getSystemResourceAsStream(resourceName);
@@ -111,7 +109,7 @@ public String copyOrthanc(String installPath) throws Exception {
//Add lib to get GDCM decoder
for (int i=0; i