56 | | == Број на пациенти кои биле на преглед во даден оддел и број на упати кои биле издадени за во оддел после извршен преглед, за секое тримесечје, за тековната година |
57 | | |
58 | | {{{#!sql |
59 | | select distinct o.naziv as oddel, b.naziv as bolnica, |
60 | | case when pregled_quarter.trimesecje = 1 then pacienti_quarter.pacienti else 0 end as quarter_1_pacienti, |
61 | | case when pregled_quarter.trimesecje = 2 then pacienti_quarter.pacienti else 0 end as quarter_2_pacienti, |
62 | | case when pregled_quarter.trimesecje = 3 then pacienti_quarter.pacienti else 0 end as quarter_3_pacienti, |
63 | | case when pregled_quarter.trimesecje = 4 then pacienti_quarter.pacienti else 0 end as quarter_4_pacienti, |
| 56 | == Број на пациенти кои биле на преглед во даден оддел и број на упати кои биле/се издадени за во оддел, за секое тримесечје, за тековната година |
| 57 | |
| 58 | {{{#!sql |
| 59 | select o.naziv as oddel, b.naziv as bolnica, |
| 60 | case when pacienti_quarter.trimesecje = 1 then pacienti_quarter.pacienti else 0 end as quarter_1_pacienti, |
| 61 | case when pacienti_quarter.trimesecje = 2 then pacienti_quarter.pacienti else 0 end as quarter_2_pacienti, |
| 62 | case when pacienti_quarter.trimesecje = 3 then pacienti_quarter.pacienti else 0 end as quarter_3_pacienti, |
| 63 | case when pacienti_quarter.trimesecje = 4 then pacienti_quarter.pacienti else 0 end as quarter_4_pacienti, |
65 | | case when pregled_quarter.trimesecje = 1 then upati_quarter.upati else 0 end as quarter_1_upati, |
66 | | case when pregled_quarter.trimesecje = 2 then upati_quarter.upati else 0 end as quarter_2_upati, |
67 | | case when pregled_quarter.trimesecje = 3 then upati_quarter.upati else 0 end as quarter_3_upati, |
68 | | case when pregled_quarter.trimesecje = 4 then upati_quarter.upati else 0 end as quarter_4_upati |
| 65 | case when upati_quarter.trimesecje = 1 then upati_quarter.upati else 0 end as quarter_1_upati, |
| 66 | case when upati_quarter.trimesecje = 2 then upati_quarter.upati else 0 end as quarter_2_upati, |
| 67 | case when upati_quarter.trimesecje = 3 then upati_quarter.upati else 0 end as quarter_3_upati, |
| 68 | case when upati_quarter.trimesecje = 4 then upati_quarter.upati else 0 end as quarter_4_upati |
71 | | join ( |
72 | | select o.oddel_id, o.bolnica_id, extract (quarter from p.vreme) as trimesecje |
73 | | from pregled p |
74 | | join doktor d on p.doktor_id = d.doktor_id |
75 | | join oddel o on (d.oddel_id, d.bolnica_id) = (o.oddel_id, o.bolnica_id) |
76 | | ) pregled_quarter on (o.oddel_id, o.bolnica_id) = (pregled_quarter.oddel_id, pregled_quarter.bolnica_id) |
77 | | left join ( |
78 | | select o.oddel_id, o.bolnica_id, count (p.covek_pacient_id) as pacienti |
| 71 | left join ( |
| 72 | select o.oddel_id, o.bolnica_id, count (p.covek_pacient_id) as pacienti, |
| 73 | extract (quarter from p.vreme) as trimesecje |