Skip to content

Commit

Permalink
Merge pull request #19 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored Sep 18, 2018
2 parents 9ba3236 + d1547a7 commit a24ea6a
Show file tree
Hide file tree
Showing 9 changed files with 482 additions and 161 deletions.
500 changes: 356 additions & 144 deletions pom.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/org/petctviewer/orthanc/anonymize/AboutBoxFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("<html><i>Based on Orthanc http://www.orthanc-server.com</i></html>");
Expand Down
7 changes: 2 additions & 5 deletions src/org/petctviewer/orthanc/anonymize/CloseWindowAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/org/petctviewer/orthanc/importdicom/ImportDCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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){
Expand All @@ -162,6 +165,14 @@ 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)");
Expand Down
40 changes: 36 additions & 4 deletions src/org/petctviewer/orthanc/monitoring/Burner_Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,8 +60,9 @@ public class Burner_Settings extends JDialog {
private String labelFile;
private String epsonDirectory;
private String fijiDirectory;
private String burnerManifacturer;
private Boolean deleteStudies;
private JComboBox<String> comboBoxSupportType;
private JComboBox<String> comboBoxSupportType, comboBoxBurnerManufacturer;

/**
* Launch the application.
Expand Down Expand Up @@ -100,6 +105,31 @@ public void actionPerformed(ActionEvent e) {
}
}
});
{
JLabel lblDiscburnerManufacturer = new JLabel("DiscBurner Manufacturer : ");
lblDiscburnerManufacturer.setHorizontalAlignment(SwingConstants.CENTER);
contentPanel.add(lblDiscburnerManufacturer);
}
{
comboBoxBurnerManufacturer = new JComboBox<String>(new String[] {"Epson", "Primera"});

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);
}
{
Expand All @@ -126,7 +156,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();
Expand Down Expand Up @@ -203,6 +233,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);
Expand Down Expand Up @@ -236,20 +267,21 @@ 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);
}
}

}

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);




}
Expand Down
65 changes: 61 additions & 4 deletions src/org/petctviewer/orthanc/monitoring/CD_Burner.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,6 +48,7 @@

public class CD_Burner {

private String burnerManifacturer;
private String dateFormatChoix;
private String labelFile;
private String epsonDirectory;
Expand Down Expand Up @@ -165,7 +165,13 @@ public void makeCD(List<String> 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) {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/org/petctviewer/orthanc/monitoring/Monitoring_GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/org/petctviewer/orthanc/query/Rest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 10 additions & 2 deletions src/org/petctviewer/orthanc/query/VueRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a24ea6a

Please sign in to comment.