Example #1
0
 function Render($AParams)
 {
     global $RowDescr;
     $vBranchInfo = GetBranchInfo();
     $vWidths = array(35, 25, 5, 5);
     $vAligns = array('L', 'L', 'C', 'R');
     for ($i = 0; $i <= 20; $i++) {
         $vWidths[] = 10;
         $vAligns[] = 'R';
     }
     $vDB = GetDB();
     $vBegDate = $AParams['beg_date'];
     $vEndDate = $AParams['end_date'];
     $this->SetFont('arial_rus', '', 10);
     $vHeight = $this->FontSize * 1.5;
     $vWidth = $this->GetAreaWidth();
     $this->AddPage();
     $vX = $this->GetX();
     $vY = $this->GetY();
     $this->Cell($vWidth, $vHeight, iconv("utf8", "windows-1251", @$vBranchInfo['name']), '', 0, 'L');
     $this->SetXY($vX, $vY);
     $this->Cell($vWidth, $vHeight, 'Ф.57', '', 0, 'R');
     $this->Ln($vHeight);
     $this->Cell($vWidth, $vHeight, 'Дата создания: ' . iconv("utf8", "windows-1251", Date2ReadableLong(date('Y-m-d H:i:s'))), '', 0, 'L');
     $this->Ln($vHeight);
     $this->SetFont('arial', 'B', 12);
     $this->Cell($vWidth, $vHeight, 'СВЕДЕНИЯ О ТРАВМАХ, ОТРАВЛЕНИЯХ И НЕКОТОРЫХ ДРУГИХ ПОСЛЕДСТВИЯХ ВОЗДЕЙСТВИЯ ВНЕШНИХ ПРИЧИН', '', 0, 'C');
     $this->SetFont('arial_rus', '', 7);
     $this->Ln($vHeight);
     $this->Cell($vWidth, $vHeight, 'за период с ' . iconv("utf8", "windows-1251", Date2ReadableLong($vBegDate)) . ' г. по ' . iconv("utf8", "windows-1251", Date2ReadableLong($vEndDate)) . ' г.', '', 0, 'C');
     $this->Ln($vHeight * 2);
     $this->CellML($vWidths[0], $vHeight * 6, 'Травмы, отравления и некоторые другие последствия воздействия внешних причин', 'L', 'R');
     $this->CellML($vWidths[1], $vHeight * 6, 'Код по МКБ X пересмотра', 'L', 'R');
     $this->CellML($vWidths[2], $vHeight * 6, 'Пол', 'C', 'U');
     $this->CellML($vWidths[3], $vHeight * 6, '№ строки', 'C', 'U');
     $vX = $this->GetX();
     $vY = $this->GetY();
     $this->CellML($vWidths[4] * 12, $vHeight, 'У взрослых и подростков (18 лет и старше)', 'C', 'R');
     $this->CellML($vWidths[4] * 8, $vHeight, 'У детей (0 - 17 лет включительно)', 'C', 'R');
     $this->CellML($vWidths[24], $vHeight * 6, 'ВСЕГО', 'C', 'U');
     $this->SetXY($vX, $vY + $vHeight);
     $this->CellML($vWidths[4] * 5, $vHeight, 'связанные с производством', 'C', 'R');
     $this->CellML($vWidths[9] * 6, $vHeight, 'несвязанные с производством', 'C', 'R');
     $this->CellML($vWidths[15], $vHeight * 5, 'ИТОГО', 'C', 'U');
     $this->CellML($vWidths[16], $vHeight * 5, 'бытовые', 'C', 'U');
     $this->CellML($vWidths[17], $vHeight * 5, 'уличные', 'C', 'U');
     $this->CellML($vWidths[18] * 2, $vHeight * 2, 'транспорт-ные', 'C');
     $this->CellML($vWidths[20], $vHeight * 5, 'школьные', 'C', 'U');
     $this->CellML($vWidths[21], $vHeight * 5, 'спортивные', 'C', 'U');
     $this->CellML($vWidths[22], $vHeight * 5, 'прочие', 'C', 'U');
     $this->CellML($vWidths[22], $vHeight * 5, 'ИТОГО', 'C', 'U');
     $this->SetXY($vX, $vY + $vHeight * 2);
     $this->CellML($vWidths[4], $vHeight * 4, 'в промышлен-ности', 'C', 'U');
     $this->CellML($vWidths[5], $vHeight * 4, 'в сельском хозяйстве', 'C', 'U');
     $this->CellML($vWidths[6] * 2, $vHeight * 2, 'транспорт-ные', 'C', 'R');
     $this->CellML($vWidths[8], $vHeight * 4, 'прочие', 'C', 'U');
     $this->CellML($vWidths[9], $vHeight * 4, 'бытовые', 'C', 'U');
     $this->CellML($vWidths[10], $vHeight * 4, 'уличные', 'C', 'U');
     $this->CellML($vWidths[11] * 2, $vHeight * 2, 'транспорт-ные', 'C', 'R');
     $this->CellML($vWidths[13], $vHeight * 4, 'спортивные', 'C', 'U');
     $this->CellML($vWidths[14], $vHeight * 4, 'прочие', 'C', 'U');
     $this->SetXY($vX + $vWidths[4] * 2, $vY + $vHeight * 4);
     $this->CellML($vWidths[6], $vHeight * 2, 'всего', 'C', 'U');
     $this->CellML($vWidths[7], $vHeight * 2, 'авто', 'C', 'U');
     $this->SetXY($vX + $vWidths[4] * 7, $vY + $vHeight * 4);
     $this->CellML($vWidths[11], $vHeight * 2, 'всего', 'C', 'U');
     $this->CellML($vWidths[12], $vHeight * 2, 'авто', 'C', 'U');
     $this->SetXY($vX + $vWidths[4] * 14, $vY + $vHeight * 3);
     $this->CellML($vWidths[18], $vHeight * 3, 'всего', 'C', 'U');
     $this->CellML($vWidths[19], $vHeight * 3, 'авто', 'C', 'U');
     $this->Ln($vHeight * 3);
     $vCodeToRow =& PrepareCodeToRowMap();
     $vTable = 'emst_cases LEFT JOIN rb_trauma_types ON rb_trauma_types.id = emst_cases.trauma_type_id';
     $vFields = 'count(emst_cases.id) AS cnt, diagnosis_mkb, is_male, if( DATE_ADD( born_date, INTERVAL 18 YEAR ) > create_time, rb_trauma_types.f57_col_child, rb_trauma_types.f57_col_adult) as cols';
     $vFilter = $vDB->CondGE('create_time', $vBegDate) . ' AND ' . $vDB->CondLT('create_time', DateAddDay($vEndDate)) . '  GROUP BY diagnosis_mkb, is_male, cols';
     $vOrder = '';
     $vRecords = $vDB->Select($vTable, $vFields, $vFilter, $vOrder);
     $vBadCodes = array();
     $vReport = array();
     while ($vRecord = $vRecords->Fetch()) {
         if ($vRecord['diagnosis_mkb'] === NULL || $vRecord['is_male'] === NULL || $vRecord['cols'] === NULL) {
             continue;
         }
         $vCode = str_replace(' ', '', $vRecord['diagnosis_mkb']);
         if ($vCode == '') {
             continue;
         }
         if (preg_match('/^[A-Z][0-9][0-9]$/i', $vCode)) {
             $vCode = $vCode . '.0';
         } else {
             if (preg_match('/^[A-Z][0-9][0-9]\\.[0-9].*$/i', $vCode)) {
                 $vCode = substr($vCode, 0, 5);
             }
         }
         if (empty($vCodeToRow[$vCode])) {
             $vBadCodes[$vRecord['diagnosis_mkb']] = $vRecord['diagnosis_mkb'];
             continue;
         }
         $vRowIndexes = $vCodeToRow[$vCode];
         $vIsMale = $vRecord['is_male'] ? 1 : 0;
         $vCols = explode(',', $vRecord['cols']);
         foreach ($vCols as $vCol) {
             $vColIdx = trim($vCol);
             foreach ($vRowIndexes as $vRowIndex) {
                 $vReport[$vRowIndex][$vIsMale][$vColIdx] = $vRecord['cnt'] + @$vReport[$vRowIndex][$vIsMale][$vColIdx];
             }
         }
     }
     $vRowNum = 0;
     for ($i = 0; $i < count($RowDescr); $i++) {
         $vRow = array($RowDescr[$i]['title'], $RowDescr[$i]['codes'], 'М', ++$vRowNum);
         for ($j = 0; $j <= 20; $j++) {
             $vRow[] = @$vReport[$i][1][$j];
         }
         $this->OutputTableRow($vWidths, $vHeight, $vRow, $vAligns);
         $vRow = array('', '', 'Ж', ++$vRowNum);
         for ($j = 0; $j <= 20; $j++) {
             $vRow[] = @$vReport[$i][0][$j];
         }
         $this->OutputTableRow($vWidths, $vHeight, $vRow, $vAligns);
     }
     if (@$AParams['show_unlisted_cases']) {
         $vTable = 'emst_cases';
         $vFields = 'id, diagnosis_mkb, trauma_type_id, born_date';
         $vFilter = $vDB->CondGE('create_time', $vBegDate) . ' AND ' . $vDB->CondLT('create_time', DateAddDay($vEndDate)) . ' AND (' . $vDB->CondIn('diagnosis_mkb', $vBadCodes) . ' OR diagnosis_mkb IS NULL' . ' OR trauma_type_id IS NULL' . ' OR born_date IS NULL' . ' OR born_date = 0000-00-00' . ')';
         $vOrder = 'id';
         $vRecords = $vDB->Select($vTable, $vFields, $vFilter, $vOrder);
         if ($vRecords->Count() > 0) {
             $this->AddPage();
             $this->Cell(30, $vHeight, '№ по порядку', 1, 0, 'R');
             $this->Cell(30, $vHeight, '№ истории', 1, 0, 'R');
             $this->Cell(180, $vHeight, 'причина', 1, 0, 'L');
             $this->Ln($vHeight);
             $i = 0;
             while ($vRecord = $vRecords->Fetch()) {
                 $vMessage = array();
                 $vCode = str_replace(' ', '', $vRecord['diagnosis_mkb']);
                 if ($vCode != '' && !(preg_match('/^[A-Z][0-9][0-9](\\.[0-9])?$/i', $vCode) && $vCode >= 'S00' && $vCode <= 'T98.9')) {
                     $vMessage[] = 'Код МКБ "' . $vRecord['diagnosis_mkb'] . '"';
                 }
                 if ($vRecord['trauma_type_id'] === NULL || $vRecord['trauma_type_id'] === '') {
                     $vMessage[] = 'не указан тип травмы';
                 }
                 if ($vRecord['born_date'] === NULL || $vRecord['born_date'] === '' || $vRecord['born_date'] === '0000-00-00') {
                     $vMessage[] = 'дата рождения не указана';
                 }
                 $this->Cell(30, $vHeight, ++$i, 1, 0, 'R');
                 $this->Cell(30, $vHeight, $vRecord['id'], 1, 0, 'R');
                 $this->Cell(180, $vHeight, implode(', ', $vMessage), 1, 0, 'L');
                 $this->Ln($vHeight);
             }
         }
     }
 }
