medivo 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/app/assets/javascripts/medivo/date.js +1078 -0
  2. data/app/assets/javascripts/medivo/helpers.coffee +31 -0
  3. data/app/assets/javascripts/medivo/lab_appointment/application.js +6 -0
  4. data/app/assets/javascripts/medivo/lab_appointment/handlers.coffee +31 -0
  5. data/app/assets/javascripts/medivo/lab_appointment/models.coffee +16 -0
  6. data/app/assets/javascripts/medivo/lab_appointment/sample/show_appointments.coffee +13 -0
  7. data/app/assets/javascripts/medivo/lab_appointment/views.coffee +9 -0
  8. data/app/assets/javascripts/medivo/lab_list/application.js +2 -1
  9. data/app/assets/javascripts/medivo/lab_list/{init.coffee → handlers.coffee} +7 -6
  10. data/app/assets/javascripts/medivo/lab_list/models.coffee +12 -54
  11. data/app/assets/javascripts/medivo/lab_list/sample/show_labs.coffee +8 -1
  12. data/app/assets/javascripts/medivo/lab_list/views.coffee +21 -30
  13. data/app/assets/javascripts/medivo/models.coffee +29 -0
  14. data/app/assets/javascripts/medivo/views.coffee +16 -0
  15. data/app/controllers/medivo/labs_controller.rb +10 -0
  16. data/app/models/medivo/appointment.rb +21 -0
  17. data/app/models/medivo/appointment_resource.rb +14 -0
  18. data/app/models/medivo/insurance_order.rb +1 -6
  19. data/app/models/medivo/lab.rb +11 -9
  20. data/app/models/medivo/lab_resource.rb +14 -0
  21. data/app/models/medivo/order.rb +2 -2
  22. data/app/models/medivo/primary_insurance.rb +6 -4
  23. data/app/models/medivo/resource_config.rb +16 -0
  24. data/config/routes.rb +1 -0
  25. data/lib/generators/medivo/appointments/appointments_generator.rb +15 -0
  26. data/lib/generators/medivo/labs/labs_generator.rb +33 -0
  27. data/lib/generators/medivo/templates/appointment_resource.yml +11 -0
  28. data/lib/generators/medivo/templates/lab_resource.yml +21 -0
  29. data/lib/generators/medivo/templates/labs_controller.rb +6 -0
  30. data/lib/generators/medivo/templates/search.html.haml +45 -0
  31. data/lib/medivo.rb +2 -1
  32. data/lib/medivo/fdf_generator.rb +36 -0
  33. data/lib/medivo/version.rb +1 -1
  34. data/spec/dummy/app/assets/javascripts/application.js +2 -0
  35. data/spec/dummy/app/controllers/labs_controller.rb +3 -5
  36. data/spec/dummy/app/views/labs/search.html.haml +31 -1
  37. data/spec/dummy/config/medivo/appointment_resource.yml +12 -0
  38. data/spec/dummy/config/medivo/lab_resource.yml +21 -0
  39. data/spec/dummy/config/routes.rb +1 -1
  40. data/spec/dummy/log/development.log +7782 -0
  41. data/spec/dummy/log/test.log +243 -0
  42. data/spec/dummy/tmp/cache/assets/C46/F00/sprockets%2F2281d588b540056c5a7306c32a3761b9 +0 -0
  43. data/spec/dummy/tmp/cache/assets/C69/500/sprockets%2F140b56780716711c2b6eb1028f042ca6 +0 -0
  44. data/spec/dummy/tmp/cache/assets/C6C/8D0/sprockets%2F2f423a28516973330a94ad121151f3bf +0 -0
  45. data/spec/dummy/tmp/cache/assets/C70/AC0/sprockets%2F25232afc7932c662d9d6f032030a2428 +0 -0
  46. data/spec/dummy/tmp/cache/assets/C81/D00/sprockets%2F64f056bd752d271308a86a6f865b1911 +0 -0
  47. data/spec/dummy/tmp/cache/assets/CB4/BD0/sprockets%2F3378f27c0d4f5e6d708665b22707a31f +0 -0
  48. data/spec/dummy/tmp/cache/assets/CC3/EF0/sprockets%2F453b504c1f8f374578636f699eaa455d +0 -0
  49. data/spec/dummy/tmp/cache/assets/CD8/DA0/sprockets%2F622aa5281d15503829a5f7a0bf56fc29 +0 -0
  50. data/spec/dummy/tmp/cache/assets/CDD/820/sprockets%2Fb28231960c7ac62eff9048e702a29c70 +0 -0
  51. data/spec/dummy/tmp/cache/assets/CEC/EF0/sprockets%2F4b24a74018f693c06088bd52f8cc9f86 +0 -0
  52. data/spec/dummy/tmp/cache/assets/CEE/250/sprockets%2F96688f33f2f8aa261bf6701c1d6d7575 +0 -0
  53. data/spec/dummy/tmp/cache/assets/D07/6B0/sprockets%2F69a2df619ff14da071309dac4196400e +0 -0
  54. data/spec/dummy/tmp/cache/assets/D1B/820/sprockets%2F92a83e15913997b3d9ac7ed437b1e44c +0 -0
  55. data/spec/dummy/tmp/cache/assets/D20/F10/sprockets%2Fb2e907e4faa85fe755f4439e3b229088 +0 -0
  56. data/spec/dummy/tmp/cache/assets/D29/000/sprockets%2F61a10ddf57f1129c02a1049bfed6e007 +0 -0
  57. data/spec/dummy/tmp/cache/assets/D2C/F80/sprockets%2F399f6d5eb273936af7ff8f35a77c5037 +0 -0
  58. data/spec/dummy/tmp/cache/assets/D30/920/sprockets%2Fcc4603fc6441ca421a7d02886a81ab9d +0 -0
  59. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  60. data/spec/dummy/tmp/cache/assets/D36/870/sprockets%2Fce9e887568de873b133ae43d7c977f68 +0 -0
  61. data/spec/dummy/tmp/cache/assets/D3A/210/sprockets%2F4f9664dabb00038f85b417cc38bf83a1 +0 -0
  62. data/spec/dummy/tmp/cache/assets/D41/250/sprockets%2F7b3c4426715dcd1feedc4a95e5444256 +0 -0
  63. data/spec/dummy/tmp/cache/assets/D45/320/sprockets%2Fc50ff379a1bdf1dd4d22249058749cf6 +0 -0
  64. data/spec/dummy/tmp/cache/assets/D4C/7A0/sprockets%2Fbc635c7b186d1ef5178f4ed3722d868b +0 -0
  65. data/spec/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  66. data/spec/dummy/tmp/cache/assets/D55/ED0/sprockets%2F0f673e42e816c6fe5b66a5c96f896f1a +0 -0
  67. data/spec/dummy/tmp/cache/assets/D5D/3E0/sprockets%2F63fea6cc142b5f02da93bf81e70b2116 +0 -0
  68. data/spec/dummy/tmp/cache/assets/D60/030/sprockets%2Ffc9485f617fc5e9b8918755d2e08ecc6 +0 -0
  69. data/spec/dummy/tmp/cache/assets/D64/C50/sprockets%2F22ee6fb2ab1ea9694ac7f0f41a406094 +0 -0
  70. data/spec/dummy/tmp/cache/assets/D65/6D0/sprockets%2F3ce07ca1958d7ab3e80c4b3e0d24088c +0 -0
  71. data/spec/dummy/tmp/cache/assets/D68/AD0/sprockets%2F19727663b4ec901b812dbdabee2526ec +0 -0
  72. data/spec/dummy/tmp/cache/assets/D69/130/sprockets%2Fbaa4ec50a34ce938c986612c2a47a64e +0 -0
  73. data/spec/dummy/tmp/cache/assets/D6E/700/sprockets%2Ff39fb8d8a25e4f3fd01a3e506ae31935 +0 -0
  74. data/spec/dummy/tmp/cache/assets/D74/9A0/sprockets%2F0ca4e6e833c72156fc7e7d5f007d9ce3 +0 -0
  75. data/spec/dummy/tmp/cache/assets/D76/720/sprockets%2F88d8aa1d2fb41ce79b8ec4150ea74748 +0 -0
  76. data/spec/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  77. data/spec/dummy/tmp/cache/assets/D88/2C0/sprockets%2F452ab3ebb1912cf1c2ba617eec52a718 +0 -0
  78. data/spec/dummy/tmp/cache/assets/D9C/F50/sprockets%2F224e78bb9e1c414a2d518a3aaffd6f77 +0 -0
  79. data/spec/dummy/tmp/cache/assets/D9F/260/sprockets%2Fa3e040f83c30e4bbc1c79ffae57909e6 +0 -0
  80. data/spec/dummy/tmp/cache/assets/DA1/640/sprockets%2F91874cbba5e63cd19d6a7bd3c8362dc4 +0 -0
  81. data/spec/dummy/tmp/cache/assets/DC1/230/sprockets%2F3a36cd467bdce1914a2b7af4ed4114cf +0 -0
  82. data/spec/dummy/tmp/cache/assets/DCE/E80/sprockets%2Fc71ec62157b9cc7aabfc030955cef87b +0 -0
  83. data/spec/dummy/tmp/cache/assets/DD1/FD0/sprockets%2Fa531f33dc9c5852d39d64a9eda44dacf +0 -0
  84. data/spec/dummy/tmp/cache/assets/DD4/2B0/sprockets%2Fef214a63f29afe7f3cbffc65af943108 +0 -0
  85. data/spec/dummy/tmp/cache/assets/DFC/420/sprockets%2F502e2c683d1aaad6ac88966ffc4d2ade +0 -0
  86. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  87. data/spec/dummy/tmp/cache/assets/E32/FC0/sprockets%2Fe55fb2eef11567fe04fdaf7e73af5ba4 +0 -0
  88. data/spec/dummy/tmp/pids/server.pid +1 -1
  89. data/spec/models/orders_spec.rb +1 -23
  90. data/spec/models/primary_insurance_spec.rb +31 -0
  91. data/spec/requests/labs_spec.rb +0 -1
  92. data/spec/spec_helper.rb +7 -1
  93. data/spec/support/blueprints.rb +9 -1
  94. data/spec/support/helper.rb +9 -0
  95. metadata +94 -26
  96. data/app/assets/javascripts/medivo/lab_appointments/application.js +0 -0
  97. data/app/assets/javascripts/medivo/lab_appointments/models.coffee +0 -0
  98. data/app/assets/javascripts/medivo/lab_appointments/sample/show_appointments.coffee +0 -0
  99. data/app/assets/javascripts/medivo/lab_appointments/views.coffee +0 -0
  100. data/app/models/medivo/resource.rb +0 -24
  101. data/lib/generators/medivo/install/install_generator.rb +0 -41
  102. data/lib/generators/medivo/install/templates/medivo_resource.yml +0 -9
  103. data/spec/dummy/config/medivo_resource.yml +0 -12
