malawi_hiv_program_reports 1.1.11 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26fde8ba891270aa134af13992809a7b5216f8782c2277cecb8761c2ab33c20a
4
- data.tar.gz: 1fb79cfb698b076a3ed023c6ab460bf315115e32eb9829bd2cf08749c6603426
3
+ metadata.gz: 0d67a1f59ec0e1c5f6e9ca66b7a611615bcdd34a82de87ffebe51710b5dd8e4f
4
+ data.tar.gz: ede999c99b737e8cc90572a91a2cdd78ff7b2a3450a3e02d978b0e53d6b64062
5
5
  SHA512:
6
- metadata.gz: 4f408a0b8d22481bfb47d2a4a7128c35cd9c3e51e4beb058b8f241e9e7ebc750e87e4605980ff010a5f04116e3d5d1e05b05ab43456985bb7fea25e4c2b712c8
7
- data.tar.gz: c1f738a66863e86a0d688c8166ec14068fc44c2e095f2e0a7dcd2d0077491eb1151f3d5c614a1ab9616389f4010f124f4f1c57d2b2af776f3a7ce2da1203dbb9
6
+ metadata.gz: 48f416ae032d733483437943b38a7e86c4b247071886248983ab9db2156d87872b5a6d463a2a0aa2e247cafc7ae92173aade82c469eac407928289aabb89dee2
7
+ data.tar.gz: 28e87a5f72089c28687709c4f5726cb2da9347c69e31a39112d5c53ea6f83ddf7592bf17f431748447b3fb9d5e6432e575a72f48d7e4ccaaec63a4afdeb981b1
@@ -201,7 +201,6 @@ module MalawiHivProgramReports
201
201
  FROM cdr_temp_max_patient_state#{start ? '_start' : ''} PARTITION (p#{location}) AS mps
202
202
  INNER JOIN patient_program PARTITION (p#{location}) AS pp ON pp.patient_id = mps.patient_id AND pp.program_id = 1 AND pp.voided = 0
203
203
  INNER JOIN patient_state PARTITION (p#{location}) AS ps ON ps.patient_program_id = pp.patient_program_id AND ps.start_date = mps.start_date AND ps.voided = 0
204
- AND (ps.end_date IS NULL OR ps.end_date > DATE(#{end_date}))
205
204
  INNER JOIN program_workflow_state pws ON pws.program_workflow_state_id = ps.state AND pws.retired = 0
206
205
  INNER JOIN concept_name cn ON cn.concept_id = pws.concept_id AND cn.concept_name_type = 'FULLY_SPECIFIED' AND cn.voided = 0
207
206
  LEFT JOIN patient_state PARTITION (p#{location}) AS ps2 ON ps.patient_program_id = ps2.patient_program_id AND ps.start_date = ps2.start_date AND ps.date_created < ps2.date_created AND ps2.voided = 0
@@ -293,7 +292,7 @@ module MalawiHivProgramReports
293
292
  INSERT INTO cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location})
294
293
  SELECT patients.patient_id, 'On antiretrovirals', COALESCE(cs.outcome_date, patients.start_date), #{location}, 4
295
294
  FROM cdr_temp_min_auto_expire_date#{start ? '_start' : ''} PARTITION (p#{location}) AS patients
296
- LEFT JOIN cdr_temp_current_state#{start ? '_start' : ''} PARTITION (p#{location}) AS cs ON cs.patient_id = patients.patient_id AND cs.site_id = patients.site_id
295
+ INNER JOIN cdr_temp_current_state#{start ? '_start' : ''} PARTITION (p#{location}) AS cs ON cs.patient_id = patients.patient_id AND cs.outcomes = 1
297
296
  WHERE patients.#{definition == 'pepfar' ? 'pepfar_defaulter_date' : 'moh_defaulter_date'} > DATE(#{start ? start_date : end_date}) #{start ? '- INTERVAL 1 DAY' : ''}
298
297
  AND (patients.patient_id) NOT IN (SELECT patient_id FROM cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location}) WHERE step IN (1, 2, 3))
299
298
  ON DUPLICATE KEY UPDATE cum_outcome = VALUES(cum_outcome), outcome_date = VALUES(outcome_date), step = VALUES(step)
@@ -305,7 +304,7 @@ module MalawiHivProgramReports
305
304
  INSERT INTO cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location})
306
305
  SELECT patients.patient_id, 'Defaulted', patients.#{definition == 'pepfar' ? 'pepfar_defaulter_date' : 'moh_defaulter_date'},#{location}, 5
307
306
  FROM cdr_temp_current_medication#{start ? '_start' : ''} PARTITION (p#{location}) AS patients
308
- LEFT JOIN cdr_temp_current_state#{start ? '_start' : ''} PARTITION (p#{location}) AS cs ON cs.patient_id = patients.patient_id
307
+ INNER JOIN cdr_temp_current_state#{start ? '_start' : ''} PARTITION (p#{location}) AS cs ON cs.patient_id = patients.patient_id AND cs.outcomes = 1
309
308
  WHERE patients.#{definition == 'pepfar' ? 'pepfar_defaulter_date' : 'moh_defaulter_date'} <= DATE(#{start ? start_date : end_date}) #{start ? '- INTERVAL 1 DAY' : ''}
310
309
  AND (patients.patient_id) NOT IN (SELECT patient_id FROM cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location}) WHERE step IN (1, 2, 3, 4))
311
310
  ON DUPLICATE KEY UPDATE cum_outcome = VALUES(cum_outcome), outcome_date = VALUES(outcome_date), step = VALUES(step)
@@ -84,7 +84,7 @@ module MalawiHivProgramReports
84
84
  FROM cdr_temp_cohort_members #{current_partition} e
85
85
  INNER JOIN cdr_temp_patient_outcomes #{current_partition} o ON e.patient_id = o.patient_id AND o.cum_outcome IN ('Defaulted', 'Patient died', 'Treatment stopped', 'Patient transferred out')
86
86
  WHERE e.patient_id IN (SELECT patient_id FROM cdr_temp_patient_outcomes_start #{current_partition} WHERE cum_outcome = 'On antiretrovirals')
87
- AND DATE(e.date_enrolled) < '#{start_date.to_date}'
87
+ AND DATE(e.earliest_start_date) < '#{start_date.to_date}'
88
88
  GROUP BY e.patient_id
89
89
  SQL
90
90
  end
@@ -103,7 +103,7 @@ module MalawiHivProgramReports
103
103
  o.cum_outcome outcome
104
104
  FROM cdr_temp_cohort_members #{current_partition} e
105
105
  INNER JOIN cdr_temp_patient_outcomes #{current_partition} o ON e.patient_id = o.patient_id AND o.cum_outcome IN ('Defaulted', 'Patient died', 'Treatment stopped', 'Patient transferred out')
106
- WHERE e.date_enrolled BETWEEN DATE('#{start_date}') AND DATE('#{end_date}')
106
+ WHERE e.earliest_start_date BETWEEN DATE('#{start_date}') AND DATE('#{end_date}')
107
107
  GROUP BY e.patient_id
108
108
  SQL
109
109
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MalawiHivProgramReports
4
- VERSION = '1.1.11'
4
+ VERSION = '1.1.13'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: malawi_hiv_program_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Chanunkha