pacing 2.0.0 → 2.1.0

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: a71bff11bdcc21f74452c5217d348302f8e3680e3c2ed9d753ba1acd156f4d4a
4
- data.tar.gz: b78da81e0108e399aba1b422f56ce5509948d2708e8b6c5a011a0f82d91086fb
3
+ metadata.gz: bbc2189e33671c8a34eccd7aa71ec4f93d48fe0228e4931655bda84c519cc1d8
4
+ data.tar.gz: a1808e5be13be267c73b2720fabafbfe9e379029a209a86f5b19921c515497f5
5
5
  SHA512:
6
- metadata.gz: 87c3abd50e088736eae74610469c86972c2ec09c0e8da94d3c7e27dd02e34d62aef25ddab2acf602d90d46e8aefd515d3b1d6102fac37dd813bcbd24ef71f507
7
- data.tar.gz: 98a2d9a5b3fc8bd62630273ead673bce8a2c2ec3667dd706b3e3ab8efdbdd6db95df39501d8ac0a08170db4b40d6c66439fad08f6937a8c1b61bc97051377c7e
6
+ metadata.gz: f320cddb2b0a54b1f834c4a8a98fb496f6d7348c848525c26fdd52e22eaec8312f083df2b9378ca0bb2794480f6d6c3e8b65239221bdd27cf5463ac5bb8f2080
7
+ data.tar.gz: 7a6d01438e8ab61f2bec040cd2ddbdd14fda5b832d93324678ce0852fb10e34cd9a8d608b4c58fc89987d974c40a9251abbc4b9a25bb6c50b0c46a68e6688055
data/README.md CHANGED
@@ -117,6 +117,39 @@ paced.calculate
117
117
  ]
118
118
  =end
119
119
 
120
+ # Optionally if we want to include the frequency of the discipline in the pacing output we can
121
+ # pass in the optional param `show_frequency`. This value defaults to false.
122
+
123
+ paced = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, mode: :liberal, summer_holidays: summer_holidays, state: state, show_frequency: true)
124
+ paced.calculate
125
+
126
+ # Below is the output we will get when in strict mode and also showing the frequency in the pacing output.
127
+ =begin
128
+ => [
129
+ {
130
+ discipline: 'Speech Therapy',
131
+ remaining_visits: 0,
132
+ used_visits: 7,
133
+ expected_visits_at_date: 3,
134
+ reset_date: '05-11-2022',
135
+ pace: 4,
136
+ pace_indicator: "🐇",
137
+ pace_suggestion: "less than once per week".
138
+ frequency: "6Mx30ST"
139
+ }, {
140
+ discipline: 'Physical Therapy',
141
+ remaining_visits: 0,
142
+ expected_visits_at_date: 3,
143
+ used_visits: 7,
144
+ reset_date: '05-11-2022',
145
+ pace: 4,
146
+ pace_indicator: "🐇",
147
+ pace_suggestion: "less than once per week",
148
+ frequency: "6Mx30PT"
149
+ }
150
+ ]
151
+ =end
152
+
120
153
  paced.interval # Return current interval start and end dates
121
154
 
122
155
  # Below is the result you will get
data/lib/pacing/pacer.rb CHANGED
@@ -4,13 +4,14 @@ require 'holidays'
4
4
  module Pacing
5
5
  class Pacer
6
6
  COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
7
- attr_reader :school_plan, :date, :non_business_days, :state, :mode, :interval, :summer_holidays
7
+ attr_reader :school_plan, :date, :non_business_days, :state, :mode, :interval, :summer_holidays, :show_frequency
8
8
 
9
- def initialize(school_plan:, date:, non_business_days:, state: :us_tn, mode: :liberal, summer_holidays: [])
9
+ def initialize(school_plan:, date:, non_business_days:, state: :us_tn, mode: :liberal, summer_holidays: [], show_frequency: false)
10
10
  @school_plan = school_plan
11
11
  @non_business_days = non_business_days
12
12
  @date = date
13
13
  @state = state
14
+ @show_frequency = show_frequency
14
15
  @mode = [:strict, :liberal].include?(mode) ? mode : :liberal
15
16
 
16
17
  Pacing::Error.new(school_plan: school_plan, date: date, non_business_days: non_business_days, state: state, mode: mode, summer_holidays: summer_holidays)
@@ -86,6 +87,10 @@ module Pacing
86
87
  discipline[:pace_indicator] = pace_indicator(discipline[:pace])
87
88
  discipline[:pace_suggestion] = readable_suggestion(rate: discipline[:suggested_rate])
88
89
 
90
+ if show_frequency
91
+ discipline[:frequency] = discipline_frequency(service)
92
+ end
93
+
89
94
  discipline.delete(:suggested_rate)
90
95
 
91
96
  discipline
@@ -94,6 +99,11 @@ module Pacing
94
99
  services
95
100
  end
96
101
 
102
+ # discipline iep frequency
103
+ def discipline_frequency(service)
104
+ service[:frequency].to_s + service[:interval][0].gsub(/(per)|p/i, "").strip.upcase + "x" + service[:time_per_session_in_minutes].to_s + service[:type_of_service][0].upcase + "T"
105
+ end
106
+
97
107
  # get a spreadout of visit dates over an interval by using simple proportion.
98
108
  def expected_visits(start_date:, end_date:, frequency:, interval:)
99
109
  reset_start = start_of_treatment_date(start_date, interval)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pacing
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
data/spec/pacing_spec.rb CHANGED
@@ -5182,4 +5182,54 @@ RSpec.describe Pacing::Pacer do
5182
5182
  expect(results).to eq([{:discipline=>"Occupational Therapy", :remaining_visits=>1, :used_visits=>0, :pace=>0, :pace_indicator=>"😁", :pace_suggestion=>"once a week", :expected_visits_at_date=>0, :reset_date=>"10-24-2022"}, {:discipline=>"Physical Therapy", :remaining_visits=>1, :used_visits=>0, :pace=>0, :pace_indicator=>"😁", :pace_suggestion=>"once a week", :expected_visits_at_date=>0, :reset_date=>"10-24-2022"}])
5183
5183
  end
5184
5184
  end
5185
- end
5185
+ end
5186
+
5187
+ describe "should include frequency in the output if show frequency is true" do
5188
+ it "should correctly parse the pacing for patient 4558" do
5189
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"02-23-2022", :end_date=>"02-23-2023", :type_of_service=>"Speech Therapy", :frequency=>12, :interval=>"monthly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>3, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"monthly"}, {:school_plan_type=>"IEP", :start_date=>"05-19-2022", :end_date=>"11-01-2022", :type_of_service=>"Language Therapy", :frequency=>3, :interval=>"weekly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>0, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"weekly"}]}
5190
+ date = "10-17-2022"
5191
+ non_business_days = []
5192
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5193
+ expect(results).to eq([{:discipline=>"Speech Therapy", :remaining_visits=>22, :used_visits=>3, :pace=>-10, :pace_indicator=>"🐢", :pace_suggestion=>"once a day", :expected_visits_at_date=>13, :reset_date=>"11-01-2022", :frequency=>"25Mx20ST"}])
5194
+ end
5195
+
5196
+ it "should correctly parse the pacing for patient 4559" do
5197
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"10-27-2021", :end_date=>"10-27-2022", :type_of_service=>"Speech Therapy", :frequency=>8, :interval=>"monthly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>1, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"monthly"}, {:school_plan_type=>"IEP", :start_date=>"10-27-2021", :end_date=>"10-27-2022", :type_of_service=>"Speech Therapy", :frequency=>1, :interval=>"weekly", :time_per_session_in_minutes=>45, :completed_visits_for_current_interval=>0, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"weekly"}]}
5198
+ date = "10-17-2022"
5199
+ non_business_days = []
5200
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5201
+ expect(results).to eq([{:discipline=>"Speech Therapy", :remaining_visits=>11, :used_visits=>1, :pace=>-5, :pace_indicator=>"🐢", :pace_suggestion=>"about once every other day", :expected_visits_at_date=>6, :reset_date=>"11-01-2022", :frequency=>"12Mx45ST"}])
5202
+ end
5203
+
5204
+ it "should also accept 'Language' as a type of service 4560" do
5205
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"05-23-2022", :end_date=>"05-23-2023", :type_of_service=>"Speech Therapy", :frequency=>6, :interval=>"monthly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>4, :extra_sessions_allowable=>1, :interval_for_extra_sessions_allowable=>"monthly"}, {:school_plan_type=>"IEP", :start_date=>"05-23-2022", :end_date=>"05-23-2023", :type_of_service=>"Language", :frequency=>6, :interval=>"monthly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>4, :extra_sessions_allowable=>1, :interval_for_extra_sessions_allowable=>"monthly"}]}
5206
+ date = "10-17-2022"
5207
+ non_business_days = []
5208
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5209
+ expect(results).to eq([{:discipline=>"Speech Therapy", :remaining_visits=>10, :used_visits=>4, :pace=>-2, :pace_indicator=>"🐢", :pace_suggestion=>"about once every other day", :expected_visits_at_date=>6, :reset_date=>"11-01-2022", :frequency=>"12Mx20ST"}])
5210
+ end
5211
+
5212
+ it "should correctly parse the pacing for patient 4561" do
5213
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"12-03-2021", :end_date=>"12-03-2022", :type_of_service=>"Speech and language", :frequency=>12, :interval=>"monthly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>4, :extra_sessions_allowable=>1, :interval_for_extra_sessions_allowable=>"monthly"}]}
5214
+ date = "10-17-2022"
5215
+ non_business_days = []
5216
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5217
+ expect(results).to eq([{:discipline=>"Speech Therapy", :remaining_visits=>9, :used_visits=>4, :pace=>-2, :pace_indicator=>"🐢", :pace_suggestion=>"about once every other day", :expected_visits_at_date=>6, :reset_date=>"11-01-2022", :frequency=>"12Mx20ST"}])
5218
+ end
5219
+
5220
+ it "should correctly parse the pacing for patient 4562" do
5221
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"09-27-2022", :end_date=>"09-27-2023", :type_of_service=>"Language Therapy", :frequency=>30, :interval=>"yearly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>4, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"yearly"}]}
5222
+ date = "10-17-2022"
5223
+ non_business_days = []
5224
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5225
+ expect(results).to eq([{:discipline=>"Speech Therapy", :remaining_visits=>26, :used_visits=>4, :pace=>2, :pace_indicator=>"🐇", :pace_suggestion=>"less than once per week", :expected_visits_at_date=>2, :reset_date=>"09-27-2023", :frequency=>"30Yx20ST"}])
5226
+ end
5227
+
5228
+ it "should correctly parse the pacing for patient 4563" do
5229
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"11-03-2021", :end_date=>"11-03-2022", :type_of_service=>"Speech Therapy", :frequency=>1, :interval=>"weekly", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>0, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"weekly"}]}
5230
+ date = "10-17-2022"
5231
+ non_business_days = []
5232
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5233
+ expect(results).to eq([{:discipline=>"Speech Therapy", :remaining_visits=>1, :used_visits=>0, :pace=>0, :pace_indicator=>"😁", :pace_suggestion=>"once a week", :expected_visits_at_date=>0, :reset_date=>"10-24-2022", :frequency=>"1Wx20ST"}])
5234
+ end
5235
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pacing
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-11-17 00:00:00.000000000 Z
13
+ date: 2022-12-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec