his_emr_api_radiology 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c6576d07080687e0df1b25241687622a81da1f30f26d0a467e89e08b81db0c60
4
+ data.tar.gz: 484cfc967233e854a8a8f2b69a2c16fa3a83d4808f004064393e4135c3f0e55e
5
+ SHA512:
6
+ metadata.gz: ec2834a0dea01ca698e2ae3946e159f890c1fd9c204cdb7182cff23fd62cb6bc6fc59ba7b6ee1eb2af50200c7805ccf6b39d96d6205278a2605de8c8ab8034fe
7
+ data.tar.gz: d38e52206f9853f1d2c5a9b17f816fabef3df40fdac307c31b233eb5b32c9cab1c59b4ef928e59b30857f635fc77255a0f761bcd995b35b60b20720834b81d75
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 petros
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # his_emr_api_radiology
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'his_emr_api_radiology'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install his_emr_api_radiology
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1,4 @@
1
+ module Radiology
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Radiology
4
+ class LabelsController < ApplicationController
5
+ skip_before_action :authenticate
6
+
7
+ def print_order_label
8
+ label = service.print_radiology_barcode(params[:accession_number],params[:patient_national_id], params[:patient_name], params[:radio_order], params[:date_created])
9
+ send_data(label.print, type: 'application/label; charset=utf-8',
10
+ stream: false,
11
+ filename: "#{SecureRandom.hex(24)}.lbl",
12
+ disposition: 'inline')
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ class Radiology::RadiologyController < ::ApplicationController
3
+ def create
4
+ patient_details, physician_details, radiology_orders = params.require %i[patient_details physician_details radiology_orders]
5
+ radiology_orders = service.generate_msi(patient_details,physician_details, radiology_orders)
6
+ render json: radiology_orders, status: :created
7
+ end
8
+
9
+ def service
10
+ Radiology::RadiologyService
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'json'
2
+ class Radiology::RadiologyPropertiesController < ::ApplicationController
3
+ def create(success_response_status: :created)
4
+ path, value = params.require %i[path property_value]
5
+
6
+ file = File.read path
7
+ hash = JSON.parse file
8
+ if value == 'true'
9
+ hash['encounters']['radiology orders']['available'] = true
10
+ hash['encounters']['view radiology results']['available'] = true
11
+ else
12
+ hash['encounters']['radiology orders']['available'] = false
13
+ hash['encounters']['view radiology results']['available'] = false
14
+ end
15
+ File.open path , "w" do |f|
16
+ f.puts JSON.pretty_generate hash
17
+ end
18
+ render json: value, status: success_response_status
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ module Radiology
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Radiology
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Radiology
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Radiology
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ require "net/ftp"
3
+ module Radiology
4
+ module RadiologyService
5
+ class << self
6
+
7
+ def generate_msi(patient_details,physician_details, radiology_orders)
8
+ orders =''
9
+ radiology_orders.each do |order|
10
+ if orders != ''
11
+ orders = "#{order[:sub_value_text].gsub(' ', '_')} , #{orders}"
12
+ else
13
+ orders = order[:sub_value_text].gsub(' ', '_')
14
+ end
15
+ end
16
+
17
+
18
+ sample_file_path = "/var/www/BHT-EMR-API/config/sample.msi"
19
+ save_file_path = "/tmp/#{patient_details[:accession_number] }_#{patient_details[:patient_name].gsub(' ', '_')}_scheduled_radiology.msi"
20
+
21
+ # using eval() might decrease performance, not sure if there's a better way to do this.
22
+ msi_file_data = eval(File.read(sample_file_path))
23
+
24
+ File.open(save_file_path, "w+") do |f|
25
+ f.write(msi_file_data)
26
+ end
27
+ send_scheduled_msi("#{save_file_path}")
28
+ end
29
+
30
+ # send created msi file to ftp server
31
+ def send_scheduled_msi(file_path)
32
+ main_config = YAML.load_file('/var/www/BHT-EMR-API/config/application.yml')
33
+ # connect with FTP server
34
+ # NOTE: main_config[:ftp_host], main_config[:ftp_user_name], main_config[:ftp_pw] is in application.yml file.
35
+ Net::FTP.open(main_config['ftp_host']) do |ftp|
36
+ ftp.passive = true
37
+ ftp.login(main_config['ftp_user_name'], main_config['ftp_pw'])
38
+ ftp.putbinaryfile(file_path)
39
+ end
40
+ end
41
+
42
+ def print_radiology_barcode(accession_number,patient_national_id_with_dashes, patient_name, radio_order,date_created)
43
+ label = 'label' + 0.to_s
44
+ label = ZebraPrinter::Label.new(500,165)
45
+ label.font_size = 2
46
+ label.font_horizontal_multiplier = 1
47
+ label.font_vertical_multiplier = 1
48
+ label.left_margin = 300
49
+ label.draw_barcode(50,105,0,1,4,8,50,false,"#{accession_number}")
50
+ label.draw_multi_text("#{patient_name} #{patient_national_id_with_dashes}")
51
+ label.draw_multi_text("x-ray, #{radio_order.name.downcase rescue nil} - #{accession_number rescue nil}")
52
+ label.draw_multi_text("#{date_created}")
53
+
54
+ label.print(1)
55
+ end
56
+ end
57
+ end
58
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Radiology::Engine.routes.draw do
2
+ resources :radiology, path: 'api/v1/radiology'
3
+ resources :radiology_properties, path: 'api/v1/radiology_properties'
4
+
5
+ get '/api/v1/radiology/barcode', to: 'labels#print_order_label'
6
+
7
+ end
@@ -0,0 +1,6 @@
1
+ require "radiology/version"
2
+ require "radiology/engine"
3
+
4
+ module Radiology
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,15 @@
1
+ if Rails.env == 'test'
2
+ require 'rswag/ui'
3
+ require 'rswag/api'
4
+ end
5
+
6
+ module Radiology
7
+ class Engine < ::Rails::Engine
8
+ isolate_namespace Radiology
9
+ config.generators.api_only = true
10
+
11
+ config.generators do |g|
12
+ g.test_framework :rspec
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Radiology
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :radiology do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,257 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: his_emr_api_radiology
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - petros
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 5.2.4
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 5.2.4.3
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 5.2.4
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.2.4.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: bcrypt
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 3.1.0
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 3.1.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: factory_bot_rails
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: 6.1.0
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: 6.1.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: faker
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: 2.16.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: 2.16.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec-rails
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 5.0.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 5.0.0
109
+ - !ruby/object:Gem::Dependency
110
+ name: rswag-api
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 2.4.0
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: 2.4.0
123
+ - !ruby/object:Gem::Dependency
124
+ name: rswag-specs
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 2.4.0
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 2.4.0
137
+ - !ruby/object:Gem::Dependency
138
+ name: rswag-ui
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: 2.4.0
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: 2.4.0
151
+ - !ruby/object:Gem::Dependency
152
+ name: rubocop
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: 0.79.0
158
+ type: :development
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: 0.79.0
165
+ - !ruby/object:Gem::Dependency
166
+ name: rubocop-rspec
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: 1.41.0
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
177
+ - !ruby/object:Gem::Version
178
+ version: 1.41.0
179
+ - !ruby/object:Gem::Dependency
180
+ name: shoulda-matchers
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - "~>"
184
+ - !ruby/object:Gem::Version
185
+ version: 4.5.0
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - "~>"
191
+ - !ruby/object:Gem::Version
192
+ version: 4.5.0
193
+ - !ruby/object:Gem::Dependency
194
+ name: sqlite3
195
+ requirement: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: 1.4.0
200
+ type: :development
201
+ prerelease: false
202
+ version_requirements: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: 1.4.0
207
+ description: |-
208
+ This adds a radiology interface to the OpenMRS compatible core API provided by
209
+ [HIS-EMR-API](https://github.com/EGPAFMalawiHIS/HIS-EMR-API).
210
+ email:
211
+ - kayangepetros@gmail.com
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files: []
215
+ files:
216
+ - MIT-LICENSE
217
+ - README.md
218
+ - Rakefile
219
+ - app/controllers/radiology/application_controller.rb
220
+ - app/controllers/radiology/labels_controller.rb
221
+ - app/controllers/radiology/radiology_controller.rb
222
+ - app/controllers/radiology/radiology_properties_controller.rb
223
+ - app/helpers/radiology/application_helper.rb
224
+ - app/jobs/radiology/application_job.rb
225
+ - app/mailers/radiology/application_mailer.rb
226
+ - app/models/radiology/application_record.rb
227
+ - app/services/radiology/radiology_service.rb
228
+ - config/routes.rb
229
+ - lib/his_emr_api_radiology.rb
230
+ - lib/radiology/engine.rb
231
+ - lib/radiology/version.rb
232
+ - lib/tasks/radiology_tasks.rake
233
+ homepage: https://github.com/petroskayange/his_emr_api_radiology
234
+ licenses:
235
+ - MIT
236
+ metadata:
237
+ homepage_uri: https://github.com/petroskayange/his_emr_api_radiology
238
+ post_install_message:
239
+ rdoc_options: []
240
+ require_paths:
241
+ - lib
242
+ required_ruby_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ requirements: []
253
+ rubygems_version: 3.2.16
254
+ signing_key:
255
+ specification_version: 4
256
+ summary: Radiology extension for the HIS-EMR-API
257
+ test_files: []