renalware-core 2.0.69 → 2.0.70
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 +4 -4
 - data/app/controllers/renalware/events/events_controller.rb +61 -22
 - data/app/controllers/renalware/session_timeout_controller.rb +1 -0
 - data/app/helpers/renalware/application_helper.rb +1 -1
 - data/app/jobs/renalware/events/save_pdf_event_to_file_job.rb +30 -0
 - data/app/models/renalware/events/create_event.rb +28 -0
 - data/app/models/renalware/events/update_event.rb +27 -0
 - data/app/models/renalware/patient.rb +2 -1
 - data/app/pdfs/renalware/events/event_pdf.rb +124 -0
 - data/app/presenters/renalware/events/event_pdf_presenter.rb +30 -0
 - data/app/presenters/renalware/ukrdc/patient_presenter.rb +2 -1
 - data/app/views/renalware/accesses/plans/new.html.slim +2 -1
 - data/app/views/renalware/admissions/requests/_form.html.slim +1 -1
 - data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +1 -1
 - data/app/views/renalware/api/ukrdc/patients/lab_orders/_result_item.xml.builder +20 -14
 - data/app/views/renalware/events/events/show.pdf.slim +9 -0
 - data/app/views/renalware/hd/preference_sets/_form.html.slim +2 -1
 - data/app/views/renalware/letters/letters/_form.html.slim +1 -1
 - data/app/views/renalware/modalities/modalities/new.html.slim +2 -1
 - data/app/views/renalware/patients/patients/_form.html.slim +1 -1
 - data/app/views/renalware/pd/regimes/_form.html.slim +2 -1
 - data/app/views/renalware/pd/training_sessions/_form.html.slim +2 -1
 - data/app/views/renalware/problems/notes/_form.html.slim +1 -1
 - data/app/views/renalware/problems/problems/edit.html.slim +1 -1
 - data/app/views/renalware/problems/problems/new.html.slim +1 -1
 - data/app/views/renalware/renal/profiles/_form.html.slim +3 -1
 - data/config/initializers/delayed_job.rb +1 -1
 - data/config/initializers/renalware.rb +4 -2
 - data/config/routes.rb +3 -0
 - data/db/migrate/20190218142207_add_filename_prefix_to_event_types.rb +6 -0
 - data/db/migrate/20190225103005_add_info_to_hospital_centres.rb +7 -0
 - data/lib/renalware/engine.rb +1 -0
 - data/lib/renalware/version.rb +1 -1
 - data/lib/tasks/db.rake +1 -1
 - metadata +24 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 352f76d3ec23a7f2706d34b5852d8ce258815e6cc22715b67a27a568d7eb689c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9ad9a5a56ada56b791d0890d952948f978a5bf76eb3311458ce157803409b588
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8085fb62067b61c714387e07d4be44525fdd133deb3a80ff7d41784b7ac6ebeff9c6a8e56ad87252a13c7069a9105bcf16a1c7a71729ef26214cd717ec0ac743
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e81d0c7a65bf99133e0ca5097b9680f9524beed3489087047ac8254a59aa4caace983ff538774667329acc8a6913090defdd4eafd1c2447b03c9badad7944a73
         
     | 
| 
         @@ -2,35 +2,40 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            # rubocop:disable Metrics/ClassLength
         
     | 
| 
       4 
4 
     | 
    
         
             
            require_dependency "renalware/events"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "attr_extras"
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            module Renalware
         
     | 
| 
       7 
8 
     | 
    
         
             
              module Events
         
     | 
| 
       8 
9 
     | 
    
         
             
                class EventsController < BaseController
         
     | 
| 
       9 
10 
     | 
    
         
             
                  include Renalware::Concerns::Pageable
         
     | 
| 
      
 11 
     | 
    
         
            +
                  include Renalware::Concerns::PdfRenderable
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  # Render a PDF of the event
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def show
         
     | 
| 
      
 15 
     | 
    
         
            +
                    event = load_and_authorize_event_for_edit_or_update
         
     | 
| 
      
 16 
     | 
    
         
            +
                    respond_to do |format|
         
     | 
| 
      
 17 
     | 
    
         
            +
                      format.pdf do
         
     | 
| 
      
 18 
     | 
    
         
            +
                        pdf = EventPdf.new(EventPdfPresenter.new(event))
         
     | 
| 
      
 19 
     | 
    
         
            +
                        send_data pdf.render, type: "application/pdf", disposition: "inline"
         
     | 
| 
      
 20 
     | 
    
         
            +
                      end
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
       10 
23 
     | 
    
         | 
| 
       11 
24 
     | 
    
         
             
                  # HTML GET when rendering the new form
         
     | 
| 
       12 
25 
     | 
    
         
             
                  # JS GET after user selects event type, prompting us to return event-specific form fields
         
     | 
| 
       13 
26 
     | 
    
         
             
                  def new
         
     | 
| 
       14 
27 
     | 
    
         
             
                    save_path_to_return_to
         
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
       16 
     | 
    
         
            -
                      patient: patient,
         
     | 
| 
       17 
     | 
    
         
            -
                      event: build_new_event,
         
     | 
| 
       18 
     | 
    
         
            -
                      event_types: event_types
         
     | 
| 
       19 
     | 
    
         
            -
                    }
         
     | 
| 
      
 28 
     | 
    
         
            +
                    render_new(build_new_event)
         
     | 
| 
       20 
29 
     | 
    
         
             
                  end
         
     | 
| 
       21 
30 
     | 
    
         | 
| 
       22 
31 
     | 
    
         
             
                  def create
         
     | 
| 
       23 
32 
     | 
    
         
             
                    event = new_event_for_patient(event_params)
         
     | 
| 
       24 
33 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                    if  
     | 
| 
      
 34 
     | 
    
         
            +
                    if CreateEvent.call(event: event, by: current_user)
         
     | 
| 
       26 
35 
     | 
    
         
             
                      redirect_to return_url, notice: t(".success", model_name: "event")
         
     | 
| 
       27 
36 
     | 
    
         
             
                    else
         
     | 
| 
       28 
37 
     | 
    
         
             
                      flash.now[:error] = t(".failed", model_name: "event")
         
     | 
| 
       29 
     | 
    
         
            -
                       
     | 
| 
       30 
     | 
    
         
            -
                        patient: patient,
         
     | 
| 
       31 
     | 
    
         
            -
                        event: event,
         
     | 
| 
       32 
     | 
    
         
            -
                        event_types: event_types
         
     | 
| 
       33 
     | 
    
         
            -
                      }
         
     | 
| 
      
 38 
     | 
    
         
            +
                      render_new(event)
         
     | 
| 
       34 
39 
     | 
    
         
             
                    end
         
     | 
