his_emr_api_lab 2.3.3 → 2.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3873475c6cfd03e575f78f41fbf683f18c7dc7c9805727b7fe95c68bda0c9ad0
4
- data.tar.gz: 1ac84309c0eb67cc136b7e51c2254d45b64514c7a2cc605f7366cc73d33fcc59
3
+ metadata.gz: cf823a7706db9f2444ed694c9f58ea1c1851c9cf00de058bb6c980434e57b27a
4
+ data.tar.gz: 55ac7590a6cc36249ef8322b254844f3ada7ca891b45d00c3512ccfa2eee8ddc
5
5
  SHA512:
6
- metadata.gz: d4a4106f2ace136bede102affbf76ba7d6d9d740711f401b53727349ff47f3bc781ad5b3f709e56b17c75dcb1f194a7e6fa4e2abaa3895ac6685f262afa62c53
7
- data.tar.gz: 04ac7da59794e253c10bab14a5002633c1b9f30e48e0a70338153af8020443bd75914400ef274edc469a5852862bfe03623f5be4664c564af29ada6782a9b1e0
6
+ metadata.gz: 1b3efe1cf4d98acb7dd218866c331d384a7f4c0855fe2ad4475edc88e3c89799d74d479c4ca8159707eeb433a1cf985a8b98f847f2d3a6a66330af88b675343b
7
+ data.tar.gz: 51d757cdbaff73aa883332f8a0a17cc71cc117fd7812192b9c60b11506b16c8f4ba30c7a1850ee5bc49a56c531e93f912eca963519ee4251ad0edbb225ce716a
@@ -8,7 +8,7 @@ module Lab
8
8
  def perform(results_obs_id, serializer, result_enter_by)
9
9
  Rails.logger.info("Lab::ProcessLabResultJob: Processing result completion for #{serializer}")
10
10
  # set location context for the job based on the order's encounter to ensure proper context for any operations performed in the job
11
- results_obs = Lab::LabResult.unscoped.find(results_obs_id)
11
+ results_obs = Lab::LabResult.unscoped.includes(:test).find(results_obs_id)
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)
@@ -18,7 +18,7 @@ module Lab
18
18
  order_type_id: order.order_type_id,
19
19
  order_id: order.order_id, # Deprecated: Link to :id
20
20
  encounter_id: order.encounter_id,
21
- visit_id: encounter&.visit_id,
21
+ **(Encounter.column_names.include?('visit_id') ? { visit_id: encounter&.visit_id } : {}),
22
22
  order_date: order.start_date,
23
23
  location_id: encounter&.location_id,
24
24
  program_id: encounter&.program_id,
@@ -31,7 +31,13 @@ class Lab::NotificationService
31
31
  return if alert_type != 'LIMS'
32
32
 
33
33
  # Use unscoped to find user regardless of location context
34
- lab = User.unscoped.find_by(username: 'lab_daemon')
34
+ lab = Lab::Lims::Utils.lab_user
35
+
36
+ unless lab
37
+ Rails.logger.warn('NotificationService: lab_daemon user not found, skipping notification creation')
38
+ return
39
+ end
40
+
35
41
  ActiveRecord::Base.transaction do
36
42
  alert = NotificationAlert.create!(text: alert_message.to_json, date_to_expire: Time.now + not_period.days,
37
43
  creator: lab, changed_by: lab, date_created: Time.now)
@@ -63,15 +63,21 @@ module Lab
63
63
  def process_result_completion(results_obs, serializer, result_enter_by)
64
64
  process_acknowledgement(results_obs, result_enter_by)
65
65
  precess_notification_message(results_obs, serializer, result_enter_by)
66
+ rescue StandardError => e
67
+ Rails.logger.error("Lab::ResultsService: Error in post-result processing: #{e.message}")
68
+ Rails.logger.error(e.backtrace.join("\n"))
69
+ # Don't re-raise - result is already saved
66
70
  end
67
71
 
68
72
  private
69
73
 
70
74
  def precess_notification_message(result, values, result_enter_by)
71
75
  order = Order.find(result.order_id)
76
+ test_concept_id = result.test&.value_coded
77
+
72
78
  data = { Type: result_enter_by,
73
79
  Specimen: get_test_catalog_name(order.concept_id) || ConceptName.find_by(concept_id: order.concept_id)&.name,
74
- 'Test type': get_test_catalog_name(result.test.value_coded) || ConceptName.find_by(concept_id: result.test.value_coded)&.name,
80
+ 'Test type': test_concept_id ? (get_test_catalog_name(test_concept_id) || ConceptName.find_by(concept_id: test_concept_id)&.name) : nil,
75
81
  'Accession number': order&.accession_number,
76
82
  order_date: Order.columns.include?('start_date') ? order.start_date : order.date_created,
77
83
  'ARV-Number': find_arv_number(result.person_id),
data/lib/lab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lab
4
- VERSION = '2.3.3'
4
+ VERSION = '2.3.4'
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: 2.3.3
4
+ version: 2.3.4
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-04-07 00:00:00.000000000 Z
11
+ date: 2026-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: couchrest