Exemplo n.º 1
0
function ConstructCaseQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_cases';
    $vCaseID = @$AParams['case_id'];
    if (!empty($vCaseID)) {
        $vFilter[] = $ADB->CondEqual('id', $vCaseID);
    }
    AddQueryParamLike($ADB, $vFilter, $AParams, 'first_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'last_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'patr_name');
    if (array_key_exists('paytype', $AParams) && $AParams['paytype'] >= 0) {
        $vFilter[] = $ADB->CondEqual('paytype', $AParams['paytype']);
    }
    if (array_key_exists('beg_date', $AParams) && IsValidDate($AParams['beg_date'])) {
        $vFilter[] = $ADB->CondGE('create_time', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams) && IsValidDate($AParams['end_date'])) {
        $vFilter[] = $ADB->CondLT('create_time', DateAddDay($AParams['end_date']));
    }
    if (array_key_exists('doctor_id', $AParams) && !empty($AParams['doctor_id'])) {
        $vFilter[] = 'id IN (SELECT case_id FROM emst_surgeries WHERE ' . $ADB->CondEqual('user_id', $AParams['doctor_id']) . ')';
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_cases.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 2
0
function ConstructCaseQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_cases ' . ' LEFT JOIN emst_surgeries   ON emst_cases.id = emst_surgeries.case_id';
    $vFilter[] = 'emst_cases.paytype = 1';
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('create_time', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('create_time', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_cases.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 3
0
function ConstructQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_surgeries';
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('date', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    //        $vFilter = '(case_id = 11619) or (case_id = 11591)';
    $vOrder = 'case_id, date, id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 4
0
function ConstructCaseQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_cases LEFT JOIN rb_antitetanus ON emst_cases.antitetanus_id = rb_antitetanus.id';
    $vFilter[] = $ADB->CondIsNotNull('antitetanus_id');
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('create_time', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('create_time', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_cases.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 5
0
function ConstructCaseQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_surgeries ' . ' JOIN emst_cases ON emst_surgeries.case_id = emst_cases.id';
    $vFilter[] = $ADB->CondEqual('emst_surgeries`.`is_cec', 1);
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('emst_surgeries`.`date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('emst_surgeries`.`date', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_surgeries.cec_number, emst_surgeries.date, emst_surgeries.case_id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 6
0
function ConstructCaseQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_cases';
    $vFilter[] = 'ice_trauma != 0';
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('create_time', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('create_time', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_cases.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 7
0
function ConstructQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_cases LEFT JOIN rb_vistit_targets ON rb_vistit_targets.id=emst_cases.next_visit_target_id';
    //        if ( array_key_exists('case_id', $AParams) )
    //           $vFilter[] = $ADB->CondEqual('case_id', $AParams['case_id']);
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('next_visit_date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('next_visit_date', DateAddDay($AParams['end_date']));
    }
    $vFilter[] = 'emst_cases.id IN (SELECT case_id FROM emst_rg)';
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'rb_vistit_targets.name, emst_cases.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 8
0
function ConstructQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_rg ' . ' LEFT JOIN emst_cases ON emst_rg.case_id = emst_cases.id';
    if (array_key_exists('case_id', $AParams)) {
        $vFilter[] = $ADB->CondEqual('case_id', $AParams['case_id']);
    }
    if (array_key_exists('beg_date', $AParams)) {
        $vFilter[] = $ADB->CondGE('date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams)) {
        $vFilter[] = $ADB->CondLT('date', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'date, case_id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 9
0
function ConstructSurgeriesQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_surgeries ' . '  LEFT JOIN emst_cases ON emst_surgeries.case_id = emst_cases.id' . '  LEFT JOIN rb_employment_categories ON rb_employment_categories.id = emst_cases.employment_category_id' . '  LEFT JOIN rb_clinical_outcomes     ON emst_surgeries.clinical_outcome_id = rb_clinical_outcomes.id';
    $vFilter[] = '(emst_surgeries.disability=2 OR ' . '  (emst_surgeries.disability=0 AND rb_employment_categories.need_ill_doc!=0))';
    $vFilter[] = 'emst_surgeries.ill_refused=0';
    $vFilter[] = 'ill_sertificat=0';
    $vFilter[] = '(emst_surgeries.clinical_outcome_id IS NULL OR rb_clinical_outcomes.can_skip_ill_doc_on_disability=0)';
    $vFilter[] = 'emst_cases.disability_from_date = DATE(emst_surgeries.date)';
    if (array_key_exists('beg_date', $AParams) && IsValidDate($AParams['beg_date'])) {
        $vFilter[] = $ADB->CondGE('date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams) && IsValidDate($AParams['end_date'])) {
        $vFilter[] = $ADB->CondLT('date', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_surgeries.date, emst_surgeries.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 10
0
function ConstructCaseQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_cases';
    $vCaseID = @$AParams['case_id'];
    if (!empty($vCaseID)) {
        $vFilter[] = $ADB->CondEqual('id', $vCaseID);
    }
    $vFilter[] = $ADB->CondEqual('next_visit_date', $ADB->ConvertToDate(time()));
    AddQueryParamLike($ADB, $vFilter, $AParams, 'first_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'last_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'patr_name');
    if (array_key_exists('beg_date', $AParams) && IsValidDate($AParams['beg_date'])) {
        $vFilter[] = $ADB->CondGE('create_time', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams) && IsValidDate($AParams['end_date'])) {
        $vFilter[] = $ADB->CondLT('create_time', DateAddDay($AParams['end_date']));
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_cases.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 11
0
function ConstructSurgeriesQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_surgeries LEFT JOIN emst_cases ON emst_cases.id=emst_surgeries.case_id';
    $vCaseID = @$AParams['case_id'];
    if (!empty($vCaseID)) {
        $vFilter[] = $ADB->CondEqual('case_id', $vCaseID);
    }
    AddQueryParamLike($ADB, $vFilter, $AParams, 'first_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'last_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'patr_name');
    if (array_key_exists('beg_date', $AParams) && IsValidDate($AParams['beg_date'])) {
        $vFilter[] = $ADB->CondGE('date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams) && IsValidDate($AParams['end_date'])) {
        $vFilter[] = $ADB->CondLT('date', DateAddDay($AParams['end_date']));
    }
    if (array_key_exists('doctor_id', $AParams) && !empty($AParams['doctor_id'])) {
        $vFilter[] = $ADB->CondEqual('user_id', $AParams['doctor_id']);
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_surgeries.case_id, emst_surgeries.date, emst_surgeries.id';
    return array($vTable, $vFilter, $vOrder);
}
Exemplo n.º 12
0
 function DrawLine($ACEC)
 {
     $vBranchInfo = GetBranchInfo();
     $vHeight = $this->FontSize * 1.5;
     $vRowData = array();
     $vCECDate = ExtractWord($ACEC['date'], ' ', 0);
     $vCaseID = $ACEC['case_id'];
     $vNumCECesBefore = GetNumCECes($vCaseID, $vCECDate, $ACEC['id']);
     $vCECNumber = $ACEC['cec_number'];
     if ($vCECNumber == 0) {
         $vCECNumber = '';
     }
     $vRowData[] = $vCECNumber . "\n(" . ($vNumCECesBefore + 1) . ')';
     //   'Дата',
     $vRowData[] = Date2Readable($vCECDate);
     //   'Врач',
     $vRowData[] = FormatUserName($ACEC['user_id']);
     //   'Ф.И.О. больного' & 'Дата рождения'
     //            $vRowData[] = FormatName($ACEC['last_name'], $ACEC['first_name'],$ACEC['patr_name'])
     $vRowData[] = FormatNameEx($ACEC) . "\n" . FormatBornDateAndAge($vCECDate, $ACEC['born_date']) . "\nи.б. " . $vCaseID;
     //            $vRowData[] = FormatSex($ACase['is_male']);
     //   'Адрес',
     $vRowData[] = FormatAddress($ACEC['addr_reg_street'], $ACEC['addr_reg_num'], $ACEC['addr_reg_subnum'], $ACEC['addr_reg_apartment']);
     //            $vRowData[] = $ACase['phone'];
     //   'Место работы' & 'Профессия'
     $vTmpList = array();
     $vTmp = FormatWorkableAge($vCECDate, $ACEC['born_date'], $ACEC['is_male']);
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vTmp = FormatCategory($ACEC['employment_category_id']);
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vTmp = $ACEC['employment_place'];
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vTmp = $ACEC['profession'];
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vRowData[] = implode(",\n", $vTmpList);
     //   'Диагноз',
     $vRowData[] = $ACEC['diagnosis'];
     //   '№ листка нетрудоспособности',
     $vTmp = $ACEC['ill_doc'];
     if (!empty($vTmp)) {
         $vTmp .= "\n" . Date2Readable($ACEC['disability_from_date']);
         $vTmp .= "\n" . Date2Readable($vCECDate);
         $vTmp .= "\n(" . (DateDiff($vCECDate, $ACEC['disability_from_date']) + 1) . ')';
     }
     $vRowData[] = $vTmp;
     //   'Заключение комиссии'
     $vRowData[] = "лечение продлено\nс " . Date2Readable(DateAddDay($vCECDate)) . "\nпо " . Date2Readable($ACEC['cec_cureup_date']) . "\n(" . DateDiff($ACEC['cec_cureup_date'], $vCECDate) . ')';
     //   'Подписи членов комиссии'
     $vTmp = $ACEC['cec_members'];
     if (empty($vTmp)) {
         $vTmp = $vBranchInfo['cec_members'];
     }
     $vRowData[] = $vTmp;
     foreach ($vRowData as &$v) {
         $v = iconv('utf-8', 'cp1251', $v);
     }
     $this->OutTableRow($vHeight, $vRowData);
 }
Exemplo n.º 13
0
 function &loadDefaults()
 {
     global $gAddTodaySugrery;
     $vDB = GetDB();
     $vID = @$_GET['id'];
     if (!empty($vID)) {
         $vBaseInfo = $vDB->GetById('emst_cases', $vID);
         if (!is_array($vBaseInfo)) {
             $vBaseInfo = array();
         }
     } else {
         $vBaseInfo = array();
         $vBaseInfo['create_time'] = $vDB->ConvertToDateTime(time());
         $vBaseInfo['next_visit_date'] = $vDB->ConvertToDate(time());
         CopyRecordStrValue($vBaseInfo, $_GET, 'first_name');
         CopyRecordStrValue($vBaseInfo, $_GET, 'last_name');
         CopyRecordStrValue($vBaseInfo, $_GET, 'patr_name');
     }
     $vResult = array();
     $vResult['BaseInfo'] =& $vBaseInfo;
     if (!empty($vID)) {
         $vSurgeries =& $vDB->SelectList('emst_surgeries', '*', $vDB->CondEqual('case_id', $vID), 'date, id');
         // order
     } else {
         $vSurgeries = array();
     }
     $vNow = $vDB->ConvertToDateTime(time());
     $vToday = ExtractWord($vNow, ' ', 0);
     $vCount = count($vSurgeries);
     if ($gAddTodaySugrery && ($vCount == 0 || ExtractWord($vSurgeries[$vCount - 1]['date'], ' ', 0) != $vToday)) {
         $vSurgeries[] = array('date' => $vNow);
         if ($vCount == 0) {
             if (@DateIsEmpty($vBaseInfo['accident_datetime'])) {
                 $vBaseInfo['accident_datetime'] = $vToday;
             }
             $vBaseInfo['disability_from_date'] = $vToday;
             $vSurgeries[$vCount]['objective'] = 'Общее состояние удовлетворительное';
         } else {
             CopyValues($vSurgeries[$vCount], $vSurgeries[$vCount - 1], array('complaints', 'dynamic_id', 'diagnosis', 'diagnosis_mkb', 'disability', 'ill_refused', 'ill_sertificat', 'ill_doc', 'ill_doc_is_continue', 'ill_beg_date', 'ill_end_date', 'next_cec_date'));
             if (!empty($vSurgeries[$vCount - 1]['ill_doc_new'])) {
                 $vSurgeries[$vCount]['ill_doc'] = $vSurgeries[$vCount - 1]['ill_doc_new'];
                 $vSurgeries[$vCount]['ill_doc_is_continue'] = true;
             }
             if ($vSurgeries[$vCount - 1]['ill_end_date'] == $vToday) {
                 $vSurgeries[$vCount]['ill_beg_date'] = DateAddDay($vSurgeries[$vCount - 1]['ill_end_date']);
                 $vSurgeries[$vCount]['ill_end_date'] = '';
             }
             $vObjectiveList = array();
             $vClinicalOutcomeID = $vSurgeries[$vCount - 1]['clinical_outcome_id'];
             if (!empty($vClinicalOutcomeID)) {
                 $vList = GetClinicalOutcomesList();
                 $vObjectiveList[] = 'На предыдущем приёме был установлен исход "' . $vList[$vClinicalOutcomeID] . '". явку объясняет тем, что ... ';
             }
             $vNextVisitDate = $vSurgeries[$vCount - 1]['next_visit_date'];
             if ($vNextVisitDate != '0000-00-00' && $vNextVisitDate < $vToday) {
                 $vObjectiveList[] = 'На приём ' . Date2ReadableLong($vNextVisitDate) . " не явился, объясняет это тем, что ... ";
             }
             $vObjectiveList[] = 'Общее состояние удовлетворительное';
             $vSurgeries[$vCount]['objective'] = implode(".\n", $vObjectiveList);
             CopyValues($vSurgeries[$vCount], $vSurgeries[$vCount - 1], array('cure'));
             /*
                                 CopyValues($vSurgeries[$vCount],
                                            $vSurgeries[$vCount-1],
                                            array('objective',  'cure', 'notes'));
             */
             for ($i = $vCount - 1; $i >= 0; $i--) {
                 if ($vSurgeries[$i]['is_cec']) {
                     $vSurgeries[$vCount]['next_cec_date'] = $vSurgeries[$i]['cec_cureup_date'];
                     break;
                 }
             }
             if ($vSurgeries[$vCount - 1]['next_cec_date'] == $vToday) {
                 $vSurgeries[$vCount]['is_cec'] = 1;
             }
         }
         $vSurgeries[$vCount]['user_id'] = $_SESSION['User.ID'];
     }
     $vCount = count($vSurgeries);
     $vResult['surgeries'] =& $vSurgeries;
     for ($i = 0; $i < $vCount; $i++) {
         $vResult[DatePageName($i)] =& $vSurgeries[$i];
     }
     //            CopyValues($vSurgeries[0], $vBaseInfo, array('accident', 'accident_datetime', 'accident_place', 'antitetanus_id', 'antitetanus_series', 'phone_message_required', 'ice_trauma', 'animal_bite_trauma', 'ixodes_trauma', 'message_number', 'diagnosis', 'diagnosis_mkb', 'disability_from_date'));
     if ($vCount > 0) {
         CopyValues($vSurgeries[0], $vBaseInfo, array('accident', 'accident_datetime', 'accident_place', 'antitetanus_id', 'antitetanus_series', 'phone_message_required', 'ice_trauma', 'animal_bite_trauma', 'ixodes_trauma', 'message_number', 'disability_from_date'));
     }
     $vResult['MiscDocs']['studinfo_freed_beg_date'] = @$vBaseInfo['create_time'];
     $vResult['MiscDocs']['studinfo_freed_end_date'] = $vToday;
     $vResult['html_referer'] = $_SESSION['PrevPage'];
     return $vResult;
 }
Exemplo n.º 14
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);
             }
         }
     }
 }
Exemplo n.º 15
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);
                     }
                 }
             }
     */
 }
Exemplo n.º 16
0
 function Render($AParams)
 {
     $vWidths = array(50, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20);
     $vAligns = array('L', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R');
     $vDB = GetDB();
     $vBegDate = $AParams['beg_date'];
     $vEndDate = $AParams['end_date'];
     $vPayType = $AParams['paytype'];
     $this->SetFont('arial_rus', '', 10);
     $vHeight = $this->FontSize * 1.5;
     $vWidth = $this->GetAreaWidth();
     $this->AddPage();
     $this->Cell($vWidth, $vHeight, iconv('utf-8', 'cp1251', 'Отчет по явкам'), '', 0, 'C');
     $this->Ln($vHeight);
     $this->Cell($vWidth, $vHeight, iconv('utf-8', 'cp1251', 'за период с ') . iconv('utf-8', 'cp1251', Date2ReadableLong($vBegDate)) . iconv('utf-8', 'cp1251', ' г. по ') . iconv('utf-8', 'cp1251', Date2ReadableLong($vEndDate)) . iconv('utf-8', 'cp1251', ' г.'), '', 0, 'C');
     $this->Ln($vHeight * 2);
     $vTable = 'emst_surgeries' . '  LEFT JOIN emst_cases ON emst_surgeries.case_id=emst_cases.id' . '  LEFT JOIN users      ON emst_surgeries.user_id=users.id' . '  LEFT JOIN rb_employment_categories ON emst_cases.employment_category_id = rb_employment_categories.id' . '  LEFT JOIN rb_clinical_outcomes     ON emst_surgeries.clinical_outcome_id = rb_clinical_outcomes.id';
     $vFields = 'emst_surgeries.user_id as user_id,' . 'users.full_name as full_name,' . '(DATE(emst_surgeries.date)=DATE(emst_cases.create_time)) as is_primary,' . '(emst_cases.doc_series="" OR emst_cases.doc_number="" OR emst_cases.polis_series="" OR emst_cases.polis_number="") as is_bad_doc,' . gSurgeryWithBadIllDoc . ' as is_bad_illdoc,' . gLostOutcome . ' as is_lost_outcome,' . 'emst_surgeries.eisoms_status as eisoms_status,' . 'count(emst_surgeries.id) as surgeries_count';
     $vFilter = $vDB->CondGE('date', $vBegDate) . ' AND ' . $vDB->CondLT('date', DateAddDay($vEndDate)) . ' AND ' . $vDB->CondEqual('paytype', $vPayType) . '  GROUP BY emst_surgeries.user_id, is_primary, is_bad_doc, eisoms_status, is_bad_illdoc, is_lost_outcome';
     $vOrder = 'users.full_name';
     $vReport = array();
     $vRecords = $vDB->Select($vTable, $vFields, $vFilter, $vOrder);
     while ($vRecord = $vRecords->Fetch()) {
         $vUserID = '_' . @$vRecord['user_id'];
         if (empty($vReport[$vUserID])) {
             $vReport[$vUserID] = array('name' => $vRecord['full_name']);
         }
         $vReportLine =& $vReport[$vUserID];
         $vColName = 'Col' . $vRecord['is_primary'] . $vRecord['is_bad_doc'];
         $vReportLine[$vColName] = @$vReportLine[$vColName] + $vRecord['surgeries_count'];
         $vColName = 'IllDoc' . $vRecord['is_bad_illdoc'];
         $vReportLine[$vColName] = @$vReportLine[$vColName] + $vRecord['surgeries_count'];
         $vColName = 'IsLostOutcome' . $vRecord['is_lost_outcome'];
         $vReportLine[$vColName] = @$vReportLine[$vColName] + $vRecord['surgeries_count'];
         $vColName = 'EISOMSStatus' . $vRecord['eisoms_status'];
         $vReportLine[$vColName] = @$vReportLine[$vColName] + $vRecord['surgeries_count'];
     }
     $vTotalCol00 = 0;
     $vTotalCol01 = 0;
     $vTotalCol10 = 0;
     $vTotalCol11 = 0;
     $vTotalIllDoc1 = 0;
     $vTotalIsLostOutcome1 = 0;
     $vTotalEISOMSStatus0 = 0;
     $vTotalEISOMSStatus1 = 0;
     $vTotalEISOMSStatus2 = 0;
     $vRowData = array(iconv('utf-8', 'cp1251', 'Врач'), iconv('utf-8', 'cp1251', 'Первичные'), iconv('utf-8', 'cp1251', 'в т.ч. с ошибками в документах'), iconv('utf-8', 'cp1251', 'Повторные'), iconv('utf-8', 'cp1251', 'в т.ч. с ошибками в документах'), iconv('utf-8', 'cp1251', 'всего'), iconv('utf-8', 'cp1251', 'в т.ч. с ошибками в документах'), iconv('utf-8', 'cp1251', 'с ошибками в б/л'), iconv('utf-8', 'cp1251', 'Без указания исхода'), iconv('utf-8', 'cp1251', 'ЕИС ОМС: не отпр.'), iconv('utf-8', 'cp1251', 'ЕИС ОМС: ошибки'), iconv('utf-8', 'cp1251', 'ЕИС ОМС: приняты'));
     $this->OutputTableRow($vWidths, $vHeight, $vRowData, $vAligns);
     foreach ($vReport as $vUserID => $vUserData) {
         $vName = iconv('utf-8', 'cp1251', $vUserData['name']);
         $vCol00 = @$vUserData['Col00'];
         // повторные, нормальные
         $vCol01 = @$vUserData['Col01'];
         // повторные, док
         $vCol10 = @$vUserData['Col10'];
         // первичные, нормальные
         $vCol11 = @$vUserData['Col11'];
         // первичные, док
         $vEISOMSStatus0 = @$vUserData['EISOMSStatus0'];
         // не отправлялось в ЕИС ОМС
         $vEISOMSStatus1 = @$vUserData['EISOMSStatus1'];
         // не принято ЕИС ОМС (ошибки)
         $vEISOMSStatus2 = @$vUserData['EISOMSStatus2'];
         // приняты ЕИС ОМС
         $vIllDoc1 = @$vUserData['IllDoc1'];
         // б/л
         $vIsLostOutcome1 = @$vUserData['IsLostOutcome1'];
         // нет исхода
         $vRowData = array($vName, $vCol10 + $vCol11, $vCol11, $vCol00 + $vCol01, $vCol01, $vCol00 + $vCol01 + $vCol10 + $vCol11, $vCol11 + $vCol01, $vIllDoc1, $vIsLostOutcome1, $vEISOMSStatus0, $vEISOMSStatus1, $vEISOMSStatus2);
         $this->OutputTableRow($vWidths, $vHeight, $vRowData, $vAligns);
         $vTotalCol00 += $vCol00;
         $vTotalCol01 += $vCol01;
         $vTotalCol10 += $vCol10;
         $vTotalCol11 += $vCol11;
         $vTotalEISOMSStatus0 += $vEISOMSStatus0;
         $vTotalEISOMSStatus1 += $vEISOMSStatus1;
         $vTotalEISOMSStatus2 += $vEISOMSStatus2;
         $vTotalIllDoc1 += $vIllDoc1;
         $vTotalIsLostOutcome1 += $vIsLostOutcome1;
     }
     $vRowData = array(iconv('utf-8', 'cp1251', 'Всего'), $vTotalCol10 + $vTotalCol11, $vTotalCol11, $vTotalCol00 + $vTotalCol01, $vTotalCol01, $vTotalCol00 + $vTotalCol01 + $vTotalCol10 + $vTotalCol11, $vTotalCol11 + $vTotalCol01, $vTotalIllDoc1, $vTotalIsLostOutcome1, $vTotalEISOMSStatus0, $vTotalEISOMSStatus1, $vTotalEISOMSStatus2);
     $this->OutputTableRow($vWidths, $vHeight, $vRowData, $vAligns);
 }
Exemplo n.º 17
0
function ConstructSurgeriesQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'emst_surgeries ' . '  LEFT JOIN emst_cases ON emst_cases.id=emst_surgeries.case_id' . '  LEFT JOIN rb_employment_categories ON emst_cases.employment_category_id = rb_employment_categories.id' . '  LEFT JOIN rb_clinical_outcomes     ON emst_surgeries.clinical_outcome_id = rb_clinical_outcomes.id';
    $vCaseID = @$AParams['case_id'];
    if (!empty($vCaseID)) {
        $vFilter[] = $ADB->CondEqual('case_id', $vCaseID);
    }
    AddQueryParamLike($ADB, $vFilter, $AParams, 'first_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'last_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'patr_name');
    if (array_key_exists('beg_date', $AParams) && IsValidDate($AParams['beg_date'])) {
        $vFilter[] = $ADB->CondGE('date', $AParams['beg_date']);
    }
    if (array_key_exists('end_date', $AParams) && IsValidDate($AParams['end_date'])) {
        $vFilter[] = $ADB->CondLT('date', DateAddDay($AParams['end_date']));
    }
    if (array_key_exists('doctor_id', $AParams) && !empty($AParams['doctor_id'])) {
        $vFilter[] = $ADB->CondEqual('user_id', $AParams['doctor_id']);
    }
    if (array_key_exists('is_primary', $AParams)) {
        $vFilterPart = gSurgeryIsPrimary;
        if ($AParams['is_primary'] === '0') {
            $vFilter[] = 'NOT ' . $vFilterPart;
        } else {
            if ($AParams['is_primary'] === '1') {
                $vFilter[] = $vFilterPart;
            }
        }
    }
    if (array_key_exists('empty_diagnosis_mkb', $AParams) && $AParams['empty_diagnosis_mkb']) {
        $vFilter[] = 'emst_surgeries.diagnosis_mkb = \'\'';
    }
    if (array_key_exists('is_bad_doc', $AParams)) {
        $vFilterPart = gCaseWithBadDoc;
        if ($AParams['is_bad_doc'] === '0') {
            $vFilter[] = 'NOT ' . $vFilterPart;
        } else {
            if ($AParams['is_bad_doc'] === '1') {
                $vFilter[] = $vFilterPart;
            }
        }
    }
    if (array_key_exists('is_bad_illdoc', $AParams)) {
        $vFilterPart = gSurgeryWithBadIllDoc;
        if ($AParams['is_bad_illdoc'] === '0') {
            $vFilter[] = 'NOT ' . $vFilterPart;
        } else {
            if ($AParams['is_bad_illdoc'] === '1') {
                $vFilter[] = $vFilterPart;
            }
        }
    }
    if (array_key_exists('eisoms_status', $AParams) && $AParams['eisoms_status'] !== '') {
        $vFilter[] = $ADB->CondEqual('eisoms_status', $AParams['eisoms_status']);
        $vFilter[] = 'emst_cases.paytype = 0';
    }
    if (array_key_exists('is_lost_outcome', $AParams) && $AParams['is_lost_outcome']) {
        $vFilter[] = gLostOutcome;
    }
    $vFilter = implode(' AND ', $vFilter);
    $vOrder = 'emst_surgeries.date, emst_surgeries.id';
    return array($vTable, $vFilter, $vOrder);
}