renalware-core 2.0.40 → 2.0.41

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c3d9338a0d4d5c869623f1f05fae525bb69315935feaa19bcb144a6816c2bd5
4
- data.tar.gz: 6b0726dc261af4365e1fc62a01103e98d57c0569276b8269ccf547bdac0ece5b
3
+ metadata.gz: 4028a0511b757d40f892d8b53f96aad528c613903b72b565cdb3aaba0fb24475
4
+ data.tar.gz: 15c5b296ecf7ae47466c7e33480146b3cf00a6dfe88a4c3da0fc6e0dd1a40714
5
5
  SHA512:
6
- metadata.gz: 169887f515113d57a0af78685994267dc4d64621b2d03fc6d8ea6661f6baf64f567cb147f9b76fa98d13d180450523fc68da58118b984574e3eac8e26b48481b
7
- data.tar.gz: '0859821f1051c9cf0fe83f73c8e9fb5a691e819a0e1a9068a35a0bdd07d0910f354c007e7fa5fa9f848fe203c8b084f869d0bee8a398522bd11c8e492e2e9353'
6
+ metadata.gz: 4415c46fd5f27d2b770675aff7c2fe215605b3a538702a6ef605a0c89f62e15a02bd2cbf733333a3a2a4096450049b9b51e60caf0979c98d4c0d59c0df7e583f
7
+ data.tar.gz: fd3490bad516d1d04f5fb2c384537b83acc1d5c79fd8d4cc0aec949452dc3f62716ce7ce5839e780bf1c9e4efce7c70db365ba58d1c0a18a221be13ef0efa57d
@@ -21,8 +21,28 @@ module Renalware
21
21
  }
22
22
  end
23
23
 
24
+ def new
25
+ render_new(Appointment.new)
26
+ end
27
+
28
+ def create
29
+ appointment = Appointment.new(appointment_params)
30
+ appointment.user = current_user
31
+ authorize appointment
32
+ if appointment.save
33
+ redirect_to appointments_path, notice: t(".success", model_name: "Appointment")
34
+ else
35
+ render_new(appointment)
36
+ end
37
+ end
38
+
24
39
  private
25
40
 
41
+ def render_new(appointment)
42
+ authorize appointment
43
+ render :new, locals: { appointment: appointment }
44
+ end
45
+
26
46
  def build_params_for_html_form(appointments)
