<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Apotek extends CI_Controller
{

    // CONSTRUCT
    public function __construct()
    {
        parent::__construct();
        $this->load->helper('form');
        $this->load->library('form_validation');
        $this->load->model('M_rekamMedis');
        $this->load->model('M_apotek');
        $this->load->helper('url');

        if (!$this->session->userdata('username')) {
            redirect('login');
        }
    }

    public function pasien($id)
    {
        $data['judul'] = "Klinik";
        $data['pasien'] = $this->M_rekamMedis->pemeriksaan($id)->row_array();
        $data['hasilObat'] = $this->M_rekamMedis->hasilObat($id)->result_array();
        $data['countObat'] = $this->M_rekamMedis->hasilObat($id)->num_rows();
        $data['user'] = $this->db->get_where('userV2', ['username' => $this->session->userdata('username')])->row_array();
        $this->load->view('properti/header', $data);
        $this->load->view('properti/menu', $data);
        $this->load->view('apotek/pasien', $data);
        $this->load->view('properti/footer', $data);
    }

    public function claim($id)
    {
        $this->db->query("UPDATE Cases SET Obat = '1' WHERE [Case ID] = '$id'");
        redirect('apotek/pasien/'.$id);
    }

    public function listClaim()
    {
        $data['judul'] = "Klinik";
        $data['user'] = $this->db->get_where('userV2', ['username' => $this->session->userdata('username')])->row_array();
        $data['claim'] = $this->M_apotek->claim()->result_array();
        $this->load->view('properti/header', $data);
        $this->load->view('properti/menu', $data);
        $this->load->view('apotek/listClaim', $data);
        $this->load->view('properti/footer', $data);
    }

    
}