@@ -25,8 +25,6 @@ |
||
| 25 | 25 | namespace Hospitalplugin\Entities; |
| 26 | 26 | |
| 27 | 27 | use Hospitalplugin\DB\DoctrineBootstrap; |
| 28 | -use Hospitalplugin\utils\Utils; |
|
| 29 | -use Hospitalplugin\Twig\EscapePLCharsExtension; |
|
| 30 | 28 | use Hospitalplugin\Entities\WardCRUD; |
| 31 | 29 | use Hospitalplugin\Twig\PLTwig; |
| 32 | 30 | |
@@ -33,27 +33,27 @@ |
||
| 33 | 33 | class HospitalForm { |
| 34 | 34 | public static function load($yaml, $class, $dir) { |
| 35 | 35 | try { |
| 36 | - $em = DoctrineBootstrap::getEntityManager (); |
|
| 36 | + $em = DoctrineBootstrap::getEntityManager(); |
|
| 37 | 37 | |
| 38 | - $userId = $userId = wp_get_current_user ()->ID; |
|
| 39 | - $ward = WardCRUD::getWardForUser ( $userId ); |
|
| 40 | - $user = $em->find ( "\Hospitalplugin\Entities\User", $userId ); |
|
| 38 | + $userId = $userId = wp_get_current_user()->ID; |
|
| 39 | + $ward = WardCRUD::getWardForUser($userId); |
|
| 40 | + $user = $em->find("\Hospitalplugin\Entities\User", $userId); |
|
| 41 | 41 | |
| 42 | - if (! empty ( $_POST )) { |
|
| 42 | + if (!empty ($_POST)) { |
|
| 43 | 43 | $args = $_POST; |
| 44 | - $i = new $class ( $args ); |
|
| 45 | - $i->setWard ( $ward ); |
|
| 46 | - $i->setUser ( $user ); |
|
| 47 | - $em->persist ( $i ); |
|
| 48 | - $em->flush (); |
|
| 44 | + $i = new $class($args); |
|
| 45 | + $i->setWard($ward); |
|
| 46 | + $i->setUser($user); |
|
| 47 | + $em->persist($i); |
|
| 48 | + $em->flush(); |
|
| 49 | 49 | } else { |
| 50 | - $object = \Hospitalplugin\utils\YAML2Object::getObject ( $yaml ); |
|
| 51 | - echo PLTwig::load ( $dir )->render ( 'form.twig', array ( |
|
| 50 | + $object = \Hospitalplugin\utils\YAML2Object::getObject($yaml); |
|
| 51 | + echo PLTwig::load($dir)->render('form.twig', array( |
|
| 52 | 52 | 'infections' => $object |
| 53 | - ) ); |
|
| 53 | + )); |
|
| 54 | 54 | } |
| 55 | - } catch ( Exception $e ) { |
|
| 56 | - echo "ERR: " . $e; |
|
| 55 | + } catch (Exception $e) { |
|
| 56 | + echo "ERR: ".$e; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -25,7 +25,6 @@ |
||
| 25 | 25 | namespace Hospitalplugin\Entities; |
| 26 | 26 | |
| 27 | 27 | use Hospitalplugin\DB\DoctrineBootstrap; |
| 28 | -use Hospitalplugin\utils\Utils; |
|
| 29 | 28 | |
| 30 | 29 | class InfectionsCRUD { |
| 31 | 30 | public static function getInfections($from, $to, $wardId, $class) { |
@@ -29,33 +29,33 @@ |
||
| 29 | 29 | |
| 30 | 30 | class InfectionsCRUD { |
| 31 | 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 ( |
|
| 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 | 40 | 'from' => $from, |
| 41 | 41 | 'to' => $to |
| 42 | - ) ); |
|
| 42 | + )); |
|
| 43 | 43 | if ($wardId != 'all') { |
| 44 | - $qb->andWhere ( $qb->expr ()->eq ( 'i.ward', ':ward' ) ) /* */ |
|
| 45 | - ->setParameter ( 'ward', $wardId ); |
|
| 44 | + $qb->andWhere($qb->expr()->eq('i.ward', ':ward')) /* */ |
|
| 45 | + ->setParameter('ward', $wardId); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $query = $qb->getQuery (); |
|
| 49 | - $infections = $query->getResult (); |
|
| 48 | + $query = $qb->getQuery(); |
|
| 49 | + $infections = $query->getResult(); |
|
| 50 | 50 | |
| 51 | 51 | return $infections; |
| 52 | 52 | } |
| 53 | 53 | public static function updateVerification($id, $weryfikacja) { |
| 54 | 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 (); |
|
| 55 | + $em = (object) DoctrineBootstrap::getEntityManager(); |
|
| 56 | + $infection = $em->getRepository('Hospitalplugin\Entities\Infections')->find($id); |
|
| 57 | + $infection->setWeryfikacja($weryfikacja); |
|
| 58 | + $em->flush(); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | public static function obj2DB($obj) { |
@@ -27,7 +27,6 @@ |
||
| 27 | 27 | use Hospitalplugin\DB\DoctrineBootstrap; |
| 28 | 28 | use Hospitalplugin\Entities\Patient; |
| 29 | 29 | use Hospitalplugin\Entities\PatientDeleted; |
| 30 | -use Hospitalplugin\Entities\PatientFactory; |
|
| 31 | 30 | use Hospitalplugin\utils\Utils; |
| 32 | 31 | |
| 33 | 32 | class PatientCRUD { |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return Patient array |
| 44 | 44 | */ |
| 45 | 45 | public static function getPatients($month = null, $day = null, $wardId = 0) { |
| 46 | - return PatientCRUD::getPatientsDateRange ( Utils::getStartDate ( $month, $day ), Utils::getEndDate ( $month, $day ), $wardId ); |
|
| 46 | + return PatientCRUD::getPatientsDateRange(Utils::getStartDate($month, $day), Utils::getEndDate($month, $day), $wardId); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | * @return Patient array |
| 60 | 60 | */ |
| 61 | 61 | public static function getPatientsDateRange($date1, $date2, $wardId = 0) { |
| 62 | - $entityManager = ( object ) DoctrineBootstrap::getEntityManager (); |
|
| 63 | - $params = array ( |
|
| 62 | + $entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
| 63 | + $params = array( |
|
| 64 | 64 | 'from' => $date1, |
| 65 | 65 | 'to' => $date2, |
| 66 | 66 | 'oddzialId' => $wardId |
| 67 | 67 | ); |
| 68 | - $q = $entityManager->createQuery ( 'select p FROM Hospitalplugin\Entities\Patient p WHERE p.dataKategoryzacji BETWEEN :from AND :to and p.oddzialId = :oddzialId ORDER BY p.name' )->setParameters ( $params )->setFirstResult ( 0 )->setMaxResults ( 1000 ); |
|
| 69 | - $patients = $q->getResult (); |
|
| 68 | + $q = $entityManager->createQuery('select p FROM Hospitalplugin\Entities\Patient p WHERE p.dataKategoryzacji BETWEEN :from AND :to and p.oddzialId = :oddzialId ORDER BY p.name')->setParameters($params)->setFirstResult(0)->setMaxResults(1000); |
|
| 69 | + $patients = $q->getResult(); |
|
| 70 | 70 | return $patients; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @return Patient Patient |
| 80 | 80 | */ |
| 81 | 81 | public static function getPatient($id, $type = '') { |
| 82 | - $entityManager = ( object ) DoctrineBootstrap::getEntityManager (); |
|
| 83 | - $type = 'Hospitalplugin\Entities\Patient' . $type; |
|
| 84 | - $patient = $entityManager->getRepository ( $type )->findOneBy ( array ( |
|
| 82 | + $entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
| 83 | + $type = 'Hospitalplugin\Entities\Patient'.$type; |
|
| 84 | + $patient = $entityManager->getRepository($type)->findOneBy(array( |
|
| 85 | 85 | 'id' => $id |
| 86 | - ) ); |
|
| 87 | - return Utils::cast ( $type, ( object ) $patient, 0 ); |
|
| 86 | + )); |
|
| 87 | + return Utils::cast($type, (object) $patient, 0); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | * @return Patient |
| 96 | 96 | */ |
| 97 | 97 | public static function setPatientCategories($obj, $type) { |
| 98 | - $entityManager = DoctrineBootstrap::getEntityManager (); |
|
| 99 | - $patient = PatientCRUD::getPatient ( $obj->id, $type ); |
|
| 100 | - foreach ( get_object_vars ( $obj ) as $key => $value ) { |
|
| 101 | - call_user_func ( array ( |
|
| 98 | + $entityManager = DoctrineBootstrap::getEntityManager(); |
|
| 99 | + $patient = PatientCRUD::getPatient($obj->id, $type); |
|
| 100 | + foreach (get_object_vars($obj) as $key => $value) { |
|
| 101 | + call_user_func(array( |
|
| 102 | 102 | $patient, |
| 103 | - 'set' . ucwords ( $key ) |
|
| 104 | - ), $value ); |
|
| 103 | + 'set'.ucwords($key) |
|
| 104 | + ), $value); |
|
| 105 | 105 | } |
| 106 | - $entityManager->merge ( $patient ); |
|
| 107 | - $entityManager->flush (); |
|
| 106 | + $entityManager->merge($patient); |
|
| 107 | + $entityManager->flush(); |
|
| 108 | 108 | return $patient; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * @return Patient |
| 117 | 117 | */ |
| 118 | 118 | public static function createPatient($type, $name, $pesel) { |
| 119 | - $entityManager = DoctrineBootstrap::getEntityManager (); |
|
| 120 | - $type = 'Hospitalplugin\Entities\Patient' . $type; |
|
| 121 | - $patient = new $type (); |
|
| 122 | - $patient->setName ( $name ); |
|
| 123 | - $patient->setPesel ( $pesel ); |
|
| 124 | - $entityManager->persist ( $patient ); |
|
| 125 | - $entityManager->flush (); |
|
| 119 | + $entityManager = DoctrineBootstrap::getEntityManager(); |
|
| 120 | + $type = 'Hospitalplugin\Entities\Patient'.$type; |
|
| 121 | + $patient = new $type(); |
|
| 122 | + $patient->setName($name); |
|
| 123 | + $patient->setPesel($pesel); |
|
| 124 | + $entityManager->persist($patient); |
|
| 125 | + $entityManager->flush(); |
|
| 126 | 126 | return $patient; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -133,19 +133,19 @@ discard block |
||
| 133 | 133 | * int |
| 134 | 134 | */ |
| 135 | 135 | public static function deletePatient($id, $userId = 0) { |
| 136 | - $entityManager = ( object ) DoctrineBootstrap::getEntityManager (); |
|
| 136 | + $entityManager = (object) DoctrineBootstrap::getEntityManager(); |
|
| 137 | 137 | $type = 'Hospitalplugin\Entities\Patient'; |
| 138 | - $patient = $entityManager->getRepository ( $type )->findOneBy ( array ( |
|
| 138 | + $patient = $entityManager->getRepository($type)->findOneBy(array( |
|
| 139 | 139 | 'id' => $id |
| 140 | - ) ); |
|
| 141 | - $entityManager->remove ( $patient ); |
|
| 140 | + )); |
|
| 141 | + $entityManager->remove($patient); |
|
| 142 | 142 | $log = strval($patient); |
| 143 | 143 | $audit = new PatientDeleted(); |
| 144 | - $audit->deletedAt = new \DateTime (); |
|
| 144 | + $audit->deletedAt = new \DateTime(); |
|
| 145 | 145 | $audit->deletedByUserId = $userId; |
| 146 | 146 | $audit->log = $log; |
| 147 | - $entityManager->persist ( $audit ); |
|
| 148 | - $entityManager->flush (); |
|
| 147 | + $entityManager->persist($audit); |
|
| 148 | + $entityManager->flush(); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | ?> |
| 152 | 152 | \ No newline at end of file |
@@ -3,9 +3,6 @@ |
||
| 3 | 3 | namespace Hospitalplugin\Entities; |
| 4 | 4 | |
| 5 | 5 | use Hospitalplugin\DB\DoctrineBootstrap; |
| 6 | -use Hospitalplugin\utils\Utils; |
|
| 7 | -use Doctrine\DBAL\Schema\View; |
|
| 8 | -use Doctrine\ORM\Query\ResultSetMapping; |
|
| 9 | 6 | |
| 10 | 7 | class PatientRaportOptimized { |
| 11 | 8 | /** |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * @param unknown $date |
| 15 | 15 | */ |
| 16 | 16 | public static function getRaport($wardId, $date) { |
| 17 | - $startDate = $date . '-01'; |
|
| 18 | - $endDate = date ( "Y-m-t 23:59:59", strtotime ( $startDate ) ); |
|
| 17 | + $startDate = $date.'-01'; |
|
| 18 | + $endDate = date("Y-m-t 23:59:59", strtotime($startDate)); |
|
| 19 | 19 | |
| 20 | - return PatientRaportOptimized::getRaportBetweenDatesNative ( $wardId, $startDate, $endDate ); |
|
| 20 | + return PatientRaportOptimized::getRaportBetweenDatesNative($wardId, $startDate, $endDate); |
|
| 21 | 21 | } |
| 22 | 22 | private static function updateNativeRaport() { |
| 23 | - $em = DoctrineBootstrap::getEntityManager (); |
|
| 24 | - $conn = $em->getConnection (); |
|
| 23 | + $em = DoctrineBootstrap::getEntityManager(); |
|
| 24 | + $conn = $em->getConnection(); |
|
| 25 | 25 | // create report table |
| 26 | 26 | $sql1 = "CREATE TABLE IF NOT EXISTS kategoria_view |
| 27 | 27 | (data DATETIME, oddzialId INT, kategoria INT, suma INT, |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | kategoriaPacjenta"; |
| 51 | 51 | // select |
| 52 | 52 | try { |
| 53 | - $conn->query ( $sql1 ); |
|
| 54 | - $conn->query ( $sql2 ); |
|
| 55 | - } catch ( Exception $e ) { |
|
| 53 | + $conn->query($sql1); |
|
| 54 | + $conn->query($sql2); |
|
| 55 | + } catch (Exception $e) { |
|
| 56 | 56 | // echo 'Caught exception: ', $e->getMessage(), "\n"; |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -63,19 +63,19 @@ discard block |
||
| 63 | 63 | * @param unknown $endDate |
| 64 | 64 | */ |
| 65 | 65 | public static function getRaportBetweenDatesNative($wardId, $startDate, $endDate) { |
| 66 | - $em = DoctrineBootstrap::getEntityManager (); |
|
| 66 | + $em = DoctrineBootstrap::getEntityManager(); |
|
| 67 | 67 | PatientRaportOptimized::updateNativeRaport(); |
| 68 | - $conn = $em->getConnection (); |
|
| 68 | + $conn = $em->getConnection(); |
|
| 69 | 69 | $sql3 = "SELECT kategoria, date(data) as data, suma FROM kategoria_view WHERE data between :data1 AND :data2 and oddzialId = :oddzialId"; |
| 70 | - $stmt = $conn->prepare ( $sql3 ); |
|
| 71 | - $stmt->execute ( array ( |
|
| 70 | + $stmt = $conn->prepare($sql3); |
|
| 71 | + $stmt->execute(array( |
|
| 72 | 72 | 'data1' => $startDate, |
| 73 | 73 | 'data2' => $endDate, |
| 74 | 74 | 'oddzialId' => $wardId |
| 75 | - ) ); |
|
| 75 | + )); |
|
| 76 | 76 | $result = $stmt->fetchAll(); |
| 77 | - $table = array (); |
|
| 78 | - foreach ( $result as $row ) { |
|
| 77 | + $table = array(); |
|
| 78 | + foreach ($result as $row) { |
|
| 79 | 79 | $table [$row ['data']] [$row ['kategoria']] = $row ['suma']; |
| 80 | 80 | } |
| 81 | 81 | return $table; |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Hospitalplugin\utils; |
| 4 | 4 | |
| 5 | -use Hospitalplugin\Entities\InfectionsCRUD; |
|
| 6 | 5 | use Hospitalplugin\Entities\Infections; |
| 7 | 6 | |
| 8 | 7 | class ExcelExport { |
@@ -10,60 +10,60 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | */ |
| 12 | 12 | public static function init() { |
| 13 | - add_action ( 'admin_init', array ( |
|
| 13 | + add_action('admin_init', array( |
|
| 14 | 14 | 'Hospitalplugin\utils\ExcelExport', |
| 15 | 15 | 'excel_export' |
| 16 | - ), 1 ); |
|
| 16 | + ), 1); |
|
| 17 | 17 | } |
| 18 | 18 | /** |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | 21 | public static function getColumnLetter($num) { |
| 22 | - return chr ( 65 + $num ); |
|
| 22 | + return chr(65 + $num); |
|
| 23 | 23 | } |
| 24 | 24 | /** |
| 25 | 25 | */ |
| 26 | 26 | static function excel_export() { |
| 27 | - if (! isset ( $_POST ['excel'] )) { |
|
| 27 | + if (!isset ($_POST ['excel'])) { |
|
| 28 | 28 | return; |
| 29 | 29 | } else { |
| 30 | 30 | // dataSetName: Infections, Punction |
| 31 | 31 | $dataSetName = $_POST ['dataSetName']; |
| 32 | - $classname = '\Hospitalplugin\utils\ExcelExport' . $dataSetName; |
|
| 32 | + $classname = '\Hospitalplugin\utils\ExcelExport'.$dataSetName; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $objPHPExcel = new \PHPExcel (); |
|
| 36 | - $classname::fillData ( $objPHPExcel ); |
|
| 35 | + $objPHPExcel = new \PHPExcel(); |
|
| 36 | + $classname::fillData($objPHPExcel); |
|
| 37 | 37 | |
| 38 | - ExcelExport::downloadExcel ( $objPHPExcel, $dataSetName . '.xlsx' ); |
|
| 38 | + ExcelExport::downloadExcel($objPHPExcel, $dataSetName.'.xlsx'); |
|
| 39 | 39 | } |
| 40 | 40 | /** |
| 41 | 41 | */ |
| 42 | 42 | static function cellColor($objPHPExcel, $cells, $color) { |
| 43 | - $objPHPExcel->getActiveSheet ()->getStyle ( $cells )->getFill ()->applyFromArray ( array ( |
|
| 43 | + $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array( |
|
| 44 | 44 | 'type' => \PHPExcel_Style_Fill::FILL_SOLID, |
| 45 | - 'startcolor' => array ( |
|
| 45 | + 'startcolor' => array( |
|
| 46 | 46 | 'rgb' => $color |
| 47 | 47 | ) |
| 48 | - ) ); |
|
| 48 | + )); |
|
| 49 | 49 | } |
| 50 | 50 | /** |
| 51 | 51 | */ |
| 52 | 52 | static function styleActiveSheet($objPHPExcel) { |
| 53 | - $objPHPExcel->getActiveSheet ()->getDefaultStyle ()->getFont ()->setName ( 'Arial' )->setSize ( 8 )->setBold ( false ); |
|
| 54 | - $objPHPExcel->getActiveSheet ()->getDefaultStyle ()->getNumberFormat ()->setFormatCode ( \PHPExcel_Style_NumberFormat::FORMAT_TEXT ); |
|
| 55 | - $objPHPExcel->getActiveSheet ()->freezePane ( 'A3' ); |
|
| 56 | - $style = array ( |
|
| 57 | - 'alignment' => array ( |
|
| 53 | + $objPHPExcel->getActiveSheet()->getDefaultStyle()->getFont()->setName('Arial')->setSize(8)->setBold(false); |
|
| 54 | + $objPHPExcel->getActiveSheet()->getDefaultStyle()->getNumberFormat()->setFormatCode(\PHPExcel_Style_NumberFormat::FORMAT_TEXT); |
|
| 55 | + $objPHPExcel->getActiveSheet()->freezePane('A3'); |
|
| 56 | + $style = array( |
|
| 57 | + 'alignment' => array( |
|
| 58 | 58 | 'horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER, |
| 59 | 59 | 'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER |
| 60 | 60 | ) |
| 61 | 61 | ); |
| 62 | - $objWorksheet = $objPHPExcel->getActiveSheet (); |
|
| 63 | - $objWorksheet->getDefaultStyle ()->applyFromArray ( $style ); |
|
| 64 | - $objWorksheet->getStyle ( 'A1:AA2' )->getFont ()->setBold ( true ); |
|
| 65 | - for($col = ord ( 'a' ); $col <= ord ( 'z' ); $col ++) { |
|
| 66 | - $objWorksheet->getColumnDimension ( chr ( $col ) )->setAutoSize ( true ); |
|
| 62 | + $objWorksheet = $objPHPExcel->getActiveSheet(); |
|
| 63 | + $objWorksheet->getDefaultStyle()->applyFromArray($style); |
|
| 64 | + $objWorksheet->getStyle('A1:AA2')->getFont()->setBold(true); |
|
| 65 | + for ($col = ord('a'); $col <= ord('z'); $col ++) { |
|
| 66 | + $objWorksheet->getColumnDimension(chr($col))->setAutoSize(true); |
|
| 67 | 67 | } |
| 68 | 68 | return $objPHPExcel; |
| 69 | 69 | } |
@@ -72,19 +72,19 @@ discard block |
||
| 72 | 72 | * @param unknown $objPHPExcel |
| 73 | 73 | */ |
| 74 | 74 | private static function downloadExcel($objPHPExcel, $filename) { |
| 75 | - ob_end_clean (); |
|
| 76 | - ob_start (); |
|
| 77 | - header ( "Content-type: application/vnd.ms-excel; charset=utf-8" ); |
|
| 78 | - header ( "Content-Transfer-Encoding: binary" ); |
|
| 79 | - header ( "Content-Description: File Transfer" ); |
|
| 80 | - header ( "Content-Disposition: attachment; filename=\"" . $filename . "\"" ); |
|
| 81 | - header ( "Cache-Control: max-age=0" ); |
|
| 82 | - header ( "Expires: 0" ); |
|
| 83 | - header ( "Pragma: no-cache" ); |
|
| 75 | + ob_end_clean(); |
|
| 76 | + ob_start(); |
|
| 77 | + header("Content-type: application/vnd.ms-excel; charset=utf-8"); |
|
| 78 | + header("Content-Transfer-Encoding: binary"); |
|
| 79 | + header("Content-Description: File Transfer"); |
|
| 80 | + header("Content-Disposition: attachment; filename=\"".$filename."\""); |
|
| 81 | + header("Cache-Control: max-age=0"); |
|
| 82 | + header("Expires: 0"); |
|
| 83 | + header("Pragma: no-cache"); |
|
| 84 | 84 | |
| 85 | - $objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel2007' ); |
|
| 86 | - $objWriter->setPreCalculateFormulas ( true ); |
|
| 87 | - $objWriter->save ( 'php://output' ); |
|
| 85 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); |
|
| 86 | + $objWriter->setPreCalculateFormulas(true); |
|
| 87 | + $objWriter->save('php://output'); |
|
| 88 | 88 | exit (); |
| 89 | 89 | } |
| 90 | 90 | /** |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * @param unknown $string |
| 93 | 93 | */ |
| 94 | 94 | private static function clearName($string, $removeWords) { |
| 95 | - $string = str_replace ( ' ', '-', $string ); |
|
| 96 | - $string = preg_replace ( '/[^A-Za-z0-9\-]/', '', $string ); |
|
| 97 | - foreach ( $removeWords as $word ) { |
|
| 98 | - $string = str_replace ( $word, '', $string ); |
|
| 95 | + $string = str_replace(' ', '-', $string); |
|
| 96 | + $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); |
|
| 97 | + foreach ($removeWords as $word) { |
|
| 98 | + $string = str_replace($word, '', $string); |
|
| 99 | 99 | } |
| 100 | - $string = substr ( $string, 0, 29 ); |
|
| 100 | + $string = substr($string, 0, 29); |
|
| 101 | 101 | return $string; |
| 102 | 102 | } |
| 103 | 103 | /** |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @param unknown $title |
| 106 | 106 | */ |
| 107 | 107 | static function printTitle($objPHPExcel, $title) { |
| 108 | - $objPHPExcel->getActiveSheet ()->setTitle ( ExcelExport::clearName ( $title, array('ddzia') ), true ); |
|
| 109 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 1, $title ); |
|
| 108 | + $objPHPExcel->getActiveSheet()->setTitle(ExcelExport::clearName($title, array('ddzia')), true); |
|
| 109 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 1, $title); |
|
| 110 | 110 | } |
| 111 | 111 | /** |
| 112 | 112 | * |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | static function newSheet($objPHPExcel, $index = -1) { |
| 116 | 116 | if ($index < 0) { |
| 117 | - $index = $objPHPExcel->getSheetCount (); |
|
| 117 | + $index = $objPHPExcel->getSheetCount(); |
|
| 118 | 118 | } |
| 119 | - $objPHPExcel->createSheet ( $index ); |
|
| 120 | - $objPHPExcel->setActiveSheetIndex ( $index ); |
|
| 121 | - $sheet = $objPHPExcel->getActiveSheet (); |
|
| 119 | + $objPHPExcel->createSheet($index); |
|
| 120 | + $objPHPExcel->setActiveSheetIndex($index); |
|
| 121 | + $sheet = $objPHPExcel->getActiveSheet(); |
|
| 122 | 122 | return $sheet; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -2,8 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Hospitalplugin\utils; |
| 4 | 4 | |
| 5 | -use Hospitalplugin\Entities\InfectionsCRUD; |
|
| 6 | -use Hospitalplugin\Entities\Infections; |
|
| 7 | 5 | use Hospitalplugin\Entities\PatientRaport; |
| 8 | 6 | use Hospitalplugin\Entities\WardCRUD; |
| 9 | 7 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * @param unknown $id |
| 15 | 15 | */ |
| 16 | 16 | private static function getData($id, $type) { |
| 17 | - $raport = PatientRaport::getRaportBetweenDates ( $id, $type, '2014-06-01', (new \DateTime ())->format ( "Y-m-d" ) ); |
|
| 17 | + $raport = PatientRaport::getRaportBetweenDates($id, $type, '2014-06-01', (new \DateTime())->format("Y-m-d")); |
|
| 18 | 18 | return $raport; |
| 19 | 19 | } |
| 20 | 20 | /** |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | private static function printHeaders($objPHPExcel, $cols) { |
| 26 | 26 | $count = 1; |
| 27 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 2, "Data" ); |
|
| 28 | - foreach ( $cols as $col ) { |
|
| 29 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, 2, sprintf ( "%7s", $col ) ); |
|
| 27 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 2, "Data"); |
|
| 28 | + foreach ($cols as $col) { |
|
| 29 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, 2, sprintf("%7s", $col)); |
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | /** |
@@ -34,45 +34,45 @@ discard block |
||
| 34 | 34 | private static function printData($objPHPExcel, $data, $type) { |
| 35 | 35 | $row = 3; |
| 36 | 36 | $lastColumn = 1; |
| 37 | - $colNumberOfPatients = ExcelExport::getColumnLetter ( 1 ); |
|
| 38 | - $indexes = PatientRaport::getIndexes ( $type ); |
|
| 39 | - foreach ( $data as $rowKey => $rowValue ) { |
|
| 37 | + $colNumberOfPatients = ExcelExport::getColumnLetter(1); |
|
| 38 | + $indexes = PatientRaport::getIndexes($type); |
|
| 39 | + foreach ($data as $rowKey => $rowValue) { |
|
| 40 | 40 | // 1 col: date |
| 41 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row, json_encode ( $rowKey ) ); |
|
| 41 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row, json_encode($rowKey)); |
|
| 42 | 42 | $count = 1; |
| 43 | 43 | // 2-5 cols: N1 N2 N3 N0 |
| 44 | - foreach ( $indexes as $index ) { |
|
| 45 | - $value = isset ( $rowValue [$index] ) ? $rowValue [$index] : "0"; |
|
| 46 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, $value ); |
|
| 44 | + foreach ($indexes as $index) { |
|
| 45 | + $value = isset ($rowValue [$index]) ? $rowValue [$index] : "0"; |
|
| 46 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, $value); |
|
| 47 | 47 | } |
| 48 | 48 | // 6 col: num of categorized (N = N1+N2+N3) |
| 49 | - $colHighestCategory = ExcelExport::getColumnLetter ( $count - 2 ); |
|
| 50 | - $colNumberOfPatients = ExcelExport::getColumnLetter ( $count ); |
|
| 51 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, '=SUM(B' . $row . ':' . $colHighestCategory . $row . ')' ); |
|
| 52 | - $tpb = PatientRaport::getTpb ( $type ); |
|
| 49 | + $colHighestCategory = ExcelExport::getColumnLetter($count - 2); |
|
| 50 | + $colNumberOfPatients = ExcelExport::getColumnLetter($count); |
|
| 51 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, '=SUM(B'.$row.':'.$colHighestCategory.$row.')'); |
|
| 52 | + $tpb = PatientRaport::getTpb($type); |
|
| 53 | 53 | // 7-11 tpb1, tpb2, tpb3, 0 (no-cat), 2 (add) |
| 54 | - foreach ( $tpb as $tpbn ) { |
|
| 55 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, $tpbn ); |
|
| 54 | + foreach ($tpb as $tpbn) { |
|
| 55 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, $tpbn); |
|
| 56 | 56 | } |
| 57 | 57 | // 9-11: Tpb1*N1,Tpb2*N2,Tpb3*N3+2xN |
| 58 | - $tpbSize = count ( $tpb ); |
|
| 59 | - foreach ( $tpb as $tpbn ) { |
|
| 60 | - $col1Letter = ExcelExport::getColumnLetter ( $count - 2 * $tpbSize ); |
|
| 61 | - $col2Letter = ExcelExport::getColumnLetter ( $count - $tpbSize ); |
|
| 62 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, '=' . $col1Letter . $row . "*" . $col2Letter . $row ); |
|
| 58 | + $tpbSize = count($tpb); |
|
| 59 | + foreach ($tpb as $tpbn) { |
|
| 60 | + $col1Letter = ExcelExport::getColumnLetter($count - 2 * $tpbSize); |
|
| 61 | + $col2Letter = ExcelExport::getColumnLetter($count - $tpbSize); |
|
| 62 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, '='.$col1Letter.$row."*".$col2Letter.$row); |
|
| 63 | 63 | } |
| 64 | 64 | // SUM Tpb |
| 65 | - $col3Letter = ExcelExport::getColumnLetter ( $count - $tpbSize ); |
|
| 66 | - $col4Letter = ExcelExport::getColumnLetter ( $count - 1 ); |
|
| 67 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( $count ++, $row, '=SUM(' . $col3Letter . $row . ":" . $col4Letter . $row . ")" ); |
|
| 65 | + $col3Letter = ExcelExport::getColumnLetter($count - $tpbSize); |
|
| 66 | + $col4Letter = ExcelExport::getColumnLetter($count - 1); |
|
| 67 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($count ++, $row, '=SUM('.$col3Letter.$row.":".$col4Letter.$row.")"); |
|
| 68 | 68 | $row ++; |
| 69 | 69 | $lastColumn = $count - 1; |
| 70 | 70 | } |
| 71 | 71 | // number of categorization days |
| 72 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 1, 1, '=COUNTIFS(' . $colNumberOfPatients . '3:' . $colNumberOfPatients . ($row - 1) . ',">0")' ); |
|
| 72 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 1, '=COUNTIFS('.$colNumberOfPatients.'3:'.$colNumberOfPatients.($row - 1).',">0")'); |
|
| 73 | 73 | // sum |
| 74 | - $col5Letter = ExcelExport::getColumnLetter ( $lastColumn ); |
|
| 75 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 2, 1, '=SUM(' . $col5Letter . '3:' . $col5Letter . ($row - 1) . ')/60' ); |
|
| 74 | + $col5Letter = ExcelExport::getColumnLetter($lastColumn); |
|
| 75 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(2, 1, '=SUM('.$col5Letter.'3:'.$col5Letter.($row - 1).')/60'); |
|
| 76 | 76 | return $row; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -81,61 +81,61 @@ discard block |
||
| 81 | 81 | * @param unknown $objPHPExcel |
| 82 | 82 | */ |
| 83 | 83 | static function fillSummary($objPHPExcel) { |
| 84 | - ExcelExport::newSheet ( $objPHPExcel, 0 ); |
|
| 85 | - ExcelExport::printTitle ( $objPHPExcel, "Raport" ); |
|
| 86 | - $sheetCount = $objPHPExcel->getSheetCount (); |
|
| 87 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'A2', 'Oddz.' ); |
|
| 88 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'B2', 'Dni' ); |
|
| 89 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'C2', 'Tpb' ); |
|
| 90 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'D2', 'Tśpb' ); |
|
| 91 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'E2', 'Tśpc*' ); |
|
| 92 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'F2', 'Tśpc**' ); |
|
| 93 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'G2', 'Td***' ); |
|
| 94 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'H2', 'Le*' ); |
|
| 95 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'I2', 'Le**' ); |
|
| 96 | - for($i = 1; $i < $sheetCount; $i ++) { |
|
| 97 | - $loadedSheetNames = $objPHPExcel->getSheetNames (); |
|
| 98 | - foreach ( $loadedSheetNames as $sheetIndex => $loadedSheetName ) { |
|
| 84 | + ExcelExport::newSheet($objPHPExcel, 0); |
|
| 85 | + ExcelExport::printTitle($objPHPExcel, "Raport"); |
|
| 86 | + $sheetCount = $objPHPExcel->getSheetCount(); |
|
| 87 | + $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Oddz.'); |
|
| 88 | + $objPHPExcel->getActiveSheet()->setCellValue('B2', 'Dni'); |
|
| 89 | + $objPHPExcel->getActiveSheet()->setCellValue('C2', 'Tpb'); |
|
| 90 | + $objPHPExcel->getActiveSheet()->setCellValue('D2', 'Tśpb'); |
|
| 91 | + $objPHPExcel->getActiveSheet()->setCellValue('E2', 'Tśpc*'); |
|
| 92 | + $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Tśpc**'); |
|
| 93 | + $objPHPExcel->getActiveSheet()->setCellValue('G2', 'Td***'); |
|
| 94 | + $objPHPExcel->getActiveSheet()->setCellValue('H2', 'Le*'); |
|
| 95 | + $objPHPExcel->getActiveSheet()->setCellValue('I2', 'Le**'); |
|
| 96 | + for ($i = 1; $i < $sheetCount; $i ++) { |
|
| 97 | + $loadedSheetNames = $objPHPExcel->getSheetNames(); |
|
| 98 | + foreach ($loadedSheetNames as $sheetIndex => $loadedSheetName) { |
|
| 99 | 99 | if ($sheetIndex == 0) { |
| 100 | 100 | continue; |
| 101 | 101 | } |
| 102 | 102 | $row = $sheetIndex + 2; |
| 103 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'A' . $row, "='" . $loadedSheetName . "'!A1" ); |
|
| 104 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'B' . $row, "='" . $loadedSheetName . "'!B1" ); |
|
| 105 | - $objPHPExcel->getActiveSheet ()->setCellValue ( 'C' . $row, "='" . $loadedSheetName . "'!C1" ); |
|
| 106 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 3, $row, "=IF(C" . $row . ">0,C" . $row . "/B" . $row . ",0)" ); |
|
| 107 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 4, $row, "=D" . $row . "*110%" ); |
|
| 108 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 5, $row, "=D" . $row . "*125%" ); |
|
| 109 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 6, $row, "1531" ); |
|
| 110 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 7, $row, "=IF(E" . $row . ">0,E" . $row . "*365/G" . $row . ",\"-\")" ); |
|
| 111 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 8, $row, "=IF(F" . $row . ">0,F" . $row . "*365/G" . $row . ",\"-\")" ); |
|
| 103 | + $objPHPExcel->getActiveSheet()->setCellValue('A'.$row, "='".$loadedSheetName."'!A1"); |
|
| 104 | + $objPHPExcel->getActiveSheet()->setCellValue('B'.$row, "='".$loadedSheetName."'!B1"); |
|
| 105 | + $objPHPExcel->getActiveSheet()->setCellValue('C'.$row, "='".$loadedSheetName."'!C1"); |
|
| 106 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(3, $row, "=IF(C".$row.">0,C".$row."/B".$row.",0)"); |
|
| 107 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(4, $row, "=D".$row."*110%"); |
|
| 108 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(5, $row, "=D".$row."*125%"); |
|
| 109 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6, $row, "1531"); |
|
| 110 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(7, $row, "=IF(E".$row.">0,E".$row."*365/G".$row.",\"-\")"); |
|
| 111 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(8, $row, "=IF(F".$row.">0,F".$row."*365/G".$row.",\"-\")"); |
|
| 112 | 112 | } |
| 113 | - $objPHPExcel->getActiveSheet ()->getStyle ( 'C3:I100' )->getNumberFormat ()->setFormatCode ( '#,##0.0' ); |
|
| 114 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row + 1, "* Czas pielęgnacji pośredniej jako 10% czasu pielęgnacji bezpośredniej" ); |
|
| 115 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row + 2, "** Czas pielęgnacji pośredniej jako 25% czasu pielęgnacji bezpośredniej" ); |
|
| 116 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, $row + 3, "*** Czas dyspozycyjny - propozycja z Rozporządzenia MZ: 202 dni x 7,58 h" ); |
|
| 117 | - ExcelExport::styleActiveSheet ( $objPHPExcel ); |
|
| 113 | + $objPHPExcel->getActiveSheet()->getStyle('C3:I100')->getNumberFormat()->setFormatCode('#,##0.0'); |
|
| 114 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row + 1, "* Czas pielęgnacji pośredniej jako 10% czasu pielęgnacji bezpośredniej"); |
|
| 115 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row + 2, "** Czas pielęgnacji pośredniej jako 25% czasu pielęgnacji bezpośredniej"); |
|
| 116 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row + 3, "*** Czas dyspozycyjny - propozycja z Rozporządzenia MZ: 202 dni x 7,58 h"); |
|
| 117 | + ExcelExport::styleActiveSheet($objPHPExcel); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | static function fillData($objPHPExcel) { |
| 121 | 121 | // no time limit for this script |
| 122 | - set_time_limit ( 0 ); |
|
| 123 | - $time_start = microtime ( true ); |
|
| 122 | + set_time_limit(0); |
|
| 123 | + $time_start = microtime(true); |
|
| 124 | 124 | // remove first default sheet |
| 125 | - $objPHPExcel->removeSheetByIndex ( 0 ); |
|
| 125 | + $objPHPExcel->removeSheetByIndex(0); |
|
| 126 | 126 | // get wards |
| 127 | - $wards = WardCRUD::getWardsArray (); |
|
| 128 | - foreach ( $wards as $ward ) { |
|
| 129 | - ExcelExport::newSheet ( $objPHPExcel ); |
|
| 130 | - $wardName = $ward->name . " (" . $ward->getTypOddzialu () . ")"; |
|
| 131 | - ExcelExport::printTitle ( $objPHPExcel, $wardName ); |
|
| 132 | - $data = ExcelExportPunction::getData ( $ward->id, $ward->getTypOddzialu () ); |
|
| 133 | - $cols = PatientRaport::getColumns ( $ward->getTypOddzialu () ); |
|
| 134 | - ExcelExportPunction::printHeaders ( $objPHPExcel, $cols ); |
|
| 135 | - ExcelExportPunction::printData ( $objPHPExcel, $data, $ward->getTypOddzialu () ); |
|
| 136 | - ExcelExport::styleActiveSheet ( $objPHPExcel ); |
|
| 127 | + $wards = WardCRUD::getWardsArray(); |
|
| 128 | + foreach ($wards as $ward) { |
|
| 129 | + ExcelExport::newSheet($objPHPExcel); |
|
| 130 | + $wardName = $ward->name." (".$ward->getTypOddzialu().")"; |
|
| 131 | + ExcelExport::printTitle($objPHPExcel, $wardName); |
|
| 132 | + $data = ExcelExportPunction::getData($ward->id, $ward->getTypOddzialu()); |
|
| 133 | + $cols = PatientRaport::getColumns($ward->getTypOddzialu()); |
|
| 134 | + ExcelExportPunction::printHeaders($objPHPExcel, $cols); |
|
| 135 | + ExcelExportPunction::printData($objPHPExcel, $data, $ward->getTypOddzialu()); |
|
| 136 | + ExcelExport::styleActiveSheet($objPHPExcel); |
|
| 137 | 137 | } |
| 138 | - ExcelExportPunction::fillSummary ( $objPHPExcel ); |
|
| 139 | - $objPHPExcel->getActiveSheet ()->setCellValueByColumnAndRow ( 0, 100, "summary " . ($time_start - microtime ( true )) . " s" ); |
|
| 138 | + ExcelExportPunction::fillSummary($objPHPExcel); |
|
| 139 | + $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 100, "summary ".($time_start - microtime(true))." s"); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | \ No newline at end of file |
@@ -24,7 +24,6 @@ |
||
| 24 | 24 | namespace Hospitalplugin\utils; |
| 25 | 25 | |
| 26 | 26 | use Hospitalplugin\Entities\Patient; |
| 27 | -use Hospitalplugin\Entities\PatientZZ; |
|
| 28 | 27 | |
| 29 | 28 | /** |
| 30 | 29 | * PersonGenerator |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | public static function getRandomPerson() |
| 55 | 55 | { |
| 56 | 56 | // TODO extract paths |
| 57 | - self::$names = Utils::readFileToArray(__DIR__ . '/../../resources/pl_names.csv'); |
|
| 58 | - self::$mnames = Utils::readFileToArray(__DIR__ . '/../../resources/pl_mnames.csv'); |
|
| 59 | - self::$fnames = Utils::readFileToArray(__DIR__ . '/../../resources/pl_fnames.csv'); |
|
| 57 | + self::$names = Utils::readFileToArray(__DIR__.'/../../resources/pl_names.csv'); |
|
| 58 | + self::$mnames = Utils::readFileToArray(__DIR__.'/../../resources/pl_mnames.csv'); |
|
| 59 | + self::$fnames = Utils::readFileToArray(__DIR__.'/../../resources/pl_fnames.csv'); |
|
| 60 | 60 | // var_dump(self::$mnames); |
| 61 | 61 | $sex = (rand(0, 1) == 0 ? 'm' : 'f'); |
| 62 | 62 | $firstname = ($sex == 'm' ? self::getRandom(self::$mnames) : self::getRandom(self::$fnames)); |
| 63 | 63 | $lastname = self::getRandom(self::$names); |
| 64 | 64 | if ($sex == 'f' && self::endsWith($lastname, 'i')) { |
| 65 | - $lastname = rtrim($lastname, "i") . 'a'; |
|
| 65 | + $lastname = rtrim($lastname, "i").'a'; |
|
| 66 | 66 | } |
| 67 | 67 | $bdate = self::getRandomBirthDate(); |
| 68 | 68 | $pesel = self::getRandomPesel($bdate, $sex); |
| 69 | - return $firstname . ' ' . $lastname . '|' . $pesel; |
|
| 69 | + return $firstname.' '.$lastname.'|'.$pesel; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | $age = rand(0, 100); |
| 88 | 88 | $dayOfYear = rand(0, 365); |
| 89 | - $interval = new \DateInterval('P' . $age . 'Y' . $dayOfYear . 'D'); |
|
| 89 | + $interval = new \DateInterval('P'.$age.'Y'.$dayOfYear.'D'); |
|
| 90 | 90 | $date = new \DateTime(); |
| 91 | 91 | $birth = $date->sub($interval); |
| 92 | 92 | return $birth->format('Y-m-d'); |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | use Hospitalplugin\Entities\PatientZZ; |
| 25 | 25 | use Punction\DB\DoctrineBootstrap; |
| 26 | 26 | |
| 27 | -if (! defined ( 'ABSPATH' )) { |
|
| 28 | - define ( 'WP_USE_THEMES', false ); |
|
| 27 | +if (!defined('ABSPATH')) { |
|
| 28 | + define('WP_USE_THEMES', false); |
|
| 29 | 29 | require ('/var/www/wp/wp-load.php'); |
| 30 | 30 | } |
| 31 | 31 | require_once ('/var/www/vendor/autoload.php'); |
| 32 | -Logger::configure ( '../resources/log4php.xml' ); |
|
| 32 | +Logger::configure('../resources/log4php.xml'); |
|
| 33 | 33 | /** |
| 34 | 34 | * migration log4php logger |
| 35 | 35 | */ |
| 36 | -$log = Logger::getLogger ( "migration" ); |
|
| 37 | -$log->info ( "Start!" ); |
|
| 36 | +$log = Logger::getLogger("migration"); |
|
| 37 | +$log->info("Start!"); |
|
| 38 | 38 | |
| 39 | 39 | global $wpdb; |
| 40 | 40 | /** |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | $error = "Error: the query failed..."; |
| 58 | 58 | /** |
| 59 | 59 | */ |
| 60 | -$results = $wpdb->get_results ( $query, ARRAY_A ) || wp_die ( $error ); |
|
| 60 | +$results = $wpdb->get_results($query, ARRAY_A) || wp_die($error); |
|
| 61 | 61 | |
| 62 | -$db1 = new DoctrineBootstrap (); |
|
| 63 | -$entityManager = $db1->getEntityManager (); |
|
| 62 | +$db1 = new DoctrineBootstrap(); |
|
| 63 | +$entityManager = $db1->getEntityManager(); |
|
| 64 | 64 | |
| 65 | -foreach ( $results as $result ) { |
|
| 65 | +foreach ($results as $result) { |
|
| 66 | 66 | /** |
| 67 | 67 | */ |
| 68 | 68 | $id = $result ['ID']; |
@@ -71,65 +71,65 @@ discard block |
||
| 71 | 71 | $title = $result ['post_title']; |
| 72 | 72 | /** |
| 73 | 73 | */ |
| 74 | - $pesel = implode ( get_post_meta ( $id, 'pesel' ) ); |
|
| 74 | + $pesel = implode(get_post_meta($id, 'pesel')); |
|
| 75 | 75 | /** |
| 76 | 76 | */ |
| 77 | - $oddzid = implode ( get_post_meta ( $id, 'oddzial.ID' ) ); |
|
| 77 | + $oddzid = implode(get_post_meta($id, 'oddzial.ID')); |
|
| 78 | 78 | /** |
| 79 | 79 | */ |
| 80 | 80 | |
| 81 | - $numer_historii = implode ( get_post_meta ( $id, 'numer_ksiegi_glownej' ) ); |
|
| 81 | + $numer_historii = implode(get_post_meta($id, 'numer_ksiegi_glownej')); |
|
| 82 | 82 | /** |
| 83 | 83 | */ |
| 84 | - $data_kategoryzacji = implode ( get_post_meta ( $id, 'data_kategoryzacji' ) ); |
|
| 84 | + $data_kategoryzacji = implode(get_post_meta($id, 'data_kategoryzacji')); |
|
| 85 | 85 | /** |
| 86 | 86 | */ |
| 87 | - $kategoria_pacjenta = implode ( get_post_meta ( $id, 'kategoria_pacjenta' ) ); |
|
| 87 | + $kategoria_pacjenta = implode(get_post_meta($id, 'kategoria_pacjenta')); |
|
| 88 | 88 | /** |
| 89 | 89 | */ |
| 90 | - $aktywnosc_fizyczna = implode ( get_post_meta ( $id, '1_aktywnosc_fizyczna' ) ); |
|
| 90 | + $aktywnosc_fizyczna = implode(get_post_meta($id, '1_aktywnosc_fizyczna')); |
|
| 91 | 91 | /** |
| 92 | 92 | */ |
| 93 | - $higiena = implode ( get_post_meta ( $id, '2_higiena' ) ); |
|
| 93 | + $higiena = implode(get_post_meta($id, '2_higiena')); |
|
| 94 | 94 | /** |
| 95 | 95 | */ |
| 96 | - $odzywianie = implode ( get_post_meta ( $id, '3_odzywianie' ) ); |
|
| 96 | + $odzywianie = implode(get_post_meta($id, '3_odzywianie')); |
|
| 97 | 97 | /** |
| 98 | 98 | */ |
| 99 | - $wydalanie = implode ( get_post_meta ( $id, '4_wydalanie' ) ); |
|
| 99 | + $wydalanie = implode(get_post_meta($id, '4_wydalanie')); |
|
| 100 | 100 | /** |
| 101 | 101 | */ |
| 102 | - $pomiar_objawow_zyciowych = implode ( get_post_meta ( $id, '5_pomiar_objawow_zyciowych' ) ); |
|
| 102 | + $pomiar_objawow_zyciowych = implode(get_post_meta($id, '5_pomiar_objawow_zyciowych')); |
|
| 103 | 103 | /** |
| 104 | 104 | */ |
| 105 | - $leczenie = implode ( get_post_meta ( $id, '6_leczenie' ) ); |
|
| 105 | + $leczenie = implode(get_post_meta($id, '6_leczenie')); |
|
| 106 | 106 | /** |
| 107 | 107 | */ |
| 108 | - $edukacja_i_wsparcie_psychiczne = implode ( get_post_meta ( $id, '7_edukacja_i_wsparcie_psychiczne' ) ); |
|
| 108 | + $edukacja_i_wsparcie_psychiczne = implode(get_post_meta($id, '7_edukacja_i_wsparcie_psychiczne')); |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | */ |
| 112 | - $patient = new PatientZZ (); |
|
| 113 | - $patient->setName ( $title ); |
|
| 112 | + $patient = new PatientZZ(); |
|
| 113 | + $patient->setName($title); |
|
| 114 | 114 | if ($data_kategoryzacji == null) { |
| 115 | - $log->warn ( "Patient " . $id . " missing date. Omitting." ); |
|
| 115 | + $log->warn("Patient ".$id." missing date. Omitting."); |
|
| 116 | 116 | continue; |
| 117 | 117 | } |
| 118 | - $patient->setDataKategoryzacji ( \DateTime::createFromFormat ( "d-m-Y", $data_kategoryzacji ) ); |
|
| 119 | - $patient->setOddzialId ( $oddzid ); |
|
| 120 | - $patient->setNumerHistorii ( $numer_historii ); |
|
| 118 | + $patient->setDataKategoryzacji(\DateTime::createFromFormat("d-m-Y", $data_kategoryzacji)); |
|
| 119 | + $patient->setOddzialId($oddzid); |
|
| 120 | + $patient->setNumerHistorii($numer_historii); |
|
| 121 | 121 | |
| 122 | - $patient->setPesel ( $pesel ); |
|
| 123 | - $patient->setKategoriaPacjenta ( $kategoria_pacjenta ); |
|
| 124 | - $patient->setAktywnoscFizyczna ( $aktywnosc_fizyczna ); |
|
| 125 | - $patient->setHigiena ( $higiena ); |
|
| 126 | - $patient->setOdzywianie ( $odzywianie ); |
|
| 127 | - $patient->setWydalanie ( $wydalanie ); |
|
| 128 | - $patient->setPomiarObjawowZyciowych ( $pomiar_objawow_zyciowych ); |
|
| 129 | - $patient->setLeczenie ( $leczenie ); |
|
| 130 | - $patient->setEdukacjaIWsparciePsychiczne ( $edukacja_i_wsparcie_psychiczne ); |
|
| 122 | + $patient->setPesel($pesel); |
|
| 123 | + $patient->setKategoriaPacjenta($kategoria_pacjenta); |
|
| 124 | + $patient->setAktywnoscFizyczna($aktywnosc_fizyczna); |
|
| 125 | + $patient->setHigiena($higiena); |
|
| 126 | + $patient->setOdzywianie($odzywianie); |
|
| 127 | + $patient->setWydalanie($wydalanie); |
|
| 128 | + $patient->setPomiarObjawowZyciowych($pomiar_objawow_zyciowych); |
|
| 129 | + $patient->setLeczenie($leczenie); |
|
| 130 | + $patient->setEdukacjaIWsparciePsychiczne($edukacja_i_wsparcie_psychiczne); |
|
| 131 | 131 | |
| 132 | - $entityManager->persist ( $patient ); |
|
| 132 | + $entityManager->persist($patient); |
|
| 133 | 133 | } |
| 134 | -$entityManager->flush (); |
|
| 135 | -$log->info ( "Stop!" ); |
|
| 134 | +$entityManager->flush(); |
|
| 135 | +$log->info("Stop!"); |
|
@@ -70,16 +70,16 @@ discard block |
||
| 70 | 70 | protected $user; |
| 71 | 71 | |
| 72 | 72 | function __construct($args) { |
| 73 | - foreach ( $args as $key => $value ) { |
|
| 73 | + foreach ($args as $key => $value) { |
|
| 74 | 74 | if ($key == 'dataRaportu') { |
| 75 | - $value = new \DateTime ( $value ); |
|
| 75 | + $value = new \DateTime($value); |
|
| 76 | 76 | } |
| 77 | - call_user_func ( array ( |
|
| 77 | + call_user_func(array( |
|
| 78 | 78 | $this, |
| 79 | - 'set' . $key |
|
| 80 | - ), $value ); |
|
| 79 | + 'set'.$key |
|
| 80 | + ), $value); |
|
| 81 | 81 | } |
| 82 | - $this->dataPrzeslania = new \DateTime (); |
|
| 82 | + $this->dataPrzeslania = new \DateTime(); |
|
| 83 | 83 | echo '<h3><div class="alert alert-primary">Dziękuję za przesłanie raportu!</div></h3>'; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -111,12 +111,12 @@ discard block |
||
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | 113 | public function toString() { |
| 114 | - $txt = $this->getId (); |
|
| 115 | - $data = $this->getDataRaportu (); |
|
| 114 | + $txt = $this->getId(); |
|
| 115 | + $data = $this->getDataRaportu(); |
|
| 116 | 116 | if ($data instanceof \DateTime) { |
| 117 | - $txt .= $this->getDataRaportu ()->format ( "Y-m-d" ); |
|
| 117 | + $txt .= $this->getDataRaportu()->format("Y-m-d"); |
|
| 118 | 118 | } else { |
| 119 | - $txt .= $this->getDataRaportu (); |
|
| 119 | + $txt .= $this->getDataRaportu(); |
|
| 120 | 120 | } |
| 121 | 121 | return $txt; |
| 122 | 122 | } |