Skip to content

Commit

Permalink
Merge pull request #10 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored Jun 24, 2018
2 parents f70da94 + 4c3f3c5 commit 278b181
Show file tree
Hide file tree
Showing 8 changed files with 739 additions and 726 deletions.
1,058 changes: 511 additions & 547 deletions src/org/petctviewer/orthanc/Jsonsettings/SettingsGUI.java

Large diffs are not rendered by default.

34 changes: 14 additions & 20 deletions src/org/petctviewer/orthanc/anonymize/VueAnon.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@

import com.michaelbaranov.microba.calendar.DatePicker;

import ij.IJ;
import ij.WindowManager;
import ij.plugin.PlugIn;

import org.petctviewer.orthanc.*;
Expand All @@ -109,7 +107,7 @@ public class VueAnon extends JFrame implements PlugIn{
private JLabel state = new JLabel();
private DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
private DateFormat dfZip = new SimpleDateFormat("MM_dd_yyyy_HHmmss");
private JFrame gui=this;
private JFrame gui;
private JSONParser parser=new JSONParser();

//QueryFillStore
Expand Down Expand Up @@ -235,6 +233,11 @@ public VueAnon(){
if(runOrthanc.getIsStarted()) {
makeGUI();
}
else {
//SK PROBLEME LE PROGRAMME NE QUITTE PAS
System.out.println("ici");
//this.dispose();
}

}else {
makeGUI();
Expand All @@ -243,6 +246,7 @@ public VueAnon(){
}

public void makeGUI(){
gui=this;
//On set les objets necessaires
modelePatients = new TableDataPatientsAnon(connexionHttp);
modeleExportSeries = new TableDataExportSeries(connexionHttp, this, stateExports);
Expand Down Expand Up @@ -2516,6 +2520,9 @@ public void stateChanged(ChangeEvent e) {
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.getRootPane().setDefaultButton(search);
this.addWindowListener(new CloseWindowAdapter(this, this.zipContent, this.modeleAnonStudies.getOldOrthancUIDs(), this.modeleExportStudies.getStudiesList(), monitoring, runOrthanc));
pack();
setLocationRelativeTo(null);
setVisible(true);
}

private void openCloseAnonTool(boolean open) {
Expand Down Expand Up @@ -2913,17 +2920,8 @@ protected void done(){
public static void main(String... args){
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.NoOpLog");
VueAnon vue = new VueAnon();
SwingUtilities.invokeLater(new Runnable(){

@Override
public void run() {
vue.pack();
vue.setLocationRelativeTo(null);
vue.setVisible(true);

}
});
new VueAnon();

}

@Override
Expand All @@ -2932,12 +2930,8 @@ public void run(String string) {

@Override
public void run() {
VueAnon vue = new VueAnon();
vue.pack();
vue.setLocationRelativeTo(null);
WindowManager.addWindow(gui);
IJ.register(VueAnon.class);
vue.setVisible(true);
new VueAnon();

}

});
Expand Down
5 changes: 2 additions & 3 deletions src/org/petctviewer/orthanc/monitoring/CD_Burner.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,13 @@ private File printDat(String nom, String id, String date, String studyDescriptio
SimpleDateFormat formatter = new SimpleDateFormat(dateFormatChoix);
String formattedDate = formatter.format(dateExamen);

//On parse le nom pour enlever les _ et passer le prenom en minuscule
//On parse le nom pour enlever les ^ et passer le prenom en minuscule
int separationNomPrenom=nom.indexOf("^", 0);
if (separationNomPrenom!=-1) {
nom=nom.substring(0, separationNomPrenom+2)+nom.substring(separationNomPrenom+2).toLowerCase();
}


String datFile = "patientName="+nom.replaceAll("^", " ")+"\n"
String datFile = "patientName="+nom.replaceAll("\\^", " ")+"\n"
+ "patientId=" + id +"\n"
+ "patientDate="+ formattedDate + "\n"
+ "studyDescription="+ studyDescription+"\n";
Expand Down
21 changes: 6 additions & 15 deletions src/org/petctviewer/orthanc/monitoring/JDBC_Monitoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ public class JDBC_Monitoring<accessionNumber> {
private Connection connection;

private Preferences jprefer = Preferences.userRoot().node("<unnamed>/anonPlugin");

public static void main(String arg[]) {
JDBC_Monitoring monitoring=new JDBC_Monitoring();
monitoring.InsertPatient("a", "b", "c", "dd","e","f");
monitoring.InsertStudy("gd", "dfg", "dfg", "dg","dg", "dfg", "dfg", "dg", "gd");
monitoring.InsertSeries("100", "100", "90", "Manifacturer", "Manifacturer_Model", "Performing_Physician_Name", "Series_Description", "Station_Name", "22012015", "15124500", "Protocol_Name", "Series_Instance_UID", "Comment_Radiation_Dose", "Radiopharmaceutical_sequence", "Radiopharmaceutical", "RadiopharmaceuticalStartTime", "RadionuclideTotalDose", "RadionuclideHalfLife", "RadionuclidePositronFraction", "Radiation_Dose_Module", "Shared_Tags", "Orthanc_Serie_ID");


}


public JDBC_Monitoring() {
Expand Down Expand Up @@ -74,12 +65,12 @@ public void InsertPatient(String patientLastName, String patientFirstName, Strin
}

public void InsertStudy(String studyID, String studyInstanceUID, String Orthanc_Study_ID, String accessionNumber, String institutionName, String referringPhysicianName,
String studyDate, String studyDescription, String studyTime ) {
String studyDate, String studyDescription, String studyTime, String parentPatientOrthanc ) {

try {
Statement st = connection.createStatement();
String sql = ("INSERT INTO `studies`(`accessionNumber`, `institutionName`, `referringPhysicianName`, `studyDate`, `studyDescription`, `studyID`, `studyInstanceUID`, `studyTime`, `Orthanc_Study_ID`) "
+ "VALUES ('"+accessionNumber+"','"+institutionName+"','"+referringPhysicianName+"','"+studyDate+"','"+studyDescription+"','"+studyID+"','"+studyInstanceUID+"','"+studyTime+"','"+Orthanc_Study_ID+"')");
String sql = ("INSERT INTO `studies`(`accessionNumber`, `institutionName`, `referringPhysicianName`, `studyDate`, `studyDescription`, `studyID`, `studyInstanceUID`, `studyTime`, `Orthanc_Study_ID`, `parentPatientOrthanc`) "
+ "VALUES ('"+accessionNumber+"','"+institutionName+"','"+referringPhysicianName+"','"+studyDate+"','"+studyDescription+"','"+studyID+"','"+studyInstanceUID+"','"+studyTime+"','"+Orthanc_Study_ID+"','"+parentPatientOrthanc+"')");
System.out.println(sql);
boolean rs = st.execute(sql);
} catch (SQLException e) {
Expand All @@ -92,12 +83,12 @@ public void InsertStudy(String studyID, String studyInstanceUID, String Orthanc_

public void InsertSeries(String size, String age, String weight, String Manifacturer, String Manifacturer_Model, String Performing_Physician_Name, String Series_Description, String Station_Name, String Content_Date, String Content_Time,
String Protocol_Name, String Series_Instance_UID, String Comment_Radiation_Dose, String Radiopharmaceutical_sequence, String Radiopharmaceutical, String RadiopharmaceuticalStartTime, String RadionuclideTotalDose, String RadionuclideHalfLife, String RadionuclidePositronFraction,
String Radiation_Dose_Module, String Shared_Tags, String Orthanc_Serie_ID) {
String Radiation_Dose_Module, String Shared_Tags, String Orthanc_Serie_ID, String parentStudyOrthanc) {

try {
Statement st = connection.createStatement();
String sql = ("INSERT INTO `series`(`size`, `age`, `weight`, `Manifacturer`, `Manifacturer_Model`, `Performing_Physician_Name`, `Series_Description`, `Station_Name`, `Content_Date`, `Content_Time`, `Protocol_Name`, `Series_Instance_UID`, `Comment_Radiation_Dose`, `Radiopharmaceutical_sequence`, `Radiopharmaceutical`, `RadiopharmaceuticalStartTime`, `RadionuclideTotalDose`, `RadionuclideHalfLife`, `RadionuclidePositronFraction`, `Radiation_Dose_Module`, `shared_Tags`, `Orthanc_Serie_ID`) "
+ "VALUES ('"+size+"','"+age+"','"+weight+"','"+Manifacturer+"','"+Manifacturer_Model+"','"+Performing_Physician_Name+"','"+Series_Description+"','"+Station_Name+"','"+Content_Date+"','"+Content_Time+"','"+Protocol_Name+"','"+Series_Instance_UID+"','"+Comment_Radiation_Dose+"','"+Radiopharmaceutical_sequence+"','"+Radiopharmaceutical+"','"+RadiopharmaceuticalStartTime+"','"+RadionuclideTotalDose+"','"+RadionuclideHalfLife+"','"+RadionuclidePositronFraction+"','"+Radiation_Dose_Module+"','"+Shared_Tags+"','"+Orthanc_Serie_ID+"')");
String sql = ("INSERT INTO `series`(`size`, `age`, `weight`, `Manifacturer`, `Manifacturer_Model`, `Performing_Physician_Name`, `Series_Description`, `Station_Name`, `Content_Date`, `Content_Time`, `Protocol_Name`, `Series_Instance_UID`, `Comment_Radiation_Dose`, `Radiopharmaceutical_sequence`, `Radiopharmaceutical`, `RadiopharmaceuticalStartTime`, `RadionuclideTotalDose`, `RadionuclideHalfLife`, `RadionuclidePositronFraction`, `Radiation_Dose_Module`, `shared_Tags`, `Orthanc_Serie_ID`,`parentStudyOrthanc` ) "
+ "VALUES ('"+size+"','"+age+"','"+weight+"','"+Manifacturer+"','"+Manifacturer_Model+"','"+Performing_Physician_Name+"','"+Series_Description+"','"+Station_Name+"','"+Content_Date+"','"+Content_Time+"','"+Protocol_Name+"','"+Series_Instance_UID+"','"+Comment_Radiation_Dose+"','"+Radiopharmaceutical_sequence+"','"+Radiopharmaceutical+"','"+RadiopharmaceuticalStartTime+"','"+RadionuclideTotalDose+"','"+RadionuclideHalfLife+"','"+RadionuclidePositronFraction+"','"+Radiation_Dose_Module+"','"+Shared_Tags+"','"+Orthanc_Serie_ID+"','"+parentStudyOrthanc+"')");
System.out.println(sql);
boolean rs = st.execute(sql);
} catch (SQLException e) {
Expand Down
42 changes: 30 additions & 12 deletions src/org/petctviewer/orthanc/monitoring/Tag_Monitoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ else if (level.equals("study")) {
}
if(jprefer.getBoolean("useDBMonitoring", false)) {
db.InsertPatient(studyTag.get("LastName"), studyTag.get("FirstName") , studyTag.get("PatientID"), monitoring.newPatientID.get(i), studyTag.get("PatientBirthDate"), studyTag.get("PatientSex") );
db.InsertStudy(studyTag.get("StudyID"), studyTag.get("StudyInstanceUID"), studyTag.get(monitoring.newStudyID.get(i)), studyTag.get("AccessionNumber"), studyTag.get("InstitutionName"), studyTag.get("ReferringPhysicianName"), studyTag.get("StudyDate"), studyTag.get("StudyDescription"), studyTag.get("StudyTime"));
db.InsertStudy(studyTag.get("StudyID"), studyTag.get("StudyInstanceUID"), studyTag.get(monitoring.newStudyID.get(i)), studyTag.get("AccessionNumber"), studyTag.get("InstitutionName"), studyTag.get("ReferringPhysicianName"), studyTag.get("StudyDate"), studyTag.get("StudyDescription"), studyTag.get("StudyTime"), studyTag.get("ParentPatient"));

}
if(jprefer.getBoolean("AutoDeleteMonitoring", false)) {
Expand All @@ -90,14 +90,13 @@ else if (level.equals("serie")) {


StringBuilder sbSharedTags=parametre.makeGetConnectionAndStringBuilder("/series/"+monitoring.newStableSeriesID.get(i)+"/shared-tags");
textAreaConsole.append("Shared-Tags"+sbSharedTags+",");
//textAreaConsole.append("Shared-Tags"+sbSharedTags+",");
foundTags.put("Shared_Tags", sbSharedTags.toString());

System.out.println(foundTags.toString());
if(jprefer.getBoolean("useDBMonitoring", false)) {
db.InsertPatient(foundTags.get("LastName"), foundTags.get("FirstName") , foundTags.get("PatientID"), foundTags.get("ParentPatient") , foundTags.get("PatientBirthDate"), foundTags.get("PatientSex") );
db.InsertStudy(foundTags.get("StudyID"), foundTags.get("StudyInstanceUID"), foundTags.get("ParentStudy") , foundTags.get("AccessionNumber"), foundTags.get("InstitutionName"), foundTags.get("ReferringPhysicianName"), foundTags.get("StudyDate"), foundTags.get("StudyDescription"), foundTags.get("StudyTime"));
db.InsertSeries(foundTags.get("PatientSize"), foundTags.get("PatientAge"), foundTags.get("PatientWeight"),foundTags.get("Manufacturer"), foundTags.get("ManufacturerModelName"), foundTags.get("PerformingPhysicianName"), foundTags.get("SeriesDescription"), foundTags.get("StationName"), foundTags.get("ContentDate"), foundTags.get("ContentTime"), foundTags.get("ProtocolName"), foundTags.get("SeriesInstanceUID"), foundTags.get("CommentsOnRadiationDose"), foundTags.get("RadiopharmaceuticalInformationSequence"), foundTags.get("Radiopharmaceutical"), foundTags.get("RadiopharmaceuticalStartTime"), foundTags.get("RadionuclideTotalDose"), foundTags.get("RadionuclideHalfLife"), foundTags.get("RadionuclidePositronFraction"), foundTags.get(Tag_Of_Interest.radiationDoseModule), foundTags.get("Shared_Tags"), foundTags.get(monitoring.newStableSeriesID.get(i)));
db.InsertStudy(foundTags.get("StudyID"), foundTags.get("StudyInstanceUID"), foundTags.get("ParentStudy") , foundTags.get("AccessionNumber"), foundTags.get("InstitutionName"), foundTags.get("ReferringPhysicianName"), foundTags.get("StudyDate"), foundTags.get("StudyDescription"), foundTags.get("StudyTime"), foundTags.get("ParentPatient"));
db.InsertSeries(foundTags.get("PatientSize"), foundTags.get("PatientAge"), foundTags.get("PatientWeight"),foundTags.get("Manufacturer"), foundTags.get("ManufacturerModelName"), foundTags.get("PerformingPhysicianName"), foundTags.get("SeriesDescription"), foundTags.get("StationName"), foundTags.get("ContentDate"), foundTags.get("ContentTime"), foundTags.get("ProtocolName"), foundTags.get("SeriesInstanceUID"), foundTags.get("CommentsOnRadiationDose"), foundTags.get("RadiopharmaceuticalInformationSequence"), foundTags.get("Radiopharmaceutical"), foundTags.get("RadiopharmaceuticalStartTime"), foundTags.get("RadionuclideTotalDose"), foundTags.get("RadionuclideHalfLife"), foundTags.get("RadionuclidePositronFraction"), foundTags.get(Tag_Of_Interest.radiationDoseModule), foundTags.get("Shared_Tags"), monitoring.newStableSeriesID.get(i), foundTags.get("ParentStudy"));

}
if(jprefer.getBoolean("AutoDeleteMonitoring", false)) {
Expand Down Expand Up @@ -134,12 +133,20 @@ private HashMap<String, String> getMainPatientTag(JSONObject mainPatientTag) {
textAreaConsole.append("PatientSex"+ patientSex+ ",");
textAreaConsole.append("PatientBirthDate= " +birthDate+ "\n");

String[] name =patientName.split("^");
HashMap<String, String> hashmapTagPatient=new HashMap<String, String>();

if(patientName.indexOf("^") != -1) {
String[] namePatient =patientName.split("\\^");
hashmapTagPatient.put("LastName", namePatient[0]);
hashmapTagPatient.put("FirstName", namePatient[1]);
}
else {
hashmapTagPatient.put("LastName", patientName);
hashmapTagPatient.put("FirstName", "N/A");
}

hashmapTagPatient.put("PatientBirthDate", birthDate);
hashmapTagPatient.put("PatientID", patientID);
hashmapTagPatient.put("LastName", name[0]);
hashmapTagPatient.put("FirstName", name[1]);
hashmapTagPatient.put("PatientSex", patientSex);

return hashmapTagPatient;
Expand All @@ -161,6 +168,7 @@ private HashMap<String, String> getMainStudyTag(JSONObject jsonStudy) {
String studyID=(String) jsonMainStudyTag.get("StudyID");
String studyInstanceUID=(String) jsonMainStudyTag.get("StudyInstanceUID");
String studyTime=(String) jsonMainStudyTag.get("StudyTime");
String parentPatientID=(String) jsonMainStudyTag.get("ParentPatient");

textAreaConsole.append("AccessionNumber= "+accessionNumber+ ",");
textAreaConsole.append("InstitutionName= " + institutionName+ ",");
Expand All @@ -179,6 +187,7 @@ private HashMap<String, String> getMainStudyTag(JSONObject jsonStudy) {
hashmapTagPatient.put("StudyID", studyID);
hashmapTagPatient.put("StudyInstanceUID", studyInstanceUID);
hashmapTagPatient.put("StudyTime", studyTime);
hashmapTagPatient.put("ParentPatient", parentPatientID);

return hashmapTagPatient;

Expand Down Expand Up @@ -226,9 +235,17 @@ private HashMap<String, String> getTagFromInstance(String seriesID) {

}

String[] namePatient =hashmapTag.get("PatientName").split("^");
hashmapTag.put("LastName", namePatient[0]);
hashmapTag.put("FirstName", namePatient[1]);

if(hashmapTag.get("PatientName").indexOf("^") != -1) {
String[] namePatient =hashmapTag.get("PatientName").split("\\^");
hashmapTag.put("LastName", namePatient[0]);
hashmapTag.put("FirstName", namePatient[1]);
}
else {
hashmapTag.put("LastName", hashmapTag.get("PatientName"));
hashmapTag.put("FirstName", "N/A");
}


for (int i=0 ; i<Tag_Of_Interest.tagOfInterestStudy.length; i++) {
if (tags.containsKey(Tag_Of_Interest.tagOfInterestStudy[i])) {
Expand All @@ -254,10 +271,11 @@ private HashMap<String, String> getTagFromInstance(String seriesID) {

if (tags.containsKey(Tag_Of_Interest.radiopharmaceuticalTag)) {
JSONObject radiopharmaceuticalSequence = (JSONObject) tags.get(Tag_Of_Interest.radiopharmaceuticalTag);
hashmapTag.put("RadiopharmaceuticalInformationSequence", radiopharmaceuticalSequence.toString());
JSONArray radiopharmaceuticalSequenceTags= (JSONArray) radiopharmaceuticalSequence.get("Value");
JSONObject radiopharmaceuticalSequenceTagsValue = (JSONObject) radiopharmaceuticalSequenceTags.get(0);
for (int i=0 ; i<Tag_Of_Interest.radiopharmaceutical.length; i++) {
if (tags.containsKey(Tag_Of_Interest.radiopharmaceutical[i])) {
if (radiopharmaceuticalSequenceTagsValue.containsKey(Tag_Of_Interest.radiopharmaceutical[i])) {
JSONObject jsonTag=(JSONObject) radiopharmaceuticalSequenceTagsValue.get(Tag_Of_Interest.radiopharmaceutical[i]);
String name=(String) jsonTag.get("Name");
String value=(String) jsonTag.get("Value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Tag_Of_Interest {
public static String[] tagOfInterestPatient = {"0010,0020","0010,0010", "0010,0040", "0010,0030"};
public static String[] tagOfInterestStudy= {"0008,0020", "0008,0030", "0010,1020", "0010,1010",
"0010,1030", "0008,1030", "0008,0050", "0020,000d", "0020,0010"};
public static String[] tagOfInterestSeries= {"0008,0070","0008,1090","0008,1050","0008,103E","0008,1010","0008,0023",
public static String[] tagOfInterestSeries= {"0008,0070","0008,1090","0008,1050","0008,103e","0008,1010","0008,0023",
"0008,0033","0018,1030","0020,000e", "0040,0310"};
public static String radiopharmaceuticalTag="0054,0016";
public static String radiationDoseModule="0040,030e";
Expand Down
Loading

0 comments on commit 278b181

Please sign in to comment.