Completed
Push — master ( 17af13...acdc2b )
by Andrzej
02:44
created

PatientRaport   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 190
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 17
c 4
b 0
f 0
lcom 0
cbo 4
dl 0
loc 190
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getRaport() 0 6 1
B getQuery() 0 27 2
A getRaportBetweenDates() 0 16 3
A getColumns() 0 50 2
A getIndexes() 0 20 2
C getTpb() 0 45 7
1
<?php
2
3
namespace Hospitalplugin\Entities;
4
5
use Hospitalplugin\DB\DoctrineBootstrap;
6
use Hospitalplugin\utils\Utils;
7
use Doctrine\DBAL\Schema\View;
8
use Doctrine\ORM\Query\ResultSetMapping;
9
10
class PatientRaport {
11
	/**
12
	 *
13
	 * @param unknown $wardId        	
14
	 * @param unknown $date        	
15
	 */
16
	public static function getRaport($wardId, $date, $wardType) {
17
		$startDate = $date . '-01';
18
		$endDate = date ( "Y-m-t 23:59:59", strtotime ( $startDate ) );
19
		
20
		return PatientRaport::getRaportBetweenDates ( $wardId, $wardType, $startDate, $endDate );
0 ignored issues
show
Documentation introduced by
$startDate is of type string, but the function expects a object<Hospitalplugin\Entities\unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$endDate is of type string, but the function expects a object<Hospitalplugin\Entities\unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
	}
22
	private static function getQuery($type) {
23
		if ($type == 'POR') {
24
			// poród zabiegowy
25
			$dql1 = "  SELECT p.kategoriaPacjenta + 3 as kategoria, DATE(p.dataKategoryzacji) as data, COUNT(p.kategoriaPacjenta) as suma ";
26
			$dql1 .= " FROM Hospitalplugin\Entities\PatientPOR p ";
27
			$dql1 .= " WHERE p.dataKategoryzacji BETWEEN ?1 AND ?2 AND p.oddzialId = ?3 AND p.iICzas = 3";
28
			$dql1 .= " GROUP BY data, p.kategoriaPacjenta";
29
			// poród siłami natury
30
			$dql2 = "  SELECT p.kategoriaPacjenta as kategoria, DATE(p.dataKategoryzacji) as data, COUNT(p.kategoriaPacjenta) as suma ";
31
			$dql2 .= " FROM Hospitalplugin\Entities\PatientPOR p ";
32
			$dql2 .= " WHERE p.dataKategoryzacji BETWEEN ?1 AND ?2 AND p.oddzialId = ?3 AND (p.iICzas <> 3 OR p.iICzas IS NULL)";
33
			$dql2 .= " GROUP BY data, p.kategoriaPacjenta";
34
			return array (
35
					$dql1,
36
					$dql2 
37
			);
38
		} else {
39
			// pozostałe typy
40
			$dql = "  SELECT p.kategoriaPacjenta as kategoria, DATE(p.dataKategoryzacji) as data, COUNT(p.kategoriaPacjenta) as suma ";
41
			$dql .= " FROM Hospitalplugin\Entities\Patient p ";
42
			$dql .= " WHERE p.dataKategoryzacji BETWEEN ?1 AND ?2 AND p.oddzialId = ?3";
43
			$dql .= " GROUP BY data, p.kategoriaPacjenta";
44
			return array (
45
					$dql 
46
			);
47
		}
48
	}
49
	/**
50
	 *
51
	 * @param unknown $wardId        	
52
	 * @param unknown $type        	
53
	 * @param unknown $startDate        	
54
	 * @param unknown $endDate        	
55
	 * @return array
56
	 */
57
	public static function getRaportBetweenDates($wardId, $type, $startDate, $endDate) {
58
		$em = DoctrineBootstrap::getEntityManager ();
59
		$em->getConfiguration ()->addCustomDatetimeFunction ( 'DATE', 'Hospitalplugin\DQLFunctions\DateFunction' );
60
		$dql = PatientRaport::getQuery ( $type );
61
		$allResults = array ();
62
		foreach ( $dql as $query ) {
63
			$result = $em->createQuery ( $query )->setParameter ( 1, $startDate )->setParameter ( 2, $endDate )->setParameter ( 3, $wardId )->getResult ();
64
			$allResults = array_merge ( $result, $allResults );
65
		}
66
		
67
		$table = array ();
68
		foreach ( $allResults as $row ) {
69
			$table [$row ['data']] [$row ['kategoria']] = $row ['suma'];
70
		}
71
		return $table;
72
	}
73
	/**
74
	 * @param unknown $type
75
	 */
76
	static function getColumns($type) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
77
		if ($type == 'POR') {
78
			return array (
79
					'N1 naturalny',
80
					'N2 naturalny',
81
					'N3 naturalny',
82
					'N1 zabiegowy',
83
					'N2 zabiegowy',
84
					'N3 zabiegowy',
85
					'brak kat.',
86
					'N',
87
					'Tpb1',
88
					'Tpb2',
89
					'Tpb3',
90
					'Tpb1z',
91
					'Tpb2z',
92
					'Tpb3z',
93
					'Tpb0',
94
					'2',
95
					'Tpb1*N1',
96
					'Tpb2*N2',
97
					'Tpb3*N3',
98
					'Tpb1z*N1z',
99
					'Tpb2z*N2z',
100
					'Tpb3z*N3z',
101
					'Tpb0',
102
					'2*N',
103
					'Tpb/dzień'
104
			);
105
		} else {
106
			return array (
107
					'N1',
108
					'N2',
109
					'N3',
110
					'brak kat.',
111
					'N',
112
					'Tpb1',
113
					'Tpb2',
114
					'Tpb3',
115
					'Tpb0',
116
					'2',
117
					'Tpb1*N1',
118
					'Tpb2*N2',
119
					'Tpb3*N3',
120
					'Tpb0',
121
					'2*N',
122
					'Tpb/dzień'
123
			);
124
		}
125
	}
