Passed
Push — dev ( d62152...d10d14 )
by Salim
03:23
created
src/models/Visit_Group.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -21,101 +21,101 @@
 block discarded – undo
21 21
 class Visit_Group
22 22
 {
23 23
 
24
-    public $groupId;
25
-    public $studyName;
26
-    public $groupModality;
27
-
28
-    public $linkpdo;
29
-
30
-    const GROUP_MODALITY_PET = "PT";
31
-    const GROUP_MODALITY_CT = "CT";
32
-    const GROUP_MODALITY_MR = "MR";
33
-
34
-    public function __construct(PDO $linkpdo, int $groupId)
35
-    {
36
-
37
-        $this->linkpdo = $linkpdo;
38
-        $visitGroupQuery = $this->linkpdo->prepare('SELECT * FROM visit_group WHERE id = :groupId');
39
-        $visitGroupQuery->execute(array('groupId' => $groupId));
40
-
41
-        $visitGroupData = $visitGroupQuery->fetch(PDO::FETCH_ASSOC);
42
-
43
-        if (empty($visitGroupData)) {
44
-            throw new Exception('No Visit Group Found');
45
-        }
46
-
47
-        $this->groupId = $visitGroupData['id'];
48
-        $this->studyName = $visitGroupData['study'];
49
-        $this->groupModality = $visitGroupData['group_modality'];
50
-    }
51
-
52
-    /**
53
-     * Get Visit Type object from Visit Name in this group
54
-     */
55
-    public function getVisitType(String $visitName): Visit_Type
56
-    {
57
-        return Visit_Type::getVisitTypeByName($this->groupId, $visitName, $this->linkpdo);
58
-    }
59
-
60
-    /**
61
-     * Return all visit type of the current visit group
62
-     */
63
-    public function getAllVisitTypesOfGroup(): array
64
-    {
65
-
66
-        $allVisitsType = $this->linkpdo->prepare('SELECT id FROM visit_type WHERE group_id= :groupId ORDER BY visit_order');
67
-        $allVisitsType->execute(array('groupId' => $this->groupId));
68
-        $allVisits = $allVisitsType->fetchall(PDO::FETCH_COLUMN);
69
-
70
-        $visitTypeArray = [];
71
-        foreach ($allVisits as $visitTypeId) {
72
-            $visitTypeArray[] = new Visit_Type($this->linkpdo, $visitTypeId);
73
-        }
74
-
75
-        return $visitTypeArray;
76
-    }
77
-
78
-    /**
79
-     * Get iterator for Visit Type in this group
80
-     */
81
-    public function getAllVisitTypesOfGroupIterator(): Visit_Type_Iterator
82
-    {
83
-        return new Visit_Type_Iterator($this->getAllVisitTypesOfGroup());
84
-    }
85
-
86
-    /**
87
-     * Get Study Visit manager of this group
88
-     */
89
-    public function getStudyVisitManager(): Group_Visit_Manager
90
-    {
91
-        $studyObject = new Study($this->studyName, $this->linkpdo);
92
-        return new Group_Visit_Manager($studyObject, $this, $this->linkpdo);
93
-    }
94
-
95
-    /**
96
-     * Get study Object of this group
97
-     */
98
-    public function getStudy(): Study
99
-    {
100
-        return new Study($this->studyName, $this->linkpdo);
101
-    }
102
-
103
-    /**
104
-     * Create a new Visit Group
105
-     */
106
-    public static function createVisitGroup(String $studyName, String $groupModality, PDO $linkpdo): Visit_Group
107
-    {
108
-
109
-        $req = $linkpdo->prepare('INSERT INTO visit_group (study,  group_modality)
24
+	public $groupId;
25
+	public $studyName;
26
+	public $groupModality;
27
+
28
+	public $linkpdo;
29
+
30
+	const GROUP_MODALITY_PET = "PT";
31
+	const GROUP_MODALITY_CT = "CT";
32
+	const GROUP_MODALITY_MR = "MR";
33
+
34
+	public function __construct(PDO $linkpdo, int $groupId)
35
+	{
36
+
37
+		$this->linkpdo = $linkpdo;
38
+		$visitGroupQuery = $this->linkpdo->prepare('SELECT * FROM visit_group WHERE id = :groupId');
39
+		$visitGroupQuery->execute(array('groupId' => $groupId));
40
+
41
+		$visitGroupData = $visitGroupQuery->fetch(PDO::FETCH_ASSOC);
42
+
43
+		if (empty($visitGroupData)) {
44
+			throw new Exception('No Visit Group Found');
45
+		}
46
+
47
+		$this->groupId = $visitGroupData['id'];
48
+		$this->studyName = $visitGroupData['study'];
49
+		$this->groupModality = $visitGroupData['group_modality'];
50
+	}
51
+
52
+	/**
53
+	 * Get Visit Type object from Visit Name in this group
54
+	 */
55
+	public function getVisitType(String $visitName): Visit_Type
56
+	{
57
+		return Visit_Type::getVisitTypeByName($this->groupId, $visitName, $this->linkpdo);
58
+	}
59
+
60
+	/**
61
+	 * Return all visit type of the current visit group
62
+	 */
63
+	public function getAllVisitTypesOfGroup(): array
64
+	{
65
+
66
+		$allVisitsType = $this->linkpdo->prepare('SELECT id FROM visit_type WHERE group_id= :groupId ORDER BY visit_order');
67
+		$allVisitsType->execute(array('groupId' => $this->groupId));
68
+		$allVisits = $allVisitsType->fetchall(PDO::FETCH_COLUMN);
69
+
70
+		$visitTypeArray = [];
71
+		foreach ($allVisits as $visitTypeId) {
72
+			$visitTypeArray[] = new Visit_Type($this->linkpdo, $visitTypeId);
73
+		}
74
+
75
+		return $visitTypeArray;
76
+	}
77
+
78
+	/**
79
+	 * Get iterator for Visit Type in this group
80
+	 */
81
+	public function getAllVisitTypesOfGroupIterator(): Visit_Type_Iterator
82
+	{
83
+		return new Visit_Type_Iterator($this->getAllVisitTypesOfGroup());
84
+	}
85
+
86
+	/**
87
+	 * Get Study Visit manager of this group
88
+	 */
89
+	public function getStudyVisitManager(): Group_Visit_Manager
90
+	{
91
+		$studyObject = new Study($this->studyName, $this->linkpdo);
92
+		return new Group_Visit_Manager($studyObject, $this, $this->linkpdo);
93
+	}
94
+
95
+	/**
96
+	 * Get study Object of this group
97
+	 */
98
+	public function getStudy(): Study
99
+	{
100
+		return new Study($this->studyName, $this->linkpdo);
101
+	}
102
+
103
+	/**
104
+	 * Create a new Visit Group
105
+	 */
106
+	public static function createVisitGroup(String $studyName, String $groupModality, PDO $linkpdo): Visit_Group
107
+	{
108
+
109
+		$req = $linkpdo->prepare('INSERT INTO visit_group (study,  group_modality)
110 110
                                       VALUES(:studyName, :groupModality)');
111 111
 
112
-        $req->execute(array(
113
-            'studyName' => $studyName,
114
-            'groupModality' => $groupModality
115
-        ));
112
+		$req->execute(array(
113
+			'studyName' => $studyName,
114
+			'groupModality' => $groupModality
115
+		));
116 116
 
117
-        $idGroup = $linkpdo->lastInsertId();
117
+		$idGroup = $linkpdo->lastInsertId();
118 118
 
119
-        return new Visit_Group($linkpdo, $idGroup);
120
-    }
119
+		return new Visit_Group($linkpdo, $idGroup);
120
+	}
121 121
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -27,26 +27,26 @@  discard block
 block discarded – undo
27 27
 
28 28
     public $linkpdo;
29 29
 
30
-    const GROUP_MODALITY_PET = "PT";
31
-    const GROUP_MODALITY_CT = "CT";
32
-    const GROUP_MODALITY_MR = "MR";
30
+    const GROUP_MODALITY_PET="PT";
31
+    const GROUP_MODALITY_CT="CT";
32
+    const GROUP_MODALITY_MR="MR";
33 33
 
34 34
     public function __construct(PDO $linkpdo, int $groupId)
35 35
     {
36 36
 
37
-        $this->linkpdo = $linkpdo;
38
-        $visitGroupQuery = $this->linkpdo->prepare('SELECT * FROM visit_group WHERE id = :groupId');
37
+        $this->linkpdo=$linkpdo;
38
+        $visitGroupQuery=$this->linkpdo->prepare('SELECT * FROM visit_group WHERE id = :groupId');
39 39
         $visitGroupQuery->execute(array('groupId' => $groupId));
40 40
 
41
-        $visitGroupData = $visitGroupQuery->fetch(PDO::FETCH_ASSOC);
41
+        $visitGroupData=$visitGroupQuery->fetch(PDO::FETCH_ASSOC);
42 42
 
43 43
         if (empty($visitGroupData)) {
44 44
             throw new Exception('No Visit Group Found');
45 45
         }
46 46
 
47
-        $this->groupId = $visitGroupData['id'];
48
-        $this->studyName = $visitGroupData['study'];
49
-        $this->groupModality = $visitGroupData['group_modality'];
47
+        $this->groupId=$visitGroupData['id'];
48
+        $this->studyName=$visitGroupData['study'];
49
+        $this->groupModality=$visitGroupData['group_modality'];
50 50
     }
51 51
 
52 52
     /**
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
     public function getAllVisitTypesOfGroup(): array
64 64
     {
65 65
 
66
-        $allVisitsType = $this->linkpdo->prepare('SELECT id FROM visit_type WHERE group_id= :groupId ORDER BY visit_order');
66
+        $allVisitsType=$this->linkpdo->prepare('SELECT id FROM visit_type WHERE group_id= :groupId ORDER BY visit_order');
67 67
         $allVisitsType->execute(array('groupId' => $this->groupId));
68
-        $allVisits = $allVisitsType->fetchall(PDO::FETCH_COLUMN);
68
+        $allVisits=$allVisitsType->fetchall(PDO::FETCH_COLUMN);
69 69
 
70
-        $visitTypeArray = [];
70
+        $visitTypeArray=[];
71 71
         foreach ($allVisits as $visitTypeId) {
72
-            $visitTypeArray[] = new Visit_Type($this->linkpdo, $visitTypeId);
72
+            $visitTypeArray[]=new Visit_Type($this->linkpdo, $visitTypeId);
73 73
         }
74 74
 
75 75
         return $visitTypeArray;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function getStudyVisitManager(): Group_Visit_Manager
90 90
     {
91
-        $studyObject = new Study($this->studyName, $this->linkpdo);
91
+        $studyObject=new Study($this->studyName, $this->linkpdo);
92 92
         return new Group_Visit_Manager($studyObject, $this, $this->linkpdo);
93 93
     }
94 94
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     public static function createVisitGroup(String $studyName, String $groupModality, PDO $linkpdo): Visit_Group
107 107
     {
108 108
 
109
-        $req = $linkpdo->prepare('INSERT INTO visit_group (study,  group_modality)
109
+        $req=$linkpdo->prepare('INSERT INTO visit_group (study,  group_modality)
110 110
                                       VALUES(:studyName, :groupModality)');
111 111
 
112 112
         $req->execute(array(
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             'groupModality' => $groupModality
115 115
         ));
116 116
 
117
-        $idGroup = $linkpdo->lastInsertId();
117
+        $idGroup=$linkpdo->lastInsertId();
118 118
 
119 119
         return new Visit_Group($linkpdo, $idGroup);
120 120
     }
Please login to merge, or discard this patch.
src/models/Visit_Builder.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -38,35 +38,35 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public static function isTableEmpty(Visit_Type $vt): bool
40 40
 	{
41
-		$linkpdo = Visit_Builder::getLinkpdo();
42
-		$table = $vt->tableReviewSpecificName;
43
-		$pdoSt = $linkpdo->query('SELECT * FROM ' . $table . ';');
41
+		$linkpdo=Visit_Builder::getLinkpdo();
42
+		$table=$vt->tableReviewSpecificName;
43
+		$pdoSt=$linkpdo->query('SELECT * FROM '.$table.';');
44 44
 		return count($pdoSt->fetchAll()) == 0;
45 45
 	}
46 46
 
47 47
 	public static function dropColumn(Visit_Type $vt, string $column) : PDOStatement
48 48
 	{
49
-		$linkpdo = Visit_Builder::getLinkpdo();
50
-		$table = $vt->tableReviewSpecificName;
51
-		$sql = 'ALTER TABLE `' . $table . '` DROP COLUMN `' . $column . '`;';
49
+		$linkpdo=Visit_Builder::getLinkpdo();
50
+		$table=$vt->tableReviewSpecificName;
51
+		$sql='ALTER TABLE `'.$table.'` DROP COLUMN `'.$column.'`;';
52 52
 		return $linkpdo->query($sql);
53 53
 	}
54 54
 
55 55
 
56 56
 	public static function alterColumn(Visit_Type $vt, $columnNameBefore, $columnNameAfter, $dataType) : PDOStatement
57 57
 	{ 
58
-		$linkpdo = Visit_Builder::getLinkpdo();
59
-		$table = $vt->tableReviewSpecificName;
60
-		$sql = 'ALTER TABLE `' . $table . '` CHANGE `' . $columnNameBefore . '` `' . $columnNameAfter . '` ' . $dataType . ';';
58
+		$linkpdo=Visit_Builder::getLinkpdo();
59
+		$table=$vt->tableReviewSpecificName;
60
+		$sql='ALTER TABLE `'.$table.'` CHANGE `'.$columnNameBefore.'` `'.$columnNameAfter.'` '.$dataType.';';
61 61
 		return $linkpdo->query($sql);
62 62
 	}
63 63
 
64 64
 
65 65
 	public static function addColumn(Visit_Type $vt, $columnName, $dataType) : PDOStatement
66 66
 	{
67
-		$linkpdo = Visit_Builder::getLinkpdo();
68
-		$table = $vt->tableReviewSpecificName;
69
-		$sql = 'ALTER TABLE `' . $table . '` ADD `' . $columnName . '` ' . $dataType . ';';
67
+		$linkpdo=Visit_Builder::getLinkpdo();
68
+		$table=$vt->tableReviewSpecificName;
69
+		$sql='ALTER TABLE `'.$table.'` ADD `'.$columnName.'` '.$dataType.';';
70 70
 		return $linkpdo->query($sql);
71 71
 	}
72 72
 
@@ -79,38 +79,38 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public static function formatDataType(string $typeLabel, $typeParams): string
81 81
 	{
82
-		$res = '';
82
+		$res='';
83 83
 		switch ($typeLabel) {
84 84
 			case 'int':
85
-				$res = 'INT(11)';
85
+				$res='INT(11)';
86 86
 				break;
87 87
 			case 'tinyint':
88
-				$res = 'TINYINT(1)';
88
+				$res='TINYINT(1)';
89 89
 				break;
90 90
 			case 'tinytext':
91
-				$res = 'TINYTEXT';
91
+				$res='TINYTEXT';
92 92
 				break;
93 93
 			case 'date':
94
-				$res = 'DATE';
94
+				$res='DATE';
95 95
 				break;
96 96
 			case 'varchar':
97
-				$param = Visit_Builder::escape($typeParams[0]);
97
+				$param=Visit_Builder::escape($typeParams[0]);
98 98
 				// Format params array into string e.g. '(123)'
99
-				$res = 'VARCHAR(' . $param . ')';
99
+				$res='VARCHAR('.$param.')';
100 100
 				break;
101 101
 			case 'decimal':
102
-				$param1 = Visit_Builder::escape($typeParams[0]);
103
-				$param2 = Visit_Builder::escape($typeParams[1]);
102
+				$param1=Visit_Builder::escape($typeParams[0]);
103
+				$param2=Visit_Builder::escape($typeParams[1]);
104 104
 				// Format params array into string e.g. '(12,3)'
105
-				$res = 'DECIMAL(' . $param1 . ',' . $param2 . ')';
105
+				$res='DECIMAL('.$param1.','.$param2.')';
106 106
 				break;
107 107
 			case 'enum':
108
-				$params = [];
108
+				$params=[];
109 109
 				foreach ($typeParams as $tp) {
110 110
 					array_push($params, Visit_Builder::escape($tp));
111 111
 				}
112 112
 				// Format params array into string e.g. '("abc","def","ghi")'
113
-				$res = 'ENUM("' . implode('","', $params) . '")';
113
+				$res='ENUM("'.implode('","', $params).'")';
114 114
 				break;
115 115
 			default:
116 116
 				throw new Exception('Unknown datatype');
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public static function getColumnDataType(Visit_Type $vt, string $columnName): string
141 141
 	{
142
-		$columns = $vt->getSpecificTableInputType();
142
+		$columns=$vt->getSpecificTableInputType();
143 143
 		foreach ($columns as $c) {
144 144
 			// Retrieving original data type
145 145
 			if ($c['COLUMN_NAME'] == $columnName) {
146 146
 				return $c['COLUMN_TYPE'];
147 147
 			}
148 148
 		}
149
-		throw new Exception('Cannot find column ' . $columnName . ' for visit type ' . $vt);
149
+		throw new Exception('Cannot find column '.$columnName.' for visit type '.$vt);
150 150
 	}
151 151
 
152 152
 
Please login to merge, or discard this patch.
src/models/Session.php 3 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -26,147 +26,147 @@
 block discarded – undo
26 26
  */
27 27
 Class Session{
28 28
     
29
-    public static function checkSession(bool $log=true, bool $writeSession=false){
30
-        
31
-        if(session_status() == PHP_SESSION_NONE) {
32
-        		session_start();
33
-        }
34
-        
35
-        //Write logs
36
-        if($log){
37
-            isset($_POST['id_visit']) ? $logIdVisit=$_POST['id_visit'] : $logIdVisit='N/A';
38
-            isset($_POST['patient_num']) ? $logPatientNum=$_POST['patient_num'] : $logPatientNum='N/A';
39
-            @self::logInfo('Username : '.$_SESSION['username'].
40
-                ' Role: '.$_SESSION ['role'].' Study: '.$_SESSION['study'].' Visit ID: '.$logIdVisit.' Patient Num: '.$logPatientNum);
29
+	public static function checkSession(bool $log=true, bool $writeSession=false){
30
+        
31
+		if(session_status() == PHP_SESSION_NONE) {
32
+				session_start();
33
+		}
34
+        
35
+		//Write logs
36
+		if($log){
37
+			isset($_POST['id_visit']) ? $logIdVisit=$_POST['id_visit'] : $logIdVisit='N/A';
38
+			isset($_POST['patient_num']) ? $logPatientNum=$_POST['patient_num'] : $logPatientNum='N/A';
39
+			@self::logInfo('Username : '.$_SESSION['username'].
40
+				' Role: '.$_SESSION ['role'].' Study: '.$_SESSION['study'].' Visit ID: '.$logIdVisit.' Patient Num: '.$logPatientNum);
41 41
             
42
-        }
42
+		}
43 43
 
44
-        //Check session availability
45
-        if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1200)) {
46
-            // last request was more than 30 minutes ago or unexisting
47
-            session_unset();     // unset $_SESSION variable for the run-time
48
-            session_destroy();   // destroy session data in storage
49
-            self::redirectAndEndScript();
50
-        }else if(empty($_SESSION)){
51
-            //if session already empty
52
-            self::redirectAndEndScript();
53
-        }else{
54
-            $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
55
-        }
56
-        
57
-        //If script dosen't need to write on session data, close write to free async ajax request
58
-        if(!$writeSession){
59
-        	session_write_close();
60
-        }
61
-        
62
-    }
44
+		//Check session availability
45
+		if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1200)) {
46
+			// last request was more than 30 minutes ago or unexisting
47
+			session_unset();     // unset $_SESSION variable for the run-time
48
+			session_destroy();   // destroy session data in storage
49
+			self::redirectAndEndScript();
50
+		}else if(empty($_SESSION)){
51
+			//if session already empty
52
+			self::redirectAndEndScript();
53
+		}else{
54
+			$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
55
+		}
56
+        
57
+		//If script dosen't need to write on session data, close write to free async ajax request
58
+		if(!$writeSession){
59
+			session_write_close();
60
+		}
61
+        
62
+	}
63 63
     
64
-    /**
65
-     * Redirect to index and end script execution
66
-     */
67
-    private static function redirectAndEndScript(){
68
-        echo '<meta http-equiv="Refresh" content="0;/index.php">';
69
-        exit("Session Lost");
70
-    }
64
+	/**
65
+	 * Redirect to index and end script execution
66
+	 */
67
+	private static function redirectAndEndScript(){
68
+		echo '<meta http-equiv="Refresh" content="0;/index.php">';
69
+		exit("Session Lost");
70
+	}
71 71
     
72
-    /**
73
-     * Instanciate a new PDO object for database connexion
74
-     * And Fill Php constant parameter
75
-     * @return PDO
76
-     */
77
-    public static function getLinkpdo(){
78
-        
79
-        //Load the config file defining constants
80
-        if(!defined('DATABASE_HOST')){
81
-            require_once($_SERVER["DOCUMENT_ROOT"].'/data/_config/config.inc.php');
82
-        }
83
-        
84
-        //Instanciate PDO connexion with SSL or not
85
-        if(DATABASE_SSL){
86
-            $linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'', self::getSSLPDOArrayOptions() );    
87
-        }else{
88
-            $linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'');   
89
-        }
72
+	/**
73
+	 * Instanciate a new PDO object for database connexion
74
+	 * And Fill Php constant parameter
75
+	 * @return PDO
76
+	 */
77
+	public static function getLinkpdo(){
78
+        
79
+		//Load the config file defining constants
80
+		if(!defined('DATABASE_HOST')){
81
+			require_once($_SERVER["DOCUMENT_ROOT"].'/data/_config/config.inc.php');
82
+		}
83
+        
84
+		//Instanciate PDO connexion with SSL or not
85
+		if(DATABASE_SSL){
86
+			$linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'', self::getSSLPDOArrayOptions() );    
87
+		}else{
88
+			$linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'');   
89
+		}
90 90
 
