2 include_once("../../globals.php");
3 include_once("$srcdir/patient.inc");
4 include_once("$srcdir/acl.inc");
5 include_once("$srcdir/options.inc.php");
7 // Check authorization.
9 if (!acl_check('patients', 'demo', '', 'write')) {
10 die(xlt('Updating demographics is not authorized.'));
13 $tmp = getPatientData($pid, "squad");
14 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad'])) {
15 die(xlt('You are not authorized to access this squad.'));
18 if (!acl_check('patients', 'demo', '', array('write','addonly'))) {
19 die(xlt('Adding demographics is not authorized.'));
23 foreach ($_POST as $key => $val) {
24 if ($val == "MM/DD/YYYY") {
29 // Update patient_data and employer_data:
32 $newdata['patient_data']['id'] = $_POST['db_id'];
33 $fres = sqlStatement("SELECT * FROM layout_options " .
34 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
35 "ORDER BY group_name, seq");
36 while ($frow = sqlFetchArray($fres)) {
37 $data_type = $frow['data_type'];
38 $field_id = $frow['field_id'];
41 $table = 'patient_data';
42 if (strpos($field_id, 'em_') === 0) {
43 $colname = substr($field_id, 3);
44 $table = 'employer_data';
47 //get value only if field exist in $_POST (prevent deleting of field with disabled attribute)
48 if (isset($_POST["form_$field_id"])) {
49 $newdata[$table][$colname] = get_layout_form_value($frow);
53 updatePatientData($pid, $newdata['patient_data']);
54 updateEmployerData($pid, $newdata['employer_data']);
56 $i1dob = fixDate(filter_input(INPUT_POST
, "i1subscriber_DOB"));
57 $i1date = fixDate(filter_input(INPUT_POST
, "i1effective_date"), date('Y-m-d'));
62 filter_input(INPUT_POST
, "i1provider"),
63 filter_input(INPUT_POST
, "i1policy_number"),
64 filter_input(INPUT_POST
, "i1group_number"),
65 filter_input(INPUT_POST
, "i1plan_name"),
66 filter_input(INPUT_POST
, "i1subscriber_lname"),
67 filter_input(INPUT_POST
, "i1subscriber_mname"),
68 filter_input(INPUT_POST
, "i1subscriber_fname"),
69 filter_input(INPUT_POST
, "form_i1subscriber_relationship"),
70 filter_input(INPUT_POST
, "i1subscriber_ss"),
72 filter_input(INPUT_POST
, "i1subscriber_street"),
73 filter_input(INPUT_POST
, "i1subscriber_postal_code"),
74 filter_input(INPUT_POST
, "i1subscriber_city"),
75 filter_input(INPUT_POST
, "form_i1subscriber_state"),
76 filter_input(INPUT_POST
, "form_i1subscriber_country"),
77 filter_input(INPUT_POST
, "i1subscriber_phone"),
78 filter_input(INPUT_POST
, "i1subscriber_employer"),
79 filter_input(INPUT_POST
, "i1subscriber_employer_street"),
80 filter_input(INPUT_POST
, "i1subscriber_employer_city"),
81 filter_input(INPUT_POST
, "i1subscriber_employer_postal_code"),
82 filter_input(INPUT_POST
, "form_i1subscriber_employer_state"),
83 filter_input(INPUT_POST
, "form_i1subscriber_employer_country"),
84 filter_input(INPUT_POST
, 'i1copay'),
85 filter_input(INPUT_POST
, 'form_i1subscriber_sex'),
87 filter_input(INPUT_POST
, 'i1accept_assignment'),
88 filter_input(INPUT_POST
, 'i1policy_type')
91 $i2dob = fixDate(filter_input(INPUT_POST
, "i2subscriber_DOB"));
92 $i2date = fixDate(filter_input(INPUT_POST
, "i2effective_date"), date('Y-m-d'));
97 filter_input(INPUT_POST
, "i2provider"),
98 filter_input(INPUT_POST
, "i2policy_number"),
99 filter_input(INPUT_POST
, "i2group_number"),
100 filter_input(INPUT_POST
, "i2plan_name"),
101 filter_input(INPUT_POST
, "i2subscriber_lname"),
102 filter_input(INPUT_POST
, "i2subscriber_mname"),
103 filter_input(INPUT_POST
, "i2subscriber_fname"),
104 filter_input(INPUT_POST
, "form_i2subscriber_relationship"),
105 filter_input(INPUT_POST
, "i2subscriber_ss"),
107 filter_input(INPUT_POST
, "i2subscriber_street"),
108 filter_input(INPUT_POST
, "i2subscriber_postal_code"),
109 filter_input(INPUT_POST
, "i2subscriber_city"),
110 filter_input(INPUT_POST
, "form_i2subscriber_state"),
111 filter_input(INPUT_POST
, "form_i2subscriber_country"),
112 filter_input(INPUT_POST
, "i2subscriber_phone"),
113 filter_input(INPUT_POST
, "i2subscriber_employer"),
114 filter_input(INPUT_POST
, "i2subscriber_employer_street"),
115 filter_input(INPUT_POST
, "i2subscriber_employer_city"),
116 filter_input(INPUT_POST
, "i2subscriber_employer_postal_code"),
117 filter_input(INPUT_POST
, "form_i2subscriber_employer_state"),
118 filter_input(INPUT_POST
, "form_i2subscriber_employer_country"),
119 filter_input(INPUT_POST
, 'i2copay'),
120 filter_input(INPUT_POST
, 'form_i2subscriber_sex'),
122 filter_input(INPUT_POST
, 'i2accept_assignment'),
123 filter_input(INPUT_POST
, 'i2policy_type')
126 $i3dob = fixDate(filter_input(INPUT_POST
, "i3subscriber_DOB"));
127 $i3date = fixDate(filter_input(INPUT_POST
, "i3effective_date"), date('Y-m-d'));
132 filter_input(INPUT_POST
, "i3provider"),
133 filter_input(INPUT_POST
, "i3policy_number"),
134 filter_input(INPUT_POST
, "i3group_number"),
135 filter_input(INPUT_POST
, "i3plan_name"),
136 filter_input(INPUT_POST
, "i3subscriber_lname"),
137 filter_input(INPUT_POST
, "i3subscriber_mname"),
138 filter_input(INPUT_POST
, "i3subscriber_fname"),
139 filter_input(INPUT_POST
, "form_i3subscriber_relationship"),
140 filter_input(INPUT_POST
, "i3subscriber_ss"),
142 filter_input(INPUT_POST
, "i3subscriber_street"),
143 filter_input(INPUT_POST
, "i3subscriber_postal_code"),
144 filter_input(INPUT_POST
, "i3subscriber_city"),
145 filter_input(INPUT_POST
, "form_i3subscriber_state"),
146 filter_input(INPUT_POST
, "form_i3subscriber_country"),
147 filter_input(INPUT_POST
, "i3subscriber_phone"),
148 filter_input(INPUT_POST
, "i3subscriber_employer"),
149 filter_input(INPUT_POST
, "i3subscriber_employer_street"),
150 filter_input(INPUT_POST
, "i3subscriber_employer_city"),
151 filter_input(INPUT_POST
, "i3subscriber_employer_postal_code"),
152 filter_input(INPUT_POST
, "form_i3subscriber_employer_state"),
153 filter_input(INPUT_POST
, "form_i3subscriber_employer_country"),
154 filter_input(INPUT_POST
, 'i3copay'),
155 filter_input(INPUT_POST
, 'form_i3subscriber_sex'),
157 filter_input(INPUT_POST
, 'i3accept_assignment'),
158 filter_input(INPUT_POST
, 'i3policy_type')
161 include_once("demographics.php");