ruby_astm 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/mappings.json +19 -3
- data/lib/publisher/google_lab_interface.rb +1 -2
- data/lib/publisher/poller.rb +24 -1
- data/lib/ruby_astm/custom/siemens_abg_electrolyte_module.rb +4 -0
- data/lib/ruby_astm/lab_interface.rb +5 -5
- data/lib/ruby_astm/order.rb +8 -0
- data/lib/ruby_astm/result.rb +25 -1
- data/lib/ruby_astm/usb_module.rb +26 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f211891d302b07536fa0edbadcd5da4395f17627
|
4
|
+
data.tar.gz: d803f0319f91c825ab9fa560c7dfe3ae7e08f9a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6db8e7f19a9d7b4014c3e9f8ce18f4a7b89509d11a5121ca6935366cc671a4d88b03d2d2a37f4c83d1f5de4803f8ec27ee00ecc046fd22e54213252430c2f785
|
7
|
+
data.tar.gz: 0dfbc2aad3bfac163e3121a0d501895775c1eec7f4c5d8f72b19df4fd8922e225bc01bd2f9b9a87af1560ed98972dbcbbad3d209feefcc2aacba475dad6f7951
|
data/lib/mappings.json
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
"_comment" : "key -> code sent by analyzer, eg sysmex sends WBC count under the code 'WBC'. value -> object. Object structure: 'LIS_CODE': in the google lab interface, this code is present in two places on google drive. one) in the name of the file, two) inside the file, where the test result value should be added. For eg in the hemogram report, TLCparam, is present in the name of the file, as well as inside the file, so the google script will update it with the relevant value. 'TUBE' stands for the type of tube in which this test has to be performed. This should match the constants in the Google Lab Interface.rb file. Now there is another problem that we have to deal with here. When going bidirectional, in some machines like Roche Cobas e411, the test codes come in as numbers, and not letters, so the keys here in this file are numbers, for those tests. Because Roche is a bitch basically.",
|
3
3
|
"A1c" : {
|
4
4
|
"LIS_CODE" : "HBA1C",
|
5
|
+
"TUBE" : "EDTA",
|
5
6
|
"REPORT_NAME" : "Glycosylated Hemoglobin",
|
6
7
|
"TYPE" : "HEMAT"
|
7
8
|
},
|
@@ -195,7 +196,10 @@
|
|
195
196
|
"LIS_CODE" : "ALB",
|
196
197
|
"TUBE" : "SERUM",
|
197
198
|
"REPORT_NAME" : "Albumin",
|
198
|
-
"TYPE" : "BIOCHEM"
|
199
|
+
"TYPE" : "BIOCHEM",
|
200
|
+
"MACHINE_SPECIFIC_LIS_CODES" : {
|
201
|
+
"CLINITEK" : "UALB"
|
202
|
+
}
|
199
203
|
},
|
200
204
|
"GGTP" : {
|
201
205
|
"LIS_CODE" : "GGT",
|
@@ -479,6 +483,18 @@
|
|
479
483
|
"REPORT_NAME" : "Urine Routine",
|
480
484
|
"TYPE" : "URINE"
|
481
485
|
},
|
486
|
+
"CRE" : {
|
487
|
+
"LIS_CODE" : "UCRE",
|
488
|
+
"TUBE" : "URINE_CONTAINER",
|
489
|
+
"REPORT_NAME" : "Urine Routine",
|
490
|
+
"TYPE" : "URINE"
|
491
|
+
},
|
492
|
+
"UALB" : {
|
493
|
+
"LIS_CODE" : "UALB",
|
494
|
+
"TUBE" : "URINE_CONTAINER",
|
495
|
+
"REPORT_NAME" : "Urine Routine",
|
496
|
+
"TYPE" : "URINE"
|
497
|
+
},
|
482
498
|
"UA" : {
|
483
499
|
"LIS_CODE" : "SURIC",
|
484
500
|
"TUBE" : "SERUM",
|
@@ -501,13 +517,13 @@
|
|
501
517
|
"LIS_CODE" : "full_body_package",
|
502
518
|
"TUBE" : "",
|
503
519
|
"REPORT_NAME" : "full body package",
|
504
|
-
"PACKAGE_COMPONENTS" : ["HBA1C", "TLCparam", "RBCparam", "HBparam", "HCTparam", "MCVparam", "MCHparam", "MCHCparam", "PCparam", "Nparam", "Lparam", "Mparam", "Eparam", "BASOparam", "ANCparam", "ALCparam", "AMCparam", "AECparam", "ABCparam", "RDWCVparam", "GLUR", "GLUPP", "GLUF", "CHOL", "TRIG", "HDLC", "LDL", "VLDLC", "CRE", "UREA", "BUN", "ALB", "GGT", "BID", "CA", "BIT", "BII", "ALPU", "GOTHL", "GPTHL", "HOMCY", "SIRON", "SUIBC", "STIBC", "SURIC", "SPHOS", "SMAG", "SNATRIUM", "SPOTASSIUM", "SCHLORIDE", "SIGE", "SPSA", "SFER", "TSH", "T4", "T3", "VITD", "HCV", "B12", "ESR", "GLU", "BIL", "KET", "SG", "BLO", "pH", "PRO", "URO", "NIT", "LEU", "COL", "CLA"]
|
520
|
+
"PACKAGE_COMPONENTS" : ["HBA1C", "TLCparam", "RBCparam", "HBparam", "HCTparam", "MCVparam", "MCHparam", "MCHCparam", "PCparam", "Nparam", "Lparam", "Mparam", "Eparam", "BASOparam", "ANCparam", "ALCparam", "AMCparam", "AECparam", "ABCparam", "RDWCVparam", "GLUR", "GLUPP", "GLUF", "CHOL", "TRIG", "HDLC", "LDL", "VLDLC", "CRE", "UREA", "BUN", "ALB", "GGT", "BID", "CA", "BIT", "BII", "ALPU", "GOTHL", "GPTHL", "HOMCY", "SIRON", "SUIBC", "STIBC", "SURIC", "SPHOS", "SMAG", "SNATRIUM", "SPOTASSIUM", "SCHLORIDE", "SIGE", "SPSA", "SFER", "TSH", "T4", "T3", "VITD", "HCV", "B12", "ESR", "GLU", "BIL", "KET", "SG", "BLO", "pH", "PRO", "URO", "NIT", "LEU", "COL", "CLA","UCRE","UALB"]
|
505
521
|
},
|
506
522
|
"PRE_OP_PACKAGE" : {
|
507
523
|
"LIS_CODE" : "pre_op_package",
|
508
524
|
"TUBE" : "",
|
509
525
|
"REPORT_NAME" : "pre_op_package",
|
510
|
-
"PACKAGE_COMPONENTS" : ["TLCparam", "RBCparam", "HBparam", "HCTparam", "MCVparam", "MCHparam", "MCHCparam", "PCparam", "Nparam", "Lparam", "Mparam", "Eparam", "BASOparam", "ANCparam", "ALCparam", "AMCparam", "AECparam", "ABCparam", "RDWCVparam", "GLUR","ESR", "GLU", "BIL", "KET", "SG", "BLO", "pH", "PRO", "URO", "NIT", "LEU", "COL", "CLA", "HIV", "HBS"]
|
526
|
+
"PACKAGE_COMPONENTS" : ["TLCparam", "RBCparam", "HBparam", "HCTparam", "MCVparam", "MCHparam", "MCHCparam", "PCparam", "Nparam", "Lparam", "Mparam", "Eparam", "BASOparam", "ANCparam", "ALCparam", "AMCparam", "AECparam", "ABCparam", "RDWCVparam", "GLUR","ESR", "GLU", "BIL", "KET", "SG", "BLO", "pH", "PRO", "URO", "NIT", "LEU", "COL", "CLA", "HIV", "HBS","UCRE","UALB"]
|
511
527
|
},
|
512
528
|
"LIPID_PROFILE" : {
|
513
529
|
"LIS_CODE" : "lipid_profile",
|
@@ -2,11 +2,10 @@ require 'google/apis/script_v1'
|
|
2
2
|
require 'googleauth'
|
3
3
|
require 'googleauth/stores/file_token_store'
|
4
4
|
require 'fileutils'
|
5
|
-
|
5
|
+
require_relative "poller"
|
6
6
|
|
7
7
|
class Google_Lab_Interface < Poller
|
8
8
|
|
9
|
-
|
10
9
|
OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'.freeze
|
11
10
|
APPLICATION_NAME = 'Google Apps Script API Ruby Quickstart'.freeze
|
12
11
|
## these two cannot be hardcoded.
|
data/lib/publisher/poller.rb
CHANGED
@@ -107,8 +107,27 @@ class Poller
|
|
107
107
|
|
108
108
|
end
|
109
109
|
|
110
|
+
def assign_tube(component_machine_code,tests_hash,tube_type)
|
111
|
+
tube_key = nil
|
112
|
+
unless tests_hash.keys.select{|c| c=~/#{tube_type}/ }.blank?
|
113
|
+
tube_key = tests_hash.keys.select{|c| c=~/#{tube_type}/ }[0]
|
114
|
+
tests_hash[tube_key] << component_machine_code
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
110
118
|
## first we have to test the packages.
|
111
119
|
|
120
|
+
def determine_tube(component_machine_code,tests_hash)
|
121
|
+
res = $mappings[component_machine_code]["TUBE"]
|
122
|
+
if res.is_a? Array
|
123
|
+
res.each do |tube|
|
124
|
+
assign_tube(component_machine_code,tests_hash,tube)
|
125
|
+
end
|
126
|
+
elsif res.is_a? String
|
127
|
+
assign_tube(component_machine_code,tests_hash,res)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
112
131
|
def build_tests_hash(record)
|
113
132
|
#puts "Record is ---------------------------------------------"
|
114
133
|
#puts record
|
@@ -190,17 +209,21 @@ class Poller
|
|
190
209
|
## for eg plasma tube can do all the tests
|
191
210
|
## so can serum
|
192
211
|
## but we use the plasma tube only for some.
|
193
|
-
|
212
|
+
=begin
|
194
213
|
tube = $mappings[component_machine_code]["TUBE"]
|
195
214
|
tube_key = nil
|
196
215
|
unless tests_hash.keys.select{|c| c=~/#{tube}/ }.blank?
|
197
216
|
tube_key = tests_hash.keys.select{|c| c=~/#{tube}/ }[0]
|
198
217
|
tests_hash[tube_key] << component_machine_code
|
199
218
|
end
|
219
|
+
=end
|
220
|
+
determine_tube(component_machine_code,tests_hash)
|
221
|
+
|
200
222
|
end
|
201
223
|
|
202
224
|
else
|
203
225
|
## here also it is the same problem.
|
226
|
+
## this can be sorted out by using the array of the tube.
|
204
227
|
tube = $mappings[machine_code]["TUBE"]
|
205
228
|
tube_key = nil
|
206
229
|
unless tests_hash.keys.select{|c| c=~/#{tube}/ }.blank?
|
@@ -93,6 +93,7 @@ module SiemensAbgElectrolyteModule
|
|
93
93
|
## @param[String] barcode : the barcode
|
94
94
|
## @param[Result] result : result_object
|
95
95
|
def add_result?(barcode,result)
|
96
|
+
puts "Came to add result"
|
96
97
|
return true if $redis.hget(SIEMENS_ELEC_ABG_RESULTS_HASH,barcode).blank?
|
97
98
|
existing_results = JSON.parse($redis.hget(SIEMENS_ELEC_ABG_RESULTS_HASH,barcode))
|
98
99
|
if existing_results[result.name].blank?
|
@@ -103,6 +104,8 @@ module SiemensAbgElectrolyteModule
|
|
103
104
|
false
|
104
105
|
end
|
105
106
|
|
107
|
+
|
108
|
+
|
106
109
|
## we override the lab interface methods
|
107
110
|
## and we don't pollute the lab interface itself.
|
108
111
|
## as this is a custom analyzer.
|
@@ -203,6 +206,7 @@ module SiemensAbgElectrolyteModule
|
|
203
206
|
|
204
207
|
unless o.results.blank?
|
205
208
|
p.orders << o
|
209
|
+
$redis.hset(SIEMENS_ELEC_ABG_RESULTS_HASH,patient_id,JSON.generate(o.results_values_hash))
|
206
210
|
self.headers[-1].patients << p
|
207
211
|
end
|
208
212
|
|
@@ -266,10 +266,10 @@ module LabInterface
|
|
266
266
|
if data.bytes.to_a[-1] == 4
|
267
267
|
puts "GOT EOT --- PROCESSING BUFFER, AND CLEARING."
|
268
268
|
process_text(self.data_buffer)
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
puts self.test_data_bytes.flatten.to_s
|
269
|
+
root_path = File.dirname __dir__
|
270
|
+
puts "root path #{root_path}"
|
271
|
+
IO.write((File.join root_path,'../test','resources','d10_error.txt'),self.test_data_bytes.to_s)
|
272
|
+
#puts self.test_data_bytes.flatten.to_s
|
273
273
|
self.data_buffer = ''
|
274
274
|
unless self.headers.blank?
|
275
275
|
if self.headers[-1].queries.blank?
|
@@ -381,7 +381,7 @@ module LabInterface
|
|
381
381
|
self.headers[-1].patients << hl7_patient
|
382
382
|
when "Hl7_Order"
|
383
383
|
unless self.headers[-1].patients.blank?
|
384
|
-
hl7_order = Hl7Order.new({:line => line, :patient_id => self.headers[-1].patients[-1].patient_id})
|
384
|
+
hl7_order = Hl7Order.new({:line => line, :patient_id => self.headers[-1].patients[-1].patient_id}, :machine_name => self.headers[-1].machine_name)
|
385
385
|
self.headers[-1].patients[-1].orders << hl7_order
|
386
386
|
end
|
387
387
|
when "Header"
|
data/lib/ruby_astm/order.rb
CHANGED
data/lib/ruby_astm/result.rb
CHANGED
@@ -8,6 +8,9 @@ class Result
|
|
8
8
|
attr_accessor :reference_ranges
|
9
9
|
attr_accessor :dilution
|
10
10
|
|
11
|
+
## sometimes we customize the lis code based on the machine which is sending it, so we need this.
|
12
|
+
attr_accessor :machine_name
|
13
|
+
|
11
14
|
def set_name(args)
|
12
15
|
puts "came to set name"
|
13
16
|
if line = args[:line]
|
@@ -109,6 +112,10 @@ class Result
|
|
109
112
|
end
|
110
113
|
end
|
111
114
|
|
115
|
+
def set_machine_name(args)
|
116
|
+
self.machine_name = args[:machine_name]
|
117
|
+
end
|
118
|
+
|
112
119
|
|
113
120
|
|
114
121
|
## here will call mappings and check the result correlation
|
@@ -121,6 +128,7 @@ class Result
|
|
121
128
|
set_dilution(args)
|
122
129
|
set_units(args)
|
123
130
|
|
131
|
+
|
124
132
|
=begin
|
125
133
|
if args[:line]
|
126
134
|
line = args[:line]
|
@@ -148,7 +156,23 @@ class Result
|
|
148
156
|
|
149
157
|
## @return[String] the name defined in the mappings.json file, or the name that wqs passed in.
|
150
158
|
def lookup_mapping(name)
|
151
|
-
$mappings[name]
|
159
|
+
unless $mappings[name].blank?
|
160
|
+
unless self.machine_name.blank?
|
161
|
+
unless $mappings[name]["MACHINE_SPECIFIC_LIS_CODES"].blank?
|
162
|
+
unless $mappings[name]["MACHINE_SPECIFIC_LIS_CODES"][self.machine_name].blank?
|
163
|
+
redirect = $mappings[name]["MACHINE_SPECIFIC_LIS_CODES"][self.machine_name]
|
164
|
+
unless $mappings[redirect].blank?
|
165
|
+
$mappings[redirect]["LIS_CODE"]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
else
|
170
|
+
$mappings[name]["LIS_CODE"]
|
171
|
+
end
|
172
|
+
else
|
173
|
+
name
|
174
|
+
end
|
175
|
+
#$mappings[name] ? $mappings[name]["LIS_CODE"] : name
|
152
176
|
end
|
153
177
|
|
154
178
|
def lookup_transform(name)
|
data/lib/ruby_astm/usb_module.rb
CHANGED
@@ -5,6 +5,9 @@ module UsbModule
|
|
5
5
|
mattr_accessor :usb_response_bytes
|
6
6
|
|
7
7
|
ESR_RESULTS_HASH = "ESR_RESULTS_HASH"
|
8
|
+
ESR_SORTED_SET = "ESR_SORTED_SET"
|
9
|
+
## a particular barcode will be allowed to have 3 different results, after which the next time it won't be uploaded.
|
10
|
+
MAX_REPEAT_RESULT_COUNT = 3
|
8
11
|
|
9
12
|
def begin_patient_results
|
10
13
|
">00A00013"
|
@@ -32,6 +35,21 @@ module UsbModule
|
|
32
35
|
self.usb_response_bytes[-3] == 13
|
33
36
|
end
|
34
37
|
|
38
|
+
def add_result_by_count?(barcode,result)
|
39
|
+
begin
|
40
|
+
|
41
|
+
|
42
|
+
rescue => e
|
43
|
+
puts e.to_s
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
## total times repeated, we can have that as max 3 times.
|
48
|
+
## so after that it wont add.
|
49
|
+
## so we keep a sorted set with the barcode and the count
|
50
|
+
## like key -> value, score
|
51
|
+
## key(barcode) -> value(time) -> score(count)
|
52
|
+
## so we can zincrby, each time.
|
35
53
|
def add_result?(barcode,result)
|
36
54
|
begin
|
37
55
|
Integer(result)
|
@@ -40,12 +58,17 @@ module UsbModule
|
|
40
58
|
#puts "the result is not zero"
|
41
59
|
existing_result = $redis.hget(ESR_RESULTS_HASH,barcode)
|
42
60
|
#puts "existing result is: #{existing_result}"
|
43
|
-
if (
|
44
|
-
|
61
|
+
if (existing_result.blank?)
|
62
|
+
true
|
63
|
+
else
|
64
|
+
if existing_result != result
|
65
|
+
current_count = $redis.zincrby(ESR_SORTED_SET,1,barcode)
|
66
|
+
current_count <= MAX_REPEAT_RESULT_COUNT
|
67
|
+
end
|
45
68
|
end
|
46
69
|
rescue => e
|
47
70
|
puts e.to_s
|
48
|
-
|
71
|
+
false
|
49
72
|
end
|
50
73
|
|
51
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_astm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bhargav Raut
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.6.14.4
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: A Ruby gem to interface with Medical instruments that work on the ASTM protocol
|