| 
       35 
40 
     | 
    
         
             
                  end
         
     | 
| 
       36 
41 
     | 
    
         | 
| 
         @@ -47,29 +52,43 @@ module Renalware 
     | 
|
| 
       47 
52 
     | 
    
         
             
                  end
         
     | 
| 
       48 
53 
     | 
    
         | 
| 
       49 
54 
     | 
    
         
             
                  def edit
         
     | 
| 
       50 
     | 
    
         
            -
                     
     | 
| 
       51 
     | 
    
         
            -
                      patient: patient,
         
     | 
| 
       52 
     | 
    
         
            -
                      event: load_and_authorize_event_for_edit_or_update,
         
     | 
| 
       53 
     | 
    
         
            -
                      event_types: []
         
     | 
| 
       54 
     | 
    
         
            -
                    }
         
     | 
| 
      
 55 
     | 
    
         
            +
                    render_edit(load_and_authorize_event_for_edit_or_update)
         
     | 
| 
       55 
56 
     | 
    
         
             
                  end
         
     | 
| 
       56 
57 
     | 
    
         | 
| 
       57 
58 
     | 
    
         
             
                  def update
         
     | 
| 
       58 
59 
     | 
    
         
             
                    event = load_and_authorize_event_for_edit_or_update
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    if UpdateEvent.call(event: event, params: event_params, by: current_user)
         
     | 
| 
       60 
62 
     | 
    
         
             
                      redirect_to return_url, notice: t(".success", model_name: "event")
         
     | 
| 
       61 
63 
     | 
    
         
             
                    else
         
     | 
| 
       62 
64 
     | 
    
         
             
                      flash.now[:error] = failed_msg_for("event type")
         
     | 
| 
       63 
     | 
    
         
            -
                       
     | 
| 
       64 
     | 
    
         
            -
                        patient: patient,
         
     | 
| 
       65 
     | 
    
         
            -
                        event: event,
         
     | 
| 
       66 
     | 
    
         
            -
                        event_types: []
         
     | 
| 
       67 
     | 
    
         
            -
                      }
         
     | 
| 
      
 65 
     | 
    
         
            +
                      render_edit(event)
         
     | 
| 
       68 
66 
     | 
    
         
             
                    end
         
     | 
| 
       69 
67 
     | 
    
         
             
                  end
         
     | 
| 
       70 
68 
     | 
    
         | 
| 
      
 69 
     | 
    
         
            +
                  def destroy
         
     | 
| 
      
 70 
     | 
    
         
            +
                    load_and_authorize_event_for_edit_or_update.destroy!
         
     | 
| 
      
 71 
     | 
    
         
            +
                    redirect_to patient_events_path
         
     | 
| 
      
 72 
     | 
    
         
            +
                  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
       71 
74 
     | 
    
         
             
                  protected
         
     | 
| 
       72 
75 
     | 
    
         | 
| 
      
 76 
     | 
    
         
            +
                  def render_new(event)
         
     | 
| 
      
 77 
     | 
    
         
            +
                    render :new, locals: {
         
     | 
| 
      
 78 
     | 
    
         
            +
                      patient: patient,
         
     | 
| 
      
 79 
     | 
    
         
            +
                      event: event,
         
     | 
| 
      
 80 
     | 
    
         
            +
                      event_types: event_types
         
     | 
| 
      
 81 
     | 
    
         
            +
                    }
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  def render_edit(event)
         
     | 
| 
      
 85 
     | 
    
         
            +
                    render :edit, locals: {
         
     | 
| 
      
 86 
     | 
    
         
            +
                      patient: patient,
         
     | 
| 
      
 87 
     | 
    
         
            +
                      event: event,
         
     | 
| 
      
 88 
     | 
    
         
            +
                      event_types: []
         
     | 
| 
      
 89 
     | 
    
         
            +
                    }
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
       73 
92 
     | 
    
         
             
                  def save_path_to_return_to
         
     | 
| 
       74 
93 
     | 
    
         
             
                    return unless request.format == :html
         
     | 
| 
       75 
94 
     | 
    
         | 
| 
         @@ -169,6 +188,26 @@ module Renalware 
     | 
|
| 
       169 
188 
     | 
    
         
             
                    end
         
     | 
| 
       170 
189 
     | 
    
         
             
                  end
         
     | 
| 
       171 
190 
     | 
    
         | 
| 
      
 191 
     | 
    
         
            +
                  # Returns an array of objects defininig each category, with that category's types within it.
         
     | 
| 
      
 192 
     | 
    
         
            +
                  # rubocop:disable Metrics/MethodLength
         
     | 
| 
      
 193 
     | 
    
         
            +
                  def event_types_new
         
     | 
| 
      
 194 
     | 
    
         
            +
                    Events::Category.order(:position).map do |category|
         
     | 
| 
      
 195 
     | 
    
         
            +
                      types = category.types.order(:name).map do |event_type|
         
     | 
| 
      
 196 
     | 
    
         
            +
                        [
         
     | 
| 
      
 197 
     | 
    
         
            +
                          event_type.name,
         
     | 
| 
      
 198 
     | 
    
         
            +
                          event_type.id,
         
     | 
| 
      
 199 
     | 
    
         
            +
                          {
         
     | 
| 
      
 200 
     | 
    
         
            +
                            data: {
         
     | 
| 
      
 201 
     | 
    
         
            +
                              source: new_patient_event_path(patient, event_type_id: event_type.id, format: :js)
         
     | 
| 
      
 202 
     | 
    
         
            +
                            }
         
     | 
| 
      
 203 
     | 
    
         
            +
                          }
         
     | 
| 
      
 204 
     | 
    
         
            +
                        ]
         
     | 
| 
      
 205 
     | 
    
         
            +
                      end
         
     | 
| 
      
 206 
     | 
    
         
            +
                      OpenStruct.new(name: category.name, id: category.id, types: types)
         
     | 
| 
      
 207 
     | 
    
         
            +
                    end
         
     | 
| 
      
 208 
     | 
    
         
            +
                  end
         
     | 
| 
      
 209 
     | 
    
         
            +
                  # rubocop:enable Metrics/MethodLength
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
       172 
211 
     | 
    
         
             
                  def query_params
         
     | 
| 
       173 
212 
     | 
    
         
             
                    params.fetch(:q, {})
         
     | 
| 
       174 
213 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -13,6 +13,7 @@ module Renalware 
     | 
|
| 
       13 
13 
     | 
    
         
             
              class SessionTimeoutController < BaseController
         
     | 
| 
       14 
14 
     | 
    
         
             
                prepend_before_action :skip_timeout, only: :has_user_timed_out
         
     | 
| 
       15 
