malawi_hiv_program_reports 1.1.10 → 1.1.11

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: d4d17044e31a6c36f8b4469283f763c0269fb5ae59d42861b24b050194326c44
4
- data.tar.gz: '029b6065fb4148d0d4ae1bd450b3bbf5cffded9060e2928c334c3a971c13d610'
3
+ metadata.gz: 26fde8ba891270aa134af13992809a7b5216f8782c2277cecb8761c2ab33c20a
4
+ data.tar.gz: 1fb79cfb698b076a3ed023c6ab460bf315115e32eb9829bd2cf08749c6603426
5
5
  SHA512:
6
- metadata.gz: 41235cd3c34531df48b9ae40b732ee7b73517b808dd35d61926704e5fcb532a5754737b7dd81ddb7a855036c9cf4c158d82bcfac65011588cfb6fd639f5c119d
7
- data.tar.gz: 2e458bf9233151036c5dd42b26542732862cd5e6483dc8e9a6870db076f23c68f9619d4db3f94857a2ff4ea308d72150dddfc02583feaf894ff4f449faa68d34
6
+ metadata.gz: 4f408a0b8d22481bfb47d2a4a7128c35cd9c3e51e4beb058b8f241e9e7ebc750e87e4605980ff010a5f04116e3d5d1e05b05ab43456985bb7fea25e4c2b712c8
7
+ data.tar.gz: c1f738a66863e86a0d688c8166ec14068fc44c2e095f2e0a7dcd2d0077491eb1151f3d5c614a1ab9616389f4010f124f4f1c57d2b2af776f3a7ce2da1203dbb9
@@ -183,7 +183,7 @@ module MalawiHivProgramReports
183
183
 
184
184
  def update_outcomes
185
185
  if check_if_table_exists('cdr_temp_patient_outcomes')
186
- MalawiHivProgramReports::Moh::CumulativeOutcome.new(end_date:, start_date:, definition:,
186
+ MalawiHivProgramReports::Moh::CumulativeOutcome.new(end_date:, start_date:, definition: type,
187
187
  rebuild: 'true', location:).find_report
188
188
  else
189
189
  rebuild_report
@@ -191,8 +191,8 @@ module MalawiHivProgramReports
191
191
  end
192
192
 
193
193
  def rebuild_report
194
- MalawiHivProgramReports::Moh::CumulativeCohort.new(definition:, start_date:, end_date:,
195
- locations: [location], rebuild: 'true').find_report
194
+ MalawiHivProgramReports::Moh::CumulativeCohort.new(definition: type, start_date:, end_date:,
195
+ locations: location, rebuild: 'true').find_report
196
196
  end
197
197
 
198
198
  def check_if_table_exists(table_name)
@@ -409,6 +409,7 @@ module MalawiHivProgramReports
409
409
  AND patient_type.voided = 0
410
410
  AND patient_type.concept_id = 3289 -- Type of patient
411
411
  AND patient_type.obs_datetime < DATE(#{end_date}) + INTERVAL 1 DAY
412
+ INNER JOIN encounter PARTITION (p#{location}) AS obs_encounter ON obs_encounter.encounter_id = patient_type.encounter_id AND obs_encounter.voided = 0 AND obs_encounter.program_id = 1 -- HIV PROGRAM
412
413
  LEFT JOIN encounter PARTITION (p#{location}) AS clinic_registration ON clinic_registration.patient_id = e.patient_id
413
414
  AND clinic_registration.program_id = 1 -- HIV PROGRAM
414
415
  AND clinic_registration.encounter_type = 9 -- HIV CLINIC REGISTRATION
@@ -205,7 +205,8 @@ module MalawiHivProgramReports
205
205
  INNER JOIN program_workflow_state pws ON pws.program_workflow_state_id = ps.state AND pws.retired = 0
206
206
  INNER JOIN concept_name cn ON cn.concept_id = pws.concept_id AND cn.concept_name_type = 'FULLY_SPECIFIED' AND cn.voided = 0
207
207
  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
208
- WHERE ps2.patient_program_id IS NULL AND ps.voided = 0
208
+ AND ps2.start_date < DATE(#{start ? start_date : end_date}) #{start ? '' : '+ INTERVAL 1 DAY'}
209
+ WHERE ps2.patient_program_id IS NULL AND ps.voided = 0 AND ps.start_date < DATE(#{start ? start_date : end_date}) #{start ? '' : '+ INTERVAL 1 DAY'}
209
210
  GROUP BY mps.patient_id
210
211
  ON DUPLICATE KEY UPDATE cum_outcome = VALUES(cum_outcome), outcome_date = VALUES(outcome_date), state = VALUES(state), outcomes = VALUES(outcomes)
211
212
  SQL
@@ -243,7 +244,7 @@ module MalawiHivProgramReports
243
244
  SELECT tesd.patient_id, 'Patient died', MAX(ps.start_date), #{location}, 1
244
245
  FROM cdr_temp_cohort_members PARTITION (p#{location}) tesd
245
246
  INNER JOIN patient_program PARTITION (p#{location}) pp ON pp.patient_id = tesd.patient_id AND pp.program_id = 1 AND pp.voided = 0
246
- INNER JOIN patient_state PARTITION (p#{location}) ps ON ps.patient_program_id = pp.patient_program_id AND ps.state = 3 AND ps.voided = 0 AND ps.start_date <= #{end_date}
247
+ INNER JOIN patient_state PARTITION (p#{location}) ps ON ps.patient_program_id = pp.patient_program_id AND ps.state = 3 AND ps.voided = 0 AND ps.start_date < DATE(#{start ? start_date : end_date}) #{start ? '' : '+ INTERVAL 1 DAY'}
247
248
  WHERE tesd.patient_id NOT IN (SELECT patient_id FROM cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location}) WHERE step = 1)
248
249
  AND tesd.date_enrolled < DATE(#{start ? start_date : end_date}) #{start ? '' : '+ INTERVAL 1 DAY'}
249
250
  GROUP BY tesd.patient_id
@@ -258,7 +259,7 @@ module MalawiHivProgramReports
258
259
  INSERT INTO cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location})
259
260
  SELECT patients.patient_id,patients.cum_outcome,patients.outcome_date, #{location}, 2
260
261
  FROM cdr_temp_current_state#{start ? '_start' : ''} PARTITION (p#{location}) AS patients
261
- WHERE (patients.patient_id) NOT IN (SELECT patient_id FROM cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location}) WHERE step = 1)
262
+ WHERE patients.patient_id NOT IN (SELECT patient_id FROM cdr_temp_patient_outcomes#{start ? '_start' : ''} PARTITION (p#{location}) WHERE step = 1)
262
263
  AND patients.outcomes = 1
263
264
  AND patients.state IN (
264
265
  SELECT pws.program_workflow_state_id state
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MalawiHivProgramReports
4
- VERSION = '1.1.10'
4
+ VERSION = '1.1.11'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: malawi_hiv_program_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Chanunkha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-27 00:00:00.000000000 Z
11
+ date: 2024-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails