renalware-core 2.0.0.pre.rc11 → 2.0.0.pre.rc13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (386) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/app/assets/javascripts/renalware/letters.js +10 -0
  4. data/app/assets/stylesheets/renalware/modules/_letters.scss +0 -2
  5. data/app/assets/stylesheets/renalware/modules/_pathology.scss +24 -3
  6. data/app/assets/stylesheets/renalware/modules/_patients.scss +1 -2
  7. data/app/assets/stylesheets/renalware/partials/_layout.scss +3 -15
  8. data/app/assets/stylesheets/renalware/patient_pages.scss +43 -0
  9. data/app/controllers/renalware/api/ukrdc/patients_controller.rb +1 -1
  10. data/app/controllers/renalware/api/v1/medications/prescriptions_controller.rb +38 -0
  11. data/app/controllers/renalware/drugs/drugs_controller.rb +2 -6
  12. data/app/controllers/renalware/letters/completed_letters_controller.rb +21 -3
  13. data/app/controllers/renalware/letters/lists_controller.rb +9 -1
  14. data/app/controllers/renalware/pathology/historical_observation_results_controller.rb +1 -1
  15. data/app/controllers/renalware/pathology/recent_observation_results_controller.rb +1 -1
  16. data/app/helpers/renalware/letters_helper.rb +7 -0
  17. data/app/models/concerns/renalware/patient_pathology_scopes.rb +1 -1
  18. data/app/models/concerns/renalware/patients_ransack_helper.rb +10 -8
  19. data/app/models/concerns/renalware/personable.rb +1 -1
  20. data/app/models/renalware/admissions/admission.rb +1 -1
  21. data/app/models/renalware/admissions/consult.rb +1 -1
  22. data/app/models/renalware/admissions/request.rb +1 -1
  23. data/app/models/renalware/clinical/body_composition.rb +1 -1
  24. data/app/models/renalware/drugs/classification.rb +2 -2
  25. data/app/models/renalware/drugs/drug.rb +1 -1
  26. data/app/models/renalware/feeds/files/import_job_factory.rb +0 -1
  27. data/app/models/renalware/feeds/files/practices/import_job.rb +1 -0
  28. data/app/models/renalware/feeds/message_processor.rb +5 -4
  29. data/app/models/renalware/hd/diary_slot.rb +3 -2
  30. data/app/models/renalware/letters/archive.rb +1 -1
  31. data/app/models/renalware/letters/complete_letter.rb +9 -5
  32. data/app/models/renalware/letters/contact.rb +1 -1
  33. data/app/models/renalware/letters/electronic_receipt.rb +1 -1
  34. data/app/models/renalware/letters/letter.rb +3 -0
  35. data/app/models/renalware/letters/letter/approved.rb +2 -0
  36. data/app/models/renalware/letters/letter/draft.rb +5 -1
  37. data/app/models/renalware/letters/letter/pending_review.rb +2 -0
  38. data/app/models/renalware/letters/pdf_letter_cache.rb +27 -13
  39. data/app/models/renalware/letters/signature.rb +2 -2
  40. data/app/models/renalware/low_clearance/mdm_patients_query.rb +1 -1
  41. data/app/models/renalware/messaging/internal/author.rb +1 -0
  42. data/app/models/renalware/messaging/message.rb +1 -1
  43. data/app/models/renalware/pathology/measurement_unit.rb +1 -1
  44. data/app/models/renalware/pathology/observation.rb +7 -2
  45. data/app/models/renalware/pathology/observation_description.rb +8 -2
  46. data/app/models/renalware/pathology/observation_request.rb +1 -4
  47. data/app/models/renalware/patients/alert.rb +1 -1
  48. data/app/models/renalware/patients/bookmark.rb +1 -0
  49. data/app/models/renalware/patients/worry.rb +4 -1
  50. data/app/models/renalware/pd/peritonitis_episode_type.rb +2 -1
  51. data/app/models/renalware/pd/regime_bag.rb +1 -1
  52. data/app/models/renalware/renal/aki_alert.rb +1 -1
  53. data/app/models/renalware/research/study.rb +5 -2
  54. data/app/models/renalware/research/study_participant.rb +5 -14
  55. data/app/models/renalware/transplants/donation.rb +1 -1
  56. data/app/models/renalware/transplants/mdm_patients_query.rb +4 -2
  57. data/app/models/renalware/transplants/recipient_followup.rb +2 -2
  58. data/app/models/renalware/transplants/registrations/wait_list_query.rb +8 -2
  59. data/app/models/renalware/ukrdc.rb +9 -0
  60. data/app/models/renalware/ukrdc/patients_query.rb +24 -0
  61. data/app/models/renalware/ukrdc/send_patient.rb +97 -0
  62. data/app/models/renalware/ukrdc/send_patients.rb +91 -0
  63. data/app/models/renalware/ukrdc/transmission_log.rb +30 -0
  64. data/app/models/renalware/virology/profile.rb +1 -0
  65. data/app/presenters/date_presenter.rb +2 -0
  66. data/app/presenters/date_time_presenter.rb +2 -0
  67. data/app/presenters/enumerize/value_presenter.rb +2 -0
  68. data/app/presenters/false_class_presenter.rb +2 -0
  69. data/app/presenters/presenter.rb +2 -0
  70. data/app/presenters/renalware/accesses/assessment_presenter.rb +2 -0
  71. data/app/presenters/renalware/accesses/patient_presenter.rb +2 -0
  72. data/app/presenters/renalware/accesses/plan_presenter.rb +2 -0
  73. data/app/presenters/renalware/accesses/procedure_presenter.rb +2 -0
  74. data/app/presenters/renalware/accesses/profile_presenter.rb +2 -0
  75. data/app/presenters/renalware/address_presenter.rb +2 -0
  76. data/app/presenters/renalware/address_presenter/block.rb +2 -0
  77. data/app/presenters/renalware/address_presenter/short.rb +2 -0
  78. data/app/presenters/renalware/address_presenter/single_line.rb +2 -0
  79. data/app/presenters/renalware/admin/users/summary_part.rb +2 -0
  80. data/app/presenters/renalware/admissions/admission_presenter.rb +2 -0
  81. data/app/presenters/renalware/admissions/consult_presenter.rb +2 -0
  82. data/app/presenters/renalware/admissions/summary_part.rb +2 -0
  83. data/app/presenters/renalware/clinical/body_composition_presenter.rb +2 -0
  84. data/app/presenters/renalware/clinical/dry_weight_presenter.rb +2 -0
  85. data/app/presenters/renalware/clinical/dry_weights_presenter.rb +2 -0
  86. data/app/presenters/renalware/clinical/header_presenter.rb +2 -0
  87. data/app/presenters/renalware/clinical/profile_presenter.rb +2 -0
  88. data/app/presenters/renalware/country_presenter.rb +2 -0
  89. data/app/presenters/renalware/dashboard/dashboard_presenter.rb +2 -0
  90. data/app/presenters/renalware/directory/person_auto_complete_presenter.rb +2 -0
  91. data/app/presenters/renalware/events/events_presenter.rb +2 -0
  92. data/app/presenters/renalware/events/summary_part.rb +2 -0
  93. data/app/presenters/renalware/hd/dashboard_presenter.rb +2 -0
  94. data/app/presenters/renalware/hd/diary_presenter.rb +2 -0
  95. data/app/presenters/renalware/hd/diary_slot_presenter.rb +2 -0
  96. data/app/presenters/renalware/hd/mdm_patient_presenter.rb +2 -0
  97. data/app/presenters/renalware/hd/mdm_presenter.rb +2 -0
  98. data/app/presenters/renalware/hd/null_slot.rb +2 -0
  99. data/app/presenters/renalware/hd/patient_presenter.rb +2 -0
  100. data/app/presenters/renalware/hd/profile_document_presenter.rb +2 -0
  101. data/app/presenters/renalware/hd/profile_presenter.rb +2 -0
  102. data/app/presenters/renalware/hd/protocol/session_presenter.rb +2 -0
  103. data/app/presenters/renalware/hd/protocol_presenter.rb +2 -0
  104. data/app/presenters/renalware/hd/session_access_presenter.rb +2 -0
  105. data/app/presenters/renalware/hd/session_presenter.rb +2 -0
  106. data/app/presenters/renalware/hd/station_presenter.rb +2 -0
  107. data/app/presenters/renalware/hd/unmet_preferences_presenter.rb +2 -0
  108. data/app/presenters/renalware/letters/contact_description_presenter.rb +2 -0
  109. data/app/presenters/renalware/letters/contact_presenter.rb +2 -0
  110. data/app/presenters/renalware/letters/contacts_presenter.rb +2 -0
  111. data/app/presenters/renalware/letters/electronic_receipt_presenter.rb +2 -0
  112. data/app/presenters/renalware/letters/letter_form_presenter.rb +2 -0
  113. data/app/presenters/renalware/letters/letter_presenter.rb +2 -0
  114. data/app/presenters/renalware/letters/letter_presenter_factory.rb +2 -0
  115. data/app/presenters/renalware/letters/part_class_filter.rb +2 -0
  116. data/app/presenters/renalware/letters/practice_email_meta_data.rb +2 -0
  117. data/app/presenters/renalware/letters/recipient_presenter.rb +2 -0
  118. data/app/presenters/renalware/letters/summary_part.rb +2 -0
  119. data/app/presenters/renalware/low_clearance/dashboard_presenter.rb +2 -0
  120. data/app/presenters/renalware/low_clearance/mdm_presenter.rb +2 -0
  121. data/app/presenters/renalware/mdm_patient_presenter.rb +2 -0
  122. data/app/presenters/renalware/mdm_patients_presenter.rb +2 -0
  123. data/app/presenters/renalware/mdm_presenter.rb +2 -4
  124. data/app/presenters/renalware/medications/prescription_presenter.rb +2 -0
  125. data/app/presenters/renalware/medications/provider_code_presenter.rb +2 -0
  126. data/app/presenters/renalware/medications/route_form_presenter.rb +2 -0
  127. data/app/presenters/renalware/medications/summary_part.rb +37 -6
  128. data/app/presenters/renalware/medications/treatable_presenter.rb +2 -0
  129. data/app/presenters/renalware/messaging/internal/message_presenter.rb +2 -0
  130. data/app/presenters/renalware/messaging/internal/receipt_presenter.rb +2 -0
  131. data/app/presenters/renalware/pathology/observation_presenter.rb +4 -2
  132. data/app/presenters/renalware/pathology/observation_set_presenter.rb +21 -8
  133. data/app/presenters/renalware/pathology/observations_diff.rb +2 -0
  134. data/app/presenters/renalware/pathology/observations_for_codes_presenter.rb +2 -0
  135. data/app/presenters/renalware/pathology/patient_presenter.rb +2 -0
  136. data/app/presenters/renalware/pathology/requests/global_rule_presenter.rb +2 -0
  137. data/app/presenters/renalware/pathology/requests/global_rule_set_presenter.rb +2 -0
  138. data/app/presenters/renalware/pathology/requests/patient_rule_presenter.rb +2 -0
  139. data/app/presenters/renalware/pathology/requests/request_presenter.rb +2 -0
  140. data/app/presenters/renalware/pathology/requests/sample_description.rb +2 -0
  141. data/app/presenters/renalware/pathology/results_presenter.rb +2 -0
  142. data/app/presenters/renalware/patient_presenter.rb +2 -0
  143. data/app/presenters/renalware/pd/dashboard_presenter.rb +2 -0
  144. data/app/presenters/renalware/pd/delivery_interval_presenter.rb +2 -0
  145. data/app/presenters/renalware/pd/mdm_presenter.rb +2 -0
  146. data/app/presenters/renalware/pd/peritonitis_episode_presenter.rb +2 -0
  147. data/app/presenters/renalware/pd/training_duration_presenter.rb +2 -0
  148. data/app/presenters/renalware/primary_care_physician_presenter.rb +2 -0
  149. data/app/presenters/renalware/problems/summary_part.rb +2 -0
  150. data/app/presenters/renalware/renal/clinical_summary_presenter.rb +2 -0
  151. data/app/presenters/renalware/reporting/audit_presenter.rb +2 -0
  152. data/app/presenters/renalware/summary_part.rb +2 -0
  153. data/app/presenters/renalware/system/users_presenter.rb +2 -0
  154. data/app/presenters/renalware/time_of_day_presenter.rb +2 -0
  155. data/app/presenters/renalware/transplants/consent_presenter.rb +2 -0
  156. data/app/presenters/renalware/transplants/donor_dashboard_presenter.rb +2 -0
  157. data/app/presenters/renalware/transplants/mdm_presenter.rb +2 -0
  158. data/app/presenters/renalware/transplants/patient_presenter.rb +2 -0
  159. data/app/presenters/renalware/transplants/recipient_dashboard_presenter.rb +2 -0
  160. data/app/presenters/renalware/transplants/wait_list_registration_presenter.rb +2 -0
  161. data/app/presenters/renalware/ukrdc/pathology_observation_presenter.rb +2 -0
  162. data/app/presenters/renalware/ukrdc/patient_presenter.rb +58 -4
  163. data/app/presenters/string_presenter.rb +2 -0
  164. data/app/presenters/time_presenter.rb +2 -0
  165. data/app/presenters/true_class_presenter.rb +2 -0
  166. data/app/views/renalware/api/ukrdc/patients/_encounters.xml.builder +1 -3
  167. data/app/views/renalware/api/ukrdc/patients/_lab_orders.xml.builder +5 -6
  168. data/app/views/renalware/api/ukrdc/patients/_observations.xml.builder +5 -4
  169. data/app/views/renalware/api/ukrdc/patients/encounters/_hd_session.xml.builder +1 -1
  170. data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +7 -1
  171. data/app/views/renalware/api/v1/medications/prescriptions/index.json.jbuilder +14 -0
  172. data/app/views/renalware/api/v1/patients/patients/show.json.jbuilder +17 -4
  173. data/app/views/renalware/clinics/clinic_visits/_clinic_visit.html.slim +1 -1
  174. data/app/views/renalware/events/events/toggled_cell/_biopsy.html.slim +1 -1
  175. data/app/views/renalware/events/events/toggled_cell/_investigation.html.slim +1 -1
  176. data/app/views/renalware/events/events/toggled_cell/_simple.html.slim +1 -1
  177. data/app/views/renalware/events/events/toggled_cell/_swab.html.slim +1 -1
  178. data/app/views/renalware/events/swabs/_list.html.slim +1 -1
  179. data/app/views/renalware/hd/mdm_patients/_patient.html.slim +6 -0
  180. data/app/views/renalware/hd/mdm_patients/_table.html.slim +6 -0
  181. data/app/views/renalware/layouts/_patient.html.slim +32 -30
  182. data/app/views/renalware/letters/completed_letters/create.js.erb +8 -0
  183. data/app/views/renalware/letters/completed_letters/new.html.slim +27 -0
  184. data/app/views/renalware/letters/lists/_letter.html.slim +18 -4
  185. data/app/views/renalware/letters/lists/_table.html.slim +19 -0
  186. data/app/views/renalware/letters/lists/show.html.slim +13 -24
  187. data/app/views/renalware/letters/lists/show.js.erb +11 -0
  188. data/app/views/renalware/medications/_summary_part.html.slim +17 -16
  189. data/app/views/renalware/pathology/current_observation_results/index.html.slim +9 -12
  190. data/app/views/renalware/patients/_layout.html.slim +27 -24
  191. data/app/views/renalware/patients/_side_menu.html.slim +1 -0
  192. data/app/views/renalware/patients/side_menu/_actions.html.slim +1 -1
  193. data/app/views/renalware/virology/vaccinations/_toggled_cell.html.slim +1 -1
  194. data/config/initializers/delayed_job.rb +3 -0
  195. data/config/initializers/wicked_pdf.rb +0 -1
  196. data/config/locales/en.yml +6 -0
  197. data/config/locales/renalware/hd/mdm_patients.yml +6 -0
  198. data/config/routes.rb +2 -4
  199. data/db/functions/import_practice_memberships_csv_v02.sql +50 -0
  200. data/db/migrate/20180221210458_add_state_index_on_modalities.rb +5 -0
  201. data/db/migrate/20180222090501_add_partial_index_to_bookmarks.rb +6 -0
  202. data/db/migrate/20180223100420_add_sent_to_ukrdc_at_to_patients.rb +5 -0
  203. data/db/migrate/20180226124724_add_patient_id_to_virology_profile.rb +9 -0
  204. data/db/migrate/20180226132410_create_ukrdc_transmission_logs.rb +15 -0
  205. data/db/migrate/20180301095040_update_fn_to_upsert_gp_practive_memberships.rb +9 -0
  206. data/db/migrate/20180305134959_add_display_group_to_observation_desriptions.rb +32 -0
  207. data/db/migrate/20180306071308_remove_rogue_aki_alerts_column.rb +5 -0
  208. data/db/migrate/20180306080518_add_state_tracking_cols_to_letters.rb +19 -0
  209. data/lib/renalware/engine.rb +1 -0
  210. data/lib/renalware/version.rb +1 -1
  211. data/lib/tasks/ukrdc.rake +16 -0
  212. data/lib/test_support/ajax_helpers.rb +2 -2
  213. data/spec/factories/accesses/patients.rb +2 -0
  214. data/spec/factories/accesses/plans.rb +2 -0
  215. data/spec/factories/accesses/plans_types.rb +2 -0
  216. data/spec/factories/accesses/procedures.rb +2 -0
  217. data/spec/factories/accesses/profiles.rb +2 -0
  218. data/spec/factories/accesses/sites.rb +2 -0
  219. data/spec/factories/accesses/types.rb +2 -0
  220. data/spec/factories/admissions/admissions.rb +2 -0
  221. data/spec/factories/admissions/consult_sites.rb +2 -0
  222. data/spec/factories/admissions/consults.rb +2 -0
  223. data/spec/factories/admissions/request_reasons.rb +2 -0
  224. data/spec/factories/admissions/requests.rb +1 -0
  225. data/spec/factories/clinical/allergies.rb +2 -0
  226. data/spec/factories/clinical/body_compositions.rb +2 -0
  227. data/spec/factories/clinical/dry_weights.rb +2 -0
  228. data/spec/factories/clinical/patients.rb +2 -0
  229. data/spec/factories/clinics/appointments.rb +2 -0
  230. data/spec/factories/clinics/clinic_visits.rb +2 -0
  231. data/spec/factories/clinics/clinics.rb +2 -0
  232. data/spec/factories/deaths/cause.rb +2 -0
  233. data/spec/factories/deaths/modality_descriptions.rb +2 -0
  234. data/spec/factories/directory/people.rb +2 -0
  235. data/spec/factories/drugs/drug.rb +2 -0
  236. data/spec/factories/drugs/drug_types.rb +7 -0
  237. data/spec/factories/events/events.rb +2 -0
  238. data/spec/factories/events/events_types.rb +2 -0
  239. data/spec/factories/feeds/file.rb +2 -0
  240. data/spec/factories/feeds/file_types.rb +2 -0
  241. data/spec/factories/hd/cannulation_types.rb +2 -0
  242. data/spec/factories/hd/dialysates.rb +2 -0
  243. data/spec/factories/hd/dialysers.rb +2 -0
  244. data/spec/factories/hd/diaries.rb +2 -0
  245. data/spec/factories/hd/diurnal_period_codes.rb +2 -0
  246. data/spec/factories/hd/hd_session_document.rb +2 -0
  247. data/spec/factories/hd/modality_descriptions.rb +2 -0
  248. data/spec/factories/hd/patient_statistics.rb +2 -0
  249. data/spec/factories/hd/patients.rb +2 -0
  250. data/spec/factories/hd/preference_sets.rb +2 -0
  251. data/spec/factories/hd/profiles.rb +2 -0
  252. data/spec/factories/hd/schedule_definitions.rb +2 -0
  253. data/spec/factories/hd/sessions.rb +2 -0
  254. data/spec/factories/hd/slots.rb +2 -0
  255. data/spec/factories/hd/station_locations.rb +2 -0
  256. data/spec/factories/hd/stations.rb +2 -0
  257. data/spec/factories/hospitals/centres.rb +2 -0
  258. data/spec/factories/hospitals/units.rb +2 -0
  259. data/spec/factories/hospitals/wards.rb +2 -0
  260. data/spec/factories/letters/archives.rb +2 -0
  261. data/spec/factories/letters/contact_descriptions.rb +2 -0
  262. data/spec/factories/letters/contacts.rb +2 -0
  263. data/spec/factories/letters/descriptions.rb +2 -0
  264. data/spec/factories/letters/electronic_receipts.rb +2 -0
  265. data/spec/factories/letters/letterheads.rb +2 -0
  266. data/spec/factories/letters/letters.rb +2 -0
  267. data/spec/factories/letters/patients.rb +2 -0
  268. data/spec/factories/letters/primary_care_physicians.rb +2 -0
  269. data/spec/factories/letters/recipients.rb +2 -0
  270. data/spec/factories/low_clearance/modality_descriptions.rb +2 -0
  271. data/spec/factories/low_clearance/patients.rb +2 -0
  272. data/spec/factories/low_clearance/profiles.rb +2 -0
  273. data/spec/factories/medications/medication_route.rb +2 -0
  274. data/spec/factories/medications/prescription.rb +2 -0
  275. data/spec/factories/medications/prescription_terminations.rb +2 -0
  276. data/spec/factories/medications/prescription_version.rb +2 -0
  277. data/spec/factories/messaging/internal/authors.rb +2 -0
  278. data/spec/factories/messaging/internal/messages.rb +2 -0
  279. data/spec/factories/messaging/internal/receipts.rb +2 -0
  280. data/spec/factories/messaging/internal/recipients.rb +2 -0
  281. data/spec/factories/messaging/patients.rb +2 -0
  282. data/spec/factories/modalities/modalities.rb +2 -0
  283. data/spec/factories/modalities/modality_descriptions.rb +2 -0
  284. data/spec/factories/modalities/modality_reasons.rb +2 -0
  285. data/spec/factories/pathology/consultant.rb +2 -0
  286. data/spec/factories/pathology/lab.rb +2 -0
  287. data/spec/factories/pathology/measurement_units.rb +2 -0
  288. data/spec/factories/pathology/observation_descriptions.rb +6 -0
  289. data/spec/factories/pathology/observation_requests.rb +3 -1
  290. data/spec/factories/pathology/observations.rb +2 -0
  291. data/spec/factories/pathology/patients.rb +2 -0
  292. data/spec/factories/pathology/request_descriptions.rb +2 -0
  293. data/spec/factories/pathology/requests/drug_category.rb +2 -0
  294. data/spec/factories/pathology/requests/global_rule.rb +2 -0
  295. data/spec/factories/pathology/requests/global_rule_set.rb +2 -0
  296. data/spec/factories/pathology/requests/patient_rule.rb +2 -0
  297. data/spec/factories/pathology/requests/request.rb +2 -0
  298. data/spec/factories/patients/alerts.rb +2 -0
  299. data/spec/factories/patients/bookmarks.rb +2 -0
  300. data/spec/factories/patients/ethnicities.rb +2 -0
  301. data/spec/factories/patients/languages.rb +2 -0
  302. data/spec/factories/patients/patients.rb +2 -0
  303. data/spec/factories/patients/practice_memberships.rb +2 -0
  304. data/spec/factories/patients/practices.rb +2 -0
  305. data/spec/factories/patients/primary_care_physicians.rb +2 -0
  306. data/spec/factories/patients/religions.rb +2 -0
  307. data/spec/factories/patients/users.rb +2 -0
  308. data/spec/factories/pd/assessments.rb +2 -0
  309. data/spec/factories/pd/bag_types.rb +2 -0
  310. data/spec/factories/pd/episode_types.rb +2 -0
  311. data/spec/factories/pd/exit_site_infections.rb +2 -0
  312. data/spec/factories/pd/fluid_descriptions.rb +2 -0
  313. data/spec/factories/pd/infection_organisms.rb +2 -0
  314. data/spec/factories/pd/modality_descriptions.rb +2 -0
  315. data/spec/factories/pd/organism_codes.rb +2 -0
  316. data/spec/factories/pd/patients.rb +2 -0
  317. data/spec/factories/pd/pd_regimes.rb +2 -0
  318. data/spec/factories/pd/peritonitis_episode_type_descriptions.rb +2 -0
  319. data/spec/factories/pd/peritonitis_episodes.rb +2 -0
  320. data/spec/factories/pd/pet_adequacies.rb +2 -0
  321. data/spec/factories/pd/regime_bags.rb +2 -0
  322. data/spec/factories/pd/systems.rb +2 -0
  323. data/spec/factories/pd/training_sessions.rb +2 -0
  324. data/spec/factories/pd/training_sites.rb +2 -0
  325. data/spec/factories/pd/training_types.rb +2 -0
  326. data/spec/factories/problems/problems.rb +2 -0
  327. data/spec/factories/renal/aki_alert_actions.rb +2 -0
  328. data/spec/factories/renal/aki_alerts.rb +2 -0
  329. data/spec/factories/renal/patients.rb +2 -0
  330. data/spec/factories/renal/prd_description.rb +2 -0
  331. data/spec/factories/renal/profiles.rb +2 -0
  332. data/spec/factories/reporting/audits.rb +2 -0
  333. data/spec/factories/research/studies.rb +2 -0
  334. data/spec/factories/research/study_participants.rb +2 -0
  335. data/spec/factories/shared/accountable.rb +2 -0
  336. data/spec/factories/snippets/snippets.rb +2 -0
  337. data/spec/factories/snippets/users.rb +2 -0
  338. data/spec/factories/system/addresses.rb +6 -0
  339. data/spec/factories/system/countries.rb +2 -0
  340. data/spec/factories/system/roles.rb +2 -0
  341. data/spec/factories/system/templates.rb +2 -0
  342. data/spec/factories/system/users.rb +2 -0
  343. data/spec/factories/transplants/donations.rb +2 -0
  344. data/spec/factories/transplants/donor_stage.rb +2 -0
  345. data/spec/factories/transplants/donor_stage_position.rb +2 -0
  346. data/spec/factories/transplants/donor_stage_status.rb +2 -0
  347. data/spec/factories/transplants/live_donor_modality_description.rb +2 -0
  348. data/spec/factories/transplants/modality_descriptions.rb +2 -0
  349. data/spec/factories/transplants/patients.rb +2 -0
  350. data/spec/factories/transplants/recipient_followups.rb +2 -0
  351. data/spec/factories/transplants/recipient_operations.rb +2 -0
  352. data/spec/factories/transplants/registration_status_descriptions.rb +2 -0
  353. data/spec/factories/transplants/registration_statuses.rb +2 -0
  354. data/spec/factories/transplants/registrations.rb +2 -0
  355. data/spec/factories/virology/vaccinations.rb +2 -0
  356. data/spec/support/capybara.rb +2 -0
  357. data/spec/support/capybara_helper.rb +2 -0
  358. data/spec/support/database_functions_spec_helper.rb +2 -0
  359. data/spec/support/date_helpers.rb +2 -0
  360. data/spec/support/devise_spec_helper.rb +2 -0
  361. data/spec/support/drugs_spec_helper.rb +2 -0
  362. data/spec/support/factory_bot.rb +2 -0
  363. data/spec/support/json_helpers.rb +2 -0
  364. data/spec/support/letters_spec_helper.rb +9 -0
  365. data/spec/support/login_macros.rb +2 -0
  366. data/spec/support/matchers/document.rb +2 -0
  367. data/spec/support/matchers/validate_timeliness_of.rb +2 -0
  368. data/spec/support/pathology_spec_helper.rb +2 -0
  369. data/spec/support/patients_spec_helper.rb +2 -0
  370. data/spec/support/poltergeist.rb +2 -0
  371. data/spec/support/pundit_matcher.rb +2 -0
  372. data/spec/support/roles_spec_helper.rb +2 -0
  373. data/spec/support/select2_spec_helper.rb +2 -0
  374. data/spec/support/select_date_spec_helper.rb +2 -0
  375. data/spec/support/shared_contexts/a_global_rule_set.rb +2 -0
  376. data/spec/support/shared_examples/accountable_examples.rb +2 -0
  377. data/spec/support/shared_examples/paranoia_examples.rb +2 -1
  378. data/spec/support/shared_examples/supersedable_examples.rb +2 -0
  379. data/spec/support/translations.rb +2 -0
  380. data/spec/support/travel.rb +2 -0
  381. data/spec/support/webmock.rb +2 -0
  382. metadata +39 -6
  383. data/app/presenters/renalware/pathology/historical_observation_results/html_table_view.rb +0 -64
  384. data/app/presenters/renalware/pathology/historical_observation_results/presenter.rb +0 -86
  385. data/app/presenters/renalware/pathology/recent_observation_results/html_table_view.rb +0 -39
  386. data/app/presenters/renalware/pathology/recent_observation_results/presenter.rb +0 -107
