Skip to content

Commit

Permalink
Merge pull request #7 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored Jun 1, 2018
2 parents cc5deb0 + 342d447 commit aaa8c45
Show file tree
Hide file tree
Showing 21 changed files with 1,220 additions and 534 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
<version>0.4.4.3</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
</dependency>

</dependencies>

</project>
62 changes: 57 additions & 5 deletions src/org/petctviewer/orthanc/CTP/CTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ public class CTP {
private String username;
private String password;
private Preferences jprefer = Preferences.userRoot().node("<unnamed>/anonPlugin");
private String serverAdress=jprefer.get("CTP address", null);
private String serverAdress;
private String authentication=null;
private JSONParser parser=new JSONParser();

public CTP(String username, String password) {
/*public static void main(String[] args) {
CTP ctp=new CTP("Imagerie", "Imagerie");
ctp.validateUpload("TEP0", "1.2.276.0.7230010.3.1.2.8323329.22919.1526044062.863352", "11017101022001");
}*/

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

Expand All @@ -39,8 +45,8 @@ public String[] getAvailableStudies(){
jsonPost.put("password", password);
JSONArray studies = null;
try {
String answser=makePostConnection("/get-studies",jsonPost.toString());

String answser=makePostConnection("/Rest_Api/get-studies.php",jsonPost.toString());
System.out.println(answser);
studies=(JSONArray) parser.parse(answser);
} catch (IOException | ParseException e) {
// TODO Auto-generated catch block
Expand All @@ -63,7 +69,7 @@ public String[] getAvailableVisits(String studyName) {
jsonPost.put("studyName", studyName);
JSONArray visits = null;
try {
String answser=makePostConnection("/get-visits",jsonPost.toString());
String answser=makePostConnection("/Rest_Api/get-visits.php",jsonPost.toString());
visits=(JSONArray) parser.parse(answser);
} catch (IOException | ParseException e) {
// TODO Auto-generated catch block
Expand All @@ -84,6 +90,52 @@ public String[] getAvailableVisits(String studyName) {

}

public JSONArray getAvailableImports(String studyName, String visitName) {
JSONObject jsonPost=new JSONObject();
jsonPost.put("username", username);
jsonPost.put("password", password);
jsonPost.put("studyName", studyName);
jsonPost.put("visit", visitName);
JSONArray visits = null;
try {
String answser=makePostConnection("/Rest_Api/get-possible-import.php", jsonPost.toString());
visits=(JSONArray) parser.parse(answser);
} catch (IOException | ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (visits !=null) {
return visits;
}
else {
return null;
}

}

public boolean validateUpload(String visitName, String studyInstanceUID, String patientNumber) {
JSONObject jsonPost=new JSONObject();
jsonPost.put("username", username);
jsonPost.put("password", password);
jsonPost.put("visitName", visitName);
jsonPost.put("StudyInstanceUID", studyInstanceUID);
jsonPost.put("patientNumber", patientNumber);
JSONObject visits = null;
try {
String answser=makePostConnection("/Rest_Api/validate-upload.php", jsonPost.toString());
System.out.println(answser);
visits=(JSONObject) parser.parse(answser);
} catch (IOException | ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//visits=(JSONObject) parser.parse(answser);

return (boolean) visits.get("recivedConfirmation");


}


private String makePostConnection(String apiUrl, String post) throws IOException {
URL url = null;
Expand Down
Loading

0 comments on commit aaa8c45

Please sign in to comment.