Passed
Push — dev ( d62152...d10d14 )
by Salim
03:23
created
src/models/Documentation.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -20,66 +20,66 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Documentation {
22 22
     
23
-    public $documentId;
24
-    public $study;
25
-    public $documentName;
26
-    public $documentFileLocation;
27
-    public $documentVersion;
28
-    public $documentDate;
29
-    public $accessInvestigator;
30
-    public $accessController;
31
-    public $accessMonitor;
32
-    public $accessReviewer;
33
-    public $deleted;
23
+	public $documentId;
24
+	public $study;
25
+	public $documentName;
26
+	public $documentFileLocation;
27
+	public $documentVersion;
28
+	public $documentDate;
29
+	public $accessInvestigator;
30
+	public $accessController;
31
+	public $accessMonitor;
32
+	public $accessReviewer;
33
+	public $deleted;
34 34
     
35 35
     
36
-    public function __construct(PDO $linkpdo, int $idDocumentation){
36
+	public function __construct(PDO $linkpdo, int $idDocumentation){
37 37
     	
38
-    	$documentationQuery = $linkpdo->prepare("SELECT * FROM documentation WHERE id_documentation = :idDocumentation");
39
-    	$documentationQuery->execute(array('idDocumentation' => $idDocumentation));
40
-    	$documentation=$documentationQuery->fetch(PDO::FETCH_ASSOC);
38
+		$documentationQuery = $linkpdo->prepare("SELECT * FROM documentation WHERE id_documentation = :idDocumentation");
39
+		$documentationQuery->execute(array('idDocumentation' => $idDocumentation));
40
+		$documentation=$documentationQuery->fetch(PDO::FETCH_ASSOC);
41 41
     	
42
-        $this->documentId=$documentation['id_documentation'];
43
-        $this->study=$documentation['study'];
44
-        $this->documentName=$documentation['name'];
45
-        $this->documentVersion=$documentation['version'];
46
-        $this->documentDate=$documentation['document_date'];
47
-        $this->accessInvestigator=$documentation['investigator'];
48
-        $this->accessController=$documentation['controller'];
49
-        $this->accessMonitor=$documentation['monitor'];
50
-        $this->accessReviewer=$documentation['reviewer'];
51
-        $this->deleted=$documentation['deleted'];
42
+		$this->documentId=$documentation['id_documentation'];
43
+		$this->study=$documentation['study'];
44
+		$this->documentName=$documentation['name'];
45
+		$this->documentVersion=$documentation['version'];
46
+		$this->documentDate=$documentation['document_date'];
47
+		$this->accessInvestigator=$documentation['investigator'];
48
+		$this->accessController=$documentation['controller'];
49
+		$this->accessMonitor=$documentation['monitor'];
50
+		$this->accessReviewer=$documentation['reviewer'];
51
+		$this->deleted=$documentation['deleted'];
52 52
         
53
-        $this->documentFileLocation = ($_SERVER['DOCUMENT_ROOT']."/data/upload/documentation/".$this->study."/".$this->documentName);
54
-    }
53
+		$this->documentFileLocation = ($_SERVER['DOCUMENT_ROOT']."/data/upload/documentation/".$this->study."/".$this->documentName);
54
+	}
55 55
     
56
-    /**
57
-     * Return if the current documentation is allowed for a given role
58
-     * @param String $role
59
-     * @return boolean
60
-     */
56
+	/**
57
+	 * Return if the current documentation is allowed for a given role
58
+	 * @param String $role
59
+	 * @return boolean
60
+	 */
61 61
     
62
-    public function isDocumentationAllowedForRole(String $role){
63
-        if($role==User::INVESTIGATOR) return $this->accessInvestigator;
64
-        else if($role==User::CONTROLLER) return $this->accessController;
65
-        else if($role==User::MONITOR) return $this->accessMonitor;
66
-        else if($role==User::REVIEWER) return $this->accessReviewer;
67
-        else if($role==User::SUPERVISOR) return true;
68
-        else return false;
69
-    }
62
+	public function isDocumentationAllowedForRole(String $role){
63
+		if($role==User::INVESTIGATOR) return $this->accessInvestigator;
64
+		else if($role==User::CONTROLLER) return $this->accessController;
65
+		else if($role==User::MONITOR) return $this->accessMonitor;
66
+		else if($role==User::REVIEWER) return $this->accessReviewer;
67
+		else if($role==User::SUPERVISOR) return true;
68
+		else return false;
69
+	}
70 70
     
71
-    /**
72
-     * Update documentation table
73
-     * @param PDO $linkpdo
74
-     * @param int $idDocumentation
75
-     * @param bool $investigator
76
-     * @param bool $monitor
77
-     * @param bool $controller
78
-     * @param bool $reviewer
79
-     * @param bool $deleted
80
-     */
81
-    public static function updateDocumentation(PDO $linkpdo, int $idDocumentation, bool $investigator, bool $monitor, bool $controller, bool $reviewer, bool $deleted){
82
-        $update = $linkpdo->prepare('UPDATE documentation
71
+	/**
72
+	 * Update documentation table
73
+	 * @param PDO $linkpdo
74
+	 * @param int $idDocumentation
75
+	 * @param bool $investigator
76
+	 * @param bool $monitor
77
+	 * @param bool $controller
78
+	 * @param bool $reviewer
79
+	 * @param bool $deleted
80
+	 */
81
+	public static function updateDocumentation(PDO $linkpdo, int $idDocumentation, bool $investigator, bool $monitor, bool $controller, bool $reviewer, bool $deleted){
82
+		$update = $linkpdo->prepare('UPDATE documentation
83 83
                                     SET investigator = :investigator,
84 84
                                         controller = :controller,
85 85
                                         monitor = :monitor,
@@ -87,29 +87,29 @@  discard block
 block discarded – undo
87 87
                                         deleted=:deleted
88 88
 									WHERE id_documentation = :id');
89 89
         
90
-        $update->execute(array('investigator' => intval($investigator),
91
-            'controller' => intval($controller),
92
-            'monitor' => intval($monitor),
93
-            'reviewer' =>intval($reviewer),
94
-            'deleted'=>intval($deleted),
95
-            'id' => $idDocumentation ));
96
-    }
90
+		$update->execute(array('investigator' => intval($investigator),
91
+			'controller' => intval($controller),
92
+			'monitor' => intval($monitor),
93
+			'reviewer' =>intval($reviewer),
94
+			'deleted'=>intval($deleted),
95
+			'id' => $idDocumentation ));
96
+	}
97 97
     
98
-    /**
99
-     * Create documentation entry in database
100
-     * @param PDO $linkpdo
101
-     * @param String $uploadedFilename
102
-     * @param String $study
103
-     * @param String $version
104
-     */
105
-    public static function insertDocumentation(PDO $linkpdo, String $uploadedFilename, String $study, String $version){
106
-        $insertion = $linkpdo->prepare('INSERT INTO documentation (name, document_date, study, version)
98
+	/**
99
+	 * Create documentation entry in database
100
+	 * @param PDO $linkpdo
101
+	 * @param String $uploadedFilename
102
+	 * @param String $study
103
+	 * @param String $version
104
+	 */
105
+	public static function insertDocumentation(PDO $linkpdo, String $uploadedFilename, String $study, String $version){
106
+		$insertion = $linkpdo->prepare('INSERT INTO documentation (name, document_date, study, version)
107 107
 																			VALUES (:name, :doc_date, :study, :version)');
108
-        $insertion->execute(array(
109
-            'name' => $uploadedFilename,
110
-            'doc_date' => date("Y-m-d"),
111
-            'study' => $study,
112
-            'version'=>$version
113
-        ));
114
-    }
108
+		$insertion->execute(array(
109
+			'name' => $uploadedFilename,
110
+			'doc_date' => date("Y-m-d"),
111
+			'study' => $study,
112
+			'version'=>$version
113
+		));
114
+	}
115 115
 }
116 116
\ No newline at end of file
Please login to merge, or discard this patch.
src/models/TagAnon.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@
 block discarded – undo
18 18
  */
19 19
 class TagAnon {
20 20
     
21
-    const KEEP=0;
22
-    const REPLACE=1;
23
-    const CLEAR=2;
21
+	const KEEP=0;
22
+	const REPLACE=1;
23
+	const CLEAR=2;
24 24
     
25
-    public $tag;
26
-    public $choice;
27
-    public $newValue;
25
+	public $tag;
26
+	public $choice;
27
+	public $newValue;
28 28
     
29
-    public function __construct($tag, $choice, $newValue=null){
30
-        $this->tag=$tag;
31
-        $this->choice=$choice;
32
-        $this->newValue=$newValue;
33
-    }
29
+	public function __construct($tag, $choice, $newValue=null){
30
+		$this->tag=$tag;
31
+		$this->choice=$choice;
32
+		$this->newValue=$newValue;
33
+	}
34 34
     
35 35
 }
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
src/models/Center.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct(PDO $linkpdo, $code){
34 34
 	    
35
-	    $centerQuery = $linkpdo->prepare('SELECT * FROM centers WHERE code=:code');
36
-	    $centerQuery->execute(array('code'=>$code));
37
-	    $center=$centerQuery->fetch(PDO::FETCH_ASSOC);
35
+		$centerQuery = $linkpdo->prepare('SELECT * FROM centers WHERE code=:code');
36
+		$centerQuery->execute(array('code'=>$code));
37
+		$center=$centerQuery->fetch(PDO::FETCH_ASSOC);
38 38
 	    
39
-	    if(empty($center)){
40
-	        throw new Exception("Non Existing Center");
41
-	    }
42
-	    $this->linkpdo=$linkpdo;
43
-	    $this->name=$center['name'];
44
-	    $this->code=$center['code'];
45
-	    $this->countryCode=$center['country_code'];
46
-	    $this->countryName=Global_Data::getCountryName($linkpdo, $this->countryCode);
39
+		if(empty($center)){
40
+			throw new Exception("Non Existing Center");
41
+		}
42
+		$this->linkpdo=$linkpdo;
43
+		$this->name=$center['name'];
44
+		$this->code=$center['code'];
45
+		$this->countryCode=$center['country_code'];
46
+		$this->countryName=Global_Data::getCountryName($linkpdo, $this->countryCode);
47 47
 	}
48 48
 
49 49
 	/**
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 	 * @param string $countryCode
53 53
 	 */
54 54
 	public function updateCenter(string $name, string $countryCode){
55
-	    $updatePatient = $this->linkpdo->prepare("UPDATE centers
55
+		$updatePatient = $this->linkpdo->prepare("UPDATE centers
56 56
                                             SET name = :centerName,
57 57
                                             country_code = :countryCode
58 58
                                             WHERE code = :code");
59 59
 	    
60
-	    $updatePatient->execute(array('centerName'=>$name,
61
-	        'countryCode'=>$countryCode,
62
-	        'code'=>$this->code));
60
+		$updatePatient->execute(array('centerName'=>$name,
61
+			'countryCode'=>$countryCode,
62
+			'code'=>$this->code));
63 63
 	    
64 64
 	}
65 65
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		$insertion->execute(array(
108 108
 				'name' => $name,
109 109
 				'code' => $code,
110
-		        'countryCode' =>$countryCode
110
+				'countryCode' =>$countryCode
111 111
 		));
112 112
 	}
113 113
 }
114 114
\ No newline at end of file
Please login to merge, or discard this patch.
src/models/Patient.php 1 patch
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -19,99 +19,99 @@  discard block
 block discarded – undo
19 19
 
20 20
 class Patient{
21 21
     
22
-    public $patient;
23
-    private $linkpdo;
24
-    public $patientCode;
25
-    public $patientFirstName;
26
-    public $patientLastName;
27
-    public $patientGender;
28
-    public $patientBirthDateUS;
29
-    public $patientBirthDate;
30
-    public $patientRegistrationDate;
31
-    public $patientInvestigatorName;
32
-    public $patientCenter;
33
-    public $patientStudy;
34
-    public $patientWithdraw;
35
-    public $patientWithdrawReason;
36
-    public $patientWithdrawDate;
37
-    public $patientWithdrawDateString;
38
-
39
-    const PATIENT_WITHDRAW="withdraw";
22
+	public $patient;
23
+	private $linkpdo;
24
+	public $patientCode;
25
+	public $patientFirstName;
26
+	public $patientLastName;
27
+	public $patientGender;
28
+	public $patientBirthDateUS;
29
+	public $patientBirthDate;
30
+	public $patientRegistrationDate;
31
+	public $patientInvestigatorName;
32
+	public $patientCenter;
33
+	public $patientStudy;
34
+	public $patientWithdraw;
35
+	public $patientWithdrawReason;
36
+	public $patientWithdrawDate;
37
+	public $patientWithdrawDateString;
38
+
39
+	const PATIENT_WITHDRAW="withdraw";
40 40
     
41
-    function __construct($patientCode, PDO $linkpdo) {
42
-        $this->patient=$patientCode;
43
-        $this->linkpdo= $linkpdo;
41
+	function __construct($patientCode, PDO $linkpdo) {
42
+		$this->patient=$patientCode;
43
+		$this->linkpdo= $linkpdo;
44 44
         
45
-        $queryPatientsData = $this->linkpdo->prepare('SELECT * FROM patients WHERE code = :patient');
46
-        $queryPatientsData->execute(array('patient' => $this->patient));
47
-        $dataPatient = $queryPatientsData->fetch(PDO::FETCH_ASSOC);
45
+		$queryPatientsData = $this->linkpdo->prepare('SELECT * FROM patients WHERE code = :patient');
46
+		$queryPatientsData->execute(array('patient' => $this->patient));
47
+		$dataPatient = $queryPatientsData->fetch(PDO::FETCH_ASSOC);
48 48
         
49
-        if(empty($dataPatient)){
50
-            throw new Exception("Non Existing Patient");
51
-        }
49
+		if(empty($dataPatient)){
50
+			throw new Exception("Non Existing Patient");
51
+		}
52 52
         
53
-        $this->patientCode=$dataPatient['code'];
54
-        $this->patientFirstName=$dataPatient['first_name'];
55
-        $this->patientLastName=$dataPatient['last_name'];
56
-        $this->patientGender=$dataPatient['gender'];
57
-        $this->patientBirthDateUS=sprintf("%02d", $dataPatient['birth_month']).'-'.sprintf("%02d", $dataPatient['birth_day']).'-'.$dataPatient['birth_year'];
58
-        $this->patientBirthDate=sprintf("%02d", $dataPatient['birth_year']).'-'.sprintf("%02d", $dataPatient['birth_month']).'-'.$dataPatient['birth_day'];
59
-        $this->patientRegistrationDate=$dataPatient['registration_date'];
60
-        $this->patientInvestigatorName=$dataPatient['investigator_name'];
61
-        $this->patientCenter=$dataPatient['center'];
62
-        $this->patientStudy=$dataPatient['study'];
63
-        $this->patientWithdraw=$dataPatient['withdraw'];
64
-        $this->patientWithdrawReason=$dataPatient['withdraw_reason'];
65
-        $this->patientWithdrawDate=new DateTimeImmutable($dataPatient['withdraw_date']);
66
-        $this->patientWithdrawDateString=$dataPatient['withdraw_date'];
53
+		$this->patientCode=$dataPatient['code'];
54
+		$this->patientFirstName=$dataPatient['first_name'];
55
+		$this->patientLastName=$dataPatient['last_name'];
56
+		$this->patientGender=$dataPatient['gender'];
57
+		$this->patientBirthDateUS=sprintf("%02d", $dataPatient['birth_month']).'-'.sprintf("%02d", $dataPatient['birth_day']).'-'.$dataPatient['birth_year'];
58
+		$this->patientBirthDate=sprintf("%02d", $dataPatient['birth_year']).'-'.sprintf("%02d", $dataPatient['birth_month']).'-'.$dataPatient['birth_day'];
59
+		$this->patientRegistrationDate=$dataPatient['registration_date'];
60
+		$this->patientInvestigatorName=$dataPatient['investigator_name'];
61
+		$this->patientCenter=$dataPatient['center'];
62
+		$this->patientStudy=$dataPatient['study'];
63
+		$this->patientWithdraw=$dataPatient['withdraw'];
64
+		$this->patientWithdrawReason=$dataPatient['withdraw_reason'];
65
+		$this->patientWithdrawDate=new DateTimeImmutable($dataPatient['withdraw_date']);
66
+		$this->patientWithdrawDateString=$dataPatient['withdraw_date'];
67 67
         
68
-    }
68
+	}
69 69
 
70
-    public function getImmutableRegistrationDate() : DateTimeImmutable {
71
-        return new DateTimeImmutable($this->patientRegistrationDate);
72
-    }
70
+	public function getImmutableRegistrationDate() : DateTimeImmutable {
71
+		return new DateTimeImmutable($this->patientRegistrationDate);
72
+	}
73 73
     
74
-    /**
75
-     * get Patient's Center Object
76
-     * @return Center
77
-     */
78
-    public function getPatientCenter() : Center {
79
-        $centerObject=new Center($this->linkpdo, $this->patientCenter);
80
-        return $centerObject;
81
-    }
74
+	/**
75
+	 * get Patient's Center Object
76
+	 * @return Center
77
+	 */
78
+	public function getPatientCenter() : Center {
79
+		$centerObject=new Center($this->linkpdo, $this->patientCenter);
80
+		return $centerObject;
81
+	}
82 82
     
83
-    /**
84
-     * Update withdraw status
85
-     * @param bool $withdraw
86
-     * @param string $withdrawDate
87
-     * @param string $withdrawReason
88
-     */
89
-    public function changeWithdrawStatus(bool $withdraw, ?string $withdrawDate, ?string $withdrawReason){
83
+	/**
84
+	 * Update withdraw status
85
+	 * @param bool $withdraw
86
+	 * @param string $withdrawDate
87
+	 * @param string $withdrawReason
88
+	 */
89
+	public function changeWithdrawStatus(bool $withdraw, ?string $withdrawDate, ?string $withdrawReason){
90 90
         
91
-        $insertion = $this->linkpdo->prepare('UPDATE patients
91
+		$insertion = $this->linkpdo->prepare('UPDATE patients
92 92
                                             SET withdraw = :withdraw,
93 93
                                             withdraw_date = :withdraw_date,
94 94
                                             withdraw_reason = :withdraw_reason
95 95
                                             WHERE patients.code = :patient');
96 96
         
97
-        $insertion->execute(array('withdraw'=>intval($withdraw),
98
-            'withdraw_date' => $withdrawDate,
99
-            'withdraw_reason' => $withdrawReason,
100
-            'patient' => $this->patient));
97
+		$insertion->execute(array('withdraw'=>intval($withdraw),
98
+			'withdraw_date' => $withdrawDate,
99
+			'withdraw_reason' => $withdrawReason,
100
+			'patient' => $this->patient));
101 101
         
102
-    }
102
+	}
103 103
     
104
-    /**
105
-     * Update patient data
106
-     * @param $initials
107
-     * @param $gender
108
-     * @param $birthDate
109
-     * @param $registrationDate
110
-     * @param $investigator
111
-     * @param $centerCode
112
-     */
113
-    public function editPatientDetails($initials, $gender, $birthDate, $registrationDate, $investigator, $centerCode){
114
-            $insertion = $this->linkpdo->prepare("UPDATE patients
104
+	/**
105
+	 * Update patient data
106
+	 * @param $initials
107
+	 * @param $gender
108
+	 * @param $birthDate
109
+	 * @param $registrationDate
110
+	 * @param $investigator
111
+	 * @param $centerCode
112
+	 */
113
+	public function editPatientDetails($initials, $gender, $birthDate, $registrationDate, $investigator, $centerCode){
114
+			$insertion = $this->linkpdo->prepare("UPDATE patients
115 115
                                             SET first_name = :firstName,
116 116
                                             last_name = :lastName,
117 117
                                             gender = :gender,
@@ -123,131 +123,131 @@  discard block
 block discarded – undo
123 123
                                             center=:centerCode
124 124
                                             WHERE patients.code = :patient");
125 125
             
126
-            $insertion->execute(array('firstName'=>$initials[1],
127
-                'lastName'=>$initials[0],
128
-                'gender'=>strtoupper($gender[0]),
129
-                'year'=>substr($birthDate, 0, 4),
130
-                'month'=>substr($birthDate, 5, 2),
131
-                'day'=>substr($birthDate, 8, 2),
132
-                'registrationDate' => $registrationDate,
133
-                'investigator' => $investigator,
134
-                'centerCode'=>$centerCode,
135
-                'patient' => $this->patient));
126
+			$insertion->execute(array('firstName'=>$initials[1],
127
+				'lastName'=>$initials[0],
128
+				'gender'=>strtoupper($gender[0]),
129
+				'year'=>substr($birthDate, 0, 4),
130
+				'month'=>substr($birthDate, 5, 2),
131
+				'day'=>substr($birthDate, 8, 2),
132
+				'registrationDate' => $registrationDate,
133
+				'investigator' => $investigator,
134
+				'centerCode'=>$centerCode,
135
+				'patient' => $this->patient));
136 136
        
137 137
         
138
-    }
139
-
140
-    /**
141
-     * Return visit Manage to manage patient's visit status
142
-     */
143
-    public function getPatientVisitManager(Visit_Group $visitGroupObject) {
144
-        //Look if specific patient visit manager exists for this study
145
-        $specificObjectFile=$_SERVER["DOCUMENT_ROOT"].'/data/form/'.$this->patientStudy.'/Poo/'.$this->patientStudy."_Patient_Visit_Manager.php";
138
+	}
139
+
140
+	/**
141
+	 * Return visit Manage to manage patient's visit status
142
+	 */
143
+	public function getPatientVisitManager(Visit_Group $visitGroupObject) {
144
+		//Look if specific patient visit manager exists for this study
145
+		$specificObjectFile=$_SERVER["DOCUMENT_ROOT"].'/data/form/'.$this->patientStudy.'/Poo/'.$this->patientStudy."_Patient_Visit_Manager.php";
146 146
             
147
-        if(is_file($specificObjectFile)){
148
-            require_once($specificObjectFile);
149
-            $objectName=$this->patientStudy."_Patient_Visit_Manager";
150
-            return new $objectName($this, $visitGroupObject, $this->linkpdo);
151
-        }else{
152
-            return new Patient_Visit_Manager($this, $visitGroupObject, $this->linkpdo);
153
-        }
147
+		if(is_file($specificObjectFile)){
148
+			require_once($specificObjectFile);
149
+			$objectName=$this->patientStudy."_Patient_Visit_Manager";
150
+			return new $objectName($this, $visitGroupObject, $this->linkpdo);
151
+		}else{
152
+			return new Patient_Visit_Manager($this, $visitGroupObject, $this->linkpdo);
153
+		}
154 154
 
155
-    }
155
+	}
156 156
 
157
-    private function getAllPossibleVisitGroup() : Array { 
157
+	private function getAllPossibleVisitGroup() : Array { 
158 158
 
159
-        $patientStudy=$this->getPatientStudy();
160
-        $possibleStudyGroups=$patientStudy->getAllPossibleVisitGroups();
159
+		$patientStudy=$this->getPatientStudy();
160
+		$possibleStudyGroups=$patientStudy->getAllPossibleVisitGroups();
161 161
 
162
-        return $possibleStudyGroups;
162
+		return $possibleStudyGroups;
163 163
 
164
-    }
164
+	}
165 165
 
166
-    /**
167
-     * Return visits created for this patient without group filter
168
-     */
169
-    public function getAllCreatedPatientsVisits(bool $deletedVisits = false) : Array
170
-    {
171
-        $possibleStudyGroups=$this->getAllPossibleVisitGroup();
166
+	/**
167
+	 * Return visits created for this patient without group filter
168
+	 */
169
+	public function getAllCreatedPatientsVisits(bool $deletedVisits = false) : Array
170
+	{
171
+		$possibleStudyGroups=$this->getAllPossibleVisitGroup();
172 172
 
173
-        $visitsObjectArray = [];
173
+		$visitsObjectArray = [];
174 174
 
175
-        foreach($possibleStudyGroups as $studyGroup){
176
-            $createdVisits=$this->getPatientVisitManager($studyGroup)->getCreatedPatientsVisits($deletedVisits);
177
-            array_push($visitsObjectArray, ...$createdVisits);
178
-        }
175
+		foreach($possibleStudyGroups as $studyGroup){
176
+			$createdVisits=$this->getPatientVisitManager($studyGroup)->getCreatedPatientsVisits($deletedVisits);
177
+			array_push($visitsObjectArray, ...$createdVisits);
178
+		}
179 179
 
180
-        return $visitsObjectArray;
181
-    }
180
+		return $visitsObjectArray;
181
+	}
182 182
 
183 183
 
184
-     /**
185
-     * Return visits uploaded for this patient without group filter
186
-     */
187
-    public function getAllQcDonePatientsVisits(bool $deletedVisits = false) : Array
188
-    {
189
-        $possibleStudyGroups=$this->getAllPossibleVisitGroup();
184
+	 /**
185
+	  * Return visits uploaded for this patient without group filter
186
+	  */
187
+	public function getAllQcDonePatientsVisits(bool $deletedVisits = false) : Array
188
+	{
189
+		$possibleStudyGroups=$this->getAllPossibleVisitGroup();
190 190
 
191
-        $visitsObjectArray = [];
191
+		$visitsObjectArray = [];
192 192
 
193
-        foreach($possibleStudyGroups as $studyGroup){
194
-            $createdVisits=$this->getPatientVisitManager($studyGroup)->getQcDonePatientsVisits($deletedVisits);
195
-            array_push($visitsObjectArray, ...$createdVisits);
196
-        }
193
+		foreach($possibleStudyGroups as $studyGroup){
194
+			$createdVisits=$this->getPatientVisitManager($studyGroup)->getQcDonePatientsVisits($deletedVisits);
195
+			array_push($visitsObjectArray, ...$createdVisits);
196
+		}
197 197
 
198
-        return $visitsObjectArray;
199
-    }
198
+		return $visitsObjectArray;
199
+	}
200 200
 
201
-    public function getAllVisitToCreate() : array {
201
+	public function getAllVisitToCreate() : array {
202 202
 
203
-        $possiblevisitsGroups=$this->getAllPossibleVisitGroup();
203
+		$possiblevisitsGroups=$this->getAllPossibleVisitGroup();
204 204
 
205
-        $visitsObjectArray = [];
205
+		$visitsObjectArray = [];
206 206
 
207
-        foreach($possiblevisitsGroups as $visitGroup){
208
-            try{
209
-                $availableVisits=$this->getPatientVisitManager($visitGroup)->getAvailableVisitsToCreate();
210
-            }catch (Exception $e){
211
-                $availableVisits=array($e->getMessage());
212
-            }
207
+		foreach($possiblevisitsGroups as $visitGroup){
208
+			try{
209
+				$availableVisits=$this->getPatientVisitManager($visitGroup)->getAvailableVisitsToCreate();
210
+			}catch (Exception $e){
211
+				$availableVisits=array($e->getMessage());
212
+			}
213 213
 
214
-            $visitsObjectArray [$visitGroup->groupModality]['visitsName'] = $availableVisits;
215
-            $visitsObjectArray [$visitGroup->groupModality]['groupId'] = $visitGroup->groupId;
216
-        }
214
+			$visitsObjectArray [$visitGroup->groupModality]['visitsName'] = $availableVisits;
215
+			$visitsObjectArray [$visitGroup->groupModality]['groupId'] = $visitGroup->groupId;
216
+		}
217 217
 
218
-        return $visitsObjectArray;
218
+		return $visitsObjectArray;
219 219
 
220
-    }
220
+	}
221 221
 
222
-    public function isMissingVisit(){
222
+	public function isMissingVisit(){
223 223
 
224
-        $modalitiesMissingVisits=$this->getMissingVisitModalities();
224
+		$modalitiesMissingVisits=$this->getMissingVisitModalities();
225 225
 
226
-        $isMissingSomeVisits= ( sizeof($modalitiesMissingVisits) > 0 ) ;
226
+		$isMissingSomeVisits= ( sizeof($modalitiesMissingVisits) > 0 ) ;
227 227
 
228
-        return $isMissingSomeVisits ; 
228
+		return $isMissingSomeVisits ; 
229 229
 
230
-    }
230
+	}
231 231
 
232
-    public function getMissingVisitModalities(){
232
+	public function getMissingVisitModalities(){
233 233
 
234
-        $possiblevisitsGroups=$this->getAllPossibleVisitGroup();
234
+		$possiblevisitsGroups=$this->getAllPossibleVisitGroup();
235 235
 
236
-        $visitsMissingGroupsArray = [];
236
+		$visitsMissingGroupsArray = [];
237 237
 
238
-        foreach($possiblevisitsGroups as $visitGroup){
239
-            $missingVisit=$this->getPatientVisitManager($visitGroup)->isMissingVisit();
240
-            if($missingVisit){
241
-                $visitsMissingGroupsArray[]=$visitGroup->groupModality;
242
-            }
243
-        }
238
+		foreach($possiblevisitsGroups as $visitGroup){
239
+			$missingVisit=$this->getPatientVisitManager($visitGroup)->isMissingVisit();
240
+			if($missingVisit){
241
+				$visitsMissingGroupsArray[]=$visitGroup->groupModality;
242
+			}
243
+		}
244 244
 
245
-        return $visitsMissingGroupsArray;
245
+		return $visitsMissingGroupsArray;
246 246
 
247
-    }
247
+	}
248 248
 
249
-    public function getPatientStudy() : Study {
250
-        return new Study($this->patientStudy, $this->linkpdo);
251
-    }
249
+	public function getPatientStudy() : Study {
250
+		return new Study($this->patientStudy, $this->linkpdo);
251
+	}
252 252
       
253 253
 }
254 254
\ No newline at end of file
Please login to merge, or discard this patch.
src/models/Orthanc_Patient.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	
33 33
 	
34 34
 	public function __construct($patientOrthancID, $url, $context){
35
-	    //Set orthanc address
36
-	    $this->url=$url;
37
-	    $this->context = $context;
38
-	    //Set current patient Orthanc ID
35
+		//Set orthanc address
36
+		$this->url=$url;
37
+		$this->context = $context;
38
+		//Set current patient Orthanc ID
39 39
 		$this->patientOrthancID=$patientOrthancID;
40 40
 	}
41 41
 	
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * Get and store the main tags of the patient level
44 44
 	 */
45 45
 	public function retrievePatientData(){
46
-	    $context  = stream_context_create($this->context);
47
-	    $json = file_get_contents($this->url.'/patients/'.$this->patientOrthancID, false, $context);
46
+		$context  = stream_context_create($this->context);
47
+		$json = file_get_contents($this->url.'/patients/'.$this->patientOrthancID, false, $context);
48 48
 		$patientJson=json_decode($json, true);
49 49
 		//Add needed informations in this object
50 50
 		$this->patientName=$patientJson['MainDicomTags']['PatientName'];
Please login to merge, or discard this patch.
src/models/Visit_Type.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -18,108 +18,108 @@
 block discarded – undo
18 18
  */
19 19
 Class Visit_Type{
20 20
     
21
-    public $id;
22
-    public $groupId;
23
-    public $name;
24
-    public $tableReviewSpecificName;
25
-    public $visitOrder;
26
-    public $localFormNeeded;
27
-    public $qcNeeded;
28
-    public $reviewNeeded;
29
-    public $optionalVisit;
30
-    public $limitLowDays;
31
-    public $limitUpDays;
32
-    public $anonProfile;
21
+	public $id;
22
+	public $groupId;
23
+	public $name;
24
+	public $tableReviewSpecificName;
25
+	public $visitOrder;
26
+	public $localFormNeeded;
27
+	public $qcNeeded;
28
+	public $reviewNeeded;
29
+	public $optionalVisit;
30
+	public $limitLowDays;
31
+	public $limitUpDays;
32
+	public $anonProfile;
33 33
 
34
-    public $linkpdo;
34
+	public $linkpdo;
35 35
     
36
-    public function __construct(PDO $linkpdo, int $visitTypeId){
36
+	public function __construct(PDO $linkpdo, int $visitTypeId){
37 37
         
38
-        $this->linkpdo=$linkpdo;
39
-        $visitTypeQuery = $this->linkpdo->prepare('SELECT * FROM visit_type WHERE id = :visitTypeId');
40
-        $visitTypeQuery->execute(array('visitTypeId' => $visitTypeId));
41
-        $visitType=$visitTypeQuery->fetch(PDO::FETCH_ASSOC);
38
+		$this->linkpdo=$linkpdo;
39
+		$visitTypeQuery = $this->linkpdo->prepare('SELECT * FROM visit_type WHERE id = :visitTypeId');
40
+		$visitTypeQuery->execute(array('visitTypeId' => $visitTypeId));
41
+		$visitType=$visitTypeQuery->fetch(PDO::FETCH_ASSOC);
42 42
 
43
-        $this->id=$visitType['id'];
44
-        $this->groupId=$visitType['group_id'];
45
-        $this->name=$visitType['name'];
46
-        $this->tableReviewSpecificName=$visitType['table_review_specific'];
47
-        $this->visitOrder=$visitType['visit_order'];
48
-        $this->localFormNeeded=$visitType['local_form_needed'];
49
-        $this->qcNeeded=$visitType['qc_needed'];
50
-        $this->reviewNeeded=$visitType['review_needed'];
51
-        $this->optionalVisit=$visitType['optional'];
52
-        $this->limitLowDays=$visitType['limit_low_days'];
53
-        $this->limitUpDays=$visitType['limit_up_days'];
54
-        $this->anonProfile=$visitType['anon_profile'];
43
+		$this->id=$visitType['id'];
44
+		$this->groupId=$visitType['group_id'];
45
+		$this->name=$visitType['name'];
46
+		$this->tableReviewSpecificName=$visitType['table_review_specific'];
47
+		$this->visitOrder=$visitType['visit_order'];
48
+		$this->localFormNeeded=$visitType['local_form_needed'];
49
+		$this->qcNeeded=$visitType['qc_needed'];
50
+		$this->reviewNeeded=$visitType['review_needed'];
51
+		$this->optionalVisit=$visitType['optional'];
52
+		$this->limitLowDays=$visitType['limit_low_days'];
53
+		$this->limitUpDays=$visitType['limit_up_days'];
54
+		$this->anonProfile=$visitType['anon_profile'];
55 55
         
56
-    }
56
+	}
57 57
 
58
-    public static function getVisitTypeByName($groupId, String $visitName,PDO $linkpdo) : Visit_Type {
59
-        $visitTypeQuery = $linkpdo->prepare('SELECT id FROM visit_type WHERE group_id = :groupId AND name= :name');
60
-        $visitTypeQuery->execute(array('groupId' => $groupId, 'name'=>$visitName));
61
-        $visitTypeId=$visitTypeQuery->fetch(PDO::FETCH_COLUMN);
62
-        return new Visit_Type($linkpdo, $visitTypeId);
58
+	public static function getVisitTypeByName($groupId, String $visitName,PDO $linkpdo) : Visit_Type {
59
+		$visitTypeQuery = $linkpdo->prepare('SELECT id FROM visit_type WHERE group_id = :groupId AND name= :name');
60
+		$visitTypeQuery->execute(array('groupId' => $groupId, 'name'=>$visitName));
61
+		$visitTypeId=$visitTypeQuery->fetch(PDO::FETCH_COLUMN);
62
+		return new Visit_Type($linkpdo, $visitTypeId);
63 63
 
64
-    }
64
+	}
65 65
     
66
-    /**
67
-     * Return name of specific table of this visit type
68
-     * @return array
69
-     */
70
-    public function getSpecificFormColumn() : Array {
71
-        $visitsTypeColumnQuery=$this->linkpdo->prepare('SELECT `COLUMN_NAME`
66
+	/**
67
+	 * Return name of specific table of this visit type
68
+	 * @return array
69
+	 */
70
+	public function getSpecificFormColumn() : Array {
71
+		$visitsTypeColumnQuery=$this->linkpdo->prepare('SELECT `COLUMN_NAME`
72 72
                                             FROM `INFORMATION_SCHEMA`.`COLUMNS`
73 73
                                             WHERE  `TABLE_NAME`="'.$this->tableReviewSpecificName.'"');
74
-        $visitsTypeColumnQuery->execute();
75
-        $columnsSpecific=$visitsTypeColumnQuery->fetchAll(PDO::FETCH_COLUMN);
74
+		$visitsTypeColumnQuery->execute();
75
+		$columnsSpecific=$visitsTypeColumnQuery->fetchAll(PDO::FETCH_COLUMN);
76 76
         
77
-        return $columnsSpecific;
78
-    }
77
+		return $columnsSpecific;
78
+	}
79 79
     
80
-    /**
81
-     * Return name and type of the specific table of this visit
82
-     * @return array
83
-     */
84
-    public function getSpecificTableInputType() : Array {
85
-        $query = $this->linkpdo->prepare('SELECT COLUMN_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME="'.$this->tableReviewSpecificName.'"');
86
-        $query->execute();
87
-        $datas=$query->fetchAll(PDO::FETCH_ASSOC);
80
+	/**
81
+	 * Return name and type of the specific table of this visit
82
+	 * @return array
83
+	 */
84
+	public function getSpecificTableInputType() : Array {
85
+		$query = $this->linkpdo->prepare('SELECT COLUMN_NAME, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME="'.$this->tableReviewSpecificName.'"');
86
+		$query->execute();
87
+		$datas=$query->fetchAll(PDO::FETCH_ASSOC);
88 88
         
89
-        return $datas;
89
+		return $datas;
90 90
         
91
-    }
91
+	}
92 92
 
93
-    public function getVisitGroup() : Visit_Group{
94
-        return new Visit_Group($this->linkpdo, $this->groupId);
95
-    }
93
+	public function getVisitGroup() : Visit_Group{
94
+		return new Visit_Group($this->linkpdo, $this->groupId);
95
+	}
96 96
     
97
-    public static function createVisitType(string $studyName, Visit_Group $visitGroup, String $visitName, int $order, int $limitLowDays, int $limitUpDays, bool $localFormNeed, bool $qcNeeded, bool $reviewNeeded, bool $optional, String $anonProfile, PDO $linkpdo){
97
+	public static function createVisitType(string $studyName, Visit_Group $visitGroup, String $visitName, int $order, int $limitLowDays, int $limitUpDays, bool $localFormNeed, bool $qcNeeded, bool $reviewNeeded, bool $optional, String $anonProfile, PDO $linkpdo){
98 98
         
99
-        $req = $linkpdo->prepare('INSERT INTO visit_type (group_id, name, table_review_specific, visit_order, local_form_needed, qc_needed, review_needed, optional, limit_low_days, limit_up_days, anon_profile)
99
+		$req = $linkpdo->prepare('INSERT INTO visit_type (group_id, name, table_review_specific, visit_order, local_form_needed, qc_needed, review_needed, optional, limit_low_days, limit_up_days, anon_profile)
100 100
                                       VALUES(:groupId, :visitName, :tableSpecific, :order, :localFormNeeded, :qcNeeded, :reviewNeeded, :optional, :limitLowDays, :limitUpDays, :anonProfile)');
101 101
         
102
-        $tableSpecificName=$visitGroup->groupModality."_".$studyName."_".$visitName;
102
+		$tableSpecificName=$visitGroup->groupModality."_".$studyName."_".$visitName;
103 103
 
104
-        $req->execute(array('groupId' => $visitGroup->groupId,
105
-            'visitName'=>$visitName,
106
-            'tableSpecific'=>$tableSpecificName,
107
-            'order'=>intval($order),
108
-            'localFormNeeded'=>intval($localFormNeed),
109
-            'qcNeeded'=>intval($qcNeeded),
110
-            'reviewNeeded'=>intval($reviewNeeded),
111
-            'optional'=>intval($optional),
112
-            'limitLowDays'=>intval($limitLowDays),
113
-            'limitUpDays'=>intval($limitUpDays),
114
-            'anonProfile'=>$anonProfile
115
-        ));
104
+		$req->execute(array('groupId' => $visitGroup->groupId,
105
+			'visitName'=>$visitName,
106
+			'tableSpecific'=>$tableSpecificName,
107
+			'order'=>intval($order),
108
+			'localFormNeeded'=>intval($localFormNeed),
109
+			'qcNeeded'=>intval($qcNeeded),
110
+			'reviewNeeded'=>intval($reviewNeeded),
111
+			'optional'=>intval($optional),
112
+			'limitLowDays'=>intval($limitLowDays),
113
+			'limitUpDays'=>intval($limitUpDays),
114
+			'anonProfile'=>$anonProfile
115
+		));
116 116
         
117
-        //Create specific table of the visit for form with relation with the review table
118
-        $req = $linkpdo->prepare(' CREATE TABLE '.$tableSpecificName.' (id_review integer(11) NOT NULL, PRIMARY KEY (id_review));
117
+		//Create specific table of the visit for form with relation with the review table
118
+		$req = $linkpdo->prepare(' CREATE TABLE '.$tableSpecificName.' (id_review integer(11) NOT NULL, PRIMARY KEY (id_review));
119 119
             ALTER TABLE '.$tableSpecificName.' ADD FOREIGN KEY fk_idReview (id_review) REFERENCES reviews(id_review);
120 120
             ALTER TABLE '.$tableSpecificName.' ADD PRIMARY KEY (`id_review`); ');
121 121
         
122
-        $req->execute();
123
-    }
122
+		$req->execute();
123
+	}
124 124
     
125 125
 }
126 126
\ No newline at end of file
Please login to merge, or discard this patch.
src/models/Orthanc_Serie.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 
51 51
 	
52 52
 	public function __construct($seriesOrthancID, $url, $context) {
53
-	    //Set Orthanc http address
54
-	    $this->url=$url;
55
-	    $this->context = $context;
53
+		//Set Orthanc http address
54
+		$this->url=$url;
55
+		$this->context = $context;
56 56
 	    
57 57
 		//Set the current serie's Orthanc ID
58 58
 		$this->serieOrthancID=$seriesOrthancID;
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 	 *Get Series related data and store them in this object
63 63
 	 */
64 64
 	public function retrieveSeriesData(){
65
-	    $context  = stream_context_create($this->context);
66
-	    //Store all shared tags
67
-	    $this->sharedTags = json_decode(file_get_contents($this->url.'/series/'.$this->serieOrthancID.'/shared-tags', false, $context));
65
+		$context  = stream_context_create($this->context);
66
+		//Store all shared tags
67
+		$this->sharedTags = json_decode(file_get_contents($this->url.'/series/'.$this->serieOrthancID.'/shared-tags', false, $context));
68 68
 		//parse main series informations
69
-	    $json = file_get_contents($this->url.'/series/'.$this->serieOrthancID, false, $context);
69
+		$json = file_get_contents($this->url.'/series/'.$this->serieOrthancID, false, $context);
70 70
 		$seriesJson=json_decode($json, true);
71 71
 		//add needed informations in the current object
72 72
 		$this->seriesManufacturer=$seriesJson['MainDicomTags']['Manufacturer'];
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 	 * Get statistics of the series (size in MB)
95 95
 	 */
96 96
 	private function retrieveSeriesStatistics(){
97
-	    $context  = stream_context_create($this->context);
98
-	    $json = file_get_contents($this->url.'/series/'.$this->serieOrthancID.'/statistics/', false, $context);
99
-	    $statisticsJson=json_decode($json, true);
100
-	    $this->diskSizeMb=$statisticsJson['DiskSizeMB'];
101
-	    $this->uncompressedSizeMb=$statisticsJson['UncompressedSizeMB'];
97
+		$context  = stream_context_create($this->context);
98
+		$json = file_get_contents($this->url.'/series/'.$this->serieOrthancID.'/statistics/', false, $context);
99
+		$statisticsJson=json_decode($json, true);
100
+		$this->diskSizeMb=$statisticsJson['DiskSizeMB'];
101
+		$this->uncompressedSizeMb=$statisticsJson['UncompressedSizeMB'];
102 102
 	    
103 103
 	}
104 104
 	
@@ -107,19 +107,19 @@  discard block
 block discarded – undo
107 107
 	 * @param $instanceID
108 108
 	 */
109 109
 	private function retrieveInstancesData($instanceID){
110
-	    $context  = stream_context_create($this->context);
111
-	    $json = file_get_contents($this->url.'/instances/'.$instanceID.'/tags/', false, $context);
112
-	    $instanceJson=json_decode($json, true);
113
-	    $this->patientWeight=$instanceJson['0010,1030']['Value'];
114
-	    $this->seriesModelName=$instanceJson['0008,1090']['Value'];
115
-	    $this->injectedDose=$instanceJson['0054,0016']['Value'][0]['0018,1074']['Value'];
116
-	    //SK InjectedTime est deprecie en faveur de DateTime, A surveiller pour la suite
117
-	    $this->injectedTime=$instanceJson['0054,0016']['Value'][0]['0018,1072']['Value'] ;
118
-	    $this->injectedDateTime=$instanceJson['0054,0016']['Value'][0]['0018,1078']['Value'] ;
119
-	    $this->injectedActivity=$instanceJson['0054,0016']['Value'][0]['0018,1077']['Value'];
120
-	    $this->radiopharmaceutical=$instanceJson['0054,0016']['Value'][0]['0018,0031']['Value'];
121
-	    $this->halfLife=$instanceJson['0054,0016']['Value'][0]['0018,1075']['Value'];
122
-	    $this->sopClassUid=$instanceJson['0008,0016']['Value'];
110
+		$context  = stream_context_create($this->context);
111
+		$json = file_get_contents($this->url.'/instances/'.$instanceID.'/tags/', false, $context);
112
+		$instanceJson=json_decode($json, true);
113
+		$this->patientWeight=$instanceJson['0010,1030']['Value'];
114
+		$this->seriesModelName=$instanceJson['0008,1090']['Value'];
115
+		$this->injectedDose=$instanceJson['0054,0016']['Value'][0]['0018,1074']['Value'];
116
+		//SK InjectedTime est deprecie en faveur de DateTime, A surveiller pour la suite
117
+		$this->injectedTime=$instanceJson['0054,0016']['Value'][0]['0018,1072']['Value'] ;
118
+		$this->injectedDateTime=$instanceJson['0054,0016']['Value'][0]['0018,1078']['Value'] ;
119
+		$this->injectedActivity=$instanceJson['0054,0016']['Value'][0]['0018,1077']['Value'];
120
+		$this->radiopharmaceutical=$instanceJson['0054,0016']['Value'][0]['0018,0031']['Value'];
121
+		$this->halfLife=$instanceJson['0054,0016']['Value'][0]['0018,1075']['Value'];
122
+		$this->sopClassUid=$instanceJson['0008,0016']['Value'];
123 123
 	}
124 124
 	
125 125
 	/**
Please login to merge, or discard this patch.
src/models/Visit_Group.php 1 patch
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.
src/models/Session.php 1 patch
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.