Fixes a missing arg for newPatient function
[openemr.git] / interface / patient_file / summary / demographics_save_dutch.php
blobcdcf9cdc9762f53092f73ff194f32b7a12e58132
1 <?
2 include_once("../../globals.php");
3 include_once("$srcdir/patient.inc");
4 include_once("$srcdir/acl.inc");
6 // Check authorization.
7 $thisauth = acl_check('patients', 'demo');
8 if ($pid) {
9 if ($thisauth != 'write')
10 die("Updating demographics is not authorized.");
11 $tmp = getPatientData($pid, "squad");
12 if ($tmp['squad'] && ! acl_check('squads', $tmp['squad']))
13 die("You are not authorized to access this squad.");
14 } else {
15 if ($thisauth != 'write' && $thisauth != 'addonly')
16 die("Adding demographics is not authorized.");
19 foreach ($_POST as $key => $val) {
20 if ($val == "MM/DD/YYYY") {
21 $_POST[$key] = "";
25 // prepare the sex value for the table
26 switch ( $_POST["df_sex"]) {
27 case 0: $var_sex = ''; break;
28 case 1: $var_sex = 'Male'; break;
29 case 2: $var_sex = 'Female'; break;
30 default: $var_sex = '';
33 // prepare the voice and email dropdown value
34 $dfvoice = ( $_POST['df_allowvoice'] ) ? xl('Yes') : xl('No');
35 $dfemail = ( $_POST['df_allowemail'] ) ? xl('Yes') : xl('No');
38 $provider_data = array (
39 'pro_referer' => $_POST['df_pcp_rfr'],
40 'pro_company' => $_POST['df_pcp_company'],
41 'pro_initials' => $_POST['df_pcp_initials'],
42 'pro_prefix' => $_POST['df_pcp_prefix'],
43 'pro_lname' => $_POST['df_pcp_lname'],
44 'pro_street' => $_POST['df_pcp_street'],
45 'pro_number' => $_POST['df_pcp_number'],
46 'pro_addition' => $_POST['df_pcp_addition'],
47 'pro_city' => $_POST['df_pcp_city'],
48 'pro_zipcode' => $_POST['df_pcp_zipcode'],
49 'pro_phone' => $_POST['df_pcp_phone'],
50 'pro_fax' => $_POST['df_pcp_fax'],
51 'pro_email' => $_POST['df_pcp_email']
53 if ( $_POST['df_pcp_rfr'] == '1' ) {
54 // the referer is the provider itself
55 $provider_data['pro_referer'] = 1;
56 } else {
57 $code = ( $_POST['df_rfr_type'] ) ? $_POST['df_rfr_type'] : $_POST['df_rfr_code'];
58 $referer_data = array(
59 'ref_code' => $code,
60 'ref_company' => $_POST['df_rfr_company'],
61 'ref_initials' => $_POST['df_rfr_initials'],
62 'ref_prefix' => $_POST['df_rfr_prefix'],
63 'ref_lname' => $_POST['df_rfr_lname'],
64 'ref_street' => $_POST['df_rfr_street'],
65 'ref_number' => $_POST['df_rfr_number'],
66 'ref_addition' => $_POST['df_rfr_addition'],
67 'ref_city' => $_POST['df_rfr_city'],
68 'ref_zipcode' => $_POST['df_rfr_zipcode'],
69 'ref_phone' => $_POST['df_rfr_phone'],
70 'ref_fax' => $_POST['df_rfr_fax'],
71 'ref_email' => $_POST['df_rfr_email']
75 // filtreat the variables
76 $obf = new Filtreatment();
77 foreach ( $provider_data as $pd => $pdv) {
78 $provider_data_clean[$pd] = $obf->ft_dbsql($pdv);
81 foreach ( $referer_data as $rf => $rfv) {
82 $referer_data_clean[$rf] = $obf->ft_dbsql($rfv);
85 $finrev = fixDate($_POST["financial_review"]);
87 $nstreet = ( isset($_POST['df_straat']) ) ? $_POST['df_straat'] : '' ;
88 $nnr = ( isset($_POST['df_nummer']) ) ? $_POST['df_nummer'] : '' ;
89 $nadd = ( isset($_POST['df_toevoe']) ) ? $_POST['df_toevoe'] : '' ;
91 $street = $nstreet .' '. $nnr .' '. $nadd;
93 $nstreet_clean = $obf->ft_dbsql($nstreet, 'SQL');
94 $nnr_clean = $obf->ft_integer($nnr);
95 $nadd_clean = $obf->ft_dbsql($nadd, 'SQL');
96 $street_clean = $obf->ft_dbsql($street);
98 $initials_clean = $obf->ft_dbsql($_POST['df_voorletters']);
99 $achternaam = $obf->ft_dbsql($_POST['df_achternaam']);
100 $roepnaam = $obf->ft_dbsql($_POST['df_roepnaam']);
101 $dob = $obf->ft_validdate($_POST['df_geboorte']);
103 $postal_clean = $obf->ft_dbsql($_POST['df_postal']);
104 $plaats_clean = $obf->ft_dbsql($_POST['df_plaats']);
106 $insurance_clean= (int)$_POST['df_insurance'];
107 $policy_clean = $obf->ft_dbsql($_POST['df_policy']);
108 $insdate_clean = $obf->ft_validdate($_POST['df_insdatum']);
110 // ================================================
111 // VALIDATION STUFF
113 $valid = TRUE;
115 // required fields
116 $valid = ( !empty($nstreet_clean) && !empty($nnr_clean) && !empty($initials_clean) && !empty($postal_clean) && !empty($plaats_clean));
118 if ( !$valid ) {
119 $_SESSION['errormsg'] = 'Eén of meer verplichte velden zijn niet ingevuld!<br />';
120 reload_form();
123 // date of birth validation
124 if ( !$dob ) {
125 $_SESSION['errormsg'] = 'Date must be in the form YYYY-MM-DD and must be a valid date!<br />';
126 reload_form();
129 // if we have an insurer, we must have also a policy number
130 // insurance = 1 means UNINSURED so we don't need the policy
131 if ( $insurance_clean ) {
132 if ( ($insurance_clean != 1) && (!$policy_clean) ) {
133 $_SESSION['errormsg'] = 'The policy number is mandatory for a choosen insurer!<br />';
135 if ( !$insdate_clean ) {
136 $_SESSION['errormsg'] .= 'Date must be in the form YYYY-MM-DD and must be a valid date!<br />';
138 if ( $_SESSION['errormsg'] ) reload_form();
141 // ================================================
143 // call the functions to save the infos
144 newPatientData(
145 $_SESSION['pid'],
146 '', // title
147 $roepnaam, // first name
148 $achternaam, // last name
149 '', // middle name
150 $var_sex,
151 $dob,
152 $street_clean, //initialy $_POST["street"], DBC Addition
153 $nstreet_clean,
154 $nnr_clean,
155 $nadd_clean, // EOS DBC
156 $postal_clean,
157 $plaats_clean,
158 '', // state
159 $_POST["df_land"],
160 $_POST["df_burgerservicenummer"],
161 '', //$_POST["occupation"],
162 $_POST["df_telh"],
163 $_POST["df_telw"],
164 $_POST["df_emtel"],
165 $_POST["df_huwe"],
166 $_POST["df_emcon"],
167 '', //$_POST["referrer"],
168 '', //$_POST["referrerID"],
169 $_POST["df_emailcon"],
170 strtolower($_POST["language"]),
171 '', //$_POST["ethnoracial"],
172 '', //$_POST["interpretter"],
173 '', //$_POST["migrantseasonal"],
174 '', //$_POST["family_size"],
175 '', //$_POST["monthly_income"],
176 '', //$_POST["homeless"],
177 '', //$finrev,
178 $pid, // pubpid is the same with the pid for us
179 $pid,
180 '', //$_POST["providerID"],
181 '', //$_POST["genericname1"],
182 '', //$_POST["genericval1"],
183 '', //$_POST["genericname2"],
184 '', //$_POST["genericval2"],
185 $_POST["df_telm"],
186 $dfemail,
187 $dfvoice,
188 '', //$_POST["squad"],
189 '', //$_POST["pharmacy_id"],
190 $_POST["df_licid"],
191 '', //$_POST["hipaa_notice"],
192 '', //$_POST["hipaa_message"],
193 $_POST["df_allowmsg"], // $regdate
194 $_POST["df_voorvoegsel"],
195 $_POST["df_par_voorvoegsel"],
196 $_POST["df_par_achternaam"],
197 $initials_clean,
198 $provider_data_clean,
199 $referer_data_clean
203 $i1dob = fixDate($_POST["i1subscriber_DOB"]);
205 // insurance stuff
206 if ( $insurance_clean ) {
207 set_insurer_nl($_SESSION['pid'], $insurance_clean, $insdate_clean, $policy_clean);
210 $i2dob = fixDate($_POST["i2subscriber_DOB"]);
212 if ($GLOBALS['concurrent_layout']) {
213 include_once("demographics.php");
214 } else {
215 include_once("patient_summary.php");
219 RELOAD THE FORM
222 function reload_form() {
223 header('location:demographics_full_dutch.php');