<?php
defined('BASEPATH') or exit('No direct script access allowed');
class M_Kasir extends CI_Model
{
    public function idxkasir()
    {
        $tgl = date('Y-m-d');
        return $this->db->query("SELECT c.PatientCode,c.[Case ID],c.Category,c.Description,c.[Intake Date],c.[Closed Date],cp.CompanyName,c.[Case Status] FROM Cases c join Company cp on c.CompanyCode = cp.CompanyCode WHERE c.[Intake Date]= '$tgl' order by c.[Case Status] Desc ");
    }

    public function CaribyCases($cari)
    {
        return $this->db->query("SELECT c.PatientCode,c.[Case ID],c.Category,c.Description,c.[Intake Date],c.[Closed Date],cp.CompanyName,c.[Case Status] FROM Cases c join Company cp on c.CompanyCode = cp.CompanyCode WHERE [Case ID] = '$cari'");
    }

    public function CaribyMR($cari)
    {
        return $this->db->query("SELECT c.PatientCode,c.[Case ID],c.Category,c.Description,c.[Intake Date],c.[Closed Date],cp.CompanyName,c.[Case Status] FROM Cases c join Company cp on c.CompanyCode = cp.CompanyCode WHERE c.PatientCode LIKE '%$cari%'");
    }

    public function CaribyNama($cari)
    {
        return $this->db->query("SELECT c.PatientCode,c.[Case ID],c.Category,c.Description,c.[Intake Date],c.[Closed Date],cp.CompanyName,c.[Case Status] FROM Cases c join Company cp on c.CompanyCode = cp.CompanyCode WHERE c.[Description] LIKE '%$cari%'");
    }

    public function Payment($cari)
    {
        return $this->db->query("Select * from Payment WHERE [Case ID] = '$cari' AND Status = 'OK' ");
    }

    public function CariVoid($cari)
    {
        return $this->db->query("Select * from Payment WHERE [Invoice ID] = '$cari' AND Status = 'OK' ");
    }

    public function PrintClaimNote($id)
    {
        return $this->db->query("Select c.[Case ID], c.Description, c.PatientCode, c.Class, c.Room, c.CompanyCode, c.[Intake Date], c.[Case Status], cp.CompanyName from Cases c join Company cp on c.CompanyCode = cp.CompanyCode WHERE [Case ID] = '$id'");
    } 

    public function VStatementDetail($id)
    {
        return $this->db->query("select * from VStatementDetail WHERE [Case ID] = '$id'");
    }

    public function paymentbayar($id)
    {
        return $this->db->query("select * from payment WHERE [Case ID] = '$id' and Status = 'OK'");
    }

    public function ttl($id)
    {
        return $this->db->query("select SUM(Total) as Total  from VStatementDetail where [Case ID] = '$id'");
    }

    public function obat($id)
    {
        return $this->db->query("select * from VSatementDetailDrugs WHERE [Case ID] = '$id'");
    }

}