SELECT b.id as id,b.final_amount as final_amount, sum(bd.net_amount+bd.corporate_covered_amount) as net_amount ,b.narration as narration
FROM bills as b
inner join bill_details as bd on b.id = bd.bill_id
inner join visits as v on v.id = b.visit_id
inner join patients as p on p.id = v.patient_id
inner join corporates as c on v.corporate_id = c.id
inner join department_service_groups as dsg on dsg.id = bd.department_service_group_id
WHERE (bd.status = $1 and bd.is_cancelled != $2 and ((v.patient_type=$3) or (v.patient_type=$4 and b.narration=$5)) and date(bill_date) >= $6 and date(bill_date) <= $7 and dsg.id = $8 and bd.location_id =$9)
GROUP BY b.id,b.narration,b.final_amount
ORDER BY b.id
Total Time ms
Loading...
Average Time ms
Loading...
Calls
Loading...
Tables
| Name |
Rows |
Indexes |
| bill_details |
342102 |
-
id
PRIMARY
-
bill_id
-
item_with_detail_id
-
location_id
-
narration
-
patient_id
-
reference_3
-
service_id
-
service_request_detail_id
-
station_id
|
| bills |
213932 |
-
id
PRIMARY
-
created_at
-
extid
UNIQUE
-
form_token
UNIQUE
-
ip_supplementary_bill_id
-
luxury_type_id
-
narration
-
visit_id
|
| corporates |
22 |
|
| department_service_groups |
127 |
|
| patients |
86189 |
-
id
PRIMARY
-
blood_group_id
-
extid
-
photograph_id
|
| visits |
222986 |
-
id
PRIMARY
-
extid
-
patient_id
|