clinic_finder 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +23 -0
- data/README.md +110 -0
- data/Rakefile +8 -0
- data/build.sh +3 -0
- data/clinic_finder.gemspec +21 -0
- data/fixtures/clinics.yml +144 -0
- data/lib/clinic_finder.rb +84 -0
- data/lib/clinic_finder/gestation_helper.rb +32 -0
- data/test/test_clinic_finder.rb +78 -0
- data/test/test_gestation_helper.rb +55 -0
- data/test/test_helper.rb +5 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1395796307b7e4dc1c69d210f37f0c976f666d02
|
4
|
+
data.tar.gz: d12d1d938849d0414c1e80dab9c85d5de849fd7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aacbea8da4beb63753b31d20ec350e3ba2b051d7b414ed574225c24459b0f3b1e0a1db0fea9d28849f4ac6ea3479c4abede1c38f7245a38b4f45ca0cb6ba43fa
|
7
|
+
data.tar.gz: 4b7f6ac8c24a445a93430b33eb40ff90d0783528201902bb0d86916f85f350f791efdcff0fa0fd25903bde4e414e9412da204ad35011ebc9db0ad07d839fb443
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
clinic_finder (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
geokit (1.10.0)
|
10
|
+
minitest (5.10.1)
|
11
|
+
rake (12.0.0)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
clinic_finder!
|
18
|
+
geokit
|
19
|
+
minitest
|
20
|
+
rake (>= 0.9.2)
|
21
|
+
|
22
|
+
BUNDLED WITH
|
23
|
+
1.14.4
|
data/README.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# clinic_finder
|
2
|
+
# ABORTRON
|
3
|
+
|
4
|
+
* CI: https://travis-ci.org/colinxfleming/clinic_finder
|
5
|
+
* build script: build.sh
|
6
|
+
* run tests: rake test
|
7
|
+
|
8
|
+
## Problem Description
|
9
|
+
|
10
|
+
Our case management team is helping patients navigate a variety of logistical challenges to securing an abortion, such as figuring out the closest clinic to them, or the cheapest clinic in their state, or a clinic that will still see them (since many clinics have a gestational age cutoff after which they won't do abortions anymore). The DC area is fortunate enough to have a variety of providers, and we'd like to have a tool that helps us filter down our set of clinics and help our case managers recommend an optimal few clinics, given a patient's particular needs.
|
11
|
+
|
12
|
+
## How we'd like to use it
|
13
|
+
|
14
|
+
We'd prefer this as a ruby library so that we can plug it into our existing case management system easily. If that's not an option, we can adapt the logic from it.
|
15
|
+
|
16
|
+
## How we'd like it to work
|
17
|
+
|
18
|
+
As a case manager, given that I have:
|
19
|
+
* A patient with limited resources, a gestational age, and a zip code
|
20
|
+
* A set of clinics with certain attributes, including an address and a set schedule of costs and whether or not they accept National Abortion Federation (NAF) funding, and certain other factors that might make them a better fit for a patient
|
21
|
+
|
22
|
+
I would like to be able to filter and sort down to a subset of available clinics.
|
23
|
+
|
24
|
+
Relevant parts of our clinic objects that we'd like to filter on:
|
25
|
+
* zip: five digit zip code
|
26
|
+
* cost: cost in dollars for an abortion procedure
|
27
|
+
* gestation_limit: limit in days, at which point a clinic won't perform abortions. e.g. no abortions after 147 days (21 weeks).
|
28
|
+
* naf_clinic: boolean value for whether or not a clinic accepts NAF funding (e.g. whether or not we can count on a grant)
|
29
|
+
|
30
|
+
Information from a patient that we'd like to plug into the tool:
|
31
|
+
* zip code of patient
|
32
|
+
* patient's gestational age
|
33
|
+
|
34
|
+
## Setup
|
35
|
+
|
36
|
+
[PLACEHOLDER FOR INSTALL INSTRUCTIONS]
|
37
|
+
|
38
|
+
This gem currently requires data to be in the form of a .yml file, which is passed in to the library instance at the point of initialization as such:
|
39
|
+
|
40
|
+
`Abortron::ClinicFinder.new(yaml_file)`
|
41
|
+
|
42
|
+
The gem expects yml data to be in the following format:
|
43
|
+
|
44
|
+
```
|
45
|
+
planned_parenthood_oakland:
|
46
|
+
street_address: 1001 Broadway
|
47
|
+
city: Oakland
|
48
|
+
state: CA
|
49
|
+
zip: 94607
|
50
|
+
accepts_naf: false
|
51
|
+
gestational_limit: 139
|
52
|
+
costs_9wks: 425
|
53
|
+
costs_12wks: 475
|
54
|
+
costs_18wks: 975
|
55
|
+
costs_24wks: null
|
56
|
+
costs_30wks: null
|
57
|
+
```
|
58
|
+
Hot tip: Before using your yml file, please be sure to feed it through a YAML linter like [YAML Lint](http://www.yamllint.com/) to remove any syntax errors.
|
59
|
+
|
60
|
+
Long term goal here is to make this usable with ActiveRecord models directly.
|
61
|
+
|
62
|
+
## Methods
|
63
|
+
|
64
|
+
First, you will need to instantiate a library instance.
|
65
|
+
|
66
|
+
`@abortron = Abortron::ClinicFinder.new(your_yaml_file)`
|
67
|
+
|
68
|
+
To find the cheapest clinic within your dataset that will serve the patient based on their LMP, call:
|
69
|
+
|
70
|
+
`@abortron.locate_cheapest_clinic(patient_zip: 94114, gestational_age: 60)`
|
71
|
+
|
72
|
+
This will return an array of hashes that look like so:
|
73
|
+
|
74
|
+
```
|
75
|
+
=> [{'planned_parenthood_oakland' => {'street_address' => '1001 Broadway',
|
76
|
+
'city' => 'Oakland', 'state' => 'CA',
|
77
|
+
'zip' => 94607,
|
78
|
+
'accepts_naf' => false,
|
79
|
+
'gestational_limit' => 139,
|
80
|
+
'costs_9wks' => 425,
|
81
|
+
'costs_12wks' => 475,
|
82
|
+
'costs_18wks' => 975,
|
83
|
+
'costs_24wks' => nil,
|
84
|
+
'costs_30wks' => nil}},
|
85
|
+
{'castro_family_planning' => {'street_address' => '5464 Folsom',
|
86
|
+
'city' => 'San Francisco',
|
87
|
+
'state' => 'CA',
|
88
|
+
'zip' => 94607,
|
89
|
+
'accepts_naf' => false,
|
90
|
+
'gestational_limit' => 139,
|
91
|
+
'costs_9wks' => 425,
|
92
|
+
'costs_12wks' => 475,
|
93
|
+
'costs_18wks' => 975,
|
94
|
+
'costs_24wks' => nil,
|
95
|
+
'costs_30wks' => nil}}]
|
96
|
+
```
|
97
|
+
|
98
|
+
|
99
|
+
## Further goals
|
100
|
+
* Make gem usable with ActiveRecord models directly, instead of via a yml file that requires maintenance
|
101
|
+
* Incorporate check for NAF only (the infrastructure is currently present as a default-false argument, but is not being used)
|
102
|
+
* Create method for cheapest **and** closest, defined as the cheapest clinic of your three closest clinics
|
103
|
+
* Create a method for easiest/fastest access via public transportation (this may require patient to provide full address, not just zip)
|
104
|
+
|
105
|
+
## Measuring success
|
106
|
+
|
107
|
+
We'd like to walk away with:
|
108
|
+
|
109
|
+
* A ruby gem that we can install in a separate app
|
110
|
+
* A standalone sinatra app that we can demo to case managers
|
data/Rakefile
ADDED
data/build.sh
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'clinic_finder'
|
3
|
+
s.version = '0.0.0'
|
4
|
+
s.date = '2017-02-23'
|
5
|
+
s.summary = 'Finding abortion clinics based on zip and LMP'
|
6
|
+
s.description = 'Help abortion fund case managers match ' \
|
7
|
+
'patients to optimal clinics.'
|
8
|
+
s.authors = ['Team Code for DCAF', 'Colin Fleming', 'Lisa Waldschmitt']
|
9
|
+
s.email = 'info@dcabortionfund.org'
|
10
|
+
s.files = ['lib/clinic_finder.rb', 'lib/clinic_finder/gestation_helper.rb']
|
11
|
+
s.homepage = 'http://www.dcabortionfund.org'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.rubyforge_project = "clinic_finder"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
# A set of fake clinics with cost, geo, and naf data to use as stubs
|
2
|
+
planned_parenthood_oakland:
|
3
|
+
street_address: 1001 Broadway
|
4
|
+
city: Oakland
|
5
|
+
state: CA
|
6
|
+
zip: 94607
|
7
|
+
accepts_naf: false
|
8
|
+
gestational_limit: 139
|
9
|
+
costs_9wks: 425
|
10
|
+
costs_12wks: 475
|
11
|
+
costs_18wks: 975
|
12
|
+
costs_24wks: null
|
13
|
+
costs_30wks: null
|
14
|
+
|
15
|
+
planned_parenthood_san_fran:
|
16
|
+
street_address: 2430 Folsom
|
17
|
+
city: San Francisco
|
18
|
+
state: CA
|
19
|
+
zip: 94110
|
20
|
+
accepts_naf: false
|
21
|
+
gestational_limit: 111
|
22
|
+
costs_9wks: 300
|
23
|
+
costs_12wks: 325
|
24
|
+
costs_18wks: null
|
25
|
+
costs_18wks: null
|
26
|
+
costs_24wks: null
|
27
|
+
costs_30wks: null
|
28
|
+
|
29
|
+
castro_family_planning:
|
30
|
+
street_address: 517 Castro
|
31
|
+
city: San Francisco
|
32
|
+
state: CA
|
33
|
+
zip: 94114
|
34
|
+
accepts_naf: true
|
35
|
+
gestational_limit: 126
|
36
|
+
costs_9wks: 295
|
37
|
+
costs_12wks: 425
|
38
|
+
costs_18wks: 1500
|
39
|
+
costs_24wks: null
|
40
|
+
costs_30wks: null
|
41
|
+
|
42
|
+
silcon_valley_womens_clinic:
|
43
|
+
street_address: 110 S Market
|
44
|
+
city: San Jose
|
45
|
+
state: CA
|
46
|
+
zip: 95110
|
47
|
+
accepts_naf: true
|
48
|
+
gestational_limit: 98
|
49
|
+
costs_9wks: 375
|
50
|
+
costs_12wks: 400
|
51
|
+
costs_18wks: null
|
52
|
+
costs_24wks: null
|
53
|
+
costs_30wks: null
|
54
|
+
|
55
|
+
discreet_treatment_centers_of_ca:
|
56
|
+
street_address: 570 Pacific
|
57
|
+
city: Monterey
|
58
|
+
state: CA
|
59
|
+
zip: 93940
|
60
|
+
accepts_naf: false
|
61
|
+
gestational_limit: 154
|
62
|
+
costs_9wks: 400
|
63
|
+
costs_12wks: 400
|
64
|
+
costs_18wks: 1150
|
65
|
+
costs_24wks: null
|
66
|
+
costs_30wks: null
|
67
|
+
|
68
|
+
albuquerque_medical_center:
|
69
|
+
street_address: 1801 Mountain NW
|
70
|
+
city: Albuquerque
|
71
|
+
state: NM
|
72
|
+
zip: 87104
|
73
|
+
accepts_naf: true
|
74
|
+
gestational_limit: 210
|
75
|
+
costs_9wks: 300
|
76
|
+
costs_12wks: 325
|
77
|
+
costs_18wks: 1100
|
78
|
+
costs_24wks: 4000
|
79
|
+
costs_30wks: 9500
|
80
|
+
|
81
|
+
butte_health_clinic:
|
82
|
+
street_address: 7473 Humboldt
|
83
|
+
city: Butte Meadows
|
84
|
+
state: CA
|
85
|
+
zip: 95942
|
86
|
+
accepts_naf: true
|
87
|
+
gestational_limit: 111
|
88
|
+
costs_9wks: 350
|
89
|
+
costs_12wks: 400
|
90
|
+
costs_18wks: null
|
91
|
+
costs_24wks: null
|
92
|
+
costs_30wks: null
|
93
|
+
|
94
|
+
planned_parenthood_fresno:
|
95
|
+
street_address: 2220 Tulare
|
96
|
+
city: Fresno
|
97
|
+
state: CA
|
98
|
+
zip: 93721
|
99
|
+
accepts_naf: false
|
100
|
+
gestational_limit: 97
|
101
|
+
costs_9wks: 425
|
102
|
+
costs_12wks: 475
|
103
|
+
costs_18wks: null
|
104
|
+
costs_24wks: null
|
105
|
+
costs_30wks: null
|
106
|
+
|
107
|
+
womens_health_of_venice_beach:
|
108
|
+
street_address: 2025 Pacific
|
109
|
+
city: Los Angeles
|
110
|
+
state: CA
|
111
|
+
zip: 90291
|
112
|
+
accepts_naf: true
|
113
|
+
gestational_limit: 119
|
114
|
+
costs_9wks: 350
|
115
|
+
costs_12wks: 350
|
116
|
+
costs_18wks: null
|
117
|
+
costs_24wks: null
|
118
|
+
costs_30wks: null
|
119
|
+
|
120
|
+
planned_parenthood_la:
|
121
|
+
street_address: 3900 W Manchester
|
122
|
+
city: Los Angeles
|
123
|
+
state: CA
|
124
|
+
zip: 90305
|
125
|
+
accepts_naf: false
|
126
|
+
gestational_limit: 146
|
127
|
+
costs_9wks: 415
|
128
|
+
costs_12wks: 460
|
129
|
+
costs_18wks: 1450
|
130
|
+
costs_24wks: null
|
131
|
+
costs_30wks: null
|
132
|
+
|
133
|
+
la_medical_center:
|
134
|
+
street_address: 5905 Wilshire
|
135
|
+
city: Los Angeles
|
136
|
+
state: CA
|
137
|
+
zip: 90036
|
138
|
+
accepts_naf: true
|
139
|
+
gestational_limit: 168
|
140
|
+
costs_9wks: 400
|
141
|
+
costs_12wks: 400
|
142
|
+
costs_18wks: 1600
|
143
|
+
costs_24wks: 3000
|
144
|
+
costs_30wks: null
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'geokit'
|
3
|
+
require_relative './clinic_finder/gestation_helper'
|
4
|
+
|
5
|
+
# Core class
|
6
|
+
module Abortron
|
7
|
+
class ClinicFinder
|
8
|
+
attr_reader :clinics
|
9
|
+
|
10
|
+
def initialize(yml_file)
|
11
|
+
@clinics = ::YAML.load_file(yml_file)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_full_address(gestational_age) # need to test filtering gestational limit
|
15
|
+
@clinic_addresses = []
|
16
|
+
filtered_clinics = @clinics.keep_if { |name, info| gestational_age < info['gestational_limit']}
|
17
|
+
filtered_clinics.each do |clinic, info|
|
18
|
+
@clinic_addresses << {name: clinic, address: "#{info['street_address']}, #{info['city']}, #{info['state']}"}
|
19
|
+
end
|
20
|
+
@clinic_addresses
|
21
|
+
end
|
22
|
+
|
23
|
+
def clinics_coordinates_conversion
|
24
|
+
@coordinates_hash = {}
|
25
|
+
@clinic_addresses.map! do |address| # {name: 'Oakland Clinic', address: '101 Main St, Oakland, CA'}
|
26
|
+
location = ::Geokit::Geocoders::GoogleGeocoder.geocode(address[:address])
|
27
|
+
float_coordinates = location.ll.split(',').map(&:to_f)
|
28
|
+
@coordinates_hash[address[:name]] = float_coordinates
|
29
|
+
sleep(0.5)
|
30
|
+
end
|
31
|
+
@coordinates_hash
|
32
|
+
end
|
33
|
+
|
34
|
+
def patient_coordinates_conversion(patient_zipcode)
|
35
|
+
@patient_location = ::Geokit::Geocoders::GoogleGeocoder.geocode(patient_zipcode)
|
36
|
+
@patient_float_coordinates = @patient_location.ll
|
37
|
+
end
|
38
|
+
|
39
|
+
def calculate_distance
|
40
|
+
distances = []
|
41
|
+
@coordinates_hash.each do |name, coordinates|
|
42
|
+
ll = Geokit::LatLng.new(coordinates[0], coordinates[1])
|
43
|
+
distances << {name: name, distance: ll.distance_to(@patient_float_coordinates)}
|
44
|
+
# distances = [ {name: "Oakland", distance: 2}, {name: "San Francisco", distance: 1} ]
|
45
|
+
end
|
46
|
+
@distances = distances.sort_by {|distance| distance[:distance]}
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def find_closest_clinics
|
51
|
+
@distances[0..2]
|
52
|
+
end
|
53
|
+
|
54
|
+
# need to write test to make sure everything gets called
|
55
|
+
def locate_nearest_clinic(patient_zipcode:, gestational_age:)
|
56
|
+
patient_coordinates_conversion(patient_zipcode)
|
57
|
+
create_full_address(gestational_age)
|
58
|
+
clinics_coordinates_conversion
|
59
|
+
calculate_distance
|
60
|
+
find_closest_clinics
|
61
|
+
end
|
62
|
+
|
63
|
+
def locate_cheapest_clinic(gestational_age:, naf_clinics_only: false)
|
64
|
+
@helper = ::ClinicFinder::GestationHelper.new(gestational_age)
|
65
|
+
@gestational_tier = @helper.gestational_tier
|
66
|
+
decorate_data(available_clinics)
|
67
|
+
end
|
68
|
+
|
69
|
+
# This method makes the sorted clinic data more easily traversible by converting the data into a hash of names (keys) and informational attributes (values) rather than leaving them as separate values in a nested array.
|
70
|
+
private def decorate_data(data)
|
71
|
+
sorted_clinics = []
|
72
|
+
three_cheapest(data).map { |clinic_array| sorted_clinics << { clinic_array.first => clinic_array.last } }
|
73
|
+
sorted_clinics
|
74
|
+
end
|
75
|
+
|
76
|
+
private def three_cheapest(data)
|
77
|
+
data.sort_by { |name, information| information[@gestational_tier] }.first(3)
|
78
|
+
end
|
79
|
+
|
80
|
+
private def available_clinics
|
81
|
+
@clinics.keep_if { |name, information| information[@gestational_tier] && @helper.within_gestational_limit?(information['gestational_limit']) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class ClinicFinder
|
2
|
+
class GestationHelper
|
3
|
+
attr_reader :gestational_age, :gestational_weeks
|
4
|
+
|
5
|
+
def initialize(gestational_age)
|
6
|
+
@gestational_age = gestational_age
|
7
|
+
# BUSINESS LOGIC HERE - CHANGE AS NEEDED
|
8
|
+
# We round up under the assumption that as soon as you pass the threshhold
|
9
|
+
# of a pricing tier - say, 9 weeks and 1 day - you will be priced into the
|
10
|
+
# more expensive tier (12 weeks). Change logic if this is not the case.
|
11
|
+
@gestational_weeks = (@gestational_age/7.0).ceil
|
12
|
+
end
|
13
|
+
|
14
|
+
def gestational_tier
|
15
|
+
if @gestational_weeks < 10
|
16
|
+
'costs_9wks'
|
17
|
+
elsif @gestational_weeks < 13
|
18
|
+
'costs_12wks'
|
19
|
+
elsif @gestational_weeks < 19
|
20
|
+
'costs_18wks'
|
21
|
+
elsif @gestational_weeks < 25
|
22
|
+
'costs_24wks'
|
23
|
+
else
|
24
|
+
'costs_30wks'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def within_gestational_limit?(gestational_limit)
|
29
|
+
@gestational_age < gestational_limit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require_relative '../lib/clinic_finder'
|
3
|
+
|
4
|
+
class TestClinicFinder < TestClass
|
5
|
+
|
6
|
+
def setup
|
7
|
+
file = File.join(File.dirname(__FILE__), '../fixtures/clinics.yml')
|
8
|
+
@abortron = Abortron::ClinicFinder.new(file)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_that_initialize_sets_clinic_variable
|
12
|
+
assert_kind_of Hash, @abortron.clinics
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_that_full_addresses_created
|
16
|
+
assert_kind_of Array, @abortron.create_full_address(100)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_that_full_address_has_needed_fields
|
20
|
+
assert_equal [{:name=>"planned_parenthood_oakland", :address=>"1001 Broadway, Oakland, CA"}, {:name=>"planned_parenthood_san_fran", :address=>"2430 Folsom, San Francisco, CA"}, {:name=>"castro_family_planning", :address=>"517 Castro, San Francisco, CA"}, {:name=>"discreet_treatment_centers_of_ca", :address=>"570 Pacific, Monterey, CA"}, {:name=>"albuquerque_medical_center", :address=>"1801 Mountain NW, Albuquerque, NM"}, {:name=>"butte_health_clinic", :address=>"7473 Humboldt, Butte Meadows, CA"}, {:name=>"womens_health_of_venice_beach", :address=>"2025 Pacific, Los Angeles, CA"}, {:name=>"planned_parenthood_la", :address=>"3900 W Manchester, Los Angeles, CA"}, {:name=>"la_medical_center", :address=>"5905 Wilshire, Los Angeles, CA"}], @abortron.create_full_address(100)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_that_clinic_coordinates_are_hashes
|
24
|
+
addresses = @abortron.create_full_address(100)
|
25
|
+
assert_kind_of Hash, @abortron.clinics_coordinates_conversion
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_that_clinic_coordinates_are_found
|
29
|
+
@abortron.create_full_address(100)
|
30
|
+
information = @abortron.clinics_coordinates_conversion
|
31
|
+
assert_equal [37.8021736,-122.2729171], information["planned_parenthood_oakland"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_that_patient_coordinates_are_found
|
35
|
+
pt_address = "88 Colin P Kelly Jr St, San Francisco, CA"
|
36
|
+
pt_mock = MiniTest::Mock.new
|
37
|
+
pt_mock.expect(:ll, [37.78226710000001, -122.3912479])
|
38
|
+
Geokit::Geocoders::GoogleGeocoder.stub(:geocode, pt_mock) do
|
39
|
+
@abortron.patient_coordinates_conversion(pt_address)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_that_distances_calculated_between_clinics_and_patient
|
44
|
+
@abortron.create_full_address(100)
|
45
|
+
@abortron.clinics_coordinates_conversion
|
46
|
+
@abortron.patient_coordinates_conversion("94117")
|
47
|
+
first_clinic = {name: "castro_family_planning", distance: 0.92356303468274}
|
48
|
+
assert_equal first_clinic, @abortron.calculate_distance.first
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_that_returns_top_3_closest_clinics
|
52
|
+
@abortron.create_full_address(100)
|
53
|
+
@abortron.clinics_coordinates_conversion
|
54
|
+
@abortron.patient_coordinates_conversion("94117")
|
55
|
+
@abortron.calculate_distance
|
56
|
+
assert_equal [{:name=>"castro_family_planning", :distance=>0.92356303468274}, {:name=>"planned_parenthood_san_fran", :distance=>1.8319683663768311}, {:name=>"planned_parenthood_oakland", :distance=>9.580895789655901}], @abortron.find_closest_clinics
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_locate_cheapest_clinic_locates
|
60
|
+
clinic = {
|
61
|
+
'planned_parenthood_oakland' =>
|
62
|
+
{
|
63
|
+
'street_address' => '1001 Broadway',
|
64
|
+
'city' => 'Oakland',
|
65
|
+
'state' => 'CA',
|
66
|
+
'zip' => 94607,
|
67
|
+
'accepts_naf' => false,
|
68
|
+
'gestational_limit' => 139,
|
69
|
+
'costs_9wks' => 425,
|
70
|
+
'costs_12wks' => 475,
|
71
|
+
'costs_18wks' => 975,
|
72
|
+
'costs_24wks' => nil,
|
73
|
+
'costs_30wks' => nil
|
74
|
+
}
|
75
|
+
}
|
76
|
+
assert_equal clinic, @abortron.locate_cheapest_clinic(gestational_age: 100)[0]
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require_relative '../lib/clinic_finder/gestation_helper'
|
3
|
+
|
4
|
+
class TestGestationHelper < TestClass
|
5
|
+
def setup
|
6
|
+
@helper = ClinicFinder::GestationHelper.new(10)
|
7
|
+
@clinic = {
|
8
|
+
'street_address': '2025 Pacific',
|
9
|
+
'city': 'Los Angeles',
|
10
|
+
'state': 'CA',
|
11
|
+
'zip': 90291,
|
12
|
+
'accepts_naf': true,
|
13
|
+
'gestational_limit': 119,
|
14
|
+
'costs_9wks': 350,
|
15
|
+
'costs_12wks': 350,
|
16
|
+
'costs_18wks': nil,
|
17
|
+
'costs_24wks': nil,
|
18
|
+
'costs_30wks': nil
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_that_initialize_sets_gestational_age_variable
|
23
|
+
assert_equal 10, @helper.gestational_age
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_that_initialize_sets_gestational_weeks_variable
|
27
|
+
assert_equal 2, @helper.gestational_weeks
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_that_gestational_limit_greater_than_ga_is_true
|
31
|
+
assert_equal true, @helper.within_gestational_limit?(30)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_that_gestational_limit_less_than_ga_is_false
|
35
|
+
assert_equal false, @helper.within_gestational_limit?(5)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_that_gestational_limit_equal_to_ga_is_false
|
39
|
+
assert_equal false, @helper.within_gestational_limit?(10)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_gestational_tier_under_lower_bound
|
43
|
+
assert_equal 'costs_9wks', @helper.gestational_tier
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_gestational_tier_within_bound
|
47
|
+
@helper = ClinicFinder::GestationHelper.new(100)
|
48
|
+
assert_equal 'costs_18wks', @helper.gestational_tier
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_gestational_tier_above_upper_bound
|
52
|
+
@helper = ClinicFinder::GestationHelper.new(400)
|
53
|
+
assert_equal 'costs_30wks', @helper.gestational_tier
|
54
|
+
end
|
55
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clinic_finder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Team Code for DCAF
|
8
|
+
- Colin Fleming
|
9
|
+
- Lisa Waldschmitt
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: Help abortion fund case managers match patients to optimal clinics.
|
16
|
+
email: info@dcabortionfund.org
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- build.sh
|
28
|
+
- clinic_finder.gemspec
|
29
|
+
- fixtures/clinics.yml
|
30
|
+
- lib/clinic_finder.rb
|
31
|
+
- lib/clinic_finder/gestation_helper.rb
|
32
|
+
- test/test_clinic_finder.rb
|
33
|
+
- test/test_gestation_helper.rb
|
34
|
+
- test/test_helper.rb
|
35
|
+
homepage: http://www.dcabortionfund.org
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project: clinic_finder
|
55
|
+
rubygems_version: 2.6.8
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Finding abortion clinics based on zip and LMP
|
59
|
+
test_files:
|
60
|
+
- test/test_clinic_finder.rb
|
61
|
+
- test/test_gestation_helper.rb
|
62
|
+
- test/test_helper.rb
|