his_emr_api_lab 2.1.8 → 2.1.8.2

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: 44e72036503453b83d8f3cfcdff281e1085e461c476a8f793e24a3d72f12f223
4
- data.tar.gz: 0100d95046a1a81db0fc8b7eace3e9fa02dc2f9be6f396f073954bbfa5578993
3
+ metadata.gz: 9cb9a5bbd197abbf3a6e6491f40c4393eae00454dfab8a2f95998e63e5c433c5
4
+ data.tar.gz: 9d03fc2d27f0cecdcf96a31a2c943613bbd682490975a21c20de74b911f50b12
5
5
  SHA512:
6
- metadata.gz: 25cb61dabafa209680d649747e35a06e19ed3685c7730bc0c539a35357e9e9529794ed180714c626125ec6ab8104b107e90e6ad0ab0cbebfcaee2ae728ea7815
7
- data.tar.gz: 0da64fc5aa9647ffcc3252ae597b0492bacb3b77ec97064c4433f72bcd122431e04114323f7f13dc602faa0ccdc7c2f836b098a1090e9a56fa8cae774503101f
6
+ metadata.gz: 30d5d98bc17b9b393499eef09d029ac04223aac2112baa7dbd6d43beef07ef86f0c44148a00258558db939eb4ef4acafbb4ce862411cc158b9006da007c63426
7
+ data.tar.gz: c01c90f3d5911cf65a60b30e366af294e1d47703e37edf8d057374688d95928223f62166e911a3d37e5598badcefbd07f7e7e64f507d622aa3812bde77a709e0
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Lab
4
4
  class OrdersController < ApplicationController
5
+ skip_before_action :authenticate, only: %i[order_status order_result summary]
5
6
  before_action :authenticate_request, only: %i[order_status order_result summary]
6
7
 
7
8
  def create
@@ -76,8 +77,26 @@ module Lab
76
77
  private
77
78
 
78
79
  def authenticate_request
79
- decoded_user = authorize_request
80
- user(decoded_user)
80
+ header = request.headers['Authorization']
81
+ content = header.split(' ')
82
+ auth_scheme = content.first
83
+ unless header
84
+ errors = ['Authorization token required']
85
+ render json: { errors: errors }, status: :unauthorized
86
+ return false
87
+ end
88
+ unless auth_scheme == 'Bearer'
89
+ errors = ['Authorization token bearer scheme required']
90
+ render json: { errors: errors }, status: :unauthorized
91
+ return false
92
+ end
93
+ process_token(content.last)
94
+ end
95
+
96
+ def process_token(token)
97
+ browser = Browser.new(request.user_agent)
98
+ decoded = Lab::JsonWebTokenService.decode(token, request.remote_ip + browser.name + browser.version)
99
+ user(decoded)
81
100
  end
82
101
 
83
102
  def user(decoded)
@@ -10,7 +10,7 @@ module Lab
10
10
  target_lab = target_lab&.value_text || order.target_lab&.value_text || Location.current_health_center&.name
11
11
 
12
12
  encounter = Encounter.find_by_encounter_id(order.encounter_id)
13
- program = Program.find_by_program_id(encounter.program_id)
13
+ program = Program.find_by_program_id(encounter&.program_id)
14
14
 
15
15
  ActiveSupport::HashWithIndifferentAccess.new(
16
16
  {
@@ -19,8 +19,8 @@ module Lab
19
19
  order_id: order.order_id, # Deprecated: Link to :id
20
20
  encounter_id: order.encounter_id,
21
21
  order_date: order.start_date,
22
- location_id: encounter.location_id,
23
- program_id: encounter.program_id,
22
+ location_id: encounter&.location_id,
23
+ program_id: encounter&.program_id,
24
24
  program_name: program&.name,
25
25
  patient_id: order.patient_id,
26
26
  accession_number: order.accession_number,
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.1.8'
4
+ VERSION = '2.1.8.2'
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.1.8
4
+ version: 2.1.8.2
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-02-27 00:00:00.000000000 Z
11
+ date: 2026-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: couchrest