@@ -4,8 +4,8 @@ module Renalware
4
4
  module Drugs
5
5
  class Classification < ApplicationRecord
6
6
  self.table_name = "drug_types_drugs" # a relic from migrating from habtm
7
- belongs_to :drug
8
- belongs_to :drug_type, class_name: "Type"
7
+ belongs_to :drug, touch: true
8
+ belongs_to :drug_type, class_name: "Type", inverse_of: :classifications
9
9
  end
10
10
  end
11
11
  end
@@ -6,7 +6,7 @@ module Renalware
6
6
  acts_as_paranoid
7
7
 
8
8
  has_many :classifications, dependent: :destroy
9
- has_many :drug_types, through: :classifications
9
+ has_many :drug_types, through: :classifications, after_remove: proc { |drug| drug.touch }
10
10
 
11
11
  scope :ordered, -> { order(:name) }
12
12
 
@@ -4,7 +4,6 @@ module Renalware
4
4
  module Feeds
5
5
  module Files
6
6
  class ImportJobFactory
7
-
8
7
  # Returns the active job class required to process files of type file_type
9
8
  def self.job_class_for(file_type)
10
9
  "Renalware::Feeds::Files::#{file_type.name.camelize}::ImportJob".constantize
@@ -43,6 +43,7 @@ module Renalware
43
43
  ZipArchive.new(zipfile).unzip do |files|
44
44
  xml_pathname = find_file_in(files, FILE_TO_EXTRACT_FROM_ARCHIVE)
45
45
  csv_path = Practices::ConvertXmlToCsv.call(xml_pathname)
46
+ FileUtils.copy(csv_path, Rails.root.join("generated_organisations.csv"))
46
47
  Practices::ImportCSV.new(csv_path).call
47
48
  end
48
49
  log "Practice count after update: #{practice_count}"
@@ -9,10 +9,11 @@ module Renalware
9
9
  include Wisper::Publisher
10
10
 
11
11
  def call(raw_message)
12
- message_payload = parse_message(raw_message)
13
- persist_message(message_payload)
14
-
15
- broadcast(:message_processed, message_payload)
12
+ ActiveRecord::Base.transaction do
13
+ message_payload = parse_message(raw_message)
14
+ persist_message(message_payload)
15
+ broadcast(:message_processed, message_payload)
16
+ end
16
17
  rescue StandardError => exception
17
18
  notify_exception(exception)
18
19
  raise exception
@@ -2,6 +2,7 @@ require_dependency "renalware/hd"
2
2
 
3
3
  module Renalware
4
4
  module HD
5
+ # TODO: Document
5
6
  class DiarySlot < ApplicationRecord
6
7
  # Changing to_ary from private to public here is a hack required to remove a SimpleDelgator
7
8
  # warning in eg Renalware::HD::WeeklyDiary::WeeklySlotDecorator:
@@ -26,8 +27,8 @@ module Renalware
26
27
  attr_accessor :change_type
27
28
 
28
29
  include Accountable
29
- belongs_to :diary, class_name: "Renalware::HD::Diary"
30
- belongs_to :patient
30
+ belongs_to :diary, class_name: "Renalware::HD::Diary", touch: true
31
+ belongs_to :patient, touch: true
31
32
  belongs_to :station, class_name: "Renalware::HD::Station"
32
33
  belongs_to :diurnal_period_code
33
34
 
@@ -5,7 +5,7 @@ module Renalware
5
5
  class Archive < ApplicationRecord
6
6
  include Accountable
7
7
 
8
- belongs_to :letter
8
+ belongs_to :letter, touch: true
9
9
 
10
10
  validates :content, presence: true
11
11
  end
@@ -1,18 +1,22 @@
1
1
  require_dependency "renalware/letters"
2
+ require "attr_extras"
2
3
 
3
4
  module Renalware
4
5
  module Letters
5
6
  class CompleteLetter
7
+ include Broadcasting
8
+ pattr_initialize :letter
9
+
6
10
  class << self
7
11
  alias_method :build, :new
8
12
  end