126
	static function getIndexes($type) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
127
		if ($type == 'POR') {
128
			return array (
129
					'1',
130
					'2',
131
					'3',
132
					'4',
133
					'5',
134
					'6',
135
					'0'
136
			);
137
		} else {
138
			return array (
139
					'1',
140
					'2',
141
					'3',
142
					'0'
143
			);
144
		}
145
	}
146
	/**
147
	 * based on
148
	 * Zalecenie Konsultanta Krajowego w dz.
149
	 * pielęgniarstwa w sprawie realizacji przepisów rozporządzenia Ministra Zdrowia z dnia 28 grudnia 2012 roku w sprawie sposobu ustalenia minimalnych norm zatrudnienia pielęgniarek i położnych w podmiotach leczniczych niebędących przedsiębiorcami.
150
	 * http://www.nipip.pl/index.php/prawo/opiniekk/w-dz-pielegniarstwa/konsultant-krajowy-dr-hab-n-hum-maria-kozka/2265-zalecenie-konsultanta-krajowego-w-dz-pielegniarstwa-w-sprawie-realizacji-przepisow-rozporzadzenia-ministra-zdrowia-z-dnia-28-grudnia-2012-roku-w-sprawie-sposobu-ustalenia-minimalnych-norm-zatrudnienia-pielegniarek-i-poloznych-w-podmiotach-leczniczych-nieb
151
	 *
152
	 * @param unknown $type
153
	 */
154
	static function getTpb($type) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
155
		if ($type == 'ZZ' || $type == 'PED') {
156
			return array (
157
					38,
158
					95,
159
					159,
160
					0,
161
					2
162
			);
163
		} else if ($type == 'PSY') {
164
			return array (
165
					40,
166
					100,
167
					160,
168
					0,
169
					2
170
			);
171
		} else if ($type == 'POR') {
172
			return array (
173
					137,
174
					274,
175
					328,
176
					53,
177
					53,
178
					120,
179
					0,
180
					2
181
			);
182
		} else if ($type == 'DIA') {
183
			return array (
184
					52,
185
					112,
186
					0,
187
					2
188
			);
189
		} else if ($type == 'POL') {
190
			return array (
191
					72,
192
					100,
193
					98,
194
					0,
195
					2
196
			);
197
		}
198
	}
199
}