Interim autoloaded library/classes via composer classmap, take 4. (#422)
[openemr.git] / library / classes / Address.class.php
blobb60174e7cbb1d62b2cdeced125e011aa8c4df0c6
1 <?php
2 /************************************************************************
3 address.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 /**
12 * class Address
15 class Address extends ORDataObject{
16 var $id;
17 var $foreign_id;
18 var $line1;
19 var $line2;
20 var $city;
21 var $state;
22 var $zip;
23 var $plus_four;
24 var $country;
26 /**
27 * Constructor sets all Address attributes to their default value
29 function __construct($id = "", $foreign_id = "") {
30 $this->id = $id;
31 $this->foreign_id = $foreign_id;
32 $this->_table = "addresses";
33 $this->line1 = "";
34 $this->line2 = "";
35 $this->city = "";
36 $this->state = "";
37 $this->zip = "";
38 $this->plus_four = "";
39 $this->country = "USA";
40 if ($id != "") {
41 $this->populate();
46 static function factory_address($foreign_id = "") {
47 if (empty($foreign_id)) {
48 $foreign_id= "like '%'";
50 else {
51 $foreign_id= " = '" . add_escape_custom(strval($foreign_id)) . "'";
53 $a = new Address();
54 $sql = "SELECT id FROM " . $a->_table . " WHERE foreign_id " .$foreign_id ;
55 //echo $sql . "<bR />";
56 $results = sqlQ($sql);
57 //echo "sql: $sql";
58 $row = sqlFetchArray($results);
59 if (!empty($row)) {
60 $a = new Address($row['id']);
63 return $a;
66 function toString($html = false) {
67 $string .= "\n"
68 . "ID: " . $this->id."\n"
69 . "FID: " . $this->foreign_id."\n"
70 .$this->line1 . "\n"
71 .$this->line2 . "\n"
72 .$this->city . ", " . strtoupper($this->state) . " " . $this->zip . "-" . $this->plus_four. "\n"
73 .$this->country. "\n";
75 if ($html) {
76 return nl2br($string);
78 else {
79 return $string;
83 function set_id($id) {
84 $this->id = $id;
86 function get_id() {
87 return $this->id;
89 function set_foreign_id($fid) {
90 $this->foreign_id = $fid;
92 function get_foreign_id() {
93 return $this->foreign_id;
95 function set_line1($line1) {
96 $this->line1 = $line1;
98 function get_line1() {
99 return $this->line1;
101 function set_line2($line2) {
102 $this->line2 = $line2;
104 function get_line2() {
105 return $this->line2;
107 function get_lines_display() {
108 $string .= $this->get_line1();
109 $string .= " " . $this->get_line2();
110 return $string;
112 function set_city($city) {
113 $this->city = $city;
115 function get_city() {
116 return $this->city;
118 function set_state($state) {
119 $this->state = strtoupper($state);
121 function get_state() {
122 return $this->state;
124 function set_zip($zip) {
125 $this->zip = $zip;
127 function get_zip() {
128 return $this->zip;
130 function set_plus_four($plus_four) {
131 $this->plus_four = $plus_four;
133 function get_plus_four() {
134 return $this->plus_four;
136 function set_country($country) {
137 $this->country = $country;
139 function get_country() {
140 return $this->country;
142 function persist($fid ="") {
143 if (!empty($fid)) {
144 $this->foreign_id = $fid;
146 parent::persist();
149 } // end of Address
151 $a = new Address("0");
153 echo $a->toString(true);*/