Fee sheet and Codes revenue code (#7415)
[openemr.git] / interface / forms / fee_sheet / review / initialize_review.js
bloba8eff1d4155f20273863e05f71fb407c6bcaeea1
1 /**
2  * Basic javascript setup for the fee sheet review features
3  *
4  * @package   OpenEMR
5  * @link      http://www.open-emr.org
6  * @author    Kevin Yeh <kevin.y@integralemr.com>
7  * @copyright Copyright (c) 2013 Kevin Yeh <kevin.y@integralemr.com> and OEMR <www.oemr.org>
8  * @license   https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
9  */
11 var fee_sheet_new = webroot + "/interface/forms/fee_sheet/new.php";
14 var review_path = webroot + "/interface/forms/fee_sheet/review/";
15 var review_ajax = review_path + "fee_sheet_ajax.php";
17 var ajax_fee_sheet_options = review_path + "fee_sheet_options_ajax.php";
18 var justify_ajax = review_path + "fee_sheet_justify.php";
20 var ajax_fee_sheet_search = review_path + "fee_sheet_search_ajax.php";
22 var display_table_selector = "table[name='selected_codes']";
24 function add_review_button() {
25     var review = $("<input type='button' class='btn btn-primary'/>");
26     review.attr("value", review_tag);
27     review.attr("data-bind", "click: review_event")
28     var td = $("<td class='review_td'></td>");
29     td.append(review)
30     var template = $("<div class='review'></div>").appendTo(td);
31     template.attr("data-bind", "template: {name: 'review-display', data: review}");
32     // This makes the Review button first in the row.
33     // $("[name='search_term']").parent().parent().prepend(td); // left the  original code alone
34     $("#copay_review tr:first").append(td);
35     return td;
38 function get_fee_sheet_options(level) {
39     fee_sheet_options = [];
40     var fso = $.ajax(ajax_fee_sheet_options, {
41         type: "GET",
42         data: {
43             pricelevel: level
44         },
45         async: false,
46         dataType: "json"
47     });
48     var json_options = JSON.parse(fso.responseText)['fee_sheet_options'];
49     for (var idx = 0; idx < json_options.length; idx++) {
50         var cur = json_options[idx];
51         fee_sheet_options.push(new fee_sheet_option(cur.code, cur.code_type, cur.description, cur.price));
52     }
53     return fee_sheet_options;
56 var view_model;
58 function initialize_review() {
59     var review = add_review_button();
61     view_model = new fee_sheet_review_view_model();
62     view_model.displayReview = ko.observable(false);
63     get_fee_sheet_options('standard');
64     ko.applyBindings(view_model, review.get(0));
66 $(initialize_review);