his_emr_api_lab 2.3.1 → 2.3.3
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/app/controllers/lab/orders_controller.rb +24 -4
- data/app/jobs/lab/process_lab_result_job.rb +10 -0
- data/app/jobs/lab/void_order_job.rb +8 -0
- data/app/services/lab/orders_service.rb +31 -1
- data/app/services/lab/results_service.rb +11 -0
- 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: 3873475c6cfd03e575f78f41fbf683f18c7dc7c9805727b7fe95c68bda0c9ad0
|
|
4
|
+
data.tar.gz: 1ac84309c0eb67cc136b7e51c2254d45b64514c7a2cc605f7366cc73d33fcc59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4a4106f2ace136bede102affbf76ba7d6d9d740711f401b53727349ff47f3bc781ad5b3f709e56b17c75dcb1f194a7e6fa4e2abaa3895ac6685f262afa62c53
|
|
7
|
+
data.tar.gz: 04ac7da59794e253c10bab14a5002633c1b9f30e48e0a70338153af8020443bd75914400ef274edc469a5852862bfe03623f5be4664c564af29ada6782a9b1e0
|
|
@@ -11,7 +11,11 @@ module Lab
|
|
|
11
11
|
OrdersService.order_test(order_params)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
orders.each
|
|
14
|
+
orders.each do |order|
|
|
15
|
+
Lab::PushOrderJob.perform_later(order.fetch(:order_id))
|
|
16
|
+
rescue StandardError => e
|
|
17
|
+
Rails.logger.error("Failed to enqueue PushOrderJob for order #{order.fetch(:order_id)}: #{e.message}")
|
|
18
|
+
end
|
|
15
19
|
|
|
16
20
|
render json: orders, status: :created
|
|
17
21
|
end
|
|
@@ -19,7 +23,12 @@ module Lab
|
|
|
19
23
|
def update
|
|
20
24
|
specimen = params.require(:specimen).slice(:concept_id)
|
|
21
25
|
order = OrdersService.update_order(params[:id], specimen:, force_update: params[:force_update])
|
|
22
|
-
|
|
26
|
+
|
|
27
|
+
begin
|
|
28
|
+
Lab::PushOrderJob.perform_later(order.fetch(:order_id))
|
|
29
|
+
rescue StandardError => e
|
|
30
|
+
Rails.logger.error("Failed to enqueue PushOrderJob for order #{order.fetch(:order_id)}: #{e.message}")
|
|
31
|
+
end
|
|
23
32
|
|
|
24
33
|
render json: order
|
|
25
34
|
end
|
|
@@ -31,7 +40,13 @@ module Lab
|
|
|
31
40
|
|
|
32
41
|
patient = Patient.find(id) if filters[:patient_id] || filters[:patient]
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
if filters[:patient_id] || filters[:patient]
|
|
44
|
+
begin
|
|
45
|
+
Lab::UpdatePatientOrdersJob.perform_later(patient.id)
|
|
46
|
+
rescue StandardError => e
|
|
47
|
+
Rails.logger.error("Failed to enqueue UpdatePatientOrdersJob for patient #{patient.id}: #{e.message}")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
35
50
|
orders = OrdersSearchService.find_orders(filters)
|
|
36
51
|
begin
|
|
37
52
|
render json: orders.reload, status: :ok
|
|
@@ -47,7 +62,12 @@ module Lab
|
|
|
47
62
|
|
|
48
63
|
def destroy
|
|
49
64
|
OrdersService.void_order(params[:id], params[:reason])
|
|
50
|
-
|
|
65
|
+
|
|
66
|
+
begin
|
|
67
|
+
Lab::VoidOrderJob.perform_later(params[:id])
|
|
68
|
+
rescue StandardError => e
|
|
69
|
+
Rails.logger.error("Failed to enqueue VoidOrderJob for order #{params[:id]}: #{e.message}")
|
|
70
|
+
end
|
|
51
71
|
|
|
52
72
|
render status: :no_content
|
|
53
73
|
end
|
|
@@ -12,6 +12,16 @@ module Lab
|
|
|
12
12
|
encounter = Encounter.unscoped.find_by(encounter_id: results_obs.encounter_id)
|
|
13
13
|
Location.current = Location.find(encounter.location_id) if encounter&.location_id
|
|
14
14
|
Lab::ResultsService.process_result_completion(results_obs, serializer, result_enter_by)
|
|
15
|
+
|
|
16
|
+
# Publish notification that results have been processed
|
|
17
|
+
ActiveSupport::Notifications.instrument(
|
|
18
|
+
'lab.results_saved',
|
|
19
|
+
patient_id: results_obs.person_id,
|
|
20
|
+
order_id: results_obs.order_id,
|
|
21
|
+
result_id: results_obs.obs_id,
|
|
22
|
+
encounter_id: results_obs.encounter_id,
|
|
23
|
+
timestamp: Time.current
|
|
24
|
+
)
|
|
15
25
|
end
|
|
16
26
|
end
|
|
17
27
|
end
|
|
@@ -16,6 +16,14 @@ module Lab
|
|
|
16
16
|
|
|
17
17
|
worker = Lab::Lims::PushWorker.new(Lab::Lims::ApiFactory.create_api)
|
|
18
18
|
worker.push_order(order)
|
|
19
|
+
|
|
20
|
+
# Publish notification that order has been voided
|
|
21
|
+
ActiveSupport::Notifications.instrument(
|
|
22
|
+
'lab.order_voided',
|
|
23
|
+
patient_id: order.patient_id,
|
|
24
|
+
order_id: order.order_id,
|
|
25
|
+
timestamp: Time.current
|
|
26
|
+
)
|
|
19
27
|
end
|
|
20
28
|
end
|
|
21
29
|
end
|
|
@@ -50,6 +50,10 @@ module Lab
|
|
|
50
50
|
# reason_for_test_id: is a concept_id for a (standard) reason of why the test is being carried out
|
|
51
51
|
# requesting_clinician: Name of the clinician requesting the test (defaults to current user)
|
|
52
52
|
def order_test(order_params)
|
|
53
|
+
serialized_order = nil
|
|
54
|
+
order_id = nil
|
|
55
|
+
patient_id = nil
|
|
56
|
+
|
|
53
57
|
Order.transaction do
|
|
54
58
|
encounter = find_encounter(order_params)
|
|
55
59
|
if order_params[:accession_number].present? && check_tracking_number(order_params[:accession_number])
|
|
@@ -68,13 +72,29 @@ module Lab
|
|
|
68
72
|
# Reload order to include status trails and tests
|
|
69
73
|
order = Lab::LabOrder.prefetch_relationships.find(order.order_id)
|
|
70
74
|
|
|
71
|
-
Lab::LabOrderSerializer.serialize_order(
|
|
75
|
+
serialized_order = Lab::LabOrderSerializer.serialize_order(
|
|
72
76
|
order, requesting_clinician: add_requesting_clinician(order, order_params),
|
|
73
77
|
reason_for_test: add_reason_for_test(order, order_params),
|
|
74
78
|
target_lab: add_target_lab(order, order_params),
|
|
75
79
|
comment_to_fulfiller: add_comment_to_fulfiller(order, order_params)
|
|
76
80
|
)
|
|
81
|
+
|
|
82
|
+
# Store IDs for notification after transaction commits
|
|
83
|
+
order_id = order.order_id
|
|
84
|
+
patient_id = order.patient_id
|
|
77
85
|
end
|
|
86
|
+
|
|
87
|
+
# Publish notification AFTER transaction commits
|
|
88
|
+
# This ensures the order is visible in the database before rebuilding
|
|
89
|
+
ActiveSupport::Notifications.instrument(
|
|
90
|
+
'lab.order_created',
|
|
91
|
+
patient_id: patient_id,
|
|
92
|
+
order_id: order_id,
|
|
93
|
+
accession_number: serialized_order[:accession_number],
|
|
94
|
+
timestamp: Time.current
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
serialized_order
|
|
78
98
|
end
|
|
79
99
|
|
|
80
100
|
def attach_test_method(order, order_params)
|
|
@@ -153,6 +173,16 @@ module Lab
|
|
|
153
173
|
save_order_status_trail(order, order_params) if order_params['status']
|
|
154
174
|
end
|
|
155
175
|
create_rejection_notification(order_params) if order_params['status'] == 'test-rejected'
|
|
176
|
+
|
|
177
|
+
# Publish notification that order status has changed
|
|
178
|
+
ActiveSupport::Notifications.instrument(
|
|
179
|
+
'lab.order_status_changed',
|
|
180
|
+
patient_id: order.patient_id,
|
|
181
|
+
order_id: order.order_id,
|
|
182
|
+
new_status: order_params['status'],
|
|
183
|
+
tracking_number: order_params['tracking_number'],
|
|
184
|
+
timestamp: Time.current
|
|
185
|
+
)
|
|
156
186
|
end
|
|
157
187
|
|
|
158
188
|
def update_order_result(order_params)
|
|
@@ -46,6 +46,17 @@ module Lab
|
|
|
46
46
|
ProcessLabResultJob.perform_now(results_obs.id, serializer, result_enter_by)
|
|
47
47
|
|
|
48
48
|
Rails.logger.info("Lab::ResultsService: Result created for test #{test_id} #{serializer}")
|
|
49
|
+
|
|
50
|
+
# Publish notification that results have been created
|
|
51
|
+
ActiveSupport::Notifications.instrument(
|
|
52
|
+
'lab.results_created',
|
|
53
|
+
patient_id: results_obs.person_id,
|
|
54
|
+
order_id: results_obs.order_id,
|
|
55
|
+
result_id: results_obs.obs_id,
|
|
56
|
+
test_id: test_id,
|
|
57
|
+
timestamp: Time.current
|
|
58
|
+
)
|
|
59
|
+
|
|
49
60
|
serializer
|
|
50
61
|
end
|
|
51
62
|
|
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: 2.3.
|
|
4
|
+
version: 2.3.3
|
|
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: 2026-
|
|
11
|
+
date: 2026-04-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: couchrest
|