4 class C_InsuranceNumbers
extends Controller
{
8 var $insurance_numbers;
10 function __construct($template_mod = "general")
12 parent
::__construct();
13 $this->providers
= array();
14 $this->insurance_numbers
= array();
15 $this->template_mod
= $template_mod;
16 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
17 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_numbers&");
18 $this->assign("STYLE", $GLOBALS['style']);
19 $this->assign("WEB_ROOT", $GLOBALS['webroot'] );
22 function default_action()
24 return $this->list_action();
27 function edit_action($id = "",$provider_id="",$p_obj = null)
30 //case where a direct id is provided, doesn't matter if a provider id is available get it from the insurance_numbers record
31 if (get_class($this->insurance_numbers
[0]) != "insurancenumbers" && is_numeric($id) ) {
32 $this->insurance_numbers
[0] = new InsuranceNumbers($id);
33 $this->providers
[0] = new Provider($this->insurance_numbers
[0]->get_provider_id());
35 elseif (is_numeric($provider_id)) {
36 $this->providers
[0] = new Provider($provider_id);
37 if (get_class($this->insurance_numbers
[0]) != "insurancenumbers") {
38 if ($id == "default") {
39 $this->insurance_numbers
[0] = $this->providers
[0]->get_insurance_numbers_default();
40 if (!is_object($this->insurance_numbers
[0])) {
41 $this->insurance_numbers
[0] = new InsuranceNumbers();
42 $this->insurance_numbers
[0]->set_provider_id($provider_id);
46 $this->insurance_numbers
[0] = new InsuranceNumbers();
47 $this->insurance_numbers
[0]->set_provider_id($provider_id);
52 elseif (get_class($this->insurance_numbers
[0]) == "insurancenumbers") {
53 //this is the case that occurs after an update
54 $this->providers
[0] = new Provider($this->insurance_numbers
[0]->get_provider_id());
57 $this->insurance_numbers
[0] = new InsuranceNumbers();
58 $this->providers
[0] = new Provider();
59 $this->assign("ERROR","A provider must be specified. Check the link you you came from or the URL and try again.");
61 $ic = new InsuranceCompany();
62 $icompanies = $ic->insurance_companies_factory();
64 //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
65 //Those numbers are entered uder default
66 $ic_array = array("Default");
68 foreach ($icompanies as $ic_tmp) {
69 $ic_array[$ic_tmp->get_id()] = $ic_tmp->get_name();
72 $ic_type_options_array = array();
74 foreach ($this->insurance_numbers
[0]->provider_number_type_array
as $type => $type_title) {
75 $ic_type_options_array[$type] = "$type $type_title";
78 $ic_rendering_type_options_array = array();
80 foreach ($this->insurance_numbers
[0]->rendering_provider_number_type_array
as $type => $type_title) {
81 $ic_rendering_type_options_array[$type] = "$type $type_title";
84 $this->assign("ic_array", $ic_array);
85 $this->assign("ic_type_options_array", $ic_type_options_array);
86 $this->assign("ic_rendering_type_options_array", $ic_rendering_type_options_array);
88 $this->assign("provider", $this->providers
[0]);
89 $this->assign("ins", $this->insurance_numbers
[0]);
90 return $this->fetch($GLOBALS['template_dir'] . "insurance_numbers/" . $this->template_mod
. "_edit.html");
93 function list_action()
97 $this->assign("providers", $p->providers_factory());
98 return $this->fetch($GLOBALS['template_dir'] . "insurance_numbers/" . $this->template_mod
. "_list.html");
102 function edit_action_process()
104 if ($_POST['process'] != "true")
107 if (is_numeric($_POST['id'])) {
108 $this->insurance_numbers
[0] = new InsuranceNumbers($_POST['id']);
111 $this->insurance_numbers
[0] = new InsuranceNumbers();
114 parent
::populate_object($this->insurance_numbers
[0]);
116 $this->insurance_numbers
[0]->persist();
117 //insurance numbers need to be repopulated so that insurance_company_name recieves a value
118 $this->insurance_numbers
[0]->populate();
120 //echo "action processeed";
121 $_POST['process'] = "";
123 if (!is_numeric($_POST['id'])) {//Z&H
124 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_numbers&action=list");//Z&H