emr_ohsp_interface 1.2.3 → 2.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 +4 -4
- data/app/services/emr_ohsp_interface/emr_ohsp_interface_service.rb +111 -50
- data/lib/emr_ohsp_interface/version.rb +1 -1
- metadata +28 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c906580f753b4ecd4247310a6e86515ba23ac8f34a022d17c2d133eb8e35ce8
|
4
|
+
data.tar.gz: 0343e303c83d845d8e6764797157e056fdc4a34d3060e28d0978b80c32ed292a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363dcd8068deb4bab8a6ce38463a173e7e32ea958eb0699fae6c9f8a9685ade0d5248227fd7584a3d562462941e6c270a40585aab5621faa7efee3b04191a8df
|
7
|
+
data.tar.gz: 447c8cbb8205eac3365d78b7105674829888ae55c8de36dbf4e4fdb917735ec0263db733d601ec5c10f55237b92b45c52f8f2fee5a956355ddca7473d7baea17
|
@@ -443,8 +443,13 @@ module EmrOhspInterface
|
|
443
443
|
end
|
444
444
|
|
445
445
|
def generate_hmis_17_report(start_date=nil,end_date=nil)
|
446
|
+
|
446
447
|
diag_map = settings["hmis_17_map"]
|
448
|
+
|
449
|
+
#pull the data
|
450
|
+
type = EncounterType.find_by_name 'Outpatient diagnosis'
|
447
451
|
collection = {}
|
452
|
+
|
448
453
|
special_indicators = [
|
449
454
|
"Referals from other institutions",
|
450
455
|
"OPD total attendance",
|
@@ -452,68 +457,124 @@ module EmrOhspInterface
|
|
452
457
|
"Malaria 5 years and older - new",
|
453
458
|
"HIV/AIDS - new"
|
454
459
|
]
|
460
|
+
|
455
461
|
special_under_five_indicators = [
|
456
462
|
"Measles under five years - new",
|
457
463
|
"Pneumonia under 5 years- new",
|
458
464
|
"Dysentery under 5 years - new",
|
459
465
|
"Diarrhoea non - bloody -new cases (under5)",
|
460
|
-
"Malaria under 5 years - new"
|
461
|
-
"Acute respiratory infections U5 - new"
|
466
|
+
"Malaria under 5 years - new"
|
462
467
|
]
|
463
468
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
469
|
+
diag_map.each do |key,value|
|
470
|
+
options = {"ids"=>nil}
|
471
|
+
concept_ids = ConceptName.where(name: value).collect{|cn| cn.concept_id}
|
472
|
+
|
473
|
+
if !special_indicators.include?(key) && !special_under_five_indicators.include?(key)
|
474
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
475
|
+
AND encounter_type = ? AND value_coded IN (?)
|
476
|
+
AND concept_id IN(6543, 6542)',
|
477
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
478
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
479
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
480
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
481
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
482
|
+
|
483
|
+
all = data.collect{|record| record.person_id}
|
484
|
+
|
485
|
+
|
486
|
+
options["ids"] = all
|
487
|
+
|
488
|
+
collection[key] = options
|
489
|
+
else
|
490
|
+
if key.eql?("Referals from other institutions")
|
491
|
+
_type = EncounterType.find_by_name 'PATIENT REGISTRATION'
|
492
|
+
visit_type = ConceptName.find_by_name 'Type of visit'
|
493
|
+
|
494
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
495
|
+
AND encounter_type = ? AND value_coded IS NOT NULL
|
496
|
+
AND obs.concept_id = ?', start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
497
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),_type.id, visit_type.concept_id).\
|
498
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
499
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id
|
500
|
+
INNER JOIN concept_name c ON c.concept_id = 6541').\
|
501
|
+
select('encounter.encounter_type, obs.value_coded, obs.obs_datetime, p.*, c.name visit_type').\
|
502
|
+
group('p.person_id, encounter.encounter_id')
|
503
|
+
|
504
|
+
all = data.collect{|record| record.person_id}
|
505
|
+
|
506
|
+
options["ids"] = all
|
507
|
+
|
508
|
+
collection[key] = options
|
509
|
+
end
|
510
|
+
|
476
511
|
if key.eql?("OPD total attendance")
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
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
|
524
|
+
collection[key] = options
|
483
525
|
end
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
526
|
+
|
527
|
+
if key.eql?("Referal to other institutions")
|
528
|
+
data = Observation.where("obs_datetime BETWEEN ? AND ?
|
529
|
+
AND concept_id = ?",start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
530
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),'7414').\
|
531
|
+
joins('LEFT JOIN location l ON l.location_id = obs.value_text').\
|
532
|
+
select('obs.person_id').order('obs_datetime DESC')
|
533
|
+
all = data.collect{|record| record.person_id}
|
534
|
+
options["ids"] = all
|
535
|
+
collection[key] = options
|
536
|
+
end
|
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"]}
|
545
|
+
options["ids"] = all
|
546
|
+
collection[key] = options
|
547
|
+
end
|
548
|
+
|
549
|
+
if key.eql?("Measles under five years - new")
|
550
|
+
collection[key] = disaggregate('less',concept_ids, start_date, end_date, type)
|
551
|
+
end
|
552
|
+
|
553
|
+
if key.eql?("Pneumonia under 5 years- new")
|
554
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
555
|
+
end
|
556
|
+
|
557
|
+
if key.eql?("Malaria under 5 years - new")
|
558
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
559
|
+
end
|
560
|
+
|
561
|
+
if key.eql?("Malaria 5 years and older - new")
|
562
|
+
collection[key] = disaggregate('greater',concept_ids, start_date, end_date, type)
|
563
|
+
end
|
564
|
+
|
565
|
+
if key.eql?("Dysentery under 5 years - new")
|
566
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
567
|
+
end
|
568
|
+
|
569
|
+
if key.eql?("Diarrhoea non - bloody -new cases (under5)")
|
570
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
497
571
|
end
|
572
|
+
|
498
573
|
end
|
499
|
-
|
500
|
-
|
574
|
+
end
|
575
|
+
|
576
|
+
collection
|
501
577
|
|
502
|
-
def registration_report(start_date=nil,end_date=nil)
|
503
|
-
ActiveRecord::Base.connection.select_all <<~SQL
|
504
|
-
SELECT
|
505
|
-
MIN(IFNULL(c.name, 'Unidentified')) AS visit_type,
|
506
|
-
obs.person_id
|
507
|
-
FROM `encounter`
|
508
|
-
LEFT JOIN obs ON obs.encounter_id = encounter.encounter_id AND obs.voided = 0
|
509
|
-
LEFT JOIN concept_name c ON c.concept_id = obs.value_coded
|
510
|
-
AND c.name IN ('New patient','Revisiting','Referral') AND c.voided = 0
|
511
|
-
WHERE
|
512
|
-
encounter.voided = 0
|
513
|
-
AND DATE(encounter_datetime) BETWEEN '#{start_date}' AND '#{end_date}'
|
514
|
-
AND encounter.program_id = 14 -- OPD program
|
515
|
-
GROUP BY encounter.patient_id, DATE(encounter_datetime);
|
516
|
-
SQL
|
517
578
|
end
|
518
579
|
|
519
580
|
def generate_notifiable_disease_conditions_report(start_date=nil,end_date=nil)
|
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:
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Justin Manda, Petros Kayange,
|
7
|
+
- Justin Manda, Petros Kayange, Dominic Kasanga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 5.2.4.3
|
19
|
+
version: 7.0.6
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 5.2.4.3
|
26
|
+
version: 7.0.6
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rspec
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +44,14 @@ dependencies:
|
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '1'
|
47
|
+
version: '2.1'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '1'
|
54
|
+
version: '2.1'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: mysql2
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +66,26 @@ dependencies:
|
|
72
66
|
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.6
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.3'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.6
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.3'
|
75
89
|
description:
|
76
90
|
email:
|
77
91
|
- justinmandah@gmail.com, kayangepetros@gmail.com, dominickasanga@gmail.com
|
@@ -120,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
134
|
- !ruby/object:Gem::Version
|
121
135
|
version: '0'
|
122
136
|
requirements: []
|
123
|
-
rubygems_version: 3.4.
|
137
|
+
rubygems_version: 3.4.10
|
124
138
|
signing_key:
|
125
139
|
specification_version: 4
|
126
140
|
summary: This in a gem that facilitates interfacing of EMR, One Health Surveillance
|