Sha256: 5d4e5c4ef2b09de62f8005c29a444557495e621c77ec441bea07343f9c3b8053

Contents?: true

Size: 732 Bytes

Versions: 134

Compression:

Stored size: 732 Bytes

Contents

select
  patients.id as patient_id,
  patients.secure_id as patient_secure_id,
  current_modality.id as modality_id,
  modality_descriptions.id as modality_description_id,
  modality_descriptions.name as modality_name,
  current_modality.started_on as started_on
from patients
  -- this join only required as currently there can be > 1 current modality for a patient
  -- here we select the current modality with the most recent started_on
  left outer join (
    select distinct on (patient_id) * from modality_modalities
    order by patient_id, started_on desc
) as current_modality
on patients.id = current_modality.patient_id
left outer join modality_descriptions on modality_descriptions.id = current_modality.description_id;

Version data entries

134 entries across 134 versions & 1 rubygems

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