emr_ohsp_interface 1.1.0 → 1.2.0
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: 73b9145df1d352e5e6df1cbf8983b7a28a15a3a91cc86ee06341141fb0c0dfee
|
4
|
+
data.tar.gz: 60069ab8d7ef564129e656e25bd41ba598639cdf07b4f90a317823e8ec9042ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84c0c258dd74dc53322b73b85b88fdef01232cf3fc76f6e989e25e0d141fc7a16a62386465a73471992222d2a7f2f37ce30c34198fb69f4535d9b8159b8b4369
|
7
|
+
data.tar.gz: 7497b891e1aaa5715457509ed5606baa8af6df7b948a94c51ec855f4d9f0485f10999709b2c9162043ed477e562110565d3f546bb04872f070f3e9adb9004aa7
|
@@ -11,6 +11,10 @@ module EmrOhspInterface
|
|
11
11
|
config = JSON.parse(file)
|
12
12
|
end
|
13
13
|
|
14
|
+
def server_config
|
15
|
+
config =YAML.load_file("#{Rails.root}/config/application.yml")
|
16
|
+
end
|
17
|
+
|
14
18
|
def get_ohsp_facility_id
|
15
19
|
file = File.open(Rails.root.join("db","idsr_metadata","emr_ohsp_facility_map.csv"))
|
16
20
|
data = CSV.parse(file,headers: true)
|
@@ -129,11 +133,11 @@ module EmrOhspInterface
|
|
129
133
|
|
130
134
|
#under_five
|
131
135
|
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5}.\
|
132
|
-
collect{|record| record.person_id}
|
136
|
+
collect{|record| record.person_id}.uniq
|
133
137
|
options["<5yrs"] = under_five
|
134
138
|
#above 5 years
|
135
139
|
over_five = data.select{|record| calculate_age(record["birthdate"]) >=5 }.\
|
136
|
-
collect{|record| record.person_id}
|
140
|
+
collect{|record| record.person_id}.uniq
|
137
141
|
|
138
142
|
options[">=5yrs"] = over_five
|
139
143
|
|
@@ -450,7 +454,8 @@ module EmrOhspInterface
|
|
450
454
|
"Referals from other institutions",
|
451
455
|
"OPD total attendance",
|
452
456
|
"Referal to other institutions",
|
453
|
-
"Malaria 5 years and older - new"
|
457
|
+
"Malaria 5 years and older - new",
|
458
|
+
"HIV/AIDS - new"
|
454
459
|
]
|
455
460
|
|
456
461
|
special_under_five_indicators = [
|
@@ -504,27 +509,18 @@ module EmrOhspInterface
|
|
504
509
|
end
|
505
510
|
|
506
511
|
if key.eql?("OPD total attendance")
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
select('encounter.encounter_type, n.family_name, n.given_name,
|
520
|
-
obs.value_coded, obs.obs_datetime, p.*, c.name visit_type,
|
521
|
-
a.state_province district, a.township_division ta, a.city_village village').\
|
522
|
-
order('n.date_created DESC').group('n.person_id, encounter.encounter_id')
|
523
|
-
|
524
|
-
all = data.collect{|record| record.person_id}
|
525
|
-
|
526
|
-
options["ids"] = all
|
527
|
-
|
512
|
+
programID = Program.find_by_name 'OPD Program'
|
513
|
+
data = Encounter.find_by_sql(
|
514
|
+
"SELECT patient_id, DATE_FORMAT(encounter_datetime,'%Y-%m-%d') enc_date
|
515
|
+
FROM encounter e
|
516
|
+
LEFT OUTER JOIN person p ON p.person_id = e.patient_id
|
517
|
+
WHERE e.voided = 0 AND encounter_datetime BETWEEN '" + start_date.to_date.strftime('%Y-%m-%d 00:00:00') +"'
|
518
|
+
AND '" + end_date.to_date.strftime('%Y-%m-%d 23:59:59') + "'
|
519
|
+
AND program_id ='" + programID.program_id.to_s + "'
|
520
|
+
GROUP BY enc_date"
|
521
|
+
).map{|e| e. patient_id}
|
522
|
+
|
523
|
+
options["ids"] = data
|
528
524
|
collection[key] = options
|
529
525
|
end
|
530
526
|
|
@@ -534,11 +530,19 @@ module EmrOhspInterface
|
|
534
530
|
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),'7414').\
|
535
531
|
joins('LEFT JOIN location l ON l.location_id = obs.value_text').\
|
536
532
|
select('obs.person_id').order('obs_datetime DESC')
|
537
|
-
|
538
533
|
all = data.collect{|record| record.person_id}
|
534
|
+
options["ids"] = all
|
535
|
+
collection[key] = options
|
536
|
+
end
|
539
537
|
|
538
|
+
if key.eql?("HIV/AIDS - new")
|
539
|
+
data = ActiveRecord::Base.connection.select_all(
|
540
|
+
"SELECT * FROM temp_earliest_start_date
|
541
|
+
WHERE date_enrolled BETWEEN '#{start_date}' AND '#{end_date}'
|
542
|
+
AND date_enrolled = earliest_start_date
|
543
|
+
GROUP BY patient_id" ).to_hash
|
544
|
+
all = data.collect{|record| record["patient_id"]}
|
540
545
|
options["ids"] = all
|
541
|
-
|
542
546
|
collection[key] = options
|
543
547
|
end
|
544
548
|
|
@@ -632,7 +636,7 @@ module EmrOhspInterface
|
|
632
636
|
def weeks_generator
|
633
637
|
|
634
638
|
weeks = Hash.new
|
635
|
-
first_day = (
|
639
|
+
first_day = (Date.today - (11).month).at_beginning_of_month
|
636
640
|
wk_of_first_day = first_day.cweek
|
637
641
|
|
638
642
|
if wk_of_first_day > 1
|
@@ -671,7 +675,7 @@ module EmrOhspInterface
|
|
671
675
|
def send_data(data,type)
|
672
676
|
# method used to post data to the server
|
673
677
|
#prepare payload here
|
674
|
-
conn =
|
678
|
+
conn = server_config['ohsp']
|
675
679
|
payload = {
|
676
680
|
"dataSet" =>get_data_set_id(type),
|
677
681
|
"period"=>(type.eql?("weekly") ? weeks_generator.last[0] : months_generator.first[0]),
|
@@ -733,18 +737,18 @@ module EmrOhspInterface
|
|
733
737
|
headers:{'Content-Type'=> 'application/json'},
|
734
738
|
payload: payload.to_json,
|
735
739
|
#headers: {accept: :json},
|
736
|
-
user: conn["
|
737
|
-
password: conn["
|
740
|
+
user: conn["username"],
|
741
|
+
password: conn["password"])
|
738
742
|
|
739
743
|
puts send
|
740
744
|
end
|
741
745
|
|
742
746
|
def send_data_to_sms_portal(data, concept_name_collection)
|
743
|
-
conn2 =
|
747
|
+
conn2 = server_config['idsr_sms']
|
744
748
|
data = data.select {|k,v| v.select {|kk,vv| vv.length > 0}.length > 0}
|
745
749
|
payload = {
|
746
|
-
"email"=> conn2["
|
747
|
-
"password" => conn2["
|
750
|
+
"email"=> conn2["username"],
|
751
|
+
"password" => conn2["password"],
|
748
752
|
"emr_facility_id" => Location.current_health_center.id,
|
749
753
|
"emr_facility_name" => Location.current_health_center.name,
|
750
754
|
"payload" => data,
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Manda, Petros Kayange, and Dominic Kasanga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,6 +72,26 @@ dependencies:
|
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: sqlite3
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.3.6
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '1.3'
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.3.6
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.3'
|
75
95
|
description:
|
76
96
|
email:
|
77
97
|
- justinmandah@gmail.com, kayangepetros@gmail.com, dominickasanga@gmail.com
|
@@ -120,7 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
140
|
- !ruby/object:Gem::Version
|
121
141
|
version: '0'
|
122
142
|
requirements: []
|
123
|
-
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.7.6
|
124
145
|
signing_key:
|
125
146
|
specification_version: 4
|
126
147
|
summary: This in a gem that facilitates interfacing of EMR, One Health Surveillance
|