Пример #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);
}
Пример #2
0
function ConstructClientQuery(&$ADB, $AParams)
{
    $vFilter = array();
    $vTable = 'imp_clients' . ' LEFT JOIN rb_doc_types ON imp_clients.doc_type_id=rb_doc_types.id' . ' LEFT JOIN rb_insurance_companies ON imp_clients.insurance_company_id=rb_insurance_companies.id' . ' LEFT JOIN imp_addr   AS reg_addr   ON imp_clients.addr_reg_id=reg_addr.id' . ' LEFT JOIN imp_house  AS reg_house  ON reg_addr.house_id=reg_house.id' . ' LEFT JOIN imp_prefix AS reg_prefix ON reg_house.prefix_id=reg_prefix.id' . ' LEFT JOIN imp_geonim_name AS reg_geonim_name ON reg_prefix.geonim_name_id=reg_geonim_name.id' . ' LEFT JOIN imp_geonim_type AS reg_geonim_type ON reg_prefix.geonim_type_id=reg_geonim_type.id' . ' LEFT JOIN imp_town   AS reg_town   ON reg_prefix.town_id=reg_town.id' . ' LEFT JOIN imp_addr   AS loc_addr   ON imp_clients.addr_loc_id=loc_addr.id' . ' LEFT JOIN imp_house  AS loc_house  ON loc_addr.house_id=loc_house.id' . ' LEFT JOIN imp_prefix AS loc_prefix ON loc_house.prefix_id=loc_prefix.id' . ' LEFT JOIN imp_geonim_name AS loc_geonim_name ON loc_prefix.geonim_name_id=loc_geonim_name.id' . ' LEFT JOIN imp_geonim_type AS loc_geonim_type ON loc_prefix.geonim_type_id=loc_geonim_type.id' . ' LEFT JOIN imp_town   AS loc_town   ON loc_prefix.town_id=loc_town.id';
    $vCols = 'imp_clients.*,' . 'rb_doc_types.name as doc_type,' . 'rb_insurance_companies.name as insurance_company,' . 'reg_town.name as reg_town_name,' . 'reg_geonim_name.name as reg_street_name,' . 'reg_geonim_type.name as reg_street_type,' . 'reg_house.number as reg_number,' . 'reg_house.corpus as reg_corpus,' . 'reg_addr.flat as reg_flat,' . 'loc_town.name as loc_town_name,' . 'loc_geonim_name.name as loc_street_name,' . 'loc_geonim_type.name as loc_street_type,' . 'loc_house.number as loc_number,' . 'loc_house.corpus as loc_corpus,' . 'loc_addr.flat as loc_flat';
    AddQueryParamLike($ADB, $vFilter, $AParams, 'first_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'last_name');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'patr_name');
    AddQueryParamEqual($ADB, $vFilter, $AParams, 'doc_type_id');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'doc_series');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'doc_number');
    AddQueryParamEqual($ADB, $vFilter, $AParams, 'insurance_company_id');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'polis_series');
    AddQueryParamLike($ADB, $vFilter, $AParams, 'polis_number');
    #        $vFilter = implode(' AND ', $vFilter);
    $vFilter = '0';
    $vOrder = 'last_name, first_name, patr_name, born_date, id';
    return array($vTable, $vCols, $vFilter, $vOrder);
}
Пример #3
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);
}
Пример #4
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);
}
Пример #5
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);
}