renalware-forms 0.1.0 → 0.1.1

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: 347e9f7644d2f72db868d81b7c16a22403285db8bed1bdf545041f53fcae2b79
4
- data.tar.gz: b909b6addb49a49c618324e41c34cadb19eb04ce9140d1a48562cbbab0deea0f
3
+ metadata.gz: 7b8cdf83759e6c1ddacfa9d339f9c9b2baeca1a0a380a7e19e88fd7c318f5274
4
+ data.tar.gz: aae863d39847a60411fa8dba064e4523cc6e64a663bb5961b30056f6cbd05410
5
5
  SHA512:
6
- metadata.gz: d2d1937839e25b9ceabc0e4eb03e21e571a831f795fce8cea0194cdfd5f6c2147d53d18174bee50125854872bcee892c865522cecbe7bb0a8c46b573ea2d0440
7
- data.tar.gz: 95f1eb71ec37fbaac84f61956a9193812feb613ee9188966cf1c4d139d10e5fbb30d4f1ba7202b114a2f7a346a5ec3c749637a0f919bfe7d1cf59d8a9fc2524a
6
+ metadata.gz: 3b8e557c9259bf7fe13d28d5b9157cab38d8bd3efca56f2d719b9c67d95901c8da9d440c02a5b7cc5811e5b969f45eda96db829d7c8688d5c125861afcec5d33
7
+ data.tar.gz: 43c1fecc6aec66d9cafae6ab6c1a113043d9dd876ca32e658c0b44e2b326deda459313f51d8be8a5d8c076f8f31d764d2df58211f73005ab63bdbb0f2185df1d
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Gem Version](https://badge.fury.io/rb/renalware-forms.svg)](https://badge.fury.io/rb/renalware-forms)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/945cd0c49335e9e4595d/maintainability)](https://codeclimate.com/github/airslie/renalware-forms/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/945cd0c49335e9e4595d/test_coverage)](https://codeclimate.com/github/airslie/renalware-forms/test_coverage)
4
+
1
5
  # Renalware::Forms
2
6
 
3
7
  This gem
@@ -63,4 +67,4 @@ for it to open on a Mac).
63
67
 
64
68
  ## License
65
69
 
66
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT)
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "zeitwerk"
3
4
  require "prawn"
4
5
  require "prawn/table"
5
6
  require "attr_extras"
6
- require "active_support"
7
+
8
+ # Set up autoloading with zeitwerk
9
+ # As we are nested in lib/renalware/forms, be sure to push an absolute
10
+ # path to the lib folder.
11
+ loader = Zeitwerk::Loader.new
12
+ loader.push_dir File.expand_path("../", __dir__)
13
+ loader.setup
7
14
 
8
15
  module Renalware
9
16
  module Forms
10
- extend ActiveSupport::Autoload
11
-
12
- autoload :Helpers
13
- autoload :Base
14
- autoload :Homecare
15
- autoload :Generic
16
17
  end
17
18
  end
@@ -3,8 +3,8 @@
3
3
  module Renalware::Forms
4
4
  class Base
5
5
  include Prawn::View
6
- EMPTY_CHECKBOX = "o " # in ZapfDingbats
7
- CHECKBOX = "3 "
6
+ EMPTY_CHECKBOX = "o " # in ZapfDingbats
7
+ CHECKBOX = "n " # ■ in ZapfDingbats
8
8
 
9
9
  # lower case o is an empty checkbox in ZapfDingbats
10
10
  def cell_with_leading_checkbox(text, checked: false, **options)
@@ -22,5 +22,40 @@ module Renalware::Forms
22
22
  }
23
23
  end
24
24
  end
25
+
26
+ def cell_with_trailing_checkbox(text, checked: false, **options)
27
+ if checked
28
+ {
29
+ content: "#{text} <font name='ZapfDingbats'>#{CHECKBOX}</font>",
30
+ inline_format: true,
31
+ **options
32
+ }
33
+ else
34
+ {
35
+ content: "#{text} <font name='ZapfDingbats'>#{EMPTY_CHECKBOX}</font>",
36
+ inline_format: true,
37
+ **options
38
+ }
39
+ end
40
+ end
41
+
42
+ def underlined_table_style
43
+ {
44
+ cell_style: {
45
+ padding: [2, 5, 2, 0],
46
+ border_width: 0.5,
47
+ border_color: "AAAAAA",
48
+ borders: [:bottom]
49
+ }
50
+ }
51
+ end
52
+
53
+ def borderless_table_style
54
+ {
55
+ cell_style: {
56
+ border_width: 0.5
57
+ }
58
+ }
59
+ end
25
60
  end
26
61
  end
@@ -2,8 +2,5 @@
2
2
 
3
3
  module Renalware::Forms
4
4
  module Generic
5
- extend ActiveSupport::Autoload
6
-
7
- autoload :Homecare
8
5
  end
9
6
  end
@@ -3,9 +3,6 @@
3
3
  module Renalware::Forms
4
4
  module Generic
5
5
  module Homecare
6
- extend ActiveSupport::Autoload
7
-
8
- autoload :V1
9
6
  end
10
7
  end
11
8
  end
@@ -3,10 +3,6 @@
3
3
  module Renalware::Forms::Generic
4
4
  module Homecare
5
5
  module V1
6
- extend ActiveSupport::Autoload
7
-
8
- autoload :Base
9
- autoload :Document
10
6
  end
11
7
  end
12
8
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ class Allergies < Base
6
+ def build
7
+ move_down 30
8
+ font_size 10
9
+ text "Known Allergies", style: :bold
10
+ args.allergies.each do |allergy|
11
+ text allergy
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -4,6 +4,26 @@ module Renalware::Forms::Generic
4
4
  module Homecare::V1
5
5
  class Base < Renalware::Forms::Base
6
6
  pattr_initialize :document, :args
7
+ TABLE_WIDTH = 555
8
+
9
+ def table_styles(**options)
10
+ {
11
+ cell_style: {
12
+ padding: [1, 5, 1, 1],
13
+ border_width: 0.5,
14
+ border_color: "AAAAAA",
15
+ **options
16
+ }
17
+ }
18
+ end
19
+
20
+ def heading(text, **options)
21
+ {
22
+ content: text,
23
+ font_style: :bold,
24
+ **options
25
+ }
26
+ end
7
27
  end
8
28
  end
9
29
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ class DeliveryFrequencies < Base
6
+ def build
7
+ font_size 10
8
+ move_down 10
9
+ row = [heading("Frequency of deliveries:")]
10
+ args.delivery_frequencies.each do |freq|
11
+ row.concat << cell_with_leading_checkbox(freq)
12
+ end
13
+
14
+ table(
15
+ [row],
16
+ **table_styles(border_width: 0, padding: [1, 30, 1, 0]),
17
+ column_widths: { 0 => 150 }
18
+ )
19
+ end
20
+ end
21
+ end
22
+ end
@@ -10,10 +10,21 @@ module Renalware::Forms::Generic
10
10
  end
11
11
 
12
12
  def document
13
- @document ||= Prawn::Document.new(page_size: "A4", page_layout: :portrait, margin: 15)
13
+ @document ||= Prawn::Document.new(page_size: "A4", page_layout: :portrait, margin: 25)
14
14
  end
15
15
 
16
- def build; end
16
+ def build
17
+ Prawn::Font::AFM.hide_m17n_warning = true
18
+ [
19
+ Heading,
20
+ PatientDetails,
21
+ Medications,
22
+ Allergies,
23
+ PrescriptionDurations,
24
+ DeliveryFrequencies,
25
+ Signoff
26
+ ].each { |klass| klass.new(document, args).build }
27
+ end
17
28
  end
18
29
  end
19
30
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ class Heading < Base
6
+ def build
7
+ move_down 10
8
+ font_size 12
9
+ text "PO: #{args.po_number}"
10
+ font_size 8
11
+ text "RW ref: #{args.hospital_number}"
12
+ text "Drugs types: #{args.drug_type}"
13
+ move_down 30
14
+ font_size 16
15
+ text "Home Delivery Medication List", style: :bold
16
+ font_size 8
17
+ text "As at #{args.generated_at}"
18
+ image(
19
+ File.join(File.dirname(__dir__), "v1/assets/nhs_logo.jpg"),
20
+ width: 60,
21
+ at: [490, 800]
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ class Medications < Base
6
+ def build
7
+ move_down 20
8
+ font_size 10
9
+
10
+ rows = []
11
+ rows << [
12
+ heading("Date"),
13
+ heading("Drug"),
14
+ heading("Dose"),
15
+ heading("Route"),
16
+ heading("Freq"),
17
+ heading("Pharmacy comments")
18
+ ]
19
+
20
+ args.medications.map do |med|
21
+ rows << [
22
+ med.date.to_s,
23
+ med.drug,
24
+ med.dose,
25
+ med.route,
26
+ med.frequency,
27
+ ""
28
+ ]
29
+ end
30
+
31
+ table(
32
+ rows,
33
+ column_widths: {
34
+ 0 => 60,
35
+ 1 => 140,
36
+ 2 => 80,
37
+ 3 => 75,
38
+ 4 => 75,
39
+ 5 => 110
40
+ },
41
+ **table_styles,
42
+ **underlined_table_style
43
+ )
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ class PatientDetails < Base
6
+ def build
7
+ move_down 10
8
+ font_size 10
9
+ table(
10
+ [
11
+ [heading("Name"), args.patient_name],
12
+ [heading("Modality"), args.modality],
13
+ [heading("Date of Birth"), args.born_on],
14
+ [heading("NHS Number"), args.nhs_number],
15
+ [heading("Hospital no"), args.hospital_number],
16
+ [heading("Address"), args.formatted_address_and_postcode]
17
+ ],
18
+ **table_styles(border_width: 0)
19
+ )
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ # List our the available prescription_durations and is selected_prescription_duration
6
+ # supplied then mark that one as checked.
7
+ class PrescriptionDurations < Base
8
+ def build
9
+ font_size 10
10
+ move_down 20
11
+ row = [heading("Repeat prescription for:")]
12
+ args.prescription_durations.each do |duration|
13
+ checked = duration == args.selected_prescription_duration
14
+ row.concat << cell_with_leading_checkbox(duration, checked: checked)
15
+ end
16
+
17
+ table(
18
+ [row],
19
+ **table_styles(border_width: 0, padding: [1, 30, 1, 0]),
20
+ column_widths: { 0 => 150 }
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware::Forms::Generic
4
+ module Homecare::V1
5
+ class Signoff < Base
6
+ def build
7
+ move_down 40
8
+ font_size 10
9
+ consultant
10
+ move_down 40
11
+ prescriber
12
+ move_down 40
13
+ text "Order number:", style: :bold
14
+ move_down 10
15
+ text "Other pharmacy comments:", style: :bold
16
+ end
17
+
18
+ private
19
+
20
+ def consultant
21
+ table(
22
+ [
23
+ [heading("Consultant:"), args.consultant]
24
+ ],
25
+ column_widths: { 0 => 80, 1 => 210 },
26
+ **table_styles,
27
+ **underlined_table_style
28
+ )
29
+ end
30
+
31
+ def prescriber
32
+ table(
33
+ [
34
+ [heading("Prescriber:"), heading("Signature:"), heading("Date:")]
35
+ ],
36
+ column_widths: {
37
+ 0 => 220,
38
+ 1 => 215,
39
+ 2 => 100
40
+ },
41
+ **table_styles.merge(underlined_table_style)
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
@@ -3,14 +3,8 @@
3
3
  require "prawn"
4
4
  require "prawn/table"
5
5
  require "attr_extras"
6
- require "active_support"
7
6
 
8
7
  module Renalware::Forms
9
8
  module Homecare
10
- extend ActiveSupport::Autoload
11
-
12
- autoload :Pdf
13
- autoload :Args
14
- autoload :Generic
15
9
  end
16
10
  end
@@ -3,47 +3,76 @@
3
3
  require "virtus"
4
4
  require "active_model"
5
5
 
6
+ # rubocop:disable Metrics/ClassLength
6
7
  module Renalware::Forms
7
8
  class Homecare::Args
8
- include Virtus::Model
9
+ include Virtus.model
9
10
  include ActiveModel::Validations
10
11
 
12
+ class Medication
13
+ include Virtus.model(strict: true)
14
+ include ActiveModel::Validations
15
+
16
+ attribute :date, Date
17
+ attribute :drug, String
18
+ attribute :dose, String
19
+ attribute :route, String
20
+ attribute :frequency, String
21
+ end
22
+
11
23
  # The first 2 attrbutes are used to drive what PDF to build
12
24
  attribute :provider, String
13
25
  attribute :version, Integer
14
-
15
- attribute :title, String
26
+ attribute :title, String, default: ""
16
27
  attribute :given_name, String
17
28
  attribute :family_name, String
18
- attribute :nhs_number, String
29
+ attribute :nhs_number, String, default: ""
19
30
  attribute :born_on, Date
20
- attribute :fmc_patient, String
21
- attribute :telephone, String
22
- attribute :hospital_number, String
23
- attribute :address, String
24
- attribute :postcode, String
31
+ attribute :modality, String, default: ""
32
+ attribute :fmc_patient, String, default: ""
33
+ attribute :telephone, String, default: ""
34
+ attribute :hospital_number, String, default: ""
35
+ attribute :address, Array(String), default: []
36
+ attribute :postcode, String, default: ""
25
37
  attribute :modality, String
26
- attribute :prescriber_name, String
38
+ attribute :prescriber_name, String, default: ""
27
39
  attribute :prescription_date, Date
28
40
  attribute :hospital_name, String
29
41
  attribute :hospital_department, String
30
42
  attribute :hospital_address, Array[String]
31
43
  attribute :po_number, String
44
+ attribute :generated_at, DateTime
32
45
  attribute :no_known_allergies, Boolean
33
46
  attribute :allergies, Array[String]
47
+ attribute :drug_type, String
34
48
  attribute :administration_route, String
35
49
  attribute :administration_frequency, String
36
50
  attribute :prescription_duration, String
37
51
  attribute :administration_device, String
52
+ attribute :medications, Array[Medication]
53
+ attribute :consultant, String
54
+ attribute :delivery_frequencies, Array[String], default: ["3 months", "6 months"]
55
+ attribute :prescription_durations, Array[String] # e.g. ["3 months", "6 months"]
56
+ attribute :selected_prescription_duration, String # e.g. "3 months"
38
57
 
39
58
  # validates! will raise eg ActiveModel::StrictValidationFailed: Family name can't be blank
40
59
  validates! :family_name, presence: true
41
60
  validates! :given_name, presence: true
42
61
 
62
+ def patient_name
63
+ name = [family_name, given_name].compact.join(", ")
64
+ name += " (#{title})" if title.to_s != ""
65
+ name
66
+ end
67
+
43
68
  def formatted_address
44
69
  format_address_array address
45
70
  end
46
71
 
72
+ def formatted_address_and_postcode
73
+ format_address_array(address << postcode)
74
+ end
75
+
47
76
  def formatted_hospital_address
48
77
  format_address_array hospital_address
49
78
  end
@@ -81,11 +110,13 @@ module Renalware::Forms
81
110
  args.fmc_patient = "123"
82
111
  args.telephone = "07000 000001"
83
112
  args.hospital_number = "ABC123"
84
- args.address = ["line1", "", nil, "line2", "line3. "]
113
+ args.modality = "PD"
114
+ args.address = ["line1", "", nil, "line2", "line3 "]
85
115
  args.postcode = "TW1 1UU"
86
116
  args.modality = "HD"
87
117
  args.prescriber_name = "Dr X Yz"
88
118
  args.prescription_date = Date.today.to_s
119
+ args.consultant = "Dr Pepper"
89
120
  args.hospital_name = "THE ROYAL LONDON HOSPITAL"
90
121
  args.hospital_department = ""
91
122
  args.hospital_address = [
@@ -97,13 +128,28 @@ module Renalware::Forms
97
128
  ]
98
129
  args.no_known_allergies = false
99
130
  args.allergies = ["Nuts", nil, "Penicillin", "Mown grass"]
131
+ args.drug_type = "ESA"
100
132
  args.administration_frequency = "Daily"
101
133
  args.administration_route = "Per Oral"
102
134
  args.prescription_duration = "1 month"
103
135
  args.administration_device = "device?"
136
+ args.po_number = "P123"
137
+ args.generated_at = Time.now
138
+ args.delivery_frequencies = ["1 week", "3 months", "6 months", "12 month"]
139
+ args.prescription_durations = ["3 months", "6 months", "12 months"]
140
+ args.selected_prescription_duration = "6 months"
141
+
142
+ args.medications << Medication.new(
143
+ date: Date.today,
144
+ drug: "Example drug",
145
+ dose: "1 unit",
146
+ route: "PO",
147
+ frequency: "3"
148
+ )
104
149
 
105
150
  raise ArgumentError, args.errors unless args.valid?
106
151
  end
107
152
  end
108
153
  end
109
154
  end
155
+ # rubocop:enable Metrics/ClassLength
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Renalware
4
4
  module Forms
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: activemodel
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +94,20 @@ dependencies:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
96
  version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: zeitwerk
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -151,8 +151,16 @@ files:
151
151
  - lib/renalware/forms/generic.rb
152
152
  - lib/renalware/forms/generic/homecare.rb
153
153
  - lib/renalware/forms/generic/homecare/v1.rb
154
+ - lib/renalware/forms/generic/homecare/v1/allergies.rb
155
+ - lib/renalware/forms/generic/homecare/v1/assets/nhs_logo.jpg
154
156
  - lib/renalware/forms/generic/homecare/v1/base.rb
157
+ - lib/renalware/forms/generic/homecare/v1/delivery_frequencies.rb
155
158
  - lib/renalware/forms/generic/homecare/v1/document.rb
159
+ - lib/renalware/forms/generic/homecare/v1/heading.rb
160
+ - lib/renalware/forms/generic/homecare/v1/medications.rb
161
+ - lib/renalware/forms/generic/homecare/v1/patient_details.rb
162
+ - lib/renalware/forms/generic/homecare/v1/prescription_durations.rb
163
+ - lib/renalware/forms/generic/homecare/v1/signoff.rb
156
164
  - lib/renalware/forms/helpers.rb
157
165
  - lib/renalware/forms/homecare.rb
158
166
  - lib/renalware/forms/homecare/args.rb