Bug fix for provider Insurance Numbers
[openemr.git] / library / classes / Provider.class.php
bloba497188ed48cc1b3ab0a5bde05a6fc2f75b1d242
1 <?php
2 /************************************************************************
3 prescription.php - Copyright duhlman
5 /usr/share/apps/umbrello/headings/heading.php
7 This file was generated on %date% at %time%
8 The original location of this file is /home/duhlman/uml-generated-code/prescription.php
9 **************************************************************************/
11 require_once("ORDataObject.class.php");
12 require_once("InsuranceNumbers.class.php");
13 /**
14 * class Provider
17 class Provider extends ORDataObject{
19 var $id;
20 var $lname;
21 var $fname;
22 var $federal_drug_id;
23 var $insurance_numbers;
24 var $specialty;
25 var $npi;
26 var $state_license_number;
28 /**
29 * Constructor sets all Prescription attributes to their default value
31 function Provider ($id = "", $prefix = "") {
32 $this->id = $id;
33 $this->federal_drug_id = "";
34 $this->_table = "users";
35 $this-> npi = "";
36 $this->insurance_numbers = array();
37 $this->state_license_number = "";
38 if ($id != "") {
39 $this->populate();
43 function populate() {
44 $res = sqlQuery("SELECT fname,lname,federaldrugid, specialty, npi, state_license_number FROM users where id =". mysql_real_escape_string($this->id));
46 if (is_array($res)) {
47 $this->lname = $res['lname'];
48 $this->fname = $res['fname'];
49 $this->federal_drug_id = $res['federaldrugid'];
50 $this->specialty = $res['specialty'];
51 $this->npi = $res['npi'];
52 $this->state_license_number = $res['state_license_number'];
55 $ins = new InsuranceNumbers();
56 $this->insurance_numbers = $ins->insurance_numbers_factory($this->id);
59 function utility_provider_array() {
60 $provider_array = array();
61 $res = sqlQ("Select id,fname,lname from users where authorized = 1");
62 while ($row = mysql_fetch_array($res) ) {
63 $provider_array[$row['id']] = $row['fname'] . " " . $row['lname'];
65 return $provider_array;
68 function providers_factory($sort = "ORDER BY lname,fname") {
69 $psa = array();
70 $sql = "SELECT id FROM " . $this->_table . " where authorized = 1 " . $sort;
71 $results = sqlQ($sql);
73 while($row = mysql_fetch_array($results) ) {
74 $psa[] = new Provider($row['id']);
77 return $psa;
80 function get_id() {
81 return $this->id;
84 function get_name_display() {
85 return $this->fname . " " . $this->lname;
88 function get_specialty() {
89 return $this->specialty;
92 function get_provider_number_default() {
93 if (!empty($this->insurance_numbers)) {
94 return $this->insurance_numbers[0]->get_provider_number();
98 function get_rendering_provider_number_default() {
99 if (!empty($this->insurance_numbers)) {
100 return $this->insurance_numbers[0]->get_rendering_provider_number();
104 function get_insurance_numbers() {
105 return $this->insurance_numbers;
108 function get_insurance_numbers_default() {
109 return $this->insurance_numbers[0];
112 function get_group_number_default() {
113 if (!empty($this->insurance_numbers)) {
114 return $this->insurance_numbers[0]->get_group_number();
118 function get_npi() {
119 return $this->npi;
122 function get_state_license_number() {
123 return $this->state_license_number;
126 } // end of Provider