<?php

class Patient_model extends CI_Model {

    function __construct() {
        
    }

    public function getPatientList() {

        $mysql = "SELECT p.practice_id,p.id AS patient_id,p.member_id,p.long_id,m.firstname,m.lastname,m.phone,p.added::date ,m.gender,m.dob::date AS dob"
                . " FROM patients p LEFT JOIN members m ON m.id=p.member_id WHERE p.practice_id=" . $_SESSION['practice_id'] . " ORDER BY p.added DESC";
        $query = $this->db->query($mysql);
        $num = $query->num_rows();
        $data["patient_list"] = $query->result();
        return $data;
    }

    public function LoadPatient($practice_id, $patient_id) {

        $mysql = "SELECT p.practice_id,p.id AS patient_id,p.member_id,p.long_id,m.firstname,m.lastname,m.phone,p.added::date,m.email "
                . " FROM patients p LEFT JOIN members m ON m.id=p.member_id WHERE p.id=" . $patient_id . " AND  p.practice_id=" . $_SESSION['practice_id'];
        $query = $this->db->query($mysql);
        $num = $query->num_rows();
        $data["patient_return"] = $query->result();
        return $data;
    }

}
