his_emr_api_lab 0.0.15 → 1.0.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: 2a7b072fd83de5ea6c03054521d68b82ac2c01237097a8ea9748113b5446a285
4
- data.tar.gz: 5a67e4211a1d0b61d6f8a51357ee2a9fb898bd1c7973d2fc224039451f0a00d1
3
+ metadata.gz: 7e6be868d3a1113b834bf4e6644734eead3e01d7b51f90e310e3020eb8125b6c
4
+ data.tar.gz: bd7ca74bdf0af442d3a4c6f9a1f9e0a73d4d61571f1e39ae6ce5352246cd801d
5
5
  SHA512:
6
- metadata.gz: ea314a6c8598617ae9f8ef0cb272d3258ecc50d60f2226103625edd2a11ae7a49bbb08915816ffe3650c3bd78339db7373ee96b63e0a7072c3a703c2e62ecca7
7
- data.tar.gz: ba1049dbb93d3d842cb31eae9a88e939e0e687e0a2d866432c07713bc670d75c92760dbdd2a22c89f733f00ccc2382b757cd0a4f32563a590fedfe253c6af5a2
6
+ metadata.gz: 7c122f5fbc967d7e470aac9eb455f77d9471a40caa582a9306d4558a25094d8efba17a9aca25ea312609ac9c7571cf154f463a0c65a55387bb8a030dcf48b7c6
7
+ data.tar.gz: 9c68ca05bb1accaac6942c37f2399ae5ef5f94bde87cbd30811f35e394a9b2a43e2671f266173839156b980c3030051fc5e9fc4103c3b8f41a7dcd84e5324e35
@@ -45,10 +45,11 @@ module Lab
45
45
  paths = [
46
46
  "#{ENV['HOME']}/apps/nlims_controller/config/#{filename}",
47
47
  "/var/www/nlims_controller/config/#{filename}",
48
- Rails.root.parent.join("nlims_controller/config/#{filename}"),
49
- Rails.root.join('config/lims-couch.yml')
48
+ Rails.root.parent.join("nlims_controller/config/#{filename}")
50
49
  ]
51
50
 
51
+ paths = [Rails.root.join('config/lims-couchdb.yml'), *paths] if filename == 'couchdb.yml'
52
+
52
53
  paths.each do |path|
53
54
  Rails.logger.debug("Looking for LIMS couchdb config at: #{path}")
54
55
  return path if File.exist?(path)
@@ -24,6 +24,8 @@ module Lab
24
24
  sample_type: format_sample_type(serialized_order.specimen.name),
25
25
  sample_status: format_sample_status(serialized_order.specimen.name),
26
26
  sample_statuses: format_sample_status_trail(order),
27
+ test_statuses: format_test_status_trail(order),
28
+ who_order_test: format_orderer(order),
27
29
  districy: current_district, # yes districy [sic]...
28
30
  priority: serialized_order.reason_for_test.name,
29
31
  date_created: serialized_order.order_date,
@@ -75,9 +77,7 @@ module Lab
75
77
  end
76
78
 
77
79
  def format_sample_status_trail(order)
78
- if order.concept_id == ConceptName.find_by_name!('Unknown').concept_id
79
- return []
80
- end
80
+ return [] if order.concept_id == ConceptName.find_by_name!('Unknown').concept_id
81
81
 
82
82
  user = User.find(order.discontinued_by || order.creator)
83
83
  drawn_by = PersonName.find_by_person_id(user.user_id)
@@ -96,6 +96,31 @@ module Lab
96
96
  ]
97
97
  end
98
98
 
99
+ def format_test_status_trail(order)
100
+ order.tests.each_with_object({}) do |test, trail|
101
+ test_name = ConceptName.find_by_concept_id!(test.value_coded).name
102
+ test_name = 'Viral load' if test_name.casecmp?('HIV Viral Load')
103
+
104
+ current_test_trail = trail[test_name] = {}
105
+
106
+ current_test_trail[test.obs_datetime.strftime('%Y%m%d%H%M%S')] = {
107
+ status: 'Drawn',
108
+ updated_by: find_user(test.creator)
109
+ }
110
+
111
+ next unless test.result
112
+
113
+ current_test_trail[test.obs_datetime.strftime('%Y%m%d%H%M%S')] = {
114
+ status: 'Verified',
115
+ updated_by: find_user(test.result.creator)
116
+ }
117
+ end
118
+ end
119
+
120
+ def format_orderer(order)
121
+ find_user(order.creator)
122
+ end
123
+
99
124
  def format_test_results(order)
100
125
  order.tests&.each_with_object({}) do |test, results|
101
126
  next unless test.result
@@ -134,6 +159,20 @@ module Lab
134
159
  def current_facility_name
135
160
  current_health_center.name
136
161
  end
162
+
163
+ def find_user(user_id)
164
+ user = User.find(user_id)
165
+ person_name = PersonName.find_by(person_id: user.person_id)
166
+ phone_number = PersonAttribute.find_by(type: PersonAttributeType.where(name: 'Cell phone number'),
167
+ person_id: user.person_id)
168
+
169
+ {
170
+ first_name: person_name&.given_name,
171
+ last_name: person_name&.family_name,
172
+ phone_number: phone_number&.value,
173
+ id: user.username
174
+ }
175
+ end
137
176
  end
138
177
  end
139
178
  end
@@ -26,11 +26,11 @@ module Lab
26
26
  User.current = Utils.lab_user
27
27
 
28
28
  fout.write("Worker ##{Process.pid} started at #{Time.now}")
29
- worker = new(CouchDbApi.new)
29
+ worker = new(Api::CouchDbApi.new)
30
30
  worker.pull_orders
31
31
  # TODO: Verify that names being pushed to LIMS are of the correct format (ie matching
32
32
  # LIMS naming conventions). Enable pushing when that is done
33
- # worker.push_orders
33
+ worker.push_orders
34
34
  end
35
35
  end
36
36
 
data/lib/lab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lab
4
- VERSION = '0.0.15'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: his_emr_api_lab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elizabeth Glaser Pediatric Foundation Malawi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-21 00:00:00.000000000 Z
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: couchrest