malawi_hiv_program_reports 1.0.9 → 1.0.11
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b0b18ac14704b02389c59bca8c5e49c80fa48b381ec37faf25a26dbe9995c90
|
4
|
+
data.tar.gz: 8ad3b0382ec582c6e8289f599e65591011e15969b7f0ddba40f71e87bd626bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbbb974329cd00cfe4b57d3d6bb154c669952cf91a1996b89aee8df63086cd35b7cdf5435173f42d329ac7e00eb4d966f57e13e440aa5aa494c26584e8f2c89
|
7
|
+
data.tar.gz: 3dfd717d6d6364097edaf7397c5b3380542d74f4eba5bbfd89911c562da8def22584d0adc574e7c45b358f7247bcf7925db8832aebf83b7cb0e1078f03eadbc7
|
@@ -92,6 +92,7 @@ module MalawiHivProgramReports
|
|
92
92
|
cohort_struct.quarterly_all_males = males(quarter_start_date, end_date)
|
93
93
|
|
94
94
|
# Pregnant females (all ages)
|
95
|
+
create_temp_pregnant_obs(start_date, end_date)
|
95
96
|
cohort_struct.pregnant_females_all_ages = pregnant_females_all_ages(start_date, end_date)
|
96
97
|
cohort_struct.cum_pregnant_females_all_ages = pregnant_females_all_ages(cum_start_date, end_date)
|
97
98
|
cohort_struct.quarterly_pregnant_females_all_ages = pregnant_females_all_ages(quarter_start_date, end_date)
|
@@ -1944,27 +1945,36 @@ module MalawiHivProgramReports
|
|
1944
1945
|
SQL
|
1945
1946
|
end
|
1946
1947
|
|
1948
|
+
def create_temp_pregnant_obs(start_date, end_date)
|
1949
|
+
ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS temp_pregnant_obs;'
|
1950
|
+
ActiveRecord::Base.connection.execute <<~SQL
|
1951
|
+
CREATE TABLE temp_pregnant_obs
|
1952
|
+
SELECT o.person_id,o.value_coded, o.obs_datetime, o.site_id
|
1953
|
+
FROM obs o
|
1954
|
+
WHERE o.concept_id IN (6131,1755,7972,7563)
|
1955
|
+
AND o.value_coded IN (1065,1755)#{' '}
|
1956
|
+
AND o.voided = 0 #{site_manager(operator: 'AND', column: 'o.location_id', location: @location)}
|
1957
|
+
AND o.obs_datetime >= '#{start_date}' AND o.obs_datetime < '#{end_date}' + INTERVAL 1 DAY;
|
1958
|
+
SQL
|
1959
|
+
ActiveRecord::Base.connection.execute 'CREATE INDEX fre_person ON temp_pregnant_obs(person_id);'
|
1960
|
+
ActiveRecord::Base.connection.execute 'CREATE INDEX fre_obs_time ON temp_pregnant_obs(obs_datetime);'
|
1961
|
+
end
|
1962
|
+
|
1947
1963
|
def pregnant_females_all_ages(start_date, end_date)
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1964
|
+
concept('Yes').concept_id
|
1965
|
+
concept('IS PATIENT PREGNANT?').concept_id
|
1966
|
+
concept('PATIENT PREGNANT').concept_id
|
1967
|
+
concept('PREGNANT AT INITIATION?').concept_id
|
1968
|
+
concept('Reason for ART eligibility').concept_id
|
1953
1969
|
|
1954
1970
|
# (patient_id_plus_date_enrolled || []).each do |patient_id, date_enrolled|
|
1955
1971
|
registered = ActiveRecord::Base.connection.select_all <<~SQL
|
1956
|
-
SELECT
|
1957
|
-
FROM temp_earliest_start_date
|
1958
|
-
INNER JOIN
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
AND obs.obs_datetime < #{interval_manager(date: 'patients.earliest_start_date', value: 1, interval: 'DAY', operator: '+')}
|
1963
|
-
AND #{in_manager(column: 'obs.value_coded', values: [yes_concept_id, patient_preg_concept_id])}
|
1964
|
-
AND obs.voided = 0 #{site_manager(operator: 'AND', column: 'obs.site_id', location: @location)}
|
1965
|
-
WHERE patients.gender IN ('F','Female')
|
1966
|
-
AND patients.date_enrolled BETWEEN '#{start_date}' AND '#{end_date}' #{site_manager(operator: 'AND', column: 'patients.site_id', location: @location)}
|
1967
|
-
GROUP BY patient_id #{@adapter == 'mysql2' ? '' : ',obs.value_coded'}
|
1972
|
+
SELECT tesd.*, ft.value_coded
|
1973
|
+
FROM temp_earliest_start_date tesd#{' '}
|
1974
|
+
INNER JOIN temp_pregnant_obs ft ON ft.person_id = tesd.patient_id AND DATE(ft.obs_datetime) = DATE(tesd.earliest_start_date)
|
1975
|
+
AND tesd.gender = 'F'
|
1976
|
+
WHERE tesd.gender = 'F' and tesd.date_enrolled >= DATE('#{start_date}') AND tesd.date_enrolled <= DATE('#{end_date}') #{site_manager(operator: 'AND', column: 'tesd.site_id', location: @location)}
|
1977
|
+
GROUP BY tesd.patient_id
|
1968
1978
|
SQL
|
1969
1979
|
|
1970
1980
|
pregnant_at_initiation = ActiveRecord::Base.connection.select_all <<~SQL
|
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.0.
|
4
|
+
version: 1.0.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-03-
|
11
|
+
date: 2024-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|