his_emr_api_lab 0.0.9 → 0.0.14
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/services/lab/labelling_service/order_label.rb +7 -4
- data/app/services/lab/lims/failed_imports.rb +34 -0
- data/app/services/lab/lims/migrator.rb +1 -1
- data/app/services/lab/lims/utils.rb +2 -0
- data/app/services/lab/lims/worker.rb +9 -1
- data/lib/lab/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb42401918667c79dc2f78a1ce8f32cd611abd12650686142546e28396eb7cf4
|
4
|
+
data.tar.gz: 76fd320373a81bf3b10b42aeca93a381e63d112f66ee977618778b9f56c1b8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfcb51b5aeb60f0910ab62fdbca15e7cf13bcf450c625755eb29a15556122d5de40e92d4ffd7d7a1141b2bebd1d285bc567fa0ed87280c5bc501a0d52ee6cdb1
|
7
|
+
data.tar.gz: 9cb56acdbcc7559dd0106b8af3eab31141cbe1e9ca13d36094a3cb25dcc0d632a1fb910db9b6312000ca83563e2c118acf819816fecb29288e3390d74cecbdb1
|
@@ -60,11 +60,14 @@ module Lab
|
|
60
60
|
def drawer
|
61
61
|
return 'N/A' if order.concept_id == unknown_concept.concept_id
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
drawer_id = User.find(order.discontinued_by || order.creator).person_id
|
64
|
+
draw_date = (order.discontinued_date || order.start_date).strftime('%d/%^b/%Y %H:%M:%S')
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
name = PersonName.find_by_person_id(drawer_id)
|
67
|
+
return "#{name.given_name} #{name.family_name} #{draw_date}" if name
|
68
|
+
|
69
|
+
user = User.find_by_user_id(drawer_id)
|
70
|
+
user ? "#{user.username} #{draw_date}" : 'N/A'
|
68
71
|
end
|
69
72
|
|
70
73
|
def specimen
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './api'
|
4
|
+
require_relative './order_dto'
|
5
|
+
|
6
|
+
module Lab
|
7
|
+
module Lims
|
8
|
+
##
|
9
|
+
# Manage LIMS orders that failed to import
|
10
|
+
module FailedImports
|
11
|
+
class << self
|
12
|
+
##
|
13
|
+
# Retrieve all imports that failed
|
14
|
+
def failed_imports(start_id = 0, limit = 20)
|
15
|
+
Lab::LimsFailedImport.where('id >= ?', start_id).limit(limit)
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Forcefully imports a failed import into a patient
|
20
|
+
def force_import(failed_import_id, _patient_id)
|
21
|
+
failed_import = Lab::LimsFailedImport.find(failed_import_id)
|
22
|
+
order_dto = Lab::Lims::OrderDTO.new(lims_api.find_order(failed_import.lims_id))
|
23
|
+
byebug
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def lims_api
|
29
|
+
@lims_api ||= Lab::Lims::Api.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -66,6 +66,8 @@ module Lab
|
|
66
66
|
Date.strptime(str_date, '%d-%m-%Y').strftime('%Y-%m-%d')
|
67
67
|
elsif str_date.match?(/(\d{4}\d{2}\d{2})\d+/)
|
68
68
|
Date.strptime(str_date, '%Y%m%d').strftime('%Y-%m-%d')
|
69
|
+
elsif str_date.match?(%r{\d{2}/\d{2}/\d{4}})
|
70
|
+
str_date.to_date.to_s
|
69
71
|
else
|
70
72
|
Rails.logger.warn("Invalid date: #{str_date}")
|
71
73
|
parse_date(fallback_date)
|
@@ -139,9 +139,17 @@ module Lab
|
|
139
139
|
def find_patient_by_nhid(nhid)
|
140
140
|
national_id_type = PatientIdentifierType.where(name: ['National id', 'Old Identification Number'])
|
141
141
|
identifiers = PatientIdentifier.where(type: national_id_type, identifier: nhid)
|
142
|
+
.joins('INNER JOIN person ON person.person_id = patient_identifier.patient_id AND person.voided = 0')
|
142
143
|
if identifiers.count.zero?
|
143
|
-
identifiers = PatientIdentifier.unscoped
|
144
|
+
identifiers = PatientIdentifier.unscoped
|
145
|
+
.where(voided: 1, type: national_id_type, identifier: nhid)
|
146
|
+
.joins('INNER JOIN person ON person.person_id = patient_identifier.patient_id AND person.voided = 0')
|
144
147
|
end
|
148
|
+
|
149
|
+
# Joining to person above to ensure that the person is not voided,
|
150
|
+
# it was noted at one site that there were some people that were voided
|
151
|
+
# upon merging but the patient and patient_identifier was not voided
|
152
|
+
|
145
153
|
return nil if identifiers.count.zero?
|
146
154
|
|
147
155
|
patients = Patient.where(patient_id: identifiers.select(:patient_id))
|
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: 0.0.
|
4
|
+
version: 0.0.14
|
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: 2021-
|
11
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: couchrest
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- app/services/lab/lims/api.rb
|
253
253
|
- app/services/lab/lims/config.rb
|
254
254
|
- app/services/lab/lims/exceptions.rb
|
255
|
+
- app/services/lab/lims/failed_imports.rb
|
255
256
|
- app/services/lab/lims/migrator.rb
|
256
257
|
- app/services/lab/lims/order_dto.rb
|
257
258
|
- app/services/lab/lims/order_serializer.rb
|