15 
     | 
    
         
             
                skip_before_action :authenticate_user!, only: :has_user_timed_out
         
     | 
| 
      
 16 
     | 
    
         
            +
                skip_before_action :track_ahoy_visit, only: :has_user_timed_out
         
     | 
| 
       16 
17 
     | 
    
         
             
                protect_from_forgery except: [:has_user_timed_out, :reset_user_clock]
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
       18 
19 
     | 
    
         
             
                # Note this action will NOT update the session activity (thus keeping the session alive)
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "renalware/events"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "fileutils"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Renalware
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Events
         
     | 
| 
      
 8 
     | 
    
         
            +
                # Used for example in a host app like renalware-kch to generate a PDF event for saving to
         
     | 
| 
      
 9 
     | 
    
         
            +
                # the electronic public register
         
     | 
| 
      
 10 
     | 
    
         
            +
                class SavePdfEventToFileJob < ApplicationJob
         
     | 
| 
      
 11 
     | 
    
         
            +
                  queue_as :pdf_generation
         
     | 
| 
      
 12 
     | 
    
         
            +
                  queue_with_priority 1
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  def perform(event:, file_path:)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    file_path = Pathname(file_path)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    create_folder_if_not_exists(file_path)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    File.open(file_path, "wb") { |file| file << pdf_data_for(event) }
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def pdf_data_for(event)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    decorated_event = EventPdfPresenter.new(event)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    EventPdf.new(decorated_event).render
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def create_folder_if_not_exists(path)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    FileUtils.mkdir_p(path.dirname)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "renalware/events"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "attr_extras"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Renalware
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Events
         
     | 
| 
      
 8 
     | 
    
         
            +
                # A wrapper around the creation of an Event to allow is to broadcast a Wisper event to the
         
     | 
| 
      
 9 
     | 
    
         
            +
                # 'world' (or rather just whoever has been configured in the broadcast subscription map).
         
     | 
| 
      
 10 
     | 
    
         
            +
                class CreateEvent
         
     | 
| 
      
 11 
     | 
    
         
            +
                  include Broadcasting
         
     | 
| 
      
 12 
     | 
    
         
            +
                  pattr_initialize [:event!, :by!]
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  # Returns the boolean result of event.save_by
         
     | 
| 
      
 15 
     | 
    
         
            +
                  def self.call(**args)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    new(**args)
         
     | 
| 
      
 17 
     | 
    
         
            +
                      .broadcasting_to_configured_subscribers
         
     | 
| 
      
 18 
     | 
    
         
            +
                      .call
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  def call
         
     | 
| 
      
 22 
     | 
    
         
            +
                    event.save_by(by).tap do |success|
         
     | 
| 
      
 23 
     | 
    
         
            +
                      broadcast(:event_created, event) if success
         
     | 
| 
      
 24 
     | 
    
         
            +
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "renalware/events"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Renalware
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Events
         
     | 
| 
      
 7 
     | 
    
         
            +
                # A wrapper around the updating of an Event to allow is to broadcast a Wisper event to anyone
         
     | 
| 
      
 8 
     | 
    
         
            +
                # configure to listen in the broadcast subscription map.
         
     | 
| 
      
 9 
     | 
    
         
            +
                class UpdateEvent
         
     | 
| 
      
 10 
     | 
    
         
            +
                  include Broadcasting
         
     | 
| 
      
 11 
     | 
    
         
            +
                  pattr_initialize [:event!, :params!, :by!]
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  # Returns the boolean result of event.update_by
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def self.call(**args)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    new(**args)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      .broadcasting_to_configured_subscribers
         
     | 
| 
      
 17 
     | 
    
         
            +
                      .call
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  def call
         
     | 
| 
      
 21 
     | 
    
         
            +
                    event.update_by(by, params).tap do |success|
         
     | 
| 
      
 22 
     | 
    
         
            +
                      broadcast(:event_updated, event) if success
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -120,9 +120,10 @@ module Renalware 
     | 
|
| 
       120 
120 
     | 
    
         
             
                def to_s(format = :default)
         
     | 
| 
       121 
121 
     | 
    
         
             
                  title_suffix = " (#{title})" if has_title?
         
     | 
| 
       122 
122 
     | 
    
         
             
                  formatted_name = "#{family_name.upcase}, #{given_name}#{title_suffix}"
         
     | 
| 
      
 123 
     | 
    
         
            +
                  formatted_nhs_number = " (#{nhs_number})" if nhs_number.present?
         
     | 
| 
       123 
124 
     | 
    
         
             
                  case format
         
     | 
| 
       124 
125 
     | 
    
         
             
                  when :default then formatted_name
         
     | 
| 
       125 
     | 
    
         
            -
                  when :long then "#{formatted_name} 
     | 
| 
      
 126 
     | 
    
         
            +
                  when :long then "#{formatted_name}#{formatted_nhs_number}"
         
     | 
| 
       126 
127 
     | 
    
         
             
                  else full_name
         
     | 
| 
       127 
128 
     | 
    
         
             
                  end
         
     | 
| 
       128 
129 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,124 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "renalware/events"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
      
 6 
     | 
    
         
            +
            module Renalware
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Events
         
     | 
| 
      
 8 
     | 
    
         
            +
                # We have used wicked_pdf (which shells out to wkhtmltopdf) up to know, but using prawn here
         
     | 
| 
      
 9 
     | 
    
         
            +
                # as it Event PDFs are somewhat simpler, and there is no extant html equivalent we can render.
         
     | 
| 
      
 10 
     | 
    
         
            +
                # Its also a useful test to see if this is a better approach all round. It is certainly much
         
     | 
| 
      
 11 
     | 
    
         
            +
                # quicker and less resource intensive to create the PDFs.
         
     | 
| 
      
 12 
     | 
    
         
            +
                class EventPdf
         
     | 
| 
      
 13 
     | 
    
         
            +
                  include Prawn::View
         
     | 
| 
      
 14 
     | 
    
         
            +
                  attr_reader :event
         
     | 
| 
      
 15 
     | 
    
         
            +
                  delegate :patient, :event_type, to: :event
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  def initialize(event)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @event = event
         
     | 
| 
      
 19 
     | 
    
         
            +
                    build
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  def build
         
     | 
| 
      
 23 
     | 
    
         
            +
                    render_hospital_centre_info
         
     | 
| 
      
 24 
     | 
    
         
            +
                    render_patient_identifiers
         
     | 
| 
      
 25 
     | 
    
         
            +
                    render_common_event_fields
         
     | 
| 
      
 26 
     | 
    
         
            +
                    render_specific_event_fields(event.document)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    render_notes
         
     | 
| 
      
 28 
     | 
    
         
            +
                    self
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def render_header
         
     | 