@@ -0,0 +1,31 @@
1
+ ########## js and handlebars helpers ##############
2
+ window.isNumber = (n)->
3
+ !isNaN(parseFloat(n)) && isFinite(n)
4
+
5
+ String.prototype.capitalize = ->
6
+ this.charAt(0).toUpperCase() + this.substring(1).toLowerCase()
7
+
8
+ String.prototype.titleize = ->
9
+ res = []
10
+ parts = this.split(" ")
11
+ $.each(parts, (index, part)->
12
+ res.push(part.capitalize())
13
+ )
14
+ res.join(" ")
15
+
16
+ Handlebars.registerHelper("rounded", (number)->
17
+ if isNumber(number)
18
+ parseFloat(number).toFixed(2)
19
+ )
20
+
21
+ Handlebars.registerHelper("titleize", (string)->
22
+ if (string != undefined)
23
+ string.titleize()
24
+ )
25
+
26
+ Handlebars.registerHelper("address_without_comma", (lab)->
27
+ return unless this.data and this.data.address
28
+ this.data.address.replace(/(\s*,\s*$)/g, "").titleize()
29
+ )
30
+
31
+
@@ -0,0 +1,6 @@
1
+ //= require medivo/date
2
+ //= require medivo/handlebars
3
+ //= require medivo/helpers
4
+ //= require medivo/lab_appointment/models
5
+ //= require medivo/lab_appointment/views
6
+ //= require medivo/lab_appointment/handlers
@@ -0,0 +1,31 @@
1
+ $(document).ready ->
2
+
3
+ ####### value of the selected time ##########
4
+ $('input:radio[name=appointment_time]:checked').val()
5
+
6
+ ###### handle ajax appointment data search ########
7
+ $("form#appointment_data_search")
8
+ .bind('ajax:beforeSend', (event, data)->
9
+ date = $(this).find('#appointment_date').val()
10
+ # if (!date.match(/\d{5}/))
11
+ # span = $('<span>Date format should be MM/DD/YYYY</span>')
12
+ # $('form#appointment_data_search .error_message').append(span)
13
+ # span.fadeOut(4000)
14
+ # false
15
+ )
16
+ .bind('ajax:success', (event, data)->
17
+ window.appointment_list.setList(data.times)
18
+ # set the first as selected
19
+ $('input:radio[name=appointment_time]:first').prop('checked',true)
20
+ $('form#appointment_data_search input[type=submit]').prop("disabled", false)
21
+ )
22
+ .bind('ajax:complete', (event, data)->
23
+ # nothing here for now
24
+ )
25
+
26
+ ###### handle toggle to show more appointments ########
27
+ $("#more_appointments_list_toggler").live("click", ->
28
+ window.appointment_list.setShowNumber(window.max_appointment_show_number)
29
+ $("#more_appointments_list_toggler").parent('p').hide()
30
+ )
31
+
@@ -0,0 +1,16 @@
1
+ #= require medivo/models
2
+
3
+ ########## Appointment model ##############
4
+ class window.Appointment
5
+ constructor: (@data) ->
6
+
7
+ formattedDate: ->
8
+ date = @data.replace('|',' ')
9
+ Date.parse(date).toString("dddd, MMMM d, yyyy hh:mm tt")
10
+
11
+ ########## AppointmentList model ##############
12
+ class window.AppointmentList extends List
13
+
14
+ constructor: (appointment_info, show_number)->
15
+ super( appointment_info, show_number, Appointment, 'appointment_list_tracker')
16
+
@@ -0,0 +1,13 @@
1
+ #
2
+ # this is a sample of how to initialize the showing of appointments
3
+ # you could use this javascript or do your own
4
+ #
5
+
6
+ $(document).ready ->
7
+
8
+ ####### init empty lab list and the views #########
9
+ appointment_show_number = 5
10
+ window.max_appointment_show_number = 10 # used in handler.coffee
11
+ window.appointment_list = new window.AppointmentList( [], appointment_show_number )
12
+ window.appointment_list_view = new window.AppointmentListView( appointment_list )
13
+
@@ -0,0 +1,9 @@
1
+ #= require medivo/views
2
+
3
+ ############### AppointmentList view ###############
4
+ class window.AppointmentListView extends ListView
5
+ constructor: (@list)->
6
+ super(@list, 'appointment_list', 'appointment_item_template')
7
+
8
+
9
+
@@ -4,6 +4,7 @@
4
4
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
5
  // the compiled file.
