modified assests
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers;
|
||||
use App\Enums\RecordStatusEnum;
|
||||
use App\Models\BaseModel;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Sample;
|
||||
|
||||
use App\Http\Controllers\Helper\GlobalController;
|
||||
@@ -16,14 +15,13 @@ class DashboardController extends Controller
|
||||
{
|
||||
protected $sampleModel;
|
||||
protected $invoiceModel;
|
||||
private $baseLabId;
|
||||
private $baseOrganizationId;
|
||||
protected $base;
|
||||
|
||||
public function __construct(Sample $sampleModel, Invoice $invoiceModel){
|
||||
public function __construct(Sample $sampleModel){
|
||||
$this->sampleModel = $sampleModel;
|
||||
$this->invoiceModel = $invoiceModel;
|
||||
$this->baseLabId = Session::get('base_lab_id');
|
||||
$this->base = Session::get('base_lab');
|
||||
$this->baseOrganizationId = Session::get('base_organization_id');
|
||||
$this->base = Session::get('base_organization');
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +51,7 @@ class DashboardController extends Controller
|
||||
//income
|
||||
$todayIncome = $this->getTodayIncome();
|
||||
$todayIncome+=$this->getDailyReportV2(date('Y-m-d'), date('Y-m-d'));
|
||||
$yesterdayIncome = $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
$yesterdayIncome = $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('invoice_date', date('Y-m-d', strtotime('-1 day')))->sum('gross_total');
|
||||
$yesterdayIncome+=$this->getDailyReportV2(date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')));
|
||||
if($yesterdayIncome>0){
|
||||
@@ -114,9 +112,9 @@ class DashboardController extends Controller
|
||||
$displaySampleResult = $monlthlySample;
|
||||
|
||||
} elseif ($q->dt == 'this_year'){
|
||||
$yearSamples = $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
$yearSamples = $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereYear('admission_date', date('Y'))->count();
|
||||
$last_yearSample = $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
$last_yearSample = $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereYear('admission_date', (date('Y')-1))->count();
|
||||
if($last_yearSample>0){
|
||||
$growthSample = (($yearSamples - $last_yearSample) / $last_yearSample);
|
||||
@@ -167,7 +165,7 @@ class DashboardController extends Controller
|
||||
else{
|
||||
$todayIncome = $this->getTodayIncome();
|
||||
$todayIncome+=$this->getDailyReportV2(date('Y-m-d'), date('Y-m-d'));
|
||||
$yesterdayIncome = $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
$yesterdayIncome = $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('invoice_date', date('Y-m-d', strtotime('-1 day')))->sum('gross_total');
|
||||
$yesterdayIncome+=$this->getDailyReportV2(date('Y-m-d', strtotime('-1 day')), date('Y-m-d', strtotime('-1 day')));
|
||||
if($yesterdayIncome>0){
|
||||
@@ -261,36 +259,36 @@ class DashboardController extends Controller
|
||||
//get total sample count for dashboard by lab id
|
||||
|
||||
function getTotalRejectedSampleCount(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)->count();
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)->count();
|
||||
}
|
||||
|
||||
function getTodayRejectedSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
->whereDate('admission_date', date('Y-m-d'))->get();
|
||||
}
|
||||
|
||||
function getYesterdayRejectedSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->get();
|
||||
}
|
||||
|
||||
function getThisMonthRejectedSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->get();
|
||||
}
|
||||
|
||||
function getPreviousMonthRejectedSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->get();
|
||||
}
|
||||
|
||||
function getThisYearRejectedSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
->whereYear('admission_date', date('Y'))->get();
|
||||
}
|
||||
|
||||
function getLastYearRejectedSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('sample_condition', 0)
|
||||
->whereYear('admission_date', (date('Y')-1))->get();
|
||||
}
|
||||
|
||||
@@ -299,109 +297,109 @@ class DashboardController extends Controller
|
||||
|
||||
|
||||
function getTotalSampleCount(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
||||
}
|
||||
|
||||
//get yesterday sample count for dashboard by lab id
|
||||
|
||||
function getYesterdaySampleCount(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->count();
|
||||
}
|
||||
|
||||
function getTodaySamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('admission_date', date('Y-m-d'))->get();
|
||||
}
|
||||
|
||||
function getThisMonthSamples(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->get();
|
||||
}
|
||||
|
||||
function getPreviousMonthSamples(){
|
||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->get();
|
||||
}
|
||||
|
||||
function getLastYearAverage(){
|
||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->count();
|
||||
}
|
||||
|
||||
function getTodayIncome(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('invoice_date', date('Y-m-d'))->sum('gross_total');
|
||||
}
|
||||
|
||||
function getThisMonthIncome(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('invoice_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->sum('gross_total');
|
||||
}
|
||||
|
||||
function getPreviousMonthIncome(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('invoice_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->sum('gross_total');
|
||||
}
|
||||
|
||||
function getLastYearIncome(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('invoice_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->sum('gross_total');
|
||||
}
|
||||
|
||||
function getTotalIncome(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->sum('gross_total');
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->sum('gross_total');
|
||||
}
|
||||
|
||||
function getTotalPatient(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->distinct('patient_id')->count('patient_id');
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getTodayPatient(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('admission_date', date('Y-m-d'))->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getYesterdayPatient(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereDate('admission_date', date('Y-m-d', strtotime('-1 day')))->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getThisMonthPatient(){
|
||||
return $this->sampleModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date('Y-m-01 00:00:00'), date('Y-m-t 23:59:59')])->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getPreviousMonthPatient(){
|
||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date("Y-m-d 00:00:00", strtotime("first day of previous month")), date("Y-m-d 23:59:59", strtotime("last day of previous month"))])->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getLastYearPatient(){
|
||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date('Y-01-01 00:00:00', strtotime('-1 year')), date('Y-12-31 23:59:59', strtotime('-1 year'))])->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getThisYearPatient(){
|
||||
return $this->sampleModel::with(['patient'])->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
return $this->sampleModel::with(['patient'])->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])
|
||||
->whereBetween('admission_date', [date('Y-01-01 00:00:00'), date('Y-12-31 23:59:59')])->distinct('patient_id')->count('patient_id');
|
||||
}
|
||||
|
||||
function getTotalInvoice(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->count();
|
||||
}
|
||||
|
||||
function getTotalPaidInvoice(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', 0)->count();
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', 0)->count();
|
||||
}
|
||||
|
||||
function getTotalUnpaidInvoice(){
|
||||
return $this->invoiceModel::query()->where(['lab_id' => $this->baseLabId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', '>', 0)->count();
|
||||
return $this->invoiceModel::query()->where(['organization_id' => $this->baseOrganizationId, BaseModel::RECORD_STATUS_FIELD => RecordStatusEnum::ACTIVE])->where('balance', '>', 0)->count();
|
||||
}
|
||||
|
||||
|
||||
function getSampleSourceChart($period = 2){
|
||||
$samplePeriodCondition = " and s.lab_id = ".$this->baseLabId;
|
||||
$samplePeriodCondition = " and s.organization_id = ".$this->baseOrganizationId;
|
||||
if($period == 1) $samplePeriodCondition.= " and date(s.admission_date)='".date('Y-m-d')."'"; // today
|
||||
if($period == 2) $samplePeriodCondition.= " and s.admission_date BETWEEN '".date('Y-m-01 00:00:00')."' AND '".date('Y-m-t 23:59:59')."'"; // this month
|
||||
if($period == 3) $samplePeriodCondition.= " and s.admission_date BETWEEN '".date('Y-01-01 23:59:59')."' AND '".date('Y-12-31 23:59:59')."'"; // this year
|
||||
@@ -422,7 +420,7 @@ class DashboardController extends Controller
|
||||
) sample
|
||||
ON sample.sample_source_id = ss.`id`
|
||||
WHERE ss.`record_status_id` = 1
|
||||
AND ss.`lab_id` = ".$this->baseLabId."
|
||||
AND ss.`organization_id` = ".$this->baseOrganizationId."
|
||||
");
|
||||
$sampleSourceDataArray = [];
|
||||
foreach ($sampleSourceData as $data){
|
||||
@@ -458,7 +456,7 @@ class DashboardController extends Controller
|
||||
FROM samples s
|
||||
WHERE YEAR(s.`admission_date`) between ".$fromYear." and ".$toYear."
|
||||
AND s.`record_status_id` = 1
|
||||
AND s.`lab_id` = ".$this->baseLabId."
|
||||
AND s.`organization_id` = ".$this->baseOrganizationId."
|
||||
GROUP BY MONTH(s.`admission_date`), YEAR(s.`admission_date`) ");
|
||||
return $sampleByYear;
|
||||
}
|
||||
@@ -482,14 +480,14 @@ class DashboardController extends Controller
|
||||
sum(r.bank_repayment_amount) as total_bank_paid,
|
||||
0 as total_owe
|
||||
from repayments r
|
||||
inner join invoices inv on inv.id = r.invoice_id and r.lab_id = inv.lab_id and inv.record_status_id = 1
|
||||
inner join samples s on s.`id` = inv.`sample_id` and s.`lab_id` = inv.`lab_id` and s.`record_status_id` = 1
|
||||
inner join patients p on p.`id` = s.`patient_id` and p.`lab_id` = s.`lab_id`
|
||||
INNER JOIN sample_sources ss ON ss.id = s.`sample_source_id` AND ss.`lab_id` = s.`lab_id`
|
||||
inner join invoices inv on inv.id = r.invoice_id and r.organization_id = inv.organization_id and inv.record_status_id = 1
|
||||
inner join samples s on s.`id` = inv.`sample_id` and s.`organization_id` = inv.`organization_id` and s.`record_status_id` = 1
|
||||
inner join patients p on p.`id` = s.`patient_id` and p.`organization_id` = s.`organization_id`
|
||||
INNER JOIN sample_sources ss ON ss.id = s.`sample_source_id` AND ss.`organization_id` = s.`organization_id`
|
||||
INNER JOIN physicians ps ON ps.`id` = s.`physician_id`
|
||||
where r.`record_status_id` = 1
|
||||
AND DATE(r.repayment_date) BETWEEN '".date('Y-m-d', strtotime($startDate))."' AND '".date('Y-m-d', strtotime($endDate))."'
|
||||
and r.lab_id= ".$this->baseLabId."
|
||||
and r.organization_id= ".$this->baseOrganizationId."
|
||||
group by r.`repayment_date`,
|
||||
ss.`name_en`,
|
||||
p.`name_en`,
|
||||
@@ -515,14 +513,14 @@ class DashboardController extends Controller
|
||||
$current = DB::table('samples')
|
||||
->selectRaw('MONTH(admission_date) as month, COUNT(*) as total')
|
||||
->whereYear('admission_date', $thisYear)
|
||||
->where('lab_id', $this->baseLabId)
|
||||
->where('organization_id', $this->baseOrganizationId)
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
$previous = DB::table('samples')
|
||||
->selectRaw('MONTH(admission_date) as month, COUNT(*) as total')
|
||||
->whereYear('admission_date', $lastYear)
|
||||
->where('lab_id', $this->baseLabId)
|
||||
->where('organization_id', $this->baseOrganizationId)
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
@@ -547,14 +545,14 @@ class DashboardController extends Controller
|
||||
$current = DB::table('invoices')
|
||||
->selectRaw('MONTH(invoice_date) as month, SUM(gross_total) as total')
|
||||
->whereYear('invoice_date', $thisYear)
|
||||
->where('lab_id', $this->baseLabId)
|
||||
->where('organization_id', $this->baseOrganizationId)
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
$previous = DB::table('invoices')
|
||||
->selectRaw('MONTH(invoice_date) as month, SUM(gross_total) as total')
|
||||
->whereYear('invoice_date', $lastYear)
|
||||
->where('lab_id', $this->baseLabId)
|
||||
->where('organization_id', $this->baseOrganizationId)
|
||||
->groupBy('month')
|
||||
->pluck('total', 'month');
|
||||
|
||||
@@ -585,13 +583,13 @@ class DashboardController extends Controller
|
||||
FROM samples s
|
||||
WHERE s.`record_status_id` = 1
|
||||
and year(s.admission_date) = ".$thisYear."
|
||||
AND s.lab_id = ".$this->baseLabId."
|
||||
AND s.organization_id = ".$this->baseOrganizationId."
|
||||
GROUP BY s.`sample_source_id`
|
||||
|
||||
) sample
|
||||
ON sample.sample_source_id = ss.`id`
|
||||
WHERE ss.`record_status_id` = 1
|
||||
AND ss.`lab_id` = ".$this->baseLabId."
|
||||
AND ss.`organization_id` = ".$this->baseOrganizationId."
|
||||
ORDER BY total_samples DESC
|
||||
LIMIT 10
|
||||
");
|
||||
@@ -615,13 +613,13 @@ class DashboardController extends Controller
|
||||
INNER JOIN departments sd ON sd.id = st.`department_id`
|
||||
WHERE s.`record_status_id` = 1
|
||||
and year(s.admission_date) = ".$thisYear."
|
||||
AND s.lab_id = ".$this->baseLabId."
|
||||
AND s.organization_id = ".$this->baseOrganizationId."
|
||||
GROUP BY st.`department_id`
|
||||
|
||||
) sample
|
||||
ON sample.department_id = d.`id`
|
||||
WHERE d.`record_status_id` = 1
|
||||
AND d.`lab_id` = ".$this->baseLabId."
|
||||
AND d.`organization_id` = ".$this->baseOrganizationId."
|
||||
ORDER BY d.`name_en`
|
||||
");
|
||||
return response()->json($samplePanelData);
|
||||
|
||||
Reference in New Issue
Block a user