Fee sheet enhancements
[openemr.git] / interface / forms / fee_sheet / review / fee_sheet_options_queries.php
blob454bea05e70685bb92c5ecd00e12137a5f6cfa84
1 <?php
2 /**
3 * Utility functions for retrieving fee sheet options.
4 *
5 * Copyright (C) 2013 Kevin Yeh <kevin.y@integralemr.com> and OEMR <www.oemr.org>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @package OpenEMR
19 * @author Kevin Yeh <kevin.y@integralemr.com>
20 * @link http://www.open-emr.org
24 /**
25 * Object representing the code,description and price for a fee sheet option
26 * (typically a procedure code).
28 class fee_sheet_option
30 function __construct($c,$ct,$desc,$price,$category)
32 $this->code=$c;
33 $this->code_type=$ct;
34 $this->description=$desc;
35 $this->price=$price;
36 $this->category=$category;
37 if($price==null)
39 $this->price=xl("Not Specified");
42 public $code;
43 public $code_type;
44 public $description;
45 public $price;
46 public $fee_display;
47 public $category;
50 /**
51 * get a list of fee sheet options
53 * @param string $pricelevel which pricing level to retrieve
54 * @return an array containing the options
56 function load_fee_sheet_options($pricelevel)
58 $clFSO_code_type='substring_index(fso.fs_codes,"|",1)';
59 $clFSO_code='replace(substring_index(fso.fs_codes,"|",-2),"|","")';
61 $sql= "SELECT codes.code,code_types.ct_key as code_type,codes.code_text,pr_price,fso.fs_category"
62 . " FROM fee_sheet_options as fso, code_types "
63 . " ,codes LEFT JOIN prices ON (codes.id=prices.pr_id AND prices.pr_level=?)"
64 . " WHERE codes.code=".$clFSO_code
65 . " AND code_types.ct_key=".$clFSO_code_type
66 . " AND codes.code_type=code_types.ct_id"
67 . " ORDER BY fso.fs_category,fso.fs_option";
69 $results=sqlStatement($sql,array($pricelevel));
71 $retval=array();
72 while($res=sqlFetchArray($results))
74 $fso=new fee_sheet_option($res['code'],$res['code_type'],$res['code_text'],$res['pr_price'],$res['fs_category']);
75 $retval[]=$fso;
78 return $retval;