emr_ohsp_interface 1.2.0 → 1.2.2
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: be2ba0df688b91d1575492fa6baaf5c9e89a80f6b364eb92e100268e717260fb
|
4
|
+
data.tar.gz: 70ea97490458b7f611e558a59000dbf9c7987154cdadb581bf1f2935e7adf5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963c904f3a7e1cdaa64ac8c9df78a3ff0746c272796871bfde4e525084d4698ceb1c9fc8c36b2fca009f0784f534da87fa24077c66f095d9662047c90ee3d07e
|
7
|
+
data.tar.gz: 6d33652b469e327a19c3b3fa28ad7837598f62470d3baef1c6007d30574ad2fb25045a2cbba6e76980f97de726bbffd25d48307536070a870903942e410a4b1a
|
@@ -443,13 +443,8 @@ module EmrOhspInterface
|
|
443
443
|
end
|
444
444
|
|
445
445
|
def generate_hmis_17_report(start_date=nil,end_date=nil)
|
446
|
-
|
447
446
|
diag_map = settings["hmis_17_map"]
|
448
|
-
|
449
|
-
#pull the data
|
450
|
-
type = EncounterType.find_by_name 'Outpatient diagnosis'
|
451
447
|
collection = {}
|
452
|
-
|
453
448
|
special_indicators = [
|
454
449
|
"Referals from other institutions",
|
455
450
|
"OPD total attendance",
|
@@ -457,124 +452,68 @@ module EmrOhspInterface
|
|
457
452
|
"Malaria 5 years and older - new",
|
458
453
|
"HIV/AIDS - new"
|
459
454
|
]
|
460
|
-
|
461
455
|
special_under_five_indicators = [
|
462
456
|
"Measles under five years - new",
|
463
457
|
"Pneumonia under 5 years- new",
|
464
458
|
"Dysentery under 5 years - new",
|
465
459
|
"Diarrhoea non - bloody -new cases (under5)",
|
466
|
-
"Malaria under 5 years - new"
|
460
|
+
"Malaria under 5 years - new",
|
461
|
+
"Acute respiratory infections U5 - new"
|
467
462
|
]
|
468
463
|
|
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
|
-
|
511
|
-
if key.eql?("OPD total attendance")
|
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
464
|
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
collection[key] =
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
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)
|
465
|
+
reg_data = registration_report(start_date,end_date)
|
466
|
+
|
467
|
+
data =Observation.where("obs_datetime BETWEEN ? AND ? AND c.voided = ? AND obs.concept_id IN (?) ",
|
468
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'), end_date.to_date.strftime('%Y-%m-%d 23:59:59'),0, [6543, 6542]).\
|
469
|
+
joins('INNER JOIN concept_name c ON c.concept_id = obs.value_coded
|
470
|
+
INNER JOIN person p ON p.person_id = obs.person_id').\
|
471
|
+
pluck("c.name, CASE WHEN (SELECT timestampdiff(year, birthdate, '#{end_date.to_date.strftime('%Y-%m-%d')}')) >= 5 THEN 'more_than_5'
|
472
|
+
ELSE 'less_than_5' END AS age_group,p.person_id").group_by(&:shift)
|
473
|
+
|
474
|
+
diag_map.each do |key, value|
|
475
|
+
collection[key] = { "ids" => [] }
|
476
|
+
if key.eql?("OPD total attendance")
|
477
|
+
collection[key]["ids"] = reg_data.map { |item| item[1] }
|
478
|
+
else
|
479
|
+
if key.eql?("Referals from other institutions")
|
480
|
+
reg_data = reg_data.rows.group_by(&:shift)
|
481
|
+
collection[key]["ids"]= reg_data['Referral'].flatten
|
482
|
+
end
|
567
483
|
end
|
568
|
-
|
569
|
-
|
570
|
-
|
484
|
+
data.each do |phrase, counts|
|
485
|
+
next unless value.include?(phrase)
|
486
|
+
|
487
|
+
counts.each do |label, count|
|
488
|
+
if !key.eql?("Malaria 5 years and older - new") && !special_under_five_indicators.include?(key)
|
489
|
+
collection[key]["ids"] << count
|
490
|
+
else
|
491
|
+
if ((special_under_five_indicators.include?(key) && label.eql?("less_than_5")) ||
|
492
|
+
(key.eql?("Malaria 5 years and older - new") && label.eql?("more_than_5")))
|
493
|
+
collection[key]["ids"] << count
|
494
|
+
end
|
495
|
+
end
|
496
|
+
end
|
571
497
|
end
|
572
|
-
|
573
498
|
end
|
574
|
-
|
575
|
-
|
576
|
-
collection
|
499
|
+
collection
|
500
|
+
end
|
577
501
|
|
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
|
578
517
|
end
|
579
518
|
|
580
519
|
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: 1.2.
|
4
|
+
version: 1.2.2
|
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: 2023-
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,26 +72,6 @@ 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'
|
95
75
|
description:
|
96
76
|
email:
|
97
77
|
- justinmandah@gmail.com, kayangepetros@gmail.com, dominickasanga@gmail.com
|
@@ -140,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
120
|
- !ruby/object:Gem::Version
|
141
121
|
version: '0'
|
142
122
|
requirements: []
|
143
|
-
|
144
|
-
rubygems_version: 2.7.6
|
123
|
+
rubygems_version: 3.0.9
|
145
124
|
signing_key:
|
146
125
|
specification_version: 4
|
147
126
|
summary: This in a gem that facilitates interfacing of EMR, One Health Surveillance
|