Integrating the problem list improvements with the recent fee sheet improvements...
[openemr.git] / interface / forms / fee_sheet / review / fee_sheet_justify.php
blobe3e36a6688a480ae90b79cba2aa9dc751523ce85
1 <?php
2 /**
3 * Controller for fee sheet justification AJAX requests
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
22 $fake_register_globals=false;
23 $sanitize_all_escapes=true;
25 require_once("../../../globals.php");
27 require_once("fee_sheet_queries.php");
28 include_once("$srcdir/jsonwrapper/jsonwrapper.php");
29 if(!acl_check('acct', 'bill'))
31 header("HTTP/1.0 403 Forbidden");
32 echo "Not authorized for billing";
33 return false;
37 if(isset($_REQUEST['pid']))
39 $req_pid=$_REQUEST['pid'];
42 if(isset($_REQUEST['encounter']))
44 $req_encounter=$_REQUEST['encounter'];
46 if(isset($_REQUEST['task']))
48 $task=$_REQUEST['task'];
50 if(isset($_REQUEST['billing_id']))
52 $billing_id=$_REQUEST['billing_id'];
54 if($task=='retrieve')
56 $retval=array();
57 $patient=issue_diagnoses($req_pid,$req_encounter);
58 $common=common_diagnoses();
59 $retval['patient']=$patient;
60 $retval['common']=$common;
61 $fee_sheet_diags=array();
62 $fee_sheet_procs=array();
63 fee_sheet_items($req_pid,$req_encounter,$fee_sheet_diags,$fee_sheet_procs);
64 $retval['current']=$fee_sheet_diags;
65 echo json_encode($retval);
66 return;
68 if($task=='update')
70 $skip_issues=false;
71 if(isset($_REQUEST['skip_issues']))
73 $skip_issues=$_REQUEST['skip_issues']=='true';
75 $diags=array();
76 if(isset($_REQUEST['diags']))
78 $json_diags=json_decode($_REQUEST['diags']);
80 foreach($json_diags as $diag)
82 $new_diag=new code_info($diag->{'code'},$diag->{'code_type'},$diag->{'description'});
83 if(isset($diag->{'prob_id'}))
85 $new_diag->db_id=$diag->{'prob_id'};
87 else
89 $new_diag->db_id=null;
90 $new_diag->create_problem=$diag->{'create_problem'};
92 $diags[]=$new_diag;
94 $database->StartTrans();
95 create_diags($req_pid,$req_encounter,$diags);
96 if(!$skip_issues)
98 update_issues($req_pid,$req_encounter,$diags);
100 update_justify($req_pid,$req_encounter,$diags,$billing_id);
101 $database->CompleteTrans();