<?php

class Encounter_model extends CI_Model {

    function __construct() {
        
    }

    public function getEncounterList() {

        $mysql = "SELECT pe.member_id AS patient_id, pe.primary_complain AS reason, to_char(pe.appt_date, 'Day Mon DD  HH12:MI') AS appt,m.firstname,m.lastname,'F' AS gender , '35' AS age, pe.id,pe.id AS encounter_id FROM patient_encounters pe LEFT JOIN members m ON m.id=pe.member_id";
        $query = $this->db->query($mysql);
        $num = $query->num_rows();
        $data["encounter_list"] = $query->result();
        return $data;
    }

    public function LoadEncounter($practice_id, $patient_id) {

        $mysql = "SELECT pe.member_id AS patient_id, pe.primary_complain AS reason, to_char(pe.appt_date, 'Day Mon DD  HH12:MI')  AS appt,m.firstname,m.lastname,'F' AS gender , '35' AS age, pe.id,pe.id AS encounter_id FROM patient_encounters pe LEFT JOIN members m ON m.id=pe.member_id";
        $query = $this->db->query($mysql);
        $num = $query->num_rows();
        $data["patient_return"] = $query->result();
        return $data;
    }

}
/*


mermsemr_dev=> SELECT pe.primary_complain AS reason, pe.appt_date AS appt,m.firstname,m.lastname,'F' AS gender , '35' AS age, pe.id,pe.id AS encounter_id FROM patient_encounters pe LEFT JOIN members m ON m.id=pe.member_id;
           reason           |            appt            | firstname | lastname | gender | age | id | encounter_id
----------------------------+----------------------------+-----------+----------+--------+-----+----+--------------
 Nighthly headache          | 2020-12-20 16:36:45.143238 | Olutest   | Ameytest | F      | 35  |  1 |            1
 Sleepy and lazy all time   | 2020-12-27 10:56:06        | Olutest   | Ameytest | F      | 35  |  2 |            2
 Broken bones need fix      | 2020-12-28 11:56:06        | Pottie    | Gloria   | F      | 35  |  3 |            3
 Too much food always       | 2020-12-27 12:56:06        | fagbemi   | Moore    | F      | 35  |  4 |            4
 Just like to visit and see | 2020-12-27 15:56:06        | Olutest   | Ameytest | F      | 35  |  5 |            5
(5 rows)

*/