9
13
 
10
- def initialize(letter)
11
- @letter = letter
12
- end
13
-
14
14
  def call(by:)
15
- @letter.complete(by: by).save!
15
+ Letter.transaction do
16
+ @letter = letter.complete(by: by)
17
+ letter.save!
18
+ broadcast(:letter_completed, letter)
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -3,7 +3,7 @@ require_dependency "renalware/letters"
3
3
  module Renalware
4
4
  module Letters
5
5
  class Contact < ApplicationRecord
6
- belongs_to :patient
6
+ belongs_to :patient, touch: true
7
7
  belongs_to :person, class_name: "Directory::Person"
8
8
  belongs_to :description, class_name: "ContactDescription"
9
9
 
@@ -7,7 +7,7 @@ require_dependency "renalware/letters"
7
7
  module Renalware
8
8
  module Letters
9
9
  class ElectronicReceipt < ApplicationRecord
10
- belongs_to :letter
10
+ belongs_to :letter, touch: true
11
11
  belongs_to :recipient, class_name: "Renalware::User"
12
12
  validates :letter, presence: true
13
13
  validates :recipient_id, presence: true
@@ -12,6 +12,9 @@ module Renalware
12
12
 
13
13
  belongs_to :event, polymorphic: true
14
14
  belongs_to :author, class_name: "User"
