InfectionsCRUD::getInfections()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 2
eloc 17
nc 2
nop 4
1
<?php
2
3
/**
4
 * PatientCRUD
5
 *
6
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
7
 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
8
 *
9
 * Permission is hereby granted to use or copy this program
10
 * for any purpose, provided the above notices are retained on all copies.
11
 * Permission to modify the code and to distribute modified code is granted,
12
 * provided the above notices are retained, and a notice that the code was
13
 * modified is included with the above copyright notice.
14
 *
15
 * @category  Wp
16
 * @package   Punction
17
 * @author    Andrzej Marcinkowski <[email protected]>
18
 * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz
19
 * @license   MIT http://opensource.org/licenses/MIT
20
 * @version   1.0 $Format:%H$
21
 * @link      http://
22
 * @since     File available since Release 1.0.0
23
 * PHP Version 5
24
 */
25
namespace Hospitalplugin\Entities;
26
27
use Hospitalplugin\DB\DoctrineBootstrap;
28
use Hospitalplugin\utils\Utils;
29
30
class InfectionsCRUD {
31
	public static function getInfections($from, $to, $wardId, $class) {
32
		$em = ( object ) DoctrineBootstrap::getEntityManager ();
33
		$qb = $em->createQueryBuilder ();
34
		$qb->select ( 'i' )->from ( 'Hospitalplugin\Entities\\' . $class, 'i' ) /* */
35
        ->addOrderBy ( 'i.dataRaportu', 'DESC' ) /* */
36
        ->addOrderBy ( 'i.dataPrzeslania ', 'DESC' ) /* */
37
        ->where ( /* */
38
        		$qb->expr ()->between ( 'i.dataRaportu', ':from', ':to' ) ) /* */
39
        		->setParameters ( array (
40
				'from' => $from,
41
				'to' => $to 
42
		) );
43
		if ($wardId != 'all') {
44
			$qb->andWhere ( $qb->expr ()->eq ( 'i.ward', ':ward' ) ) /* */
45
        			->setParameter ( 'ward', $wardId );
46
		}
47
		
48
		$query = $qb->getQuery ();
49
		$infections = $query->getResult ();
50
		
51
		return $infections;
52
	}
53
	public static function updateVerification($id, $weryfikacja) {
54
		if ($id != null && $weryfikacja != null) {
55
			$em = ( object ) DoctrineBootstrap::getEntityManager ();
56
			$infection = $em->getRepository ( 'Hospitalplugin\Entities\Infections' )->find ( $id );
57
			$infection->setWeryfikacja ( $weryfikacja );
58
			$em->flush ();
59
		}
60
	}
61
	public static function obj2DB($obj) {
62
		$id = $obj->id;
63
		$em = DoctrineBootstrap::getEntityManager();
64
		$infection = $em->getRepository('Hospitalplugin\Entities\Infections')->find($id);
65
		$infection->setWeryfikacja($obj->value);
66
		$em->persist($infection);
67
		$em->flush();
68
		echo $id;
69
	}
70
}
71
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...