pvdgm_services 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +29 -0
  3. data/Rakefile +40 -0
  4. data/app/contexts/services/accept_hl7_message_context.rb +32 -0
  5. data/app/contexts/services/application_mds_context.rb +21 -0
  6. data/app/contexts/services/complete_sltc_registration_process_context.rb +23 -0
  7. data/app/contexts/services/create_account_mapping_context.rb +23 -0
  8. data/app/contexts/services/create_configured_account_context.rb +26 -0
  9. data/app/contexts/services/create_configured_facility_context.rb +26 -0
  10. data/app/contexts/services/create_credential_context.rb +23 -0
  11. data/app/contexts/services/create_facility_mapping_context.rb +23 -0
  12. data/app/contexts/services/create_public_key_context.rb +22 -0
  13. data/app/contexts/services/create_service_context.rb +22 -0
  14. data/app/contexts/services/create_service_definition_context.rb +26 -0
  15. data/app/contexts/services/create_sltc_registration_context.rb +24 -0
  16. data/app/contexts/services/create_third_party_context.rb +22 -0
  17. data/app/contexts/services/hl7_message_trimming_context.rb +19 -0
  18. data/app/contexts/services/invoke_service_context.rb +21 -0
  19. data/app/contexts/services/list_sltc_providers_context.rb +22 -0
  20. data/app/contexts/services/mds_file_processing_context.rb +27 -0
  21. data/app/contexts/services/mds_file_upload_context.rb +25 -0
  22. data/app/contexts/services/mds_pull_context.rb +21 -0
  23. data/app/contexts/services/monthly_service_table_cleanup_context.rb +19 -0
  24. data/app/contexts/services/notify_new_registration_context.rb +22 -0
  25. data/app/contexts/services/notify_sltc_provider_change_context.rb +19 -0
  26. data/app/contexts/services/request_sltc_baseline_context.rb +23 -0
  27. data/app/contexts/services/update_account_mapping_context.rb +23 -0
  28. data/app/contexts/services/update_configured_account_context.rb +26 -0
  29. data/app/contexts/services/update_configured_facility_context.rb +26 -0
  30. data/app/contexts/services/update_credential_context.rb +23 -0
  31. data/app/contexts/services/update_facility_mapping_context.rb +23 -0
  32. data/app/contexts/services/update_public_key_context.rb +23 -0
  33. data/app/contexts/services/update_service_context.rb +23 -0
  34. data/app/contexts/services/update_service_definition_context.rb +26 -0
  35. data/app/contexts/services/update_third_party_context.rb +23 -0
  36. data/app/controllers/services/account_mappings_controller.rb +54 -0
  37. data/app/controllers/services/adts_controller.rb +35 -0
  38. data/app/controllers/services/application_controller.rb +17 -0
  39. data/app/controllers/services/assessment_requests_controller.rb +48 -0
  40. data/app/controllers/services/available_files_controller.rb +19 -0
  41. data/app/controllers/services/configured_account_base_controller.rb +17 -0
  42. data/app/controllers/services/configured_accounts_controller.rb +59 -0
  43. data/app/controllers/services/configured_facilities_controller.rb +65 -0
  44. data/app/controllers/services/facility_mappings_controller.rb +58 -0
  45. data/app/controllers/services/mds_files_controller.rb +75 -0
  46. data/app/controllers/services/mds_pull_accounts_controller.rb +57 -0
  47. data/app/controllers/services/public_keys_controller.rb +50 -0
  48. data/app/controllers/services/service_base_controller.rb +18 -0
  49. data/app/controllers/services/service_definition_base_controller.rb +31 -0
  50. data/app/controllers/services/service_definitions_controller.rb +59 -0
  51. data/app/controllers/services/services_controller.rb +56 -0
  52. data/app/controllers/services/sltc_providers_controller.rb +15 -0
  53. data/app/controllers/services/sltc_registrations_controller.rb +74 -0
  54. data/app/controllers/services/status_masking.rb +17 -0
  55. data/app/controllers/services/third_parties_controller.rb +47 -0
  56. data/app/controllers/services/third_party_base_controller.rb +17 -0
  57. data/app/controllers/services/validation_controller.rb +17 -0
  58. data/app/helpers/services/application_helper.rb +8 -0
  59. data/app/helpers/services/assessment_request_helper.rb +19 -0
  60. data/app/helpers/services/available_files_helper.rb +27 -0
  61. data/app/helpers/services/mds_pull_accounts_helper.rb +27 -0
  62. data/app/helpers/services/sltc_registrations_helper.rb +15 -0
  63. data/app/mailers/services_mailer.rb +57 -0
  64. data/app/models/services/abaqis_mds_push.rb +51 -0
  65. data/app/models/services/account_mapping.rb +10 -0
  66. data/app/models/services/application_api.rb +19 -0
  67. data/app/models/services/assessment_request.rb +18 -0
  68. data/app/models/services/available_file.rb +73 -0
  69. data/app/models/services/configured_account.rb +26 -0
  70. data/app/models/services/configured_facility.rb +16 -0
  71. data/app/models/services/credential.rb +9 -0
  72. data/app/models/services/facility_mapping.rb +12 -0
  73. data/app/models/services/ftp_server.rb +69 -0
  74. data/app/models/services/hl7_inbound_service.rb +47 -0
  75. data/app/models/services/hl7_message.rb +27 -0
  76. data/app/models/services/isc_code.rb +15 -0
  77. data/app/models/services/isc_code_lookup.rb +75 -0
  78. data/app/models/services/mds_assessment.rb +371 -0
  79. data/app/models/services/mds_content.rb +55 -0
  80. data/app/models/services/mds_pull.rb +41 -0
  81. data/app/models/services/mds_pull_account.rb +192 -0
  82. data/app/models/services/mds_push.rb +24 -0
  83. data/app/models/services/mds_upload.rb +64 -0
  84. data/app/models/services/mds_upload_content.rb +148 -0
  85. data/app/models/services/mds_ws_response.rb +21 -0
  86. data/app/models/services/mds_ws_response_handler.rb +31 -0
  87. data/app/models/services/pcc_mds_pull.rb +77 -0
  88. data/app/models/services/provider_change.rb +26 -0
  89. data/app/models/services/public_key.rb +11 -0
  90. data/app/models/services/service.rb +20 -0
  91. data/app/models/services/service_definition.rb +37 -0
  92. data/app/models/services/service_implementation.rb +29 -0
  93. data/app/models/services/sltc_api.rb +179 -0
  94. data/app/models/services/sltc_api_exception.rb +54 -0
  95. data/app/models/services/sltc_mds_pull.rb +230 -0
  96. data/app/models/services/sltc_registration.rb +23 -0
  97. data/app/models/services/third_party.rb +18 -0
  98. data/app/roles/services/account_mapping_creator.rb +13 -0
  99. data/app/roles/services/account_mapping_updator.rb +12 -0
  100. data/app/roles/services/configured_account_creator.rb +13 -0
  101. data/app/roles/services/configured_account_updater.rb +12 -0
  102. data/app/roles/services/configured_facility_creator.rb +13 -0
  103. data/app/roles/services/configured_facility_updater.rb +12 -0
  104. data/app/roles/services/credential_creator.rb +11 -0
  105. data/app/roles/services/credential_updater.rb +20 -0
  106. data/app/roles/services/facility_mapping_creator.rb +13 -0
  107. data/app/roles/services/facility_mapping_updater.rb +11 -0
  108. data/app/roles/services/hl7_adt_message_saver.rb +15 -0
  109. data/app/roles/services/hl7_message_trimmer.rb +14 -0
  110. data/app/roles/services/mds_assessment_categorizer.rb +71 -0
  111. data/app/roles/services/mds_file_processor.rb +86 -0
  112. data/app/roles/services/mds_notifications.rb +44 -0
  113. data/app/roles/services/monthly_service_table_cleaner.rb +19 -0
  114. data/app/roles/services/new_registration_notifier.rb +11 -0
  115. data/app/roles/services/public_key_creator.rb +14 -0
  116. data/app/roles/services/public_key_updater.rb +12 -0
  117. data/app/roles/services/service_creator.rb +13 -0
  118. data/app/roles/services/service_definition_creator.rb +13 -0
  119. data/app/roles/services/service_definition_updater.rb +12 -0
  120. data/app/roles/services/service_invoker.rb +25 -0
  121. data/app/roles/services/service_updater.rb +11 -0
  122. data/app/roles/services/sltc_baseline_requestor.rb +19 -0
  123. data/app/roles/services/sltc_provider_change_notifier.rb +25 -0
  124. data/app/roles/services/sltc_provider_lister.rb +13 -0
  125. data/app/roles/services/sltc_registration_completer.rb +81 -0
  126. data/app/roles/services/sltc_registration_saver.rb +13 -0
  127. data/app/roles/services/submit_mds_file_for_processing.rb +28 -0
  128. data/app/roles/services/third_party_creator.rb +13 -0
  129. data/app/roles/services/third_party_updater.rb +12 -0
  130. data/app/utils/services/file_upload_handler.rb +33 -0
  131. data/app/utils/services/mds_upload_filters.rb +26 -0
  132. data/app/utils/services/mds_xml_file_parser.rb +104 -0
  133. data/app/utils/services/upload_file.rb +13 -0
  134. data/app/validators/isc_code_validator.rb +42 -0
  135. data/app/validators/mds_birthdate_validator.rb +37 -0
  136. data/app/validators/mds_date_validator.rb +8 -0
  137. data/app/validators/mds_integer_validator.rb +15 -0
  138. data/app/validators/mds_version_validator.rb +16 -0
  139. data/app/validators/state_code_validator.rb +9 -0
  140. data/app/views/layouts/services/application.html.erb +14 -0
  141. data/app/views/services/account_mappings/index.json.jbuilder +9 -0
  142. data/app/views/services/account_mappings/show.json.jbuilder +7 -0
  143. data/app/views/services/assessment_requests/index.json.jbuilder +11 -0
  144. data/app/views/services/available_files/index.json.jbuilder +13 -0
  145. data/app/views/services/configured_accounts/index.json.jbuilder +13 -0
  146. data/app/views/services/configured_accounts/show.json.jbuilder +11 -0
  147. data/app/views/services/configured_facilities/index.json.jbuilder +13 -0
  148. data/app/views/services/configured_facilities/show.json.jbuilder +11 -0
  149. data/app/views/services/facility_mappings/index.json.jbuilder +10 -0
  150. data/app/views/services/facility_mappings/show.json.jbuilder +8 -0
  151. data/app/views/services/mds_files/create.builder +10 -0
  152. data/app/views/services/mds_pull_accounts/index.json.jbuilder +11 -0
  153. data/app/views/services/public_keys/index.json.jbuilder +8 -0
  154. data/app/views/services/public_keys/show.json.jbuilder +6 -0
  155. data/app/views/services/service_definitions/index.json.jbuilder +17 -0
  156. data/app/views/services/service_definitions/show.json.jbuilder +16 -0
  157. data/app/views/services/services/index.json.jbuilder +6 -0
  158. data/app/views/services/services/show.json.jbuilder +4 -0
  159. data/app/views/services/sltc_providers/index.json.jbuilder +10 -0
  160. data/app/views/services/sltc_registrations/index.json.jbuilder +10 -0
  161. data/app/views/services/third_parties/index.json.jbuilder +7 -0
  162. data/app/views/services/third_parties/show.json.jbuilder +5 -0
  163. data/app/views/services_mailer/burying_job.html.erb +20 -0
  164. data/app/views/services_mailer/delaying_job.html.erb +20 -0
  165. data/app/views/services_mailer/notify_sltc_client_registration.html.erb +39 -0
  166. data/app/views/services_mailer/notify_sltc_client_registration_invalid_request_type.html.erb +8 -0
  167. data/app/views/services_mailer/notify_sltc_client_registration_request_invalid.html.erb +10 -0
  168. data/app/views/services_mailer/notify_sltc_client_registration_validation_errors.html.erb +13 -0
  169. data/app/views/services_mailer/notify_sltc_provider_changes.html.erb +26 -0
  170. data/app/views/services_mailer/notify_support_about_no_mds_pull.html.erb +6 -0
  171. data/config/routes.rb +48 -0
  172. data/db/migrate/20140102000000_create_services_engine_tables.rb +131 -0
  173. data/db/migrate/20140517184450_new_services_columns.rb +24 -0
  174. data/db/migrate/20140525142842_new_configured_provider_table.rb +18 -0
  175. data/db/migrate/20140714172442_add_error_column_to_hl7_messages.rb +5 -0
  176. data/db/migrate/20140730164152_mds_upload_tables.rb +78 -0
  177. data/db/sql_data/service_data_setup.sql +24 -0
  178. data/lib/services/engine.rb +40 -0
  179. data/lib/services/version.rb +3 -0
  180. data/lib/services.rb +4 -0
  181. data/lib/tasks/services_tasks.rake +40 -0
  182. data/spec/dummy/README.rdoc +261 -0
  183. data/spec/dummy/Rakefile +7 -0
  184. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  185. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  186. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  187. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  188. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  189. data/spec/dummy/config/application.rb +60 -0
  190. data/spec/dummy/config/boot.rb +10 -0
  191. data/spec/dummy/config/database.yml +29 -0
  192. data/spec/dummy/config/environment.rb +5 -0
  193. data/spec/dummy/config/environments/development.rb +35 -0
  194. data/spec/dummy/config/environments/production.rb +68 -0
  195. data/spec/dummy/config/environments/test.rb +32 -0
  196. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  197. data/spec/dummy/config/initializers/email.rb +1 -0
  198. data/spec/dummy/config/initializers/inflections.rb +15 -0
  199. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  200. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  201. data/spec/dummy/config/initializers/session_store.rb +8 -0
  202. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  203. data/spec/dummy/config/locales/en.yml +5 -0
  204. data/spec/dummy/config/routes.rb +4 -0
  205. data/spec/dummy/config.ru +4 -0
  206. data/spec/dummy/db/schema.rb +237 -0
  207. data/spec/dummy/db/sql_data/services_isc_codes.sql +878 -0
  208. data/spec/dummy/log/test.log +3498 -0
  209. data/spec/dummy/public/404.html +26 -0
  210. data/spec/dummy/public/422.html +26 -0
  211. data/spec/dummy/public/500.html +25 -0
  212. data/spec/dummy/public/favicon.ico +0 -0
  213. data/spec/dummy/script/rails +6 -0
  214. data/spec/models/abaqis_mds_push_spec.rb +120 -0
  215. data/spec/models/available_file_spec.rb +234 -0
  216. data/spec/models/configured_account_spec.rb +39 -0
  217. data/spec/models/ftp_server_spec.rb +221 -0
  218. data/spec/models/isc_code_lookup_spec.rb +125 -0
  219. data/spec/models/isc_code_spec.rb +5 -0
  220. data/spec/models/mds_assessment_spec.rb +1070 -0
  221. data/spec/models/mds_pull_account_spec.rb +468 -0
  222. data/spec/models/mds_pull_spec.rb +48 -0
  223. data/spec/models/mds_push_spec.rb +43 -0
  224. data/spec/models/mds_ws_response_spec.rb +54 -0
  225. data/spec/models/pcc_mds_pull_spec.rb +273 -0
  226. data/spec/models/service_implementation_spec.rb +88 -0
  227. data/spec/models/sltc_api_exception_spec.rb +136 -0
  228. data/spec/models/sltc_api_spec.rb +192 -0
  229. data/spec/models/sltc_mds_pull_spec.rb +776 -0
  230. data/spec/roles/account_mapping_creator_spec.rb +40 -0
  231. data/spec/roles/account_mapping_updator_spec.rb +16 -0
  232. data/spec/roles/configured_account_creator_spec.rb +40 -0
  233. data/spec/roles/configured_account_updater_spec.rb +16 -0
  234. data/spec/roles/configured_facility_creator_spec.rb +40 -0
  235. data/spec/roles/configured_facility_updater_spec.rb +16 -0
  236. data/spec/roles/credential_creator_spec.rb +23 -0
  237. data/spec/roles/credential_updater_spec.rb +38 -0
  238. data/spec/roles/facility_mapping_creator_spec.rb +40 -0
  239. data/spec/roles/facility_mapping_updater_spec.rb +16 -0
  240. data/spec/roles/hl7_adt_message_saver_spec.rb +35 -0
  241. data/spec/roles/hl7_message_trimmer_spec.rb +31 -0
  242. data/spec/roles/monthly_service_table_cleaner_spec.rb +27 -0
  243. data/spec/roles/new_registration_notifier_spec.rb +18 -0
  244. data/spec/roles/service_ceator_spec.rb +34 -0
  245. data/spec/roles/service_definition_creator_spec.rb +40 -0
  246. data/spec/roles/service_definition_updater_spec.rb +16 -0
  247. data/spec/roles/service_invoker_spec.rb +22 -0
  248. data/spec/roles/service_updater_spec.rb +17 -0
  249. data/spec/roles/sltc_baseline_requestor_spec.rb +30 -0
  250. data/spec/roles/sltc_provider_lister_spec.rb +27 -0
  251. data/spec/roles/sltc_registration_completer_spec.rb +187 -0
  252. data/spec/roles/sltc_registration_saver_spec.rb +34 -0
  253. data/spec/roles/third_party_creator_spec.rb +34 -0
  254. data/spec/roles/third_party_updater_spec.rb +17 -0
  255. data/spec/spec_helper.rb +72 -0
  256. metadata +581 -0
