malawi_hiv_program_reports 1.1.19 → 1.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59ce2b645e8862156cd2dfe62c5085eb8f92b940f3abb591d4ed90affc349a72
4
- data.tar.gz: 2b4a8ba3fd2ee2e82ae0e645b6b52f8951bb04e2bc9f418faed1ff4052f14acf
3
+ metadata.gz: 9452090ad1301bd223ba5fe909770f991b280a328a78f291959cc627b3a5445b
4
+ data.tar.gz: 69c727c81ebadf855040d3724dc557d43ef62abb8282c6164eef13a4f10ad4e9
5
5
  SHA512:
6
- metadata.gz: 645f9cbfdbeaf74c6b2da6035a3d336408d7e28663171557ecc2e68c7d53489d218408dd76980d870ef0d74dbc1238a57d388d194ac3195e3fe0953420e97d6e
7
- data.tar.gz: f6b5ad1078a1a8c3c68faee0d74c71502dce1099797140ab72ca171d92e8bf585b00b750758c3dead290927266c5c90aa8b912e57786d04db53418c4c15e8a67
6
+ metadata.gz: 1f8d8117bd8d26f3b98b47d4e165a6cab08ef1f28955328ee4a32b14fe7151f2081b4d52e50f7ac1c8b00e6a57aaa0d540c93f02deaa43712a2a681b8d715a57
7
+ data.tar.gz: 70e3c528f4527b41e5a27daa6b2238342798d8e3b03e2befe51027e88822d138da486e4fc6652f1a9bae4cbc24cce1810277d1e0b258d49501c9d39689f78c4a
@@ -88,6 +88,8 @@ module MalawiHivProgramReports
88
88
  maternal_status = data['maternal_status']
89
89
  # we need to handle regimes that only have one P to become PP. Otherwise if it is already PP or PA we leave
90
90
  # it as is. Regimens are in this format NUMBERLETTERS
91
+
92
+ report[age_group.to_s][gender.to_s][regimen.to_s] << patient_id if regimen.to_s == '15P'
91
93
  regimen = regimen.gsub(/(\d+[A-Za-z]*P)\z/, '\1P') if regimen.match?(/\A\d+[A-Za-z]*[^P]P\z/)
92
94
  gender = data['gender']
93
95
  report[age_group.to_s][gender.to_s][regimen.to_s] << patient_id
@@ -6,7 +6,7 @@ module MalawiHivProgramReports
6
6
  # rubocop:disable Metrics/ClassLength
7
7
  class CohortDisaggregatedAdditions
8
8
  COHORT_REGIMENS = %w[
9
- 0P 2P 4PP 4PA 9PP 9PA 11PP 11PA 12PP 12PA 14PP 14PA 15PP 15PA 16P 17PP 17PA
9
+ 0P 2P 4PP 4PA 9PP 9PA 11PP 11PA 12PP 12PA 14PP 14PA 15P 15PP 15PA 16P 17PP 17PA
10
10
  4A 5A 6A 7A 8A 9A 10A 11A 12A 13A 14A 15A 16A 17A
11
11
  ].freeze
12
12
 
@@ -75,6 +75,7 @@ module MalawiHivProgramReports
75
75
  fourteen_pp: 'Regimen 14PP',
76
76
  fourteen_pa: 'Regimen 14PA',
77
77
  fourteen_a: 'Regimen 14 A',
78
+ fifteen_p: 'Regimen 15P',
78
79
  fifteen_pp: 'Regimen 15PP',
79
80
  fifteen_pa: 'Regimen 15PA',
80
81
  fifteen_a: 'Regimen 15 A',
@@ -31,22 +31,6 @@ module MalawiHivProgramReports
31
31
  load_breast_feeding
32
32
  end
33
33
 
34
- private
35
-
36
- def vl_maternal_status(patient_list)
37
- return { FP: [], FBf: [] } if patient_list.blank?
38
-
39
- pregnant = pregnant_women(patient_list).map { |woman| woman['person_id'].to_i }
40
- return { FP: pregnant, FBf: [] } if (patient_list - pregnant).blank?
41
-
42
- feeding = breast_feeding(patient_list - pregnant).map { |woman| woman['person_id'].to_i }
43
-
44
- {
45
- FP: pregnant,
46
- FBf: feeding
47
- }
48
- end
49
-
50
34
  def pregnant_women(patient_list)
51
35
  ActiveRecord::Base.connection.execute <<~SQL
52
36
  SELECT person_id
@@ -63,6 +47,22 @@ module MalawiHivProgramReports
63
47
  SQL
64
48
  end
65
49
 
50
+ private
51
+
52
+ def vl_maternal_status(patient_list)
53
+ return { FP: [], FBf: [] } if patient_list.blank?
54
+
55
+ pregnant = pregnant_women(patient_list).map { |woman| woman['person_id'].to_i }
56
+ return { FP: pregnant, FBf: [] } if (patient_list - pregnant).blank?
57
+
58
+ feeding = breast_feeding(patient_list - pregnant).map { |woman| woman['person_id'].to_i }
59
+
60
+ {
61
+ FP: pregnant,
62
+ FBf: feeding
63
+ }
64
+ end
65
+
66
66
  def load_pregnant_women
67
67
  ActiveRecord::Base.connection.execute <<~SQL
68
68
  INSERT INTO cdr_temp_maternal_status #{current_partition} (patient_id, site_id, maternal_status)
@@ -26,7 +26,7 @@ module MalawiHivProgramReports
26
26
  end
27
27
 
