updated user manual wiki page link for future 4.1.2
[openemr.git] / controllers / C_InsuranceNumbers.class.php
blob202978febbb730909b947da1a88e0dcaa3a30846
1 <?php
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 {
9 var $template_mod;
10 var $providers;
11 var $insurance_numbers;
13 function C_InsuranceNumbers($template_mod = "general") {
14 parent::Controller();
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']);
21 $this->assign("WEB_ROOT", $GLOBALS['webroot'] );
24 function default_action() {
25 return $this->list_action();
28 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);
45 else {
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());
56 else {
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() {
95 $p = new Provider();
96 $this->assign("providers", $p->providers_factory());
97 return $this->fetch($GLOBALS['template_dir'] . "insurance_numbers/" . $this->template_mod . "_list.html");
101 function edit_action_process() {
102 if ($_POST['process'] != "true")
103 return;
104 //print_r($_POST);
105 if (is_numeric($_POST['id'])) {
106 $this->insurance_numbers[0] = new InsuranceNumbers($_POST['id']);
108 else {
109 $this->insurance_numbers[0] = new InsuranceNumbers();
112 parent::populate_object($this->insurance_numbers[0]);
114 $this->insurance_numbers[0]->persist();
115 //insurance numbers need to be repopulated so that insurance_company_name recieves a value
116 $this->insurance_numbers[0]->populate();
118 //echo "action processeed";
119 $_POST['process'] = "";
121 if (!is_numeric($_POST['id'])) {//Z&H
122 header('Location:'.$GLOBALS['webroot']."/controller.php?" . "practice_settings&insurance_numbers&action=list");//Z&H
123 }//Z&H