| 
      
 32 
     | 
    
         
            +
                    font_size 12
         
     | 
| 
      
 33 
     | 
    
         
            +
                    text title
         
     | 
| 
      
 34 
     | 
    
         
            +
                    move_down 10
         
     | 
| 
      
 35 
     | 
    
         
            +
                    text event.patient.to_s, style: :bold
         
     | 
| 
      
 36 
     | 
    
         
            +
                    move_down 10
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def render_patient_identifiers
         
     | 
| 
      
 40 
     | 
    
         
            +
                    move_cursor_to 675
         
     | 
| 
      
 41 
     | 
    
         
            +
                    font_size 10
         
     | 
| 
      
 42 
     | 
    
         
            +
                    bounding_box([0, cursor], width: 340) do
         
     | 
| 
      
 43 
     | 
    
         
            +
                      render_header
         
     | 
| 
      
 44 
     | 
    
         
            +
                      font_size 10
         
     | 
| 
      
 45 
     | 
    
         
            +
                      text "DOB: #{I18n.l(patient.born_on)}"
         
     | 
| 
      
 46 
     | 
    
         
            +
                      text "NHS: #{patient.nhs_number}"
         
     | 
| 
      
 47 
     | 
    
         
            +
                      patient.hospital_identifiers.all.each do |key, value|
         
     | 
| 
      
 48 
     | 
    
         
            +
                        text "#{key}: #{value}"
         
     | 
| 
      
 49 
     | 
    
         
            +
                      end
         
     | 
| 
      
 50 
     | 
    
         
            +
                      move_down 10
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  def render_common_event_fields
         
     | 
| 
      
 55 
     | 
    
         
            +
                    text "Date: #{I18n.l(event.date_time)}"
         
     | 
| 
      
 56 
     | 
    
         
            +
                    move_down 10
         
     | 
| 
      
 57 
     | 
    
         
            +
                    if event.respond_to?(:description)
         
     | 
| 
      
 58 
     | 
    
         
            +
                      text "<u>Description</u>", inline_format: true
         
     | 
| 
      
 59 
     | 
    
         
            +
                      move_down 5
         
     | 
| 
      
 60 
     | 
    
         
            +
                      text event.description
         
     | 
| 
      
 61 
     | 
    
         
            +
                      move_down 10
         
     | 
| 
      
 62 
     | 
    
         
            +
                    end
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  def render_specific_event_fields(document)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    document.attributes.each do |name, value|
         
     | 
| 
      
 67 
     | 
    
         
            +
                      # could handle recursive documents here but none exists ATM even in HEROIC
         
     | 
| 
      
 68 
     | 
    
         
            +
                      text "#{document.class.human_attribute_name(name)}:    #{value}"
         
     | 
| 
      
 69 
     | 
    
         
            +
                    end
         
     | 
| 
      
 70 
     | 
    
         
            +
                    move_down 10
         
     | 
| 
      
 71 
     | 
    
         
            +
                  end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                  def render_notes
         
     | 
| 
      
 74 
     | 
    
         
            +
                    text "<u>Notes</u>", inline_format: true
         
     | 
| 
      
 75 
     | 
    
         
            +
                    move_down 5
         
     | 
| 
      
 76 
     | 
    
         
            +
                    output_html_as_text_but_preserving_paragraph_breaks(text: event.notes)
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  def render_hospital_centre_info
         
     | 
| 
      
 80 
     | 
    
         
            +
                    bounding_box([340, cursor], width: 200) do
         
     | 
| 
      
 81 
     | 
    
         
            +
                      image_path = "app/assets/images/renalware/nhs_a4_letter_logo_black.png"
         
     | 
| 
      
 82 
     | 
    
         
            +
                      image Renalware::Engine.root.join(image_path), height: 30, position: :right
         
     | 
| 
      
 83 
     | 
    
         
            +
                      move_down 10
         
     | 
| 
      
 84 
     | 
    
         
            +
                      text event.hospital_centre_trust_name, align: :right
         
     | 
| 
      
 85 
     | 
    
         
            +
                      text event.hospital_centre_trust_caption, align: :right
         
     | 
| 
      
 86 
     | 
    
         
            +
                      font_size 8
         
     | 
| 
      
 87 
     | 
    
         
            +
                      output_html_as_text_but_preserving_paragraph_breaks(
         
     | 
| 
      
 88 
     | 
    
         
            +
                        text: interpret_new_lines_in(event.hospital_centre_info),
         
     | 
| 
      
 89 
     | 
    
         
            +
                        strip_tags: false,
         
     | 
| 
      
 90 
     | 
    
         
            +
                        align: :right,
         
     | 
| 
      
 91 
     | 
    
         
            +
                        inline_format: true
         
     | 
| 
      
 92 
     | 
    
         
            +
                      )
         
     | 
| 
      
 93 
     | 
    
         
            +
                      font_size 10
         
     | 
| 
      
 94 
     | 
    
         
            +
                    end
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  # Ensure any new line characters in a string are interpreted as actual new lines.
         
     | 
| 
      
 98 
     | 
    
         
            +
                  # This lets use /n in seed data and in the database.
         
     | 
| 
      
 99 
     | 
    
         
            +
                  def interpret_new_lines_in(text)
         
     | 
| 
      
 100 
     | 
    
         
            +
                    text&.gsub('\n', "\n")
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                  # Create new line if there is a <br>.
         
     | 
| 
      
 104 
     | 
    
         
            +
                  # If there is an empty line (caused by <br><br>) move down to indicate a new paragraph.
         
     | 
| 
      
 105 
     | 
    
         
            +
                  def output_html_as_text_but_preserving_paragraph_breaks(text:, strip_tags: true, **args)
         
     | 
| 
      
 106 
     | 
    
         
            +
                    return if text.blank?
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                    text.split("<br>").each do |paragraph|
         
     | 
| 
      
 109 
     | 
    
         
            +
                      if strip_tags
         
     | 
| 
      
 110 
     | 
    
         
            +
                        text ActionView::Base.full_sanitizer.sanitize(paragraph), **args
         
     | 
| 
      
 111 
     | 
    
         
            +
                      else
         
     | 
| 
      
 112 
     | 
    
         
            +
                        text paragraph, **args
         
     | 
| 
      
 113 
     | 
    
         
            +
                      end
         
     | 
| 
      
 114 
     | 
    
         
            +
                      move_down(10) if ActionView::Base.full_sanitizer.sanitize(paragraph).blank?
         
     | 
| 
      
 115 
     | 
    
         
            +
                    end
         
     | 
| 
      
 116 
     | 
    
         
            +
                  end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                  def title
         
     | 
| 
      
 119 
     | 
    
         
            +
                    event_type.title || event_type.name
         
     | 
