3 require_once ($GLOBALS['fileroot'] . "/library/classes/Controller.class.php");
4 require_once($GLOBALS['fileroot'] ."/library/classes/Provider.class.php");
5 require_once($GLOBALS['fileroot'] ."/library/classes/InsuranceNumbers.class.php");
7 class C_InsuranceNumbers
extends Controller
{
11 var $insurance_numbers;
13 function C_InsuranceNumbers($template_mod = "general") {
15 $this->providers
= array();
16 $this->insurance_numbers
= array();
17 $this->template_mod
= $template_mod;
18 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
19 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_numbers&");
20 $this->assign("STYLE", $GLOBALS['style']);
23 function default_action() {
24 return $this->list_action();
27 function edit_action($id = "",$provider_id="",$p_obj = null) {
29 //case where a direct id is provided, doesn't matter if a provider id is available get it from the insurance_numbers record
30 if (get_class($this->insurance_numbers
[0]) != "insurancenumbers" && is_numeric($id) ) {
31 $this->insurance_numbers
[0] = new InsuranceNumbers($id);
32 $this->providers
[0] = new Provider($this->insurance_numbers
[0]->get_provider_id());
34 elseif (is_numeric($provider_id)) {
35 $this->providers
[0] = new Provider($provider_id);
36 if (get_class($this->insurance_numbers
[0]) != "insurancenumbers") {
37 if ($id == "default") {
38 $this->insurance_numbers
[0] = $this->providers
[0]->get_insurance_numbers_default();
39 if (!is_object($this->insurance_numbers
[0])) {
40 $this->insurance_numbers
[0] = new InsuranceNumbers();
41 $this->insurance_numbers
[0]->set_provider_id($provider_id);
45 $this->insurance_numbers
[0] = new InsuranceNumbers();
46 $this->insurance_numbers
[0]->set_provider_id($provider_id);
51 elseif (get_class($this->insurance_numbers
[0]) == "insurancenumbers") {
52 //this is the case that occurs after an update
53 $this->providers
[0] = new Provider($this->insurance_numbers
[0]->get_provider_id());
56 $this->insurance_numbers
[0] = new InsuranceNumbers();
57 $this->providers
[0] = new Provider();
58 $this->assign("ERROR","A provider must be specified. Check the link you you came from or the URL and try again.");
60 $ic = new InsuranceCompany();
61 $icompanies = $ic->insurance_companies_factory();
63 //It is possible to set a group and provider number to be used in the event that there is not direct hit on the insurance-provider lookup
64 //Those numbers are entered uder default
65 $ic_array = array("Default");
67 foreach ($icompanies as $ic_tmp) {
68 $ic_array[$ic_tmp->get_id()] = $ic_tmp->get_name();
71 $ic_type_options_array = array();
73 foreach ($this->insurance_numbers
[0]->provider_number_type_array
as $type => $type_title) {
74 $ic_type_options_array[$type] = "$type $type_title";
77 $ic_rendering_type_options_array = array();
79 foreach ($this->insurance_numbers
[0]->rendering_provider_number_type_array
as $type => $type_title) {
80 $ic_rendering_type_options_array[$type] = "$type $type_title";
83 $this->assign("ic_array", $ic_array);
84 $this->assign("ic_type_options_array", $ic_type_options_array);
85 $this->assign("ic_rendering_type_options_array", $ic_rendering_type_options_array);
87 $this->assign("provider", $this->providers
[0]);
88 $this->assign("ins", $this->insurance_numbers
[0]);
89 return $this->fetch($GLOBALS['template_dir'] . "insurance_numbers/" . $this->template_mod
. "_edit.html");
92 function list_action() {
95 $this->assign("providers", $p->providers_factory());
96 return $this->fetch($GLOBALS['template_dir'] . "insurance_numbers/" . $this->template_mod
. "_list.html");
100 function edit_action_process() {
101 if ($_POST['process'] != "true")
104 if (is_numeric($_POST['id'])) {
105 $this->insurance_numbers
[0] = new InsuranceNumbers($_POST['id']);
108 $this->insurance_numbers
[0] = new InsuranceNumbers();
111 parent
::populate_object($this->insurance_numbers
[0]);
113 $this->insurance_numbers
[0]->persist();
114 //insurance numbers need to be repopulated so that insurance_company_name recieves a value
115 $this->insurance_numbers
[0]->populate();
117 //echo "action processeed";
118 $_POST['process'] = "";