renalware-forms 0.1.10 → 0.1.11

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: 92ef42b414ec62117acbf04fc22a9bf34e1ca82176a69c02914c564345f6f327
4
+ data.tar.gz: c951b4c7190b188bda3d2544e96fe173bf52b19ee3eb77313215c4b5708c738b
5
5
  SHA512:
6
- metadata.gz: 5b2beb336928b99dbeda3d71a54204f7a7a942cc4436853fe827a819c8c84f9a29208cb1254c15886987deec20bd8640060065a752763e6f59306751e7b03412
7
- data.tar.gz: 3fd76b82b143ded9456ecdeea33603ad5290af005ff6ca479676207d090b981243e7aaf1358e7b9fe20743401314a60d2f0d38c12c9b8ca8def935361f00b266
6
+ metadata.gz: 0e834a60b44a5244f9845eb8897624a1a64fba69c2dca49755dab064f61629a78f4bb020624ff007ab4376da87b2dd562f526d068972b848534e5068398c0784
7
+ data.tar.gz: 23b9b51811838cc076afb490526bd79adc2943a16038b7be9747122f05ee9c9d00ef84d08b27523346de161a643d680ae0c4c64f84bebd5bd7a56357a58e2b53
@@ -1,58 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "virtus"
3
+ require "dry-types"
4
+ require "dry-struct"
4
5
  require "active_model"
5
6
 
6
7
  # rubocop:disable Metrics/ClassLength
7
8
  module Renalware::Forms
8
- class Homecare::Args
9
- include Virtus.model
9
+ module Types
10
+ include Dry.Types()
11
+ end
12
+
13
+ class Homecare::Args < Dry::Struct
10
14
  include ActiveModel::Validations
11
15
 
12
- class Medication
13
- include Virtus.model(strict: true)
16
+ class Medication < Dry::Struct
14
17
  include ActiveModel::Validations
15
18
 
16
- attribute :date, Date
17
- attribute :drug, String
18
- attribute :dose, String
19
- attribute :route, String
20
- attribute :frequency, String
19
+ attribute :date, Types::Params::Date
20
+ attribute :drug, Types::String
21
+ attribute :dose, Types::String
22
+ attribute :route, Types::String
23
+ attribute :frequency, Types::String
21
24
  end
22
25
 
23
26
  # The first 2 attrbutes are used to drive what PDF to build
24
- attribute :provider, String
25
- attribute :version, Integer
26
- attribute :title, String, default: ""
27
- attribute :given_name, String
28
- attribute :family_name, String
29
- attribute :nhs_number, String, default: ""
30
- attribute :born_on, Date
31
- attribute :modality, String, default: ""
32
- attribute :telephone, String, default: ""
33
- attribute :hospital_number, String, default: ""
34
- attribute :address, Array(String), default: []
35
- attribute :postcode, String, default: ""
36
- attribute :modality, String
37
- attribute :prescriber_name, String, default: ""
38
- attribute :prescription_date, Date
39
- attribute :hospital_name, String
40
- attribute :hospital_department, String
41
- attribute :hospital_address, Array[String]
42
- attribute :hospital_telephone, String
43
- attribute :po_number, String
44
- attribute :generated_at, DateTime
45
- attribute :no_known_allergies, Boolean
46
- attribute :allergies, Array[String]
47
- attribute :drug_type, String
48
- attribute :prescription_duration, String
49
- attribute :administration_device, String
50
- attribute :medications, Array[Medication]
51
- attribute :consultant, String
52
- attribute :delivery_frequencies, Array[String], default: ["3 months", "6 months"]
53
- attribute :prescription_durations, Array[String] # e.g. ["3 months", "6 months"]
54
- attribute :selected_prescription_duration, String # e.g. "3 months"
55
- attribute :selected_delivery_frequency, String # e.g. "6 months"
27
+ attribute :provider, Types::Coercible::String
28
+ attribute :version, Types::Integer
29
+ attribute :title, Types::String.default("")
30
+ attribute :given_name, Types::String
31
+ attribute :family_name, Types::String
32
+ attribute :nhs_number, Types::String.default("")
33
+ attribute :born_on, Types::Params::Date
34
+ attribute :modality, Types::String.default("")
35
+ attribute :telephone, Types::String.default("")
36
+ attribute :hospital_number, Types::String.default("")
37
+ attribute :address, Types::Array.of(Types::Coercible::String).default([].dup, shared: true)
38
+ attribute :postcode, Types::String.default("")
39
+ attribute :prescriber_name, Types::String.default("")
40
+ attribute :prescription_date, Types::Params::Date
41
+ attribute :hospital_name, Types::String.default("")
42
+ attribute :hospital_department, Types::String.default("")
43
+ attribute :hospital_address, Types::Array.of(Types::Coercible::String).default([], shared: true)
44
+ attribute :hospital_telephone, Types::String.default("")
45
+ attribute :po_number, Types::String.default("")
46
+ attribute :generated_at, (Types::Params::DateTime.default { DateTime.now })
47
+ attribute :no_known_allergies, Types::Bool
48
+ attribute :allergies, Types::Array.of(Types::Coercible::String)
49
+ attribute :drug_type, Types::Coercible::String
50
+ # attribute :prescription_duration, Types::String
51
+ attribute :administration_device, Types::String.default("")
52
+ attribute :medications, Types::Array.of(Medication).default([].dup, shared: true)
53
+ attribute :consultant, Types::String.default("")
54
+ attribute(
55
+ :delivery_frequencies,
56
+ Types::Array.of(Types::Coercible::String).default(["3 months", "6 months"].freeze)
57
+ )
58
+ attribute(
59
+ :prescription_durations,
60
+ Types::Array
61
+ .of(Types::Coercible::String)
62
+ .default(["3 months", "6 months", "12 months"].freeze)
63
+ )
64
+ attribute :selected_prescription_duration, Types::String.default("") # e.g. "6 months"
65
+ attribute :selected_delivery_frequency, Types::String.default("") # e.g. "6 months"
56
66
 
57
67
  validates :family_name, presence: true
58
68
  validates :given_name, presence: true
@@ -100,27 +110,26 @@ module Renalware::Forms
100
110
  end
101
111
 
102
112
  def self.test_data(provider: :generic, version: 1)
103
- new.tap do |args|
104
- args.provider = provider
105
- args.version = version
106
- args.title = "Mr"
107
- args.given_name = "Jack"
108
- args.family_name = "JONES"
109
- args.nhs_number = "0123456789"
110
- args.born_on = Date.parse("2001-01-01")
111
- args.telephone = "07000 000001"
112
- args.hospital_number = "ABC123"
113
- args.modality = "PD"
114
- args.address = ["line1", "", nil, "line2", "line3 "]
115
- args.postcode = "TW1 1UU"
116
- args.modality = "HD"
117
- args.prescriber_name = "Dr X Yz"
118
- args.prescription_date = Date.today.to_s
119
- args.consultant = "Dr Pepper"
120
- args.hospital_name = "THE ROYAL LONDON HOSPITAL"
121
- args.hospital_telephone = "0000 000001"
122
- args.hospital_department = "Renal"
123
- args.hospital_address = [
113
+ args = new(
114
+ provider: provider,
115
+ version: version,
116
+ title: "Mr",
117
+ given_name: "Jack",
118
+ family_name: "JONES",
119
+ nhs_number: "0123456789",
120
+ born_on: Date.parse("2001-01-01"),
121
+ telephone: "07000 000001",
122
+ hospital_number: "ABC123",
123
+ modality: "HD",
124
+ address: ["line1", "", nil, "line2", "line3 "],
125
+ postcode: "TW1 1UU",
126
+ prescriber_name: "Dr X Yz",
127
+ prescription_date: Date.today.to_s,
128
+ consultant: "Dr Pepper",
129
+ hospital_name: "THE ROYAL LONDON HOSPITAL",
130
+ hospital_telephone: "0000 000001",
131
+ hospital_department: "Renal",
132
+ hospital_address: [
124
133
  "The Royal London Hospital",
125
134
  "Barts Health NHS Trust",
126
135
  "Whitechapel",
@@ -129,30 +138,29 @@ module Renalware::Forms
129
138
  "UK",
130
139
  "Tel: 0800 00000000",
131
140
  "Another line"
132
-
133
- ]
134
- args.no_known_allergies = false
135
- args.allergies = ["Nuts", nil, "Penicillin", "Mown grass"]
136
- args.drug_type = "ESA"
137
- args.prescription_duration = "1 month"
138
- args.administration_device = "device?"
139
- args.po_number = "P123"
140
- args.generated_at = Time.now
141
- args.delivery_frequencies = ["1 week", "3 months", "6 months", "12 month"]
142
- args.prescription_durations = ["3 months", "6 months", "12 months"]
143
- args.selected_prescription_duration = "6 months"
144
- args.selected_delivery_frequency = "6 months"
145
-
146
- args.medications << Medication.new(
147
- date: Date.today,
148
- drug: "Example drug",
149
- dose: "1 unit",
150
- route: "PO",
151
- frequency: "3"
152
- )
153
-
154
- raise ArgumentError, args.errors unless args.valid?
155
- end
141
+ ],
142
+ no_known_allergies: false,
143
+ allergies: ["Nuts", nil, "Penicillin", "Mown grass"],
144
+ drug_type: "ESA",
145
+ prescription_duration: "1 month",
146
+ administration_device: "device?",
147
+ po_number: "P123",
148
+ delivery_frequencies: ["1 week", "3 months", "6 months", "12 month"],
149
+ prescription_durations: ["3 months", "6 months", "12 months"],
150
+ selected_prescription_duration: "6 months",
151
+ selected_delivery_frequency: "6 months"
152
+ )
153
+
154
+ args.medications << Medication.new(
155
+ date: Date.today,
156
+ drug: "Example drug",
157
+ dose: "1 unit",
158
+ route: "PO",
159
+ frequency: "3"
160
+ )
161
+
162
+ raise ArgumentError, args.errors unless args.valid?
163
+ args
156
164
  end
157
165
 
158
166
  def medications_are_present
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Renalware
4
4
  module Forms
5
- VERSION = "0.1.10"
5
+ VERSION = "0.1.11"
6
6
  end
7
7
  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.11
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: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -81,19 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: virtus
84
+ name: dry-types
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: dry-struct
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'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: zeitwerk
99
113
  requirement: !ruby/object:Gem::Requirement