| 
      
 120 
     | 
    
         
            +
                  end
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
      
 123 
     | 
    
         
            +
            end
         
     | 
| 
      
 124 
     | 
    
         
            +
            # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_dependency "renalware/events"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Renalware
         
     | 
| 
      
 6 
     | 
    
         
            +
              module Events
         
     | 
| 
      
 7 
     | 
    
         
            +
                class EventPdfPresenter < SimpleDelegator
         
     | 
| 
      
 8 
     | 
    
         
            +
                  class DefaultHospitalCentreNotFoundError < StandardError; end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  class DefaultHospitalCentreNotSetError < StandardError; end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  delegate :info,
         
     | 
| 
      
 12 
     | 
    
         
            +
                           :trust_name,
         
     | 
| 
      
 13 
     | 
    
         
            +
                           :trust_caption,
         
     | 
| 
      
 14 
     | 
    
         
            +
                           to: :hospital_centre, prefix: true, allow_nil: true
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  private
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  def hospital_centre
         
     | 
| 
      
 19 
     | 
    
         
            +
                    @hospital_centre ||= begin
         
     | 
| 
      
 20 
     | 
    
         
            +
                      centre = Renalware::Hospitals::Centre.find_by(code: default_hospital_centre_code)
         
     | 
| 
      
 21 
     | 
    
         
            +
                      centre.presence || raise(DefaultHospitalCentreNotFoundError, default_hospital_centre_code)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def default_hospital_centre_code
         
     | 
| 
      
 26 
     | 
    
         
            +
                    Renalware.config.ukrdc_site_code.presence || raise(DefaultHospitalCentreNotSetError)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -60,6 +60,7 @@ module Renalware 
     | 
|
| 
       60 
60 
     | 
    
         
             
                      letters_patient
         
     | 
| 
       61 
61 
     | 
    
         
             
                        .letters
         
     | 
| 
       62 
62 
     | 
    
         
             
                        .approved_or_completed
         
     | 
| 
      
 63 
     | 
    
         
            +
                        .includes(:updated_by, :author, :letterhead, :archive)
         
     | 
| 
       63 
64 
     | 
    
         
             
                        .where("updated_at > ?", changes_since),
         
     | 
| 
       64 
65 
     | 
    
         
             
                      Renalware::Letters::LetterPresenterFactory
         
     | 
| 
       65 
66 
     | 
    
         
             
                    )
         
     | 
| 
         @@ -68,7 +69,7 @@ module Renalware 
     | 
|
| 
       68 
69 
     | 
    
         
             
                  def finished_hd_sessions
         
     | 
| 
       69 
70 
     | 
    
         
             
                    hd_patient
         
     | 
| 
       70 
71 
     | 
    
         
             
                      .finished_hd_sessions
         
     | 
| 
       71 
     | 
    
         
            -
                      .includes(:patient, :dialysate)
         
     | 
| 
      
 72 
     | 
    
         
            +
                      .includes(:patient, :dialysate, :updated_by)
         
     | 
| 
       72 
73 
     | 
    
         
             
                      .where("hd_sessions.updated_at > ?", changes_since)
         
     | 
| 
       73 
74 
     | 
    
         
             
                  end
         
     | 
| 
       74 
75 
     | 
    
         | 
| 
         @@ -17,7 +17,7 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
                      strong= request.patient.to_s(:long)
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                  = f.input :patient_id, as: :hidden
         
     | 
| 
       20 
     | 
    
         
            -
                  = f.input :reason_id, collection: reasons, wrapper: :horizontal_medium
         
     | 
| 
      
 20 
     | 
    
         
            +
                  = f.input :reason_id, collection: reasons, wrapper: :horizontal_medium, autofocus: true
         
     | 
| 
       21 
21 
     | 
    
         
             
                  = f.input :priority, wrapper: :horizontal_small
         
     | 
| 
       22 
22 
     | 
    
         
             
                  = f.input :hospital_unit_id, collection: hospital_units, wrapper: :horizontal_medium
         
     | 
| 
       23 
23 
     | 
    
         
             
                  = f.input :notes, as: :text, wrapper: :horizontal_large, input_html: { rows: 5 }
         
     | 
| 
         @@ -45,7 +45,7 @@ xml.LabOrder do 
     | 
|
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
              xml.ResultItems do
         
     | 
| 
       47 
47 
     | 
    
         
             
                render partial: "renalware/api/ukrdc/patients/lab_orders/result_item",
         
     | 
| 
       48 
     | 
    
         
            -
                       collection: request.observations 
     | 
| 
      
 48 
     | 
    
         
            +
                       collection: request.observations,
         
     | 
| 
       49 
49 
     | 
    
         
             
                       as: :observation,
         
     | 
| 
       50 
50 
     | 
    
         
             
                       locals: { builder: builder, patient: patient }
         
     | 
| 
       51 
51 
     | 
    
         
             
              end
         
     | 
| 
         @@ -3,21 +3,27 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            xml = builder
         
     | 
| 
       4 
4 
     | 
    
         
             
            observation = Renalware::Pathology::ObservationPresenter.new(observation)
         
     | 
| 
       5 
5 
     | 
    
         
             
            observation = Renalware::UKRDC::PathologyObservationPresenter.new(observation)
         
     | 
| 
      
 6 
     | 
    
         
            +
            result = observation.result || ""
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
            # The UKRDC XSD Schema specifies that observations cannot be longer than 20 characters.
         
     | 
| 
      
 9 
     | 
    
         
            +
            # KCH regularly get notes in the result, saying things like "No recent Urea result" - which in this
         
     | 
| 
      
 10 
     | 
    
         
            +
            # case exceeds 20 characters. We need to skip these.
         
     | 
| 
      
 11 
     | 
    
         
            +
            if result.length <= 20
         
     | 
| 
      
 12 
     | 
    
         
            +
              xml.ResultItem do
         
     | 
| 
      
 13 
     | 
    
         
            +
                xml.EnteredOn observation.updated_at&.iso8601
         
     | 
| 
      
 14 
     | 
    
         
            +
                xml.PrePost observation.pre_post(patient_is_on_hd: patient.current_modality_hd?)
         
     | 
| 
      
 15 
     | 
    
         
            +
                xml.ServiceId do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  if observation.description_loinc_code.present?
         
     | 
| 
      
 17 
     | 
    
         
            +
                    xml.CodingStandard "PV"
         
     | 
| 
      
 18 
     | 
    
         
            +
                    xml.Code observation.description_loinc_code
         
     | 
| 
      
 19 
     | 
    
         
            +
                  else
         
     | 
| 
      
 20 
     | 
    
         
            +
                    xml.CodingStandard "LOCAL"
         
     | 
