renalware-forms 0.1.10 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cce70f650aa4a18739885e3f567b4bea6195f15c8d75f2708ba23a30d04f927
4
- data.tar.gz: d39780022bd9edf3c20f01bceba25d0b23098890d4805168bea339970bb69d3b
3
+ metadata.gz: 17b52d0a15890cefaeb0f17f380dfdb7ad4278a018e33c8efce02d0223087661
4
+ data.tar.gz: e03e9e3936da756f26656fa3a3f7f20a0aa2adbc8b4a3e6ffa4171722945fa56
5
5
  SHA512:
6
- metadata.gz: 5b2beb336928b99dbeda3d71a54204f7a7a942cc4436853fe827a819c8c84f9a29208cb1254c15886987deec20bd8640060065a752763e6f59306751e7b03412
7
- data.tar.gz: 3fd76b82b143ded9456ecdeea33603ad5290af005ff6ca479676207d090b981243e7aaf1358e7b9fe20743401314a60d2f0d38c12c9b8ca8def935361f00b266
6
+ metadata.gz: 7916272475387df5ae34a022fa4119bbe563e556607e3c695255193fc1f2058ced488dd3cbd72f6cb21923ccfde2a782ae2a92d66993b41a0a5bec500c640a01
7
+ data.tar.gz: 24e0160727b509117d8c1ec5b60154e43b15180b1e94113b8e1bcc072083301196c79b8ea21a3e469b458f896701709af7c0ff8a7ea7a5cf702130e402f3bfe8
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ tmp/**/*
2
+ .byebug_history
3
+ .rubocop-https---raw-githubusercontent-com-airslie-styleguide-master-rubocop-yml
4
+ .overcommit.yml
5
+ pkg/renalware-forms-0.1.0.gem
6
+ coverage
7
+ pkg
8
+ .bundle
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,63 @@
1
+ require:
2
+ - rubocop-rails
3
+ - rubocop-rspec
4
+ - rubocop-performance
5
+
6
+ # Note that the local default.yml is overwritten on CodeClimate with the contents of
7
+ # the remote rubocop.yml pulled from GitHub in a codeclimate prepare step.
8
+ inherit_from:
9
+ - default.yml
10
+
11
+ AllCops:
12
+ UseCache: true
13
+ TargetRubyVersion: 3.0
14
+ # Just defining the Exclude or Include keys here overwrites the settings in default.yml
15
+ # so we have to redefine the entire set
16
+ Exclude:
17
+ - "*.gemspec"
18
+ - "vendor/**/*"
19
+ - "bin/**/*"
20
+ - "lib/tasks/**/*"
21
+ - "db/**/*"
22
+ - "spec/dummy/bin/**/*"
23
+ - "spec/dummy/lib/tasks/**/*"
24
+ - "spec/dummy/db/**/*"
25
+ - "tmp/**/*"
26
+ - "spec/dummy/tmp/**/*"
27
+ - "vendor/bundle/**/*"
28
+ - "config/initializers/devise.rb"
29
+
30
+ Layout/LineLength:
31
+ Exclude:
32
+ - "spec/acceptance/renalware/steps/**/*"
33
+
34
+ Metrics/AbcSize:
35
+ Max: 50
36
+ RSpec/ExampleLength:
37
+ Max: 40
38
+ RSpec/NestedGroups:
39
+ Max: 4
40
+ RSpec/MultipleExpectations:
41
+ Max: 20
42
+ RSpec/DescribeClass:
43
+ Enabled: false
44
+ RSpec/ImplicitSubject:
45
+ Enabled: false
46
+ RSpec/DescribedClass:
47
+ Enabled: false
48
+ Performance/RedundantBlockCall:
49
+ Enabled: false
50
+ Style/NumericPredicate:
51
+ Enabled: false
52
+ RSpec/InstanceVariable:
53
+ Enabled: false
54
+ Metrics/MethodLength:
55
+ Max: 50
56
+ Rails/Date:
57
+ Enabled: false
58
+ Rails/TimeZone:
59
+ Enabled: false
60
+ Style/AsciiComments:
61
+ Enabled: false
62
+ Style/ZeroLengthPredicate:
63
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
@@ -0,0 +1,51 @@
1
+ # Use the latest stable version of Semaphore 2.0 YML syntax:
2
+ version: v1.0
3
+ name: renalware-forms
4
+
5
+ agent:
6
+ machine:
7
+ type: e1-standard-2
8
+ os_image: ubuntu1804
9
+
10
+ blocks:
11
+ - name: Test setup
12
+ task:
13
+ jobs:
14
+ - name: bundle
15
+ commands:
16
+ - checkout
17
+ - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-master-
18
+ - sem-version ruby 3.0.2
19
+ - bundle install --deployment -j 4 --path vendor/bundle
20
+ - cache store gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock) vendor/bundle
21
+
22
+ - name: Tests
23
+ task:
24
+ env_vars:
25
+ - name: RAILS_ENV
26
+ value: test
27
+
28
+ # This secret on semaphore contains the CC_TEST_REPORTER_ID ENV var
29
+ secrets:
30
+ - name: renalware-forms
31
+
32
+ prologue:
33
+ commands:
34
+ - checkout
35
+ - cache restore gems-$SEMAPHORE_GIT_BRANCH-$(checksum Gemfile.lock),gems-$SEMAPHORE_GIT_BRANCH-,gems-master-
36
+ - git submodule sync ; git submodule update --init
37
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
38
+ - chmod +x ./cc-test-reporter
39
+ - ./cc-test-reporter before-build
40
+ - sem-version ruby 3.0.2
41
+ - bundle install --deployment --path vendor/bundle
42
+
43
+ jobs:
44
+ - name: RSpec tests
45
+ commands:
46
+ - bundle exec rspec --format progress
47
+
48
+ epilogue:
49
+ on_pass:
50
+ commands:
51
+ - ./cc-test-reporter after-build
data/CHANGELOG.md ADDED
@@ -0,0 +1,45 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in
4
+ this [changelog](http://keepachangelog.com/en/0.3.0/).
5
+ This project adheres to Semantic Versioning.
6
+
7
+ ## Unreleased
8
+ ### Added
9
+ ### Changed
10
+ ### Fixed
11
+
12
+ ## 0.1.14
13
+ 6 Oct 2021
14
+ ### Added
15
+ ### Changed
16
+ - Switched from dry-types to Virtus
17
+ - Use Ruby 3
18
+
19
+ ### Fixed
20
+ ## 0.1.11
21
+ 3 April 2020
22
+ ### Added
23
+ ### Changed
24
+ - Switched from Virtus to dry-types
25
+ ### Fixed
26
+
27
+ ## 0.1.7
28
+ 31 Mar 2020
29
+ ### Added
30
+ ### Changed
31
+ ### Fixed
32
+ - Remove unused homecare args
33
+
34
+ ## 0.1.6
35
+ 31 Mar 2020
36
+ ### Added
37
+ ### Changed
38
+ ### Fixed
39
+ - Support supplying a selected delivery frequency
40
+
41
+ ## 0.1.3
42
+ ### Added
43
+ ### Changed
44
+ ### Fixed
45
+ - Bring in allergies
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in renalware-forms.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ group :development, :test do
15
+ gem "byebug"
16
+ gem "rubocop"
17
+ gem "rubocop-performance"
18
+ gem "rubocop-rails"
19
+ gem "rubocop-rspec"
20
+ gem "simplecov", "~> 0.17.1"
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ renalware-forms (0.1.14)
5
+ activemodel
6
+ attr_extras (~> 6.2)
7
+ prawn (~> 2.2)
8
+ prawn-table (~> 0.2)
9
+ rake
10
+ virtus
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ Ascii85 (1.1.0)
16
+ activemodel (6.1.4.1)
17
+ activesupport (= 6.1.4.1)
18
+ activesupport (6.1.4.1)
19
+ concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ i18n (>= 1.6, < 2)
21
+ minitest (>= 5.1)
22
+ tzinfo (~> 2.0)
23
+ zeitwerk (~> 2.3)
24
+ afm (0.2.2)
25
+ ast (2.4.2)
26
+ attr_extras (6.2.4)
27
+ axiom-types (0.1.1)
28
+ descendants_tracker (~> 0.0.4)
29
+ ice_nine (~> 0.11.0)
30
+ thread_safe (~> 0.3, >= 0.3.1)
31
+ byebug (11.1.3)
32
+ coercible (1.0.0)
33
+ descendants_tracker (~> 0.0.1)
34
+ concurrent-ruby (1.1.9)
35
+ descendants_tracker (0.0.4)
36
+ thread_safe (~> 0.3, >= 0.3.1)
37
+ diff-lcs (1.4.4)
38
+ docile (1.4.0)
39
+ hashery (2.1.2)
40
+ i18n (1.8.10)
41
+ concurrent-ruby (~> 1.0)
42
+ ice_nine (0.11.2)
43
+ json (2.5.1)
44
+ minitest (5.14.4)
45
+ parallel (1.21.0)
46
+ parser (3.0.2.0)
47
+ ast (~> 2.4.1)
48
+ pdf-core (0.9.0)
49
+ pdf-reader (2.5.0)
50
+ Ascii85 (~> 1.0)
51
+ afm (~> 0.2.1)
52
+ hashery (~> 2.0)
53
+ ruby-rc4
54
+ ttfunk
55
+ prawn (2.4.0)
56
+ pdf-core (~> 0.9.0)
57
+ ttfunk (~> 1.7)
58
+ prawn-table (0.2.2)
59
+ prawn (>= 1.3.0, < 3.0.0)
60
+ rack (2.2.3)
61
+ rainbow (3.0.0)
62
+ rake (13.0.6)
63
+ regexp_parser (2.1.1)
64
+ rexml (3.2.5)
65
+ rspec (3.10.0)
66
+ rspec-core (~> 3.10.0)
67
+ rspec-expectations (~> 3.10.0)
68
+ rspec-mocks (~> 3.10.0)
69
+ rspec-core (3.10.1)
70
+ rspec-support (~> 3.10.0)
71
+ rspec-expectations (3.10.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.10.0)
74
+ rspec-mocks (3.10.2)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.10.0)
77
+ rspec-support (3.10.2)
78
+ rubocop (1.22.1)
79
+ parallel (~> 1.10)
80
+ parser (>= 3.0.0.0)
81
+ rainbow (>= 2.2.2, < 4.0)
82
+ regexp_parser (>= 1.8, < 3.0)
83
+ rexml
84
+ rubocop-ast (>= 1.12.0, < 2.0)
85
+ ruby-progressbar (~> 1.7)
86
+ unicode-display_width (>= 1.4.0, < 3.0)
87
+ rubocop-ast (1.12.0)
88
+ parser (>= 3.0.1.1)
89
+ rubocop-performance (1.11.5)
90
+ rubocop (>= 1.7.0, < 2.0)
91
+ rubocop-ast (>= 0.4.0)
92
+ rubocop-rails (2.12.2)
93
+ activesupport (>= 4.2.0)
94
+ rack (>= 1.1)
95
+ rubocop (>= 1.7.0, < 2.0)
96
+ rubocop-rspec (2.5.0)
97
+ rubocop (~> 1.19)
98
+ ruby-progressbar (1.11.0)
99
+ ruby-rc4 (0.1.5)
100
+ simplecov (0.17.1)
101
+ docile (~> 1.1)
102
+ json (>= 1.8, < 3)
103
+ simplecov-html (~> 0.10.0)
104
+ simplecov-html (0.10.2)
105
+ thread_safe (0.3.6)
106
+ ttfunk (1.7.0)
107
+ tzinfo (2.0.4)
108
+ concurrent-ruby (~> 1.0)
109
+ unicode-display_width (2.1.0)
110
+ virtus (2.0.0)
111
+ axiom-types (~> 0.1)
112
+ coercible (~> 1.0)
113
+ descendants_tracker (~> 0.0, >= 0.0.3)
114
+ zeitwerk (2.4.2)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ byebug
121
+ pdf-reader
122
+ renalware-forms!
123
+ rspec
124
+ rubocop
125
+ rubocop-performance
126
+ rubocop-rails
127
+ rubocop-rspec
128
+ simplecov (~> 0.17.1)
129
+
130
+ BUNDLED WITH
131
+ 2.2.28
data/bin/rspec ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ load Gem.bin_path('rspec-core', 'rspec')
data/default.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/airslie/styleguide/master/rubocop.yml
3
+
4
+ # Don't add anything to this file other than the inherit_from above
5
+ # as this file is overwritten on CodeClimate with the contents of the above
6
+ # remote url which is downloaded in a CodeClimate prepare step.
@@ -6,3 +6,14 @@ module Renalware::Forms::Generic
6
6
  end
7
7
  end
8
8
  end
9
+
10
+ require_relative "v1/base"
11
+ require_relative "v1/allergies"
12
+ require_relative "v1/delivery_frequencies"
13
+ require_relative "v1/document"
14
+ require_relative "v1/footer"
15
+ require_relative "v1/heading"
16
+ require_relative "v1/medications"
17
+ require_relative "v1/patient_details"
18
+ require_relative "v1/prescription_durations"
19
+ require_relative "v1/signoff"
@@ -6,3 +6,5 @@ module Renalware::Forms
6
6
  end
7
7
  end
8
8
  end
9
+
10
+ require_relative "homecare/v1"
@@ -4,3 +4,5 @@ module Renalware::Forms
4
4
  module Generic
5
5
  end
6
6
  end
7
+
8
+ require_relative "generic/homecare"
@@ -29,6 +29,7 @@ module Renalware::Forms
29
29
  attribute :nhs_number, String, default: ""
30
30
  attribute :born_on, Date
31
31
  attribute :modality, String, default: ""
32
+ attribute :fmc_patient, String, default: ""
32
33
  attribute :telephone, String, default: ""
33
34
  attribute :hospital_number, String, default: ""
34
35
  attribute :address, Array(String), default: []
@@ -45,14 +46,16 @@ module Renalware::Forms
45
46
  attribute :no_known_allergies, Boolean
46
47
  attribute :allergies, Array[String]
47
48
  attribute :drug_type, String
49
+ attribute :administration_route, String
50
+ attribute :administration_frequency, String
48
51
  attribute :prescription_duration, String
49
52
  attribute :administration_device, String
50
53
  attribute :medications, Array[Medication]
51
54
  attribute :consultant, String
52
55
  attribute :delivery_frequencies, Array[String], default: ["3 months", "6 months"]
56
+ attribute :selected_delivery_frequency, String # e.g. "6 months"
53
57
  attribute :prescription_durations, Array[String] # e.g. ["3 months", "6 months"]
54
58
  attribute :selected_prescription_duration, String # e.g. "3 months"
55
- attribute :selected_delivery_frequency, String # e.g. "6 months"
56
59
 
57
60
  validates :family_name, presence: true
58
61
  validates :given_name, presence: true
@@ -84,7 +87,7 @@ module Renalware::Forms
84
87
  end
85
88
 
86
89
  def format_address_array(add)
87
- return unless add&.is_a?(Array)
90
+ return unless add.is_a?(Array)
88
91
 
89
92
  add.compact.reject { |line| line == "" }.uniq&.join("\n")
90
93
  end
@@ -99,6 +102,7 @@ module Renalware::Forms
99
102
  Array(allergies).uniq.compact.join("<br>")
100
103
  end
101
104
 
105
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
102
106
  def self.test_data(provider: :generic, version: 1)
103
107
  new.tap do |args|
104
108
  args.provider = provider
@@ -108,6 +112,7 @@ module Renalware::Forms
108
112
  args.family_name = "JONES"
109
113
  args.nhs_number = "0123456789"
110
114
  args.born_on = Date.parse("2001-01-01")
115
+ args.fmc_patient = "123"
111
116
  args.telephone = "07000 000001"
112
117
  args.hospital_number = "ABC123"
113
118
  args.modality = "PD"
@@ -121,19 +126,20 @@ module Renalware::Forms
121
126
  args.hospital_telephone = "0000 000001"
122
127
  args.hospital_department = "Renal"
123
128
  args.hospital_address = [
124
- "The Royal London Hospital",
125
- "Barts Health NHS Trust",
126
- "Whitechapel",
129
+ nil,
130
+ "WHITECHAPEL",
131
+ "",
127
132
  "LONDON",
128
133
  "E1 1FR",
129
134
  "UK",
130
135
  "Tel: 0800 00000000",
131
136
  "Another line"
132
-
133
137
  ]
134
138
  args.no_known_allergies = false
135
139
  args.allergies = ["Nuts", nil, "Penicillin", "Mown grass"]
136
140
  args.drug_type = "ESA"
141
+ args.administration_frequency = "Daily"
142
+ args.administration_route = "Per Oral"
137
143
  args.prescription_duration = "1 month"
138
144
  args.administration_device = "device?"
139
145
  args.po_number = "P123"
@@ -141,7 +147,6 @@ module Renalware::Forms
141
147
  args.delivery_frequencies = ["1 week", "3 months", "6 months", "12 month"]
142
148
  args.prescription_durations = ["3 months", "6 months", "12 months"]
143
149
  args.selected_prescription_duration = "6 months"
144
- args.selected_delivery_frequency = "6 months"
145
150
 
146
151
  args.medications << Medication.new(
147
152
  date: Date.today,
@@ -154,6 +159,7 @@ module Renalware::Forms
154
159
  raise ArgumentError, args.errors unless args.valid?
155
160
  end
156
161
  end
162
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
157
163
 
158
164
  def medications_are_present
159
165
  if medications.size == 0
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "prawn"
4
- require "prawn/table"
5
- require "attr_extras"
6
-
7
3
  module Renalware::Forms
8
4
  module Homecare
9
5
  end
10
6
  end
7
+
8
+ require_relative "homecare/args"
9
+ require_relative "homecare/pdf"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Renalware
4
4
  module Forms
5
- VERSION = "0.1.10"
5
+ VERSION = "0.1.14"
6
6
  end
7
7
  end
@@ -1,19 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "zeitwerk"
4
3
  require "prawn"
5
4
  require "prawn/table"
6
5
  require "attr_extras"
7
- require_relative "./forms/version"
8
-
9
- # Set up autoloading with zeitwerk
10
- # As we are nested in lib/renalware/forms, be sure to push an absolute
11
- # path to the lib folder.
12
- loader = Zeitwerk::Loader.new
13
- loader.push_dir File.expand_path("../", __dir__)
14
- loader.setup
15
6
 
16
7
  module Renalware
17
8
  module Forms
18
9
  end
19
10
  end
11
+
12
+ require_relative "forms/base"
13
+ require_relative "forms/helpers"
14
+ require_relative "forms/generic"
15
+ require_relative "forms/homecare"
data/lib/tasks/tasks.rake CHANGED
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  desc "Starts irb so we can debug the gem"
2
- task :console do
4
+ task console: :environment do
3
5
  exec "irb -r ./lib/renalware/forms"
4
6
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
4
+
5
+ # Maintain your gem's version:
6
+ require "renalware/forms/version"
7
+
8
+ # Describe your gem and declare its dependencies:
9
+ Gem::Specification.new do |spec|
10
+ spec.name = "renalware-forms"
11
+ spec.version = Renalware::Forms::VERSION
12
+ spec.authors = ["Airslie Ltd"]
13
+ spec.email = ["dev@aisrlie.com"]
14
+ spec.homepage = "http://airslie.com"
15
+ spec.summary = "PDF library for Renalware forms"
16
+ spec.description = "The home for various forms for external providers eg home care prescriptions"
17
+ spec.license = "MIT"
18
+ spec.required_ruby_version = ">= 3.0.0"
19
+
20
+ spec.files = `git ls-files`.split("\n")
21
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
22
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+ spec.extra_rdoc_files = ["README.md"]
25
+
26
+ spec.add_dependency "activemodel"
27
+ spec.add_dependency "attr_extras", "~> 6.2"
28
+ spec.add_dependency "prawn", "~> 2.2"
29
+ spec.add_dependency "prawn-table", "~> 0.2"
30
+ spec.add_dependency "rake"
31
+ spec.add_dependency "virtus"
32
+ spec.add_development_dependency "pdf-reader"
33
+ spec.add_development_dependency "rspec"
34
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Homecare
6
+ RSpec.describe Args do
7
+ describe "#patient_name" do
8
+ subject {
9
+ hash = default_test_arg_values.update(
10
+ given_name: "John",
11
+ family_name: "SMITH",
12
+ title: title
13
+ )
14
+ described_class.new(hash).patient_name
15
+ }
16
+
17
+ context "when title present" do
18
+ let(:title) { "Mr" }
19
+
20
+ it { is_expected.to eq("SMITH, John (Mr)") }
21
+ end
22
+
23
+ context "when title missing" do
24
+ let(:title) { "" }
25
+
26
+ it { is_expected.to eq("SMITH, John") }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::Allergies do
7
+ context "when the patient has iit recoreded that they have no known allergies" do
8
+ it do
9
+ hash = default_test_arg_values.update(no_known_allergies: true)
10
+ args = Renalware::Forms::Homecare::Args.new(hash)
11
+ doc = test_prawn_doc
12
+
13
+ described_class.new(doc, args).build
14
+
15
+ text = extract_text_from_prawn_doc(doc)
16
+ expect(text).to include("No Known Allergies")
17
+ end
18
+ end
19
+
20
+ it do
21
+ hash = default_test_arg_values.update(
22
+ no_known_allergies: false,
23
+ allergies: %w(nuts penicillin)
24
+ )
25
+ args = Renalware::Forms::Homecare::Args.new(hash)
26
+ doc = test_prawn_doc
27
+
28
+ described_class.new(doc, args).build
29
+
30
+ text = extract_text_from_prawn_doc(doc)
31
+
32
+ expect(text).not_to include("No Known Allergies")
33
+ expect(text).to include("Known Allergies")
34
+ expect(text).to include("nuts")
35
+ expect(text).to include("penicillin")
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::DeliveryFrequencies do
7
+ def extract_pdf_text(args)
8
+ doc = test_prawn_doc
9
+ described_class.new(doc, args).build
10
+ extract_text_from_prawn_doc(doc)
11
+ end
12
+
13
+ it do
14
+ hash = default_test_arg_values.update(delivery_frequencies: ["Once", "3 weeks", "6 weeks"])
15
+ args = Renalware::Forms::Homecare::Args.new(hash)
16
+
17
+ text = extract_pdf_text(args)
18
+
19
+ expect(text).to include("Frequency of deliveries")
20
+ expect(text).to match(/❏ +Once/)
21
+ expect(text).to match(/❏ +3 weeks/)
22
+ expect(text).to match(/❏ +6 weeks/)
23
+ end
24
+
25
+ context "when there are no frequencies supplied" do
26
+ it "displays the defaults" do
27
+ args = Renalware::Forms::Homecare::Args.new(**default_test_arg_values)
28
+
29
+ text = extract_pdf_text(args)
30
+
31
+ expect(text).to match(/Frequency of deliveries/)
32
+ expect(text).to match(/❏ +3 months/)
33
+ expect(text).to match(/❏ +6 months/)
34
+ end
35
+ end
36
+
37
+ context "when there is a selected delivery_frequency" do
38
+ it "indicates that frequency has been selected by checking a box" do
39
+ hash = default_test_arg_values.update(
40
+ delivery_frequencies: ["3 months", "6 months", "12 months"],
41
+ selected_delivery_frequency: "6 months"
42
+ )
43
+ args = Renalware::Forms::Homecare::Args.new(hash)
44
+
45
+ text = extract_pdf_text(args)
46
+
47
+ expect(text).to match(/❏ +3 months/)
48
+ expect(text).to match(/■ +6 months/)
49
+ expect(text).to match(/❏ +12 months/)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::Heading do
7
+ it do
8
+ hash = default_test_arg_values.update(
9
+ po_number: "P123",
10
+ hospital_number: "H123",
11
+ drug_type: "ESA"
12
+ )
13
+ args = Renalware::Forms::Homecare::Args.new(hash)
14
+ doc = test_prawn_doc
15
+
16
+ described_class.new(doc, args).build
17
+
18
+ text = extract_text_from_prawn_doc(doc)
19
+
20
+ expect(text).to include(args.po_number)
21
+ expect(text).to include(args.hospital_number)
22
+ expect(text).to include(args.drug_type)
23
+ expect(text).to include("Home Delivery Medication List")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::Medications do
7
+ it do
8
+ args = Renalware::Forms::Homecare::Args.new(**default_test_arg_values)
9
+ args.medications << Renalware::Forms::Homecare::Args::Medication.new(
10
+ date: "2020-01-01",
11
+ drug: "Drug1",
12
+ dose: "Dose1",
13
+ route: "Route1",
14
+ frequency: "Freq1"
15
+ )
16
+ args.medications << Renalware::Forms::Homecare::Args::Medication.new(
17
+ date: "2020-02-02",
18
+ drug: "Drug2",
19
+ dose: "Dose2",
20
+ route: "Route2",
21
+ frequency: "Freq2"
22
+ )
23
+ doc = test_prawn_doc
24
+
25
+ described_class.new(doc, args).build
26
+
27
+ text = extract_text_from_prawn_doc(doc)
28
+
29
+ expect(text).to include("2020-01-01")
30
+ expect(text).to include("Drug1")
31
+ expect(text).to include("Dose1")
32
+ expect(text).to include("Route1")
33
+ expect(text).to include("Freq1")
34
+ expect(text).to include("Drug2")
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::PatientDetails do
7
+ it do
8
+ hash = default_test_arg_values.update(
9
+ given_name: "John",
10
+ family_name: "SMITH",
11
+ title: "Mr",
12
+ modality: "HD",
13
+ born_on: "2001-01-01",
14
+ nhs_number: "0123456789",
15
+ hospital_number: "X123",
16
+ address: %w(aa bb cc),
17
+ postcode: "POSTCODE"
18
+ )
19
+ args = Renalware::Forms::Homecare::Args.new(hash)
20
+ doc = test_prawn_doc
21
+
22
+ described_class.new(doc, args).build
23
+
24
+ text = extract_text_from_prawn_doc(doc)
25
+
26
+ expect(text).to include("SMITH, John (Mr)")
27
+ expect(text).to include("HD")
28
+ expect(text).to include("2001-01-01")
29
+ expect(text).to include("0123456789")
30
+ expect(text).to include("X123")
31
+ expect(text).to include("aa")
32
+ expect(text).to include("bb")
33
+ expect(text).to include("cc")
34
+ expect(text).to include("POSTCODE")
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::PrescriptionDurations do
7
+ def extract_pdf_text(args)
8
+ doc = test_prawn_doc
9
+ described_class.new(doc, args).build
10
+ extract_text_from_prawn_doc(doc)
11
+ end
12
+
13
+ it do
14
+ hash = default_test_arg_values.update(
15
+ prescription_durations: ["3 months", "6 months", "12 months"]
16
+ )
17
+ args = Renalware::Forms::Homecare::Args.new(hash)
18
+
19
+ text = extract_pdf_text(args)
20
+
21
+ expect(text).to include("Repeat prescription for")
22
+ expect(text).to match(/❏ +3 months/)
23
+ expect(text).to match(/❏ +6 months/)
24
+ expect(text).to match(/❏ +12 months/)
25
+ end
26
+
27
+ it "works where there are no prescription_durations supplied" do
28
+ args = Renalware::Forms::Homecare::Args.new(default_test_arg_values)
29
+
30
+ text = extract_pdf_text(args)
31
+
32
+ expect(text).to include("Repeat prescription for")
33
+ end
34
+
35
+ context "when there is a selected prescription_duration" do
36
+ it "indicates that duration has been selected eg for checking a box" do
37
+ args = Renalware::Forms::Homecare::Args.new(
38
+ default_test_arg_values.update(
39
+ prescription_durations: ["3 months", "6 months", "12 months"],
40
+ selected_prescription_duration: "6 months"
41
+ )
42
+ )
43
+
44
+ text = extract_pdf_text(args)
45
+
46
+ expect(text).to match(/❏ +3 months/)
47
+ expect(text).to match(/■ +6 months/)
48
+ expect(text).to match(/❏ +12 months/)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ module Renalware::Forms::Generic
6
+ RSpec.describe Homecare::V1::Signoff do
7
+ it do
8
+ args = Renalware::Forms::Homecare::Args.new(
9
+ **default_test_arg_values.update(consultant: "Dr Pepper")
10
+ )
11
+ doc = test_prawn_doc
12
+
13
+ described_class.new(doc, args).build
14
+
15
+ text = extract_text_from_prawn_doc(doc)
16
+ expect(text).to include("Dr Pepper")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe Renalware::Forms::Homecare::Pdf do
6
+ describe "#generate" do
7
+ # describe "argument validation" do
8
+ # it "throws an error if args is nil" do
9
+ # expect { described_class.generate(nil) }.to raise_error(ArgumentError)
10
+ # end
11
+
12
+ # it "throws an error if arg.provider is nil" do
13
+ # args = Renalware::Forms::Homecare::Args.new(provider: nil)
14
+
15
+ # expect {
16
+ # described_class.generate(args)
17
+ # }.to raise_error(ArgumentError, "Missing provider")
18
+ # end
19
+
20
+ # it "throws an error if arg.provider is an empty string" do
21
+ # args = Renalware::Forms::Homecare::Args.new(provider: "")
22
+
23
+ # expect {
24
+ # described_class.generate(args)
25
+ # }.to raise_error(ArgumentError, "Missing provider")
26
+ # end
27
+
28
+ # it "throws an error if arg.version is not a number" do
29
+ # args = Renalware::Forms::Homecare::Args.new(provider: :a, version: nil)
30
+
31
+ # expect {
32
+ # described_class.generate(args)
33
+ # }.to raise_error(ArgumentError, "Version must be >0")
34
+ # end
35
+
36
+ # it "throws an error no matching provider found" do
37
+ # args = Renalware::Forms::Homecare::Args.new(provider: :generico, version: 1)
38
+
39
+ # expect {
40
+ # described_class.generate(args)
41
+ # }.to raise_error(
42
+ # ArgumentError,
43
+ # "No PDF forms found for provider=generico version=1 "\
44
+ # "trying to resolve Renalware::Forms::Generico::Homecare::V1::Document"
45
+ # )
46
+ # end
47
+
48
+ # it "throws an error no matching version found" do
49
+ # args = Renalware::Forms::Homecare::Args.new(provider: :generic, version: 1000)
50
+
51
+ # expect {
52
+ # described_class.generate(args)
53
+ # }.to raise_error(
54
+ # ArgumentError,
55
+ # "No PDF forms found for provider=generic version=1000 "\
56
+ # "trying to resolve Renalware::Forms::Generic::Homecare::V1000::Document"
57
+ # )
58
+ # end
59
+ # end
60
+
61
+ context "when arguments are valid" do
62
+ it "create render a PDF for a Generic::Homecare::V1::Document" do
63
+ args = Renalware::Forms::Homecare::Args.new(**default_test_arg_values)
64
+
65
+ pdf_data = described_class.generate(args).render
66
+
67
+ expect(pdf_data).to start_with("%PDF-")
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+
17
+ require "simplecov"
18
+ SimpleCov.start
19
+
20
+ require "tempfile"
21
+ require "pdf-reader"
22
+ require "./lib/renalware/forms"
23
+
24
+ def pdf_reader_from(prawn_doc)
25
+ file = Tempfile.new("pdf")
26
+ prawn_doc.render_file file
27
+ PDF::Reader.new(file)
28
+ end
29
+
30
+ def test_prawn_doc
31
+ Prawn::Document.new(
32
+ page_size: "A4",
33
+ page_layout: :portrait,
34
+ margin: 15
35
+ )
36
+ end
37
+
38
+ def default_test_arg_values
39
+ {
40
+ provider: :generic,
41
+ version: 1,
42
+ modality: "HD",
43
+ telephone: "",
44
+ hospital_number: nil,
45
+ nhs_number: nil,
46
+ consultant: nil,
47
+ postcode: nil,
48
+ hospital_department: nil,
49
+ hospital_telephone: nil,
50
+ prescriber_name: nil,
51
+ po_number: "134",
52
+ administration_device: nil,
53
+ given_name: "John",
54
+ family_name: "SMITH",
55
+ title: "Mr",
56
+ no_known_allergies: true,
57
+ allergies: [],
58
+ drug_type: :esa,
59
+ born_on: "2019-01-01",
60
+ prescription_date: "2019-01-01"
61
+ }.dup
62
+ end
63
+
64
+ def extract_text_from_prawn_doc(doc)
65
+ pdf_reader_from(doc).pages.map(&:text).join
66
+ end
67
+
68
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
69
+ RSpec.configure do |config|
70
+ config.expect_with :rspec do |expectations|
71
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
72
+ end
73
+
74
+ config.mock_with :rspec do |mocks|
75
+ mocks.verify_partial_doubles = true
76
+ end
77
+ config.shared_context_metadata_behavior = :apply_to_host_groups
78
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.14
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-04-02 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -82,20 +82,6 @@ dependencies:
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: virtus
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.0'
97
- - !ruby/object:Gem::Dependency
98
- name: zeitwerk
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: rspec
98
+ name: pdf-reader
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: pdf-reader
112
+ name: rspec
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -136,16 +122,28 @@ dependencies:
136
122
  - - ">="
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
- description: The home for various forms for external providers e.g. home care prescriptions
125
+ description: The home for various forms for external providers eg home care prescriptions
140
126
  email:
141
127
  - dev@aisrlie.com
142
- executables: []
128
+ executables:
129
+ - rspec
143
130
  extensions: []
144
- extra_rdoc_files: []
131
+ extra_rdoc_files:
132
+ - README.md
145
133
  files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
137
+ - ".ruby-version"
138
+ - ".semaphore/semaphore.yml"
139
+ - CHANGELOG.md
140
+ - Gemfile
141
+ - Gemfile.lock
146
142
  - MIT-LICENSE
147
143
  - README.md
148
144
  - Rakefile
145
+ - bin/rspec
146
+ - default.yml
149
147
  - lib/renalware/forms.rb
150
148
  - lib/renalware/forms/base.rb
151
149
  - lib/renalware/forms/generic.rb
@@ -169,6 +167,17 @@ files:
169
167
  - lib/renalware/forms/version.rb
170
168
  - lib/tasks/homecare.rake
171
169
  - lib/tasks/tasks.rake
170
+ - renalware-forms.gemspec
171
+ - spec/renalware/forms/args_spec.rb
172
+ - spec/renalware/forms/homecare/generic/v1/allergies_spec.rb
173
+ - spec/renalware/forms/homecare/generic/v1/delivery_frequencies_spec.rb
174
+ - spec/renalware/forms/homecare/generic/v1/heading_spec.rb
175
+ - spec/renalware/forms/homecare/generic/v1/mediations_spec.rb
176
+ - spec/renalware/forms/homecare/generic/v1/patient_details_spec.rb
177
+ - spec/renalware/forms/homecare/generic/v1/prescription_durations_spec.rb
178
+ - spec/renalware/forms/homecare/generic/v1/signoff_spec.rb
179
+ - spec/renalware/forms/homecare/pdf_spec.rb
180
+ - spec/spec_helper.rb
172
181
  homepage: http://airslie.com
173
182
  licenses:
174
183
  - MIT
@@ -181,14 +190,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
190
  requirements:
182
191
  - - ">="
183
192
  - !ruby/object:Gem::Version
184
- version: '0'
193
+ version: 3.0.0
185
194
  required_rubygems_version: !ruby/object:Gem::Requirement
186
195
  requirements:
187
196
  - - ">="
188
197
  - !ruby/object:Gem::Version
189
198
  version: '0'
190
199
  requirements: []
191
- rubygems_version: 3.0.3
200
+ rubygems_version: 3.2.22
192
201
  signing_key:
193
202
  specification_version: 4
194
203
  summary: PDF library for Renalware forms