Sha256: cb9e12e1d08bdc349b03f7d5edc123feb7cae1354165eeb7ccb6cb57514b1b73

Contents?: true

Size: 1.24 KB

Versions: 177

Compression:

Stored size: 1.24 KB

Contents

/*
As we already have an hd_patient_statistics table that updates (in the background)
whenever something amount an HD Session changes, here we can query that table.
WHoever given what I know about auditing now I wonder of that hd_patient_statistics table
should be the materialized view itself, and we remove the Ruby code (AuditableSessionCollection
etc) and move that logic (mainly summing and averaging) in the the view
*/
SELECT
units.name,
count(stats.id) as patient_count,
ROUND(AVG(stats.pre_mean_systolic_blood_pressure)) as mean_pre_systolic_blood_pressure,
ROUND(AVG(stats.pre_mean_diastolic_blood_pressure)) as mean_pre_diastolic_blood_pressure,
ROUND(AVG(stats.post_mean_systolic_blood_pressure)) as mean_post_systolic_blood_pressure,
ROUND(AVG(stats.post_mean_diastolic_blood_pressure)) as mean_post_diastolic_blood_pressure,
ROUND(AVG(stats.mean_fluid_removal),2) as mean_fluid_removal,
ROUND(AVG(stats.mean_weight_loss),2) as mean_weight_loss,
ROUND(AVG(stats.mean_machine_ktv),2) as mean_machine_ktv,
ROUND(AVG(stats.mean_blood_flow),2) as mean_blood_flow,
ROUND(AVG(stats.mean_litres_processed),2) as mean_litres_processed
from hd_patient_statistics as stats
inner join hospital_units as units on units.id = stats.hospital_unit_id
group by units.name

Version data entries

177 entries across 177 versions & 1 rubygems

Version Path
renalware-core-2.1.1 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.1.0 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.167 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.166 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.165 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.164 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.163 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.162 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.161 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.160 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.159 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.158 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.157 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.156 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.155 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.153 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.152 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.151 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.149 db/views/reporting_hd_overall_audit_v01.sql
renalware-core-2.0.148 db/views/reporting_hd_overall_audit_v01.sql