28
28
  COHORT_REGIMENS = %w[
29
- 0P 2P 4PP 4PA 9PP 9PA 11PP 11PA 12PP 12PA 14PP 14PA 15PP 15PA 16P 17PP 17PA
29
+ 0P 2P 4PP 4PA 9PP 9PA 11PP 11PA 12PP 12PA 14PP 14PA 15P 15PP 15PA 16P 17PP 17PA
30
30
  4A 5A 6A 7A 8A 9A 10A 11A 12A 13A 14A 15A 16A 17A
31
31
  ].freeze
32
32
 
@@ -36,10 +36,10 @@ module MalawiHivProgramReports
36
36
  def vl_maternal_status(patient_list)
37
37
  return { FP: [], FBf: [] } if patient_list.blank?
38
38
 
39
- pregnant = pregnant_women(patient_list).map { |woman| woman['person_id'].to_i }
39
+ pregnant = maternal_status.pregnant_women(patient_list).map { |woman| woman['patient_id'].to_i }
40
40
  return { FP: pregnant, FBf: [] } if (patient_list - pregnant).blank?
41
41
 
42
- feeding = breast_feeding(patient_list - pregnant).map { |woman| woman['person_id'].to_i }
42
+ feeding = maternal_status.breast_feeding(patient_list - pregnant).map { |woman| woman['patient_id'].to_i }
43
43
 
44
44
  {
45
45
  FP: pregnant,
@@ -120,40 +120,6 @@ module MalawiHivProgramReports
120
120
  true
121
121
  end
122
122
 
123
- def pregnant_women(patient_list)
124
- ActiveRecord::Base.connection.select_all <<~SQL
125
- SELECT o.person_id, o.value_coded
126
- FROM obs #{current_partition} o
127
- LEFT JOIN obs #{current_partition} a ON a.person_id = o.person_id AND a.obs_datetime > o.obs_datetime AND a.concept_id IN (#{pregnant_concepts.to_sql}) AND a.voided = 0
128
- AND a.obs_datetime >= DATE(#{ActiveRecord::Base.connection.quote(start_date)}) AND a.obs_datetime < DATE(#{ActiveRecord::Base.connection.quote(end_date)}) + INTERVAL 1 DAY
129
- WHERE a.obs_id is null
130
- AND o.obs_datetime >= DATE(#{ActiveRecord::Base.connection.quote(start_date)})
131
- AND o.obs_datetime < DATE(#{ActiveRecord::Base.connection.quote(end_date)}) + INTERVAL 1 DAY
132
- AND o.voided = 0
133
- AND o.concept_id in (#{pregnant_concepts.to_sql})
134
- AND o.person_id IN (#{patient_list.join(',')})
135
- AND o.value_coded IN (#{yes_concepts.join(',')})
136
- GROUP BY o.person_id
137
- SQL
138
- end
139
-
140
- def breast_feeding(patient_list)
141
- ActiveRecord::Base.connection.select_all <<~SQL
142
- SELECT o.person_id, o.value_coded
143
- FROM obs #{current_partition} o
144
- LEFT JOIN obs #{current_partition} a ON a.person_id = o.person_id AND a.obs_datetime > o.obs_datetime AND a.concept_id IN (#{breast_feeding_concepts.to_sql}) AND a.voided = 0
145
- AND a.obs_datetime >= DATE(#{ActiveRecord::Base.connection.quote(start_date)}) AND a.obs_datetime < DATE(#{ActiveRecord::Base.connection.quote(end_date)}) + INTERVAL 1 DAY
146
- WHERE a.obs_id is null
147
- AND o.obs_datetime >= DATE(#{ActiveRecord::Base.connection.quote(start_date)})
148
- AND o.obs_datetime < DATE(#{ActiveRecord::Base.connection.quote(end_date)}) + INTERVAL 1 DAY
149
- AND o.voided = 0
150
- AND o.concept_id IN (#{breast_feeding_concepts.to_sql})
151
- AND o.person_id IN (#{patient_list.join(',')})
152
- AND o.value_coded IN (#{yes_concepts.join(',')})
153
- GROUP BY o.person_id
154
- SQL
155
- end
156
-
157
123
  def build_report(report)
158
124
  refresh_outcomes_table
159
125
  load_tx_curr_into_report(report, create_patients_alive_and_on_art_query)
@@ -395,26 +361,18 @@ module MalawiHivProgramReports
395
361
  SQL
396
362
  end
397
363
 
398
- def yes_concepts
399
- @yes_concepts ||= ::ConceptName.where(name: 'Yes').select(:concept_id).map do |record|
400
- record['concept_id'].to_i
401
- end
402
- end
403
-
404
- def pregnant_concepts
405
- @pregnant_concepts ||= ::ConceptName.where(name: ['Is patient pregnant?', 'patient pregnant'])
406
- .select(:concept_id)
407
- end
408
-
409
- def breast_feeding_concepts
410
- @breast_feeding_concepts ||= ::ConceptName.where(name: ['Breast feeding?', 'Breast feeding', 'Breastfeeding'])
411
- .select(:concept_id)
412
- end
413
-
414
364
  def encounter_types
415
365
  @encounter_types ||= ::EncounterType.where(name: ['HIV CLINIC CONSULTATION', 'HIV STAGING'])
416
366
  .select(:encounter_type_id)
417
367
  end
368
+
369
+ def maternal_status
370
+ ArtService::Reports::MaternalStatus.new(
371
+ start_date:,
372
+ end_date:,
373
+ occupation:
374
+ )
375
+ end
418
376
  end
419
377
  end
420
378
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MalawiHivProgramReports
4
- VERSION = '1.1.19'
4
+ VERSION = '1.1.20'
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.19
4
+ version: 1.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Chanunkha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-24 00:00:00.000000000 Z
11
+ date: 2025-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails