public function actionGetTreatment()
 {
     if (!isset($_GET['q'])) {
         throw new CHttpException(401, 'Missing diagnosis name');
     }
     $lat = @$_GET['lat'];
     $long = @$_GET['long'];
     $diagnosisName = @$_GET['q'];
     $data = array();
     $diagnosis = Diagnosis::model()->findByAttributes(array('name' => $diagnosisName));
     if (!$diagnosis) {
         throw new CHttpException(401, 'Invalid diagnosis name');
     }
     $treatment = Treatment::model()->findByAttributes(array('diagnosis_id' => $diagnosis->id));
     $data['action'] = $treatment->action;
     $diagnosisType = DiagnosisTypes::model()->findByAttributes(array('diagnosis_id' => $diagnosis->id));
     $doctors = Doctors::model()->findAllByAttributes(array('type' => $diagnosisType->doctor_type_id));
     //how to compute for nearest place for the doctor
     foreach ($doctors as $d) {
         $data['doctors'][] = array('id' => $d->id, 'name' => $d->getFullname(), 'address' => $d->address, 'type' => $diagnosisType->doctorType->name, 'contact_no' => $d->contact_no, 'schedule' => $d->schedule, 'other_info' => $d->other_info, 'lat' => $d->lat, 'long' => $d->long);
     }
     echo CJSON::encode($data);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Diagnosis the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Diagnosis::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 *
 * @package           Diagnosis
 * @author            Gary Jones <*****@*****.**>
 * @link              http://gamajo.com/
 * @copyright         2014 Gary Jones, Gamajo Tech
 * @license           GPL-2.0+
 *
 * @wordpress-plugin
 * Plugin Name:       Diagnosis
 * Plugin URI:        http://github.com/GaryJones/diagnosis
 * Description:       Adds pages to the Dashboard menu with technical details about PHP, MySQL and other server details.
 * Version:           3.0.0
 * Author:            Gary Jones
 * Author URI:        http://gamajo.com/
 * Text Domain:       diagnosis
 * Domain Path:       /languages
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * GitHub Plugin URI: https://github.com/GaryJones/diagnosis
 * GitHub Branch:     master
 */
// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}
require_once plugin_dir_path(__FILE__) . 'includes/class-diagnosis.php';
// Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively.
// register_activation_hook( __FILE__, array( 'Diagnosis', 'activate' ) );
// register_deactivation_hook( __FILE__, array( 'Diagnosis', 'deactivate' ) );
$gmj_diagnosis = new Diagnosis();
$gmj_diagnosis->run();
if (empty($_SESSION['user'])) {
    header("Location: ../index.php");
    die("Redirecting to index.php");
} else {
    if (!empty($_GET['diagnosis']) && isset($_GET['submitButton'])) {
        $query = "\n                SELECT *\n                FROM appointment\n                WHERE\n                    id = :id\n                 ";
        $query_params = array(':id' => $_GET['id']);
        try {
            $stmt = $db->prepare($query);
            $stmt->execute($query_params);
        } catch (PDOException $ex) {
            die("Failed to run query: " . $ex->getMessage());
        }
        $row = $stmt->fetch();
        // Only update the tables without sending email
        $d = new Diagnosis($_SESSION['user']['id'], $row['doctor_name'], $row['patient_name'], $_SESSION["user"]["email"], htmlspecialchars($_GET['diagnosis']), htmlspecialchars($_GET['observations']), $row['date'], $row['time'], $db, htmlspecialchars($_GET['medication']));
        $d->initiate($_SESSION, $_GET['id']);
        $d->updateAppointment($_GET['id']);
    }
}
?>

<!doctype html>
<html lang="en">
<head>
    <style>.error {color: #FF0000;}</style>
    <style>.success {color: #00FF00;</style>
    <meta charset="utf-8">
    <title>Hospital Management</title>
    <meta name="description" content="Hospital management system for Intro to Software Engineering">
    <meta name="author" content="WAL Consulting">