15
+ belongs_to :submitted_for_approval_by, class_name: "User"
16
+ belongs_to :approved_by, class_name: "User"
17
+ belongs_to :completed_by, class_name: "User"
15
18
  belongs_to :patient, touch: true
16
19
  belongs_to :letterhead
17
20
  has_one :main_recipient,
@@ -10,6 +10,8 @@ module Renalware
10
10
  def complete(by:)
11
11
  becomes!(Completed).tap do |letter|
12
12
  letter.by = by
13
+ letter.completed_by = by
14
+ letter.completed_at = Time.current
13
15
  end
14
16
  end
15
17
  end
@@ -13,7 +13,11 @@ module Renalware
13
13
  end
14
14
 
15
15
  def submit(by:)
16
- becomes!(PendingReview).tap { |letter| letter.by = by }
16
+ becomes!(PendingReview).tap do |letter|
17
+ letter.by = by
18
+ letter.submitted_for_approval_by = by
19
+ letter.submitted_for_approval_at = Time.current
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -18,6 +18,8 @@ module Renalware
18
18
 
19
19
  def sign(by:)
20
20
  build_signature(user: by, signed_at: Time.current)
21
+ self.approved_by = by
22
+ self.approved_at = Time.current
21
23
  self.by = by
22
24
  self