91
-        $linkpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
91
+		$linkpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
92 92
         
93
-        //Load preferences from the database
94
-        if(! defined('GAELO_PATIENT_CODE_LENGHT') ) Session::loadPreferencesInConstants($linkpdo);
93
+		//Load preferences from the database
94
+		if(! defined('GAELO_PATIENT_CODE_LENGHT') ) Session::loadPreferencesInConstants($linkpdo);
95 95
         
96
-        return $linkpdo;
97
-    }
96
+		return $linkpdo;
97
+	}
98 98
     
99
-    /**
100
-     * Options to use SSL connexion
101
-     * @return array
102
-     */
103
-    public static function getSSLPDOArrayOptions(){
104
-        $sslOptions = array(
105
-            PDO::MYSQL_ATTR_SSL_CA => '',
106
-            PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
107
-        );
108
-        
109
-        return $sslOptions;
110
-    }
99
+	/**
100
+	 * Options to use SSL connexion
101
+	 * @return array
102
+	 */
103
+	public static function getSSLPDOArrayOptions(){
104
+		$sslOptions = array(
105
+			PDO::MYSQL_ATTR_SSL_CA => '',
106
+			PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
107
+		);
108
+        
109
+		return $sslOptions;
110
+	}
111 111
     
112
-    /**
113
-     * Write log in a daily log file in log folder
114
-     * @param string $stringInfo
115
-     */
116
-    public static function logInfo(string $stringInfo){
117
-        
118
-        if(is_writable($_SERVER["DOCUMENT_ROOT"].'/data/logs/')){
119
-            // create a log channel
120
-            $log = new Logger('OpenTrialProcessor');
121
-            $log->pushHandler(new RotatingFileHandler($_SERVER["DOCUMENT_ROOT"].'/data/logs/gaelO.log', Logger::INFO));
122
-            $log->pushProcessor(new WebProcessor());
123
-            $log->info($stringInfo);
124
-        }else{
125
-            error_log("Can't write logs folder");
126
-        }
127
-    }
112
+	/**
113
+	 * Write log in a daily log file in log folder
114
+	 * @param string $stringInfo
115
+	 */
116
+	public static function logInfo(string $stringInfo){
117
+        
118
+		if(is_writable($_SERVER["DOCUMENT_ROOT"].'/data/logs/')){
119
+			// create a log channel
120
+			$log = new Logger('OpenTrialProcessor');
121
+			$log->pushHandler(new RotatingFileHandler($_SERVER["DOCUMENT_ROOT"].'/data/logs/gaelO.log', Logger::INFO));
122
+			$log->pushProcessor(new WebProcessor());
123
+			$log->info($stringInfo);
124
+		}else{
125
+			error_log("Can't write logs folder");
126
+		}
127
+	}
128 128
     
129
-    /**
130
-     * Store preference from the database in PHP constants
131
-     * @param PDO $linkpdo
132
-     */
133
-    public static function loadPreferencesInConstants(PDO $linkpdo){
134
-        
135
-        $connecter = $linkpdo->prepare('SELECT * FROM preferences');
136
-        $connecter->execute();
137
-        
138
-        $result = $connecter->fetch(PDO::FETCH_ASSOC);
139
-        
140
-        define('GAELO_PATIENT_CODE_LENGHT',$result['patient_code_length']);
141
-        define('GAELO_PLATEFORM_NAME', $result['name']);
142
-        define('GAELO_ADMIN_EMAIL', $result['admin_email']);
143
-        define('GAELO_REPLY_TO', $result['email_reply_to']);
144
-        define('GAELO_CORPORATION', $result['corporation']);
145
-        define('GAELO_WEB_ADDRESS', $result['address']);
146
-        define('GAELO_DATE_FORMAT', $result['parse_date_import']);
147
-        define('GAELO_COUNTRY_LANGUAGE', $result['parse_country_name']);
129
+	/**
130
+	 * Store preference from the database in PHP constants
131
+	 * @param PDO $linkpdo
132
+	 */
133
+	public static function loadPreferencesInConstants(PDO $linkpdo){
134
+        
135
+		$connecter = $linkpdo->prepare('SELECT * FROM preferences');
136
+		$connecter->execute();
137
+        
138
+		$result = $connecter->fetch(PDO::FETCH_ASSOC);
139
+        
140
+		define('GAELO_PATIENT_CODE_LENGHT',$result['patient_code_length']);
141
+		define('GAELO_PLATEFORM_NAME', $result['name']);
142
+		define('GAELO_ADMIN_EMAIL', $result['admin_email']);
143
+		define('GAELO_REPLY_TO', $result['email_reply_to']);
144
+		define('GAELO_CORPORATION', $result['corporation']);
145
+		define('GAELO_WEB_ADDRESS', $result['address']);
146
+		define('GAELO_DATE_FORMAT', $result['parse_date_import']);
147
+		define('GAELO_COUNTRY_LANGUAGE', $result['parse_country_name']);
148 148
 
149
-        define('GAELO_ORTHANC_EXPOSED_INTERNAL_ADDRESS', $result['orthanc_exposed_internal_address']);
150
-        define('GAELO_ORTHANC_EXPOSED_INTERNAL_PORT', $result['orthanc_exposed_internal_port']);
151
-        define('GAELO_ORTHANC_EXPOSED_EXTERNAL_ADDRESS', $result['orthanc_exposed_external_address']);
152
-        define('GAELO_ORTHANC_EXPOSED_EXTERNAL_PORT', $result['orthanc_exposed_external_port']);
153
-        define('GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN', $result['orthanc_exposed_internal_login']);
154
-        define('GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD', $result['orthanc_exposed_internal_password']);
155
-        define('GAELO_ORTHANC_EXPOSED_EXTERNAL_LOGIN', $result['orthanc_exposed_external_login']);
156
-        define('GAELO_ORTHANC_EXPOSED_EXTERNAL_PASSWORD', $result['orthanc_exposed_external_password']);
157
-        
158
-        define('GAELO_ORTHANC_PACS_ADDRESS', $result['orthanc_pacs_address']);
159
-        define('GAELO_ORTHANC_PACS_PORT', $result['orthanc_pacs_port']);
160
-        define('GAELO_ORTHANC_PACS_LOGIN', $result['orthanc_pacs_login']);
161
-        define('GAELO_ORTHANC_PACS_PASSWORD', $result['orthanc_pacs_password']);
162
-        
163
-        define('GAELO_USE_SMTP', $result['use_smtp']);
164
-        define('GAELO_SMTP_HOST', $result['smtp_host']);
165
-        define('GAELO_SMTP_PORT', $result['smtp_port']);
166
-        define('GAELO_SMTP_USER', $result['smtp_user']);
167
-        define('GAELO_SMTP_PASSWORD', $result['smtp_password']);
168
-        define('GAELO_SMTP_SECURE', $result['smtp_secure']);
169
-        
170
-    }
149
+		define('GAELO_ORTHANC_EXPOSED_INTERNAL_ADDRESS', $result['orthanc_exposed_internal_address']);
150
+		define('GAELO_ORTHANC_EXPOSED_INTERNAL_PORT', $result['orthanc_exposed_internal_port']);
151
+		define('GAELO_ORTHANC_EXPOSED_EXTERNAL_ADDRESS', $result['orthanc_exposed_external_address']);
152
+		define('GAELO_ORTHANC_EXPOSED_EXTERNAL_PORT', $result['orthanc_exposed_external_port']);
153
+		define('GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN', $result['orthanc_exposed_internal_login']);
154
+		define('GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD', $result['orthanc_exposed_internal_password']);
155
+		define('GAELO_ORTHANC_EXPOSED_EXTERNAL_LOGIN', $result['orthanc_exposed_external_login']);
156
+		define('GAELO_ORTHANC_EXPOSED_EXTERNAL_PASSWORD', $result['orthanc_exposed_external_password']);
157
+        
158
+		define('GAELO_ORTHANC_PACS_ADDRESS', $result['orthanc_pacs_address']);
159
+		define('GAELO_ORTHANC_PACS_PORT', $result['orthanc_pacs_port']);
160
+		define('GAELO_ORTHANC_PACS_LOGIN', $result['orthanc_pacs_login']);
161
+		define('GAELO_ORTHANC_PACS_PASSWORD', $result['orthanc_pacs_password']);
162
+        
163
+		define('GAELO_USE_SMTP', $result['use_smtp']);
164
+		define('GAELO_SMTP_HOST', $result['smtp_host']);
165
+		define('GAELO_SMTP_PORT', $result['smtp_port']);
166
+		define('GAELO_SMTP_USER', $result['smtp_user']);
167
+		define('GAELO_SMTP_PASSWORD', $result['smtp_password']);
168
+		define('GAELO_SMTP_SECURE', $result['smtp_secure']);
169
+        
170
+	}
171 171
 
172 172
 }
173 173
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 /**
25 25
  * Methods that are call by all scripts
26 26
  */