6
6
  //= require medivo/handlebars
7
+ //= require medivo/helpers
7
8
  //= require medivo/lab_list/models
8
9
  //= require medivo/lab_list/views
9
- //= require medivo/lab_list/init
10
+ //= require medivo/lab_list/handlers
@@ -1,10 +1,5 @@
1
1
  $(document).ready ->
2
2
 
3
- ####### init empty lab list and the views #########
4
- window.lab_list = new window.OrderedLabList( [] )
5
- window.map_view = new window.MapView( lab_list )
6
- window.lab_list_view = new window.LabListView( lab_list )
7
-
8
3
  ###### handle ajax lab data search ########
9
4
  $("form#lab_data_search")
10
5
  .bind('ajax:beforeSend', (event, data)->
@@ -17,8 +12,14 @@ $(document).ready ->
17
12
  )
18
13
  .bind('ajax:success', (event, data)->
19
14
  window.map_view.center_point = data.zip_location
20
- window.lab_list.setLabs(data.labs)
15
+ window.lab_list.setList(data.labs)
21
16
  $('form#lab_data_search input[type=submit]').prop("disabled", false)
22
17
  )
23
18
  .bind('ajax:complete', (event, data)->
24
19
  )
20
+
21
+ ###### handle toggle to show more labs ########
22
+ $("#more_labs_list_toggler").live("click", ->
23
+ window.lab_list.setShowNumber(window.max_lab_show_number)
24
+ $("#more_labs_list_toggler").parent('p').hide()
25
+ )
@@ -1,33 +1,4 @@
1
- ########## handlebars helpers ##############
2
- isNumber = (n)->
3
- !isNaN(parseFloat(n)) && isFinite(n)
4
-
5
- String.prototype.capitalize = ->
6
- this.charAt(0).toUpperCase() + this.substring(1).toLowerCase()
7
-
8
- String.prototype.titleize = ->
9
- res = []
10
- parts = this.split(" ")
11
- $.each(parts, (index, part)->
12
- res.push(part.capitalize())
13
- )
14
- res.join(" ")
15
-
16
- Handlebars.registerHelper("rounded", (number)->
17
- if isNumber(number)
18
- parseFloat(number).toFixed(2)
19
- )
20
-
21
- Handlebars.registerHelper("titleize", (string)->
22
- if (string != undefined)
23
- string.titleize()
24
- )
25
-
26
- Handlebars.registerHelper("address_without_comma", (lab)->
27
- return unless this.data and this.data.address
28
- this.data.address.replace(/(\s*,\s*$)/g, "").titleize()
29
- )
30
-
1
+ #= require medivo/models
31
2
 
32
3
  ########## Lab model ##############
33
4
  class window.Lab
@@ -70,7 +41,7 @@ class window.OrderedLab extends Lab
70
41
  constructor: (@data, index) -> @index = index
71
42
 
72
43
  makeIcon: ->
73
- super() unless isNumber(@index)
44
+ super() unless window.isNumber(@index)
74
45
  "/assets/medivo/marker" + this.makeLetter(@index) + ".png"
75
46
 
76
47
  makeLetter: (number) ->
@@ -84,38 +55,25 @@ class window.OrderedLab extends Lab
84
55
 
85
56
 
86
57
  ########## LabList model ##############
87
- class window.LabList
88
- show_number: 3
89
- @tracker_elem: $("<input type='hidden'>")
90
-
91
- constructor: (lab_info, show_number)->
92
- @labs = []
93
- @show_number = show_number if show_number
94
- this.setLabs(lab_info)
58
+ class window.LabList extends List
95
59
 
96
- getLabs: -> @labs.slice(0, @show_number)
60
+ constructor: (lab_info, show_number, model, tracker_id)->
61
+ model = Lab unless model
62
+ tracker_id = 'lab_list_tracker' unless tracker_id
63
+ super( lab_info, show_number, model, tracker_id)
97
64
 
98
65
  # use this method to set new lab info
