emr_ohsp_interface 2.2.4 → 2.2.5

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: cd0223562697c86dc3dc5e2e0090f447b27d3d6375dd1d1ff7cdb7fb706a7f84
4
- data.tar.gz: b9102f891cf79cbc20d89ad6edf65662dd97fd3f9fe0cf2505b3fdb1c728386e
3
+ metadata.gz: c1e2f8f301b8057aed4f7ddb6e62eefd3c8108171cd949d5c329134ccae53c66
4
+ data.tar.gz: aa4515b396f441535ba766eb68ea0c71ea481f42f285dd457b7f1520fecb9bc8
5
5
  SHA512:
6
- metadata.gz: 79cc7e22960e8c66ba9b062d7913950be036a1385c56f67ff391f041b1c2fe35d1bda9699f75dd1919a03f2bfff34748ce6b1d47dd4bc30791c77890330eb901
7
- data.tar.gz: 13a729509212714349e6cfa6969e80bae9025716481e1182b236a8d788dbc0307e45faf89c753435ebd9dee6181786282ba256c64b427e5c627371927c942b56
6
+ metadata.gz: a5e32307d05ce57d5badf73902fe312b1944ac66be0caa055da6dc05123c9219e63e6c9288fe85edd03069ace7c4c750557454a1cee16542a407e87ee00185c8
7
+ data.tar.gz: 9faf563358135620f679014461235bcfb05df09e7337e343746da1117bdaf3ea475133ae05b1282359d3f6f03fd791919af4b74fa713ba513fec113f26450482
@@ -127,7 +127,7 @@ module EmrOhspInterface
127
127
  encounters = ['OUTPATIENT DIAGNOSIS','ADMISSION DIAGNOSIS']
128
128
 
129
129
  report_struct = indicators.each_with_object({}) do |indicator, report|
130
- report[indicator] = ['<5 yrs','>=5 yrs'].each_with_object({}) do |group, sub_report|
130
+ report[indicator.downcase] = ['<5 yrs','>=5 yrs'].each_with_object({}) do |group, sub_report|
131
131
  sub_report[group] = {
132
132
  outpatient_cases: [],
133
133
  inpatient_cases: [],
@@ -138,14 +138,6 @@ module EmrOhspInterface
138
138
  end
139
139
  end
140
140
 
141
- admitted_patient_died = Proc.new do |patient|
142
- visit_type = patient['visit_type']
143
- dead = patient['dead']
144
-
145
- visit_type == 'ADMISSION DIAGNOSIS' && dead
146
- end
147
-
148
-
149
141
  diagonised = ActiveRecord::Base.connection.select_all <<~SQL
150
142
  SELECT
151
143
  e.patient_id,
@@ -168,23 +160,15 @@ module EmrOhspInterface
168
160
  AND obs.concept_id IN (#{ConceptName.where(name: diagnosis_concepts).pluck(:concept_id).join(',')})
169
161
  AND obs.value_coded IN (#{ConceptName.where(name: indicators).pluck(:concept_id).join(',')})
170
162
  GROUP BY
171
- p.person_id
163
+ p.person_id, obs.concept_id
172
164
  SQL
173
165
 
174
166
  malaria_tests = lab_results(test_types: ['Malaria Screening'], start_date: start_date, end_date: end_date)
175
167
 
176
168
  tested_patient_ids = malaria_tests.map{|patient| patient['patient_id']}
177
169
 
178
- tested_positive = Proc.new do |patient|
179
- patient_id = patient['patient_id']
180
- return false unless tested_patient_ids.include?(patient_id)
181
-
182
- results = malaria_tests.find{|test| test['patient_id'] == patient_id}['results']
183
- ['positive', 'parasites seen'].include?(results)
184
- end
185
-
186
170
  diagonised.each do |patient|
187
- diagnosis = patient['diagnosis']
171
+ diagnosis = patient['diagnosis']&.downcase
188
172
  visit_type = patient['visit_type']
189
173
  patient_id = patient['patient_id']
190
174
  birthdate = patient['birthdate']
@@ -197,14 +181,29 @@ module EmrOhspInterface
197
181
  report_struct[diagnosis][age_group][:outpatient_cases] << patient_id if visit_type == 'OUTPATIENT DIAGNOSIS'
198
182
  report_struct[diagnosis][age_group][:inpatient_cases] << patient_id if visit_type == 'ADMISSION DIAGNOSIS'
199
183
  report_struct[diagnosis][age_group][:tested_malaria] << patient_id if tested_patient_ids.include?(patient_id)
200
- report_struct[diagnosis][age_group][:tested_positive_malaria] << patient_id if tested_positive.call(patient)
201
- report_struct[diagnosis][age_group][:inpatient_cases_death] << patient_id if admitted_patient_died.call(patient)
184
+ report_struct[diagnosis][age_group][:tested_positive_malaria] << patient_id if tested_positive(tested_patient_ids, patient)
185
+ report_struct[diagnosis][age_group][:inpatient_cases_death] << patient_id if admitted_patient_died(patient)
202
186
  end
203
187
 
204
188
  report_struct
205
189
 
206
190
  end
207
191
 
192
+ def tested_positive(ids, patient)
193
+ patient_id = patient['patient_id']
194
+ return false unless ids.include?(patient_id)
195
+
196
+ results = malaria_tests.find{|test| test['patient_id'] == patient_id}['results']
197
+ ['positive', 'parasites seen'].include?(results)
198
+ end
199
+
200
+ def admitted_patient_died(patient)
201
+ visit_type = patient['visit_type']
202
+ dead = patient['dead']
203
+
204
+ visit_type == 'ADMISSION DIAGNOSIS' && dead
205
+ end
206
+
208
207
  #idsr monthly report
209
208
  def generate_monthly_idsr_report(request=nil,start_date=nil,end_date=nil)
210
209
  diag_map = settings["monthly_idsr_map"]
@@ -902,4 +901,4 @@ module EmrOhspInterface
902
901
  end
903
902
  end
904
903
 
905
- end
904
+ end
@@ -1,3 +1,3 @@
1
1
  module EmrOhspInterface
2
- VERSION = '2.2.4'
2
+ VERSION = '2.2.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emr_ohsp_interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Manda, Petros Kayange, Dominic Kasanga