27
47
  OpenStruct.new(
28
48
  patient_ids: appointments.map(&:patient_id).uniq
@@ -34,6 +54,12 @@ module Renalware
34
54
  .fetch(:q, {})
35
55
  .merge(page: page, per_page: per_page)
36
56
  end
57
+
58
+ def appointment_params
59
+ params
60
+ .require(:clinics_appointment)
61
+ .permit(:patient_id, :clinic_id, :starts_at)
62
+ end
37
63
  end
38
64
  end
39
65
  end
@@ -10,8 +10,8 @@ module Renalware
10
10
  belongs_to :user
11
11
 
12
12
  validates :starts_at, presence: true
13
- validates :patient, presence: true
14
- validates :clinic, presence: true
13
+ validates :patient_id, presence: true
14
+ validates :clinic_id, presence: true
15
15
  validates :user, presence: true
16
16
 
17
17
  validates :starts_at, timeliness: { type: :datetime }
@@ -13,7 +13,11 @@ module Renalware
13
13
  has_paper_trail class_name: "Renalware::Medications::PrescriptionVersion"
14
14
 
15
15
  belongs_to :patient, touch: true
16
- belongs_to :drug, class_name: "Renalware::Drugs::Drug"
16
+
17
+ # A drug can be soft-deleted (its deleted_at set) so that it can no longer be prescribed.
18
+ # We need to be sure we can still display deleted drugs in the read-only context of an
19
+ # existing prescription, so we include deleted drugs in the relationship.
20
+ belongs_to :drug, -> { with_deleted }, class_name: "Renalware::Drugs::Drug"
17
21
  belongs_to :treatable, polymorphic: true
18
22
  belongs_to :medication_route
19
23
 
@@ -6,7 +6,7 @@ module Renalware
6
6
  def self.call(params)
7
7
  Renalware::Patient
8
8
  .includes(current_modality: [:description])
9
- .search(params[:q]).tap do |search|
9
+ .search(params[:patient_search]).tap do |search|
10
10
  search.sorts = %w(family_name given_name)
11
11
  end
12
12
  end
@@ -1,3 +1,8 @@
1
+ = content_for(:actions) do
2
+ = link_to "Add",
3
+ new_appointment_path,
4
+ class: "button"
5
+
1
6
  = within_admin_layout(title: "Upcoming Clinic Visit Appointments") do
2
7
 
3
8
  .search-form.filters
@@ -70,8 +75,7 @@
70
75
 
71
76
  td= I18n.l appointment.starts_on
72
77
  td= appointment.start_time
73
- td= link_to appointment.patient.full_name,
74
- patient_clinical_summary_path(patient_id: appointment.patient)
78
+ td= default_patient_link(appointment.patient)
75
79
  td= appointment.patient.sex.code
76
80
  td= appointment.patient.age
77
81
  td= appointment.patient.current_modality
@@ -0,0 +1,29 @@
1
+ = within_admin_layout(title: "New",
2
+ breadcrumbs: breadcrumb_for("Clinic Appointments", appointments_path)) do
3
+
4
+ = simple_form_for appointment,
5
+ url: appointments_path,
6
+ method: :post,
7
+ html: { autocomplete: "off" },
8
+ wrapper: "horizontal_form" do |f|
9
+
10
+ / Note the shenanigans to get the select2 to redisplay the patient after a validation error
11
+ / or on an edit. Selected: 1 means just select the option at index 1 - option at index 0 is always
12
+ / the blank option. Selecting index 1 fails silently if there is nothing there (no patient
13
+ / selected yet) otherwise it will display the selected patient who will always be
14
+ / at option index 1.
15
+ = f.input :patient_id,
16
+ wrapper: :horizontal_medium,
17
+ collection: [[appointment.patient&.to_s(:long), appointment.patient&.id]],
18
+ selected: 1,
19
+ input_html: { \
20
+ class: "patient-id-select2 patient-ajax-search",
21
+ data: { "ajax--url" => search_patients_path(format: :json),
22
+ placeholder: "Search by patient name or hospital/NHS no." } \
23
+ }
24
+
25
+ = f.input :clinic_id,
26
+ collection: Renalware::Clinics::Clinic.all,
27
+ wrapper: :horizontal_medium
28
+ = f.input :starts_at, as: :datetime_picker, wrapper: :horizontal_datepicker
29
+ = f.submit class: :button
@@ -3,6 +3,7 @@
3
3
  li.has-form
4
4
  = search_form_for the_patient_search,
5
5
  url: patients_path,
6
+ as: :patient_search,
6
7
  class: "patient-search-form" do |f|
7
8
  .row.collapse
8
9
  .columns.small-12
data/config/routes.rb CHANGED
@@ -115,7 +115,7 @@ Renalware::Engine.routes.draw do
115
115
  resource :worryboard, only: :show, controller: "patients/worryboard"
116
116
 
117
117
  # Clinics
118
- resources :appointments, controller: "clinics/appointments", only: [:index]
118
+ resources :appointments, controller: "clinics/appointments", only: [:new, :create, :index]
119
119
  resources :clinic_visits, only: :index, controller: "clinics/visits"
120
120
 
121
121
  resources :deaths, only: :index, as: :patient_deaths
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.40"
4
+ VERSION = "2.0.41"
5
5
  end
@@ -12,4 +12,36 @@ module Select2SpecHelper
12
12
  matches = body.find_all(".select2-results li", text: value)
13
13
  matches.last.click
14
14
  end
15
+
16
+ # select2_ajax helper to make capybara work with ajax-enabled Select2 elements
17
+ # assumes 'placeholder' option is used in Select2 (if it is using ajax, it should be)
18
+ #
19
+ # usage:
20
+ #
21
+ # it "should have a select2 field for searching by team name" do
22
+ # @team = Factory :team
23
+ # select2_ajax @team.name, from: "Select a Team", minlength: 4
24
+ # click_button "Join"
25
+ # page.should have_content "You are now on '#{@team.name}'."
26
+ # end
27
+ # Thx to https://gist.github.com/sbeam/3849340
28
+ def select2_ajax(value, options = {})
29
+ if !options.is_a?(Hash) || !options.key?(:from)
30
+ raise "Must pass a hash containing 'from'"
31
+ end
32
+
33
+ placeholder = options[:from]
34
+ minlength = options[:minlength] || 4
35
+
36
+ # click_link placeholder
37
+
38
+ page.find(:xpath, "//*[text()='#{placeholder}']").click
39
+
40
+ js = %Q|container = $('.select2-container:contains("#{placeholder}")');
41
+ $('input[type=text]', container).val('#{value[0, minlength]}').trigger('keyup');
42
+ window.setTimeout( function() {
43
+ $('li:contains("#{value}")', container).click();
44
+ }, 5000);|
45
+ page.execute_script(js)
46
+ end
15
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.40
4
+ version: 2.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-11 00:00:00.000000000 Z
11
+ date: 2018-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -2058,6 +2058,7 @@ files:
2058
2058
  - app/views/renalware/clinical/profiles/edit.html.slim
2059
2059
  - app/views/renalware/clinical/profiles/show.html.slim
2060
2060
  - app/views/renalware/clinics/appointments/index.html.slim
2061
+ - app/views/renalware/clinics/appointments/new.html.slim
2061
2062
  - app/views/renalware/clinics/clinic_visits/_clinic_visit.html.slim
2062
2063
  - app/views/renalware/clinics/clinic_visits/_form.html.slim
2063
2064
  - app/views/renalware/clinics/clinic_visits/_table.html.slim