emr_ohsp_interface 1.0.1 → 1.1.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: 649cb3e2144f053db93789503c1cd14bb48263a93c31d9fa92eb3edb30a54e42
|
4
|
+
data.tar.gz: 8f80cd97e51363c047610f2ac3661ca2cc967d81d1a475c157d9a402d3f009aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a965d0f5e3d1bbbf830bdba32faad6426ca5a34970b908808b7165e8fa5a1851688e54f1a16b6c38ee545a3e59440c74c5d074642009f648258a600e264977f
|
7
|
+
data.tar.gz: 483de992deb8ab577a65821ebb60b8f6aaeaeb209d5d570eccf27aa996eb13c2dd7f59a948b847bbaa1d1ced9c6c9dc5398edd6c7e1a136fd9ea3cec24726bec
|
data/MIT-LICENSE
CHANGED
@@ -18,6 +18,10 @@ class EmrOhspInterface::EmrOhspInterfaceController < ::ApplicationController
|
|
18
18
|
def generate_hmis_15_report
|
19
19
|
render json: service.generate_hmis_15_report(params[:start_date],params[:end_date]);
|
20
20
|
end
|
21
|
+
|
22
|
+
def generate_hmis_17_report
|
23
|
+
render json: service.generate_hmis_17_report(params[:start_date],params[:end_date]);
|
24
|
+
end
|
21
25
|
|
22
26
|
def service
|
23
27
|
EmrOhspInterface::EmrOhspInterfaceService
|
@@ -267,7 +267,10 @@ module EmrOhspInterface
|
|
267
267
|
|
268
268
|
special_indicators = ["Malaria - new cases (under 5)",
|
269
269
|
"Malaria - new cases (5 & over)",
|
270
|
-
"HIV confirmed positive (15-49 years) new cases"
|
270
|
+
"HIV confirmed positive (15-49 years) new cases",
|
271
|
+
"Diarrhoea non - bloody -new cases (under5)",
|
272
|
+
"Malnutrition - new case (under 5)",
|
273
|
+
"Acute respiratory infections - new cases (U5)"
|
271
274
|
]
|
272
275
|
|
273
276
|
diag_map.each do |key,value|
|
@@ -317,7 +320,6 @@ module EmrOhspInterface
|
|
317
320
|
options["ids"] = under_five
|
318
321
|
|
319
322
|
collection[key] = options
|
320
|
-
|
321
323
|
end
|
322
324
|
|
323
325
|
if key.eql?("Malaria - new cases (5 & over)")
|
@@ -352,11 +354,225 @@ module EmrOhspInterface
|
|
352
354
|
|
353
355
|
collection[key] = options
|
354
356
|
end
|
357
|
+
|
358
|
+
if key.eql?("Diarrhoea non - bloody -new cases (under5)")
|
359
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
360
|
+
AND encounter_type = ? AND value_coded IN (?)
|
361
|
+
AND concept_id IN(6543, 6542)',
|
362
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
363
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
364
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
365
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
366
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
367
|
+
|
368
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5 }.\
|
369
|
+
collect{|record| record["person_id"]}
|
370
|
+
|
371
|
+
options["ids"] = under_five
|
372
|
+
|
373
|
+
collection[key] = options
|
374
|
+
end
|
375
|
+
|
376
|
+
if key.eql?("Malnutrition - new case (under 5)")
|
377
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
378
|
+
AND encounter_type = ? AND value_coded IN (?)
|
379
|
+
AND concept_id IN(6543, 6542)',
|
380
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
381
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
382
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
383
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
384
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
385
|
+
|
386
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5 }.\
|
387
|
+
collect{|record| record["person_id"]}
|
388
|
+
|
389
|
+
options["ids"] = under_five
|
390
|
+
|
391
|
+
collection[key] = options
|
392
|
+
end
|
393
|
+
|
394
|
+
if key.eql?("Acute respiratory infections - new cases (U5)")
|
395
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
396
|
+
AND encounter_type = ? AND value_coded IN (?)
|
397
|
+
AND concept_id IN(6543, 6542)',
|
398
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
399
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
400
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
401
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
402
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
403
|
+
|
404
|
+
under_five = data.select{|record| calculate_age(record["birthdate"]) < 5 }.\
|
405
|
+
collect{|record| record["person_id"]}
|
406
|
+
|
407
|
+
options["ids"] = under_five
|
408
|
+
|
409
|
+
collection[key] = options
|
410
|
+
end
|
411
|
+
|
355
412
|
end
|
356
413
|
end
|
357
414
|
collection
|
358
415
|
end
|
359
416
|
|
417
|
+
def disaggregate(disaggregate_key, concept_ids, start_date, end_date, type)
|
418
|
+
options = {"ids"=>nil}
|
419
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
420
|
+
AND encounter_type = ? AND value_coded IN (?)
|
421
|
+
AND concept_id IN(6543, 6542)',
|
422
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
423
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
424
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
425
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
426
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
427
|
+
|
428
|
+
if disaggregate_key == "less"
|
429
|
+
options["ids"] = data.select{|record| calculate_age(record["birthdate"]) < 5 }.\
|
430
|
+
collect{|record| record["person_id"]}
|
431
|
+
else
|
432
|
+
if disaggregate_key == "greater"
|
433
|
+
options["ids"] = data.select{|record| calculate_age(record["birthdate"]) >= 5 }.\
|
434
|
+
collect{|record| record["person_id"]}
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
options
|
439
|
+
end
|
440
|
+
|
441
|
+
def generate_hmis_17_report(start_date=nil,end_date=nil)
|
442
|
+
|
443
|
+
diag_map = settings["hmis_17_map"]
|
444
|
+
|
445
|
+
#pull the data
|
446
|
+
type = EncounterType.find_by_name 'Outpatient diagnosis'
|
447
|
+
collection = {}
|
448
|
+
|
449
|
+
special_indicators = [
|
450
|
+
"Referals from other institutions",
|
451
|
+
"OPD total attendance",
|
452
|
+
"Referal to other institutions",
|
453
|
+
"Malaria 5 years and older - new"
|
454
|
+
]
|
455
|
+
|
456
|
+
special_under_five_indicators = [
|
457
|
+
"Measles under five years - new",
|
458
|
+
"Pneumonia under 5 years- new",
|
459
|
+
"Dysentery under 5 years - new",
|
460
|
+
"Diarrhoea non - bloody -new cases (under5)",
|
461
|
+
"Malaria under 5 years - new"
|
462
|
+
]
|
463
|
+
|
464
|
+
diag_map.each do |key,value|
|
465
|
+
options = {"ids"=>nil}
|
466
|
+
concept_ids = ConceptName.where(name: value).collect{|cn| cn.concept_id}
|
467
|
+
|
468
|
+
if !special_indicators.include?(key) && !special_under_five_indicators.include?(key)
|
469
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
470
|
+
AND encounter_type = ? AND value_coded IN (?)
|
471
|
+
AND concept_id IN(6543, 6542)',
|
472
|
+
start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
473
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),type.id,concept_ids).\
|
474
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
475
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id').\
|
476
|
+
select('encounter.encounter_type, obs.value_coded, p.*')
|
477
|
+
|
478
|
+
all = data.collect{|record| record.person_id}
|
479
|
+
|
480
|
+
|
481
|
+
options["ids"] = all
|
482
|
+
|
483
|
+
collection[key] = options
|
484
|
+
else
|
485
|
+
if key.eql?("Referals from other institutions")
|
486
|
+
_type = EncounterType.find_by_name 'PATIENT REGISTRATION'
|
487
|
+
visit_type = ConceptName.find_by_name 'Type of visit'
|
488
|
+
|
489
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
490
|
+
AND encounter_type = ? AND value_coded IS NOT NULL
|
491
|
+
AND obs.concept_id = ?', start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
492
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),_type.id, visit_type.concept_id).\
|
493
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
494
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id
|
495
|
+
INNER JOIN concept_name c ON c.concept_id = 6541').\
|
496
|
+
select('encounter.encounter_type, obs.value_coded, obs.obs_datetime, p.*, c.name visit_type').\
|
497
|
+
group('p.person_id, encounter.encounter_id')
|
498
|
+
|
499
|
+
all = data.collect{|record| record.person_id}
|
500
|
+
|
501
|
+
options["ids"] = all
|
502
|
+
|
503
|
+
collection[key] = options
|
504
|
+
end
|
505
|
+
|
506
|
+
if key.eql?("OPD total attendance")
|
507
|
+
_type = EncounterType.find_by_name 'PATIENT REGISTRATION'
|
508
|
+
visit_type = ConceptName.find_by_name 'Type of visit'
|
509
|
+
|
510
|
+
data = Encounter.where('encounter_datetime BETWEEN ? AND ?
|
511
|
+
AND encounter_type = ? AND value_coded IS NOT NULL
|
512
|
+
AND obs.concept_id = ?', start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
513
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),_type.id, visit_type.concept_id).\
|
514
|
+
joins('INNER JOIN obs ON obs.encounter_id = encounter.encounter_id
|
515
|
+
INNER JOIN person p ON p.person_id = encounter.patient_id
|
516
|
+
INNER JOIN concept_name c ON c.concept_id = obs.value_coded
|
517
|
+
LEFT JOIN person_name n ON n.person_id = encounter.patient_id AND n.voided = 0
|
518
|
+
RIGHT JOIN person_address a ON a.person_id = encounter.patient_id').\
|
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
|
+
|
528
|
+
collection[key] = options
|
529
|
+
end
|
530
|
+
|
531
|
+
if key.eql?("Referal to other institutions")
|
532
|
+
data = Observation.where("obs_datetime BETWEEN ? AND ?
|
533
|
+
AND concept_id = ?",start_date.to_date.strftime('%Y-%m-%d 00:00:00'),
|
534
|
+
end_date.to_date.strftime('%Y-%m-%d 23:59:59'),'7414').\
|
535
|
+
joins('LEFT JOIN location l ON l.location_id = obs.value_text').\
|
536
|
+
select('obs.person_id').order('obs_datetime DESC')
|
537
|
+
|
538
|
+
all = data.collect{|record| record.person_id}
|
539
|
+
|
540
|
+
options["ids"] = all
|
541
|
+
|
542
|
+
collection[key] = options
|
543
|
+
end
|
544
|
+
|
545
|
+
if key.eql?("Measles under five years - new")
|
546
|
+
collection[key] = disaggregate('less',concept_ids, start_date, end_date, type)
|
547
|
+
end
|
548
|
+
|
549
|
+
if key.eql?("Pneumonia under 5 years- new")
|
550
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
551
|
+
end
|
552
|
+
|
553
|
+
if key.eql?("Malaria under 5 years - new")
|
554
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
555
|
+
end
|
556
|
+
|
557
|
+
if key.eql?("Malaria 5 years and older - new")
|
558
|
+
collection[key] = disaggregate('greater',concept_ids, start_date, end_date, type)
|
559
|
+
end
|
560
|
+
|
561
|
+
if key.eql?("Dysentery under 5 years - new")
|
562
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
563
|
+
end
|
564
|
+
|
565
|
+
if key.eql?("Diarrhoea non - bloody -new cases (under5)")
|
566
|
+
collection[key] = disaggregate('less', concept_ids, start_date, end_date, type)
|
567
|
+
end
|
568
|
+
|
569
|
+
end
|
570
|
+
end
|
571
|
+
|
572
|
+
collection
|
573
|
+
|
574
|
+
end
|
575
|
+
|
360
576
|
def generate_notifiable_disease_conditions_report(start_date=nil,end_date=nil)
|
361
577
|
diag_map = settings["notifiable_disease_conditions"]
|
362
578
|
|
data/config/routes.rb
CHANGED
@@ -6,6 +6,7 @@ EmrOhspInterface::Engine.routes.draw do
|
|
6
6
|
get '/generate_weekly_idsr_report', to: 'emr_ohsp_interface#generate_weekly_idsr_report'
|
7
7
|
get '/generate_monthly_idsr_report', to: 'emr_ohsp_interface#generate_monthly_idsr_report'
|
8
8
|
get '/generate_hmis_15_report', to: 'emr_ohsp_interface#generate_hmis_15_report'
|
9
|
+
get '/generate_hmis_17_report', to: 'emr_ohsp_interface#generate_hmis_17_report'
|
9
10
|
|
10
11
|
# for the new crossplatform OPD system
|
11
12
|
get 'api/v1/get_lims_user', to: 'emr_lims_interface#get_user_info'
|
@@ -14,4 +15,5 @@ EmrOhspInterface::Engine.routes.draw do
|
|
14
15
|
get 'api/v1/generate_weekly_idsr_report', to: 'emr_ohsp_interface#generate_weekly_idsr_report'
|
15
16
|
get 'api/v1/generate_monthly_idsr_report', to: 'emr_ohsp_interface#generate_monthly_idsr_report'
|
16
17
|
get 'api/v1/generate_hmis_15_report', to: 'emr_ohsp_interface#generate_hmis_15_report'
|
18
|
+
get 'api/v1/generate_hmis_17_report', to: 'emr_ohsp_interface#generate_hmis_17_report'
|
17
19
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Justin Manda and
|
7
|
+
- Justin Manda, Petros Kayange, and Dominic Kasanga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
version: '0'
|
75
75
|
description:
|
76
76
|
email:
|
77
|
-
- justinmandah@gmail.com, kayangepetros@gmail.com
|
77
|
+
- justinmandah@gmail.com, kayangepetros@gmail.com, dominickasanga@gmail.com
|
78
78
|
executables: []
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|