his_emr_api_lab 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +3 -1
- data/app/controllers/lab/application_controller.rb +5 -0
- data/app/controllers/lab/orders_controller.rb +3 -3
- data/app/controllers/lab/specimen_types_controller.rb +1 -1
- data/app/controllers/lab/test_result_indicators_controller.rb +6 -4
- data/app/controllers/lab/test_types_controller.rb +1 -1
- data/app/controllers/lab/tests_controller.rb +20 -17
- data/app/jobs/lab/application_job.rb +2 -0
- data/app/jobs/lab/update_patient_orders_job.rb +1 -1
- data/app/mailers/lab/application_mailer.rb +2 -0
- data/app/models/lab/application_record.rb +2 -0
- data/app/models/lab/lab_order.rb +1 -1
- data/app/models/lab/lims_failed_import.rb +2 -0
- data/app/serializers/lab/lab_order_serializer.rb +2 -2
- data/app/serializers/lab/result_serializer.rb +2 -2
- data/app/services/lab/accession_number_service.rb +2 -2
- data/app/services/lab/concepts_service.rb +2 -2
- data/app/services/lab/labelling_service/order_label.rb +2 -2
- data/app/services/lab/lims/api/blackhole_api.rb +1 -1
- data/app/services/lab/lims/api/couchdb_api.rb +3 -3
- data/app/services/lab/lims/api/mysql_api.rb +6 -6
- data/app/services/lab/lims/api/rest_api.rb +378 -372
- data/app/services/lab/lims/api/ws_api.rb +1 -1
- data/app/services/lab/lims/api_factory.rb +1 -1
- data/app/services/lab/lims/config.rb +1 -1
- data/app/services/lab/lims/exceptions.rb +1 -0
- data/app/services/lab/lims/migrator.rb +11 -12
- data/app/services/lab/lims/order_dto.rb +4 -4
- data/app/services/lab/lims/order_serializer.rb +12 -12
- data/app/services/lab/lims/pull_worker.rb +14 -13
- data/app/services/lab/lims/push_worker.rb +5 -5
- data/app/services/lab/lims/utils.rb +4 -6
- data/app/services/lab/lims/worker.rb +1 -1
- data/app/services/lab/orders_search_service.rb +3 -3
- data/app/services/lab/orders_service.rb +5 -5
- data/app/services/lab/results_service.rb +3 -3
- data/app/services/lab/tests_service.rb +5 -5
- data/db/migrate/20210126092910_create_lab_lab_accession_number_counters.rb +2 -0
- data/db/migrate/20210310115457_create_lab_lims_order_mappings.rb +2 -0
- data/db/migrate/20210326195504_add_order_revision_to_lims_order_mapping.rb +2 -0
- data/db/migrate/20210610095024_fix_numeric_results_value_type.rb +2 -0
- data/db/migrate/20210807111531_add_default_to_lims_order_mapping.rb +2 -0
- data/lib/auto12epl.rb +55 -53
- data/lib/couch_bum/couch_bum.rb +4 -4
- data/lib/generators/lab/install/templates/rswag-ui-lab.rb +2 -0
- data/lib/his_emr_api_lab.rb +2 -0
- data/lib/lab/engine.rb +2 -0
- data/lib/lab/version.rb +1 -1
- data/lib/logger_multiplexor.rb +2 -2
- data/lib/tasks/lab_tasks.rake +2 -0
- data/lib/tasks/loaders/loader_mixin.rb +4 -4
- data/lib/tasks/loaders/reasons_for_test_loader.rb +1 -1
- data/lib/tasks/loaders/specimens_loader.rb +6 -7
- data/lib/tasks/loaders/test_result_indicators_loader.rb +5 -5
- metadata +12 -17
@@ -10,7 +10,7 @@ module Lab
|
|
10
10
|
|
11
11
|
case Lab::Lims::Config.preferred_api
|
12
12
|
when /rest/i then Lab::Lims::Api::RestApi.new(Lab::Lims::Config.rest_api)
|
13
|
-
when /couchdb/ then Lab::Lims::Api::
|
13
|
+
when /couchdb/ then Lab::Lims::Api::CouchdbApi.new(config: Lab::Lims::Config.couchdb_api)
|
14
14
|
else raise "Invalid lims_api configuration: #{Lab::Lims::Config.preferred_api}"
|
15
15
|
end
|
16
16
|
end
|
@@ -80,7 +80,7 @@ module Lab
|
|
80
80
|
# Returns: a path to a file found
|
81
81
|
def find_config_path(filename)
|
82
82
|
paths = [
|
83
|
-
"#{
|
83
|
+
"#{Dir.home}/apps/nlims_controller/config/#{filename}",
|
84
84
|
"/var/www/nlims_controller/config/#{filename}",
|
85
85
|
Rails.root.parent.join("nlims_controller/config/#{filename}")
|
86
86
|
]
|
@@ -29,10 +29,10 @@ require 'lab/lab_test'
|
|
29
29
|
require 'lab/lims_order_mapping'
|
30
30
|
require 'lab/lims_failed_import'
|
31
31
|
|
32
|
-
require_relative '
|
33
|
-
require_relative '
|
34
|
-
require_relative '
|
35
|
-
require_relative '
|
32
|
+
require_relative 'api/couchdb_api'
|
33
|
+
require_relative 'config'
|
34
|
+
require_relative 'pull_worker'
|
35
|
+
require_relative 'utils'
|
36
36
|
|
37
37
|
require_relative '../orders_service'
|
38
38
|
require_relative '../results_service'
|
@@ -42,7 +42,6 @@ require_relative '../../../serializers/lab/result_serializer'
|
|
42
42
|
require_relative '../../../serializers/lab/test_serializer'
|
43
43
|
|
44
44
|
require_relative 'order_dto'
|
45
|
-
require_relative 'utils'
|
46
45
|
|
47
46
|
module Lab
|
48
47
|
module Lims
|
@@ -60,7 +59,7 @@ module Lab
|
|
60
59
|
|
61
60
|
##
|
62
61
|
# A Lab::Lims::Api object that supports crawling of a LIMS CouchDB instance.
|
63
|
-
class CouchDbMigratorApi < Lab::Lims::Api::
|
62
|
+
class CouchDbMigratorApi < Lab::Lims::Api::CouchdbApi
|
64
63
|
def initialize(*args, processes: 1, on_merge_processes: nil, **kwargs)
|
65
64
|
super(*args, **kwargs)
|
66
65
|
|
@@ -82,7 +81,7 @@ module Lab
|
|
82
81
|
next unless row['doc']['type']&.casecmp?('Order')
|
83
82
|
|
84
83
|
User.current = Utils.lab_user
|
85
|
-
yield
|
84
|
+
yield OrderDto.new(row['doc']), OpenStruct.new(last_seq: (from || 0) + limit, current_seq: from)
|
86
85
|
end
|
87
86
|
|
88
87
|
from += orders.size
|
@@ -141,7 +140,7 @@ module Lab
|
|
141
140
|
def order_rejected(order_dto, reason)
|
142
141
|
@rejections ||= []
|
143
142
|
|
144
|
-
@rejections << OpenStruct.new(order: order_dto, reason:
|
143
|
+
@rejections << OpenStruct.new(order: order_dto, reason:)
|
145
144
|
end
|
146
145
|
end
|
147
146
|
|
@@ -168,7 +167,7 @@ module Lab
|
|
168
167
|
]
|
169
168
|
end
|
170
169
|
|
171
|
-
save_csv(MIGRATION_REJECTIONS_CSV_PATH, headers
|
170
|
+
save_csv(MIGRATION_REJECTIONS_CSV_PATH, headers:, rows:)
|
172
171
|
end
|
173
172
|
|
174
173
|
MIGRATION_FAILURES_CSV_PATH = Utils::LIMS_LOG_PATH.join('migration-failures.csv')
|
@@ -185,13 +184,13 @@ module Lab
|
|
185
184
|
]
|
186
185
|
end
|
187
186
|
|
188
|
-
save_csv(MIGRATION_FAILURES_CSV_PATH, headers
|
187
|
+
save_csv(MIGRATION_FAILURES_CSV_PATH, headers:, rows:)
|
189
188
|
end
|
190
189
|
|
191
190
|
MIGRATION_LOG_PATH = Utils::LIMS_LOG_PATH.join('migration.log')
|
192
191
|
|
193
192
|
def self.start_migration
|
194
|
-
|
193
|
+
FileUtils.mkdir_p(Utils::LIMS_LOG_PATH)
|
195
194
|
|
196
195
|
logger = LoggerMultiplexor.new(Logger.new($stdout), MIGRATION_LOG_PATH)
|
197
196
|
logger.level = :debug
|
@@ -202,7 +201,7 @@ module Lab
|
|
202
201
|
api_class = case ENV.fetch('MIGRATION_SOURCE', 'couchdb').downcase
|
203
202
|
when 'couchdb' then CouchDbMigratorApi
|
204
203
|
when 'mysql' then Api::MysqlApi
|
205
|
-
else raise "Invalid MIGRATION_SOURCE: #{ENV
|
204
|
+
else raise "Invalid MIGRATION_SOURCE: #{ENV.fetch('MIGRATION_SOURCE', nil)}"
|
206
205
|
end
|
207
206
|
|
208
207
|
worker = MigrationWorker.new(api_class)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative 'exceptions'
|
4
4
|
|
5
5
|
module Lab
|
6
6
|
module Lims
|
7
7
|
##
|
8
8
|
# LIMS' Data Transfer Object for orders
|
9
|
-
class
|
9
|
+
class OrderDto < ActiveSupport::HashWithIndifferentAccess
|
10
10
|
include Utils
|
11
11
|
|
12
12
|
##
|
@@ -15,10 +15,10 @@ module Lab
|
|
15
15
|
ActiveSupport::HashWithIndifferentAccess.new(
|
16
16
|
program_id: lab_program.program_id,
|
17
17
|
accession_number: self['tracking_number'],
|
18
|
-
patient_id
|
18
|
+
patient_id:,
|
19
19
|
specimen: { concept_id: specimen_type_id },
|
20
20
|
tests: self['tests']&.map { |test| { concept_id: test_type_id(test) } },
|
21
|
-
requesting_clinician
|
21
|
+
requesting_clinician:,
|
22
22
|
date: start_date,
|
23
23
|
target_lab: facility_name(self['receiving_facility']),
|
24
24
|
order_location: facility_name(self['sending_facility']),
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
require_relative '
|
3
|
+
require_relative 'config'
|
4
|
+
require_relative 'order_dto'
|
5
|
+
require_relative 'utils'
|
6
6
|
|
7
7
|
module Lab
|
8
8
|
module Lims
|
9
9
|
##
|
10
|
-
# Serializes a LabOrder into a LIMS
|
10
|
+
# Serializes a LabOrder into a LIMS OrderDto.
|
11
11
|
module OrderSerializer
|
12
12
|
class << self
|
13
13
|
include Utils
|
@@ -15,8 +15,8 @@ module Lab
|
|
15
15
|
def serialize_order(order)
|
16
16
|
serialized_order = Lims::Utils.structify(Lab::LabOrderSerializer.serialize_order(order))
|
17
17
|
|
18
|
-
Lims::
|
19
|
-
_id: Lab::LimsOrderMapping.find_by(order:
|
18
|
+
Lims::OrderDto.new(
|
19
|
+
_id: Lab::LimsOrderMapping.find_by(order:)&.lims_id || serialized_order.accession_number,
|
20
20
|
tracking_number: serialized_order.accession_number,
|
21
21
|
sending_facility: current_facility_name,
|
22
22
|
receiving_facility: serialized_order.target_lab,
|
@@ -39,9 +39,9 @@ module Lab
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def format_order_location(encounter_id)
|
42
|
-
location_id = Encounter.select(:location_id).where(encounter_id:
|
42
|
+
location_id = Encounter.select(:location_id).where(encounter_id:)
|
43
43
|
location = Location.select(:name)
|
44
|
-
.where(location_id:
|
44
|
+
.where(location_id:)
|
45
45
|
.first
|
46
46
|
|
47
47
|
location&.name
|
@@ -53,7 +53,7 @@ module Lab
|
|
53
53
|
name = PersonName.find_by_person_id(patient_id)
|
54
54
|
national_id = PatientIdentifier.joins(:type)
|
55
55
|
.merge(PatientIdentifierType.where(name: 'National ID'))
|
56
|
-
.where(patient_id:
|
56
|
+
.where(patient_id:)
|
57
57
|
.first
|
58
58
|
phone_number = PersonAttribute.joins(:type)
|
59
59
|
.merge(PersonAttributeType.where(name: 'Cell phone Number'))
|
@@ -86,7 +86,7 @@ module Lab
|
|
86
86
|
def find_arv_number(patient_id)
|
87
87
|
PatientIdentifier.joins(:type)
|
88
88
|
.merge(PatientIdentifierType.where(name: 'ARV Number'))
|
89
|
-
.where(patient_id:
|
89
|
+
.where(patient_id:)
|
90
90
|
.first&.identifier
|
91
91
|
end
|
92
92
|
|
@@ -209,8 +209,8 @@ module Lab
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def current_district
|
212
|
-
district = current_health_center.city_village\
|
213
|
-
|| current_health_center.parent&.name\
|
212
|
+
district = current_health_center.city_village \
|
213
|
+
|| current_health_center.parent&.name \
|
214
214
|
|| GlobalProperty.find_by_property('current_health_center_district')&.property_value
|
215
215
|
|
216
216
|
return district if district
|
@@ -17,10 +17,10 @@ module Lab
|
|
17
17
|
|
18
18
|
##
|
19
19
|
# Pulls orders from the LIMS queue and writes them to the local database
|
20
|
-
def pull_orders(batch_size: 10_000, **
|
20
|
+
def pull_orders(batch_size: 10_000, **)
|
21
21
|
logger.info("Retrieving LIMS orders starting from #{last_seq}")
|
22
22
|
|
23
|
-
lims_api.consume_orders(from: last_seq, limit: batch_size, **
|
23
|
+
lims_api.consume_orders(from: last_seq, limit: batch_size, **) do |order_dto, context|
|
24
24
|
logger.debug("Retrieved order ##{order_dto[:tracking_number]}: #{order_dto}")
|
25
25
|
|
26
26
|
patient = find_patient_by_nhid(order_dto[:patient][:id])
|
@@ -137,7 +137,7 @@ module Lab
|
|
137
137
|
person = Person.find(local_patient.id)
|
138
138
|
person_name = PersonName.find_by_person_id(local_patient.id)
|
139
139
|
|
140
|
-
unless (person.gender.blank? && lims_patient['gender'].blank?)\
|
140
|
+
unless (person.gender.blank? && lims_patient['gender'].blank?) \
|
141
141
|
|| person.gender&.first&.casecmp?(lims_patient['gender']&.first)
|
142
142
|
diff[:gender] = { local: person.gender, lims: lims_patient['gender'] }
|
143
143
|
end
|
@@ -154,8 +154,8 @@ module Lab
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def names_match?(name1, name2)
|
157
|
-
name1 = name1&.gsub(
|
158
|
-
name2 = name2&.gsub(
|
157
|
+
name1 = name1&.gsub("'", '')&.strip
|
158
|
+
name2 = name2&.gsub("'", '')&.strip
|
159
159
|
|
160
160
|
return true if name1.blank? && name2.blank?
|
161
161
|
|
@@ -229,10 +229,11 @@ module Lab
|
|
229
229
|
|
230
230
|
creator = format_result_entered_by(test_results['result_entered_by'])
|
231
231
|
|
232
|
-
ResultsService.create_results(test.id,
|
233
|
-
|
234
|
-
|
235
|
-
|
232
|
+
ResultsService.create_results(test.id, { provider_id: User.current.person_id,
|
233
|
+
date: Utils.parse_date(test_results['date_result_entered'],
|
234
|
+
order[:order_date].to_s),
|
235
|
+
comments: "LIMS import: Entered by: #{creator}",
|
236
|
+
measures: })
|
236
237
|
end
|
237
238
|
end
|
238
239
|
|
@@ -241,7 +242,7 @@ module Lab
|
|
241
242
|
test_concept = Utils.find_concept_by_name(test_name)
|
242
243
|
raise "Unknown test name, #{test_name}!" unless test_concept
|
243
244
|
|
244
|
-
LabTest.find_by(order_id
|
245
|
+
LabTest.find_by(order_id:, value_coded: test_concept.concept_id)
|
245
246
|
end
|
246
247
|
|
247
248
|
def find_measure(_order, indicator_name, value)
|
@@ -256,7 +257,7 @@ module Lab
|
|
256
257
|
|
257
258
|
ActiveSupport::HashWithIndifferentAccess.new(
|
258
259
|
indicator: { concept_id: indicator.concept_id },
|
259
|
-
value_type
|
260
|
+
value_type:,
|
260
261
|
value: value_type == 'numeric' ? value.to_f : value,
|
261
262
|
value_modifier: value_modifier.blank? ? '=' : value_modifier
|
262
263
|
)
|
@@ -292,7 +293,7 @@ module Lab
|
|
292
293
|
LimsFailedImport.create!(lims_id: order_dto[:_id],
|
293
294
|
tracking_number: order_dto[:tracking_number],
|
294
295
|
patient_nhid: order_dto[:patient][:id],
|
295
|
-
reason
|
296
|
+
reason:,
|
296
297
|
diff: diff&.to_json)
|
297
298
|
end
|
298
299
|
|
@@ -301,7 +302,7 @@ module Lab
|
|
301
302
|
end
|
302
303
|
|
303
304
|
def find_order_mapping_by_lims_id(lims_id)
|
304
|
-
mapping = Lab::LimsOrderMapping.find_by(lims_id:
|
305
|
+
mapping = Lab::LimsOrderMapping.find_by(lims_id:)
|
305
306
|
return nil unless mapping
|
306
307
|
|
307
308
|
return mapping if Lab::LabOrder.where(order_id: mapping.order_id).exists?
|
@@ -60,10 +60,10 @@ module Lab
|
|
60
60
|
Rails.logger.info("Updating order ##{order_dto[:accession_number]} in LIMS")
|
61
61
|
lims_api.update_order(mapping.lims_id, order_dto)
|
62
62
|
if order_dto['test_results'].nil? || order_dto['test_results'].empty?
|
63
|
-
mapping.update(pushed_at: Time.now)
|
63
|
+
mapping.update(pushed_at: Time.now)
|
64
64
|
else
|
65
|
-
mapping.update(pushed_at: Time.now, result_push_status: true)
|
66
|
-
|
65
|
+
mapping.update(pushed_at: Time.now, result_push_status: true)
|
66
|
+
end
|
67
67
|
elsif order_dto[:_id] && Lab::LimsOrderMapping.where(lims_id: order_dto[:_id]).exists?
|
68
68
|
# HACK: v1.1.7 had a bug where duplicates of recently created orders where being created by
|
69
69
|
# the pull worker. This here detects those duplicates and voids them.
|
@@ -72,7 +72,7 @@ module Lab
|
|
72
72
|
else
|
73
73
|
Rails.logger.info("Creating order ##{order_dto[:accession_number]} in LIMS")
|
74
74
|
update = lims_api.create_order(order_dto)
|
75
|
-
Lab::LimsOrderMapping.create!(order
|
75
|
+
Lab::LimsOrderMapping.create!(order:, lims_id: update['id'], revision: update['rev'],
|
76
76
|
pushed_at: Time.now, result_push_status: false)
|
77
77
|
end
|
78
78
|
end
|
@@ -107,7 +107,7 @@ module Lab
|
|
107
107
|
.joins(:mapping)
|
108
108
|
.where('orders.discontinued_date > :last_updated
|
109
109
|
OR obs.date_created > orders.date_created AND lab_lims_order_mappings.result_push_status = 0',
|
110
|
-
last_updated:
|
110
|
+
last_updated:)
|
111
111
|
.group('orders.order_id')
|
112
112
|
.order(discontinued_date: :desc, date_created: :desc)
|
113
113
|
end
|
@@ -8,7 +8,7 @@ module Lab
|
|
8
8
|
# Various helper methods for modules in the Lims namespaces...
|
9
9
|
module Utils
|
10
10
|
LIMS_LOG_PATH = Rails.root.join('log', 'lims')
|
11
|
-
FileUtils.mkdir_p(LIMS_LOG_PATH)
|
11
|
+
FileUtils.mkdir_p(LIMS_LOG_PATH)
|
12
12
|
|
13
13
|
def logger
|
14
14
|
Rails.logger
|
@@ -49,17 +49,15 @@ module Lab
|
|
49
49
|
god_user = User.first
|
50
50
|
|
51
51
|
person = Person.create!(creator: god_user.user_id)
|
52
|
-
PersonName.create!(person
|
52
|
+
PersonName.create!(person:, given_name: 'Lab', family_name: 'Daemon', creator: god_user.user_id)
|
53
53
|
|
54
|
-
User.create!(username: 'lab_daemon', person
|
54
|
+
User.create!(username: 'lab_daemon', person:, creator: god_user.user_id)
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.parse_date(str_date, fallback_date = nil)
|
58
58
|
str_date = str_date&.to_s
|
59
59
|
|
60
|
-
if str_date.blank? && fallback_date.blank?
|
61
|
-
raise "Can't parse blank date"
|
62
|
-
end
|
60
|
+
raise "Can't parse blank date" if str_date.blank? && fallback_date.blank?
|
63
61
|
|
64
62
|
return parse_date(fallback_date) if str_date.blank?
|
65
63
|
|
@@ -11,8 +11,8 @@ module Lab
|
|
11
11
|
.where(filters)
|
12
12
|
.order(start_date: :desc)
|
13
13
|
|
14
|
-
orders = filter_orders_by_status(orders, pop_filters(extra_filters, :status))
|
15
|
-
orders = filter_orders_by_date(orders, extra_filters)
|
14
|
+
orders = filter_orders_by_status(orders, **pop_filters(extra_filters, :status))
|
15
|
+
orders = filter_orders_by_date(orders, **extra_filters)
|
16
16
|
|
17
17
|
orders.map { |order| Lab::LabOrderSerializer.serialize_order(order) }
|
18
18
|
end
|
@@ -22,7 +22,7 @@ module Lab
|
|
22
22
|
results_query = results_query.where(person_id: patient_id) if patient_id
|
23
23
|
|
24
24
|
query = Lab::LabOrder.where.not(order_id: results_query.select(:order_id))
|
25
|
-
query = query.where(patient_id:
|
25
|
+
query = query.where(patient_id:) if patient_id
|
26
26
|
|
27
27
|
query
|
28
28
|
end
|
@@ -196,7 +196,7 @@ module Lab
|
|
196
196
|
|
197
197
|
Encounter.create!(
|
198
198
|
patient_id: order_params[:patient_id],
|
199
|
-
program_id
|
199
|
+
program_id:,
|
200
200
|
type: EncounterType.find_by_name!(Lab::Metadata::ENCOUNTER_TYPE_NAME),
|
201
201
|
encounter_datetime: order_params[:date] || Date.today,
|
202
202
|
provider_id: order_params[:provider_id] || User.current.person.person_id
|
@@ -220,7 +220,7 @@ module Lab
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def accession_number_exists?(accession_number)
|
223
|
-
Lab::LabOrder.where(accession_number:
|
223
|
+
Lab::LabOrder.where(accession_number:).exists?
|
224
224
|
end
|
225
225
|
|
226
226
|
def nlims_accession_number_exists?(accession_number)
|
@@ -269,14 +269,14 @@ module Lab
|
|
269
269
|
)
|
270
270
|
end
|
271
271
|
|
272
|
-
def create_order_observation(order, concept_name, date, **
|
272
|
+
def create_order_observation(order, concept_name, date, **)
|
273
273
|
Observation.create!(
|
274
|
-
order
|
274
|
+
order:,
|
275
275
|
encounter_id: order.encounter_id,
|
276
276
|
person_id: order.patient_id,
|
277
277
|
concept_id: ConceptName.find_by_name!(concept_name).concept_id,
|
278
278
|
obs_datetime: date&.to_time || Time.now,
|
279
|
-
**
|
279
|
+
**
|
280
280
|
)
|
281
281
|
end
|
282
282
|
|
@@ -50,7 +50,7 @@ module Lab
|
|
50
50
|
PatientID: result.person_id,
|
51
51
|
'Ordered By': order&.provider&.person&.name,
|
52
52
|
Result: values }.as_json
|
53
|
-
NotificationService.new.create_notification(result_enter_by, data)
|
53
|
+
NotificationService.new.create_notification(result_enter_by, data)
|
54
54
|
end
|
55
55
|
|
56
56
|
def process_acknowledgement(results, results_enter_by)
|
@@ -62,7 +62,7 @@ module Lab
|
|
62
62
|
def find_arv_number(patient_id)
|
63
63
|
PatientIdentifier.joins(:type)
|
64
64
|
.merge(PatientIdentifierType.where(name: 'ARV Number'))
|
65
|
-
.where(patient_id:
|
65
|
+
.where(patient_id:)
|
66
66
|
.first&.identifier
|
67
67
|
end
|
68
68
|
|
@@ -89,7 +89,7 @@ module Lab
|
|
89
89
|
order_id: test.order_id,
|
90
90
|
obs_group_id: test.obs_id,
|
91
91
|
obs_datetime: date&.to_datetime || DateTime.now,
|
92
|
-
comments:
|
92
|
+
comments:
|
93
93
|
)
|
94
94
|
end
|
95
95
|
|
@@ -35,7 +35,7 @@ module Lab
|
|
35
35
|
value_coded: params[:concept_id]
|
36
36
|
)
|
37
37
|
|
38
|
-
Lab::TestSerializer.serialize(test, order:
|
38
|
+
Lab::TestSerializer.serialize(test, order:)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -62,9 +62,9 @@ module Lab
|
|
62
62
|
def filter_tests_by_order(tests, accession_number: nil, order_date: nil, specimen_type_id: nil)
|
63
63
|
return tests unless accession_number || order_date || specimen_type_id
|
64
64
|
|
65
|
-
lab_orders = filter_orders(Lab::LabOrder.all, accession_number
|
66
|
-
order_date
|
67
|
-
specimen_type_id:
|
65
|
+
lab_orders = filter_orders(Lab::LabOrder.all, accession_number:,
|
66
|
+
order_date:,
|
67
|
+
specimen_type_id:)
|
68
68
|
tests.joins(:order).merge(lab_orders)
|
69
69
|
end
|
70
70
|
|
@@ -74,7 +74,7 @@ module Lab
|
|
74
74
|
orders = orders.where('start_date >= ? AND start_date < ?', order_date, order_date + 1.day)
|
75
75
|
end
|
76
76
|
|
77
|
-
orders = orders.where(accession_number:
|
77
|
+
orders = orders.where(accession_number:) if accession_number
|
78
78
|
orders = orders.where(concept_id: specimen_type_id) if specimen_type_id
|
79
79
|
|
80
80
|
orders
|