*/
$tab = "medical";
$nav = "social";
/**
 * Checking permissions
 */
require_once "../auth/login_check.php";
loginCheck(OPEN_PROFILE_ADMINISTRATIVE);
require_once "../lib/Form.php";
require_once "../lib/Check.php";
require_once "../model/Patient.php";
/**
 * Retrieving vars (PGS)
 */
$idPatient = Check::postGetSessionInt('id_patient');
$idRelative = Check::postGetSessionInt('id_relative');
$patient = new Patient($idPatient);
if ($patient->getName() == '') {
    FlashMsg::add(_("That patient does not exist."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
/**
 * Show page
 */
$title = _("Delete Relative from list");
$titlePage = $patient->getName() . ' (' . $title . ')';
require_once "../layout/header.php";
//$returnLocation = "../medical/relative_list.php?id_patient=" . $idPatient; // controlling var
$returnLocation = "../medical/relative_list.php";
// controlling var
/**
 * Controlling vars
 */
$tab = "medical";
$nav = "history";
/**
 * Checking permissions
 */
require_once "../auth/login_check.php";
loginCheck(OPEN_PROFILE_ADMINISTRATIVE);
require_once "../model/Query/History.php";
require_once "../model/Patient.php";
/**
 * Retrieving var (PGS)
 */
$idPatient = Check::postGetSessionInt('id_patient');
$patient = new Patient($idPatient);
if ($patient->getName() == '') {
    FlashMsg::add(_("Beneficiário não cadastrado."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
/**
 * Search database
 */
$historyQ = new Query_History();
if (!$historyQ->selectPersonal($idPatient)) {
    $historyQ->close();
    FlashMsg::add(_("Beneficiário não cadastrado."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
 * Checking permissions
 */
require_once "../auth/login_check.php";
loginCheck(OPEN_PROFILE_ADMINISTRATIVE, false);
// Not in DEMO to prevent users' malice
require_once "../lib/Form.php";
require_once "../lib/Check.php";
require_once "../model/Patient.php";
require_once "../model/Problem.php";
require_once "../model/Test.php";
/**
 * Retrieving vars (PGS)
 */
$idProblem = Check::postGetSessionInt('id_problem');
$idPatient = Check::postGetSessionInt('id_patient');
$idTest = Check::postGetSessionInt('id_test');
$patient = new Patient($idPatient);
if ($patient->getName() == '') {
    FlashMsg::add(_("That patient does not exist."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
$problem = new Problem($idProblem);
if (!$problem) {
    FlashMsg::add(_("That medical problem does not exist."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
$test = new Test($idProblem, $idTest);
if (!$test) {
    FlashMsg::add(_("That medical test does not exist"), OPEN_MSG_ERROR);
require_once "../auth/login_check.php";
loginCheck(OPEN_PROFILE_DOCTOR);
require_once "../model/Query/Page/Patient.php";
require_once "../lib/Search.php";
/*if (isset($_POST['token_form']))
  {
    include_once("../lib/Form.php");
    Form::compareToken('../medical/patient_search_form.php');
  }*/
/**
 * Retrieving vars (PGS) and scrubbing the data
 */
$currentPage = Check::postGetSessionInt('page', 1);
$searchType = Check::postGetSessionInt('search_type');
$logical = Check::postGetSessionString('logical');
$limit = Check::postGetSessionInt('limit');
// remove slashes added by form post
$searchText = stripslashes(Check::postGetSessionString('search_text'));
// remove redundant whitespace
$searchText = preg_replace("/[[:space:]]+/i", " ", $searchText);
// transform string in array of strings
$arraySearch = Search::explodeQuoted($searchText);
/**
 * Search database
 */
$patQ = new Query_Page_Patient();
$patQ->setItemsPerPage(OPEN_ITEMS_PER_PAGE);
$patQ->search($searchType, $arraySearch, $currentPage, $logical, $limit);
/**
 * No results message if no results returned from search.
 */
 */
/**
 * Controlling vars
 */
$tab = "medical";
$nav = "problems";
/**
 * Checking permissions
 */
require_once "../auth/login_check.php";
loginCheck(OPEN_PROFILE_ADMINISTRATIVE);
/**
 * Retrieving vars (PGS)
 */
$idPatient = Check::postGetSessionInt('id_patient');
$orderNumber = Check::postGetSessionInt('order_number', isset($formVar["order_number"]) ? $formVar["order_number"] - 1 : 0);
require_once "../model/Patient.php";
$patient = new Patient($idPatient);
if ($patient->getName() == '') {
    FlashMsg::add(_("That patient does not exist."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
// after clean form vars
$formVar["id_patient"] = $idPatient;
//$formVar["id_member"] = ???; // @fixme si no está vacía y es la primera vez que se accede aquí es igual al médico que le corresponde por cupo?
$formVar["order_number"] = $orderNumber + 1;
$formVar["opening_date"] = date("Y-m-d");
// automatic date (ISO format) without getText
$formVar["last_update_date"] = date("Y-m-d");
// automatic date (ISO format) without getText
require_once "../model/Query/Page/Problem.php";
require_once "../lib/Form.php";
require_once "../lib/Search.php";
/*if (isset($_POST['token_form']))
  {
    include_once("../lib/Form.php");
    Form::compareToken('../medical/patient_search_form.php');
  }*/
/**
 * Retrieving vars (PGS) and scrubbing the data
 */
//$currentPage = Check::postGetSessionInt('page_problem', 1);
$currentPage = Check::postGetSessionInt('page', 1);
$searchType = Check::postGetSessionInt('search_type_problem');
$logical = Check::postGetSessionString('logical_problem');
$limit = Check::postGetSessionInt('limit_problem');
// remove slashes added by form post
$searchText = stripslashes(Check::postGetSessionString('search_text_problem'));
// remove redundant whitespace
$searchText = preg_replace("/[[:space:]]+/i", " ", $searchText);
// transform string in array of strings
$arraySearch = Search::explodeQuoted($searchText);
/**
 * Search database
 */
$problemQ = new Query_Page_Problem();
$problemQ->setItemsPerPage(OPEN_ITEMS_PER_PAGE);
$problemQ->search($searchType, $arraySearch, $currentPage, $logical, $limit);
/**
 * No results message if no results returned from search.
 */
$nav = "problems";
/**
 * Checking permissions
 */
require_once "../auth/login_check.php";
loginCheck(OPEN_PROFILE_ADMINISTRATIVE);
require_once "../lib/Form.php";
require_once "../lib/Check.php";
require_once "../model/Patient.php";
require_once "../model/Problem.php";
/**
 * Retrieving vars (PGS)
 */
$idProblem = Check::postGetSessionInt('id_problem');
$idPatient = Check::postGetSessionInt('id_patient');
$idConnection = Check::postGetSessionInt('id_connection');
$patient = new Patient($idPatient);
if ($patient->getName() == '') {
    FlashMsg::add(_("That patient does not exist."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
$problem = new Problem($idProblem);
if (!$problem) {
    FlashMsg::add(_("That medical problem does not exist."), OPEN_MSG_ERROR);
    header("Location: ../medical/patient_search_form.php");
    exit;
}
/**
 * Show page
 */