dpjp, dr_lab, jml2 from ( select r.registry_id,r.out_dt,p.mr_code,p.patient_nm,su.srvc_unit_nm,ms.medical_service_na me,e.employee_nm dr_visite,count(*)jml1 ,e1.employee_nm dpjp from patient p join registry r on r.mr_id=p.mr_id join hospital_ci h on h.registry_id=r.registry_id join unit_visit u on u.registry_id=r.registry_id join visite v on v.unit_visit_id=u.unit_visit_id join room rm on rm.room_id=h.room_id join employee e on e.employee_id=v.employee_id join employee e1 on e1.employee_id=h.employee_id join service_unit su on su.srvc_unit_id=rm.srvc_unit_id join billing b on b.registry_id=r.registry_id and b.billing_id=v.billing_id join medical_service ms on ms.medical_service_id=b.medical_service_id where date (r.out_dt) between '20190101' and '20190231' #and p.mr_code='056595' and r.in_out_sts='I' group by r.registry_id,e.employee_nm ,ms.medical_service_name )c left join( select r.registry_id,e2.employee_nm dr_lab,count (*)jml2 from patient p join registry r on r.mr_id=p.mr_id join hospital_ci h on h.registry_id=r.registry_id join billing b on b.registry_id=r.registry_id and b.srvc_unit_id='17' join service_unit su on su.srvc_unit_id=b.srvc_unit_id join employee e2 on e2.employee_id=b.employee_charge where date (r.out_dt) between '20190101' and '20190231' and r.in_out_sts='I' group by r.registry_id,e2.employee_nm)x on x.registry_id=c.registry_id;
#Tanpa dr_laboratorium (Rawat Inap)
select r.registry_id,r.out_dt,p.mr_code,p.patient_nm,suruang.srvc_unit_nm,ms.medical_servi ce_name,e.employee_nm dr_visite,count(*)jml1 ,e1.employee_nm dpjp from patient p join registry r on r.mr_id=p.mr_id join hospital_ci h on h.registry_id=r.registry_id join unit_visit u on u.registry_id=r.registry_id join visite v on v.unit_visit_id=u.unit_visit_id join room rm on rm.room_id=h.room_id join employee e on e.employee_id=v.employee_id join employee e1 on e1.employee_id=h.employee_id join service_unit su on su.srvc_unit_id=rm.srvc_unit_id join billing b on b.registry_id=r.registry_id and b.billing_id=v.billing_id join medical_service ms on ms.medical_service_id=b.medical_service_id left join unit_visit uvruang on uvruang.unit_visit_id=v.unit_visit_id left join service_unit suruang on suruang.srvc_unit_id=uvruang.unit_id_to where date (r.out_dt) between '20190101' and '20190131' and r.in_out_sts='I' group by r.registry_id,e.employee_nm ,ms.medical_service_name;
#Dengan Nama dokter (spesifik) dan tanpa dr Laborat
select r.registry_id,r.out_dt,p.mr_code,p.patient_nm,su.srvc_unit_nm,ms.medical_service_na me,e.employee_nm dr_visite,count(*)jml1 ,e1.employee_nm dpjp from patient p join registry r on r.mr_id=p.mr_id join hospital_ci h on h.registry_id=r.registry_id join unit_visit u on u.registry_id=r.registry_id join visite v on v.unit_visit_id=u.unit_visit_id join room rm on rm.room_id=h.room_id join employee e on e.employee_id=v.employee_id join employee e1 on e1.employee_id=h.employee_id join service_unit su on su.srvc_unit_id=rm.srvc_unit_id join billing b on b.registry_id=r.registry_id and b.billing_id=v.billing_id join medical_service ms on ms.medical_service_id=b.medical_service_id where date (r.out_dt) between '20200801' and '20200930' and srvc_unit_nm='Ruangan Wijaya Kusuma' and e.employee_nm ='dr. DIAN EVA SANJAYA, Sp.S' and r.in_out_sts='I' group by r.registry_id,e.employee_nm ,ms.medical_service_name;
select * from unit_visit where unit_id_to='17';
select * from lab_diagnostic where unit_visit_id='190228081247274460RSJM'; select * from billing where billing_id='190228094032361689RSJM';