Fee sheet enhancements
[openemr.git] / interface / forms / fee_sheet / review / initialize_review.js
blob15e938c81cc6992d9f24ffccd997abfa9bfb67df
1 /**
2  * Basic javascript setup for the fee sheet review features
3  * 
4  * Copyright (C) 2013 Kevin Yeh <kevin.y@integralemr.com> and OEMR <www.oemr.org>
5  *
6  * LICENSE: This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16  *
17  * @package OpenEMR
18  * @author  Kevin Yeh <kevin.y@integralemr.com>
19  * @link    http://www.open-emr.org
20  */
21 var fee_sheet_new=webroot+"/interface/forms/fee_sheet/new.php";
24 var review_path=webroot+"/interface/forms/fee_sheet/review/";
25 var review_ajax=review_path+"fee_sheet_ajax.php";
27 var ajax_fee_sheet_options=review_path+"fee_sheet_options_ajax.php";
28 var justify_ajax=review_path+"fee_sheet_justify.php";
30 var ajax_fee_sheet_search=review_path+"fee_sheet_search_ajax.php";
32 var display_table_selector="table[cellspacing='5']";
34 function add_review_button()
37     var review=$("<input type='button'/>");
38     review.attr("value",review_tag);
39     review.attr("data-bind","click: review_event")
40     var td=$("<td class='review_td'></td>");
41     td.append(review)
42     var template=$("<div class='review'></div>").appendTo(td);
43     template.attr("data-bind","template: {name: 'review-display', data: review}");
44     var copay=$("td > input:first").parent();
45     copay.before(td);
46     return td;
50 function get_fee_sheet_options(level)
52     fee_sheet_options=[];
53     var fso=$.ajax(ajax_fee_sheet_options,{type:"GET",data:{pricelevel: level},async:false,dataType:"json"});
54     var json_options=JSON.parse(fso.responseText)['fee_sheet_options'];
55     for(var idx=0;idx<json_options.length;idx++)
56         {
57             var cur=json_options[idx];
58             fee_sheet_options.push(new fee_sheet_option(cur.code,cur.code_type,cur.description,cur.price));
59         }
60     return fee_sheet_options;
64 var view_model;
65 function initialize_review()
67     var review=add_review_button();
69     view_model=new fee_sheet_review_view_model();
70     view_model.displayReview=ko.observable(false);
71     get_fee_sheet_options('standard');
72     ko.applyBindings(view_model,review.get(0));
74 $(document).ready(initialize_review);