@@ -0,0 +1,15 @@
1
+ class MdsIntegerValidator < ActiveModel::EachValidator
2
+
3
+ def validate_each(record, attribute, value)
4
+ return true if record.send("clean_#{attribute}").blank?
5
+ record.errors[attribute] << options[:message] unless valid_value?(value)
6
+ end
7
+
8
+ private
9
+
10
+ def valid_value?(height)
11
+ char = height =~ /\D/
12
+ return false if char && height[char] != "."
13
+ height.to_i >= options[:minimum] && height.to_i <= options[:maximum]
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ class MdsVersionValidator < ActiveModel::EachValidator
2
+
3
+ def validate_each(record, attribute, value)
4
+ record.errors[attribute] << "This assessment has the wrong version of items according to the target date of #{record.reference_date.to_s}." unless valid_version?(record, value)
5
+ end
6
+
7
+ private
8
+
9
+ def valid_version?(record, version)
10
+ return false if version.blank?
11
+ return true if version == Services::MdsAssessment::VERSION1_0 && record.x0100.present?
12
+ return true if version == Services::MdsAssessment::VERSION1_1 && record.a0050.present?
13
+ return false
14
+ end
15
+
16
+ end
@@ -0,0 +1,9 @@
1
+ class StateCodeValidator < ActiveModel::EachValidator
2
+
3
+ STATE_CODES = %w{ AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA PR RI SC SD TN TX UT VT VA VI WA WV WI WY }
4
+
5
+ def validate_each(record, attribute, value)
6
+ record.errors[attribute] << "Invalid state code entered in the field #{attribute}. The value '#{value}' is not valid." unless value.blank? || STATE_CODES.include?(value)
7
+ end
8
+
9
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Services</title>
5
+ <%= stylesheet_link_tag "services/application", :media => "all" %>
6
+ <%= javascript_include_tag "services/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+ json.array!(@account_mappings) do | account_mapping |
3
+ json.id account_mapping.id
4
+ json.third_party_id account_mapping.third_party_id
5
+ json.third_party_name account_mapping.third_party.name
6
+ json.account_id account_mapping.account_id
7
+ json.account_name account_mapping.account.organization
8
+ json.account_code account_mapping.account_code
9
+ end
@@ -0,0 +1,7 @@
1
+ # -*- ruby -*-
2
+ json.id @account_mapping.id
3
+ json.third_party_id @account_mapping.third_party_id
4
+ json.third_party_name @account_mapping.third_party.name
5
+ json.account_id @account_mapping.account_id
6
+ json.account_name @account_mapping.account.organization
7
+ json.account_code @account_mapping.account_code
@@ -0,0 +1,11 @@
1
+ # -*- ruby -*-
2
+ json.array!(@assessment_requests) do | assessment_request |
3
+ json.id assessment_request.id
4
+ json.facility_code assessment_request.facility_code
5
+ json.request_id assessment_request.request_id
6
+ json.pull_from assessment_request.pull_from
7
+ json.pull_to assessment_request.pull_to
8
+ json.status assessment_request_status(assessment_request.status)
9
+ json.created_at assessment_request.created_at
10
+ json.updated_at assessment_request.updated_at
11
+ end
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+ json.array!(@available_files) do | available_file |
3
+ json.id available_file.id
4
+ json.configured_account_id available_file.configured_account_id
5
+ json.request_id available_file.request_id
6
+ json.filename available_file.filename
7
+ json.status available_file_status(available_file.status)
8
+ json.downloaded_at available_file.downloaded_at
9
+ json.composite_file_name available_file.composite_file_name
10
+ json.error available_file.error
11
+ json.created_at available_file.created_at
12
+ json.updated_at available_file.updated_at
13
+ end
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+ json.array!(@configured_accounts) do | configured_account |
3
+ json.id configured_account.id
4
+ json.service_definition_id configured_account.service_definition_id
5
+ json.account_id configured_account.account_id
6
+ json.account_name configured_account.account.organization
7
+ json.username configured_account.username
8
+ json.enabled configured_account.enabled
9
+ if configured_account.credentials.first.present?
10
+ json.password configured_account.credentials.first.password if configured_account.credentials.first.password.present?
11
+ json.token configured_account.credentials.first.token if configured_account.credentials.first.token.present?
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # -*- ruby -*-
2
+ json.id @configured_account.id
3
+ json.service_definition_id @configured_account.service_definition_id
4
+ json.account_id @configured_account.account_id
5
+ json.account_name @configured_account.account.organization
6
+ json.username @configured_account.username
7
+ json.enabled @configured_account.enabled
8
+ if @configured_account.credentials.first.present?
9
+ json.password @configured_account.credentials.first.password if @configured_account.credentials.first.password.present?
10
+ json.token @configured_account.credentials.first.token if @configured_account.credentials.first.token.present?
11
+ end
@@ -0,0 +1,13 @@
1
+ # -*- ruby -*-
2
+ json.array!(@configured_facilities) do | configured_facility |
3
+ json.id configured_facility.id
4
+ json.service_definition_id configured_facility.service_definition_id
5
+ json.facility_id configured_facility.facility_id
6
+ json.facility_name configured_facility.facility.name
7
+ json.username configured_facility.username
8
+ json.enabled configured_facility.enabled
9
+ if configured_facility.credentials.first.present?
10
+ json.password configured_facility.credentials.first.password if configured_facility.credentials.first.password.present?
11
+ json.token configured_facility.credentials.first.token if configured_facility.credentials.first.token.present?
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # -*- ruby -*-
2
+ json.id @configured_facility.id
3
+ json.service_definition_id @configured_facility.service_definition_id
4
+ json.facility_id @configured_facility.facility_id
5
+ json.facility_name @configured_facility.facility.name
6
+ json.username @configured_facility.username
7
+ json.enabled @configured_facility.enabled
8
+ if @configured_facility.credentials.first.present?
9
+ json.password @configured_facility.credentials.first.password if @configured_facility.credentials.first.password.present?
10
+ json.token @configured_facility.credentials.first.token if @configured_facility.credentials.first.token.present?
11
+ end
@@ -0,0 +1,10 @@
1
+ # -*- ruby -*-
2
+ json.array!(@facility_mappings) do | facility_mapping |
3
+ json.id facility_mapping.id
4
+ json.third_party_id facility_mapping.third_party_id
5
+ json.third_party_name facility_mapping.third_party.name
6
+ json.facility_id facility_mapping.facility_id
7
+ json.facility_name facility_mapping.facility.name
8
+ json.facility_code facility_mapping.facility_code
9
+ json.top_level facility_mapping.top_level
10
+ end
@@ -0,0 +1,8 @@
1
+ # -*- ruby -*-
2
+ json.id @facility_mapping.id
3
+ json.third_party_id @facility_mapping.third_party_id
4
+ json.third_party_name @facility_mapping.third_party.name
5
+ json.facility_id @facility_mapping.facility_id
6
+ json.facility_name @facility_mapping.facility.name
7
+ json.facility_code @facility_mapping.facility_code
8
+ json.top_level @facility_mapping.top_level
@@ -0,0 +1,10 @@
1
+ xml.composite_file_response do
2
+ if @errors.empty?
3
+ xml.status("SUCCESS")
4
+ else
5
+ xml.status("ERROR")
6
+ xml.error_message(@errors.join("\n"))
7
+ end
8
+ xml.filename(@upload.original_file_name) if @upload && @upload.original_file_name.present?
9
+ xml.submission_datetime(american_date_time(Time.now))
10
+ end
@@ -0,0 +1,11 @@
1
+ # -*- ruby -*-
2
+ json.array!(@mds_pull_accounts) do | mds_pull_account |
3
+ json.id mds_pull_account.id
4
+ json.configured_account_id mds_pull_account.configured_account_id
5
+ json.account_id mds_pull_account.configured_account.account.id
6
+ json.account_name mds_pull_account.configured_account.account.organization
7
+ json.status mds_pull_account_status(mds_pull_account.status)
8
+ json.attempt mds_pull_account.attempt
9
+ json.created_at mds_pull_account.created_at
10
+ json.updated_at mds_pull_account.updated_at
11
+ end
@@ -0,0 +1,8 @@
1
+ # -*- ruby -*-
2
+ json.array!(@public_keys) do | pk |
3
+ json.id pk.id
4
+ json.name pk.name
5
+ json.valid_until pk.valid_until
6
+ json.created_at pk.created_at
7
+ json.updated_at pk.updated_at
8
+ end
@@ -0,0 +1,6 @@
1
+ # -*- ruby -*-
2
+ json.id @public_key.id
3
+ json.name @public_key.name
4
+ json.valid_until @public_key.valid_until
5
+ json.created_at @public_key.created_at
6
+ json.updated_at @public_key.updated_at
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+ json.array!(@service_definitions) do | service_definition |
3
+ json.id service_definition.id
4
+ json.third_party_id service_definition.third_party_id
5
+ json.third_party_name service_definition.third_party.name
6
+ json.service_id service_definition.service_id
7
+ json.service_name service_definition.service.name
8
+ json.hostname service_definition.hostname
9
+ json.port service_definition.port
10
+ json.base_uri service_definition.base_uri
11
+ json.username service_definition.username
12
+ json.service_class service_definition.service_class
13
+ if service_definition.credentials.first.present?
14
+ json.password service_definition.credentials.first.password if service_definition.credentials.first.password.present?
15
+ json.token service_definition.credentials.first.token if service_definition.credentials.first.token.present?
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+ json.id @service_definition.id
3
+ json.third_party_id @service_definition.third_party_id
4
+ json.third_party_name @service_definition.third_party.name
5
+ json.service_id @service_definition.service_id
6
+ json.service_name @service_definition.service.name
7
+ json.hostname @service_definition.hostname
8
+ json.port @service_definition.port
9
+ json.base_uri @service_definition.base_uri
10
+ json.username @service_definition.username
11
+ json.service_class @service_definition.service_class
12
+ if @service_definition.credentials.first.present?
13
+ json.password @service_definition.credentials.first.password if @service_definition.credentials.first.password.present?
14
+ json.token @service_definition.credentials.first.token if @service_definition.credentials.first.token.present?
15
+ end
16
+
@@ -0,0 +1,6 @@
1
+ # -*- ruby -*-
2
+ json.array!(@services) do | service |
3
+ json.id service.id
4
+ json.name service.name
5
+ json.key service.key
6
+ end
@@ -0,0 +1,4 @@
1
+ # -*- ruby -*-
2
+ json.id @service.id
3
+ json.name @service.name
4
+ json.key @service.key
@@ -0,0 +1,10 @@
1
+ # -*- ruby -*-
2
+ json.array!(@providers) do | provider |
3
+ json.id provider['id']
4
+ json.name provider['name']
5
+ json.state provider['state']
6
+ json.npi provider['npi']
7
+ json.ccn provider['ccn']
8
+ json.fac_id provider['mdsFacilityId']
9
+ end
10
+
@@ -0,0 +1,10 @@
1
+ # -*- ruby -*-
2
+ json.array!(@registrations) do | registration |
3
+ json.id registration.id
4
+ json.company_name registration.company_name
5
+ json.initiated_by registration.initiated_by
6
+ json.timestamp registration.timestamp
7
+ json.status sltc_registration_status(registration.status)
8
+ json.created_at registration.created_at
9
+ json.updated_at registration.updated_at
10
+ end
@@ -0,0 +1,7 @@
1
+ # -*- ruby -*-
2
+ json.array!(@third_parties) do | third_party |
3
+ json.id third_party.id
4
+ json.name third_party.name
5
+ json.key third_party.key
6
+ json.contact_email third_party.contact_email
7
+ end
@@ -0,0 +1,5 @@
1
+ # -*- ruby -*-
2
+ json.id @third_party.id
3
+ json.name @third_party.name
4
+ json.key @third_party.key
5
+ json.contact_email @third_party.contact_email
@@ -0,0 +1,20 @@
1
+ <h1>Burying a job on <%= @application_host %></h1>
2
+
3
+ <table>
4
+ <thead>
5
+ </thead>
6
+ <tbody>
7
+ <tr>
8
+ <td><strong>Host</strong></td>
9
+ <td><%= @application_host %></td>
10
+ </tr>
11
+ <tr>
12
+ <td><strong>Service</strong></td>
13
+ <td><%= @mds_pull_account.configured_account.service_definition.service.name %></td>
14
+ </tr>
15
+ <tr>
16
+ <td><strong>Third Party</strong></td>
17
+ <td><%= @mds_pull_account.configured_account.service_definition.third_party.name %></td>
18
+ </tr>
19
+ </tbody>
20
+ </table>
@@ -0,0 +1,20 @@
1
+ <h1>Delaying a job on <%= @application_host %></h1>
2
+
3
+ <table>
4
+ <thead>
5
+ </thead>
6
+ <tbody>
7
+ <tr>
8
+ <td><strong>Host</strong></td>
9
+ <td><%= @application_host %></td>
10
+ </tr>
11
+ <tr>
12
+ <td><strong>Service</strong></td>
13
+ <td><%= @mds_pull_account.configured_account.service_definition.service.name %></td>
14
+ </tr>
15
+ <tr>
16
+ <td><strong>Third Party</strong></td>
17
+ <td><%= @mds_pull_account.configured_account.service_definition.third_party.name %></td>
18
+ </tr>
19
+ </tbody>
20
+ </table>
@@ -0,0 +1,39 @@
1
+ <p>On host: <%= @application_host %></p>
2
+
3
+ <p>Provider '<strong><%= @registration.company_name %></strong>' has registered with SimpleLTC
4
+ and would like abaqis to start processing their MDS 3.0 Files. The registration was
5
+ initiated by: <%= @registration.initiated_by %>.</p>
6
+
7
+ <p>There are a couple of things to be done to complete the abaqis registration process:</p>
8
+
9
+ <ol>
10
+ <li>Determine the abaqis account_id of the provider and write it down. If this provider
11
+ is not currently an abaqis customer, work with the sales department to get this
12
+ provider set up in abaqis.</li>
13
+ <li>Use the <strong>service_mgr</strong> application to verify that there is a
14
+ configured_account record for the Providigm/MdsPush service definition to allow MDS
15
+ files to be uploaded for that account.</li>
16
+ <li>Use the <strong>service_mgr</strong> application to complete the registration. The
17
+ <strong>service_mgr</strong> will perform the following steps:<ol>
18
+ <li>Create an account mapping between the abaqis account and the SimpleLTC account</li>
19
+ <li>Create an account configuration enabling the downloading of MDS 3.0 files from
20
+ SimpleLTC</li>
21
+ <li>Create facility mappings between the abaqis facilities and the SimpleLTC facilities</li>
22
+ <li>Create facility configurations to enable downloading of MDS 3.0 files for the
23
+ configured facilities</li>
24
+ <li>For each configured facility, create a baseline request to SimpleLTC (for the
25
+ last 6 months worth of assessments, by default).</li>
26
+ </ol></li>
27
+ </ol>
28
+
29
+ <p>Sit back, relax and watch the assessments come flowing into abaqis.</p>
30
+
31
+ <p><strong>NOTE:</strong> The following is an example of how you would invoke the
32
+ <strong>service_mgr</strong> application:</p>
33
+
34
+ <pre>
35
+ service_mgr sltc_registration complete
36
+ </pre>
37
+
38
+ <p><strong>service_mgr</strong> will prompt you for all the information necessary to complete
39
+ the registration.</p>
@@ -0,0 +1,8 @@
1
+ <p>On host: <%= @application_host %></p>
2
+
3
+ <p>We received a SimpleLTC registration request of type: <%= @mt %>. We support only message
4
+ type 1. The details:</p>
5
+
6
+ <ul>
7
+ <li><strong>JWT:</strong><br/><%= @jwt %></li>
8
+ </ul>
@@ -0,0 +1,10 @@
1
+ <p>On host: <%= @application_host %></p>
2
+
3
+ <p>We received an invalid SimpleLTC registration request. The details:</p>
4
+
5
+ <ul>
6
+ <li><strong>JWT:</strong><br/><%= @jwt %></li>
7
+ <li><strong>Exception:</strong><%= @ex.message %></li>
8
+ </ul>
9
+ <p>Backtrace:</p>
10
+ <pre><%= @ex.backtrace.join("\n") %></pre>
@@ -0,0 +1,13 @@
1
+ <p>On host: <%= @application_host %></p>
2
+
3
+ <p>We received a SimpleLTC registration request with validation errors. The details:</p>
4
+
5
+ <ul>
6
+ <li><strong>JWT:</strong><br/><%= @jwt %></li>
7
+ </ul>
8
+ <p>Validation Error(s):</p>
9
+ <ol>
10
+ <% @registration.errors.full_messages.each do | msg | %>
11
+ <li><%= msg %></li>
12
+ <% end %>
13
+ </ol>
@@ -0,0 +1,26 @@
1
+ <h1>SLTC: Changes to provider assignments on <%= @application_host %></h1>
2
+
3
+ <% c_account_ids = @provider_deltas.pluck(:configured_account_id).uniq %>
4
+
5
+ <ol>
6
+ <% c_account_ids.each do | ca_id | %>
7
+ <% deltas_for_account = @provider_deltas.select { | pd | pd.configured_account_id == ca_id } %>
8
+ <% account = deltas_for_account.first.configured_account.account %>
9
+ <li>
10
+ Provider changes for account '<%= account.organization %> (<%= account.id %>)'
11
+ <ol>
12
+ <% deltas_for_account.each do | delta | %>
13
+ <li>
14
+ <%= (delta.verb == Services::ProviderChange::VERB_ADD) ? "Added" : "Deleted" %> provider '<%= delta.name %> (<%= delta.facility_code %>)'
15
+ <ul>
16
+ <li>CCN: <%= delta.ccn %></li>
17
+ <li>NPI: <%= delta.npi %></li>
18
+ <li>FacId: <%= delta.fac_id %> (<%= delta.state %>)</li>
19
+ </ul>
20
+ </li>
21
+ <% end %>
22
+ </ol>
23
+ </li>
24
+ <% end %>
25
+ </ol>
26
+
@@ -0,0 +1,6 @@
1
+ <html>
2
+ <body>
3
+ <h3>There was no record of an MDS Pull Today.</h3>
4
+ <p>Check to see if the Rufus scheduler is running on production.</p>
5
+ </body>
6
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,48 @@
1
+ Services::Engine.routes.draw do
2
+
3
+ resources :mds_files, only: [ :create ] do
4
+ collection do
5
+ post 'composite'
6
+ end
7
+ end
8
+
9
+ resources :third_parties, except: [ :destroy ] do
10
+ resources :account_mappings, except: [ :new, :edit ]
11
+ resources :facility_mappings, except: [ :new, :edit ]
12
+ resources :service_definitions, except: [ :new, :edit ] do
13
+ resources :configured_accounts, except: [ :new, :edit ] do
14
+ resources :available_files, only: [ :index ]
15
+ end
16
+ resources :configured_facilities, except: [ :new, :edit ]
17
+ end
18
+ end
19
+
20
+ resources :services, except: [ :destroy, :new, :edit ] do
21
+ member do
22
+ put 'invoke'
23
+ end
24
+ resources :mds_pull_accounts, only: [ :index ]
25
+ resources :service_definitions, except: [ :new, :edit, :create, :destroy ] do
26
+ resources :mds_pull_accounts, only: [ :index ]
27
+ resources :configured_facilities, except: [ :new, :edit, :create, :destroy ]
28
+ resources :configured_accounts, except: [ :new, :edit, :create, :destroy ] do
29
+ resources :available_files, only: [ :index ]
30
+ resources :mds_pull_accounts, only: [ :index ]
31
+ end
32
+ end
33
+ end
34
+
35
+ resources :assessment_requests, only: [ :index, :create ]
36
+ resources :sltc_providers, only: [ :index ]
37
+ resources :sltc_registrations, only: [ :create, :index ] do
38
+ member do
39
+ post 'complete'
40
+ end
41
+ end
42
+
43
+ resources :public_keys, except: [ :new, :edit ]
44
+
45
+ resources :adts, only: [ :create ]
46
+
47
+ get '/validation', to: 'validation#valid_object'
48
+ end
@@ -0,0 +1,131 @@
1
+ class CreateServicesEngineTables < ActiveRecord::Migration
2
+
3
+ def change
4
+
5
+ create_table :services_third_parties do |t|
6
+ t.column :name, :string, :null => false
7
+ t.column :contact_email, :string, :null => false
8
+ t.timestamps
9
+ end
10
+
11
+ create_table :services_account_mappings do |t|
12
+ t.column :third_party_id, :int, :null => false
13
+ t.column :account_id, :int, :null => false
14
+ t.column :account_code, :string, :null => false
15
+ t.timestamps
16
+ t.foreign_key(:services_third_parties, column: :third_party_id) if t.respond_to?(:foreign_key)
17
+ end
18
+
19
+ create_table :services_facility_mappings do |t|
20
+ t.column :third_party_id, :int, :null => false
21
+ t.column :facility_id, :int, :null => false
22
+ t.column :facility_code, :string, :null => false
23
+ t.column :top_level, :boolean, :null => false, :default => false
24
+ t.timestamps
25
+ t.foreign_key(:services_third_parties, column: :third_party_id) if t.respond_to?(:foreign_key)
26
+ end
27
+
28
+ create_table :services_services do |t|
29
+ t.column :name, :string, :null => false
30
+ t.timestamps
31
+ end
32
+
33
+ create_table :services_credentials do |t|
34
+ t.column :credentialled_type, :string, :null => false
35
+ t.column :credentialled_id, :int, :null => false
36
+ t.column :password_enc, :binary, :limit => 255
37
+ t.column :token_enc, :binary, :limit => 255
38
+ t.column :expire_on, :datetime
39
+ t.timestamps
40
+ end
41
+
42
+ create_table :services_service_definitions do |t|
43
+ t.column :third_party_id, :int, :null => false
44
+ t.column :service_id, :int, :null => false
45
+ t.column :hostname, :string
46
+ t.column :port, :int
47
+ t.column :base_uri, :string
48
+ t.column :username, :string
49
+ t.column :service_class, :string, :null => false
50
+ t.timestamps
51
+ t.foreign_key(:services_third_parties, column: :third_party_id) if t.respond_to?(:foreign_key)
52
+ t.foreign_key(:services_services, column: :service_id) if t.respond_to?(:foreign_key)
53
+ end
54
+
55
+ create_table :services_configured_accounts do |t|
56
+ t.column :service_definition_id, :int, :null => false
57
+ t.column :account_id, :int, :null => false
58
+ t.column :username, :string
59
+ t.column :enabled, :boolean, :null => false, :default => false
60
+ t.timestamps
61
+ t.foreign_key(:services_service_definitions, column: :service_definition_id) if t.respond_to?(:foreign_key)
62
+ end
63
+
64
+ create_table :services_configured_facilities do |t|
65
+ t.column :service_definition_id, :int, :null => false
66
+ t.column :facility_id, :int, :null => false
67
+ t.column :username, :string
68
+ t.column :enabled, :boolean, :null => false, :default => false
69
+ t.timestamps
70
+ t.foreign_key(:services_service_definitions, column: :service_definition_id) if t.respond_to?(:foreign_key)
71
+ end
72
+
73
+ create_table :services_available_files do |t|
74
+ t.column :configured_account_id, :int, :null => false
75
+ t.column :request_id, :string, :null => false
76
+ t.column :filename, :string, :null => false
77
+ t.column :status, :int, :null => false, :default => 0
78
+ t.column :downloaded_at, :datetime
79
+ t.column :composite_file_name, :string
80
+ t.column :error, :string
81
+ t.timestamps
82
+ t.foreign_key(:services_configured_accounts, column: :configured_account_id) if t.respond_to?(:foreign_key)
83
+ end
84
+
85
+ create_table :services_mds_pull_accounts do |t|
86
+ t.column :configured_account_id, :int, :null => false
87
+ t.column :status, :int, :null => false, :default => 0
88
+ t.column :attempt, :int, :null => false, :default => 0
89
+ t.timestamps
90
+ t.foreign_key(:services_configured_accounts, column: :configured_account_id) if t.respond_to?(:foreign_key)
91
+ end
92
+
93
+ create_table :services_assessment_requests do |t|
94
+ t.column :facility_code, :string, :null => false
95
+ t.column :request_id, :string, :null => false
96
+ t.column :pull_from, :datetime
97
+ t.column :pull_to, :datetime
98
+ t.column :status, :int, :null => false, :default => 0
99
+ t.timestamps
100
+ end
101
+
102
+ create_table :services_hl7_messages do |t|
103
+ t.integer :facility_id, :null => true
104
+ t.integer :resident_id, :null => true
105
+ t.string :message_type, :null => false
106
+ t.binary :message_enc
107
+ t.integer :status, :null => false, :default => 0
108
+ t.timestamps
109
+ t.foreign_key(:facilities, column: :facility_id) if t.respond_to?(:foreign_key)
110
+ t.foreign_key(:residents, column: :resident_id) if t.respond_to?(:foreign_key)
111
+ end
112
+
113
+ create_table :services_sltc_registrations do |t|
114
+ t.string :company_name
115
+ t.binary :auth_password_enc
116
+ t.binary :auth_username_enc
117
+ t.string :initiated_by
118
+ t.datetime :timestamp
119
+ t.integer :status, null: true, default: 0
120
+ t.timestamps
121
+ end
122
+
123
+ create_table :services_public_keys do |t|
124
+ t.column :name, :string, null: false
125
+ t.column :key, :text, null: false
126
+ t.column :valid_until, :datetime
127
+ t.timestamps
128
+ end
129
+
130
+ end
131
+ end