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 +4 -4
- data/app/services/lab/lims/config.rb +3 -2
- data/app/services/lab/lims/order_serializer.rb +42 -3
- data/app/services/lab/lims/worker.rb +2 -2
- data/lib/lab/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e6be868d3a1113b834bf4e6644734eead3e01d7b51f90e310e3020eb8125b6c
|
4
|
+
data.tar.gz: bd7ca74bdf0af442d3a4c6f9a1f9e0a73d4d61571f1e39ae6ce5352246cd801d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
33
|
+
worker.push_orders
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/lib/lab/version.rb
CHANGED
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
|
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-
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: couchrest
|