his_emr_api_lab 2.4.2.pre.beta → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c709c42cf59eed483429321c58ddf08678dc809850c2d59cb58ca8d8bf4f3c3
4
- data.tar.gz: 3f54225c34b8547665dfa5d553971e7d0b299d6744496d9e457184f3c7c105b8
3
+ metadata.gz: 87bb2fa74878c6f69d4f52ec514e1e03118608be3e466f0b80a43df7cb0d51dc
4
+ data.tar.gz: 65227f424e63b2f179f74339e34ec2cb3437d8068b219cfb9a94754a1e511cb0
5
5
  SHA512:
6
- metadata.gz: c53d18764e2dd4d99e4881855778acec6c8a2852744eb8bba144aea85249d8a0d5555f6c6e85773333367439606fa8652104d14169cb0290964bd308c23f5e7a
7
- data.tar.gz: 45a1847d5591bbd4e352d15d320651cbaa2b2d774b5752cc17caceb8416a3fa56c505efd230b3c4635bb334c4d2bd3d2e885de5996324e94da1f5a82d01260c6
6
+ metadata.gz: bdba5bc2908c3eaeb1389f1dd746fe0ebd9728c75e70ccc84553a0b3a25e54b238f36298367e927eeac87feea4d01d4283e11ef70a919a31553197156a4d8a68
7
+ data.tar.gz: 0c18b7c2ccc0e5ea5c1bb775aa286990bcd1ea254ececc70d35b386e5b6dde885c72b0b276aa9b524a9cccb2fbdbb673439c68ee6b046085c320cfe8becd8905
@@ -87,21 +87,17 @@ module Lab
87
87
  concept = ConceptName.where(name: Lab::Metadata::TEST_TYPE_CONCEPT_NAME)
88
88
  .select(:concept_id)
89
89
  LabTest.unscoped.where(concept_id: concept, order_id: order.order_id, voided: 0)
90
- .order(:date_created, :obs_id)
91
90
  end
92
91
 
93
92
  def self.voided_tests(order)
94
93
  concept = ConceptName.where(name: Lab::Metadata::TEST_TYPE_CONCEPT_NAME)
95
94
  .select(:concept_id)
96
95
  LabTest.unscoped.where(concept_id: concept, order_id: order.order_id, voided: 1)
97
- .order(:date_voided, :obs_id)
98
96
  end
99
97
 
100
98
  def self.order_observation(order, concept_name)
101
99
  concept = ConceptName.where(name: concept_name).select(:concept_id)
102
- Observation.unscoped.where(order_id: order.order_id, concept_id: concept, voided: 0)
103
- .order(:date_created, :obs_id)
104
- .first
100
+ Observation.unscoped.find_by(order_id: order.order_id, concept_id: concept, voided: 0)
105
101
  end
106
102
 
107
103
  def self.latest_order_status(order)
@@ -52,14 +52,13 @@ class Lab::NotificationService
52
52
  ) do |new_alert|
53
53
  # Only set these attributes on creation
54
54
  new_alert.text = alert_message.to_json
55
- new_alert.date_to_expire = Time.now + not_period.days
55
+ new_alert.date_to_expire = Time.now + notification_period.days
56
56
  new_alert.creator = lab
57
57
  new_alert.changed_by = lab
58
58
  new_alert.date_created = Time.now
59
59
  end
60
60
 
61
- # Only notify if this is a new record (not a duplicate)
62
- notify(alert, User.joins(:roles).uniq) if alert.previously_new_record?
61
+ notify(alert, users(order_location(alert.order_id)))
63
62
  rescue ActiveRecord::RecordNotUnique
64
63
  # Handle race condition if unique constraint exists
65
64
  Rails.logger.info("Duplicate notification prevented for test_type: #{test_type_id}, order: #{order_id}, specimen: #{specimen_id}")
@@ -70,15 +69,29 @@ class Lab::NotificationService
70
69
  end
71
70
  end
72
71
 
73
- def not_period
72
+ def notification_period
74
73
  result = GlobalProperty.where(property: 'notification.period')&.first
75
74
  return result.property_value.to_i if result.present?
76
75
 
77
76
  7 # default to 7 days
78
77
  end
79
78
 
80
- def notify(notification_alert, recipients)
79
+ def users(location_id = nil)
80
+ return User.joins(:roles).where(location_id: location_id).uniq if location_id.present? && User.column_names.include?('location_id')
81
+
82
+ User.joins(:roles).uniq
83
+ end
84
+
85
+ def order_location(order_id)
86
+ return nil unless Observation.column_names.include?('location_id')
87
+
88
+ Observation.find_by(order_id: order_id)&.location_id
89
+ end
90
+
91
+ def notify(notification_alert, recipients)
81
92
  recipients.each do |recipient|
93
+ next if recipient.notification_alert_recipients.exists?(alert_id: notification_alert.id)
94
+
82
95
  recipient.notification_alert_recipients.create(
83
96
  alert_id: notification_alert.id
84
97
  )
@@ -63,7 +63,7 @@ module Lab
63
63
 
64
64
  def process_result_completion(results_obs, serializer, result_enter_by)
65
65
  process_acknowledgement(results_obs, result_enter_by)
66
- precess_notification_message(results_obs, serializer, result_enter_by)
66
+ process_notification_message(results_obs, serializer, result_enter_by)
67
67
  rescue StandardError => e
68
68
  Rails.logger.error("Lab::ResultsService: Error in post-result processing: #{e.message}")
69
69
  Rails.logger.error(e.backtrace.join("\n"))
@@ -72,7 +72,7 @@ module Lab
72
72
 
73
73
  private
74
74
 
75
- def precess_notification_message(result, values, result_enter_by)
75
+ def process_notification_message(result, values, result_enter_by)
76
76
  order = Order.find(result.order_id)
77
77
  test_concept_id = result.test&.value_coded
78
78
  uniq_checkers = {
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.4.2-beta'.freeze
4
+ VERSION = '2.4.3'.freeze
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.4.2.pre.beta
4
+ version: 2.4.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-07-03 00:00:00.000000000 Z
11
+ date: 2026-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: couchrest
@@ -342,9 +342,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
342
342
  version: '0'
343
343
  required_rubygems_version: !ruby/object:Gem::Requirement
344
344
  requirements:
345
- - - ">"
345
+ - - ">="
346
346
  - !ruby/object:Gem::Version
347
- version: 1.3.1
347
+ version: '0'
348
348
  requirements: []
349
349
  rubygems_version: 3.4.1
350
350
  signing_key: