pacing 2.1.0 → 2.2.1

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: bbc2189e33671c8a34eccd7aa71ec4f93d48fe0228e4931655bda84c519cc1d8
4
- data.tar.gz: a1808e5be13be267c73b2720fabafbfe9e379029a209a86f5b19921c515497f5
3
+ metadata.gz: 5ccfc4f4c8e6664190adfb475373feeffa18147777afe5dd19e28b39d1c2bff2
4
+ data.tar.gz: 4834d0e23c85d6681cb91053bd4db9ab38ccd216960a157005516d9d509a7ff1
5
5
  SHA512:
6
- metadata.gz: f320cddb2b0a54b1f834c4a8a98fb496f6d7348c848525c26fdd52e22eaec8312f083df2b9378ca0bb2794480f6d6c3e8b65239221bdd27cf5463ac5bb8f2080
7
- data.tar.gz: 7a6d01438e8ab61f2bec040cd2ddbdd14fda5b832d93324678ce0852fb10e34cd9a8d608b4c58fc89987d974c40a9251abbc4b9a25bb6c50b0c46a68e6688055
6
+ metadata.gz: 41cb717c55137d9ca5cd92925fad3ba6364687bc8bab505633c2f436a39e71a7b55eb41ffc4408f619dfbd185470bc7907f5a76508d63ecbfb7135c400620bd9
7
+ data.tar.gz: 87d1830887611012fb05d9e9f1f6149e7d367b30c9464282ef2e4a571a8a105d3bd659d54f5b44a06524c1c99a0a82ea654157f1b74073cb44b29ef0146f88ca
data/lib/pacing/error.rb CHANGED
@@ -53,7 +53,7 @@ module Pacing
53
53
 
54
54
  begin
55
55
  @school_plan[:school_plan_services].each do |school_plan_service|
56
- if (parse_date(school_plan_service[:start_date]) < parse_date(@date) && parse_date(@date) < parse_date(school_plan_service[:end_date]))
56
+ if (parse_date(school_plan_service[:start_date]) <= parse_date(@date) && parse_date(@date) <= parse_date(school_plan_service[:end_date]))
57
57
  valid_range_or_exceptions = true
58
58
  end
59
59
  end
@@ -72,4 +72,3 @@ module Pacing
72
72
  end
73
73
  end
74
74
  end
75
-
@@ -32,7 +32,7 @@ module Pacing
32
32
  discipline_services = services.filter do |service|
33
33
  ["pragmatic language", "speech and language", "language", "speech", "language therapy", "speech therapy", "speech and language therapy", "speech language therapy"].include?(service[:type_of_service].downcase)
34
34
  end
35
-
35
+
36
36
  return {} if discipline_services.empty?
37
37
 
38
38
  discipline_services = normalize_to_monthly_frequency(discipline_services)
@@ -57,7 +57,7 @@ module Pacing
57
57
  discipline_services = services.filter do |service|
58
58
  ["occupation therapy", "occupational therapy", "occupation"].include?(service[:type_of_service].downcase)
59
59
  end
60
-
60
+
61
61
  return {} if discipline_services.empty?
62
62
 
63
63
  discipline_services = normalize_to_monthly_frequency(discipline_services)
@@ -82,7 +82,7 @@ module Pacing
82
82
  discipline_services = services.filter do |service|
83
83
  ["physical therapy", "physical"].include?(service[:type_of_service].downcase)
84
84
  end
85
-
85
+
86
86
  return {} if discipline_services.empty?
87
87
 
88
88
  discipline_services = normalize_to_monthly_frequency(discipline_services)
@@ -107,7 +107,7 @@ module Pacing
107
107
  discipline_services = services.filter do |service|
108
108
  ["feeding therapy", "feeding"].include?(service[:type_of_service].downcase)
109
109
  end
110
-
110
+
111
111
  return {} if discipline_services.empty?
112
112
 
113
113
  discipline_services = normalize_to_monthly_frequency(discipline_services)
@@ -155,8 +155,11 @@ module Pacing
155
155
  # average business days for each interval
156
156
  interval_average_days = {
157
157
  "weekly" => 5,
158
+ "per week" => 5,
158
159
  "monthly" => 22,
159
- "yearly" => 210 # take away average holidays period with is 2.5 months
160
+ "per month" => 22,
161
+ "yearly" => 210,
162
+ "per year" => 210 # take away average holidays period with is 2.5 months
160
163
  }
161
164
 
162
165
  return services if same_interval(services)
@@ -164,7 +167,7 @@ module Pacing
164
167
  services.map do |service|
165
168
  if !(service[:interval] == "monthly")
166
169
  # weekly(5 days) = frequency # weekly
167
- # monthly(20 days) = frequency * monthly
170
+ # monthly(20 days) = frequency * monthly
168
171
  # yearly(200 days)
169
172
 
170
173
  f = service[:frequency]
@@ -207,4 +210,3 @@ module Pacing
207
210
  end
208
211
  end
209
212
  end
210
-
data/lib/pacing/pacer.rb CHANGED
@@ -44,7 +44,9 @@ module Pacing
44
44
  discipline = {}
45
45
  discipline[:discipline] = discipline_name
46
46
  discipline[:reset_date] = reset_date(start_date: service[:start_date], interval: service[:interval])
47
- discipline[:start_date] = start_of_treatment_date(parse_date(service[:start_date]), service[:interval]).strftime("%m-%d-%Y")
47
+ parsed_date = service[:start_date] ? parse_date(service[:start_date]) : nil
48
+ treatment_start_date = parsed_date && service[:interval] ? start_of_treatment_date(parsed_date, service[:interval]) : nil
49
+ discipline[:start_date] = treatment_start_date ? treatment_start_date.strftime("%m-%d-%Y") : nil
48
50
  discipline
49
51
  end
50
52
  end
@@ -101,7 +103,7 @@ module Pacing
101
103
 
102
104
  # discipline iep frequency
103
105
  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"
106
+ service[:frequency].to_s + service[:interval].gsub(/(per)|p/i, "").strip[0].upcase + "x" + service[:time_per_session_in_minutes].to_s + service[:type_of_service][0].upcase + "T"
105
107
  end
106
108
 
107
109
  # get a spreadout of visit dates over an interval by using simple proportion.
@@ -348,6 +350,6 @@ module Pacing
348
350
  holidays_start += 1 until holidays_start.wday == 1
349
351
 
350
352
  [holidays_start, holidays_end]
351
- end
353
+ end
352
354
  end
353
355
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pacing
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.1"
5
5
  end
data/spec/pacing_spec.rb CHANGED
@@ -5232,4 +5232,30 @@ describe "should include frequency in the output if show frequency is true" do
5232
5232
  results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5233
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
5234
  end
5235
+
5236
+ it "should correctly parse the pacing for patient 4564 when start_date is same as date" do
5237
+ school_plan = {:school_plan_services=>[{:school_plan_type=>"IEP", :start_date=>"01-09-2023", :end_date=>"03-30-2023", :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"}]}
5238
+ date = "01-09-2023"
5239
+ non_business_days = []
5240
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5241
+ 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=>"01-16-2023", :frequency=>"1Wx20ST"}])
5242
+ end
5243
+ end
5244
+
5245
+ describe "should calculate pacing correctly when interval starts with 'per month, per week, and per year'" do
5246
+ it "should correctly parse the pacing for patient 4565" do
5247
+ 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=>"per month", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>3, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"per month"}, {:school_plan_type=>"IEP", :start_date=>"05-19-2022", :end_date=>"11-01-2022", :type_of_service=>"Language Therapy", :frequency=>3, :interval=>"per week", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>0, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"per week"}]}
5248
+ date = "10-17-2022"
5249
+ non_business_days = []
5250
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5251
+ 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"}])
5252
+ end
5253
+
5254
+ it "should correctly parse the pacing for patient 4566" do
5255
+ 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=>"per year", :time_per_session_in_minutes=>20, :completed_visits_for_current_interval=>4, :extra_sessions_allowable=>0, :interval_for_extra_sessions_allowable=>"per year"}]}
5256
+ date = "10-17-2022"
5257
+ non_business_days = []
5258
+ results = Pacing::Pacer.new(school_plan: school_plan, date: date, non_business_days: non_business_days, show_frequency: true).calculate
5259
+ 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"}])
5260
+ end
5235
5261
  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.1.0
4
+ version: 2.2.1
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-12-07 00:00:00.000000000 Z
13
+ date: 2024-05-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.1.6
94
+ rubygems_version: 3.3.26
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Pacing is a tool that enables therapists to better manage and track their