| 
      
 21 
     | 
    
         
            +
                    xml.Code observation.description_code
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  xml.Description observation.description_name
         
     | 
| 
       17 
24 
     | 
    
         
             
                end
         
     | 
| 
       18 
     | 
    
         
            -
                xml. 
     | 
| 
      
 25 
     | 
    
         
            +
                xml.ResultValue observation.result
         
     | 
| 
      
 26 
     | 
    
         
            +
                xml.ResultValueUnits observation.measurement_unit_name
         
     | 
| 
      
 27 
     | 
    
         
            +
                xml.ObservationTime observation.observed_at&.iso8601
         
     | 
| 
       19 
28 
     | 
    
         
             
              end
         
     | 
| 
       20 
     | 
    
         
            -
              xml.ResultValue observation.result
         
     | 
| 
       21 
     | 
    
         
            -
              xml.ResultValueUnits observation.measurement_unit_name
         
     | 
| 
       22 
     | 
    
         
            -
              xml.ObservationTime observation.observed_at&.iso8601
         
     | 
| 
       23 
29 
     | 
    
         
             
            end
         
     | 
| 
         @@ -7,7 +7,8 @@ ruby: 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                = f.input :schedule_definition_id,
         
     | 
| 
       9 
9 
     | 
    
         
             
                          collection: Renalware::HD::ScheduleDefinition.ordered,
         
     | 
| 
       10 
     | 
    
         
            -
                          wrapper: :horizontal_small
         
     | 
| 
      
 10 
     | 
    
         
            +
                          wrapper: :horizontal_small,
         
     | 
| 
      
 11 
     | 
    
         
            +
                          autofocus: true
         
     | 
| 
       11 
12 
     | 
    
         
             
                = f.input :other_schedule,
         
     | 
| 
       12 
13 
     | 
    
         
             
                          input_html: { class: "small-input" }
         
     | 
| 
       13 
14 
     | 
    
         
             
                = f.association :hospital_unit,
         
     | 
| 
         @@ -17,7 +17,8 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
                                    collection: Renalware::Modalities::Description.where(hidden: false),
         
     | 
| 
       18 
18 
     | 
    
         
             
                                    input_html: { id: "modality-description-select" },
         
     | 
| 
       19 
19 
     | 
    
         
             
                                    label_method: :name, value_method: :id,
         
     | 
| 
       20 
     | 
    
         
            -
                                    wrapper: :horizontal_medium
         
     | 
| 
      
 20 
     | 
    
         
            +
                                    wrapper: :horizontal_medium,
         
     | 
| 
      
 21 
     | 
    
         
            +
                                    autofocus: true
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
                          .hide-death
         
     | 
| 
       23 
24 
     | 
    
         
             
                            = m.input :modal_change_type,
         
     | 
| 
         @@ -5,7 +5,8 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
              = f.input :treatment,
         
     | 
| 
       6 
6 
     | 
    
         
             
                        collection: available_pd_treatments_for(f.object),
         
     | 
| 
       7 
7 
     | 
    
         
             
                        include_blank: t("collection.blank_option"),
         
     | 
| 
       8 
     | 
    
         
            -
                        wrapper: :horizontal_medium
         
     | 
| 
      
 8 
     | 
    
         
            +
                        wrapper: :horizontal_medium,
         
     | 
| 
      
 9 
     | 
    
         
            +
                        autofocus: true
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
              - if f.object.apd?
         
     | 
| 
       11 
12 
     | 
    
         
             
                = f.input :assistance_type, wrapper: :horizontal_small, default: :none
         
     | 
| 
         @@ -9,7 +9,8 @@ 
     | 
|
| 
       9 
9 
     | 
    
         
             
              = f.input :ignore_me, as: :hidden
         
     | 
| 
       10 
10 
     | 
    
         
             
              = f.association :training_site,
         
     | 
| 
       11 
11 
     | 
    
         
             
                  collection: Renalware::PD::TrainingSite.ordered,
         
     | 
| 
       12 
     | 
    
         
            -
                  wrapper: :horizontal_small
         
     | 
| 
      
 12 
     | 
    
         
            +
                  wrapper: :horizontal_small,
         
     | 
| 
      
 13 
     | 
    
         
            +
                  autofocus: true
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
              = f.association :training_type,
         
     | 
| 
       15 
16 
     | 
    
         
             
                  collection: Renalware::PD::TrainingType.ordered,
         
     | 
| 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
              = simple_form_for note, url: url,
         
     | 
| 
       3 
3 
     | 
    
         
             
                  wrapper: :horizontal_form, remote: true do |f|
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                = f.input :description, as: :text, input_html: { cols: 50, rows: 3 }
         
     | 
| 
      
 5 
     | 
    
         
            +
                = f.input :description, as: :text, input_html: { cols: 50, rows: 3 }, autofocus: true
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                .row
         
     | 
| 
       8 
8 
     | 
    
         
             
                  .large-offset-3.large-7.columns
         
     | 
| 
         @@ -6,7 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
                                url: patient_problem_path(patient, problem),
         
     | 
| 
       7 
7 
     | 
    
         
             
                                html: { autocomplete: "off", class: "problem-form" } do |f|
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                  = f.input :description, as: :text
         
     | 
| 
      
 9 
     | 
    
         
            +
                  = f.input :description, as: :text, autofocus: true
         
     | 
| 
       10 
10 
     | 
    
         
             
                  = f.button :button, "Save"
         
     | 
| 
       11 
11 
     | 
    
         
             
                  span= " or "
         
     | 
| 
       12 
12 
     | 
    
         
             
                  = link_to "cancel", patient_problems_path(patient)
         
     | 
| 
         @@ -5,7 +5,9 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
              = render layout: "renalware/shared/fieldset",
         
     | 
| 
       6 
6 
     | 
    
         
             
                  locals: { legend: "Diagnosis & ESRF Info", name: "diagnosis" } do
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                = f.input :esrf_on, 
     | 
| 
      
 8 
     | 
    
         
            +
                = f.input :esrf_on,
         
     | 
| 
      
 9 
     | 
    
         
            +
                          as: :date_picker,
         
     | 
| 
      
 10 
     | 
    
         
            +
                          wrapper: :horizontal_datepicker
         
     | 
| 
       9 
11 
     | 
    
         
             
                = f.input :weight_at_esrf, wrapper: :horizontal_small
         
     | 
| 
       10 
12 
     | 
    
         
             
                = f.input :modality_at_esrf,
         
     | 
| 
       11 
13 
     | 
    
         
             
                          include_blank: "Select modality",
         
     | 
| 
         @@ -5,7 +5,7 @@ Delayed::Worker.destroy_failed_jobs = false 
     | 
|
| 
       5 
5 
     | 
    
         
             
            Delayed::Worker.max_attempts = 10 # overridden e.g. in FeedJob
         
     | 
| 
       6 
6 
     | 
    
         
             
            Delayed::Worker.max_run_time = 2.hours
         
     | 
| 
       7 
7 
     | 
    
         
             
            Delayed::Worker.read_ahead = 10
         
     | 
| 
       8 
     | 
    
         
            -
            Delayed::Worker.sleep_delay =  
     | 
| 
      
 8 
     | 
    
         
            +
            Delayed::Worker.sleep_delay = 8 # Also affects how long it takes delayed_job to stop on Crl+C
         
     | 
| 
       9 
9 
     | 
    
         
             
            Delayed::Worker.default_priority = 5 # use a lower number to get preferential treatment
         
     | 
| 
       10 
10 
     | 
    
         
             
            # Will only raise an exception on TERM signals but INT will wait for the current job to finish.
         
     | 
| 
       11 
11 
     | 
    
         
             
            Delayed::Worker.raise_signal_exceptions = :term
         
     | 
| 
         @@ -21,7 +21,7 @@ require_dependency "renalware" 
     | 
|
| 
       21 
21 
     | 
    
         
             
            #     end
         
     | 
| 
       22 
22 
     | 
    
         
             
            #   end
         
     | 
| 
       23 
23 
     | 
    
         
             
            # As it stands its a bit too easy for the exposed subscription map hash to be overwritten by a host
         
     | 
| 
       24 
     | 
    
         
            -
            # application with confusing and  
     | 
| 
      
 24 
     | 
    
         
            +
            # application with confusing and outcomes.
         
     | 
| 
       25 
25 
     | 
    
         
             
            Renalware.configure do |config|
         
     | 
| 
       26 
26 
     | 
    
         
             
              config.broadcast_subscription_map = {
         
     | 
| 
       27 
27 
     | 
    
         
             
                "Renalware::Modalities::ChangePatientModality" => [
         
     | 
| 
         @@ -39,7 +39,9 @@ Renalware.configure do |config| 
     | 
|
| 
       39 
39 
     | 
    
         
             
                "Renalware::Letters::ResolveDefaultElectronicCCs" => [
         
     | 
| 
       40 
40 
     | 
    
         
             
                  "Renalware::HD::PatientListener"
         
     | 
| 
       41 
41 
     | 
    
         
             
                ],
         
     | 
| 
       42 
     | 
    
         
            -
                "Renalware::Pathology::CreateObservationRequests" => []
         
     | 
| 
      
 42 
     | 
    
         
            +
                "Renalware::Pathology::CreateObservationRequests" => [],
         
     | 
| 
      
 43 
     | 
    
         
            +
                "Renalware::Events::CreateEvent" => [],
         
     | 
| 
      
 44 
     | 
    
         
            +
                "Renalware::Events::UpdateEvent" => []
         
     | 
| 
       43 
45 
     | 
    
         
             
              }
         
     | 
| 
       44 
46 
     | 
    
         
             
            end
         
     | 
| 
       45 
47 
     | 
    
         | 
    
        data/config/routes.rb
    CHANGED
    
    | 
         @@ -330,6 +330,9 @@ Renalware::Engine.routes.draw do 
     | 
|
| 
       330 
330 
     | 
    
         | 
| 
       331 
331 
     | 
    
         
             
                # Events
         
     | 
| 
       332 
332 
     | 
    
         
             
                resources :events, only: [:new, :create, :index], controller: "events/events"
         
     | 
| 
      
 333 
     | 
    
         
            +
                constraints(format: /(pdf)/) do
         
     | 
| 
      
 334 
     | 
    
         
            +
                  resources :events, only: :show, controller: "events/events"
         
     | 
| 
      
 335 
     | 
    
         
            +
                end
         
     | 
| 
       333 
336 
     | 
    
         | 
| 
       334 
337 
     | 
    
         
             
                resources :swabs,
         
     | 
| 
       335 
338 
     | 
    
         
             
                          only: [:new, :create, :edit, :update],
         
     | 
| 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class AddInfoToHospitalCentres < ActiveRecord::Migration[5.2]
         
     | 
| 
      
 2 
     | 
    
         
            +
              def change
         
     | 
| 
      
 3 
     | 
    
         
            +
                add_column :hospital_centres, :info, :text, null: true
         
     | 
| 
      
 4 
     | 
    
         
            +
                add_column :hospital_centres, :trust_name, :string, null: true
         
     | 
| 
      
 5 
     | 
    
         
            +
                add_column :hospital_centres, :trust_caption, :string, null: true
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/renalware/engine.rb
    CHANGED
    
    
    
        data/lib/renalware/version.rb
    CHANGED
    
    
    
        data/lib/tasks/db.rake
    CHANGED
    
    | 
         @@ -14,7 +14,7 @@ namespace :db do 
     | 
|
| 
       14 
14 
     | 
    
         
             
              namespace :demo do
         
     | 
| 
       15 
15 
     | 
    
         
             
                desc "Loads demo seed data from the renalware-core gem"
         
     | 
| 
       16 
16 
     | 
    
         
             
                task seed: :environment do
         
     | 
| 
       17 
     | 
    
         
            -
                  if Rails.env.development?
         
     | 
| 
      
 17 
     | 
    
         
            +
                  if Rails.env.development? || ENV["ALLOW_DEMO_SEEDS"] == "1"
         
     | 
| 
       18 
18 
     | 
    
         
             
                    require Renalware::Engine.root.join("spec/dummy/db/seeds")
         
     | 
| 
       19 
19 
     | 
    
         
             
                  else
         
     | 
| 
       20 
20 
     | 
    
         
             
                    puts "Task currently only possible in development environment"
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.70
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Airslie
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-02-27 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: active_type
         
     | 
| 
         @@ -556,6 +556,20 @@ dependencies: 
     | 
|
| 
       556 
556 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       557 
557 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       558 
558 
     | 
    
         
             
                    version: 1.1.3
         
     | 
| 
      
 559 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 560 
     | 
    
         
            +
              name: prawn
         
     | 
| 
      
 561 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 562 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 563 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 564 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 565 
     | 
    
         
            +
                    version: 2.2.2
         
     | 
| 
      
 566 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 567 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 568 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 569 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 570 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 571 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 572 
     | 
    
         
            +
                    version: 2.2.2
         
     | 
| 
       559 
573 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       560 
574 
     | 
    
         
             
              name: puma
         
     | 
| 
       561 
575 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -1314,6 +1328,7 @@ files: 
     | 
|
| 
       1314 
1328 
     | 
    
         
             
            - app/jobs/feed_job.rb
         
     | 
| 
       1315 
1329 
     | 
    
         
             
            - app/jobs/hl7_message_example.yml
         
     | 
| 
       1316 
1330 
     | 
    
         
             
            - app/jobs/refresh_materialized_view_job.rb
         
     | 
| 
      
 1331 
     | 
    
         
            +
            - app/jobs/renalware/events/save_pdf_event_to_file_job.rb
         
     | 
| 
       1317 
1332 
     | 
    
         
             
            - app/jobs/renalware/hd/generate_monthly_statistics.rb
         
     | 
| 
       1318 
1333 
     | 
    
         
             
            - app/jobs/renalware/hd/generate_monthly_statistics_for_patient_job.rb
         
     | 
| 
       1319 
1334 
     | 
    
         
             
            - app/jobs/renalware/hd/update_rolling_patient_statistics_job.rb
         
     | 
| 
         @@ -1408,6 +1423,7 @@ files: 
     | 
|
| 
       1408 
1423 
     | 
    
         
             
            - app/models/renalware/drugs/type.rb
         
     | 
| 
       1409 
1424 
     | 
    
         
             
            - app/models/renalware/events.rb
         
     | 
| 
       1410 
1425 
     | 
    
         
             
            - app/models/renalware/events/biopsy.rb
         
     | 
| 
      
 1426 
     | 
    
         
            +
            - app/models/renalware/events/create_event.rb
         
     | 
| 
       1411 
1427 
     | 
    
         
             
            - app/models/renalware/events/event.rb
         
     | 
| 
       1412 
1428 
     | 
    
         
             
            - app/models/renalware/events/event_query.rb
         
     | 
| 
       1413 
1429 
     | 
    
         
             
            - app/models/renalware/events/investigation.rb
         
     | 
| 
         @@ -1415,6 +1431,7 @@ files: 
     | 
|
| 
       1415 
1431 
     | 
    
         
             
            - app/models/renalware/events/simple.rb
         
     | 
| 
       1416 
1432 
     | 
    
         
             
            - app/models/renalware/events/swab.rb
         
     | 
| 
       1417 
1433 
     | 
    
         
             
            - app/models/renalware/events/type.rb
         
     | 
| 
      
 1434 
     | 
    
         
            +
            - app/models/renalware/events/update_event.rb
         
     | 
| 
       1418 
1435 
     | 
    
         
             
            - app/models/renalware/feeds.rb
         
     | 
| 
       1419 
1436 
     | 
    
         
             
            - app/models/renalware/feeds/file.rb
         
     | 
| 
       1420 
1437 
     | 
    
         
             
            - app/models/renalware/feeds/file_type.rb
         
     | 
| 
         @@ -1806,6 +1823,7 @@ files: 
     | 
|
| 
       1806 
1823 
     | 
    
         
             
            - app/models/renalware/virology/vaccination.rb
         
     | 
| 
       1807 
1824 
     | 
    
         
             
            - app/models/renalware/virology/version.rb
         
     | 
| 
       1808 
1825 
     | 
    
         
             
            - app/models/renalware/zip_archive.rb
         
     | 
| 
      
 1826 
     | 
    
         
            +
            - app/pdfs/renalware/events/event_pdf.rb
         
     | 
| 
       1809 
1827 
     | 
    
         
             
            - app/policies/application_policy.rb
         
     | 
| 
       1810 
1828 
     | 
    
         
             
            - app/policies/renalware/admin/cache_policy.rb
         
     | 
| 
       1811 
1829 
     | 
    
         
             
            - app/policies/renalware/admissions/admission_policy.rb
         
     | 
| 
         @@ -1896,6 +1914,7 @@ files: 
     | 
|
| 
       1896 
1914 
     | 
    
         
             
            - app/presenters/renalware/country_presenter.rb
         
     | 
| 
       1897 
1915 
     | 
    
         
             
            - app/presenters/renalware/dashboard/dashboard_presenter.rb
         
     | 
| 
       1898 
1916 
     | 
    
         
             
            - app/presenters/renalware/directory/person_auto_complete_presenter.rb
         
     | 
| 
      
 1917 
     | 
    
         
            +
            - app/presenters/renalware/events/event_pdf_presenter.rb
         
     | 
| 
       1899 
1918 
     | 
    
         
             
            - app/presenters/renalware/events/events_presenter.rb
         
     | 
| 
       1900 
1919 
     | 
    
         
             
            - app/presenters/renalware/events/summary_part.rb
         
     | 
| 
       1901 
1920 
     | 
    
         
             
            - app/presenters/renalware/hd/dashboard_presenter.rb
         
     | 
| 
         @@ -2173,6 +2192,7 @@ files: 
     | 
|
| 
       2173 
2192 
     | 
    
         
             
            - app/views/renalware/events/events/inputs/_swab.html.slim
         
     | 
| 
       2174 
2193 
     | 
    
         
             
            - app/views/renalware/events/events/new.html.slim
         
     | 
| 
       2175 
2194 
     | 
    
         
             
            - app/views/renalware/events/events/new.js.erb
         
     | 
| 
      
 2195 
     | 
    
         
            +
            - app/views/renalware/events/events/show.pdf.slim
         
     | 
| 
       2176 
2196 
     | 
    
         
             
            - app/views/renalware/events/events/simple/_event.html.slim
         
     | 
| 
       2177 
2197 
     | 
    
         
             
            - app/views/renalware/events/events/simple/_list.html.slim
         
     | 
| 
       2178 
2198 
     | 
    
         
             
            - app/views/renalware/events/events/simple/_table.html.slim
         
     | 
| 
         @@ -3384,6 +3404,8 @@ files: 
     | 
|
| 
       3384 
3404 
     | 
    
         
             
            - db/migrate/20181126123745_refresh_hd_grouped_transmission_logs_view.rb
         
     | 
| 
       3385 
3405 
     | 
    
         
             
            - db/migrate/20181217124025_change_ukrdc_transmission_log_error_type.rb
         
     | 
| 
       3386 
3406 
     | 
    
         
             
            - db/migrate/20190104095254_create_active_storage_tables.active_storage.rb
         
     | 
| 
      
 3407 
     | 
    
         
            +
            - db/migrate/20190218142207_add_filename_prefix_to_event_types.rb
         
     | 
| 
      
 3408 
     | 
    
         
            +
            - db/migrate/20190225103005_add_info_to_hospital_centres.rb
         
     | 
| 
       3387 
3409 
     | 
    
         
             
            - db/seeds.rb
         
     | 
| 
       3388 
3410 
     | 
    
         
             
            - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.csv
         
     | 
| 
       3389 
3411 
     | 
    
         
             
            - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb
         
     |