medivo 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,8 +15,9 @@ module Medivo
15
15
  raise 'implement your own logic here'
16
16
  end
17
17
 
18
- def send_pdf(bytes, file_name)
19
- send_data bytes, :disposition => 'inline', :type=> 'application/pdf', :filename=>file_name, :layout=>false
18
+ def send_pdf(file, file_name)
19
+ send_data file.read, :disposition => 'inline', :type=> 'application/pdf', :filename=>file_name, :layout=>false
20
+ file.close
20
21
  end
21
22
 
22
23
  end
@@ -6,50 +6,53 @@ module Medivo
6
6
  LABCORP_FORMAT = "%m/%d/%Y|%H:%M %P" unless defined? LABCORP_FORMAT
7
7
  MDY_FORMAT = "%m/%d/%Y" unless defined? MDY_FORMAT
8
8
 
9
- def self.find(lab_code, date, am_pm='')
10
- if real_data?
11
- data = resource.get :params=>{:labcorp_id=>lab_code, :appointment_date=>date}
12
- data = JSON.parse(data)
13
- else
14
- data = build_fake_data(date)
9
+ class << self
10
+
11
+ def find(lab_code, date, am_pm='')
12
+ if real_data?
13
+ data = resource.get :params=>{:labcorp_id=>lab_code, :appointment_date=>date}
14
+ data = JSON.parse(data)
15
+ else
16
+ data = build_fake_data(date)
17
+ end
18
+ filter_data(data, am_pm)
15
19
  end
16
- filter_data(data, am_pm)
17
- end
18
20
 
19
- def self.resource
20
- @resource ||= begin
21
- @config = ResourceConfig.find 'appointment_resource.yml'
22
- RestClient::Resource.new @config.href, :timeout => (@config.timeout || 12)
23
- rescue => e
24
- Rails.logger.error e.inspect
25
- # blow up later, so the server can start
21
+ def resource
22
+ @resource ||= begin
23
+ @config = ResourceConfig.find 'appointment_resource.yml'
24
+ RestClient::Resource.new @config.href, :timeout => (@config.timeout || 12)
25
+ rescue => e
26
+ Rails.logger.error e.inspect
27
+ # blow up later, so the server can start
28
+ end
26
29
  end
27
- end
28
30
 
29
- def self.real_data?
30
- resource # to init the resource and config file
31
- true unless ((Rails.env.development? or Rails.env.staging?) and @config.real_data == false)
32
- end
31
+ def real_data?
32
+ resource # to init the resource and config file
33
+ true unless ((Rails.env.development? or Rails.env.staging?) and @config.real_data == false)
34
+ end
33
35
 
34
- def self.filter_data(hash, am_pm)
35
- now = Time.now
36
- hash['times'].reject! do |time|
37
- (!time.match(/#{am_pm}/) or Time.strptime(time, LABCORP_FORMAT) < now)
36
+ def filter_data(hash, am_pm)
37
+ now = Time.now
38
+ hash['times'].reject! do |time|
39
+ (!time.match(/#{am_pm}/) or Time.strptime(time, LABCORP_FORMAT) < now)
40
+ end
41
+ hash
38
42
  end
39
- hash
40
- end
41
43
 
42
- def self.build_fake_data(date)
43
- date = date.is_a?(String) ? Date.strptime(date,MDY_FORMAT) : date
44
- {'times'=> [
45
- build_date(date,"08:30 AM"), build_date(date,"10:30 AM"),
46
- build_date((date + 1),"03:30 PM"), build_date((date+1),"01:30 PM"),
47
- build_date((date + 2),"10:30 AM"), build_date((date+1),"03:00 PM"),
48
- ]}
49
- end
44
+ def build_fake_data(date)
45
+ date = date.is_a?(String) ? Date.strptime(date, MDY_FORMAT) : date
46
+ {'times'=> [
47
+ build_date(date, "08:30 AM"), build_date(date, "10:30 AM"),
48
+ build_date((date + 1), "03:30 PM"), build_date((date+1), "01:30 PM"),
49
+ build_date((date + 2), "10:30 AM"), build_date((date+1), "03:00 PM"),
50
+ ]}
51
+ end
50
52
 
51
- def self.build_date(date, time)
52
- "#{date.strftime(MDY_FORMAT)}|#{time}"
53
+ def build_date(date, time)
54
+ "#{date.strftime(MDY_FORMAT)}|#{time}"
55
+ end
53
56
  end
54
57
  end
55
58
  end
@@ -1,3 +1,3 @@
1
1
  module Medivo
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -4,11 +4,11 @@ class OrdersController < ActionController::Base
4
4
  before_filter :set_pdf_headers, :get_lab_order, :only=>[:download_requisition,:download_result]
5
5
 
6
6
  def download_requisition
7
- send_pdf @lab_test_order.pdf_requisition.read, 'unitedhealthcare_requisition.pdf'
7
+ send_pdf @lab_test_order.pdf_requisition, 'unitedhealthcare_requisition.pdf'
8
8
  end
9
9
 
10
10
  def download_result
11
- send_pdf @lab_test_order.pdf_result.read, 'unitedhealthcare_result.pdf'
11
+ send_pdf @lab_test_order.pdf_result, 'unitedhealthcare_result.pdf'
12
12
  end
13
13
 
14
14
  def get_lab_order
@@ -1379,3 +1379,149 @@ Started GET "/medivo/labs/appointment_data?date=11%2F01%2F2011&lab_code=20060" f
1379
1379
  Processing by Medivo::LabsController#appointment_data as HTML
1380
1380
  Parameters: {"date"=>"11/01/2011", "lab_code"=>"20060"}
1381
1381
  Completed 200 OK in 1ms (Views: 0.4ms)
1382
+ Processing by OrdersController#download_requisition as HTML
1383
+ Rendered text template (0.0ms)
1384
+ Sent data unitedhealthcare_requisition.pdf (111.1ms)
1385
+ Completed 200 OK in 911ms (Views: 110.8ms)
1386
+ Processing by OrdersController#download_result as HTML
1387
+ Sent data unitedhealthcare_result.pdf (2.4ms)
1388
+ Completed 200 OK in 699ms (Views: 1.8ms)
1389
+
1390
+
1391
+ Started GET "/medivo/labs/lab_data?zip_code=90210" for 127.0.0.1 at 2011-11-11 09:35:11 -0500
1392
+ Processing by Medivo::LabsController#lab_data as HTML
1393
+ Parameters: {"zip_code"=>"90210"}
1394
+ Completed 200 OK in 351ms (Views: 2.1ms)
1395
+
1396
+
1397
+ Started GET "/labs/lab_search?zip_code=90210" for 127.0.0.1 at 2011-11-11 09:35:14 -0500
1398
+ Processing by LabsController#lab_search as HTML
1399
+ Parameters: {"zip_code"=>"90210"}
1400
+ Completed 200 OK in 242ms (Views: 39.0ms)
1401
+
1402
+
1403
+ Started GET "/assets/application.css" for 127.0.0.1 at 2011-11-11 09:35:14 -0500
1404
+ Served asset /application.css - 200 OK (4ms)
1405
+
1406
+
1407
+ Started GET "/assets/application.js" for 127.0.0.1 at 2011-11-11 09:35:14 -0500
1408
+ Served asset /application.js - 200 OK (38ms)
1409
+
1410
+
1411
+ Started GET "/assets/medivo/markerA.png" for 127.0.0.1 at 2011-11-11 09:35:15 -0500
1412
+ Served asset /medivo/markerA.png - 200 OK (3ms)
1413
+
1414
+
1415
+ Started GET "/assets/medivo/markerB.png" for 127.0.0.1 at 2011-11-11 09:35:15 -0500
1416
+ Served asset /medivo/markerB.png - 200 OK (2ms)
1417
+
1418
+
1419
+ Started GET "/assets/medivo/arrow.png" for 127.0.0.1 at 2011-11-11 09:35:15 -0500
1420
+ Served asset /medivo/arrow.png - 200 OK (3ms)
1421
+
1422
+
1423
+ Started GET "/medivo/labs/appointment_data?date=11%2F01%2F2011&lab_code=20060" for 127.0.0.1 at 2011-11-11 09:35:15 -0500
1424
+ Processing by Medivo::LabsController#appointment_data as HTML
1425
+ Parameters: {"date"=>"11/01/2011", "lab_code"=>"20060"}
1426
+ Completed 200 OK in 1ms (Views: 0.3ms)
1427
+ Processing by OrdersController#download_requisition as HTML
1428
+ Rendered text template (0.0ms)
1429
+ Sent data unitedhealthcare_requisition.pdf (75.7ms)
1430
+ Completed 200 OK in 885ms (Views: 74.8ms)
1431
+ Processing by OrdersController#download_result as HTML
1432
+ Sent data unitedhealthcare_result.pdf (2.2ms)
1433
+ Completed 200 OK in 723ms (Views: 1.5ms)
1434
+
1435
+
1436
+ Started GET "/medivo/labs/lab_data?zip_code=90210" for 127.0.0.1 at 2011-11-11 09:56:08 -0500
1437
+ Processing by Medivo::LabsController#lab_data as HTML
1438
+ Parameters: {"zip_code"=>"90210"}
1439
+ Completed 200 OK in 287ms (Views: 1.8ms)
1440
+
1441
+
1442
+ Started GET "/labs/lab_search?zip_code=90210" for 127.0.0.1 at 2011-11-11 09:56:10 -0500
1443
+ Processing by LabsController#lab_search as HTML
1444
+ Parameters: {"zip_code"=>"90210"}
1445
+ Completed 200 OK in 136ms (Views: 36.3ms)
1446
+
1447
+
1448
+ Started GET "/assets/application.css" for 127.0.0.1 at 2011-11-11 09:56:11 -0500
1449
+ Served asset /application.css - 200 OK (3ms)
1450
+
1451
+
1452
+ Started GET "/assets/application.js" for 127.0.0.1 at 2011-11-11 09:56:11 -0500
1453
+ Served asset /application.js - 200 OK (23ms)
1454
+
1455
+
1456
+ Started GET "/assets/medivo/markerA.png" for 127.0.0.1 at 2011-11-11 09:56:11 -0500
1457
+ Served asset /medivo/markerA.png - 200 OK (1ms)
1458
+
1459
+
1460
+ Started GET "/assets/medivo/markerB.png" for 127.0.0.1 at 2011-11-11 09:56:11 -0500
1461
+ Served asset /medivo/markerB.png - 200 OK (1ms)
1462
+
1463
+
1464
+ Started GET "/assets/medivo/arrow.png" for 127.0.0.1 at 2011-11-11 09:56:11 -0500
1465
+ Served asset /medivo/arrow.png - 200 OK (2ms)
1466
+
1467
+
1468
+ Started GET "/medivo/labs/appointment_data?date=11%2F01%2F2011&lab_code=20060" for 127.0.0.1 at 2011-11-11 09:56:11 -0500
1469
+ Processing by Medivo::LabsController#appointment_data as HTML
1470
+ Parameters: {"date"=>"11/01/2011", "lab_code"=>"20060"}
1471
+ Completed 200 OK in 1ms (Views: 0.5ms)
1472
+ Processing by OrdersController#download_requisition as HTML
1473
+ Rendered text template (0.0ms)
1474
+ Sent data unitedhealthcare_requisition.pdf (74.9ms)
1475
+ Completed 200 OK in 910ms (Views: 73.9ms)
1476
+ Processing by OrdersController#download_result as HTML
1477
+ Sent data unitedhealthcare_result.pdf (2.5ms)
1478
+ Completed 200 OK in 694ms (Views: 1.7ms)
1479
+
1480
+
1481
+ Started GET "/medivo/labs/lab_data?zip_code=90210" for 127.0.0.1 at 2011-11-11 10:00:22 -0500
1482
+ Processing by Medivo::LabsController#lab_data as HTML
1483
+ Parameters: {"zip_code"=>"90210"}
1484
+ Completed 200 OK in 261ms (Views: 2.2ms)
1485
+
1486
+
1487
+ Started GET "/labs/lab_search?zip_code=90210" for 127.0.0.1 at 2011-11-11 10:00:23 -0500
1488
+ Processing by LabsController#lab_search as HTML
1489
+ Parameters: {"zip_code"=>"90210"}
1490
+ Completed 200 OK in 268ms (Views: 39.7ms)
1491
+
1492
+
1493
+ Started GET "/assets/application.css" for 127.0.0.1 at 2011-11-11 10:00:24 -0500
1494
+ Served asset /application.css - 200 OK (4ms)
1495
+
1496
+
1497
+ Started GET "/assets/application.js" for 127.0.0.1 at 2011-11-11 10:00:24 -0500
1498
+ Served asset /application.js - 200 OK (21ms)
1499
+
1500
+
1501
+ Started GET "/assets/medivo/markerA.png" for 127.0.0.1 at 2011-11-11 10:00:24 -0500
1502
+ Served asset /medivo/markerA.png - 200 OK (1ms)
1503
+
1504
+
1505
+ Started GET "/assets/medivo/markerB.png" for 127.0.0.1 at 2011-11-11 10:00:24 -0500
1506
+ Served asset /medivo/markerB.png - 200 OK (2ms)
1507
+
1508
+
1509
+ Started GET "/assets/medivo/arrow.png" for 127.0.0.1 at 2011-11-11 10:00:24 -0500
1510
+ Served asset /medivo/arrow.png - 200 OK (2ms)
1511
+
1512
+
1513
+ Started GET "/medivo/labs/appointment_data?date=11%2F01%2F2011&lab_code=20060" for 127.0.0.1 at 2011-11-11 10:00:25 -0500
1514
+ Processing by Medivo::LabsController#appointment_data as HTML
1515
+ Parameters: {"date"=>"11/01/2011", "lab_code"=>"20060"}
1516
+ Completed 200 OK in 1ms (Views: 0.3ms)
1517
+ Processing by OrdersController#download_requisition as HTML
1518
+ Completed 500 Internal Server Error in 850ms
1519
+ Processing by OrdersController#download_result as HTML
1520
+ Completed 500 Internal Server Error in 740ms
1521
+ Processing by OrdersController#download_requisition as HTML
1522
+ Rendered text template (0.0ms)
1523
+ Sent data unitedhealthcare_requisition.pdf (67.9ms)
1524
+ Completed 200 OK in 886ms (Views: 67.1ms)
1525
+ Processing by OrdersController#download_result as HTML
1526
+ Sent data unitedhealthcare_result.pdf (1.8ms)
1527
+ Completed 200 OK in 684ms (Views: 1.1ms)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-10 00:00:00.000000000 -05:00
12
+ date: 2011-11-11 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2153317660 !ruby/object:Gem::Requirement
17
+ requirement: &2161036180 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153317660
25
+ version_requirements: *2161036180
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jquery-rails
28
- requirement: &2153317220 !ruby/object:Gem::Requirement
28
+ requirement: &2161035760 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2153317220
36
+ version_requirements: *2161035760
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-script
39
- requirement: &2153316740 !ruby/object:Gem::Requirement
39
+ requirement: &2161035300 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2153316740
47
+ version_requirements: *2161035300
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: haml-rails
50
- requirement: &2153316260 !ruby/object:Gem::Requirement
50
+ requirement: &2161034880 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2153316260
58
+ version_requirements: *2161034880
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: geocoder
61
- requirement: &2153315840 !ruby/object:Gem::Requirement
61
+ requirement: &2161034380 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2153315840
69
+ version_requirements: *2161034380
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
- requirement: &2153315420 !ruby/object:Gem::Requirement
72
+ requirement: &2161033960 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *2153315420
80
+ version_requirements: *2161033960
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: pdfkit
83
- requirement: &2153315000 !ruby/object:Gem::Requirement
83
+ requirement: &2161033540 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *2153315000
91
+ version_requirements: *2161033540
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: prawn
94
- requirement: &2153314500 !ruby/object:Gem::Requirement
94
+ requirement: &2161033100 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: '0'
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *2153314500
102
+ version_requirements: *2161033100
103
103
  description: Use the medivo platform to find lab locations, make labcorp appointments,
104
104
  place lab orders
105
105
  email:
@@ -263,7 +263,6 @@ files:
263
263
  - spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4
264
264
  - spec/dummy/tmp/cache/assets/E59/D50/sprockets%2Fbe1cc4d9b0efb617e58baa16dd1dee58
265
265
  - spec/dummy/tmp/image_path_fb5f3a59200b_1320622886.pdf
266
- - spec/dummy/tmp/pids/server.pid
267
266
  - spec/fixtures/hepc_negative_results.pdf
268
267
  - spec/fixtures/hepc_result_faq.pdf
269
268
  - spec/fixtures/lc_order_with_normal_results.xml
@@ -301,7 +300,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
301
300
  version: '0'
302
301
  segments:
303
302
  - 0
304
- hash: -80493960223806084
303
+ hash: 2876077184686065658
305
304
  required_rubygems_version: !ruby/object:Gem::Requirement
306
305
  none: false
307
306
  requirements:
@@ -310,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
310
309
  version: '0'
311
310
  segments:
312
311
  - 0
313
- hash: -80493960223806084
312
+ hash: 2876077184686065658
314
313
  requirements: []
315
314
  rubyforge_project:
316
315
  rubygems_version: 1.6.2
@@ -413,7 +412,6 @@ test_files:
413
412
  - spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4
414
413
  - spec/dummy/tmp/cache/assets/E59/D50/sprockets%2Fbe1cc4d9b0efb617e58baa16dd1dee58
415
414
  - spec/dummy/tmp/image_path_fb5f3a59200b_1320622886.pdf
416
- - spec/dummy/tmp/pids/server.pid
417
415
  - spec/fixtures/hepc_negative_results.pdf
418
416
  - spec/fixtures/hepc_result_faq.pdf
419
417
  - spec/fixtures/lc_order_with_normal_results.xml
@@ -1 +0,0 @@
1
- 22751