mahis_emr_api_lab 1.2.4 → 1.2.6

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: 1564986977bbbb02dab3359307faa412965cecb2a0aaa3d0cc97b9e2ef068f92
4
- data.tar.gz: 42fcee721977f3cbc1fd29f8f184b23e532cde82bf9846494c90bf1285f0d773
3
+ metadata.gz: 114c56e62980ef6a721d63240bb14fe640076d26cafb7d4c3fe41483786c9466
4
+ data.tar.gz: 4cdd59a7566f7128e0b6bfa6589d3525559a981891879c42b37e208489e7ca35
5
5
  SHA512:
6
- metadata.gz: 91179c762c1d91c33d6ca6c6c751ff73102b8a4e8ac9f191e3eb2aa00e0ccfa9a1e16f69accb3f19ec9d1a54f25b0066f17de4d47560c0c976d47859ad9240b9
7
- data.tar.gz: f91bb3ab835a5ec653fdaa9666475b2d26f1e0acc2d43d8d753456c748137051d6ef364bf5709bc9569f774ecd0758022f798f1a5786b59c638d878c473b2fac
6
+ metadata.gz: 1a73a0cd671d283d5cda912c1ee324eaa6fe5ba15ea25e2864fb50c40e7bf474b2bd517b243a664dca1a15a8850f6a4cef503b114f0db333a3aaa6b807739366
7
+ data.tar.gz: 20e8eb0cda6e7840b38015ee6c25fb1833e07da1fce05e27e30111e29e5efc94b633902068cc2c2dbc3479574cc8291cc863b122c9e547d5e6b45c6f84a470a2
@@ -2,7 +2,8 @@
2
2
 
3
3
  module Lab
4
4
  class LabelsController < ApplicationController
5
- skip_before_action :authenticate
5
+ _callbacks = _process_action_callbacks.map(&:filter)
6
+ skip_before_action :authenticate if _callbacks.include?(:authenticate)
6
7
 
7
8
  def print_order_label
8
9
  order_id = params.require(:order_id)
@@ -3,7 +3,8 @@
3
3
  # This controller handles creation and authentication of LIMS User
4
4
  module Lab
5
5
  class UsersController < ::ApplicationController
6
- skip_before_action :authenticate
6
+ _callbacks = _process_action_callbacks.map(&:filter)
7
+ skip_before_action :authenticate if _callbacks.include?(:authenticate)
7
8
  # create a LIMS User that will be responsible for sending lab results
8
9
  def create
9
10
  user_params = params.permit(:username, :password)
@@ -2,6 +2,10 @@
2
2
 
3
3
  module Lab
4
4
  class LabResult < Observation
5
+ def children
6
+ Observation.where(obs_group_id: obs_id, voided: 0)
7
+ end
8
+
5
9
  alias measures children
6
10
 
7
11
  default_scope do
@@ -2,9 +2,10 @@
2
2
 
3
3
  module Lab
4
4
  module LabOrderSerializer
5
- def self.serialize_order(order, tests: nil, requesting_clinician: nil, reason_for_test: nil, target_lab: nil)
5
+ def self.serialize_order(order, tests: nil, requesting_clinician: nil, reason_for_test: nil, target_lab: nil, comment_to_fulfiller: nil)
6
6
  tests ||= order.voided == 1 ? voided_tests(order) : order.tests
7
7
  requesting_clinician ||= order.requesting_clinician
8
+ comment_to_fulfiller ||= order.comment_to_fulfiller
8
9
  reason_for_test ||= order.reason_for_test
9
10
  target_lab = target_lab&.value_text || order.target_lab&.value_text || Location.current_health_center&.name
10
11
  ActiveSupport::HashWithIndifferentAccess.new(
@@ -21,6 +22,7 @@ module Lab
21
22
  },
22
23
  requesting_clinician: requesting_clinician&.value_text,
23
24
  target_lab: target_lab,
25
+ comment_to_fulfiller: comment_to_fulfiller&.value_text,
24
26
  reason_for_test: {
25
27
  concept_id: reason_for_test&.value_coded,
26
28
  name: concept_name(reason_for_test&.value_coded)
@@ -33,7 +33,7 @@ module Lab
33
33
  bum.binge_changes(since: from, limit: limit, include_docs: true) do |change|
34
34
  next unless change['doc']['type']&.casecmp?('Order')
35
35
 
36
- yield OrderDTO.new(change['doc']), self
36
+ yield OrderDto.new(change['doc']), self
37
37
  end
38
38
  end
39
39
 
@@ -162,7 +162,7 @@ module Lab
162
162
  drawn_by_first_name, drawn_by_last_name = specimen['drawn_by_name']&.split
163
163
  patient_first_name, patient_last_name = patient['name'].split
164
164
 
165
- OrderDTO.new(
165
+ OrderDto.new(
166
166
  _id: specimen['doc_id'].blank? ? SecureRandom.uuid : specimen['doc_id'],
167
167
  _rev: '0',
168
168
  tracking_number: specimen['tracking_number'],
@@ -198,7 +198,7 @@ class Lab::Lims::Api::RestApi
198
198
  end
199
199
 
200
200
  ##
201
- # Converts an OrderDTO to parameters for POST /create_order
201
+ # Converts an OrderDto to parameters for POST /create_order
202
202
  def make_create_params(order_dto)
203
203
  {
204
204
  tracking_number: order_dto.fetch(:tracking_number),
@@ -227,7 +227,7 @@ class Lab::Lims::Api::RestApi
227
227
  end
228
228
 
229
229
  ##
230
- # Converts an OrderDTO to parameters for POST /update_order
230
+ # Converts an OrderDto to parameters for POST /update_order
231
231
  def make_update_params(order_dto)
232
232
  date_updated, status = sample_drawn_status(order_dto)
233
233
 
@@ -255,7 +255,7 @@ class Lab::Lims::Api::RestApi
255
255
  end
256
256
 
257
257
  ##
258
- # Extracts sample drawn status from an OrderDTO
258
+ # Extracts sample drawn status from an OrderDto
259
259
  def sample_drawn_status(order_dto)
260
260
  order_dto[:sample_statuses].each do |trail_entry|
261
261
  date, status = trail_entry.each_pair.find { |_date, status| status['status'].casecmp?('Drawn') }
@@ -268,13 +268,13 @@ class Lab::Lims::Api::RestApi
268
268
  end
269
269
 
270
270
  ##
271
- # Extracts a sample drawn date from a LIMS OrderDTO.
271
+ # Extracts a sample drawn date from a LIMS OrderDto.
272
272
  def sample_drawn_date(order_dto)
273
273
  sample_drawn_status(order_dto).first
274
274
  end
275
275
 
276
276
  ##
277
- # Extracts the requesting clinician from a LIMS OrderDTO
277
+ # Extracts the requesting clinician from a LIMS OrderDto
278
278
  def requesting_clinician(order_dto)
279
279
  orderer = order_dto[:who_order_test]
280
280
 
@@ -2,10 +2,12 @@
2
2
 
3
3
  module Lab
4
4
  module Lims
5
- class LimsException < StandardError; end
6
- class DuplicateNHID < LimsException; end
7
- class MissingAccessionNumber < LimsException; end
8
- class UnknownSpecimenType < LimsException; end
9
- class UnknownTestType < LimsException; end
5
+ module Exceptions
6
+ class LimsException < StandardError; end
7
+ class DuplicateNHID < LimsException; end
8
+ class MissingAccessionNumber < LimsException; end
9
+ class UnknownSpecimenType < LimsException; end
10
+ class UnknownTestType < LimsException; end
11
+ end
10
12
  end
11
13
  end
@@ -29,7 +29,7 @@ require 'lab/lab_test'
29
29
  require 'lab/lims_order_mapping'
30
30
  require 'lab/lims_failed_import'
31
31
 
32
- require_relative './api/couchdb_api'
32
+ require_relative './api/couch_db_api'
33
33
  require_relative './config'
34
34
  require_relative './pull_worker'
35
35
  require_relative './utils'
@@ -82,7 +82,7 @@ module Lab
82
82
  next unless row['doc']['type']&.casecmp?('Order')
83
83
 
84
84
  User.current = Utils.lab_user
85
- yield OrderDTO.new(row['doc']), OpenStruct.new(last_seq: (from || 0) + limit, current_seq: from)
85
+ yield OrderDto.new(row['doc']), OpenStruct.new(last_seq: (from || 0) + limit, current_seq: from)
86
86
  end
87
87
 
88
88
  from += orders.size
@@ -6,7 +6,7 @@ module Lab
6
6
  module Lims
7
7
  ##
8
8
  # LIMS' Data Transfer Object for orders
9
- class OrderDTO < ActiveSupport::HashWithIndifferentAccess
9
+ class OrderDto < ActiveSupport::HashWithIndifferentAccess
10
10
  include Utils
11
11
 
12
12
  ##
@@ -7,14 +7,14 @@ require_relative './utils'
7
7
  module Lab
8
8
  module Lims
9
9
  ##
10
- # Serializes a LabOrder into a LIMS OrderDTO.
10
+ # Serializes a LabOrder into a LIMS OrderDto.
11
11
  module OrderSerializer
12
12
  class << self
13
13
  include Utils
14
14
 
15
15
  def serialize_order(order)
16
16
  serialized_order = Lims::Utils.structify(Lab::LabOrderSerializer.serialize_order(order))
17
- Lims::OrderDTO.new(
17
+ Lims::OrderDto.new(
18
18
  _id: Lab::LimsOrderMapping.find_by(order: order)&.lims_id || serialized_order.accession_number,
19
19
  tracking_number: serialized_order.accession_number,
20
20
  sending_facility: current_facility_name,
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'logger_multiplexor'
4
4
 
5
- require_relative './api/couchdb_api'
5
+ require_relative './api/couch_db_api'
6
6
 
7
7
  module Lab
8
8
  module Lims
@@ -5,6 +5,7 @@ module Lab
5
5
  # Concepts
6
6
  REASON_FOR_TEST_CONCEPT_NAME = 'Reason for test'
7
7
  REQUESTING_CLINICIAN_CONCEPT_NAME = 'Person making request'
8
+ COMMENT_TO_FULFILLER_CONCEPT_NAME = 'Comment to fulfiller'
8
9
  SPECIMEN_TYPE_CONCEPT_NAME = 'Specimen type'
9
10
  TARGET_LAB_CONCEPT_NAME = 'Lab'
10
11
  TEST_RESULT_CONCEPT_NAME = 'Lab test result'
@@ -63,7 +63,8 @@ module Lab
63
63
  Lab::LabOrderSerializer.serialize_order(
64
64
  order, requesting_clinician: add_requesting_clinician(order, order_params),
65
65
  reason_for_test: add_reason_for_test(order, order_params),
66
- target_lab: add_target_lab(order, order_params)
66
+ target_lab: add_target_lab(order, order_params),
67
+ comment_to_fulfiller: add_comment_to_fulfiller(order, order_params)
67
68
  )
68
69
  end
69
70
  end
@@ -97,11 +98,12 @@ module Lab
97
98
  end
98
99
 
99
100
  def void_order(order_id, reason)
100
- order = Lab::LabOrder.includes(%i[requesting_clinician reason_for_test target_lab], tests: [:result])
101
+ order = Lab::LabOrder.includes(%i[requesting_clinician reason_for_test target_lab comment_to_fulfiller], tests: [:result])
101
102
  .find(order_id)
102
103
 
103
104
  order.requesting_clinician&.void(reason)
104
105
  order.reason_for_test&.void(reason)
106
+ order.comment_to_fulfiller&.void(reason)
105
107
  order.target_lab&.void(reason)
106
108
 
107
109
  order.tests.each { |test| test.void(reason) }
@@ -224,6 +226,7 @@ module Lab
224
226
  order.date_created = params[:date]&.to_date || Date.today if order.respond_to?(:date_created)
225
227
  order.start_date = params[:date]&.to_date || Date.today if order.respond_to?(:start_date)
226
228
  order.auto_expire_date = params[:end_date]
229
+ order.comment_to_fulfiller = params[:comment_to_fulfiller] if params[:comment_to_fulfiller]
227
230
  order.accession_number = access_number
228
231
  order.orderer = User.current&.user_id
229
232
 
@@ -256,6 +259,15 @@ module Lab
256
259
  )
257
260
  end
258
261
 
262
+ def add_comment_to_fulfiller(order, params)
263
+ create_order_observation(
264
+ order,
265
+ Lab::Metadata::COMMENT_TO_FULFILLER_CONCEPT_NAME,
266
+ params[:date],
267
+ value_text: params['comment_to_fulfiller']
268
+ )
269
+ end
270
+
259
271
  ##
260
272
  # Attach a reason for the order/test
261
273
  #
data/lib/lab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lab
4
- VERSION = '1.2.4'
4
+ VERSION = '1.2.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mahis_emr_api_lab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elizabeth Glaser Pediatric Foundation Malawi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-06 00:00:00.000000000 Z
11
+ date: 2025-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: couchrest
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 1.4.0
201
+ version: '1.7'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 1.4.0
208
+ version: '1.7'
209
209
  description: |
210
210
  This adds a lab interface to the OpenMRS compatible core API provided by
211
211
  [HIS-EMR-API](https://github.com/EGPAFMalawiHIS/HIS-EMR-API).
@@ -254,7 +254,7 @@ files:
254
254
  - app/services/lab/lims/acknowledgement_serializer.rb
255
255
  - app/services/lab/lims/acknowledgement_worker.rb
256
256
  - app/services/lab/lims/api/blackhole_api.rb
257
- - app/services/lab/lims/api/couchdb_api.rb
257
+ - app/services/lab/lims/api/couch_db_api.rb
258
258
  - app/services/lab/lims/api/mysql_api.rb
259
259
  - app/services/lab/lims/api/rest_api.rb
260
260
  - app/services/lab/lims/api/ws_api.rb
@@ -309,7 +309,7 @@ licenses:
309
309
  - MIT
310
310
  metadata:
311
311
  source_code_uri: https://github.com/EGPAFMalawiHIS/his_emr_api_lab
312
- post_install_message:
312
+ post_install_message:
313
313
  rdoc_options: []
314
314
  require_paths:
315
315
  - lib
@@ -324,8 +324,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  - !ruby/object:Gem::Version
325
325
  version: '0'
326
326
  requirements: []
327
- rubygems_version: 3.4.17
328
- signing_key:
327
+ rubygems_version: 3.4.1
328
+ signing_key:
329
329
  specification_version: 4
330
330
  summary: Lab extension for the HIS-EMR-API
331
331
  test_files: []