23
25
  end
@@ -2,13 +2,18 @@
2
2
  # 2.5 seconds and a fair chunk of memory to convert html to pdf, so we want to cache generated PDFs
3
3
  # for a period of time.
4
4
  #
5
+ # Note that the cache in question here is not intended to be a canonical archive of PDFs for
6
+ # future reference; it is up to the host application to move the PDFs into EPR folders etc
7
+ # for archiving. This cache could be cleared at any time.
8
+ #
5
9
  # Note that even when checking to see if the PDF exists in the cache, we *always* regenerate at
6
10
  # least the HTML letter content (i.e. the letter content wrapped in a layout) as we want to make
7
- # sure we picking up any view and layout changes (Rails fragment caching could possibly be levered
11
+ # sure we are picking up any view and layout changes (fragment caching could possibly be levered
8
12
  # here as it knows the MD5 of the views and layouts used, and thus might help us to avoid having
9
13
  # to re-render the letter HTML each time - but I have started by taking the less `magical` route
10
14
  # of rendering the entire HTML letter to get its MD5 hash, which is then used in trying to find a
11
- # PDF file cache hit for that filename.
15
+ # PDF file cache hit for that filename).
16
+ #
12
17
  # Note that PDF Letters are stored in the rails cache, which is currently Filestore. If we move
13
18
  # to a multi-server environment we would need to switch to Memcached or Redis, and the PDF files
14
19
  # would be poked into that - using quite a lot of memory I am sure (ag 25k per PDF), so would be
@@ -29,19 +34,28 @@ require_dependency "renalware/letters"
29
34
  module Renalware
30
35
  module Letters
31
36
  class PdfLetterCache
32
- def self.fetch(letter)
33
- Rails.cache.fetch(cache_key_for(letter), expires_in: 1.month) do
34
- yield
37
+ class << self
38
+ def fetch(letter)
39
+ store.fetch(cache_key_for(letter)) { yield }
40
+ end
41
+
42
+ # Note the letter must be a LetterPresenter which has a #to_html method
43
+ # The to_html method should (and does on the LetterPrsenter class) render the complete
44
+ # html including surrounding layout with inline css and images. This way if the
45
+ # layout changes or the image is changed for example, the cache for the pdf is no longer
46
+ # valid and a new key and cache entry will be created.
47
+ def cache_key_for(letter)
48
+ timestamp = letter&.updated_at&.strftime("%Y%m%d%H%M%S")
49
+ "letter-pdf-#{letter.id}-#{timestamp}-#{Digest::MD5.hexdigest(letter.to_html)}"
50
+ end
51
+
52
+ def cache_path
53
+ Rails.root.join("tmp", "pdf_letter_cache")
35
54
  end
36
- end
37
55
 
38
- # Note the letter must be a LetterPresenter which has a #to_html method
39
- # The to_html method should (and does on the LetterPrsenter class) render the complete
40
- # html including surrounding layout with inline css and images. This way if the layout changes
41
- # or the image is changed for example, the cache for the pdf is no longer valid and a new
42
- # key and cache entry will be created.
43
- def self.cache_key_for(letter)
44
- "letter:pdf:#{letter.id}:#{Digest::MD5.hexdigest(letter.to_html)}"
56
+ def store
57
+ @store ||= ActiveSupport::Cache::FileStore.new(cache_path)
58
+ end
45
59
  end
46
60
  end
47
61
  end
@@ -3,8 +3,8 @@ require_dependency "renalware/letters"
3
3
  module Renalware
4
4
  module Letters
5
5
  class Signature < ApplicationRecord
6
- belongs_to :user
7
- belongs_to :letter
6
+ belongs_to :user, touch: true
7
+ belongs_to :letter, touch: true
8
8
 
9
9
  validates :user, presence: true
10
10
  validates :letter, presence: true
@@ -4,7 +4,7 @@ module Renalware
4
4
  module LowClearance
5
5
  class MDMPatientsQuery
6
6
  include ModalityScopes
7
- DEFAULT_SEARCH_PREDICATE = "ure_date ASC".freeze
7
+ DEFAULT_SEARCH_PREDICATE = "hgb_date DESC".freeze
8
8
  attr_reader :query, :relation, :named_filter
9
9
 
10
10
  def initialize(relation: Patient.all, query: nil, named_filter: nil)
@@ -2,6 +2,7 @@ require_dependency "renalware/messaging"
2
2
 
3
3
  module Renalware
4
4
  module Messaging
5
+ # TODO: Document the Internal module
5
6
  module Internal
6
7
  class Author < ActiveType::Record[Renalware::User]
7
8
  has_many :messages
@@ -13,7 +13,7 @@ module Renalware
13
13
  validates :patient, presence: true
14
14
  validates :sent_at, presence: true
15
15
 
16
- belongs_to :patient
16
+ belongs_to :patient # no touch required
17
17
  belongs_to :author
18
18
  end
19
19
  end
@@ -4,7 +4,7 @@ module Renalware
4
4
  module Pathology
5
5
  class MeasurementUnit < ApplicationRecord
6
6
  validates :name, presence: true
7
- has_many :observation_descriptions
7
+ has_many :observation_descriptions, inverse_of: :measurement_unit
8
8
  end
9
9
  end
10
10
  end
@@ -3,8 +3,13 @@ require_dependency "renalware/pathology"
3
3
  module Renalware
4
4
  module Pathology
5
5
  class Observation < ApplicationRecord
6
- belongs_to :request, class_name: "ObservationRequest", touch: true, inverse_of: :observations
7
- belongs_to :description, class_name: "ObservationDescription"
6
+ belongs_to :request,
7
+ class_name: "ObservationRequest",
8
+ touch: true,
9
+ inverse_of: :observations
10
+ belongs_to :description,
11
+ class_name: "ObservationDescription",
12
+ inverse_of: :observations
8
13
 
9
14
  validates :description, presence: true
