Changes between Version 17 and Version 18 of AdvancedReports


Ignore:
Timestamp:
01/26/22 22:36:29 (3 years ago)
Author:
183060
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedReports

    v17 v18  
    5454
    5555
    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
     59select 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,
    6464       
    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
    6969from oddel o
    7070join bolnica b on o.bolnica_id = b.bolnica_id
    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
     71left join (
     72        select o.oddel_id, o.bolnica_id, count (p.covek_pacient_id) as pacienti,
     73                extract (quarter from p.vreme) as trimesecje
    7974        from pregled p
    8075        join doktor d on p.doktor_id = d.doktor_id
     
    8277        join bolnica b on o.bolnica_id = b.bolnica_id
    8378        where extract (year from p.vreme) = extract (year from current_date)
    84         group by 1, 2
     79        group by 1, 2, 4
    8580) pacienti_quarter on (o.oddel_id, o.bolnica_id) = (pacienti_quarter.oddel_id, pacienti_quarter.bolnica_id)     
    8681left join (
    87         select u.oddel_id, u.bolnica_id, count(u.upat_id) as upati
     82        select u.oddel_id, u.bolnica_id, count(u.upat_id) as upati,
     83                extract (quarter from t.vreme) as trimesecje
    8884        from upat u
    89         join pregled p on u.pregled_id = p.pregled_id
    90         where extract (year from p.vreme) = extract (year from current_date)
    91         group by 1, 2
     85        join rezervacija r on u.upat_id = r.upat_id
     86        join termin t on (r.termin_id, r.doktor_id) = (t.termin_id, t.doktor_id)
     87        where extract (year from t.vreme) = extract (year from current_date)
     88        group by 1, 2, 4
    9289) upati_quarter on (o.oddel_id, o.bolnica_id) = (upati_quarter.oddel_id, upati_quarter.bolnica_id) ;
    9390}}}