3 use OpenEMR\Common\Twig\TwigContainer
;
4 use OpenEMR\Services\InsuranceCompanyService
;
6 class C_InsuranceCompany
extends Controller
10 var $InsuranceCompany;
12 public function __construct($template_mod = "general")
14 parent
::__construct();
15 $this->icompanies
= array();
16 $this->template_mod
= $template_mod;
17 $this->template_dir
= __DIR__
. "/templates/insurance_companies/";
18 $this->assign("FORM_ACTION", $GLOBALS['webroot'] . "/controller.php?" . attr($_SERVER['QUERY_STRING']));
19 $this->assign("CURRENT_ACTION", $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&insurance_company&");
20 $this->assign("STYLE", $GLOBALS['style']);
21 $this->assign("SUPPORT_ENCOUNTER_CLAIMS", $GLOBALS['support_encounter_claims']);
22 $this->assign("SUPPORT_ELIGIBILITY_REQUESTS", $GLOBALS['enable_eligibility_requests']);
23 $this->InsuranceCompany
= new InsuranceCompany();
26 public function default_action()
28 return $this->list_action();
31 public function edit_action($id = "", $patient_id = "", $p_obj = null)
33 if ($p_obj != null && get_class($p_obj) == "insurancecompany") {
34 $this->icompanies
[0] = $p_obj;
35 } elseif (empty($this->icompanies
[0]) ||
$this->icompanies
[0] == null ||
get_class($this->icompanies
[0]) != "insurancecompany") {
36 $this->icompanies
[0] = new InsuranceCompany($id);
39 $x = new X12Partner();
40 $this->assign("x12_partners", $x->_utility_array($x->x12_partner_factory()));
42 $this->assign("insurancecompany", $this->icompanies
[0]);
43 return $this->fetch($GLOBALS['template_dir'] . "insurance_companies/" . $this->template_mod
. "_edit.html");
46 public function list_action()
48 $twig = new TwigContainer(null, $GLOBALS['kernel']);
50 $insuranceCompanyService = new InsuranceCompanyService();
51 $results = $insuranceCompanyService->search([]);
53 if ($results->hasData()) {
54 foreach ($results->getData() as $record) {
56 'id' => $record['id'],
57 'name' => $record['name'],
58 'line1' => $record['line1'],
59 'line2' => $record['line2'],
60 'city' => $record['city'],
61 'state' => $record['state'],
62 'zip' => $record['zip'],
63 'phone' => $record['work_number'],
64 'fax' => $record['fax_number'],
65 'cms_id' => $record['cms_id'],
66 'x12_default_partner_name' => $record['x12_default_partner_name'],
67 'inactive' => $record['inactive']
69 $iCompanies[] = $company;
71 usort($iCompanies, function ($a, $b) {
72 return strcasecmp($a['name'], $b['name']);
76 'CURRENT_ACTION' => $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&insurance_company&"
77 ,'icompanies' => $iCompanies
80 return $twig->getTwig()->render('insurance_companies/general_list.html.twig', $templateVars);
84 public function edit_action_process()
86 if ($_POST['process'] != "true") {
90 if (is_numeric($_POST['id'])) {
91 $this->icompanies
[0] = new InsuranceCompany($_POST['id']);
93 $this->icompanies
[0] = new InsuranceCompany();
96 self
::populate_object($this->icompanies
[0]);
98 $this->icompanies
[0]->persist();
99 $this->icompanies
[0]->populate();
101 $_POST['process'] = "";
102 header('Location:' . $GLOBALS['webroot'] . "/controller.php?" . "practice_settings&insurance_company&action=list");//Z&H