Show last assigned bed in IPD bill print

This commit is contained in:
DevSoftTech Server 2026-08-01 15:41:59 +05:30
parent ee9bb7b560
commit 2ea2f9f2dc

View File

@ -165,12 +165,13 @@ class IpdBillingModel extends Model
->join('hc_insurance in_master', 'in_master.id = o.insurance_id', 'left')
->join('bed_master bm', 'bm.current_ipd_id = i.id', 'left')
->join(
'(select ipd_id, bed_id from bed_assignment_history where released_date is null order by id desc) bah_active',
'bah_active.ipd_id = i.id',
'(select max(id) as id, ipd_id from bed_assignment_history group by ipd_id) bah_latest',
'bah_latest.ipd_id = i.id',
'left',
false
)
->join('bed_master bm2', 'bm2.id = bah_active.bed_id', 'left')
->join('bed_assignment_history bah', 'bah.id = bah_latest.id', 'left')
->join('bed_master bm2', 'bm2.id = bah.bed_id', 'left')
->join('ipd_master_doc_list imdl', 'imdl.ipd_id = i.id', 'left')
->join('doctor_master d', 'd.id = imdl.doc_id', 'left')
->where('i.id', $ipdId)