Example #2
0
 function Render($AParams)
 {
     global $RowDescr;
     $vBranchInfo = GetBranchInfo();
     $vWidths = array(40, 35, 5, 5);
     $vAligns = array('L', 'L', 'C', 'R');
     for ($i = 0; $i < 12; $i++) {
         $vWidths[] = 16;
         $vAligns[] = 'R';
     }
     $vDB = GetDB();
     $vBegDate = $AParams['beg_date'];
     $vEndDate = $AParams['end_date'];
     $this->SetFont('arial_rus', '', 10);
     $vHeight = $this->FontSize * 1.5;
     $vWidth = $this->GetAreaWidth();
     $this->AddPage();
     $vX = $this->GetX();
     $vY = $this->GetY();
     $this->Cell($vWidth, $vHeight, iconv("utf8", "windows-1251", @$vBranchInfo['name']), '', 0, 'L');
     $this->SetXY($vX, $vY);
     $this->Cell($vWidth, $vHeight, 'Ф.16ВН', '', 0, 'R');
     $this->Ln($vHeight);
     $this->Cell($vWidth, $vHeight, 'Дата создания: ' . iconv("utf8", "windows-1251", Date2ReadableLong(date('Y-m-d H:i:s'))), '', 0, 'L');
     $this->Ln($vHeight);
     $this->SetFont('arial', 'B', 12);
     $this->Cell($vWidth, $vHeight, 'СВЕДЕНИЯ О ТРАВМАХ, ОТРАВЛЕНИЯХ И НЕКОТОРЫХ ДРУГИХ ПОСЛЕДСТВИЯХ ВОЗДЕЙСТВИЯ ВНЕШНИХ ПРИЧИН', '', 0, 'C');
     $this->SetFont('arial_rus', '', 10);
     $this->Ln($vHeight);
     $this->Cell($vWidth, $vHeight, 'за период с ' . iconv("utf8", "windows-1251", Date2ReadableLong($vBegDate)) . ' г. по ' . iconv("utf8", "windows-1251", Date2ReadableLong($vEndDate)) . ' г.', '', 0, 'C');
     $this->Ln($vHeight * 2);
     $this->CellML($vWidths[0], $vHeight * 3, 'Причина нетрудоспособности', 'L', 'R');
     $this->CellML($vWidths[1], $vHeight * 3, 'Код по МКБ X пересмотра', 'L', 'R');
     $this->CellML($vWidths[2], $vHeight * 3, 'Пол', 'C', 'U');
     $this->CellML($vWidths[3], $vHeight * 3, '№ строки', 'C', 'U');
     $this->CellML($vWidths[4], $vHeight * 3, 'Число дней', 'C', 'R');
     $this->CellML($vWidths[5], $vHeight * 3, 'Число случаев', 'C', 'R');
     $vX = $this->GetX();
     $vY = $this->GetY();
     $this->CellML($vWidths[6] * 10, $vHeight, 'В том числе по возрастам', 'C', 'R');
     $this->SetXY($vX, $vY + $vHeight);
     $this->CellML($vWidths[6], $vHeight * 2, '15-19', 'C', 'R');
     $this->CellML($vWidths[7], $vHeight * 2, '20-24', 'C', 'R');
     $this->CellML($vWidths[8], $vHeight * 2, '25-29', 'C', 'R');
     $this->CellML($vWidths[9], $vHeight * 2, '30-34', 'C', 'R');
     $this->CellML($vWidths[10], $vHeight * 2, '35-39', 'C', 'R');
     $this->CellML($vWidths[11], $vHeight * 2, '40-44', 'C', 'R');
     $this->CellML($vWidths[12], $vHeight * 2, '45-49', 'C', 'R');
     $this->CellML($vWidths[13], $vHeight * 2, '50-54', 'C', 'R');
     $this->CellML($vWidths[14], $vHeight * 2, '55-69', 'C', 'R');
     $this->CellML($vWidths[15], $vHeight * 2, '60 и старше', 'C', 'R');
     $this->Ln($vHeight * 2);
     $vCodeToRow =& PrepareCodeToRowMap();
     /*
             SELECT 
               emst_cases.id as id,
               emst_cases.create_time,
               emst_cases.born_date, 
               emst_cases.is_male, 
               DATEDIFF( max(emst_surgeries.ill_end_date), 
                         emst_cases.disability_from_date
                       ) as days,
               emst_cases.diagnosis_mkb
             FROM
               emst_cases 
               JOIN emst_surgeries ON emst_surgeries.case_id = emst_cases.id
             WHERE 
               emst_surgeries.disability=2 AND 
               emst_surgeries.ill_end_date != '0000-00-00' AND
               emst_cases.disability_from_date != '0000-00-00' AND
               emst_cases.create_time >= '2006-01-01' AND
               emst_cases.create_time < '2007-01-01'
             GROUP BY
               emst_cases.id  
     */
     $vTable = 'emst_cases JOIN emst_surgeries ON emst_surgeries.case_id = emst_cases.id';
     $vFields = 'emst_cases.id as id, emst_cases.create_time, emst_cases.born_date, emst_cases.is_male, DATEDIFF( max(emst_surgeries.ill_end_date), emst_cases.disability_from_date) as days, emst_cases.diagnosis_mkb';
     $vFilterParts = array();
     $vFilterParts[] = 'emst_surgeries.disability=2';
     $vFilterParts[] = "emst_surgeries.ill_end_date != '0000-00-00'";
     $vFilterParts[] = "emst_cases.disability_from_date != '0000-00-00'";
     $vFilterParts[] = $vDB->CondGE('create_time', $vBegDate);
     $vFilterParts[] = $vDB->CondLT('create_time', DateAddDay($vEndDate));
     $vFilter = implode(' AND ', $vFilterParts) . ' GROUP BY emst_cases.id';
     $vOrder = '';
     $vRecords = $vDB->Select($vTable, $vFields, $vFilter, $vOrder);
     $vBadCodes = array();
     $vReport = array();
     while ($vRecord = $vRecords->Fetch()) {
         if ($vRecord['diagnosis_mkb'] === NULL || $vRecord['is_male'] === NULL) {
             continue;
         }
         $vCode = str_replace(' ', '', $vRecord['diagnosis_mkb']);
         if ($vCode == '') {
             continue;
         }
         if (preg_match('/^[A-Z][0-9][0-9]$/i', $vCode)) {
             $vCode = $vCode . '.0';
         } else {
             if (preg_match('/^[A-Z][0-9][0-9]\\.[0-9].*$/i', $vCode)) {
                 $vCode = substr($vCode, 0, 5);
             }
         }
         if (empty($vCodeToRow[$vCode])) {
             $vBadCodes[$vRecord['diagnosis_mkb']] = $vRecord['diagnosis_mkb'];
             continue;
         }
         $vRowIndexes = $vCodeToRow[$vCode];
         $vIsMale = $vRecord['is_male'] ? 1 : 0;
         $vAge = CalcAge($vRecord['born_date'], $vRecord['create_time']);
         $vAgeColIndex = AgeToColIndex($vAge);
         if ($vAgeColIndex > 0) {
             foreach ($vRowIndexes as $vRowIndex) {
                 $vReport[$vRowIndex][$vIsMale][0] = $vRecord['days'] + 1 + @$vReport[$vRowIndex][$vIsMale][0];
                 $vReport[$vRowIndex][$vIsMale][1] = 1 + @$vReport[$vRowIndex][$vIsMale][1];
                 $vReport[$vRowIndex][$vIsMale][$vAgeColIndex + 2] = 1 + @$vReport[$vRowIndex][$vIsMale][$vAgeColIndex + 2];
             }
         }
     }
     $vRowNum = 0;
     for ($i = 0; $i < count($RowDescr); $i++) {
         $vRow = array($RowDescr[$i]['title'], $RowDescr[$i]['codes'], 'М', ++$vRowNum);
         for ($j = 0; $j <= 20; $j++) {
             $vRow[] = @$vReport[$i][1][$j];
         }
         $this->OutputTableRow($vWidths, $vHeight, $vRow, $vAligns);
         $vRow = array('', '', 'Ж', ++$vRowNum);
         for ($j = 0; $j <= 20; $j++) {
             $vRow[] = @$vReport[$i][0][$j];
         }
         $this->OutputTableRow($vWidths, $vHeight, $vRow, $vAligns);
     }
     /*
             if ( @$AParams['show_unlisted_cases'] )
             {
                 $vTable  = 'emst_cases';
                 $vFields = 'id, diagnosis_mkb, trauma_type_id, born_date';
                 $vFilter = $vDB->CondGE('create_time', $vBegDate) .
                            ' AND '.
                            $vDB->CondLT('create_time', DateAddDay($vEndDate)).
                            ' AND ('.
                              $vDB->CondIn('diagnosis_mkb', $vBadCodes).
                               ' OR diagnosis_mkb IS NULL'.
                               ' OR trauma_type_id IS NULL'.
                               ' OR born_date IS NULL'.
                               ' OR born_date = 0000-00-00'.
                               ')';
     
                 $vOrder  = 'id';
                 $vRecords= $vDB->Select($vTable, $vFields, $vFilter, $vOrder);
                 if ( $vRecords->Count() > 0 )
                 {
                     $this->AddPage();
                     $this->Cell(30, $vHeight,  '№ по порядку', 1, 0, 'R');
                     $this->Cell(30, $vHeight,  '№ истории', 1, 0, 'R');
                     $this->Cell(180, $vHeight, 'причина', 1, 0, 'L');
                     $this->Ln($vHeight);
     
                     $i = 0;
                     while ( $vRecord = $vRecords->Fetch() )
                     {
                        $vMessage = array();
                        $vCode = str_replace(' ', '', $vRecord['diagnosis_mkb']);
                        if ( $vCode != '' &&
                             !( preg_match('/^[A-Z][0-9][0-9](\.[0-9])?$/i', $vCode) &&
                                $vCode>='S00' &&
                                $vCode<='T98.9'
                              )   
                           )
                        {
                           $vMessage[] = 'Код МКБ "'.$vRecord['diagnosis_mkb'].'"';
                        }
                        if ( $vRecord['trauma_type_id'] === NULL || $vRecord['trauma_type_id'] === '' )
                           $vMessage[] = 'не указан тип травмы';
                        if ( $vRecord['born_date'] === NULL || $vRecord['born_date'] === '' || $vRecord['born_date'] === '0000-00-00' )
                           $vMessage[] = 'дата рождения не указана';
     
                        $this->Cell(30, $vHeight, ++$i, 1, 0, 'R');
                        $this->Cell(30, $vHeight, $vRecord['id'], 1, 0, 'R');
                        $this->Cell(180, $vHeight, implode(', ', $vMessage), 1, 0, 'L');
                        $this->Ln($vHeight);
                     }
                 }
             }
     */
 }