mahis_emr_api_lab 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +71 -0
  4. data/Rakefile +32 -0
  5. data/app/controllers/lab/application_controller.rb +6 -0
  6. data/app/controllers/lab/labels_controller.rb +17 -0
  7. data/app/controllers/lab/orders_controller.rb +78 -0
  8. data/app/controllers/lab/reasons_for_test_controller.rb +9 -0
  9. data/app/controllers/lab/results_controller.rb +20 -0
  10. data/app/controllers/lab/specimen_types_controller.rb +15 -0
  11. data/app/controllers/lab/test_result_indicators_controller.rb +9 -0
  12. data/app/controllers/lab/test_types_controller.rb +15 -0
  13. data/app/controllers/lab/tests_controller.rb +25 -0
  14. data/app/controllers/lab/users_controller.rb +32 -0
  15. data/app/jobs/lab/application_job.rb +4 -0
  16. data/app/jobs/lab/push_order_job.rb +12 -0
  17. data/app/jobs/lab/update_patient_orders_job.rb +32 -0
  18. data/app/jobs/lab/void_order_job.rb +17 -0
  19. data/app/mailers/lab/application_mailer.rb +6 -0
  20. data/app/models/lab/application_record.rb +5 -0
  21. data/app/models/lab/lab_accession_number_counter.rb +13 -0
  22. data/app/models/lab/lab_acknowledgement.rb +6 -0
  23. data/app/models/lab/lab_encounter.rb +7 -0
  24. data/app/models/lab/lab_order.rb +58 -0
  25. data/app/models/lab/lab_result.rb +31 -0
  26. data/app/models/lab/lab_test.rb +19 -0
  27. data/app/models/lab/lims_failed_import.rb +4 -0
  28. data/app/models/lab/lims_order_mapping.rb +10 -0
  29. data/app/models/lab/order_extension.rb +14 -0
  30. data/app/serializers/lab/lab_order_serializer.rb +56 -0
  31. data/app/serializers/lab/result_serializer.rb +36 -0
  32. data/app/serializers/lab/test_serializer.rb +52 -0
  33. data/app/services/lab/accession_number_service.rb +77 -0
  34. data/app/services/lab/acknowledgement_service.rb +47 -0
  35. data/app/services/lab/concepts_service.rb +82 -0
  36. data/app/services/lab/json_web_token_service.rb +20 -0
  37. data/app/services/lab/labelling_service/order_label.rb +106 -0
  38. data/app/services/lab/lims/acknowledgement_serializer.rb +29 -0
  39. data/app/services/lab/lims/acknowledgement_worker.rb +37 -0
  40. data/app/services/lab/lims/api/blackhole_api.rb +21 -0
  41. data/app/services/lab/lims/api/couchdb_api.rb +53 -0
  42. data/app/services/lab/lims/api/mysql_api.rb +316 -0
  43. data/app/services/lab/lims/api/rest_api.rb +434 -0
  44. data/app/services/lab/lims/api/ws_api.rb +121 -0
  45. data/app/services/lab/lims/api_factory.rb +19 -0
  46. data/app/services/lab/lims/config.rb +105 -0
  47. data/app/services/lab/lims/exceptions.rb +11 -0
  48. data/app/services/lab/lims/migrator.rb +216 -0
  49. data/app/services/lab/lims/order_dto.rb +105 -0
  50. data/app/services/lab/lims/order_serializer.rb +251 -0
  51. data/app/services/lab/lims/pull_worker.rb +314 -0
  52. data/app/services/lab/lims/push_worker.rb +152 -0
  53. data/app/services/lab/lims/utils.rb +91 -0
  54. data/app/services/lab/lims/worker.rb +94 -0
  55. data/app/services/lab/metadata.rb +26 -0
  56. data/app/services/lab/notification_service.rb +72 -0
  57. data/app/services/lab/orders_search_service.rb +72 -0
  58. data/app/services/lab/orders_service.rb +330 -0
  59. data/app/services/lab/results_service.rb +166 -0
  60. data/app/services/lab/tests_service.rb +105 -0
  61. data/app/services/lab/user_service.rb +62 -0
  62. data/config/routes.rb +28 -0
  63. data/db/migrate/20210126092910_create_lab_lab_accession_number_counters.rb +12 -0
  64. data/db/migrate/20210310115457_create_lab_lims_order_mappings.rb +15 -0
  65. data/db/migrate/20210323080140_change_lims_id_to_string_in_lims_order_mapping.rb +15 -0
  66. data/db/migrate/20210326195504_add_order_revision_to_lims_order_mapping.rb +5 -0
  67. data/db/migrate/20210407071728_create_lab_lims_failed_imports.rb +19 -0
  68. data/db/migrate/20210610095024_fix_numeric_results_value_type.rb +20 -0
  69. data/db/migrate/20210807111531_add_default_to_lims_order_mapping.rb +7 -0
  70. data/lib/auto12epl.rb +201 -0
  71. data/lib/couch_bum/couch_bum.rb +92 -0
  72. data/lib/generators/lab/install/USAGE +9 -0
  73. data/lib/generators/lab/install/install_generator.rb +19 -0
  74. data/lib/generators/lab/install/templates/rswag-ui-lab.rb +5 -0
  75. data/lib/generators/lab/install/templates/start_worker.rb +32 -0
  76. data/lib/generators/lab/install/templates/swagger.yaml +714 -0
  77. data/lib/lab/engine.rb +13 -0
  78. data/lib/lab/version.rb +5 -0
  79. data/lib/logger_multiplexor.rb +38 -0
  80. data/lib/mahis_emr_api_lab.rb +6 -0
  81. data/lib/tasks/lab_tasks.rake +25 -0
  82. data/lib/tasks/loaders/data/reasons-for-test.csv +7 -0
  83. data/lib/tasks/loaders/data/test-measures.csv +225 -0
  84. data/lib/tasks/loaders/data/tests.csv +161 -0
  85. data/lib/tasks/loaders/loader_mixin.rb +53 -0
  86. data/lib/tasks/loaders/metadata_loader.rb +26 -0
  87. data/lib/tasks/loaders/reasons_for_test_loader.rb +23 -0
  88. data/lib/tasks/loaders/specimens_loader.rb +65 -0
  89. data/lib/tasks/loaders/test_result_indicators_loader.rb +54 -0
  90. metadata +331 -0
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+ require_relative './loader_mixin'
5
+
6
+ module Lab
7
+ module Loaders
8
+ ##
9
+ # Load specimens and their tests into the database
10
+ module TestResultIndicatorsLoader
11
+ class << self
12
+ include LoaderMixin
13
+
14
+ def load
15
+ puts "------- Loading measures ------------"
16
+ CSV.open(data_path('test-measures.csv'), headers: :first_row) do |csv|
17
+ csv.each_with_object({}) do |row, test_measures|
18
+ test_name = row['test_name']
19
+ measure_name = row['measure_name']
20
+
21
+ ActiveRecord::Base.transaction do
22
+ measure_concept = find_or_create_concept(measure_name)
23
+ add_measure_to_test(test_name, measure_concept)
24
+ end
25
+
26
+ puts "Created measure #{test_name} <--< #{measure_name}"
27
+ rescue StandardError => e
28
+ puts "Error: #{measure_name}: #{e}"
29
+ end
30
+ end
31
+ end
32
+
33
+ def create_test_type(name)
34
+ concept_id = find_or_create_concept(name, is_set: true).concept_id
35
+
36
+ create_concept_set(concept_set: test_type_concept_id, concept_id: concept_id)
37
+ rescue StandardError => e
38
+ raise "Failed to create test type `#{name}`: #{e}"
39
+ end
40
+
41
+ def add_measure_to_test(test_name, measure_concept)
42
+ [
43
+ add_concept_to_set(set_concept_id: find_or_create_concept(Lab::Metadata::TEST_RESULT_INDICATOR_CONCEPT_NAME).concept_id,
44
+ concept_id: measure_concept.concept_id),
45
+ add_concept_to_set(set_concept_id: measure_concept.concept_id,
46
+ concept_id: find_or_create_concept(test_name).concept_id)
47
+ ]
48
+ rescue StandardError => e
49
+ raise "Failed to create measure for test `#{name}`: #{e}"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,331 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mahis_emr_api_lab
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Elizabeth Glaser Pediatric Foundation Malawi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: couchrest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: parallel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: socket.io-client-simple
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bcrypt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_bot_rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 6.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 6.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: faker
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.16.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.16.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 5.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 5.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rswag-api
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 2.4.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 2.4.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rswag-specs
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 2.4.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 2.4.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rswag-ui
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.4.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.4.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.79.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.79.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 1.41.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 1.41.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: shoulda-matchers
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 4.5.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 4.5.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: sqlite3
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 1.4.0
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 1.4.0
209
+ description: |
210
+ This adds a lab interface to the OpenMRS compatible core API provided by
211
+ [HIS-EMR-API](https://github.com/EGPAFMalawiHIS/HIS-EMR-API).
212
+ email:
213
+ - emrdevelopersmalawi@pedaids.org
214
+ executables: []
215
+ extensions: []
216
+ extra_rdoc_files: []
217
+ files:
218
+ - MIT-LICENSE
219
+ - README.md
220
+ - Rakefile
221
+ - app/controllers/lab/application_controller.rb
222
+ - app/controllers/lab/labels_controller.rb
223
+ - app/controllers/lab/orders_controller.rb
224
+ - app/controllers/lab/reasons_for_test_controller.rb
225
+ - app/controllers/lab/results_controller.rb
226
+ - app/controllers/lab/specimen_types_controller.rb
227
+ - app/controllers/lab/test_result_indicators_controller.rb
228
+ - app/controllers/lab/test_types_controller.rb
229
+ - app/controllers/lab/tests_controller.rb
230
+ - app/controllers/lab/users_controller.rb
231
+ - app/jobs/lab/application_job.rb
232
+ - app/jobs/lab/push_order_job.rb
233
+ - app/jobs/lab/update_patient_orders_job.rb
234
+ - app/jobs/lab/void_order_job.rb
235
+ - app/mailers/lab/application_mailer.rb
236
+ - app/models/lab/application_record.rb
237
+ - app/models/lab/lab_accession_number_counter.rb
238
+ - app/models/lab/lab_acknowledgement.rb
239
+ - app/models/lab/lab_encounter.rb
240
+ - app/models/lab/lab_order.rb
241
+ - app/models/lab/lab_result.rb
242
+ - app/models/lab/lab_test.rb
243
+ - app/models/lab/lims_failed_import.rb
244
+ - app/models/lab/lims_order_mapping.rb
245
+ - app/models/lab/order_extension.rb
246
+ - app/serializers/lab/lab_order_serializer.rb
247
+ - app/serializers/lab/result_serializer.rb
248
+ - app/serializers/lab/test_serializer.rb
249
+ - app/services/lab/accession_number_service.rb
250
+ - app/services/lab/acknowledgement_service.rb
251
+ - app/services/lab/concepts_service.rb
252
+ - app/services/lab/json_web_token_service.rb
253
+ - app/services/lab/labelling_service/order_label.rb
254
+ - app/services/lab/lims/acknowledgement_serializer.rb
255
+ - app/services/lab/lims/acknowledgement_worker.rb
256
+ - app/services/lab/lims/api/blackhole_api.rb
257
+ - app/services/lab/lims/api/couchdb_api.rb
258
+ - app/services/lab/lims/api/mysql_api.rb
259
+ - app/services/lab/lims/api/rest_api.rb
260
+ - app/services/lab/lims/api/ws_api.rb
261
+ - app/services/lab/lims/api_factory.rb
262
+ - app/services/lab/lims/config.rb
263
+ - app/services/lab/lims/exceptions.rb
264
+ - app/services/lab/lims/migrator.rb
265
+ - app/services/lab/lims/order_dto.rb
266
+ - app/services/lab/lims/order_serializer.rb
267
+ - app/services/lab/lims/pull_worker.rb
268
+ - app/services/lab/lims/push_worker.rb
269
+ - app/services/lab/lims/utils.rb
270
+ - app/services/lab/lims/worker.rb
271
+ - app/services/lab/metadata.rb
272
+ - app/services/lab/notification_service.rb
273
+ - app/services/lab/orders_search_service.rb
274
+ - app/services/lab/orders_service.rb
275
+ - app/services/lab/results_service.rb
276
+ - app/services/lab/tests_service.rb
277
+ - app/services/lab/user_service.rb
278
+ - config/routes.rb
279
+ - db/migrate/20210126092910_create_lab_lab_accession_number_counters.rb
280
+ - db/migrate/20210310115457_create_lab_lims_order_mappings.rb
281
+ - db/migrate/20210323080140_change_lims_id_to_string_in_lims_order_mapping.rb
282
+ - db/migrate/20210326195504_add_order_revision_to_lims_order_mapping.rb
283
+ - db/migrate/20210407071728_create_lab_lims_failed_imports.rb
284
+ - db/migrate/20210610095024_fix_numeric_results_value_type.rb
285
+ - db/migrate/20210807111531_add_default_to_lims_order_mapping.rb
286
+ - lib/auto12epl.rb
287
+ - lib/couch_bum/couch_bum.rb
288
+ - lib/generators/lab/install/USAGE
289
+ - lib/generators/lab/install/install_generator.rb
290
+ - lib/generators/lab/install/templates/rswag-ui-lab.rb
291
+ - lib/generators/lab/install/templates/start_worker.rb
292
+ - lib/generators/lab/install/templates/swagger.yaml
293
+ - lib/lab/engine.rb
294
+ - lib/lab/version.rb
295
+ - lib/logger_multiplexor.rb
296
+ - lib/mahis_emr_api_lab.rb
297
+ - lib/tasks/lab_tasks.rake
298
+ - lib/tasks/loaders/data/reasons-for-test.csv
299
+ - lib/tasks/loaders/data/test-measures.csv
300
+ - lib/tasks/loaders/data/tests.csv
301
+ - lib/tasks/loaders/loader_mixin.rb
302
+ - lib/tasks/loaders/metadata_loader.rb
303
+ - lib/tasks/loaders/reasons_for_test_loader.rb
304
+ - lib/tasks/loaders/specimens_loader.rb
305
+ - lib/tasks/loaders/test_result_indicators_loader.rb
306
+ homepage: https://github.com/EGPAFMalawiHIS/mahis_emr_api_lab
307
+ licenses:
308
+ - MIT
309
+ metadata:
310
+ source_code_uri: https://github.com/EGPAFMalawiHIS/mahis_emr_api_lab
311
+ post_install_message:
312
+ rdoc_options: []
313
+ require_paths:
314
+ - lib
315
+ required_ruby_version: !ruby/object:Gem::Requirement
316
+ requirements:
317
+ - - ">="
318
+ - !ruby/object:Gem::Version
319
+ version: '0'
320
+ required_rubygems_version: !ruby/object:Gem::Requirement
321
+ requirements:
322
+ - - ">="
323
+ - !ruby/object:Gem::Version
324
+ version: '0'
325
+ requirements: []
326
+ rubyforge_project:
327
+ rubygems_version: 2.7.6
328
+ signing_key:
329
+ specification_version: 4
330
+ summary: Lab extension for the HIS-EMR-API
331
+ test_files: []