27
-Class Session{
27
+Class Session {
28 28
     
29
-    public static function checkSession(bool $log=true, bool $writeSession=false){
29
+    public static function checkSession(bool $log=true, bool $writeSession=false) {
30 30
         
31
-        if(session_status() == PHP_SESSION_NONE) {
31
+        if (session_status() == PHP_SESSION_NONE) {
32 32
         		session_start();
33 33
         }
34 34
         
35 35
         //Write logs
36
-        if($log){
36
+        if ($log) {
37 37
             isset($_POST['id_visit']) ? $logIdVisit=$_POST['id_visit'] : $logIdVisit='N/A';
38 38
             isset($_POST['patient_num']) ? $logPatientNum=$_POST['patient_num'] : $logPatientNum='N/A';
39 39
             @self::logInfo('Username : '.$_SESSION['username'].
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
         }
43 43
 
44 44
         //Check session availability
45
-        if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1200)) {
45
+        if (isset($_SESSION['LAST_ACTIVITY']) && (time()-$_SESSION['LAST_ACTIVITY'] > 1200)) {
46 46
             // last request was more than 30 minutes ago or unexisting
47
-            session_unset();     // unset $_SESSION variable for the run-time
48
-            session_destroy();   // destroy session data in storage
47
+            session_unset(); // unset $_SESSION variable for the run-time
48
+            session_destroy(); // destroy session data in storage
49 49
             self::redirectAndEndScript();
50
-        }else if(empty($_SESSION)){
50
+        }else if (empty($_SESSION)) {
51 51
             //if session already empty
52 52
             self::redirectAndEndScript();
53
-        }else{
54
-            $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
53
+        }else {
54
+            $_SESSION['LAST_ACTIVITY']=time(); // update last activity time stamp
55 55
         }
56 56
         
57 57
         //If script dosen't need to write on session data, close write to free async ajax request
58
-        if(!$writeSession){
58
+        if (!$writeSession) {
59 59
         	session_write_close();
60 60
         }
61 61
         
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     /**
65 65
      * Redirect to index and end script execution
66 66
      */
67
-    private static function redirectAndEndScript(){
67
+    private static function redirectAndEndScript() {
68 68
         echo '<meta http-equiv="Refresh" content="0;/index.php">';
69 69
         exit("Session Lost");
70 70
     }
@@ -74,24 +74,24 @@  discard block
 block discarded – undo
74 74
      * And Fill Php constant parameter
75 75
      * @return PDO
76 76
      */
77
-    public static function getLinkpdo(){
77
+    public static function getLinkpdo() {
78 78
         
79 79
         //Load the config file defining constants
80
-        if(!defined('DATABASE_HOST')){
80
+        if (!defined('DATABASE_HOST')) {
81 81
             require_once($_SERVER["DOCUMENT_ROOT"].'/data/_config/config.inc.php');
82 82
         }
83 83
         
84 84
         //Instanciate PDO connexion with SSL or not
85
-        if(DATABASE_SSL){
86
-            $linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'', self::getSSLPDOArrayOptions() );    
87
-        }else{
88
-            $linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'');   
85
+        if (DATABASE_SSL) {
86
+            $linkpdo=new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'', self::getSSLPDOArrayOptions());    
87
+        }else {
88
+            $linkpdo=new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'');   
89 89
         }
90 90
 
91 91
         $linkpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
92 92
         
93 93
         //Load preferences from the database
94
-        if(! defined('GAELO_PATIENT_CODE_LENGHT') ) Session::loadPreferencesInConstants($linkpdo);
94
+        if (!defined('GAELO_PATIENT_CODE_LENGHT')) Session::loadPreferencesInConstants($linkpdo);
95 95
         
96 96
         return $linkpdo;
97 97
     }
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
      * Options to use SSL connexion
101 101
      * @return array
102 102
      */
103
-    public static function getSSLPDOArrayOptions(){
104
-        $sslOptions = array(
103
+    public static function getSSLPDOArrayOptions() {
104
+        $sslOptions=array(
105 105
             PDO::MYSQL_ATTR_SSL_CA => '',
106 106
             PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
107 107
         );
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
      * Write log in a daily log file in log folder
114 114
      * @param string $stringInfo
115 115
      */
116
-    public static function logInfo(string $stringInfo){
116
+    public static function logInfo(string $stringInfo) {
117 117
         
118
-        if(is_writable($_SERVER["DOCUMENT_ROOT"].'/data/logs/')){
118
+        if (is_writable($_SERVER["DOCUMENT_ROOT"].'/data/logs/')) {
119 119
             // create a log channel
120
-            $log = new Logger('OpenTrialProcessor');
120
+            $log=new Logger('OpenTrialProcessor');
121 121
             $log->pushHandler(new RotatingFileHandler($_SERVER["DOCUMENT_ROOT"].'/data/logs/gaelO.log', Logger::INFO));
122 122
             $log->pushProcessor(new WebProcessor());
123 123
             $log->info($stringInfo);
124
-        }else{
124
+        }else {
125 125
             error_log("Can't write logs folder");
126 126
         }
127 127
     }
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
      * Store preference from the database in PHP constants
131 131
      * @param PDO $linkpdo
132 132
      */
133
-    public static function loadPreferencesInConstants(PDO $linkpdo){
133
+    public static function loadPreferencesInConstants(PDO $linkpdo) {
134 134
         
135
-        $connecter = $linkpdo->prepare('SELECT * FROM preferences');
135
+        $connecter=$linkpdo->prepare('SELECT * FROM preferences');
136 136
         $connecter->execute();
137 137
         
138
-        $result = $connecter->fetch(PDO::FETCH_ASSOC);
138
+        $result=$connecter->fetch(PDO::FETCH_ASSOC);
139 139
         
140
-        define('GAELO_PATIENT_CODE_LENGHT',$result['patient_code_length']);
140
+        define('GAELO_PATIENT_CODE_LENGHT', $result['patient_code_length']);
141 141
         define('GAELO_PLATEFORM_NAME', $result['name']);
142 142
         define('GAELO_ADMIN_EMAIL', $result['admin_email']);
143 143
         define('GAELO_REPLY_TO', $result['email_reply_to']);
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
             session_unset();     // unset $_SESSION variable for the run-time
48 48
             session_destroy();   // destroy session data in storage
49 49
             self::redirectAndEndScript();
50
-        }else if(empty($_SESSION)){
50
+        } else if(empty($_SESSION)){
51 51
             //if session already empty
52 52
             self::redirectAndEndScript();
53
-        }else{
53
+        } else{
54 54
             $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
55 55
         }
56 56
         
@@ -84,14 +84,16 @@  discard block
 block discarded – undo
84 84
         //Instanciate PDO connexion with SSL or not
85 85
         if(DATABASE_SSL){
86 86
             $linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'', self::getSSLPDOArrayOptions() );    
87
-        }else{
87
+        } else{
88 88
             $linkpdo= new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME.';charset=UTF8', ''.DATABASE_USERNAME.'', ''.DATABASE_PASSWORD.'');   
89 89
         }
90 90
 
91 91
         $linkpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
92 92
         
93 93
         //Load preferences from the database
94
-        if(! defined('GAELO_PATIENT_CODE_LENGHT') ) Session::loadPreferencesInConstants($linkpdo);
94
+        if(! defined('GAELO_PATIENT_CODE_LENGHT') ) {
95
+        	Session::loadPreferencesInConstants($linkpdo);
96
+        }
95 97
         
96 98
         return $linkpdo;
97 99
     }
@@ -121,7 +123,7 @@  discard block
 block discarded – undo
121 123
             $log->pushHandler(new RotatingFileHandler($_SERVER["DOCUMENT_ROOT"].'/data/logs/gaelO.log', Logger::INFO));
122 124
             $log->pushProcessor(new WebProcessor());
123 125
             $log->info($stringInfo);
124
-        }else{
126
+        } else{
125 127
             error_log("Can't write logs folder");
126 128
         }
127 129
     }
Please login to merge, or discard this patch.
src/models/Visit_Type_Iterator.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@  discard block
 block discarded – undo
6 6
 class Visit_Type_Iterator implements Iterator
7 7
 {
8 8
 
9
-    private array $visitsTypeArray = [];
10
-    private int $index = 0;
9
+    private array $visitsTypeArray=[];
10
+    private int $index=0;
11 11
 
12 12
     public function __construct(array $visitTypeArray)
13 13
     {
14
-        $this->visitsTypeArray = $visitTypeArray;
14
+        $this->visitsTypeArray=$visitTypeArray;
15 15
     }
16 16
 
17 17
     public function setVisitPosition(String $visitName)
18 18
     {
19
-        $visitNameArray = array_map(function (Visit_Type $visitTypeObject) {
19
+        $visitNameArray=array_map(function(Visit_Type $visitTypeObject) {
20 20
             return $visitTypeObject->name;
21 21
         }, $this->visitsTypeArray);
22 22
 
23
-        $this->index = array_search($visitName, $visitNameArray);
23
+        $this->index=array_search($visitName, $visitNameArray);
24 24
     }
25 25
 
26 26
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function rewind()
57 57
     {
58
-        $this->index = 0;
58
+        $this->index=0;
59 59
     }
60 60
 
61 61
     public function key(): int
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,65 +6,65 @@
 block discarded – undo
6 6
 class Visit_Type_Iterator implements Iterator
7 7
 {
8 8
 
9
-    private array $visitsTypeArray = [];
10
-    private int $index = 0;
9
+	private array $visitsTypeArray = [];
10
+	private int $index = 0;
11 11
 
12
-    public function __construct(array $visitTypeArray)
13
-    {
14
-        $this->visitsTypeArray = $visitTypeArray;
15
-    }
12
+	public function __construct(array $visitTypeArray)
13
+	{
14
+		$this->visitsTypeArray = $visitTypeArray;
15
+	}
16 16
 
17
-    public function setVisitPosition(String $visitName)
18
-    {
19
-        $visitNameArray = array_map(function (Visit_Type $visitTypeObject) {
20
-            return $visitTypeObject->name;
21
-        }, $this->visitsTypeArray);
17
+	public function setVisitPosition(String $visitName)
18
+	{
19
+		$visitNameArray = array_map(function (Visit_Type $visitTypeObject) {
20
+			return $visitTypeObject->name;
21
+		}, $this->visitsTypeArray);
22 22
 
23
-        $this->index = array_search($visitName, $visitNameArray);
24
-    }
23
+		$this->index = array_search($visitName, $visitNameArray);
24
+	}
25 25
 
26 26
 
27
-    public function current(): Visit_Type
28
-    {
29
-        return $this->visitsTypeArray[$this->index];
30
-    }
27
+	public function current(): Visit_Type
28
+	{
29
+		return $this->visitsTypeArray[$this->index];
30
+	}
31 31
 
32
-    public function previous()
33
-    {
34
-        $this->index--;
35
-    }
32
+	public function previous()
33
+	{
34
+		$this->index--;
35
+	}
36 36
 
37
-    public function hasPrevious()
38
-    {
39
-        $this->previous();
40
-        if ($this->valid()) return $this->current();
41
-        else return false;
42
-    }
37
+	public function hasPrevious()
38
+	{
39
+		$this->previous();
40
+		if ($this->valid()) return $this->current();
41
+		else return false;
42
+	}
43 43
 
44
-    public function next()
45
-    {
46
-        $this->index++;
47
-    }
44
+	public function next()
45
+	{
46
+		$this->index++;
47
+	}
48 48
 
49
-    public function hasNext()
50
-    {
51
-        $this->next();
52
-        if ($this->valid()) return $this->current();
53
-        else return false;
54
-    }
49
+	public function hasNext()
50
+	{
51
+		$this->next();
52
+		if ($this->valid()) return $this->current();
53
+		else return false;
54
+	}
55 55
 
56
-    public function rewind()
57
-    {
58
-        $this->index = 0;
59
-    }
56
+	public function rewind()
57
+	{
58
+		$this->index = 0;
59
+	}
60 60
 
61
-    public function key(): int
62
-    {
63
-        return $this->index;
64
-    }
61
+	public function key(): int
62
+	{
63
+		return $this->index;
64
+	}
65 65
 
66
-    public function valid(): bool
67
-    {
68
-        return isset($this->visitsTypeArray[$this->key()]);
69
-    }
66
+	public function valid(): bool
67
+	{
68
+		return isset($this->visitsTypeArray[$this->key()]);
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
     public function hasPrevious()
38 38
     {
39 39
         $this->previous();
40
-        if ($this->valid()) return $this->current();
41
-        else return false;
40
+        if ($this->valid()) {
41
+        	return $this->current();
42
+        } else {
43
+        	return false;
44
+        }
42 45
     }
43 46
 
44 47
     public function next()
@@ -49,8 +52,11 @@  discard block
 block discarded – undo
49 52
     public function hasNext()
50 53
     {
51 54
         $this->next();
52
-        if ($this->valid()) return $this->current();
53
-        else return false;
55
+        if ($this->valid()) {
56
+        	return $this->current();
57
+        } else {
58
+        	return false;
59
+        }
54 60
     }
55 61
 
56 62
     public function rewind()
Please login to merge, or discard this patch.
src/models/Tracker.php 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -20,79 +20,79 @@
 block discarded – undo
20 20
  */
21 21
 class Tracker{
22 22
     
23
-    /**
24
-     * Get tracker data by Role +- Study Filter
25
-     * @param string $role
26
-     * @param PDO $linkpdo
27
-     * @param string $study
28
-     * @return array
29
-     */
30
-    public static function getTrackerByRoleStudy(string $role, PDO $linkpdo, $study=null){
31
-        if($study==null){
32
-            $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE role=:role');
33
-            $queryTracker->execute(array(
34
-                'role' => $role
35
-            ));
23
+	/**
24
+	 * Get tracker data by Role +- Study Filter
25
+	 * @param string $role
26
+	 * @param PDO $linkpdo
27
+	 * @param string $study
28
+	 * @return array
29
+	 */
30
+	public static function getTrackerByRoleStudy(string $role, PDO $linkpdo, $study=null){
31
+		if($study==null){
32
+			$queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE role=:role');
33
+			$queryTracker->execute(array(
34
+				'role' => $role
35
+			));
36 36
            
37
-        }else{
38
-            $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND role=:role');
39
-            $queryTracker->execute(array('study' => $study,
40
-                'role' => $role,
41
-            ));
37
+		}else{
38
+			$queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND role=:role');
39
+			$queryTracker->execute(array('study' => $study,
40
+				'role' => $role,
41
+			));
42 42
             
43
-        }
44
-        $trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
43
+		}
44
+		$trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
45 45
 
46
-        return $trackerResult;
47
-    }
46
+		return $trackerResult;
47
+	}
48 48
     
49
-    /**
50
-     * Return logged users messages of a study
51
-     * @param string $study
52
-     * @param PDO $linkpdo
53
-     * @return array
54
-     */
55
-    public static function getMessageStudy(string $study, PDO $linkpdo){
56
-        $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND action_type="Send Message"');
57
-        $queryTracker->execute(array('study' => $study));
58
-        $trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
59
-        return $trackerResult;
60
-    }
49
+	/**
50
+	 * Return logged users messages of a study
51
+	 * @param string $study
52
+	 * @param PDO $linkpdo
53
+	 * @return array
54
+	 */
55
+	public static function getMessageStudy(string $study, PDO $linkpdo){
56
+		$queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND action_type="Send Message"');
57
+		$queryTracker->execute(array('study' => $study));
58
+		$trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
59
+		return $trackerResult;
60
+	}
61 61
     
62
-    /**
63
-     * Get tracker data for a specific visit
64
-     * @param string $id_visit
65
-     * @param PDO $linkpdo
66
-     * @return array
67
-     */
68
-    public static function getTackerForVisit(string $id_visit, PDO $linkpdo){
69
-        $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE id_visit = :id_visit ORDER BY date');
70
-        $queryTracker->execute(array('id_visit' => $id_visit));
71
-        $trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
72
-        return $trackerResult;    
73
-    }
62
+	/**
63
+	 * Get tracker data for a specific visit
64
+	 * @param string $id_visit
65
+	 * @param PDO $linkpdo
66
+	 * @return array
67
+	 */
68
+	public static function getTackerForVisit(string $id_visit, PDO $linkpdo){
69
+		$queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE id_visit = :id_visit ORDER BY date');
70
+		$queryTracker->execute(array('id_visit' => $id_visit));
71
+		$trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
72
+		return $trackerResult;    
73
+	}
74 74
     
75
-    /**
76
-     * Activity logger to log user activity in database
77
-     * Activity should be an associative key, will be JSON encoded
78
-     */
79
-    public static function logActivity($username, $role, $study, $id_visit, $actionType, $actionDetails){
75
+	/**
76
+	 * Activity logger to log user activity in database
77
+	 * Activity should be an associative key, will be JSON encoded
78
+	 */
79
+	public static function logActivity($username, $role, $study, $id_visit, $actionType, $actionDetails){
80 80
         
81
-        $linkpdo=Session::getLinkpdo();
81
+		$linkpdo=Session::getLinkpdo();
82 82
         
83
-        $connecter = $linkpdo->prepare('INSERT INTO tracker (date, username, role, study, id_visit, action_type, action_details)
83
+		$connecter = $linkpdo->prepare('INSERT INTO tracker (date, username, role, study, id_visit, action_type, action_details)
84 84
 								VALUES(:date, :username, :role, :study, :id_visit, :action_type, :action_details)' );
85 85
         
86
-        $connecter->execute(array(
87
-            "username" => $username,
88
-            "role" => $role,
89
-            "date"=> date('Y-m-d H:i:s') . substr((string)microtime(), 1, 6),
90
-            "study"=>$study,
91
-            "id_visit"=>$id_visit,
92
-            "action_type"=>$actionType,
93
-            "action_details"=>json_encode($actionDetails)
94
-        ));
86
+		$connecter->execute(array(
87
+			"username" => $username,
88
+			"role" => $role,
89
+			"date"=> date('Y-m-d H:i:s') . substr((string)microtime(), 1, 6),
90
+			"study"=>$study,
91
+			"id_visit"=>$id_visit,
92
+			"action_type"=>$actionType,
93
+			"action_details"=>json_encode($actionDetails)
94
+		));
95 95
         
96
-    }
96
+	}
97 97
     
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @author salim
19 19
  *
20 20
  */
21
-class Tracker{
21
+class Tracker {
22 22
     
23 23
     /**
24 24
      * Get tracker data by Role +- Study Filter
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
      * @param string $study
28 28
      * @return array
29 29
      */
30
-    public static function getTrackerByRoleStudy(string $role, PDO $linkpdo, $study=null){
31
-        if($study==null){
32
-            $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE role=:role');
30
+    public static function getTrackerByRoleStudy(string $role, PDO $linkpdo, $study=null) {
31
+        if ($study == null) {
32
+            $queryTracker=$linkpdo->prepare('SELECT * FROM tracker WHERE role=:role');
33 33
             $queryTracker->execute(array(
34 34
                 'role' => $role
35 35
             ));
36 36
            
37
-        }else{
38
-            $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND role=:role');
37
+        }else {
38
+            $queryTracker=$linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND role=:role');
39 39
             $queryTracker->execute(array('study' => $study,
40 40
                 'role' => $role,
41 41
             ));
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
      * @param PDO $linkpdo
53 53
      * @return array
54 54
      */
55
-    public static function getMessageStudy(string $study, PDO $linkpdo){
56
-        $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND action_type="Send Message"');
55
+    public static function getMessageStudy(string $study, PDO $linkpdo) {
56
+        $queryTracker=$linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND action_type="Send Message"');
57 57
         $queryTracker->execute(array('study' => $study));
58 58
         $trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
59 59
         return $trackerResult;
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
      * @param PDO $linkpdo
66 66
      * @return array
67 67
      */
68
-    public static function getTackerForVisit(string $id_visit, PDO $linkpdo){
69
-        $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE id_visit = :id_visit ORDER BY date');
68
+    public static function getTackerForVisit(string $id_visit, PDO $linkpdo) {
69
+        $queryTracker=$linkpdo->prepare('SELECT * FROM tracker WHERE id_visit = :id_visit ORDER BY date');
70 70
         $queryTracker->execute(array('id_visit' => $id_visit));
71 71
         $trackerResult=$queryTracker->fetchAll(PDO::FETCH_ASSOC);
72 72
         return $trackerResult;    
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
      * Activity logger to log user activity in database
77 77
      * Activity should be an associative key, will be JSON encoded
78 78
      */
79
-    public static function logActivity($username, $role, $study, $id_visit, $actionType, $actionDetails){
79
+    public static function logActivity($username, $role, $study, $id_visit, $actionType, $actionDetails) {
80 80
         
81 81
         $linkpdo=Session::getLinkpdo();
82 82
         
83
-        $connecter = $linkpdo->prepare('INSERT INTO tracker (date, username, role, study, id_visit, action_type, action_details)
83
+        $connecter=$linkpdo->prepare('INSERT INTO tracker (date, username, role, study, id_visit, action_type, action_details)
84 84
 								VALUES(:date, :username, :role, :study, :id_visit, :action_type, :action_details)' );
85 85
         
86 86
         $connecter->execute(array(
87 87
             "username" => $username,
88 88
             "role" => $role,
89
-            "date"=> date('Y-m-d H:i:s') . substr((string)microtime(), 1, 6),
89
+            "date"=> date('Y-m-d H:i:s').substr((string)microtime(), 1, 6),
90 90
             "study"=>$study,
91 91
             "id_visit"=>$id_visit,
92 92
             "action_type"=>$actionType,
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
                 'role' => $role
35 35
             ));
36 36
            
37
-        }else{
37
+        } else{
38 38
             $queryTracker = $linkpdo->prepare('SELECT * FROM tracker WHERE study = :study AND role=:role');
39 39
             $queryTracker->execute(array('study' => $study,
40 40
                 'role' => $role,
Please login to merge, or discard this patch.
src/models/Import_Patient.php 3 patches
Braces   +15 added lines, -14 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
 			    if(GAELO_DATE_FORMAT=='m.d.Y'){
59 59
 			    	$birthDay=intval($birthDateArray[1]);
60 60
 			    	$birthMonth=intval($birthDateArray[0]);
61
-			    }
62
-			    else if(GAELO_DATE_FORMAT=='d.m.Y'){
61
+			    } else if(GAELO_DATE_FORMAT=='d.m.Y'){
63 62
 			    	$birthDay=intval($birthDateArray[0]);
64 63
 			    	$birthMonth=intval($birthDateArray[1]);
65 64
 			    }
@@ -71,8 +70,7 @@  discard block
 block discarded – undo
71 70
 				//Store the patient result import process in this object
72 71
 				if ($insertddb){
73 72
 						$this->sucessList[] = $patientNumber;
74
-				}
75
-				else{
73
+				} else{
76 74
 					$patientFailed['PatientNumber']=$patientNumber;
77 75
 					$patientFailed['Reason']="Can't write to DB, wrong date or other wrong input";
78 76
 					$this->failList[]=$patientFailed;
@@ -84,8 +82,7 @@  discard block
 block discarded – undo
84 82
 				if(!$isExistingCenter) {
85 83
 				    if( empty($patientInvestigatorNumCenter) ){
86 84
 				        $this->failList['Missing Num Center'][]=$patientNumber;
87
-				    }
88
-				    else {
85
+				    } else {
89 86
 				        $this->failList['Unknown Center'][]=$patientNumber;
90 87
 				    }
91 88
 
@@ -117,8 +114,7 @@  discard block
 block discarded – undo
117 114
 	    if(GAELO_DATE_FORMAT=='m.d.Y'){
118 115
 	        $registrationDay=intval($dateNbArray[1]);
119 116
 	        $registrationMonth=intval($dateNbArray[0]);
120
-	    }
121
-	    else if(GAELO_DATE_FORMAT=='d.m.Y'){
117
+	    } else if(GAELO_DATE_FORMAT=='d.m.Y'){
122 118
 	        $registrationDay=intval($dateNbArray[0]);
123 119
 	        $registrationMonth=intval($dateNbArray[1]);
124 120
 	    }
@@ -148,7 +144,7 @@  discard block
 block discarded – undo
148 144
 	private function isNewPatient($patientCode){
149 145
 	    try{
150 146
 	        new Patient($patientCode, $this->linkpdo);
151
-	    }catch(Exception $e1){
147
+	    } catch(Exception $e1){
152 148
 	        return true;
153 149
 	    }
154 150
 	    
@@ -176,11 +172,13 @@  discard block
 block discarded – undo
176 172
      * @return boolean
177 173
      */
178 174
 	private function isExistingCenter($patientNumCenter){
179
-	    if(is_null($patientNumCenter) || strlen($patientNumCenter)==0) return false;
175
+	    if(is_null($patientNumCenter) || strlen($patientNumCenter)==0) {
176
+	    	return false;
177
+	    }
180 178
 	    
181 179
 	    try{
182 180
 	        new Center($this->linkpdo, $patientNumCenter);
183
-	    }catch(Exception $e1){
181
+	    } catch(Exception $e1){
184 182
 	        return false;
185 183
 	    }
186 184
 	    
@@ -250,11 +248,14 @@  discard block
 block discarded – undo
250 248
 	        foreach ($this->failList as $key=>$value){
251 249
 	            if(! empty($value)){
252 250
 	                $failReport=$failReport.$key.':<br>';
253
-	                if(is_array($value)) $failReport=$failReport.implode('<br>',$value).'<br>';
254
-	                else $failReport=$failReport.$value.'<br>';
251
+	                if(is_array($value)) {
252
+	                	$failReport=$failReport.implode('<br>',$value).'<br>';
253
+	                } else {
254
+	                	$failReport=$failReport.$value.'<br>';
255
+	                }
255 256
 	            }
256 257
 	        }
257
-	    }else{
258
+	    } else{
258 259
 	        $failReport=$failReport.' None <br>' ;
259 260
 	    }
260 261
 	    
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	private $studyObject;
28 28
 	
29 29
 	public function __construct($originalJson, $study, $linkpdo){
30
-	    $this->linkpdo= $linkpdo;
30
+		$this->linkpdo= $linkpdo;
31 31
 		//Store the JSON file and the target study
32
-	    $this->originalJson=$originalJson;
32
+		$this->originalJson=$originalJson;
33 33
 		$this->study = $study;
34 34
 		$this->studyObject = new Study($study, $linkpdo);
35 35
 	}
@@ -37,17 +37,17 @@  discard block
 block discarded – undo
37 37
 	public function readJson(){
38 38
 		$jsonImport=json_decode($this->originalJson, true);
39 39
 		
40
-        //For each patient from the array list
40
+		//For each patient from the array list
41 41
 		foreach ($jsonImport as $patient){
42 42
 			//Get patient info
43
-		    $patientNumber=$patient['patientNumber'];
44
-		    $patientLastName=$patient['lastName'];
45
-		    $patientFirstName=$patient['firstName'];
46
-		    $patientGender=$patient['gender'];
47
-		    $patientInvestigatorNumCenter=$patient['investigatorNumCenter'];
48
-		    $patientDateOfBirth=$patient['dateOfBirth'];
49
-		    $patientInvestigatorName=$patient['investigatorName'];
50
-		    $patientRegistrationDate= $this->parseRegistrationDate($patient['registrationDate']);
43
+			$patientNumber=$patient['patientNumber'];
44
+			$patientLastName=$patient['lastName'];
45
+			$patientFirstName=$patient['firstName'];
46
+			$patientGender=$patient['gender'];
47
+			$patientInvestigatorNumCenter=$patient['investigatorNumCenter'];
48
+			$patientDateOfBirth=$patient['dateOfBirth'];
49
+			$patientInvestigatorName=$patient['investigatorName'];
50
+			$patientRegistrationDate= $this->parseRegistrationDate($patient['registrationDate']);
51 51
 		    
52 52
 			//Check condition before import
53 53
 			$isNewPatient=$this->isNewPatient($patientNumber);
@@ -56,20 +56,20 @@  discard block
 block discarded – undo
56 56
 			$isPrefixCorrect = $this->isCorrectPrefix($patientNumber);
57 57
 			
58 58
 			if ($isNewPatient && $isCorrectPatientNumberLenght && $isPrefixCorrect && $isExistingCenter && !empty($patientRegistrationDate) ){
59
-			    //Store in DB
60
-			    $birthDateArray=explode("/", $patientDateOfBirth);
61
-			    if(GAELO_DATE_FORMAT=='m.d.Y'){
62
-			    	$birthDay=intval($birthDateArray[1]);
63
-			    	$birthMonth=intval($birthDateArray[0]);
64
-			    }
65
-			    else if(GAELO_DATE_FORMAT=='d.m.Y'){
66
-			    	$birthDay=intval($birthDateArray[0]);
67
-			    	$birthMonth=intval($birthDateArray[1]);
68
-			    }
69
-			    $birthYear=intval($birthDateArray[2]);
59
+				//Store in DB
60
+				$birthDateArray=explode("/", $patientDateOfBirth);
61
+				if(GAELO_DATE_FORMAT=='m.d.Y'){
62
+					$birthDay=intval($birthDateArray[1]);
63
+					$birthMonth=intval($birthDateArray[0]);
64
+				}
65
+				else if(GAELO_DATE_FORMAT=='d.m.Y'){
66
+					$birthDay=intval($birthDateArray[0]);
67
+					$birthMonth=intval($birthDateArray[1]);
68
+				}
69
+				$birthYear=intval($birthDateArray[2]);
70 70
 			    
71 71
 				$insertddb=$this->addPatientToDatabase($patientNumber, $patientLastName, $patientFirstName, $patientGender,
72
-				    $patientInvestigatorNumCenter, $patientRegistrationDate, $birthDay,$birthMonth, $birthYear, $patientInvestigatorName);
72
+					$patientInvestigatorNumCenter, $patientRegistrationDate, $birthDay,$birthMonth, $birthYear, $patientInvestigatorName);
73 73
 				
74 74
 				//Store the patient result import process in this object
75 75
 				if ($insertddb){
@@ -85,21 +85,21 @@  discard block
 block discarded – undo
85 85
 			} else{
86 86
 			    
87 87
 				if(!$isExistingCenter) {
88
-				    if( empty($patientInvestigatorNumCenter) ){
89
-				        $this->failList['Missing Num Center'][]=$patientNumber;
90
-				    }
91
-				    else {
92
-				        $this->failList['Unknown Center'][]=$patientNumber;
93
-				    }
88
+					if( empty($patientInvestigatorNumCenter) ){
89
+						$this->failList['Missing Num Center'][]=$patientNumber;
90
+					}
91
+					else {
92
+						$this->failList['Unknown Center'][]=$patientNumber;
93
+					}
94 94
 
95 95
 				} else if(! $isCorrectPatientNumberLenght){
96
-				    $this->failList['Wrong PatientNumber length'][]=$patientNumber;
96
+					$this->failList['Wrong PatientNumber length'][]=$patientNumber;
97 97
 				    
98 98
 				} else if(!$isNewPatient ){
99
-				    $this->failList['Patient already in Database'][]=$patientNumber;
99
+					$this->failList['Patient already in Database'][]=$patientNumber;
100 100
 				    
101 101
 				} else if(empty($patientRegistrationDate)){
102
-				    $this->failList['Empty Registration Date'][]=$patientNumber;
102
+					$this->failList['Empty Registration Date'][]=$patientNumber;
103 103
 				} else if( ! $isPrefixCorrect){
104 104
 					$this->failList['Wrong Patient Code Prefix'][]=$patientNumber;
105 105
 				}
@@ -117,30 +117,30 @@  discard block
 block discarded – undo
117 117
 	 * @return NULL|DateTime
118 118
 	 */
119 119
 	private function parseRegistrationDate(?string $registrationDate){
120
-	    $dateNbArray=explode('/', $registrationDate);
120
+		$dateNbArray=explode('/', $registrationDate);
121 121
 	    
122
-	    if(GAELO_DATE_FORMAT=='m.d.Y'){
123
-	        $registrationDay=intval($dateNbArray[1]);
124
-	        $registrationMonth=intval($dateNbArray[0]);
125
-	    }
126
-	    else if(GAELO_DATE_FORMAT=='d.m.Y'){
127
-	        $registrationDay=intval($dateNbArray[0]);
128
-	        $registrationMonth=intval($dateNbArray[1]);
129
-	    }
122
+		if(GAELO_DATE_FORMAT=='m.d.Y'){
123
+			$registrationDay=intval($dateNbArray[1]);
124
+			$registrationMonth=intval($dateNbArray[0]);
125
+		}
126
+		else if(GAELO_DATE_FORMAT=='d.m.Y'){
127
+			$registrationDay=intval($dateNbArray[0]);
128
+			$registrationMonth=intval($dateNbArray[1]);
129
+		}
130 130
 	    
131
-	    $registrationYear=intval($dateNbArray[2]);
131
+		$registrationYear=intval($dateNbArray[2]);
132 132
 	    
133
-	    if($registrationDay==0 || $registrationMonth==0 ||$registrationYear==0){
134
-	        return null;
135
-	    }
133
+		if($registrationDay==0 || $registrationMonth==0 ||$registrationYear==0){
134
+			return null;
135
+		}
136 136
 	    
137
-	    try {
138
-	        $dateResult = new DateTime($registrationYear.'-'.$registrationMonth.'-'.$registrationDay);
139
-	    } catch (Exception $e) {
140
-	        error_log( $e->getMessage());
141
-	        return null;
142
-	    }
143
-	    return $dateResult;
137
+		try {
138
+			$dateResult = new DateTime($registrationYear.'-'.$registrationMonth.'-'.$registrationDay);
139
+		} catch (Exception $e) {
140
+			error_log( $e->getMessage());
141
+			return null;
142
+		}
143
+		return $dateResult;
144 144
 	   
145 145
 	}
146 146
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 	 * @return boolean
152 152
 	 */
153 153
 	private function isNewPatient($patientCode){
154
-	    try{
155
-	        new Patient($patientCode, $this->linkpdo);
156
-	    }catch(Exception $e1){
157
-	        return true;
158
-	    }
154
+		try{
155
+			new Patient($patientCode, $this->linkpdo);
156
+		}catch(Exception $e1){
157
+			return true;
158
+		}
159 159
 	    
160
-	    return false;
160
+		return false;
161 161
 	}
162 162
 
163 163
 	/**
@@ -192,21 +192,21 @@  discard block
 block discarded – undo
192 192
 		return (substr($string, 0, $len) === $startString); 
193 193
 	} 
194 194
 
195
-    /**
196
-     * Check that patient's center is one of known center in the plateform
197
-     * @param $patientNumCenter
198
-     * @return boolean
199
-     */
195
+	/**
196
+	 * Check that patient's center is one of known center in the plateform
197
+	 * @param $patientNumCenter
198
+	 * @return boolean
199
+	 */
200 200
 	private function isExistingCenter($patientNumCenter){
201
-	    if(is_null($patientNumCenter) || strlen($patientNumCenter)==0) return false;
201
+		if(is_null($patientNumCenter) || strlen($patientNumCenter)==0) return false;
202 202
 	    
203
-	    try{
204
-	        new Center($this->linkpdo, $patientNumCenter);
205
-	    }catch(Exception $e1){
206
-	        return false;
207
-	    }
203
+		try{
204
+			new Center($this->linkpdo, $patientNumCenter);
205
+		}catch(Exception $e1){
206
+			return false;
207
+		}
208 208
 	    
209
-	    return true;
209
+		return true;
210 210
 	}
211 211
 
212 212
 	/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @return boolean
224 224
 	 */
225 225
 	private function addPatientToDatabase($patientNumber, string $patientLastName, string $patientFirstName, string $patientGender
226
-	    , $patientInvestigatorNumCenter, $dateRegistration, $patientBirthDay, $patientBirthMonth, $patientBirthYear, string $patientInvestigatorName){
226
+		, $patientInvestigatorNumCenter, $dateRegistration, $patientBirthDay, $patientBirthMonth, $patientBirthYear, string $patientInvestigatorName){
227 227
 		
228 228
 		try {
229 229
 			$insert_bdd = $this->linkpdo->prepare('INSERT INTO patients(study, code, first_name, last_name, gender, birth_day, birth_month, birth_year, registration_date, investigator_name, center)
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			$insert_bdd->execute(array('code' => $patientNumber,
233 233
 													'first_name' => @strtoupper($patientFirstName[0]),
234 234
 													'last_name' => @strtoupper($patientLastName[0]),
235
-                                                    'gender' => @strtoupper($patientGender[0]),
235
+													'gender' => @strtoupper($patientGender[0]),
236 236
 													'birth_day' => $patientBirthDay,
237 237
 													'birth_month' => $patientBirthMonth,
238 238
 													'birth_year' => $patientBirthYear,
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 													'study' => $this->study));
243 243
 			$success=true;
244 244
 		} catch (Exception $e) {
245
-		    $success=false;
245
+			$success=false;
246 246
 			error_log($e);
247 247
 		}
248 248
 
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 	}
252 252
 	
253 253
 	public function getHTMLImportAnswer(){
254
-	    return $this->buildSuccessAnswer().$this->buildErrorAnswer();
254
+		return $this->buildSuccessAnswer().$this->buildErrorAnswer();
255 255
 	}
256 256
 	
257 257
 	public function getTextImportAnswer(){
258
-	    //Prepare Html2PlainText for email validity (both version to enhance spam validation)
259
-	    $htmlMessageObject = new \Html2Text\Html2Text($this->getHTMLImportAnswer());
260
-	    return $htmlMessageObject->getText();
258
+		//Prepare Html2PlainText for email validity (both version to enhance spam validation)
259
+		$htmlMessageObject = new \Html2Text\Html2Text($this->getHTMLImportAnswer());
260
+		return $htmlMessageObject->getText();
261 261
 	    
262 262
 	}
263 263
 	
@@ -266,21 +266,21 @@  discard block
 block discarded – undo
266 266
 	 * @return string
267 267
 	 */
268 268
 	private function buildErrorAnswer(){
269
-	    //List of failed patients
270
-	    $failReport='Failed Patients: <br>';
271
-	    if ( !empty($this->failList) ){
272
-	        foreach ($this->failList as $key=>$value){
273
-	            if(! empty($value)){
274
-	                $failReport=$failReport.$key.':<br>';
275
-	                if(is_array($value)) $failReport=$failReport.implode('<br>',$value).'<br>';
276
-	                else $failReport=$failReport.$value.'<br>';
277
-	            }
278
-	        }
279
-	    }else{
280
-	        $failReport=$failReport.' None <br>' ;
281
-	    }
269
+		//List of failed patients
270
+		$failReport='Failed Patients: <br>';
271
+		if ( !empty($this->failList) ){
272
+			foreach ($this->failList as $key=>$value){
273
+				if(! empty($value)){
274
+					$failReport=$failReport.$key.':<br>';
275
+					if(is_array($value)) $failReport=$failReport.implode('<br>',$value).'<br>';
276
+					else $failReport=$failReport.$value.'<br>';
277
+				}
278
+			}
279
+		}else{
280
+			$failReport=$failReport.' None <br>' ;
281
+		}
282 282
 	    
283
-	    return $failReport;
283
+		return $failReport;
284 284
 	}
285 285
 	
286 286
 	/**
@@ -288,18 +288,18 @@  discard block
 block discarded – undo
288 288
 	 * @return string
289 289
 	 */
290 290
 	private function buildSuccessAnswer(){
291
-	    //List of succeded patients
292
-	    $successReport='Success Patients: <br>';
293
-	    if ( !empty($this->sucessList) ){
294
-	        foreach ($this->sucessList as $value) {
295
-	            $success=$value;
296
-	            $successReport=$successReport.$success.'<br>';
297
-	        }
298
-	    } else {
299
-	        $successReport=$successReport.' None <br>';
300
-	    }
291
+		//List of succeded patients
292
+		$successReport='Success Patients: <br>';
293
+		if ( !empty($this->sucessList) ){
294
+			foreach ($this->sucessList as $value) {
295
+				$success=$value;
296
+				$successReport=$successReport.$success.'<br>';
297
+			}
298
+		} else {
299
+			$successReport=$successReport.' None <br>';
300
+		}
301 301
 	    
302
-	    return $successReport;
302
+		return $successReport;
303 303
 	}
304 304
 
305 305
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * Import patient in study (import data from Json structured file)
18 18
  */
19 19
 
20
-class Import_Patient{
20
+class Import_Patient {
21 21
 
22 22
 	private $originalJson;
23 23
 	private $linkpdo;
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
 	private $study;
27 27
 	private $studyObject;
28 28
 	
29
-	public function __construct($originalJson, $study, $linkpdo){
30
-	    $this->linkpdo= $linkpdo;
29
+	public function __construct($originalJson, $study, $linkpdo) {
30
+	    $this->linkpdo=$linkpdo;
31 31
 		//Store the JSON file and the target study
32 32
 	    $this->originalJson=$originalJson;
33
-		$this->study = $study;
34
-		$this->studyObject = new Study($study, $linkpdo);
33
+		$this->study=$study;
34
+		$this->studyObject=new Study($study, $linkpdo);
35 35
 	}
36 36
 
37
-	public function readJson(){
37
+	public function readJson() {
38 38
 		$jsonImport=json_decode($this->originalJson, true);
39 39
 		
40 40
         //For each patient from the array list
41
-		foreach ($jsonImport as $patient){
41
+		foreach ($jsonImport as $patient) {
42 42
 			//Get patient info
43 43
 		    $patientNumber=$patient['patientNumber'];
44 44
 		    $patientLastName=$patient['lastName'];
@@ -47,60 +47,60 @@  discard block
 block discarded – undo
47 47
 		    $patientInvestigatorNumCenter=$patient['investigatorNumCenter'];
48 48
 		    $patientDateOfBirth=$patient['dateOfBirth'];
49 49
 		    $patientInvestigatorName=$patient['investigatorName'];
50
-		    $patientRegistrationDate= $this->parseRegistrationDate($patient['registrationDate']);
50
+		    $patientRegistrationDate=$this->parseRegistrationDate($patient['registrationDate']);
51 51
 		    
52 52
 			//Check condition before import
53 53
 			$isNewPatient=$this->isNewPatient($patientNumber);
54 54
 			$isCorrectPatientNumberLenght=$this->isCorrectPatientNumberLenght($patientNumber);
55 55
 			$isExistingCenter=$this->isExistingCenter($patientInvestigatorNumCenter);
56
-			$isPrefixCorrect = $this->isCorrectPrefix($patientNumber);
56
+			$isPrefixCorrect=$this->isCorrectPrefix($patientNumber);
57 57
 			
58
-			if ($isNewPatient && $isCorrectPatientNumberLenght && $isPrefixCorrect && $isExistingCenter && !empty($patientRegistrationDate) ){
58
+			if ($isNewPatient && $isCorrectPatientNumberLenght && $isPrefixCorrect && $isExistingCenter && !empty($patientRegistrationDate)) {
59 59
 			    //Store in DB
60 60
 			    $birthDateArray=explode("/", $patientDateOfBirth);
61
-			    if(GAELO_DATE_FORMAT=='m.d.Y'){
61
+			    if (GAELO_DATE_FORMAT == 'm.d.Y') {
62 62
 			    	$birthDay=intval($birthDateArray[1]);
63 63
 			    	$birthMonth=intval($birthDateArray[0]);
64 64
 			    }
65
-			    else if(GAELO_DATE_FORMAT=='d.m.Y'){
65
+			    else if (GAELO_DATE_FORMAT == 'd.m.Y') {
66 66
 			    	$birthDay=intval($birthDateArray[0]);
67 67
 			    	$birthMonth=intval($birthDateArray[1]);
68 68
 			    }
69 69
 			    $birthYear=intval($birthDateArray[2]);
70 70
 			    
71 71
 				$insertddb=$this->addPatientToDatabase($patientNumber, $patientLastName, $patientFirstName, $patientGender,
72
-				    $patientInvestigatorNumCenter, $patientRegistrationDate, $birthDay,$birthMonth, $birthYear, $patientInvestigatorName);
72
+				    $patientInvestigatorNumCenter, $patientRegistrationDate, $birthDay, $birthMonth, $birthYear, $patientInvestigatorName);
73 73
 				
74 74
 				//Store the patient result import process in this object
75
-				if ($insertddb){
76
-						$this->sucessList[] = $patientNumber;
75
+				if ($insertddb) {
76
+						$this->sucessList[]=$patientNumber;
77 77
 				}
78
-				else{
78
+				else {
79 79
 					$patientFailed['PatientNumber']=$patientNumber;
80 80
 					$patientFailed['Reason']="Can't write to DB, wrong date or other wrong input";
81 81
 					$this->failList[]=$patientFailed;
82 82
 				}
83 83
 
84 84
 			//If conditions not met, add to the fail list with the respective error reason
85
-			} else{
85
+			}else {
86 86
 			    
87
-				if(!$isExistingCenter) {
88
-				    if( empty($patientInvestigatorNumCenter) ){
87
+				if (!$isExistingCenter) {
88
+				    if (empty($patientInvestigatorNumCenter)) {
89 89
 				        $this->failList['Missing Num Center'][]=$patientNumber;
90 90
 				    }
91 91
 				    else {
92 92
 				        $this->failList['Unknown Center'][]=$patientNumber;
93 93
 				    }
94 94
 
95
-				} else if(! $isCorrectPatientNumberLenght){
95
+				}else if (!$isCorrectPatientNumberLenght) {
96 96
 				    $this->failList['Wrong PatientNumber length'][]=$patientNumber;
97 97
 				    
98
-				} else if(!$isNewPatient ){
98
+				}else if (!$isNewPatient) {
99 99
 				    $this->failList['Patient already in Database'][]=$patientNumber;
100 100
 				    
101
-				} else if(empty($patientRegistrationDate)){
101
+				}else if (empty($patientRegistrationDate)) {
102 102
 				    $this->failList['Empty Registration Date'][]=$patientNumber;
103
-				} else if( ! $isPrefixCorrect){
103
+				}else if (!$isPrefixCorrect) {
104 104
 					$this->failList['Wrong Patient Code Prefix'][]=$patientNumber;
105 105
 				}
106 106
 				
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
 	 * @param string $registrationDate
117 117
 	 * @return NULL|DateTime
118 118
 	 */
119
-	private function parseRegistrationDate(?string $registrationDate){
119
+	private function parseRegistrationDate(?string $registrationDate) {
120 120
 	    $dateNbArray=explode('/', $registrationDate);
121 121
 	    
122
-	    if(GAELO_DATE_FORMAT=='m.d.Y'){
122
+	    if (GAELO_DATE_FORMAT == 'm.d.Y') {
123 123
 	        $registrationDay=intval($dateNbArray[1]);
124 124
 	        $registrationMonth=intval($dateNbArray[0]);
125 125
 	    }
126
-	    else if(GAELO_DATE_FORMAT=='d.m.Y'){
126
+	    else if (GAELO_DATE_FORMAT == 'd.m.Y') {
127 127
 	        $registrationDay=intval($dateNbArray[0]);
128 128
 	        $registrationMonth=intval($dateNbArray[1]);
129 129
 	    }
130 130
 	    
131 131
 	    $registrationYear=intval($dateNbArray[2]);
132 132
 	    
133
-	    if($registrationDay==0 || $registrationMonth==0 ||$registrationYear==0){
133
+	    if ($registrationDay == 0 || $registrationMonth == 0 || $registrationYear == 0) {
134 134
 	        return null;
135 135
 	    }
136 136
 	    
137 137
 	    try {
138
-	        $dateResult = new DateTime($registrationYear.'-'.$registrationMonth.'-'.$registrationDay);
139
-	    } catch (Exception $e) {
140
-	        error_log( $e->getMessage());
138
+	        $dateResult=new DateTime($registrationYear.'-'.$registrationMonth.'-'.$registrationDay);
139
+	    }catch (Exception $e) {
140
+	        error_log($e->getMessage());
141 141
 	        return null;
142 142
 	    }
143 143
 	    return $dateResult;
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 	 * @param $patientCode
151 151
 	 * @return boolean
152 152
 	 */
153
-	private function isNewPatient($patientCode){
154
-	    try{
153
+	private function isNewPatient($patientCode) {
154
+	    try {
155 155
 	        new Patient($patientCode, $this->linkpdo);
156
-	    }catch(Exception $e1){
156
+	    }catch (Exception $e1) {
157 157
 	        return true;
158 158
 	    }
159 159
 	    
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
 	 * @param $patientNumber
166 166
 	 * @return boolean
167 167
 	 */
168
-	private function isCorrectPatientNumberLenght($patientNumber){
168
+	private function isCorrectPatientNumberLenght($patientNumber) {
169 169
 		$lenghtImport=strlen($patientNumber);
170 170
 		
171
-		if($lenghtImport == GAELO_PATIENT_CODE_LENGHT){
171
+		if ($lenghtImport == GAELO_PATIENT_CODE_LENGHT) {
172 172
 			return true;
173
-		} else{
173
+		}else {
174 174
 			return false;
175 175
 		}
176 176
 	}
177 177
 
178
-	private function isCorrectPrefix($patientNumber){
178
+	private function isCorrectPrefix($patientNumber) {
179 179
 		//If no prefix return true
180
-		if(empty($this->studyObject->patientCodePrefix)){
180
+		if (empty($this->studyObject->patientCodePrefix)) {
181 181
 			return true;
182 182
 		}
183 183
 		//test that patient code start with study prefix
184
-		$patientNumberString = strval($patientNumber);
185
-		$studyPrefixString = strval($this->studyObject->patientCodePrefix);
186
-		return $this->startsWith( $patientNumberString, $studyPrefixString );
184
+		$patientNumberString=strval($patientNumber);
185
+		$studyPrefixString=strval($this->studyObject->patientCodePrefix);
186
+		return $this->startsWith($patientNumberString, $studyPrefixString);
187 187
 
188 188
 	}
189 189
 
190
-	private function startsWith (string $string, string $startString) { 
191
-		$len = strlen($startString); 
190
+	private function startsWith(string $string, string $startString) { 
191
+		$len=strlen($startString); 
192 192
 		return (substr($string, 0, $len) === $startString); 
193 193
 	} 
194 194
 
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
      * @param $patientNumCenter
198 198
      * @return boolean
199 199
      */
200
-	private function isExistingCenter($patientNumCenter){
201
-	    if(is_null($patientNumCenter) || strlen($patientNumCenter)==0) return false;
200
+	private function isExistingCenter($patientNumCenter) {
201
+	    if (is_null($patientNumCenter) || strlen($patientNumCenter) == 0) return false;
202 202
 	    
203
-	    try{
203
+	    try {
204 204
 	        new Center($this->linkpdo, $patientNumCenter);
205
-	    }catch(Exception $e1){
205
+	    }catch (Exception $e1) {
206 206
 	        return false;
207 207
 	    }
208 208
 	    
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 	 * @return boolean
224 224
 	 */
225 225
 	private function addPatientToDatabase($patientNumber, string $patientLastName, string $patientFirstName, string $patientGender
226
-	    , $patientInvestigatorNumCenter, $dateRegistration, $patientBirthDay, $patientBirthMonth, $patientBirthYear, string $patientInvestigatorName){
226
+	    , $patientInvestigatorNumCenter, $dateRegistration, $patientBirthDay, $patientBirthMonth, $patientBirthYear, string $patientInvestigatorName) {
227 227
 		
228 228
 		try {
229
-			$insert_bdd = $this->linkpdo->prepare('INSERT INTO patients(study, code, first_name, last_name, gender, birth_day, birth_month, birth_year, registration_date, investigator_name, center)
229
+			$insert_bdd=$this->linkpdo->prepare('INSERT INTO patients(study, code, first_name, last_name, gender, birth_day, birth_month, birth_year, registration_date, investigator_name, center)
230 230
 			VALUES(:study, :code, :first_name, :last_name, :gender, :birth_day, :birth_month, :birth_year, :registration_date, :investigator_name, :center)');
231 231
 			
232 232
 			$insert_bdd->execute(array('code' => $patientNumber,
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 													'center' => $patientInvestigatorNumCenter,
242 242
 													'study' => $this->study));
243 243
 			$success=true;
244
-		} catch (Exception $e) {
244
+		}catch (Exception $e) {
245 245
 		    $success=false;
246 246
 			error_log($e);
247 247
 		}
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 
251 251
 	}
252 252
 	
253
-	public function getHTMLImportAnswer(){
253
+	public function getHTMLImportAnswer() {
254 254
 	    return $this->buildSuccessAnswer().$this->buildErrorAnswer();
255 255
 	}
256 256
 	
257
-	public function getTextImportAnswer(){
257
+	public function getTextImportAnswer() {
258 258
 	    //Prepare Html2PlainText for email validity (both version to enhance spam validation)
259
-	    $htmlMessageObject = new \Html2Text\Html2Text($this->getHTMLImportAnswer());
259
+	    $htmlMessageObject=new \Html2Text\Html2Text($this->getHTMLImportAnswer());
260 260
 	    return $htmlMessageObject->getText();
261 261
 	    
262 262
 	}
@@ -265,19 +265,19 @@  discard block
 block discarded – undo
265 265
 	 * Build HTML for error answer
266 266
 	 * @return string
267 267
 	 */
268
-	private function buildErrorAnswer(){
268
+	private function buildErrorAnswer() {
269 269
 	    //List of failed patients
270 270
 	    $failReport='Failed Patients: <br>';
271
-	    if ( !empty($this->failList) ){
272
-	        foreach ($this->failList as $key=>$value){
273
-	            if(! empty($value)){
271
+	    if (!empty($this->failList)) {
272
+	        foreach ($this->failList as $key=>$value) {
273
+	            if (!empty($value)) {
274 274
 	                $failReport=$failReport.$key.':<br>';
275
-	                if(is_array($value)) $failReport=$failReport.implode('<br>',$value).'<br>';
275
+	                if (is_array($value)) $failReport=$failReport.implode('<br>', $value).'<br>';
276 276
 	                else $failReport=$failReport.$value.'<br>';
277 277
 	            }
278 278
 	        }
279
-	    }else{
280
-	        $failReport=$failReport.' None <br>' ;
279
+	    }else {
280
+	        $failReport=$failReport.' None <br>';
281 281
 	    }
282 282
 	    
283 283
 	    return $failReport;
@@ -287,15 +287,15 @@  discard block
 block discarded – undo
287 287
 	 * Generate HTML for sucess answer
288 288
 	 * @return string
289 289
 	 */
290
-	private function buildSuccessAnswer(){
290
+	private function buildSuccessAnswer() {
291 291
 	    //List of succeded patients
292 292
 	    $successReport='Success Patients: <br>';
293
-	    if ( !empty($this->sucessList) ){
293
+	    if (!empty($this->sucessList)) {
294 294
 	        foreach ($this->sucessList as $value) {
295 295
 	            $success=$value;
296 296
 	            $successReport=$successReport.$success.'<br>';
297 297
 	        }
298
-	    } else {
298
+	    }else {
299 299
 	        $successReport=$successReport.' None <br>';
300 300
 	    }
301 301
 	    
Please login to merge, or discard this patch.
src/models/Fill_Orthanc_Table.php 3 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -20,71 +20,71 @@  discard block
 block discarded – undo
20 20
 
21 21
 class Fill_Orthanc_Table {
22 22
     
23
-    private $linkpdo;
24
-    private $username;
25
-    private $studyOrthancObject;
26
-    private $visitObject;
23
+	private $linkpdo;
24
+	private $username;
25
+	private $studyOrthancObject;
26
+	private $visitObject;
27 27
 
28 28
     
29
-    public function __construct($id_visit, String $username, PDO $linkpdo){
30
-        $this->username= $username;
31
-        $this->linkpdo=$linkpdo;
32
-        $this->visitObject=new Visit($id_visit, $linkpdo);
33
-    }
29
+	public function __construct($id_visit, String $username, PDO $linkpdo){
30
+		$this->username= $username;
31
+		$this->linkpdo=$linkpdo;
32
+		$this->visitObject=new Visit($id_visit, $linkpdo);
33
+	}
34 34
     
35
-    /**
36
-     * return study details of a study stored in Orthanc
37
-     * @param String $studyID
38
-     * @return array
39
-     */
40
-    public function parseData(String $studyID){
41
-        $studyData=new Orthanc_Study($studyID,null,null);
42
-        $studyData->retrieveStudyData();
43
-        $this->studyOrthancObject=$studyData;
44
-        $studyDetails=get_object_vars($studyData);
45
-        return $studyDetails;
46
-    }
35
+	/**
36
+	 * return study details of a study stored in Orthanc
37
+	 * @param String $studyID
38
+	 * @return array
39
+	 */
40
+	public function parseData(String $studyID){
41
+		$studyData=new Orthanc_Study($studyID,null,null);
42
+		$studyData->retrieveStudyData();
43
+		$this->studyOrthancObject=$studyData;
44
+		$studyDetails=get_object_vars($studyData);
45
+		return $studyDetails;
46
+	}
47 47
     
48
-    /**
49
-     * Fill data in the database, write data for study and for each series
50
-     * Once done trigger the change upload status of visit to update upload status and eventually skip 
51
-     * local form and/or QC
52
-     */
53
-    public function fillDB($anonFromOrthancStudyId){
48
+	/**
49
+	 * Fill data in the database, write data for study and for each series
50
+	 * Once done trigger the change upload status of visit to update upload status and eventually skip 
51
+	 * local form and/or QC
52
+	 */
53
+	public function fillDB($anonFromOrthancStudyId){
54 54
         
55
-        //Check that original OrthancID is unknown for this study
56
-        if($this->visitObject->getParentStudyObject()->isOriginalOrthancNeverKnown($anonFromOrthancStudyId) ){
57
-            try{
58
-                //Fill la database
59
-                $this->addToDbStudy($anonFromOrthancStudyId, $this->username);
55
+		//Check that original OrthancID is unknown for this study
56
+		if($this->visitObject->getParentStudyObject()->isOriginalOrthancNeverKnown($anonFromOrthancStudyId) ){
57
+			try{
58
+				//Fill la database
59
+				$this->addToDbStudy($anonFromOrthancStudyId, $this->username);
60 60
                 
61
-                foreach ($this->studyOrthancObject->orthancSeries as $serie){
62
-                    //Fill series database
63
-                    $this->addtoDbSerie($serie);
64
-                }
65
-                $this->visitObject->changeUploadStatus(Visit::DONE, $this->username);
61
+				foreach ($this->studyOrthancObject->orthancSeries as $serie){
62
+					//Fill series database
63
+					$this->addtoDbSerie($serie);
64
+				}
65
+				$this->visitObject->changeUploadStatus(Visit::DONE, $this->username);
66 66
                 
67
-            }catch(Exception $e1){
68
-                throw new Exception("Error during import ".$e1->getMessage());
69
-            }
70
-        }else{
71
-            throw new Exception("Error during import Study Already Known");
72
-        }
73
-    }
67
+			}catch(Exception $e1){
68
+				throw new Exception("Error during import ".$e1->getMessage());
69
+			}
70
+		}else{
71
+			throw new Exception("Error during import Study Already Known");
72
+		}
73
+	}
74 74
     
75
-    /**
76
-     * Private function to write into Orthanc_Studies DB
77
-     * @param string $anonFromOrthancStudyId
78
-     */
79
-    private function addToDbStudy(string $anonFromOrthancStudyId){
80
-            $studyAcquisitionDate2=$this->parseDateTime($this->studyOrthancObject->studyDate, 1);
81
-            $studyAcquisitionTime2=$this->parseDateTime($this->studyOrthancObject->studyTime, 2);
75
+	/**
76
+	 * Private function to write into Orthanc_Studies DB
77
+	 * @param string $anonFromOrthancStudyId
78
+	 */
79
+	private function addToDbStudy(string $anonFromOrthancStudyId){
80
+			$studyAcquisitionDate2=$this->parseDateTime($this->studyOrthancObject->studyDate, 1);
81
+			$studyAcquisitionTime2=$this->parseDateTime($this->studyOrthancObject->studyTime, 2);
82 82
             
83
-            if($studyAcquisitionDate2!=null && $studyAcquisitionTime2!=null){
84
-                $acquisitionDateTime=$studyAcquisitionDate2." ".$studyAcquisitionTime2;
85
-            }
83
+			if($studyAcquisitionDate2!=null && $studyAcquisitionTime2!=null){
84
+				$acquisitionDateTime=$studyAcquisitionDate2." ".$studyAcquisitionTime2;
85
+			}
86 86
                         
87
-            $addBdd=$this->linkpdo->prepare('INSERT INTO orthanc_studies (id_visit, 
87
+			$addBdd=$this->linkpdo->prepare('INSERT INTO orthanc_studies (id_visit, 
88 88
                                             uploader, 
89 89
                                             upload_date, 
90 90
                                             acquisition_date, 
@@ -136,42 +136,42 @@  discard block
 block discarded – undo
136 136
                                     uncompressed_disk_size=:uncompressed_disk_size, 
137 137
                                     deleted=0 ');
138 138
            
139
-            $addBdd->execute(array(
140
-                'id_visit'=>$this->visitObject->id_visit,  
141
-                'uploader'=>$this->username,
142
-                'upload_date'=>date("Y-m-d H:i:s"),  
143
-                'acquisition_date'=>$this->studyOrthancObject->studyDate, 
144
-                'acquisition_time'=>$this->studyOrthancObject->studyTime,
145
-                'acquisition_datetime'=> isset($acquisitionDateTime) ? $acquisitionDateTime : null,
146
-                'study_orthanc_id'=>$this->studyOrthancObject->studyOrthancID,
147
-            	'anon_from_orthanc_id'=>$anonFromOrthancStudyId,
148
-                'study_uid'=>$this->studyOrthancObject->studyInstanceUID, 
149
-                'study_description'=>$this->studyOrthancObject->studyDescription, 
150
-                'patient_orthanc_id'=>$this->studyOrthancObject->parentPartientOrthancID,
151
-                'patient_name'=>$this->studyOrthancObject->parentPatientName, 
152
-                'patient_id'=>$this->studyOrthancObject->parentPatientID, 
153
-                'number_of_series'=>$this->studyOrthancObject->numberOfSeriesInStudy,
154
-                'number_of_instances'=>$this->studyOrthancObject->countInstances,
155
-                'disk_size'=>$this->studyOrthancObject->diskSizeMb,
156
-                'uncompressed_disk_size'=>$this->studyOrthancObject->uncompressedSizeMb
157
-            ));
139
+			$addBdd->execute(array(
140
+				'id_visit'=>$this->visitObject->id_visit,  
141
+				'uploader'=>$this->username,
142
+				'upload_date'=>date("Y-m-d H:i:s"),  
143
+				'acquisition_date'=>$this->studyOrthancObject->studyDate, 
144
+				'acquisition_time'=>$this->studyOrthancObject->studyTime,
145
+				'acquisition_datetime'=> isset($acquisitionDateTime) ? $acquisitionDateTime : null,
146
+				'study_orthanc_id'=>$this->studyOrthancObject->studyOrthancID,
147
+				'anon_from_orthanc_id'=>$anonFromOrthancStudyId,
148
+				'study_uid'=>$this->studyOrthancObject->studyInstanceUID, 
149
+				'study_description'=>$this->studyOrthancObject->studyDescription, 
150
+				'patient_orthanc_id'=>$this->studyOrthancObject->parentPartientOrthancID,
151
+				'patient_name'=>$this->studyOrthancObject->parentPatientName, 
152
+				'patient_id'=>$this->studyOrthancObject->parentPatientID, 
153
+				'number_of_series'=>$this->studyOrthancObject->numberOfSeriesInStudy,
154
+				'number_of_instances'=>$this->studyOrthancObject->countInstances,
155
+				'disk_size'=>$this->studyOrthancObject->diskSizeMb,
156
+				'uncompressed_disk_size'=>$this->studyOrthancObject->uncompressedSizeMb
157
+			));
158 158
 
159
-    }
159
+	}
160 160
     
161
-    /**
162
-     * Private function to write into the Orthanc_Series DB
163
-     * @param Orthanc_Serie $serie
164
-     */
165
-    private function addtoDbSerie(Orthanc_Serie $serie){
161
+	/**
162
+	 * Private function to write into the Orthanc_Series DB
163
+	 * @param Orthanc_Serie $serie
164
+	 */
165
+	private function addtoDbSerie(Orthanc_Serie $serie){
166 166
         
167
-        $serieAcquisitionDate2=$this->parseDateTime($serie->seriesDate, 1);
168
-        $serieAcquisitionTime2=$this->parseDateTime($serie->seriesTime, 2);
167
+		$serieAcquisitionDate2=$this->parseDateTime($serie->seriesDate, 1);
168
+		$serieAcquisitionTime2=$this->parseDateTime($serie->seriesTime, 2);
169 169
         
170
-        if($serieAcquisitionDate2!=null && $serieAcquisitionTime2!=null){
171
-            $acquisitionDateTime=$serieAcquisitionDate2." ".$serieAcquisitionTime2;
172
-        }
170
+		if($serieAcquisitionDate2!=null && $serieAcquisitionTime2!=null){
171
+			$acquisitionDateTime=$serieAcquisitionDate2." ".$serieAcquisitionTime2;
172
+		}
173 173
         
174
-        $addBddSeries=$this->linkpdo->prepare('INSERT INTO orthanc_series (
174
+		$addBddSeries=$this->linkpdo->prepare('INSERT INTO orthanc_series (
175 175
                                                 study_orthanc_id, 
176 176
                                                 modality, 
177 177
                                                 acquisition_date, 
@@ -217,71 +217,71 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$value = array(
219 219
 				'Study_Orthanc_ID'=>$this->studyOrthancObject->studyOrthancID,
220
-                'Modality'=>$serie->modality,
221
-                'Acquisition_Date'=>$serie->seriesDate,
222
-                'Acquisition_Time'=>$serie->seriesTime,
223
-                'Acquisition_DateTime'=> isset($acquisitionDateTime) ? $acquisitionDateTime : null,
224
-                'Series_Description'=> $serie->seriesDescription,
225
-		        'Injected_Dose'=> is_numeric($serie->injectedDose) ? $serie->injectedDose : null,
226
-                'Radiopharmaceutical'=> $serie->radiopharmaceutical,
227
-                'HalfLife'=> is_numeric($serie->halfLife) ? $serie->halfLife : null,
228
-                'Injected_Time'=> $serie->injectedTime,
229
-                'Injected_DateTime'=> $this->parseDateTime($serie->injectedDateTime, 0),
230
-                'Injected_Activity'=> is_numeric($serie->injectedActivity) ? $serie->injectedActivity: null,
231
-                'Series_Orthanc_ID'=> $serie->serieOrthancID,
232
-                'Number_Instances'=> $serie->numberOfInstanceInOrthanc,
233
-                'Serie_UID'=> $serie->seriesInstanceUID,
234
-                'Serie_Number'=> $serie->seriesNumber,
235
-                'Patient_Weight'=>is_numeric($serie->patientWeight) ? $serie->patientWeight:null,
236
-                'Serie_Disk_Size'=> $serie->diskSizeMb,
237
-                'Serie_Uncompressed_Disk_Size' => $serie->uncompressedSizeMb,
238
-                'Manufacturer'=> $serie->seriesManufacturer,
239
-            	'Model_Name'=>$serie->seriesModelName
240
-            );
220
+				'Modality'=>$serie->modality,
221
+				'Acquisition_Date'=>$serie->seriesDate,
222
+				'Acquisition_Time'=>$serie->seriesTime,
223
+				'Acquisition_DateTime'=> isset($acquisitionDateTime) ? $acquisitionDateTime : null,
224
+				'Series_Description'=> $serie->seriesDescription,
225
+				'Injected_Dose'=> is_numeric($serie->injectedDose) ? $serie->injectedDose : null,
226
+				'Radiopharmaceutical'=> $serie->radiopharmaceutical,
227
+				'HalfLife'=> is_numeric($serie->halfLife) ? $serie->halfLife : null,
228
+				'Injected_Time'=> $serie->injectedTime,
229
+				'Injected_DateTime'=> $this->parseDateTime($serie->injectedDateTime, 0),
230
+				'Injected_Activity'=> is_numeric($serie->injectedActivity) ? $serie->injectedActivity: null,
231
+				'Series_Orthanc_ID'=> $serie->serieOrthancID,
232
+				'Number_Instances'=> $serie->numberOfInstanceInOrthanc,
233
+				'Serie_UID'=> $serie->seriesInstanceUID,
234
+				'Serie_Number'=> $serie->seriesNumber,
235
+				'Patient_Weight'=>is_numeric($serie->patientWeight) ? $serie->patientWeight:null,
236
+				'Serie_Disk_Size'=> $serie->diskSizeMb,
237
+				'Serie_Uncompressed_Disk_Size' => $serie->uncompressedSizeMb,
238
+				'Manufacturer'=> $serie->seriesManufacturer,
239
+				'Model_Name'=>$serie->seriesModelName
240
+			);
241 241
             
242 242
 		$addBddSeries->execute($value);
243 243
 		
244
-    }
244
+	}
245 245
     
246
-    /**
247
-     * Parse a DICOM date or Time string and return a string ready to send to database
248
-     * Return null if non parsable
249
-     * @param string $string
250
-     * @param type 0=dateTime, 1=Date, 2=Time
251
-     * return formated date for db saving, null if parse failed
252
-     */
253
-    private function parseDateTime( $string, int $type){
254
-        $parsedDateTime=null;
246
+	/**
247
+	 * Parse a DICOM date or Time string and return a string ready to send to database
248
+	 * Return null if non parsable
249
+	 * @param string $string
250
+	 * @param type 0=dateTime, 1=Date, 2=Time
251
+	 * return formated date for db saving, null if parse failed
252
+	 */
253
+	private function parseDateTime( $string, int $type){
254
+		$parsedDateTime=null;
255 255
         
256
-        //If contain time split the ms (after.) which are not constant
257
-        if($type==0 || $type==2){
258
-            if(strpos($string, ".")) {
259
-                $timeWithoutms=explode(".", $string);
260
-                $string=$timeWithoutms[0];
261
-            }
256
+		//If contain time split the ms (after.) which are not constant
257
+		if($type==0 || $type==2){
258
+			if(strpos($string, ".")) {
259
+				$timeWithoutms=explode(".", $string);
260
+				$string=$timeWithoutms[0];
261
+			}
262 262
             
263
-        }
263
+		}
264 264
         
265
-        if($type==2){
266
-            $dateObject=DateTime::createFromFormat('His', $string);
267
-            if($dateObject!==false){
268
-                $parsedDateTime=$dateObject->format('H:i:s');
269
-            }
270
-        }else if($type==1){
271
-            $dateObject=DateTime::createFromFormat('Ymd', $string);
272
-            if($dateObject!==false){
273
-                $parsedDateTime=$dateObject->format('Y-m-d');
274
-            }
275
-        }else if($type==0){
276
-            $dateObject=DateTime::createFromFormat('YmdHis', $string);
277
-            if($dateObject!==false){
278
-                $parsedDateTime=$dateObject->format('Y-m-d H:i:s');
279
-            }
280
-        }
265
+		if($type==2){
266
+			$dateObject=DateTime::createFromFormat('His', $string);
267
+			if($dateObject!==false){
268
+				$parsedDateTime=$dateObject->format('H:i:s');
269
+			}
270
+		}else if($type==1){
271
+			$dateObject=DateTime::createFromFormat('Ymd', $string);
272
+			if($dateObject!==false){
273
+				$parsedDateTime=$dateObject->format('Y-m-d');
274
+			}
275
+		}else if($type==0){
276
+			$dateObject=DateTime::createFromFormat('YmdHis', $string);
277
+			if($dateObject!==false){
278
+				$parsedDateTime=$dateObject->format('Y-m-d H:i:s');
279
+			}
280
+		}
281 281
         
282
-        return $parsedDateTime;
282
+		return $parsedDateTime;
283 283
   
284
-    }
284
+	}
285 285
     
286 286
 }
287 287
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
     private $visitObject;
27 27
 
28 28
     
29
-    public function __construct($id_visit, String $username, PDO $linkpdo){
30
-        $this->username= $username;
29
+    public function __construct($id_visit, String $username, PDO $linkpdo) {
30
+        $this->username=$username;
31 31
         $this->linkpdo=$linkpdo;
32 32
         $this->visitObject=new Visit($id_visit, $linkpdo);
33 33
     }
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
      * @param String $studyID
38 38
      * @return array
39 39
      */
40
-    public function parseData(String $studyID){
41
-        $studyData=new Orthanc_Study($studyID,null,null);
40
+    public function parseData(String $studyID) {
41
+        $studyData=new Orthanc_Study($studyID, null, null);
42 42
         $studyData->retrieveStudyData();
43 43
         $this->studyOrthancObject=$studyData;
44 44
         $studyDetails=get_object_vars($studyData);
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
50 50
      * Once done trigger the change upload status of visit to update upload status and eventually skip 
51 51
      * local form and/or QC
52 52
      */
53
-    public function fillDB($anonFromOrthancStudyId){
53
+    public function fillDB($anonFromOrthancStudyId) {
54 54
         
55 55
         //Check that original OrthancID is unknown for this study
56
-        if($this->visitObject->getParentStudyObject()->isOriginalOrthancNeverKnown($anonFromOrthancStudyId) ){
57
-            try{
56
+        if ($this->visitObject->getParentStudyObject()->isOriginalOrthancNeverKnown($anonFromOrthancStudyId)) {
57
+            try {
58 58
                 //Fill la database
59 59
                 $this->addToDbStudy($anonFromOrthancStudyId, $this->username);
60 60
                 
61
-                foreach ($this->studyOrthancObject->orthancSeries as $serie){
61
+                foreach ($this->studyOrthancObject->orthancSeries as $serie) {
62 62
                     //Fill series database
63 63
                     $this->addtoDbSerie($serie);
64 64
                 }
65 65
                 $this->visitObject->changeUploadStatus(Visit::DONE, $this->username);
66 66
                 
67
-            }catch(Exception $e1){
67
+            }catch (Exception $e1) {
68 68
                 throw new Exception("Error during import ".$e1->getMessage());
69 69
             }
70
-        }else{
70
+        }else {
71 71
             throw new Exception("Error during import Study Already Known");
72 72
         }
73 73
     }
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
      * Private function to write into Orthanc_Studies DB
77 77
      * @param string $anonFromOrthancStudyId
78 78
      */
79
-    private function addToDbStudy(string $anonFromOrthancStudyId){
79
+    private function addToDbStudy(string $anonFromOrthancStudyId) {
80 80
             $studyAcquisitionDate2=$this->parseDateTime($this->studyOrthancObject->studyDate, 1);
81 81
             $studyAcquisitionTime2=$this->parseDateTime($this->studyOrthancObject->studyTime, 2);
82 82
             
83
-            if($studyAcquisitionDate2!=null && $studyAcquisitionTime2!=null){
83
+            if ($studyAcquisitionDate2 != null && $studyAcquisitionTime2 != null) {
84 84
                 $acquisitionDateTime=$studyAcquisitionDate2." ".$studyAcquisitionTime2;
85 85
             }
86 86
                         
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
      * Private function to write into the Orthanc_Series DB
163 163
      * @param Orthanc_Serie $serie
164 164
      */
165
-    private function addtoDbSerie(Orthanc_Serie $serie){
165
+    private function addtoDbSerie(Orthanc_Serie $serie) {
166 166
         
167 167
         $serieAcquisitionDate2=$this->parseDateTime($serie->seriesDate, 1);
168 168
         $serieAcquisitionTime2=$this->parseDateTime($serie->seriesTime, 2);
169 169
         
170
-        if($serieAcquisitionDate2!=null && $serieAcquisitionTime2!=null){
170
+        if ($serieAcquisitionDate2 != null && $serieAcquisitionTime2 != null) {
171 171
             $acquisitionDateTime=$serieAcquisitionDate2." ".$serieAcquisitionTime2;
172 172
         }
173 173
         
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                                                         :Model_Name, :Injected_DateTime)
216 216
         ON DUPLICATE KEY UPDATE study_orthanc_id=:Study_Orthanc_ID, modality=:Modality, acquisition_date=:Acquisition_Date, acquisition_time=:Acquisition_Time, acquisition_datetime=:Acquisition_DateTime, series_description=:Series_Description, injected_dose=:Injected_Dose, radiopharmaceutical=:Radiopharmaceutical, half_life=:HalfLife, injected_time=:Injected_Time, injected_activity=:Injected_Activity, number_of_instances=:Number_Instances, serie_number=:Serie_Number, patient_weight=:Patient_Weight, serie_disk_size=:Serie_Disk_Size, serie_uncompressed_disk_size=:Serie_Uncompressed_Disk_Size, manufacturer=:Manufacturer, model_name=:Model_Name, deleted=0, injected_datetime=:Injected_DateTime');
217 217
 
218
-		$value = array(
218
+		$value=array(
219 219
 				'Study_Orthanc_ID'=>$this->studyOrthancObject->studyOrthancID,
220 220
                 'Modality'=>$serie->modality,
221 221
                 'Acquisition_Date'=>$serie->seriesDate,
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
                 'HalfLife'=> is_numeric($serie->halfLife) ? $serie->halfLife : null,
228 228
                 'Injected_Time'=> $serie->injectedTime,
229 229
                 'Injected_DateTime'=> $this->parseDateTime($serie->injectedDateTime, 0),
230
-                'Injected_Activity'=> is_numeric($serie->injectedActivity) ? $serie->injectedActivity: null,
230
+                'Injected_Activity'=> is_numeric($serie->injectedActivity) ? $serie->injectedActivity : null,
231 231
                 'Series_Orthanc_ID'=> $serie->serieOrthancID,
232 232
                 'Number_Instances'=> $serie->numberOfInstanceInOrthanc,
233 233
                 'Serie_UID'=> $serie->seriesInstanceUID,
234 234
                 'Serie_Number'=> $serie->seriesNumber,
235
-                'Patient_Weight'=>is_numeric($serie->patientWeight) ? $serie->patientWeight:null,
235
+                'Patient_Weight'=>is_numeric($serie->patientWeight) ? $serie->patientWeight : null,
236 236
                 'Serie_Disk_Size'=> $serie->diskSizeMb,
237 237
                 'Serie_Uncompressed_Disk_Size' => $serie->uncompressedSizeMb,
238 238
                 'Manufacturer'=> $serie->seriesManufacturer,
@@ -250,31 +250,31 @@  discard block
 block discarded – undo
250 250
      * @param type 0=dateTime, 1=Date, 2=Time
251 251
      * return formated date for db saving, null if parse failed
252 252
      */
253
-    private function parseDateTime( $string, int $type){
253
+    private function parseDateTime($string, int $type) {
254 254
         $parsedDateTime=null;
255 255
         
256 256
         //If contain time split the ms (after.) which are not constant
257
-        if($type==0 || $type==2){
258
-            if(strpos($string, ".")) {
257
+        if ($type == 0 || $type == 2) {
258
+            if (strpos($string, ".")) {
259 259
                 $timeWithoutms=explode(".", $string);
260 260
                 $string=$timeWithoutms[0];
261 261
             }
262 262
             
263 263
         }
264 264
         
265
-        if($type==2){
265
+        if ($type == 2) {
266 266
             $dateObject=DateTime::createFromFormat('His', $string);
267
-            if($dateObject!==false){
267
+            if ($dateObject !== false) {
268 268
                 $parsedDateTime=$dateObject->format('H:i:s');
269 269
             }
270
-        }else if($type==1){
270
+        }else if ($type == 1) {
271 271
             $dateObject=DateTime::createFromFormat('Ymd', $string);
272
-            if($dateObject!==false){
272
+            if ($dateObject !== false) {
273 273
                 $parsedDateTime=$dateObject->format('Y-m-d');
274 274
             }
275
-        }else if($type==0){
275
+        }else if ($type == 0) {
276 276
             $dateObject=DateTime::createFromFormat('YmdHis', $string);
277
-            if($dateObject!==false){
277
+            if ($dateObject !== false) {
278 278
                 $parsedDateTime=$dateObject->format('Y-m-d H:i:s');
279 279
             }
280 280
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
                 }
65 65
                 $this->visitObject->changeUploadStatus(Visit::DONE, $this->username);
66 66
                 
67
-            }catch(Exception $e1){
67
+            } catch(Exception $e1){
68 68
                 throw new Exception("Error during import ".$e1->getMessage());
69 69
             }
70
-        }else{
70
+        } else{
71 71
             throw new Exception("Error during import Study Already Known");
72 72
         }
73 73
     }
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
             if($dateObject!==false){
268 268
                 $parsedDateTime=$dateObject->format('H:i:s');
269 269
             }
270
-        }else if($type==1){
270
+        } else if($type==1){
271 271
             $dateObject=DateTime::createFromFormat('Ymd', $string);
272 272
             if($dateObject!==false){
273 273
                 $parsedDateTime=$dateObject->format('Y-m-d');
274 274
             }
275
-        }else if($type==0){
275
+        } else if($type==0){
276 276
             $dateObject=DateTime::createFromFormat('YmdHis', $string);
277 277
             if($dateObject!==false){
278 278
                 $parsedDateTime=$dateObject->format('Y-m-d H:i:s');
Please login to merge, or discard this patch.
src/models/Orthanc_Study.php 3 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -44,21 +44,21 @@  discard block
 block discarded – undo
44 44
 	private $context;
45 45
 	
46 46
 	public function __construct($studyOrthancId, $url, $context){
47
-	    //Set http adress of orthanc
48
-	    if($url==null && $context==null){
49
-	        $linkpdo=Session::getLinkpdo();
47
+		//Set http adress of orthanc
48
+		if($url==null && $context==null){
49
+			$linkpdo=Session::getLinkpdo();
50 50
 	        
51
-	        $this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
52
-	    	$this->context = array(
53
-	    			'http' => array(
54
-	    			    'header'  => "Authorization: Basic " . base64_encode( GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD )
55
-	    			)
56
-	    	);
51
+			$this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
52
+			$this->context = array(
53
+					'http' => array(
54
+						'header'  => "Authorization: Basic " . base64_encode( GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD )
55
+					)
56
+			);
57 57
 	    	
58
-	    }else{
59
-	    	$this->url=$url;
60
-	    	$this->context = $context;	
61
-	    }
58
+		}else{
59
+			$this->url=$url;
60
+			$this->context = $context;	
61
+		}
62 62
 	    
63 63
 		//put current study orthanc ID in memory
64 64
 		$this->studyOrthancID=$studyOrthancId;
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 *Get study related tags and store them in this object
70 70
 	 */
71 71
 	public function retrieveStudyData(){
72
-	    $context  = stream_context_create($this->context);
73
-	    $json = file_get_contents($this->url.'/studies/'.$this->studyOrthancID, false, $context);
72
+		$context  = stream_context_create($this->context);
73
+		$json = file_get_contents($this->url.'/studies/'.$this->studyOrthancID, false, $context);
74 74
 		//On le decode
75 75
 		$studiesJson=json_decode($json, true);
76 76
 		//On cree un object patient avec les information
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 	 *Get study statistics info (size in MB, number of instances) and store them in this object
97 97
 	 */
98 98
 	private function retrieveStudyStatistics(){
99
-	    $context  = stream_context_create($this->context);
100
-	    $json = file_get_contents($this->url.'/studies/'.$this->studyOrthancID.'/statistics/', false, $context);
101
-	    //On le decode
102
-	    $statisticsJson=json_decode($json, true);
103
-	    $this->countInstances=$statisticsJson['CountInstances'];
104
-	    $this->diskSizeMb=$statisticsJson['DiskSizeMB'];
105
-	    $this->uncompressedSizeMb=$statisticsJson['UncompressedSizeMB'];
99
+		$context  = stream_context_create($this->context);
100
+		$json = file_get_contents($this->url.'/studies/'.$this->studyOrthancID.'/statistics/', false, $context);
101
+		//On le decode
102
+		$statisticsJson=json_decode($json, true);
103
+		$this->countInstances=$statisticsJson['CountInstances'];
104
+		$this->diskSizeMb=$statisticsJson['DiskSizeMB'];
105
+		$this->uncompressedSizeMb=$statisticsJson['UncompressedSizeMB'];
106 106
 	    
107 107
 	}
108 108
 	
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  * Collect study's data from Orthanc Server
18 18
  */
19 19
 
20
- class Orthanc_Study{
20
+ class Orthanc_Study {
21 21
 	public $studyOrthancID;
22 22
 	public $studyIsStable;
23 23
 	public $studyDate;
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 	private $url;
44 44
 	private $context;
45 45
 	
46
-	public function __construct($studyOrthancId, $url, $context){
46
+	public function __construct($studyOrthancId, $url, $context) {
47 47
 	    //Set http adress of orthanc
48
-	    if($url==null && $context==null){
48
+	    if ($url == null && $context == null) {
49 49
 	        $linkpdo=Session::getLinkpdo();
50 50
 	        
51 51
 	        $this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
52
-	    	$this->context = array(
52
+	    	$this->context=array(
53 53
 	    			'http' => array(
54
-	    			    'header'  => "Authorization: Basic " . base64_encode( GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD )
54
+	    			    'header'  => "Authorization: Basic ".base64_encode(GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD)
55 55
 	    			)
56 56
 	    	);
57 57
 	    	
58
-	    }else{
58
+	    }else {
59 59
 	    	$this->url=$url;
60
-	    	$this->context = $context;	
60
+	    	$this->context=$context;	
61 61
 	    }
62 62
 	    
63 63
 		//put current study orthanc ID in memory
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 *Get study related tags and store them in this object
70 70
 	 */
71
-	public function retrieveStudyData(){
72
-	    $context  = stream_context_create($this->context);
73
-	    $json = file_get_contents($this->url.'/studies/'.$this->studyOrthancID, false, $context);
71
+	public function retrieveStudyData() {
72
+	    $context=stream_context_create($this->context);
73
+	    $json=file_get_contents($this->url.'/studies/'.$this->studyOrthancID, false, $context);
74 74
 		//On le decode
75 75
 		$studiesJson=json_decode($json, true);
76 76
 		//On cree un object patient avec les information
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		$this->studyDescription=$studiesJson['MainDicomTags']['StudyDescription'];
80 80
 		$this->studyInstanceUID=$studiesJson['MainDicomTags']['StudyInstanceUID'];
81 81
 		$this->studyLastUpdate=$studiesJson['LastUpdate'];
82
-		$this->seriesInStudy= $studiesJson['Series'];
82
+		$this->seriesInStudy=$studiesJson['Series'];
83 83
 		$this->numberOfSeriesInStudy=sizeof($studiesJson['Series']);
84
-		$this->studyIsStable= $studiesJson['IsStable'];
84
+		$this->studyIsStable=$studiesJson['IsStable'];
85 85
 		$this->parentPatientName=$studiesJson['PatientMainDicomTags']['PatientName'];
86 86
 		$this->parentPatientID=$studiesJson['PatientMainDicomTags']['PatientID'];
87 87
 		$this->parentPartientOrthancID=$studiesJson['ParentPatient'];
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	 *Get study statistics info (size in MB, number of instances) and store them in this object
97 97
 	 */
98
-	private function retrieveStudyStatistics(){
99
-	    $context  = stream_context_create($this->context);
100
-	    $json = file_get_contents($this->url.'/studies/'.$this->studyOrthancID.'/statistics/', false, $context);
98
+	private function retrieveStudyStatistics() {
99
+	    $context=stream_context_create($this->context);
100
+	    $json=file_get_contents($this->url.'/studies/'.$this->studyOrthancID.'/statistics/', false, $context);
101 101
 	    //On le decode
102 102
 	    $statisticsJson=json_decode($json, true);
103 103
 	    $this->countInstances=$statisticsJson['CountInstances'];
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	/**
110 110
 	 * Create a series object with series data for each series and store them in this object
111 111
 	 */
112
-	private function getSeriesMainTag(){
113
-		foreach ($this->seriesInStudy as $seriesID){
112
+	private function getSeriesMainTag() {
113
+		foreach ($this->seriesInStudy as $seriesID) {
114 114
 			$series=new Orthanc_Serie($seriesID, $this->url, $this->context);
115 115
 			@$series->retrieveSeriesData();
116 116
 			$this->orthancSeries[]=$series;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	    			)
56 56
 	    	);
57 57
 	    	
58
-	    }else{
58
+	    } else{
59 59
 	    	$this->url=$url;
60 60
 	    	$this->context = $context;	
61 61
 	    }
Please login to merge, or discard this patch.
src/models/Orthanc.php 3 patches
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 	 * @param boolean $exposed
34 34
 	 */
35 35
 	public function __construct(bool $exposed=false){
36
-	    //Set Time Limit at 3H as operation could be really long
37
-	    set_time_limit(10800);
38
-        //Set address of Orthanc server
39
-        if($exposed){
40
-            $this->url=GAELO_ORTHANC_EXPOSED_INTERNAL_ADDRESS.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PORT;
41
-            $this->context = array(
42
-                'http' => array(
43
-                    'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD)
36
+		//Set Time Limit at 3H as operation could be really long
37
+		set_time_limit(10800);
38
+		//Set address of Orthanc server
39
+		if($exposed){
40
+			$this->url=GAELO_ORTHANC_EXPOSED_INTERNAL_ADDRESS.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PORT;
41
+			$this->context = array(
42
+				'http' => array(
43
+					'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD)
44 44
 	   			));
45
-        }else{
46
-            $this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
47
-            $this->context = array(
45
+		}else{
46
+			$this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
47
+			$this->context = array(
48 48
 	   			'http' => array(
49
-	   			    'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD)
49
+	   				'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD)
50 50
 	   			) );
51 51
 	   }
52 52
 
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 	 * @return mixed
58 58
 	 */
59 59
 	public function getPeers(){
60
-	    $context =stream_context_create($this->context);
61
-	    $json = file_get_contents($this->url.'/peers/',false, $context);
62
-	    $peers=json_decode($json, true);
63
-	    return $peers;
60
+		$context =stream_context_create($this->context);
61
+		$json = file_get_contents($this->url.'/peers/',false, $context);
62
+		$peers=json_decode($json, true);
63
+		return $peers;
64 64
 	}
65 65
 	
66 66
 	/**
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 				'PatientID' => $patientID,
81 81
 				'PatientName' => $patientName,
82 82
 				'StudyDate' => $studyDate,
83
-		        'StudyInstanceUID' => $studyUID,
83
+				'StudyInstanceUID' => $studyUID,
84 84
 				'AccessionNumber'=> $accessionNumber,
85 85
 				'StudyDescription'=> $studyDescription,
86 86
 		);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				array(
98 98
 						'method'  => 'POST',
99 99
 						'content' => json_encode($query),
100
-				        'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
100
+						'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
101 101
 				)
102 102
 		);
103 103
 
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function getZipTempFile(array $uidList){
117 117
 	   
118
-	    if( !is_array($uidList)){
119
-	        $uidList=array($uidList);
120
-	    }
118
+		if( !is_array($uidList)){
119
+			$uidList=array($uidList);
120
+		}
121 121
 	    
122
-	    $opts = array('http' =>
123
-	        array(
124
-	            'method'  => 'POST',
125
-	            'content' => json_encode($uidList),
126
-	            'timeout' => 3600,
127
-	            'header'=>  ['Content-Type: application/json', 'Accept: application/zip',$this->context['http']['header'] ]
128
-	        )
129
-	    );
122
+		$opts = array('http' =>
123
+			array(
124
+				'method'  => 'POST',
125
+				'content' => json_encode($uidList),
126
+				'timeout' => 3600,
127
+				'header'=>  ['Content-Type: application/json', 'Accept: application/zip',$this->context['http']['header'] ]
128
+			)
129
+		);
130 130
 	    
131
-	    $context = stream_context_create($opts);
131
+		$context = stream_context_create($opts);
132 132
 	    
133
- 	    $temp = tempnam(ini_get('upload_tmp_dir'), 'TMP_');
133
+ 		$temp = tempnam(ini_get('upload_tmp_dir'), 'TMP_');
134 134
 	    
135
-	    $nbbytes=file_put_contents($temp , fopen($this->url.'/tools/create-archive','rb', false, $context));
135
+		$nbbytes=file_put_contents($temp , fopen($this->url.'/tools/create-archive','rb', false, $context));
136 136
 	    
137
-	    return $temp;
137
+		return $temp;
138 138
 	}
139 139
 	
140 140
 	
@@ -145,15 +145,15 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public function deleteFromOrthanc(string $level, string $uid){
147 147
 	    
148
-	    $opts = array('http' =>
149
-	        array(
150
-	            'method'  => 'DELETE',
151
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
152
-	        )
153
-	    );
148
+		$opts = array('http' =>
149
+			array(
150
+				'method'  => 'DELETE',
151
+				'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
152
+			)
153
+		);
154 154
 	    
155
-	    $context  = stream_context_create($opts);
156
-	    $result = file_get_contents($this->url.'/'.$level.'/'.$uid, false, $context);
155
+		$context  = stream_context_create($opts);
156
+		$result = file_get_contents($this->url.'/'.$level.'/'.$uid, false, $context);
157 157
 	    
158 158
 	}
159 159
 	
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function addPeer(string $name , string $url, string $username, string $password){
169 169
 	    
170
-	    $peerValues['Username']=$username;
171
-	    $peerValues['Password']=$password;
172
-	    $peerValues['Url']=$url;
173
-	    $opts = array('http' =>
174
-	        array(
175
-	            'method'  => 'PUT',
176
-	            'content' => json_encode($peerValues),
177
-	            'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
178
-	        )
179
-	    );
170
+		$peerValues['Username']=$username;
171
+		$peerValues['Password']=$password;
172
+		$peerValues['Url']=$url;
173
+		$opts = array('http' =>
174
+			array(
175
+				'method'  => 'PUT',
176
+				'content' => json_encode($peerValues),
177
+				'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
178
+			)
179
+		);
180 180
 	    
181
-	    $context  = stream_context_create($opts);
182
-	    $resultJson = file_get_contents($this->url.'/peers/'.$name, false, $context);
181
+		$context  = stream_context_create($opts);
182
+		$resultJson = file_get_contents($this->url.'/peers/'.$name, false, $context);
183 183
 	    
184
-	    $result=json_decode($resultJson);
185
-	    return $result;
184
+		$result=json_decode($resultJson);
185
+		return $result;
186 186
 	    
187 187
 	}
188 188
 	
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function removePeer(string $name){
194 194
 	    
195
-	    $opts = array('http' =>
196
-	        array(
197
-	            'method'  => 'DELETE',
198
-	            'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
199
-	        )
200
-	    );
195
+		$opts = array('http' =>
196
+			array(
197
+				'method'  => 'DELETE',
198
+				'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
199
+			)
200
+		);
201 201
 	    
202
-	    $context  = stream_context_create($opts);
203
-	    $resultJson = file_get_contents($this->url.'/peers/'.$name, false, $context);
202
+		$context  = stream_context_create($opts);
203
+		$resultJson = file_get_contents($this->url.'/peers/'.$name, false, $context);
204 204
 	    
205
-	    $result=json_decode($resultJson);
205
+		$result=json_decode($resultJson);
206 206
 	    
207
-	    return $result;
207
+		return $result;
208 208
 	}
209 209
 	
210 210
 	/**
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function removeAllPeers(){
214 214
 	    
215
-	    $peers=$this->getPeers();
215
+		$peers=$this->getPeers();
216 216
 	    
217
-	    foreach ($peers as $peer){
218
-	        $this->removePeer($peer);
219
-	    }
217
+		foreach ($peers as $peer){
218
+			$this->removePeer($peer);
219
+		}
220 220
 	    
221 221
 	}
222 222
 	
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
 	 * @return boolean
227 227
 	 */
228 228
 	public function isPeerAccelerated(string $peer){
229
-	    $context =stream_context_create($this->context);
230
-	    $json = file_get_contents($this->url.'/transfers/peers/',false, $context);
231
-	    $peersTest=json_decode($json, true);
229
+		$context =stream_context_create($this->context);
230
+		$json = file_get_contents($this->url.'/transfers/peers/',false, $context);
231
+		$peersTest=json_decode($json, true);
232 232
 	    
233
-	    if($peersTest[$peer]=="installed"){
234
-	        return true;
235
-	    }
233
+		if($peersTest[$peer]=="installed"){
234
+			return true;
235
+		}
236 236
 	    
237
-	    return false;
237
+		return false;
238 238
 	}
239 239
 	
240 240
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		$opts = array('http' =>
248 248
 				array(
249 249
 						'method'  => 'POST',
250
-                        "timeout" => 300, 
250
+						"timeout" => 300, 
251 251
 						'content' => json_encode($ids),
252 252
 						'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
253 253
 				)
@@ -266,20 +266,20 @@  discard block
 block discarded – undo
266 266
 	 * @return string
267 267
 	 */
268 268
 	public function sendToPeerAsync(string $peer, array $ids){
269
-	    $data['Synchronous']=false;
270
-	    $data['Resources']=$ids;
271
-	    
272
-	    $opts = array('http' =>
273
-	        array(
274
-	            'method'  => 'POST',
275
-	            'content' => json_encode($data),
276
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
277
-	        )
278
-	    );
279
-	    
280
-	    $context = stream_context_create($opts);
281
-	    $result = file_get_contents($this->url.'/peers/'.$peer.'/store', false, $context);
282
-	    return $result;
269
+		$data['Synchronous']=false;
270
+		$data['Resources']=$ids;
271
+	    
272
+		$opts = array('http' =>
273
+			array(
274
+				'method'  => 'POST',
275
+				'content' => json_encode($data),
276
+				'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
277
+			)
278
+		);
279
+	    
280
+		$context = stream_context_create($opts);
281
+		$result = file_get_contents($this->url.'/peers/'.$peer.'/store', false, $context);
282
+		return $result;
283 283
 	}
284 284
 	
285 285
 	/**
@@ -291,35 +291,35 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function sendToPeerAsyncWithAccelerator(string $peer, array $ids, bool $gzip){
293 293
 	    
294
-	    //If Peer dosen't have accelerated transfers fall back to regular orthanc peer transfers
295
-	    if( ! $this->isPeerAccelerated($peer)){
296
-	        $answer=$this->sendToPeerAsync($peer, $ids);
297
-	        return $answer;
298
-	    }
294
+		//If Peer dosen't have accelerated transfers fall back to regular orthanc peer transfers
295
+		if( ! $this->isPeerAccelerated($peer)){
296
+			$answer=$this->sendToPeerAsync($peer, $ids);
297
+			return $answer;
298
+		}
299 299
 	    
300
-	    if(!$gzip) $data['Compression']="none" ; else $data['Compression']="gzip";
300
+		if(!$gzip) $data['Compression']="none" ; else $data['Compression']="gzip";
301 301
 	    
302
-	    $data['Peer']=$peer;
302
+		$data['Peer']=$peer;
303 303
 	    
304 304
 	    
305
-	    foreach ($ids as $serieID){
306
-	        $resourceSeries['Level']="Series";
307
-	        $resourceSeries['ID']=$serieID;
308
-	        $data['Resources'][]=$resourceSeries;
309
-	    }
305
+		foreach ($ids as $serieID){
306
+			$resourceSeries['Level']="Series";
307
+			$resourceSeries['ID']=$serieID;
308
+			$data['Resources'][]=$resourceSeries;
309
+		}
310 310
 	    
311
-	    $opts = array('http' =>
312
-	        array(
313
-	            'method'  => 'POST',
314
-	            'content' => json_encode($data),
315
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
316
-	        )
317
-	    );
311
+		$opts = array('http' =>
312
+			array(
313
+				'method'  => 'POST',
314
+				'content' => json_encode($data),
315
+				'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
316
+			)
317
+		);
318 318
 	    
319
-	    $context = stream_context_create($opts);
320
-	    $result = file_get_contents($this->url.'/transfers/send', false, $context);
319
+		$context = stream_context_create($opts);
320
+		$result = file_get_contents($this->url.'/transfers/send', false, $context);
321 321
 	    
322
-	    return $result;
322
+		return $result;
323 323
 	    
324 324
 	}
325 325
 	
@@ -330,22 +330,22 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	public function importFile(string $file){
332 332
 	    
333
-	    try{
334
-    	    $opts = array('http' =>
335
-    	        array(
336
-    	            'method'  => 'POST',
337
-    	            'content' => file_get_contents($file),
338
-    	            'header'=>  ['Content-Type: application/dicom Accept: application/json',"content-length: ".filesize($file),$this->context['http']['header']]
339
-    	        )
340
-    	    );
333
+		try{
334
+			$opts = array('http' =>
335
+				array(
336
+					'method'  => 'POST',
337
+					'content' => file_get_contents($file),
338
+					'header'=>  ['Content-Type: application/dicom Accept: application/json',"content-length: ".filesize($file),$this->context['http']['header']]
339
+				)
340
+			);
341 341
     	    
342
-    	    $context = stream_context_create($opts);
343
-    	    $result = file_get_contents($this->url.'/instances', false, $context);
342
+			$context = stream_context_create($opts);
343
+			$result = file_get_contents($this->url.'/instances', false, $context);
344 344
     	    
345
-	    }catch(Exception $e1){
346
-	        error_log("Error during import Dcm ".$e1->getMessage());
347
-	    }
348
-	    return $result;
345
+		}catch(Exception $e1){
346
+			error_log("Error during import Dcm ".$e1->getMessage());
347
+		}
348
+		return $result;
349 349
 
350 350
 	}
351 351
 
@@ -361,29 +361,29 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public function Anonymize(string $studyID, string $profile, string $patientCode, string $visitType, string $studyName){
363 363
 	    
364
-	    $jsonAnonQuery=$this->buildAnonQuery($profile, $patientCode, $patientCode, $visitType, $studyName);
364
+		$jsonAnonQuery=$this->buildAnonQuery($profile, $patientCode, $patientCode, $visitType, $studyName);
365 365
 	    
366
-	    $opts = array('http' =>
367
-	        array(
368
-	            'method'  => 'POST',
369
-	            "timeout" => 300,
370
-	            'content' => json_encode($jsonAnonQuery),
371
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
372
-	        )
373
-	    );
366
+		$opts = array('http' =>
367
+			array(
368
+				'method'  => 'POST',
369
+				"timeout" => 300,
370
+				'content' => json_encode($jsonAnonQuery),
371
+				'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
372
+			)
373
+		);
374 374
 	    
375
-	    $context = stream_context_create($opts);
375
+		$context = stream_context_create($opts);
376 376
 
377
-        $result = file_get_contents($this->url."/studies/".$studyID."/anonymize", false, $context);
377
+		$result = file_get_contents($this->url."/studies/".$studyID."/anonymize", false, $context);
378 378
         
379
-	    //get the resulting Anonymized study Orthanc ID
380
-	    $anonAnswer=json_decode($result, true);
381
-	    $anonymizedID=$anonAnswer['ID'];
379
+		//get the resulting Anonymized study Orthanc ID
380
+		$anonAnswer=json_decode($result, true);
381
+		$anonymizedID=$anonAnswer['ID'];
382 382
 	    
383
-	    //Remove SC if any in the anonymized study
384
-	    $this->removeSC($anonymizedID);
383
+		//Remove SC if any in the anonymized study
384
+		$this->removeSC($anonymizedID);
385 385
 	    
386
-	    return $anonymizedID;
386
+		return $anonymizedID;
387 387
 	    
388 388
 	}
389 389
 	
@@ -397,121 +397,121 @@  discard block
 block discarded – undo
397 397
 	 */
398 398
 	private function buildAnonQuery(string $profile, string $newPatientName, string $newPatientID, string $newStudyDescription, string $clinicalStudy){
399 399
     	    
400
-        $tagsObjects=[];
401
-        if($profile=="Default"){
402
-            $date=TagAnon::KEEP;
403
-            $body=TagAnon::KEEP;
400
+		$tagsObjects=[];
401
+		if($profile=="Default"){
402
+			$date=TagAnon::KEEP;
403
+			$body=TagAnon::KEEP;
404 404
             
405
-            $tagsObjects[]=new TagAnon("0010,0030", TagAnon::REPLACE, "19000101"); // BirthDay
406
-            $tagsObjects[]=new TagAnon("0008,1030", TagAnon::REPLACE, $newStudyDescription); //studyDescription
407
-            $tagsObjects[]=new TagAnon("0008,103E", TagAnon::KEEP); //series Description
405
+			$tagsObjects[]=new TagAnon("0010,0030", TagAnon::REPLACE, "19000101"); // BirthDay
406
+			$tagsObjects[]=new TagAnon("0008,1030", TagAnon::REPLACE, $newStudyDescription); //studyDescription
407
+			$tagsObjects[]=new TagAnon("0008,103E", TagAnon::KEEP); //series Description
408 408
            
409 409
     
410
-        }else if($profile=="Full"){
411
-            $date=TagAnon::CLEAR;
412
-            $body=TagAnon::CLEAR;
410
+		}else if($profile=="Full"){
411
+			$date=TagAnon::CLEAR;
412
+			$body=TagAnon::CLEAR;
413 413
             
414
-            $tagsObjects[]=new TagAnon("0010,0030", TagAnon::REPLACE, "19000101"); // BirthDay
415
-            $tagsObjects[]=new TagAnon("0008,1030", TagAnon::CLEAR); // studyDescription
416
-            $tagsObjects[]=new TagAnon("0008,103E", TagAnon::CLEAR); //series Description
417
-        }
414
+			$tagsObjects[]=new TagAnon("0010,0030", TagAnon::REPLACE, "19000101"); // BirthDay
415
+			$tagsObjects[]=new TagAnon("0008,1030", TagAnon::CLEAR); // studyDescription
416
+			$tagsObjects[]=new TagAnon("0008,103E", TagAnon::CLEAR); //series Description
417
+		}
418 418
         
419
-    	//List tags releted to Date
420
-    	$tagsObjects[]=new TagAnon("0008,0022", $date); // Acquisition Date
421
-    	$tagsObjects[]=new TagAnon("0008,002A", $date); // Acquisition DateTime
422
-    	$tagsObjects[]=new TagAnon("0008,0032", $date); // Acquisition Time
423
-    	$tagsObjects[]=new TagAnon("0038,0020", $date); // Admitting Date
424
-    	$tagsObjects[]=new TagAnon("0038,0021", $date); // Admitting Time
425
-    	$tagsObjects[]=new TagAnon("0008,0035", $date); // Curve Time
426
-    	$tagsObjects[]=new TagAnon("0008,0025", $date); // Curve Date
427
-    	$tagsObjects[]=new TagAnon("0008,0023", $date); // Content Date
428
-    	$tagsObjects[]=new TagAnon("0008,0033", $date); // Content Time
429
-    	$tagsObjects[]=new TagAnon("0008,0024", $date); // Overlay Date
430
-    	$tagsObjects[]=new TagAnon("0008,0034", $date); // Overlay Time
431
-    	$tagsObjects[]=new TagAnon("0040,0244", $date); // ...Start Date
432
-    	$tagsObjects[]=new TagAnon("0040,0245", $date); // ...Start Time
433
-    	$tagsObjects[]=new TagAnon("0008,0021", $date); // Series Date
434
-    	$tagsObjects[]=new TagAnon("0008,0031", $date); // Series Time
435
-    	$tagsObjects[]=new TagAnon("0008,0020", $date); // Study Date
436
-    	$tagsObjects[]=new TagAnon("0008,0030", $date); // Study Time
437
-    	$tagsObjects[]=new TagAnon("0010,21D0", $date); // Last menstrual date
438
-    	$tagsObjects[]=new TagAnon("0008,0201", $date); // Timezone offset from UTC
439
-    	$tagsObjects[]=new TagAnon("0040,0002", $date); // Scheduled procedure step start date
440
-    	$tagsObjects[]=new TagAnon("0040,0003", $date); // Scheduled procedure step start time
441
-    	$tagsObjects[]=new TagAnon("0040,0004", $date); // Scheduled procedure step end date
442
-    	$tagsObjects[]=new TagAnon("0040,0005", $date); // Scheduled procedure step end time
419
+		//List tags releted to Date
420
+		$tagsObjects[]=new TagAnon("0008,0022", $date); // Acquisition Date
421
+		$tagsObjects[]=new TagAnon("0008,002A", $date); // Acquisition DateTime
422
+		$tagsObjects[]=new TagAnon("0008,0032", $date); // Acquisition Time
423
+		$tagsObjects[]=new TagAnon("0038,0020", $date); // Admitting Date
424
+		$tagsObjects[]=new TagAnon("0038,0021", $date); // Admitting Time
425
+		$tagsObjects[]=new TagAnon("0008,0035", $date); // Curve Time
426
+		$tagsObjects[]=new TagAnon("0008,0025", $date); // Curve Date
427
+		$tagsObjects[]=new TagAnon("0008,0023", $date); // Content Date
428
+		$tagsObjects[]=new TagAnon("0008,0033", $date); // Content Time
429
+		$tagsObjects[]=new TagAnon("0008,0024", $date); // Overlay Date
430
+		$tagsObjects[]=new TagAnon("0008,0034", $date); // Overlay Time
431
+		$tagsObjects[]=new TagAnon("0040,0244", $date); // ...Start Date
432
+		$tagsObjects[]=new TagAnon("0040,0245", $date); // ...Start Time
433
+		$tagsObjects[]=new TagAnon("0008,0021", $date); // Series Date
434
+		$tagsObjects[]=new TagAnon("0008,0031", $date); // Series Time
435
+		$tagsObjects[]=new TagAnon("0008,0020", $date); // Study Date
436
+		$tagsObjects[]=new TagAnon("0008,0030", $date); // Study Time
437
+		$tagsObjects[]=new TagAnon("0010,21D0", $date); // Last menstrual date
438
+		$tagsObjects[]=new TagAnon("0008,0201", $date); // Timezone offset from UTC
439
+		$tagsObjects[]=new TagAnon("0040,0002", $date); // Scheduled procedure step start date
440
+		$tagsObjects[]=new TagAnon("0040,0003", $date); // Scheduled procedure step start time
441
+		$tagsObjects[]=new TagAnon("0040,0004", $date); // Scheduled procedure step end date
442
+		$tagsObjects[]=new TagAnon("0040,0005", $date); // Scheduled procedure step end time
443 443
     	
444
-    	// same for Body characteristics
445
-    	$tagsObjects[]=new TagAnon("0010,2160", $body); // Patient's ethnic group
446
-    	$tagsObjects[]=new TagAnon("0010,21A0", $body); // Patient's smoking status
447
-    	$tagsObjects[]=new TagAnon("0010,0040", $body); // Patient's sex
448
-    	$tagsObjects[]=new TagAnon("0010,2203", $body); // Patient's sex neutered
449
-    	$tagsObjects[]=new TagAnon("0010,1010", $body); // Patient's age
450
-    	$tagsObjects[]=new TagAnon("0010,21C0", $body); // Patient's pregnancy status
451
-    	$tagsObjects[]=new TagAnon("0010,1020", $body); // Patient's size
452
-    	$tagsObjects[]=new TagAnon("0010,1030", $body); // Patient's weight
444
+		// same for Body characteristics
445
+		$tagsObjects[]=new TagAnon("0010,2160", $body); // Patient's ethnic group
446
+		$tagsObjects[]=new TagAnon("0010,21A0", $body); // Patient's smoking status
447
+		$tagsObjects[]=new TagAnon("0010,0040", $body); // Patient's sex
448
+		$tagsObjects[]=new TagAnon("0010,2203", $body); // Patient's sex neutered
449
+		$tagsObjects[]=new TagAnon("0010,1010", $body); // Patient's age
450
+		$tagsObjects[]=new TagAnon("0010,21C0", $body); // Patient's pregnancy status
451
+		$tagsObjects[]=new TagAnon("0010,1020", $body); // Patient's size
452
+		$tagsObjects[]=new TagAnon("0010,1030", $body); // Patient's weight
453 453
     
454
-    	//Others
455
-    	$tagsObjects[]=new TagAnon("0008,0050", TagAnon::REPLACE, $clinicalStudy);  // Accession Number contains study name
456
-    	$tagsObjects[]=new TagAnon("0010,0020", TagAnon::REPLACE, $newPatientID); //new Patient Name
457
-    	$tagsObjects[]=new TagAnon("0010,0010", TagAnon::REPLACE, $newPatientName); //new Patient Name
454
+		//Others
455
+		$tagsObjects[]=new TagAnon("0008,0050", TagAnon::REPLACE, $clinicalStudy);  // Accession Number contains study name
456
+		$tagsObjects[]=new TagAnon("0010,0020", TagAnon::REPLACE, $newPatientID); //new Patient Name
457
+		$tagsObjects[]=new TagAnon("0010,0010", TagAnon::REPLACE, $newPatientName); //new Patient Name
458 458
     	
459
-    	// Keep some Private tags usefull for PET/CT or Scintigraphy
460
-    	$tagsObjects[]=new TagAnon("7053,1000", TagAnon::KEEP); //Phillips
461
-    	$tagsObjects[]=new TagAnon("7053,1009", TagAnon::KEEP); //Phillips
462
-    	$tagsObjects[]=new TagAnon("0009,103B", TagAnon::KEEP); //GE
463
-    	$tagsObjects[]=new TagAnon("0009,100D", TagAnon::KEEP); //GE
464
-    	$tagsObjects[]=new TagAnon("0011,1012", TagAnon::KEEP); //Other
459
+		// Keep some Private tags usefull for PET/CT or Scintigraphy
460
+		$tagsObjects[]=new TagAnon("7053,1000", TagAnon::KEEP); //Phillips
461
+		$tagsObjects[]=new TagAnon("7053,1009", TagAnon::KEEP); //Phillips
462
+		$tagsObjects[]=new TagAnon("0009,103B", TagAnon::KEEP); //GE
463
+		$tagsObjects[]=new TagAnon("0009,100D", TagAnon::KEEP); //GE
464
+		$tagsObjects[]=new TagAnon("0011,1012", TagAnon::KEEP); //Other
465 465
     	
466
-    	$jsonArrayAnon=[];
467
-    	$jsonArrayAnon['KeepPrivateTags']=false;
468
-    	$jsonArrayAnon['Force']=true;
466
+		$jsonArrayAnon=[];
467
+		$jsonArrayAnon['KeepPrivateTags']=false;
468
+		$jsonArrayAnon['Force']=true;
469 469
     	
470
-    	foreach($tagsObjects as $tag) {
470
+		foreach($tagsObjects as $tag) {
471 471
     	    
472
-    	    if($tag->choice==TagAnon::REPLACE){
473
-    	        $jsonArrayAnon['Replace'][$tag->tag]=$tag->newValue;
474
-    	    }else if($tag->choice==TagAnon::KEEP){
475
-    	        $jsonArrayAnon['Keep'][]=$tag->tag;
476
-            }
472
+			if($tag->choice==TagAnon::REPLACE){
473
+				$jsonArrayAnon['Replace'][$tag->tag]=$tag->newValue;
474
+			}else if($tag->choice==TagAnon::KEEP){
475
+				$jsonArrayAnon['Keep'][]=$tag->tag;
476
+			}
477 477
             
478
-    	}
478
+		}
479 479
     	
480
-    	return $jsonArrayAnon;
480
+		return $jsonArrayAnon;
481 481
     	
482
-    }
482
+	}
483 483
     
484
-    /**
485
-     * Remove secondary captures in the study
486
-     * @param string $orthancStudyID
487
-     */
488
-    private function removeSC(string $orthancStudyID){
484
+	/**
485
+	 * Remove secondary captures in the study
486
+	 * @param string $orthancStudyID
487
+	 */
488
+	private function removeSC(string $orthancStudyID){
489 489
     	
490
-    	$studyOrthanc=new Orthanc_Study($orthancStudyID, $this->url, $this->context);
491
-    	$studyOrthanc->retrieveStudyData();
492
-    	$seriesObjects=$studyOrthanc->orthancSeries;
493
-    	foreach ($studyOrthanc->orthancSeries as $serie){
494
-    		if($serie->isSecondaryCapture() ){
495
-    			$this->deleteFromOrthanc("series", $serie->serieOrthancID);
496
-    			error_log("Deleted SC");
497
-    		}
498
-    	}
490
+		$studyOrthanc=new Orthanc_Study($orthancStudyID, $this->url, $this->context);
491
+		$studyOrthanc->retrieveStudyData();
492
+		$seriesObjects=$studyOrthanc->orthancSeries;
493
+		foreach ($studyOrthanc->orthancSeries as $serie){
494
+			if($serie->isSecondaryCapture() ){
495
+				$this->deleteFromOrthanc("series", $serie->serieOrthancID);
496
+				error_log("Deleted SC");
497
+			}
498
+		}
499 499
     	
500
-    }
500
+	}
501 501
     
502 502
     
503
-    /**
504
-     * Return JobId details (get request in Orthanc)
505
-     * @param String $jobId
506
-     * @return mixed
507
-     */
508
-    public function getJobDetails(String $jobId){
503
+	/**
504
+	 * Return JobId details (get request in Orthanc)
505
+	 * @param String $jobId
506
+	 * @return mixed
507
+	 */
508
+	public function getJobDetails(String $jobId){
509 509
         
510
-        $context =stream_context_create($this->context);
511
-        $json = file_get_contents($this->url.'/jobs/'.$jobId, false, $context);
510
+		$context =stream_context_create($this->context);
511
+		$json = file_get_contents($this->url.'/jobs/'.$jobId, false, $context);
512 512
         
513
-        return json_decode($json, true);
513
+		return json_decode($json, true);
514 514
         
515
-    }
515
+	}
516 516
 
517 517
 }
518 518
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
 	 * Build connexion string in Orthanc, boolean to connect with Orthanc Exposed or Orthanc PACS
33 33
 	 * @param boolean $exposed
34 34
 	 */
35
-	public function __construct(bool $exposed=false){
35
+	public function __construct(bool $exposed=false) {
36 36
 	    //Set Time Limit at 3H as operation could be really long
37 37
 	    set_time_limit(10800);
38 38
         //Set address of Orthanc server
39
-        if($exposed){
39
+        if ($exposed) {
40 40
             $this->url=GAELO_ORTHANC_EXPOSED_INTERNAL_ADDRESS.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PORT;
41
-            $this->context = array(
41
+            $this->context=array(
42 42
                 'http' => array(
43
-                    'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD)
43
+                    'header'  => "Authorization: Basic ".base64_encode(GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD)
44 44
 	   			));
45
-        }else{
45
+        }else {
46 46
             $this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
47
-            $this->context = array(
47
+            $this->context=array(
48 48
 	   			'http' => array(
49
-	   			    'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD)
49
+	   			    'header'  => "Authorization: Basic ".base64_encode(GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD)
50 50
 	   			) );
51 51
 	   }
52 52
 
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 	 * Return list of Peers declared in Orthanc
57 57
 	 * @return mixed
58 58
 	 */
59
-	public function getPeers(){
60
-	    $context =stream_context_create($this->context);
61
-	    $json = file_get_contents($this->url.'/peers/',false, $context);
59
+	public function getPeers() {
60
+	    $context=stream_context_create($this->context);
61
+	    $json=file_get_contents($this->url.'/peers/', false, $context);
62 62
 	    $peers=json_decode($json, true);
63 63
 	    return $peers;
64 64
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param string $studyDescription
75 75
 	 * @return string json
76 76
 	 */
77
-	public function searchInOrthanc(string $level, string $patientID, string $patientName, string $studyDate, string $studyUID, string $accessionNumber, string $studyDescription){
77
+	public function searchInOrthanc(string $level, string $patientID, string $patientName, string $studyDate, string $studyUID, string $accessionNumber, string $studyDescription) {
78 78
 		
79 79
 		$queryDetails=array(
80 80
 				'PatientID' => $patientID,
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
 				
94 94
 		);
95 95
 		
96
-		$opts = array('http' =>
96
+		$opts=array('http' =>
97 97
 				array(
98 98
 						'method'  => 'POST',
99 99
 						'content' => json_encode($query),
100
-				        'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
100
+				        'header'=>  ['Content-Type: application/json Accept: application/json ', $this->context['http']['header']]
101 101
 				)
102 102
 		);
103 103
 
104
-		$context  = stream_context_create($opts);
105
-		$resultJson = file_get_contents($this->url.'/tools/find', false, $context);
104
+		$context=stream_context_create($opts);
105
+		$resultJson=file_get_contents($this->url.'/tools/find', false, $context);
106 106
 		$result=json_decode($resultJson);
107 107
 		
108 108
 		return $result;
@@ -113,26 +113,26 @@  discard block
 block discarded – undo
113 113
 	 * @param array $uidList
114 114
 	 * @return string temporary file path
115 115
 	 */
116
-	public function getZipTempFile(array $uidList){
116
+	public function getZipTempFile(array $uidList) {
117 117
 	   
118
-	    if( !is_array($uidList)){
118
+	    if (!is_array($uidList)) {
119 119
 	        $uidList=array($uidList);
120 120
 	    }
121 121
 	    
122
-	    $opts = array('http' =>
122
+	    $opts=array('http' =>
123 123
 	        array(
124 124
 	            'method'  => 'POST',
125 125
 	            'content' => json_encode($uidList),
126 126
 	            'timeout' => 3600,
127
-	            'header'=>  ['Content-Type: application/json', 'Accept: application/zip',$this->context['http']['header'] ]
127
+	            'header'=>  ['Content-Type: application/json', 'Accept: application/zip', $this->context['http']['header']]
128 128
 	        )
129 129
 	    );
130 130
 	    
131
-	    $context = stream_context_create($opts);
131
+	    $context=stream_context_create($opts);
132 132
 	    
133
- 	    $temp = tempnam(ini_get('upload_tmp_dir'), 'TMP_');
133
+ 	    $temp=tempnam(ini_get('upload_tmp_dir'), 'TMP_');
134 134
 	    
135
-	    $nbbytes=file_put_contents($temp , fopen($this->url.'/tools/create-archive','rb', false, $context));
135
+	    $nbbytes=file_put_contents($temp, fopen($this->url.'/tools/create-archive', 'rb', false, $context));
136 136
 	    
137 137
 	    return $temp;
138 138
 	}
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
 	 * @param  $level
144 144
 	 * @param  $uidList
145 145
 	 */
146
-	public function deleteFromOrthanc(string $level, string $uid){
146
+	public function deleteFromOrthanc(string $level, string $uid) {
147 147
 	    
148
-	    $opts = array('http' =>
148
+	    $opts=array('http' =>
149 149
 	        array(
150 150
 	            'method'  => 'DELETE',
151
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
151
+	            'header'=>  ['Content-Type: application/json Accept: application/json', $this->context['http']['header']]
152 152
 	        )
153 153
 	    );
154 154
 	    
155
-	    $context  = stream_context_create($opts);
156
-	    $result = file_get_contents($this->url.'/'.$level.'/'.$uid, false, $context);
155
+	    $context=stream_context_create($opts);
156
+	    $result=file_get_contents($this->url.'/'.$level.'/'.$uid, false, $context);
157 157
 	    
158 158
 	}
159 159
 	
@@ -165,21 +165,21 @@  discard block
 block discarded – undo
165 165
 	 * @param string $password
166 166
 	 * @return mixed
167 167
 	 */
168
-	public function addPeer(string $name , string $url, string $username, string $password){
168
+	public function addPeer(string $name, string $url, string $username, string $password) {
169 169
 	    
170 170
 	    $peerValues['Username']=$username;
171 171
 	    $peerValues['Password']=$password;
172 172
 	    $peerValues['Url']=$url;
173
-	    $opts = array('http' =>
173
+	    $opts=array('http' =>
174 174
 	        array(
175 175
 	            'method'  => 'PUT',
176 176
 	            'content' => json_encode($peerValues),
177
-	            'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
177
+	            'header'=>  ['Content-Type: application/json Accept: application/json ', $this->context['http']['header']]
178 178
 	        )
179 179
 	    );
180 180
 	    
181
-	    $context  = stream_context_create($opts);
182
-	    $resultJson = file_get_contents($this->url.'/peers/'.$name, false, $context);
181
+	    $context=stream_context_create($opts);
182
+	    $resultJson=file_get_contents($this->url.'/peers/'.$name, false, $context);
183 183
 	    
184 184
 	    $result=json_decode($resultJson);
185 185
 	    return $result;
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
 	 * Remove Peer declaration from Orthanc
191 191
 	 * @param string $name
192 192
 	 */
193
-	public function removePeer(string $name){
193
+	public function removePeer(string $name) {
194 194
 	    
195
-	    $opts = array('http' =>
195
+	    $opts=array('http' =>
196 196
 	        array(
197 197
 	            'method'  => 'DELETE',
198
-	            'header'=>  ['Content-Type: application/json Accept: application/json ',$this->context['http']['header']]
198
+	            'header'=>  ['Content-Type: application/json Accept: application/json ', $this->context['http']['header']]
199 199
 	        )
200 200
 	    );
201 201
 	    
202
-	    $context  = stream_context_create($opts);
203
-	    $resultJson = file_get_contents($this->url.'/peers/'.$name, false, $context);
202
+	    $context=stream_context_create($opts);
203
+	    $resultJson=file_get_contents($this->url.'/peers/'.$name, false, $context);
204 204
 	    
205 205
 	    $result=json_decode($resultJson);
206 206
 	    
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 	/**
211 211
 	 * Remove all peers from orthanc
212 212
 	 */
213
-	public function removeAllPeers(){
213
+	public function removeAllPeers() {
214 214
 	    
215 215
 	    $peers=$this->getPeers();
216 216
 	    
217
-	    foreach ($peers as $peer){
217
+	    foreach ($peers as $peer) {
218 218
 	        $this->removePeer($peer);
219 219
 	    }
220 220
 	    
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 	 * @param string $peer
226 226
 	 * @return boolean
227 227
 	 */
228
-	public function isPeerAccelerated(string $peer){
229
-	    $context =stream_context_create($this->context);
230
-	    $json = file_get_contents($this->url.'/transfers/peers/',false, $context);
228
+	public function isPeerAccelerated(string $peer) {
229
+	    $context=stream_context_create($this->context);
230
+	    $json=file_get_contents($this->url.'/transfers/peers/', false, $context);
231 231
 	    $peersTest=json_decode($json, true);
232 232
 	    
233
-	    if($peersTest[$peer]=="installed"){
233
+	    if ($peersTest[$peer] == "installed") {
234 234
 	        return true;
235 235
 	    }
236 236
 	    
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
 	 * @param string $peer
243 243
 	 * @param array $ids
244 244
 	 */
245
-	public function sendToPeer(string $peer, array $ids){
245
+	public function sendToPeer(string $peer, array $ids) {
246 246
 		
247
-		$opts = array('http' =>
247
+		$opts=array('http' =>
248 248
 				array(
249 249
 						'method'  => 'POST',
250 250
                         "timeout" => 300, 
251 251
 						'content' => json_encode($ids),
252
-						'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
252
+						'header'=>  ['Content-Type: application/json Accept: application/json', $this->context['http']['header']]
253 253
 				)
254 254
 		);
255 255
 		
256
-		$context = stream_context_create($opts);
257
-		$result = file_get_contents($this->url.'/peers/'.$peer.'/store', false, $context);
256
+		$context=stream_context_create($opts);
257
+		$result=file_get_contents($this->url.'/peers/'.$peer.'/store', false, $context);
258 258
 		return $result;
259 259
 	    
260 260
 	}
@@ -265,20 +265,20 @@  discard block
 block discarded – undo
265 265
 	 * @param array $ids
266 266
 	 * @return string
267 267
 	 */
268
-	public function sendToPeerAsync(string $peer, array $ids){
268
+	public function sendToPeerAsync(string $peer, array $ids) {
269 269
 	    $data['Synchronous']=false;
270 270
 	    $data['Resources']=$ids;
271 271
 	    
272
-	    $opts = array('http' =>
272
+	    $opts=array('http' =>
273 273
 	        array(
274 274
 	            'method'  => 'POST',
275 275
 	            'content' => json_encode($data),
276
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
276
+	            'header'=>  ['Content-Type: application/json Accept: application/json', $this->context['http']['header']]
277 277
 	        )
278 278
 	    );
279 279
 	    
280
-	    $context = stream_context_create($opts);
281
-	    $result = file_get_contents($this->url.'/peers/'.$peer.'/store', false, $context);
280
+	    $context=stream_context_create($opts);
281
+	    $result=file_get_contents($this->url.'/peers/'.$peer.'/store', false, $context);
282 282
 	    return $result;
283 283
 	}
284 284
 	
@@ -289,35 +289,35 @@  discard block
 block discarded – undo
289 289
 	 * @param bool $gzip
290 290
 	 * @return string
291 291
 	 */
292
-	public function sendToPeerAsyncWithAccelerator(string $peer, array $ids, bool $gzip){
292
+	public function sendToPeerAsyncWithAccelerator(string $peer, array $ids, bool $gzip) {
293 293
 	    
294 294
 	    //If Peer dosen't have accelerated transfers fall back to regular orthanc peer transfers
295
-	    if( ! $this->isPeerAccelerated($peer)){
295
+	    if (!$this->isPeerAccelerated($peer)) {
296 296
 	        $answer=$this->sendToPeerAsync($peer, $ids);
297 297
 	        return $answer;
298 298
 	    }
299 299
 	    
300
-	    if(!$gzip) $data['Compression']="none" ; else $data['Compression']="gzip";
300
+	    if (!$gzip) $data['Compression']="none"; else $data['Compression']="gzip";
301 301
 	    
302 302
 	    $data['Peer']=$peer;
303 303
 	    
304 304
 	    
305
-	    foreach ($ids as $serieID){
305
+	    foreach ($ids as $serieID) {
306 306
 	        $resourceSeries['Level']="Series";
307 307
 	        $resourceSeries['ID']=$serieID;
308 308
 	        $data['Resources'][]=$resourceSeries;
309 309
 	    }
310 310
 	    
311
-	    $opts = array('http' =>
311
+	    $opts=array('http' =>
312 312
 	        array(
313 313
 	            'method'  => 'POST',
314 314
 	            'content' => json_encode($data),
315
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
315
+	            'header'=>  ['Content-Type: application/json Accept: application/json', $this->context['http']['header']]
316 316
 	        )
317 317
 	    );
318 318
 	    
319
-	    $context = stream_context_create($opts);
320
-	    $result = file_get_contents($this->url.'/transfers/send', false, $context);
319
+	    $context=stream_context_create($opts);
320
+	    $result=file_get_contents($this->url.'/transfers/send', false, $context);
321 321
 	    
322 322
 	    return $result;
323 323
 	    
@@ -328,21 +328,21 @@  discard block
 block discarded – undo
328 328
 	 * @param string $file (path)
329 329
 	 * @return string
330 330
 	 */
331
-	public function importFile(string $file){
331
+	public function importFile(string $file) {
332 332
 	    
333
-	    try{
334
-    	    $opts = array('http' =>
333
+	    try {
334
+    	    $opts=array('http' =>
335 335
     	        array(
336 336
     	            'method'  => 'POST',
337 337
     	            'content' => file_get_contents($file),
338
-    	            'header'=>  ['Content-Type: application/dicom Accept: application/json',"content-length: ".filesize($file),$this->context['http']['header']]
338
+    	            'header'=>  ['Content-Type: application/dicom Accept: application/json', "content-length: ".filesize($file), $this->context['http']['header']]
339 339
     	        )
340 340
     	    );
341 341
     	    
342
-    	    $context = stream_context_create($opts);
343
-    	    $result = file_get_contents($this->url.'/instances', false, $context);
342
+    	    $context=stream_context_create($opts);
343
+    	    $result=file_get_contents($this->url.'/instances', false, $context);
344 344
     	    
345
-	    }catch(Exception $e1){
345
+	    }catch (Exception $e1) {
346 346
 	        error_log("Error during import Dcm ".$e1->getMessage());
347 347
 	    }
348 348
 	    return $result;
@@ -359,22 +359,22 @@  discard block
 block discarded – undo
359 359
 	 * @param string $studyName
360 360
 	 * @return string
361 361
 	 */
362
-	public function Anonymize(string $studyID, string $profile, string $patientCode, string $visitType, string $studyName){
362
+	public function Anonymize(string $studyID, string $profile, string $patientCode, string $visitType, string $studyName) {
363 363
 	    
364 364
 	    $jsonAnonQuery=$this->buildAnonQuery($profile, $patientCode, $patientCode, $visitType, $studyName);
365 365
 	    
366
-	    $opts = array('http' =>
366
+	    $opts=array('http' =>
367 367
 	        array(
368 368
 	            'method'  => 'POST',
369 369
 	            "timeout" => 300,
370 370
 	            'content' => json_encode($jsonAnonQuery),
371
-	            'header'=>  ['Content-Type: application/json Accept: application/json',$this->context['http']['header']]
371
+	            'header'=>  ['Content-Type: application/json Accept: application/json', $this->context['http']['header']]
372 372
 	        )
373 373
 	    );
374 374
 	    
375
-	    $context = stream_context_create($opts);
375
+	    $context=stream_context_create($opts);
376 376
 
377
-        $result = file_get_contents($this->url."/studies/".$studyID."/anonymize", false, $context);
377
+        $result=file_get_contents($this->url."/studies/".$studyID."/anonymize", false, $context);
378 378
         
379 379
 	    //get the resulting Anonymized study Orthanc ID
380 380
 	    $anonAnswer=json_decode($result, true);
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 	 * @param string $newStudyDescription
396 396
 	 * @return string
397 397
 	 */
398
-	private function buildAnonQuery(string $profile, string $newPatientName, string $newPatientID, string $newStudyDescription, string $clinicalStudy){
398
+	private function buildAnonQuery(string $profile, string $newPatientName, string $newPatientID, string $newStudyDescription, string $clinicalStudy) {
399 399
     	    
400 400
         $tagsObjects=[];
401
-        if($profile=="Default"){
401
+        if ($profile == "Default") {
402 402
             $date=TagAnon::KEEP;
403 403
             $body=TagAnon::KEEP;
404 404
             
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             $tagsObjects[]=new TagAnon("0008,103E", TagAnon::KEEP); //series Description
408 408
            
409 409
     
410
-        }else if($profile=="Full"){
410
+        }else if ($profile == "Full") {
411 411
             $date=TagAnon::CLEAR;
412 412
             $body=TagAnon::CLEAR;
413 413
             
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
     	$tagsObjects[]=new TagAnon("0010,1030", $body); // Patient's weight
453 453
     
454 454
     	//Others
455
-    	$tagsObjects[]=new TagAnon("0008,0050", TagAnon::REPLACE, $clinicalStudy);  // Accession Number contains study name
455
+    	$tagsObjects[]=new TagAnon("0008,0050", TagAnon::REPLACE, $clinicalStudy); // Accession Number contains study name
456 456
     	$tagsObjects[]=new TagAnon("0010,0020", TagAnon::REPLACE, $newPatientID); //new Patient Name
457 457
     	$tagsObjects[]=new TagAnon("0010,0010", TagAnon::REPLACE, $newPatientName); //new Patient Name
458 458
     	
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
     	$jsonArrayAnon['KeepPrivateTags']=false;
468 468
     	$jsonArrayAnon['Force']=true;
469 469
     	
470
-    	foreach($tagsObjects as $tag) {
470
+    	foreach ($tagsObjects as $tag) {
471 471
     	    
472
-    	    if($tag->choice==TagAnon::REPLACE){
472
+    	    if ($tag->choice == TagAnon::REPLACE) {
473 473
     	        $jsonArrayAnon['Replace'][$tag->tag]=$tag->newValue;
474
-    	    }else if($tag->choice==TagAnon::KEEP){
474
+    	    }else if ($tag->choice == TagAnon::KEEP) {
475 475
     	        $jsonArrayAnon['Keep'][]=$tag->tag;
476 476
             }
477 477
             
@@ -485,13 +485,13 @@  discard block
 block discarded – undo
485 485
      * Remove secondary captures in the study
486 486
      * @param string $orthancStudyID
487 487
      */
488
-    private function removeSC(string $orthancStudyID){
488
+    private function removeSC(string $orthancStudyID) {
489 489
     	
490 490
     	$studyOrthanc=new Orthanc_Study($orthancStudyID, $this->url, $this->context);
491 491
     	$studyOrthanc->retrieveStudyData();
492 492
     	$seriesObjects=$studyOrthanc->orthancSeries;
493
-    	foreach ($studyOrthanc->orthancSeries as $serie){
494
-    		if($serie->isSecondaryCapture() ){
493
+    	foreach ($studyOrthanc->orthancSeries as $serie) {
494
+    		if ($serie->isSecondaryCapture()) {
495 495
     			$this->deleteFromOrthanc("series", $serie->serieOrthancID);
496 496
     			error_log("Deleted SC");
497 497
     		}
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
      * @param String $jobId
506 506
      * @return mixed
507 507
      */
508
-    public function getJobDetails(String $jobId){
508
+    public function getJobDetails(String $jobId) {
509 509
         
510
-        $context =stream_context_create($this->context);
511
-        $json = file_get_contents($this->url.'/jobs/'.$jobId, false, $context);
510
+        $context=stream_context_create($this->context);
511
+        $json=file_get_contents($this->url.'/jobs/'.$jobId, false, $context);
512 512
         
513 513
         return json_decode($json, true);
514 514
         
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                 'http' => array(
43 43
                     'header'  => "Authorization: Basic " . base64_encode(GAELO_ORTHANC_EXPOSED_INTERNAL_LOGIN.':'.GAELO_ORTHANC_EXPOSED_INTERNAL_PASSWORD)
44 44
 	   			));
45
-        }else{
45
+        } else{
46 46
             $this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT;
47 47
             $this->context = array(
48 48
 	   			'http' => array(
@@ -297,7 +297,11 @@  discard block
 block discarded – undo
297 297
 	        return $answer;
298 298
 	    }
299 299
 	    
300
-	    if(!$gzip) $data['Compression']="none" ; else $data['Compression']="gzip";
300
+	    if(!$gzip) {
301
+	    	$data['Compression']="none" ;
302
+	    } else {
303
+	    	$data['Compression']="gzip";
304
+	    }
301 305
 	    
302 306
 	    $data['Peer']=$peer;
303 307
 	    
@@ -342,7 +346,7 @@  discard block
 block discarded – undo
342 346
     	    $context = stream_context_create($opts);
343 347
     	    $result = file_get_contents($this->url.'/instances', false, $context);
344 348
     	    
345
-	    }catch(Exception $e1){
349
+	    } catch(Exception $e1){
346 350
 	        error_log("Error during import Dcm ".$e1->getMessage());
347 351
 	    }
348 352
 	    return $result;
@@ -407,7 +411,7 @@  discard block
 block discarded – undo
407 411
             $tagsObjects[]=new TagAnon("0008,103E", TagAnon::KEEP); //series Description
408 412
            
409 413
     
410
-        }else if($profile=="Full"){
414
+        } else if($profile=="Full"){
411 415
             $date=TagAnon::CLEAR;
412 416
             $body=TagAnon::CLEAR;
413 417
             
@@ -471,7 +475,7 @@  discard block
 block discarded – undo
471 475
     	    
472 476
     	    if($tag->choice==TagAnon::REPLACE){
473 477
     	        $jsonArrayAnon['Replace'][$tag->tag]=$tag->newValue;
474
-    	    }else if($tag->choice==TagAnon::KEEP){
478
+    	    } else if($tag->choice==TagAnon::KEEP){
475 479
     	        $jsonArrayAnon['Keep'][]=$tag->tag;
476 480
             }
477 481
             
Please login to merge, or discard this patch.