99
- setLabs: (lab_info)->
66
+ setList: (lab_info)->
100
67
  this.clearMarkers()
101
- @labs = []
102
- this.loadLabs(lab_info)
103
- LabList.tracker_elem.change()
68
+ super(lab_info)
104
69
 
105
70
  clearMarkers: ->
106
- $.each( @labs, (index, lab)-> lab.clearMarker() )
107
-
108
- loadLabs: (lab_info)->
109
- return unless lab_info
110
- labs = @labs
111
- $.each( lab_info, (index, lab_data)-> labs.push(new Lab(lab_data)) )
71
+ $.each( @list, (index, lab)-> lab.clearMarker() )
112
72
 
113
73
 
114
74
  ########## OrderedLabList model ##############
115
75
  class window.OrderedLabList extends LabList
116
- loadLabs: (lab_info)->
117
- return unless lab_info
118
- labs = @labs
119
- $.each( lab_info, (index, lab_data)-> labs.push(new OrderedLab(lab_data, index)) )
76
+ constructor: (lab_info, show_number)->
77
+ super( lab_info, show_number, OrderedLab, 'ordered_lab_list_tracker')
120
78
 
121
79
 
@@ -5,11 +5,18 @@
5
5
 
6
6
  $(document).ready ->
7
7
 
8
+ ####### init empty lab list and the views #########
9
+ lab_show_number = 3 # how many labs to show at the start
10
+ window.max_lab_show_number = 6 # used in medivo/lab_list/handler.coffee
11
+ window.lab_list = new window.OrderedLabList( [], lab_show_number )
12
+ window.map_view = new window.MapView( lab_list )
13
+ window.lab_list_view = new window.LabListView( lab_list )
14
+
8
15
  # if you are loading data while the page first shows
9
16
  data = $('#lab_list_container').data('labs')
10
17
  if data.labs
11
18
  # can limit the number of labs to show with option show_labs in LabList constructor
12
19
  window.map_view.center_point = data.zip_location
13
- window.lab_list.setLabs(data.labs)
20
+ window.lab_list.setList(data.labs)
14
21
  else
15
22
  console.log('no data')
@@ -1,35 +1,25 @@
1
- ############### LabList view ###############
2
- class window.LabListView
3
-
4
- constructor: (@lab_list)->
5
- @el = $('#lab_list')
6
- @template = null
7
- this.render() if @lab_list
8
- view = this
9
- LabList.tracker_elem.change( -> view.render() )
10
-
11
- render: ->
12
- @template = Handlebars.compile($('#lab_item_template').html()) unless @template
13
- view = this
14
- view.el.empty()
15
- $.each( @lab_list.getLabs(), (index, lab)-> view.el.append( $(view.template(lab)) ) )
1
+ #= require medivo/views
16
2
 
3
+ ############### LabList view ###############
4
+ class window.LabListView extends ListView
5
+ constructor: (@list)->
6
+ super(@list, 'lab_list', 'lab_item_template')
17
7
 
18
8
 
19
9
  ############### Map view ###############
20
10
  ## the standard map view with lab icon ##
21
11
  class window.MapView
22
- constructor: (@collection, @center_point)->
23
- this.render()
24
- view = this
25
- LabList.tracker_elem.change( -> view.render() )
26
-
27
12
  el: $('#map_canvas')
28
13
  center_marker: null
29
- view: null
14
+ map: null
30
15
  markerBounds: new google.maps.LatLngBounds()
31
16
  markerBoundsZoomOut: 0.1
32
17
 
18
+ constructor: (@list, @center_point)->
19
+ this.render()
20
+ map_view = this
21
+ @list.tracker_elem.change( -> map_view.render() )
22
+
33
23
  options: {
34
24
  mapTypeId: google.maps.MapTypeId.ROADMAP
35
25
  mapTypeControl: false
@@ -37,36 +27,37 @@ class window.MapView
37
27
 
38
28
  prepareMap: ->
39
29
  return unless document.getElementById("map_canvas")
40
- if !this.view
41
- this.view = new google.maps.Map(document.getElementById("map_canvas"), this.options)
30
+ if !@map
31
+ @map = new google.maps.Map(document.getElementById("map_canvas"), this.options)
42
32
 
43
33
  createCenterMarker: ->
44
34
  if @center_point
45
35
  point = new google.maps.LatLng(this.center_point.lat, this.center_point.lng)
46
36
  @center_marker = new google.maps.Marker({
47
- position: point,
48
- map: this.view,
37
+ position: point
38
+ map: @map
49
39
  title: this.center_point.title
50
40
  icon: "/assets/medivo/arrow.png"
51
41
  })
52
42
  this.markerBounds.extend(this.center_marker.position) if this.markerBounds and this.center_marker
53
43
 
54
44
  setMarkers: (map, markerBounds) ->
55
- $.each( @collection.getLabs(), (index, model)-> model.setMarker(map, markerBounds) )
45
+ $.each( @list.getList(), (index, model)-> model.setMarker(map, markerBounds) )
56
46
 
57
47
  clear: ->
58
- @collection.clearMarkers()
48
+ @list.clearMarkers()
59
49
  if this.center_marker
60
50
  this.center_marker.setMap(null)
61
51
  this.center_marker = null
62
52
  this.markerBounds = new google.maps.LatLngBounds()
63
53
 
64
54
  render: ->
65
- return unless @collection
55
+ return unless @list
66
56
  this.clear()
67
57
  this.prepareMap()
58
+ return unless @map
68
59
  this.createCenterMarker()
69
- this.setMarkers(this.view, this.markerBounds)
60
+ this.setMarkers(@map, this.markerBounds)
70
61
 
71
62
  # extend the bounds if its too small
72
63
  if (this.markerBounds.getNorthEast().equals(this.markerBounds.getSouthWest()))
@@ -75,7 +66,7 @@ class window.MapView
75
66
  this.markerBounds.getNorthEast().lng() + this.markerBoundsZoomOut
76
67
  )
77
68
  this.markerBounds.extend(extendPoint)
78
- this.view.fitBounds(this.markerBounds)
69
+ @map.fitBounds(this.markerBounds)
79
70
 
80
71
 
81
72
 
@@ -0,0 +1,29 @@
1
+ ########## List model ##############
2
+ class window.List
3
+ show_number: 3
4
+
5
+ constructor: (list_data, show_number, model, tracker_id)->
6
+ @list = []
7
+ @show_number = show_number if show_number
8
+ @model = model
9
+ @tracker_elem = $("<input id='#{tracker_id}' type='hidden'>")
10
+ this.setList(list_data)
11
+
12
+ getList: -> @list.slice(0, @show_number)
13
+
14
+ # use this method to set a new list
15
+ setList: (list_info)->
16
+ @list = []
17
+ this.loadList(list_info)
18
+ @tracker_elem.change()
19
+
20
+ setShowNumber: (num)->
21
+ @show_number = num
22
+ @tracker_elem.change()
23
+
24
+ # meant for internal use. use setList to set the list with info
25
+ loadList: (list_info)->
26
+ return unless list_info
27
+ list = @list
28
+ model = @model
29
+ $.each( list_info, (index, data)-> list.push(new model(data, index)) )
@@ -0,0 +1,16 @@
1
+ ############### List view ###############
2
+ class window.ListView
3
+
4
+ constructor: (@list, element_id, template_id)->
5
+ @el = $("##{element_id}")
6
+ @template = Handlebars.compile($("##{template_id}").html())
7
+ this.render() if @list
8
+ view = this
9
+ @list.tracker_elem.change( -> view.render() )
10
+
11
+ render: ->
12
+ view = this
13
+ view.el.empty()
14
+ $.each( @list.getList(), (index, item)-> view.el.append( $(view.template(item)) ) )
15
+
16
+
@@ -4,5 +4,15 @@ module Medivo
4
4
  lab_data = Medivo::Lab.data_for_zip(params[:zip_code])
5
5
  render :json=> lab_data, :layout => nil
6
6
  end
7
+
8
+ def appointment_data
9
+ data = if Rails.env.development?
10
+ "{\"times\":[\"11/03/2011|08:30 AM\",\"11/04/2011|08:30 AM\",\"11/02/2011|09:00 AM\",\"11/01/2011|09:30 AM\",\"11/02/2011|09:30 AM\",\"11/03/2011|09:30 AM\",\"11/04/2011|09:30 AM\",\"10/31/2011|10:00 AM\",\"11/01/2011|10:00 AM\",\"11/02/2011|10:00 AM\",\"11/03/2011|10:00 AM\",\"11/04/2011|10:00 AM\",\"11/05/2011|10:00 AM\",\"10/31/2011|10:30 AM\",\"11/01/2011|10:30 AM\",\"11/02/2011|10:30 AM\",\"11/03/2011|10:30 AM\",\"10/31/2011|11:00 AM\",\"11/01/2011|11:00 AM\",\"11/02/2011|11:00 AM\",\"11/03/2011|11:00 AM\",\"11/04/2011|11:00 AM\",\"11/05/2011|11:00 AM\",\"10/31/2011|01:30 PM\",\"11/01/2011|01:30 PM\",\"11/02/2011|01:30 PM\",\"11/03/2011|01:30 PM\",\"11/04/2011|01:30 PM\",\"10/31/2011|02:00 PM\",\"11/01/2011|02:00 PM\",\"11/02/2011|02:00 PM\",\"11/03/2011|02:00 PM\",\"10/31/2011|02:30 PM\",\"11/01/2011|02:30 PM\",\"11/02/2011|02:30 PM\",\"11/03/2011|02:30 PM\",\"11/04/2011|02:30 PM\",\"10/31/2011|03:00 PM\",\"11/01/2011|03:00 PM\",\"11/02/2011|03:00 PM\",\"11/03/2011|03:00 PM\",\"11/04/2011|03:00 PM\",\"10/31/2011|03:30 PM\",\"11/01/2011|03:30 PM\",\"11/02/2011|03:30 PM\",\"11/03/2011|03:30 PM\",\"11/04/2011|03:30 PM\",\"10/31/2011|04:00 PM\",\"11/01/2011|04:00 PM\",\"11/02/2011|04:00 PM\",\"11/03/2011|04:00 PM\",\"11/04/2011|04:00 PM\"]}"
11
+ else
12
+ Medivo::Appointment.find(params[:lab_code], params[:date])
13
+ end
14
+ render :json=> data, :layout => nil
15
+ end
7
16
  end
8
17
  end
18
+
@@ -0,0 +1,21 @@
1
+ require 'restclient'
2
+
3
+ module Medivo
4
+ class Appointment
5
+
6
+ def self.find(lab_code, date)
7
+ resource.get :params=>{:labcorp_id=>lab_code, :appointment_date=>date}
8
+ end
9
+
10
+ private
11
+ def self.resource
12
+ @resource ||= begin
13
+ config_file = File.join(Rails.root.join('config', 'medivo', 'appointment_resource.yml'))
14
+ config = YAML.load_file(config_file)[Rails.env]
15
+ RestClient::Resource.new config['href'], :timeout => (config['timeout'] || 12)
16
+ rescue => e
17
+ p e
18
+ end
19
+ end
20
+ end
21
+ end