From b31453a24851991c3b4bbbf36644738ae4eba90b Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Wed, 29 Aug 2018 11:16:33 +0200 Subject: [PATCH 1/6] idea --- .../petctviewer/orthanc/importdicom/ImportDCM.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/org/petctviewer/orthanc/importdicom/ImportDCM.java b/src/org/petctviewer/orthanc/importdicom/ImportDCM.java index d73248d6..469b0db4 100644 --- a/src/org/petctviewer/orthanc/importdicom/ImportDCM.java +++ b/src/org/petctviewer/orthanc/importdicom/ImportDCM.java @@ -25,7 +25,9 @@ import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.nio.file.FileVisitResult; @@ -154,6 +156,7 @@ public void importFiles(Path path){ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { System.out.println("Importing " + file); + HttpURLConnection conn = connexion.sendDicom("/instances", (Files.readAllBytes(file))); if(conn.getResponseCode() == 200){ @@ -162,6 +165,15 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO }else{ System.out.println("=> Failure (Is it a DICOM file ?)\n"); } + + //Get response after save + BufferedReader br = new BufferedReader(new InputStreamReader( (conn.getInputStream() ))); + String output; + while ((output = br.readLine()) != null) { + //System.out.println(output); + } + + conn.disconnect(); totalFiles++; state.setText(successCount + "/" + totalFiles + " files were imported. (Fiji>Window>Console)"); From 61b4fcabc7627ed0034519584f741761bbbcc567 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Wed, 29 Aug 2018 11:21:46 +0200 Subject: [PATCH 2/6] git --- src/org/petctviewer/orthanc/importdicom/ImportDCM.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/importdicom/ImportDCM.java b/src/org/petctviewer/orthanc/importdicom/ImportDCM.java index 469b0db4..ca37eb8b 100644 --- a/src/org/petctviewer/orthanc/importdicom/ImportDCM.java +++ b/src/org/petctviewer/orthanc/importdicom/ImportDCM.java @@ -173,7 +173,6 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO //System.out.println(output); } - conn.disconnect(); totalFiles++; state.setText(successCount + "/" + totalFiles + " files were imported. (Fiji>Window>Console)"); From 790ec8d6a312c54ae74cf3a0f70b0260dd99c88d Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Thu, 30 Aug 2018 13:15:30 +0200 Subject: [PATCH 3/6] debug --- src/org/petctviewer/orthanc/query/Rest.java | 2 ++ src/org/petctviewer/orthanc/query/VueRest.java | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/org/petctviewer/orthanc/query/Rest.java b/src/org/petctviewer/orthanc/query/Rest.java index d91ddc1d..d1999320 100644 --- a/src/org/petctviewer/orthanc/query/Rest.java +++ b/src/org/petctviewer/orthanc/query/Rest.java @@ -64,6 +64,7 @@ private String getQueryID(String level, String name, String id, String studyDate public String[] getQueryAnswerIndexes(String level, String name, String id, String studyDate, String modality, String studyDescription, String accessionNumber, String aet) { // We call getQueryID to generate a query ID String idQuery = this.getQueryID(level, name, id, studyDate, modality, studyDescription, accessionNumber, aet); + JSONArray contentArray = null; try { contentArray = (JSONArray) parser.parse(connexion.makeGetConnectionAndStringBuilder("/queries/" + idQuery + "/answers/").toString()); @@ -231,6 +232,7 @@ public String getSeriesDescriptionID(String studyInstanceUID, String aet) { values = new String[3][serverResponseArray.size()]; for(int i = 0; i < serverResponseArray.size(); i++){ contentJson= (JSONObject) parser.parse(connexion.makeGetConnectionAndStringBuilder("/queries/" + idURL + "/answers/" + i + "/content").toString()); + if (contentJson.containsKey("0008,103e")) { JSONObject studyDescriptionJson=(JSONObject) parser.parse(contentJson.get("0008,103e").toString()); values[0][i]=(String) studyDescriptionJson.get("Value"); diff --git a/src/org/petctviewer/orthanc/query/VueRest.java b/src/org/petctviewer/orthanc/query/VueRest.java index bfea50a5..44ccf131 100644 --- a/src/org/petctviewer/orthanc/query/VueRest.java +++ b/src/org/petctviewer/orthanc/query/VueRest.java @@ -1155,8 +1155,16 @@ public void actionPerformed(ActionEvent e) { if (searchingParam.getSelectedItem().equals("Patient name")){ String inputString=userInput.getText()+"^"+userInputFirstName.getText(); if (inputString.equals("*^*")) inputString="*"; - modele.addPatient(inputString.toUpperCase(), "*", - df.format(from.getDate().getTime())+"-"+df.format(to.getDate().getTime()), + + String date; + if(df.format(from.getDate().getTime()) .equals(df.format(to.getDate().getTime()))){ + date=df.format(from.getDate().getTime()); + + }else { + date=df.format(from.getDate().getTime())+"-"+df.format(to.getDate().getTime()); + } + + modele.addPatient(inputString.toUpperCase(), "*", date , modalities.toString(), description.getText(),"*", queryAET.getSelectedItem().toString()); } // Query with the patient's ID From 463a5563fdd030a5ccbd3f1d2c1732d927493442 Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Fri, 14 Sep 2018 12:13:10 +0200 Subject: [PATCH 4/6] add Primera burner --- pom.xml | 500 +++++++++++++----- .../orthanc/anonymize/CloseWindowAdapter.java | 7 +- .../orthanc/monitoring/Burner_Settings.java | 19 +- .../orthanc/monitoring/CD_Burner.java | 65 ++- .../orthanc/monitoring/Monitoring_GUI.java | 4 +- 5 files changed, 437 insertions(+), 158 deletions(-) diff --git a/pom.xml b/pom.xml index 06d209ff..73241cae 100644 --- a/pom.xml +++ b/pom.xml @@ -1,145 +1,357 @@ - - - 1.8 - 1.8 - UTF-8 - - - 4.0.0 - - - central - Central Repository - http://repo.maven.apache.org/maven2 - default - - false - - - - Atlassian - Atlassian Repository - https://maven.atlassian.com/content/repositories/atlassian-public/ - default - - false - - - - Boundless - Boundless Repository - http://repo.boundlessgeo.com/main/ - default - - false - - - - - - - - Orthanc_Tools - Orthanc_Tools - 0.1.2-SNAPSHOT - Orthanc Tools - DICOM Tools based on Orthanc APIs - - src - - - - - 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.2 - - - 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 - - - com.google.code.gson - gson - 2.8.5 - - - - net.sf.packtag - packtag-core - 3.8 - - - - - - - - + + + + + + + +1.8 + +1.8 + +UTF-8 + + + +4.0.0 + + + + + + + +central + +Central Repository + +http://repo.maven.apache.org/maven2 + +default + + + + +false + + + + + + + + +Atlassian + +Atlassian Repository + +https://maven.atlassian.com/content/repositories/atlassian-public/ + +default + + + + +false + + + + + + + + +Boundless + +Boundless Repository + +http://repo.boundlessgeo.com/main/ + +default + + + + +false + + + + + + + +Orthanc_Tools + +Orthanc_Tools + +0.1.4 + +Orthanc Tools + +DICOM Tools based on Orthanc APIs + + + + +src + + + + + + + +src/main/resources + + + + + + + + + + + + + + +org.apache.maven.plugins + +maven-assembly-plugin + +2.4.1 + + + + + + + + + + +jar-with-dependencies + + + + + + + + + + +- + +org.petctviewer.orthanc.anonymize.VueAnon + + + + + + + + + + + + + +make-assembly + + + + +package + + + + +single + + + + + + + + + + + + + + + + + + + +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 + + + + + \ No newline at end of file diff --git a/src/org/petctviewer/orthanc/anonymize/CloseWindowAdapter.java b/src/org/petctviewer/orthanc/anonymize/CloseWindowAdapter.java index 6f3370e1..6cdee3ef 100644 --- a/src/org/petctviewer/orthanc/anonymize/CloseWindowAdapter.java +++ b/src/org/petctviewer/orthanc/anonymize/CloseWindowAdapter.java @@ -27,8 +27,6 @@ import org.petctviewer.orthanc.monitoring.Monitoring_GUI; import org.petctviewer.orthanc.setup.Run_Orthanc; -import ij.IJ; - public class CloseWindowAdapter extends WindowAdapter{ JFrame frame; @@ -54,9 +52,8 @@ public void windowClosing(WindowEvent e) { if(!zipContent.isEmpty() || !oldOrthancUIDs.isEmpty() || !listeExport.isEmpty() || monitoring.isRunningMonitoringService()){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to exit?","Orthanc Tools",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,ObjButtons,ObjButtons[1]); - if(PromptResult==JOptionPane.YES_OPTION) - { - closeAll(); + if(PromptResult==JOptionPane.YES_OPTION) { + closeAll(); } }else{ closeAll(); diff --git a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java index 8c1da80c..72d0e67a 100644 --- a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java +++ b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java @@ -56,8 +56,9 @@ public class Burner_Settings extends JDialog { private String labelFile; private String epsonDirectory; private String fijiDirectory; + private String burnerManifacturer; private Boolean deleteStudies; - private JComboBox comboBoxSupportType; + private JComboBox comboBoxSupportType, comboBoxBurnerManufacturer; /** * Launch the application. @@ -100,6 +101,16 @@ public void actionPerformed(ActionEvent e) { } } }); + { + JLabel lblDiscburnerManufacturer = new JLabel("DiscBurner Manufacturer : "); + lblDiscburnerManufacturer.setHorizontalAlignment(SwingConstants.CENTER); + contentPanel.add(lblDiscburnerManufacturer); + } + { + comboBoxBurnerManufacturer = new JComboBox(new String[] {"Epson", "Primera"}); + comboBoxBurnerManufacturer.setSelectedItem(burnerManifacturer); + contentPanel.add(comboBoxBurnerManufacturer); + } contentPanel.add(imageJ); } { @@ -126,7 +137,7 @@ public void actionPerformed(ActionEvent e) { contentPanel.add(labelFilePath); } { - JButton epsonDirectoryButton = new JButton("Set Epson Directory"); + JButton epsonDirectoryButton = new JButton("Set Monitored Directory"); epsonDirectoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc=new JFileChooser(); @@ -203,6 +214,7 @@ public void actionPerformed(ActionEvent e) { okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //On sauve dans le registery + jPrefer.put("buernerManufacturer", (String) comboBoxBurnerManufacturer.getSelectedItem()); if (epsonDirectory!=null) jPrefer.put("epsonDirectory", epsonDirectory); if (fijiDirectory!=null) jPrefer.put("fijiDirectory", fijiDirectory); if (labelFile!=null) jPrefer.put("labelFile", labelFile); @@ -243,13 +255,12 @@ public void actionPerformed(ActionEvent arg0) { public void setCDPreference() { //On prends les settings du registery + burnerManifacturer=jPrefer.get("buernerManufacturer", "Epson"); fijiDirectory=jPrefer.get("fijiDirectory", null); epsonDirectory=jPrefer.get("epsonDirectory", null); labelFile=jPrefer.get("labelFile", null); dateFormatChoix=jPrefer.get("DateFormat", null); deleteStudies=jPrefer.getBoolean("deleteStudies", false); - - } diff --git a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java index da081399..f4c74959 100644 --- a/src/org/petctviewer/orthanc/monitoring/CD_Burner.java +++ b/src/org/petctviewer/orthanc/monitoring/CD_Burner.java @@ -37,7 +37,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.apache.commons.io.FileDeleteStrategy; import org.apache.commons.io.FileUtils; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -49,6 +48,7 @@ public class CD_Burner { + private String burnerManifacturer; private String dateFormatChoix; private String labelFile; private String epsonDirectory; @@ -165,7 +165,13 @@ public void makeCD(List newStableStudyID) { } // Creation du Cd - createCdBurner(nom, id, date, studyDescription, dat, discType); + if (burnerManifacturer.equals("Epson")) { + createCdBurnerEpson(nom, id, date, studyDescription, dat, discType); + } + else if(burnerManifacturer.equals("Primera")) { + createCdBurnerPrimera(nom, id, date, studyDescription, discType); + } + //On efface la study de Orthanc if (deleteStudies) connexion.makeDeleteConnection("/studies/"+newStableStudyID.get(i)); } catch (IOException | org.json.simple.parser.ParseException | ParseException e) { @@ -229,7 +235,7 @@ private void unzip(File zipFile){ * @param studyDescription * @param dat */ - private void createCdBurner(String nom, String id, String date, String studyDescription, File dat, String discType){ + private void createCdBurnerEpson(String nom, String id, String date, String studyDescription, File dat, String discType){ //REalisation du texte pour le Robot String txtRobot= "# Making data CD\n" @@ -260,12 +266,62 @@ private void createCdBurner(String nom, String id, String date, String studyDesc textArea.append("Request Sent , Patient name "+nom+" id "+id+" date "+date+" study "+studyDescription+"\n"); } + /** + * Method for Primera Disc Burner + * @param nom + * @param id + * @param date + * @param studyDescription + * @param discType + */ + private void createCdBurnerPrimera(String nom, String id, String date, String studyDescription, String discType){ + //Command Keys/Values for Primera Robot + String txtRobot= "Copies = 1\n" + + "DataImageType = UDF\n" + + "Data="+fijiDirectory+"\n" + + "Data="+folder+ File.separator+ "DICOM\n" + + "RejectIfNotBlank=YES\n" + + "CloseDisc=YES\n" + + "VerifyDisc=YES\n" + /* PrintQuality - This key specifies the print quality. Key is optional. + The possible values : Low = 0, Medium =1, Better =2 High =3 Best =4*/ + + "PrintQuality=1\n" + /*PrintLabel - This specifies path and filename of the label to print on disc. + The possible file types are .STD (SureThingTM), .jpg (JPEG), .bmp (Windows Bitmap), or .PRN (printed to file through any application). + If this key is not given then no printing will be performed. + */ + + "PrintLabel="+labelFile+"\n" + /* MergeField - This key specifies a “Merge” field for SureThing printing. + The print file specified within the JRQ must be a SureThing file, + and it must have been designed with a Merge File specified. + Fields should be specified in the correct order to match the SureThing design. + */ + + "MergeField="+nom+"\n" + + "MergeField="+id+"\n" + + "MergeField="+date+"\n" + + "MergeField="+studyDescription+"\n"; + + + // Making a .JRQ file in the watched folder + File f = new File(epsonDirectory + File.separator + "CD_"+dateFormat.format(datenow)+".JRQ"); + PrintWriter pw = null; + try { + pw = new PrintWriter(f); + pw.write(txtRobot); + } catch (IOException e) { + e.printStackTrace(); + } finally { + pw.close(); + } + + textArea.append("Request Sent , Patient name "+nom+" id "+id+" date "+date+" study "+studyDescription+"\n"); + } + //Creer le fichier DAT pour injecter NOM, Date, Modalite private File printDat(String nom, String id, String date, String studyDescription) throws ParseException { SimpleDateFormat parser = new SimpleDateFormat("yyyyMMdd"); Date dateExamen = parser.parse(date); - //dateExamen=DateUtils.truncate(dateExamen, Calendar.DAY_OF_MONTH); SimpleDateFormat formatter = new SimpleDateFormat(dateFormatChoix); String formattedDate = formatter.format(dateExamen); @@ -320,6 +376,7 @@ public void setCDPreference() { //On prends les settings du registery Preferences jPrefer = Preferences.userNodeForPackage(Burner_Settings.class); jPrefer = jPrefer.node("CDburner"); + burnerManifacturer=jPrefer.get("buernerManufacturer", "Epson"); fijiDirectory=jPrefer.get("fijiDirectory", null); epsonDirectory=jPrefer.get("epsonDirectory", null); labelFile=jPrefer.get("labelFile", null); diff --git a/src/org/petctviewer/orthanc/monitoring/Monitoring_GUI.java b/src/org/petctviewer/orthanc/monitoring/Monitoring_GUI.java index 37b9f46c..3cddcc09 100644 --- a/src/org/petctviewer/orthanc/monitoring/Monitoring_GUI.java +++ b/src/org/petctviewer/orthanc/monitoring/Monitoring_GUI.java @@ -215,6 +215,8 @@ public void actionPerformed(ActionEvent arg0) { btnSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Burner_Settings settings=new Burner_Settings(); + settings.setLocationRelativeTo(gui); + settings.setResizable(false); settings.setVisible(true); settings.setModal(true); //Refresh settings if already started @@ -252,7 +254,7 @@ public void actionPerformed(ActionEvent arg0) { JLabel lblCdburnerBySassa = new JLabel("CD Burner"); Title.add(lblCdburnerBySassa); - JLabel lblforEpsonPp = new JLabel("(For Epson PP100 Disc Producer)"); + JLabel lblforEpsonPp = new JLabel("(For Epson or Primera Disc Producer)"); Title.add(lblforEpsonPp); JPanel panel_tag_monitoring = new JPanel(); From 7ad0478d63b967027bbf591afec11bb8a34b2d2e Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Fri, 14 Sep 2018 12:22:47 +0200 Subject: [PATCH 5/6] prepare new version --- src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java b/src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java index eeaed4b8..6c7c025a 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.03"); + JLabel title = new JLabel("Dicom Tools v.1.04"); title.setBorder(new EmptyBorder(3, 150, 3, 150)); labelPanel.add(title); JLabel orthancSite = new JLabel("Based on Orthanc http://www.orthanc-server.com"); From d1547a79c82e4617f4ffa6e87ac8a6c0fb11ed4d Mon Sep 17 00:00:00 2001 From: Salim Kanoun Date: Fri, 14 Sep 2018 14:42:24 +0200 Subject: [PATCH 6/6] update --- .../orthanc/monitoring/Burner_Settings.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java index 72d0e67a..37038375 100644 --- a/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java +++ b/src/org/petctviewer/orthanc/monitoring/Burner_Settings.java @@ -29,6 +29,10 @@ import javax.swing.JOptionPane; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.util.prefs.Preferences; import java.awt.event.ActionEvent; import javax.swing.JRadioButton; @@ -108,7 +112,22 @@ public void actionPerformed(ActionEvent e) { } { comboBoxBurnerManufacturer = new JComboBox(new String[] {"Epson", "Primera"}); - comboBoxBurnerManufacturer.setSelectedItem(burnerManifacturer); + + comboBoxBurnerManufacturer.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent arg0) { + if(comboBoxBurnerManufacturer.getSelectedItem().equals("Primera")) { + comboBoxSupportType.setEnabled(false); + }else { + comboBoxSupportType.setEnabled(true); + } + + } + + }); + + contentPanel.add(comboBoxBurnerManufacturer); } contentPanel.add(imageJ); @@ -248,6 +267,8 @@ public void actionPerformed(ActionEvent arg0) { okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); + //Select the Burner set in the options registery + comboBoxBurnerManufacturer.setSelectedItem(burnerManifacturer); } }