Sha256: a9d91ebb30dcb8cbd0cd5ab96c116e8d40fb2e0b136d7537c4223512e3968504

Contents?: true

Size: 1.28 KB

Versions: 177

Compression:

Stored size: 1.28 KB

Contents

SELECT
patients.id as patient_id,
(SELECT COUNT(*) FROM "events" WHERE "events"."patient_id" = patients.id) as events_count,
(SELECT COUNT(*) FROM "clinic_visits" WHERE "clinic_visits"."patient_id" = patients.id) as clinic_visits_count,
(SELECT COUNT(*) FROM "letter_letters" WHERE "letter_letters"."patient_id" = patients.id) as letters_count,
(SELECT COUNT(*) FROM "access_profiles" WHERE "access_profiles"."patient_id" = patients.id) as access_profiles_count,
(SELECT COUNT(*) FROM "modality_modalities" WHERE "modality_modalities"."patient_id" = patients.id) as modalities_count,
(SELECT COUNT(*) FROM "problem_problems" WHERE "problem_problems"."deleted_at" IS NULL AND "problem_problems"."patient_id" = patients.id) as problems_count,
(SELECT COUNT(*) FROM "pathology_observation_requests" WHERE "pathology_observation_requests"."patient_id" = patients.id) as observation_requests_count,
(SELECT COUNT(*) FROM "medication_prescriptions" WHERE "medication_prescriptions"."patient_id" = patients.id) as prescriptions_count,
(SELECT COUNT(*) FROM "letter_contacts" WHERE "letter_contacts"."patient_id" = patients.id) as contacts_count,
(SELECT COUNT(*) FROM "transplant_recipient_operations" WHERE "transplant_recipient_operations"."patient_id" = patients.id) as recipient_operations_count
FROM patients

Version data entries

177 entries across 177 versions & 1 rubygems

Version Path
renalware-core-2.0.147 db/views/patient_summaries_v03.sql
renalware-core-2.0.146 db/views/patient_summaries_v03.sql
renalware-core-2.0.145 db/views/patient_summaries_v03.sql
renalware-core-2.0.144 db/views/patient_summaries_v03.sql
renalware-core-2.0.143 db/views/patient_summaries_v03.sql
renalware-core-2.0.142 db/views/patient_summaries_v03.sql
renalware-core-2.0.141 db/views/patient_summaries_v03.sql
renalware-core-2.0.140 db/views/patient_summaries_v03.sql
renalware-core-2.0.139 db/views/patient_summaries_v03.sql
renalware-core-2.0.138 db/views/patient_summaries_v03.sql
renalware-core-2.0.137 db/views/patient_summaries_v03.sql
renalware-core-2.0.136 db/views/patient_summaries_v03.sql
renalware-core-2.0.135 db/views/patient_summaries_v03.sql
renalware-core-2.0.134 db/views/patient_summaries_v03.sql
renalware-core-2.0.133 db/views/patient_summaries_v03.sql
renalware-core-2.0.132 db/views/patient_summaries_v03.sql
renalware-core-2.0.131 db/views/patient_summaries_v03.sql
renalware-core-2.0.130 db/views/patient_summaries_v03.sql
renalware-core-2.0.129 db/views/patient_summaries_v03.sql
renalware-core-2.0.128 db/views/patient_summaries_v03.sql