emr_ohsp_interface 0.5.3 → 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
|
@@ -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
|
@@ -355,6 +357,47 @@ module EmrOhspInterface
|
|
355
357
|
collection
|
356
358
|
end
|
357
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
|
+
|
358
401
|
# helper menthod
|
359
402
|
def months_generator
|
360
403
|
months = Hash.new
|
@@ -480,8 +523,41 @@ module EmrOhspInterface
|
|
480
523
|
puts send
|
481
524
|
end
|
482
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
|
+
|
483
560
|
end
|
484
561
|
end
|
485
562
|
|
486
|
-
|
487
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
|