Added a new billing widget and following related changes:
[openemr.git] / interface / patient_file / summary / demographics_save.php
bloba9027e54015aa4de432054f0d647e97cfff535ef
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/patient.inc");
4 include_once("$srcdir/acl.inc");
5 include_once("$srcdir/options.inc.php");
6 include_once("$srcdir/formdata.inc.php");
8 // Check authorization.
9 $thisauth = acl_check('patients', 'demo');
10 if ($pid) {
11 if ($thisauth != 'write')
12 die(xl('Updating demographics is not authorized.'));
13 $tmp = getPatientData($pid, "squad");
14 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
15 die(xl('You are not authorized to access this squad.'));
16 } else {
17 if ($thisauth != 'write' && $thisauth != 'addonly')
18 die(xl('Adding demographics is not authorized.'));
21 foreach ($_POST as $key => $val) {
22 if ($val == "MM/DD/YYYY") {
23 $_POST[$key] = "";
27 // Update patient_data and employer_data:
29 $newdata = array();
30 $newdata['patient_data']['id'] = $_POST['db_id'];
31 $fres = sqlStatement("SELECT * FROM layout_options " .
32 "WHERE form_id = 'DEM' AND uor > 0 AND field_id != '' " .
33 "ORDER BY group_name, seq");
34 while ($frow = sqlFetchArray($fres)) {
35 $data_type = $frow['data_type'];
36 $field_id = $frow['field_id'];
37 // $value = '';
38 $colname = $field_id;
39 $table = 'patient_data';
40 if (strpos($field_id, 'em_') === 0) {
41 $colname = substr($field_id, 3);
42 $table = 'employer_data';
45 // if (isset($_POST["form_$field_id"])) $value = $_POST["form_$field_id"];
46 $value = get_layout_form_value($frow);
48 $newdata[$table][$colname] = $value;
50 updatePatientData($pid, $newdata['patient_data']);
51 updateEmployerData($pid, $newdata['employer_data']);
53 $i1dob = fixDate(formData("i1subscriber_DOB"));
54 $i1date = fixDate(formData("i1effective_date"), date('Y-m-d'));
56 newInsuranceData(
57 $pid,
58 "primary",
59 formData("i1provider"),
60 formData("i1policy_number"),
61 formData("i1group_number"),
62 formData("i1plan_name"),
63 formData("i1subscriber_lname"),
64 formData("i1subscriber_mname"),
65 formData("i1subscriber_fname"),
66 formData("form_i1subscriber_relationship"),
67 formData("i1subscriber_ss"),
68 $i1dob,
69 formData("i1subscriber_street"),
70 formData("i1subscriber_postal_code"),
71 formData("i1subscriber_city"),
72 formData("form_i1subscriber_state"),
73 formData("form_i1subscriber_country"),
74 formData("i1subscriber_phone"),
75 formData("i1subscriber_employer"),
76 formData("i1subscriber_employer_street"),
77 formData("i1subscriber_employer_city"),
78 formData("i1subscriber_employer_postal_code"),
79 formData("form_i1subscriber_employer_state"),
80 formData("form_i1subscriber_employer_country"),
81 formData('i1copay'),
82 formData('form_i1subscriber_sex'),
83 $i1date,
84 formData('i1accept_assignment')
87 $i2dob = fixDate(formData("i2subscriber_DOB"));
88 $i2date = fixDate(formData("i2effective_date"), date('Y-m-d'));
90 newInsuranceData(
91 $pid,
92 "secondary",
93 formData("i2provider"),
94 formData("i2policy_number"),
95 formData("i2group_number"),
96 formData("i2plan_name"),
97 formData("i2subscriber_lname"),
98 formData("i2subscriber_mname"),
99 formData("i2subscriber_fname"),
100 formData("form_i2subscriber_relationship"),
101 formData("i2subscriber_ss"),
102 $i2dob,
103 formData("i2subscriber_street"),
104 formData("i2subscriber_postal_code"),
105 formData("i2subscriber_city"),
106 formData("form_i2subscriber_state"),
107 formData("form_i2subscriber_country"),
108 formData("i2subscriber_phone"),
109 formData("i2subscriber_employer"),
110 formData("i2subscriber_employer_street"),
111 formData("i2subscriber_employer_city"),
112 formData("i2subscriber_employer_postal_code"),
113 formData("form_i2subscriber_employer_state"),
114 formData("form_i2subscriber_employer_country"),
115 formData('i2copay'),
116 formData('form_i2subscriber_sex'),
117 $i2date,
118 formData('i2accept_assignment')
121 $i3dob = fixDate(formData("i3subscriber_DOB"));
122 $i3date = fixDate(formData("i3effective_date"), date('Y-m-d'));
124 newInsuranceData(
125 $pid,
126 "tertiary",
127 formData("i3provider"),
128 formData("i3policy_number"),
129 formData("i3group_number"),
130 formData("i3plan_name"),
131 formData("i3subscriber_lname"),
132 formData("i3subscriber_mname"),
133 formData("i3subscriber_fname"),
134 formData("form_i3subscriber_relationship"),
135 formData("i3subscriber_ss"),
136 $i3dob,
137 formData("i3subscriber_street"),
138 formData("i3subscriber_postal_code"),
139 formData("i3subscriber_city"),
140 formData("form_i3subscriber_state"),
141 formData("form_i3subscriber_country"),
142 formData("i3subscriber_phone"),
143 formData("i3subscriber_employer"),
144 formData("i3subscriber_employer_street"),
145 formData("i3subscriber_employer_city"),
146 formData("i3subscriber_employer_postal_code"),
147 formData("form_i3subscriber_employer_state"),
148 formData("form_i3subscriber_employer_country"),
149 formData('i3copay'),
150 formData('form_i3subscriber_sex'),
151 $i3date,
152 formData('i3accept_assignment')
155 if ($GLOBALS['concurrent_layout']) {
156 include_once("demographics.php");
157 } else {
158 include_once("patient_summary.php");