emr_ohsp_interface 0.5.1 → 1.0.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b90822c9bd76ac63ee6f58ca9310cba51be673f2934909cd421861f5d55fed5
|
4
|
+
data.tar.gz: d74fedb9aa593757a009b1ee0d11b62fa390a3b12ff2b4f0c93a95685465c525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bcb9d8be53adcfd4e650073191521275e3ce8a85a8cef62110c1b755b6443bb58791e91d6cefc4ac969fe3390aa05996f6c81649995c3effc213cc80b78c40e
|
7
|
+
data.tar.gz: 8db4a502f87dc78fefba91398c1b71917f7750ad1e9248be19d50476084bfc34e40cf42c870138959c9e48015122b7bb06720fccc46b120e81568f2349dc693f
|
@@ -16,7 +16,7 @@ class EmrOhspInterface::EmrOhspInterfaceController < ::ApplicationController
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def generate_hmis_15_report
|
19
|
-
render json: service.generate_hmis_15_report(params[:
|
19
|
+
render json: service.generate_hmis_15_report(params[:start_date],params[:end_date]);
|
20
20
|
end
|
21
21
|
|
22
22
|
def service
|
@@ -5,6 +5,7 @@ module EmrOhspInterface
|
|
5
5
|
class << self
|
6
6
|
require 'csv'
|
7
7
|
require 'rest-client'
|
8
|
+
require 'json'
|
8
9
|
def settings
|
9
10
|
file = File.read(Rails.root.join("db","idsr_metadata","idsr_ohsp_settings.json"))
|
10
11
|
config = JSON.parse(file)
|
@@ -93,10 +94,11 @@ module EmrOhspInterface
|
|
93
94
|
if request == nil
|
94
95
|
response = send_data(collection,"weekly")
|
95
96
|
end
|
97
|
+
|
96
98
|
return collection
|
97
99
|
end
|
98
|
-
#idsr monthly report
|
99
100
|
|
101
|
+
#idsr monthly report
|
100
102
|
def generate_monthly_idsr_report(request=nil,start_date=nil,end_date=nil)
|
101
103
|
diag_map = settings["monthly_idsr_map"]
|
102
104
|
epi_month = months_generator.first.first.strip
|
@@ -105,7 +107,12 @@ module EmrOhspInterface
|
|
105
107
|
type = EncounterType.find_by_name 'Outpatient diagnosis'
|
106
108
|
collection = {}
|
107
109
|
|
108
|
-
special_indicators = ["Malaria in Pregnancy",
|
110
|
+
special_indicators = ["Malaria in Pregnancy",
|
111
|
+
"HIV New Initiated on ART",
|
112
|
+
"Diarrhoea In Under 5",
|
113
|
+
"Malnutrition In Under 5",
|
114
|
+
"Underweight Newborns < 2500g in Under 5 Cases",
|
115
|
+
"Severe Pneumonia in under 5 cases"]
|
109
116
|
|
110
117
|
diag_map.each do |key,value|
|
111
118
|
options = {"<5yrs"=>nil,">=5yrs"=>nil}
|
@@ -172,6 +179,76 @@ module EmrOhspInterface
|
|
172
179
|
|
173
180
|
collection[key] = options
|
174
181
|
end
|
182
|
+
|
183
|
+
if key.eql?("Diarrhoea In Under 5")
|
184
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
185
|
+
AND encounter_type = ? AND value_coded IN (?)
|
186
|
+
AND concept_id IN(6543, 6542)',
|
187
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
188
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
189
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
190
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
191
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
192
|
+
|
193
|
+
#under_five
|
194
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5}.\
|
195
|
+
collect{|record| record.person_id}
|
196
|
+
options["<5yrs"] = under_five
|
197
|
+
collection[key] = options
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
if key.eql?("Malnutrition In Under 5")
|
202
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
203
|
+
AND encounter_type = ? AND value_coded IN (?)
|
204
|
+
AND concept_id IN(6543, 6542)',
|
205
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
206
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
207
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
208
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
209
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
210
|
+
|
211
|
+
#under_five
|
212
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5}.\
|
213
|
+
collect{|record| record.person_id}
|
214
|
+
options["<5yrs"] = under_five
|
215
|
+
collection[key] = options
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
if key.eql?("Underweight Newborns < 2500g in Under 5 Cases")
|
220
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
221
|
+
AND encounter_type = ? AND value_coded IN (?)
|
222
|
+
AND concept_id IN(6543, 6542)',
|
223
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
224
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
225
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
226
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
227
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
228
|
+
|
229
|
+
#under_five
|
230
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5}.\
|
231
|
+
collect{|record| record.person_id}
|
232
|
+
options["<5yrs"] = under_five
|
233
|
+
collection[key] = options
|
234
|
+
end
|
235
|
+
|
236
|
+
if key.eql?("Severe Pneumonia in under 5 cases")
|
237
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
238
|
+
AND encounter_type = ? AND value_coded IN (?)
|
239
|
+
AND concept_id IN(6543, 6542)',
|
240
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
241
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
242
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
243
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
244
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
245
|
+
|
246
|
+
#under_five
|
247
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5}.\
|
248
|
+
collect{|record| record.person_id}
|
249
|
+
options["<5yrs"] = under_five
|
250
|
+
collection[key] = options
|
251
|
+
end
|
175
252
|
end
|
176
253
|
end
|
177
254
|
if request == nil
|
@@ -280,6 +357,47 @@ module EmrOhspInterface
|
|
280
357
|
collection
|
281
358
|
end
|
282
359
|
|
360
|
+
def generate_notifiable_disease_conditions_report(start_date=nil,end_date=nil)
|
361
|
+
diag_map = settings["notifiable_disease_conditions"]
|
362
|
+
|
363
|
+
start_date = Date.today.strftime("%Y-%m-%d") if start_date.nil?
|
364
|
+
end_date = Date.today.strftime("%Y-%m-%d") if end_date.nil?
|
365
|
+
|
366
|
+
type = EncounterType.find_by_name 'Outpatient diagnosis'
|
367
|
+
collection = {}
|
368
|
+
concept_name_for_sms_portal = {}
|
369
|
+
|
370
|
+
diag_map.each do |key,value|
|
371
|
+
options = {"<5yrs"=>nil,">=5yrs"=>nil}
|
372
|
+
concept_ids = ConceptName.where(name: value).collect{|cn| cn.concept_id}
|
373
|
+
|
374
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
375
|
+
AND encounter_type = ? AND value_coded IN (?)
|
376
|
+
AND concept_id IN(6543, 6542)',
|
377
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
378
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
379
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
380
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
381
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
382
|
+
|
383
|
+
#under_five
|
384
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5}.\
|
385
|
+
collect{|record| record.person_id}
|
386
|
+
options["<5yrs"] = under_five
|
387
|
+
#above 5 years
|
388
|
+
over_five = data.select{|record| calculate_age(record["birthdate"]) >=5 }.\
|
389
|
+
collect{|record| record.person_id}
|
390
|
+
|
391
|
+
options[">=5yrs"] = over_five
|
392
|
+
|
393
|
+
collection[key] = options
|
394
|
+
|
395
|
+
concept_name_for_sms_portal[key] = concept_ids
|
396
|
+
end
|
397
|
+
send_data_to_sms_portal(collection, concept_name_for_sms_portal)
|
398
|
+
return collection
|
399
|
+
end
|
400
|
+
|
283
401
|
# helper menthod
|
284
402
|
def months_generator
|
285
403
|
months = Hash.new
|
@@ -405,8 +523,41 @@ module EmrOhspInterface
|
|
405
523
|
puts send
|
406
524
|
end
|
407
525
|
|
526
|
+
def send_data_to_sms_portal(data, concept_name_collection)
|
527
|
+
conn2 = settings["sms_server"]
|
528
|
+
data = data.select {|k,v| v.select {|kk,vv| vv.length > 0}.length > 0}
|
529
|
+
payload = {
|
530
|
+
"email"=> conn2["user"],
|
531
|
+
"password" => conn2["pass"],
|
532
|
+
"emr_facility_id" => Location.current_health_center.id,
|
533
|
+
"emr_facility_name" => Location.current_health_center.name,
|
534
|
+
"payload" => data,
|
535
|
+
"concept_name_collection" => concept_name_collection
|
536
|
+
}
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
begin
|
541
|
+
response = RestClient::Request.execute(method: :post,
|
542
|
+
url: conn2["url"],
|
543
|
+
headers:{'Content-Type'=> 'application/json'},
|
544
|
+
payload: payload.to_json
|
545
|
+
)
|
546
|
+
rescue RestClient::ExceptionWithResponse => res
|
547
|
+
if res.class == RestClient::Forbidden
|
548
|
+
puts "error: #{res.class}"
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
if response.class != NilClass
|
553
|
+
if response.code == 200
|
554
|
+
puts "success: #{response}"
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
end
|
559
|
+
|
408
560
|
end
|
409
561
|
end
|
410
562
|
|
411
|
-
|
412
563
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emr_ohsp_interface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Manda and Petros Kayange
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|