his_emr_api_lab 0.0.6 → 0.0.11
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/labelling_service/order_label.rb +27 -6
- data/app/services/lab/lims/migrator.rb +4 -2
- data/app/services/lab/lims/order_dto.rb +8 -2
- data/app/services/lab/lims/utils.rb +2 -0
- data/app/services/lab/lims/worker.rb +3 -1
- 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: 060337303a9a04fc0f9cebbe525f2275964b41776297b440bc9d7ea4c25c39b8
|
4
|
+
data.tar.gz: 5cc5383ab62d941de6a0d5fa2f51c5199461f141459cea072b40c004277855d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25e70f8e501dd0f0edf25b6f202f41129842fe5099cd5e6d977035df063d9233ac38b98e51ebdd2c2bcb382524da111b42138815d0a48c02e5bdb979b43c8127
|
7
|
+
data.tar.gz: 950d9d988b026ac2dbaed9f63be620cc474816aaba77c64231291e721e463f2872a20c2f629a553d1c52c0689e20afb28d44fa1c981807e1a0c4ed7945d6103f
|
@@ -27,7 +27,7 @@ module Lab
|
|
27
27
|
'',
|
28
28
|
drawer,
|
29
29
|
'',
|
30
|
-
|
30
|
+
tests,
|
31
31
|
reason_for_test,
|
32
32
|
order.accession_number,
|
33
33
|
order.accession_number)
|
@@ -36,7 +36,7 @@ module Lab
|
|
36
36
|
def reason_for_test
|
37
37
|
return 'Unknown' unless order.reason_for_test
|
38
38
|
|
39
|
-
|
39
|
+
short_concept_name(order.reason_for_test.value_coded) || 'Unknown'
|
40
40
|
end
|
41
41
|
|
42
42
|
def patient
|
@@ -60,11 +60,14 @@ module Lab
|
|
60
60
|
def drawer
|
61
61
|
return 'N/A' if order.concept_id == unknown_concept.concept_id
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
drawer_id = order.discontinued_by || order.creator
|
64
|
+
draw_date = (order.discontinued_date || order.start_date).strftime('%d/%^b/%Y %H:%M:%S')
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
name = PersonName.find_by_person_id(drawer_id)
|
67
|
+
return "#{name.given_name} #{name.family_name} #{draw_date}" if name
|
68
|
+
|
69
|
+
user = User.find_by_user_id(drawer_id)
|
70
|
+
user ? "#{user.username} #{draw_date}" : 'N/A'
|
68
71
|
end
|
69
72
|
|
70
73
|
def specimen
|
@@ -73,6 +76,24 @@ module Lab
|
|
73
76
|
ConceptName.find_by_concept_id(order.concept_id)&.name || 'Unknown'
|
74
77
|
end
|
75
78
|
|
79
|
+
def tests
|
80
|
+
tests = order.tests.map do |test|
|
81
|
+
name = short_concept_name(test.value_coded) || 'Unknown'
|
82
|
+
|
83
|
+
next 'VL' if name.match?(/Viral load/i)
|
84
|
+
|
85
|
+
name.size > 7 ? name[0..6] : name
|
86
|
+
end
|
87
|
+
|
88
|
+
tests.join(', ')
|
89
|
+
end
|
90
|
+
|
91
|
+
def short_concept_name(concept_id)
|
92
|
+
ConceptName.where(concept_id: concept_id)
|
93
|
+
.min_by { |concept| concept.name.size }
|
94
|
+
&.name
|
95
|
+
end
|
96
|
+
|
76
97
|
def unknown_concept
|
77
98
|
ConceptName.find_by_name('Unknown')
|
78
99
|
end
|
@@ -142,9 +142,10 @@ module Lab
|
|
142
142
|
MIGRATION_REJECTIONS_CSV_PATH = LIMS_LOG_PATH.join('migration-rejections.csv')
|
143
143
|
|
144
144
|
def self.export_rejections(rejections)
|
145
|
-
headers = ['Accession number', 'NHID', 'First name', 'Last name', 'Reason']
|
145
|
+
headers = ['doc_id', 'Accession number', 'NHID', 'First name', 'Last name', 'Reason']
|
146
146
|
rows = (rejections || []).map do |rejection|
|
147
147
|
[
|
148
|
+
rejection.order[:_id],
|
148
149
|
rejection.order[:tracking_number],
|
149
150
|
rejection.order[:patient][:id],
|
150
151
|
rejection.order[:patient][:first_name],
|
@@ -159,9 +160,10 @@ module Lab
|
|
159
160
|
MIGRATION_FAILURES_CSV_PATH = LIMS_LOG_PATH.join('migration-failures.csv')
|
160
161
|
|
161
162
|
def self.export_failures
|
162
|
-
headers = ['Accession number', 'NHID', 'Reason', 'Difference']
|
163
|
+
headers = ['doc_id', 'Accession number', 'NHID', 'Reason', 'Difference']
|
163
164
|
rows = Lab::LimsFailedImport.all.map do |failure|
|
164
165
|
[
|
166
|
+
failure.lims_id,
|
165
167
|
failure.tracking_number,
|
166
168
|
failure.patient_nhid,
|
167
169
|
failure.reason,
|
@@ -30,9 +30,9 @@ module Lab
|
|
30
30
|
|
31
31
|
# Translates a LIMS specimen name to an OpenMRS concept_id
|
32
32
|
def specimen_type_id
|
33
|
-
lims_specimen_name = self['sample_type']
|
33
|
+
lims_specimen_name = self['sample_type']&.strip&.downcase
|
34
34
|
|
35
|
-
if %w[specimen_not_collected not_assigned].include?(lims_specimen_name)
|
35
|
+
if %w[specimen_not_collected not_assigned not_specified].include?(lims_specimen_name)
|
36
36
|
return ConceptName.select(:concept_id).find_by_name!('Unknown').concept_id
|
37
37
|
end
|
38
38
|
|
@@ -53,6 +53,8 @@ module Lab
|
|
53
53
|
|
54
54
|
# Extract requesting clinician name from LIMS
|
55
55
|
def requesting_clinician
|
56
|
+
return 'Unknown' unless self['who_order_test']
|
57
|
+
|
56
58
|
# TODO: Extend requesting clinician to an obs tree having extra parameters
|
57
59
|
# like phone number and ID to closely match the lims user.
|
58
60
|
first_name = self['who_order_test']['first_name'] || ''
|
@@ -67,6 +69,10 @@ module Lab
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def start_date
|
72
|
+
if self['date_created'].blank?
|
73
|
+
raise LimsException, 'Order missing created date'
|
74
|
+
end
|
75
|
+
|
70
76
|
Utils.parse_date(self['date_created'])
|
71
77
|
end
|
72
78
|
|
@@ -66,6 +66,8 @@ module Lab
|
|
66
66
|
Date.strptime(str_date, '%d-%m-%Y').strftime('%Y-%m-%d')
|
67
67
|
elsif str_date.match?(/(\d{4}\d{2}\d{2})\d+/)
|
68
68
|
Date.strptime(str_date, '%Y%m%d').strftime('%Y-%m-%d')
|
69
|
+
elsif str_date.match?(%r{\d{2}/\d{2}/\d{4}})
|
70
|
+
str_date.to_date.to_s
|
69
71
|
else
|
70
72
|
Rails.logger.warn("Invalid date: #{str_date}")
|
71
73
|
parse_date(fallback_date)
|
@@ -28,7 +28,9 @@ module Lab
|
|
28
28
|
fout.write("Worker ##{Process.pid} started at #{Time.now}")
|
29
29
|
worker = new(Api.new)
|
30
30
|
worker.pull_orders
|
31
|
-
|
31
|
+
# TODO: Verify that names being pushed to LIMS are of the correct format (ie matching
|
32
|
+
# LIMS naming conventions). Enable pushing when that is done
|
33
|
+
# worker.push_orders
|
32
34
|
end
|
33
35
|
end
|
34
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: 0.0.11
|
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-04-
|
11
|
+
date: 2021-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: couchrest
|