emr_ohsp_interface 2.2.0 → 2.2.1
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: 86336368f0f6cbc641d1e348ca0b22ceb80e8ee948bc4659d8b8e60d70d249d3
|
4
|
+
data.tar.gz: b8b7dbb8e07193f0f05870a20e5c00fc29c5d74762bf037579a0a557244a01fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c5cda9dbcd781ed721ba4f1e1e6ba71f31a7588887602c49955fbdb386cf97a00dc2629ae2aa6c8cf6f10b4b36b93c08b4a5390886a9f62c0935177009d6800
|
7
|
+
data.tar.gz: 5fb825a8002a881f4a897da1c729ee8e566d474749aef17a7780967ca7cb2b13fe6ee6d8eabad3ba8a2bcadbea996487594ccf7de0cfbb7aeb8fc0cb4d806594
|
@@ -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
|
+
c.name 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: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Manda, Petros Kayange, Dominic Kasanga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|