10
15
  validates :result, presence: true, unless: ->(obs) { obs.cancelled? }
@@ -3,9 +3,15 @@ require_dependency "renalware/pathology"
3
3
  module Renalware
4
4
  module Pathology
5
5
  class ObservationDescription < ApplicationRecord
6
+ has_many :observations,
7
+ class_name: "Pathology::Observation",
8
+ inverse_of: :description
6
9
  belongs_to :measurement_unit
7
- validates :display_order, uniqueness: { allow_nil: true }
8
- validates :display_order_letters, uniqueness: { allow_nil: true }
10
+
11
+ scope :in_display_order, lambda {
12
+ where("display_group is not null and display_order is not null")
13
+ .order([:display_group, :display_order])
14
+ }
9
15
 
10
16
  def self.for(codes)
11
17
  ObservationDescriptionsByCodeQuery.new(codes: codes).call
@@ -7,7 +7,7 @@ module Renalware
7
7
  foreign_key: :request_id,
8
8
  inverse_of: :request,
9
9
  dependent: :destroy
10
- belongs_to :description, class_name: "RequestDescription"
10
+ belongs_to :description, class_name: "RequestDescription", inverse_of: :requests
11
11
  belongs_to :patient, class_name: "Patient", touch: true
12
12
 
13
13
  accepts_nested_attributes_for :observations
@@ -17,9 +17,6 @@ module Renalware
17
17
  validates :requested_at, presence: true
18
18
 
19
19
  scope :ordered, -> { order(requested_at: :desc) }
20
- scope :having_observations_with_a_loinc_code, lambda {
21
- joins(observations: :description).where("loinc_code is not null") # TODO: use a merge
22
- }
23
20
 
24
21
  def requested_on
25
22
  requested_at.to_date
@@ -9,7 +9,7 @@ module Renalware
9
9
  validates :patient, presence: true
10
10
  validates :notes, presence: true
11
11
 
12
- belongs_to :patient
12
+ belongs_to :patient, touch: true
13
13
  end
14
14
  end
15
15
  end
@@ -6,6 +6,7 @@ module Renalware
6
6
  acts_as_paranoid
7
7
 
8
8
  belongs_to :user, class_name: "Renalware::Patients::User", foreign_key: :user_id
9
+ # No touch required on patient
9
10
  belongs_to :patient, class_name: "Renalware::Patient", foreign_key: :patient_id
10
11
 
11
12
  validates :patient, presence: true
@@ -6,7 +6,10 @@ module Renalware
6
6
  include Accountable
7
7
  has_paper_trail class_name: "Renalware::Patients::Version"
8
8
 
9
- belongs_to :patient, class_name: "Renalware::Patient", foreign_key: :patient_id
9
+ belongs_to :patient,
10
+ class_name: "Renalware::Patient",
11
+ foreign_key: :patient_id,
12
+ touch: true
10
13
 
11
14
  validates :patient, presence: true, uniqueness: true
12
15
  end
@@ -6,7 +6,8 @@ module Renalware
6
6
  belongs_to :peritonitis_episode_type_description,
7
7
  class_name: "PD::PeritonitisEpisodeTypeDescription"
8
8
  belongs_to :peritonitis_episode,
9
- class_name: "PD::PeritonitisEpisode"
9
+ class_name: "PD::PeritonitisEpisode",
10
+ touch: true
10
11
  end
11
12
  end
12
13
  end
@@ -14,7 +14,7 @@ module Renalware
14
14
  before_save :assign_days_per_week
15
15
 
16
16
  belongs_to :bag_type
17
- belongs_to :regime
17
+ belongs_to :regime, touch: true
18
18
 
19
19
  validates :bag_type, presence: true
20
20
  validates :volume, presence: true
@@ -5,7 +5,7 @@ module Renalware
5
5
  class AKIAlert < ApplicationRecord
6
6
  include Accountable
7
7
  scope :ordered, ->{ order(created_at: :desc) }
8
- belongs_to :patient, class_name: "Renal::Patient"
8
+ belongs_to :patient, class_name: "Renal::Patient", touch: true
9
9
  belongs_to :action, class_name: "Renal::AKIAlertAction"
10
10
  belongs_to :hospital_ward, class_name: "Hospitals::Ward"
11
11
  validates :patient, presence: true
@@ -11,9 +11,12 @@ module Renalware
11
11
  validates :started_on, timeliness: { type: :date, allow_blank: true }
12
12
  validates :terminated_on, timeliness: { type: :date, allow_blank: true, after: :started_on }
13
13
 
14
- scope :ordered, -> { order(created_at: :asc) }
14
+ scope :ordered, -> { order(code: :asc) }
15
15
 
16
- has_many :participants, class_name: "StudyParticipant", dependent: :destroy
16
+ has_many :participants,
17
+ class_name: "StudyParticipant",
18
+ dependent: :destroy,
19
+ inverse_of: :study
17
20
  end
18
21
  end
19
22
  end
@@ -7,8 +7,11 @@ module Renalware
7
7
  acts_as_paranoid
8
8
  validates :participant_id, presence: true, uniqueness: { scope: :study }
9
9
  validates :study, presence: true
10
- belongs_to :study
11
- belongs_to :patient, class_name: "Renalware::Patient", foreign_key: :participant_id
10
+ belongs_to :study, touch: true
11
+ belongs_to :patient,
12
+ class_name: "Renalware::Patient",
13
+ foreign_key: :participant_id,
14
+ touch: true
12
15
 
13
16
  def to_s
14
17
  patient&.to_s
@@ -16,15 +19,3 @@ module Renalware
16
19
  end
17
20
  end
18
21
  end
19
- # include Accountable
20
- # acts_as_paranoid
21
-
22
- # validates :code, presence: true
23
- # validates :description, presence: true
24
- # validates :started_on, timeliness: { type: :date, allow_blank: true }
25
- # validates :terminated_on, timeliness: { type: :date, allow_blank: true, after: :started_on }
26
-
27
- # scope :ordered, -> { order(created_at: :asc) }
28
- # end
29
- # end
30
- # end