simplify decrypt to return blank value when a empty value is sent (#2115)
[openemr.git] / interface / new / new.php
blob9ccecdf1ea065143f8a30e238d0ee5d0c0907566
1 <?php
2 /**
3 * new.php
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
15 if ($GLOBALS['full_new_patient_form']) {
16 require("new_comprehensive.php");
17 exit;
20 // For a layout field return 0=unused, 1=optional, 2=mandatory.
21 function getLayoutUOR($form_id, $field_id)
23 $crow = sqlQuery("SELECT uor FROM layout_options WHERE " .
24 "form_id = ? AND field_id = ? LIMIT 1", array($form_id, $field_id));
25 return 0 + $crow['uor'];
28 // Determine if the registration date should be requested.
29 $regstyle = getLayoutUOR('DEM', 'regdate') ? "" : " style='display:none'";
31 $form_pubpid = $_POST['pubpid' ] ? trim($_POST['pubpid' ]) : '';
32 $form_title = $_POST['title' ] ? trim($_POST['title' ]) : '';
33 $form_fname = $_POST['fname' ] ? trim($_POST['fname' ]) : '';
34 $form_mname = $_POST['mname' ] ? trim($_POST['mname' ]) : '';
35 $form_lname = $_POST['lname' ] ? trim($_POST['lname' ]) : '';
36 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
37 $form_sex = $_POST['sex' ] ? trim($_POST['sex' ]) : '';
38 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
39 $form_dob = $_POST['DOB' ] ? trim($_POST['DOB' ]) : '';
40 $form_regdate = $_POST['regdate' ] ? trim($_POST['regdate' ]) : date('Y-m-d');
42 <html>
44 <head>
45 <?php html_header_show(); ?>
46 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
47 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.min.css">
49 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
50 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script>
51 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
53 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
55 <script LANGUAGE="JavaScript">
57 function validate() {
58 var f = document.forms[0];
59 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
60 if (f.refsource.selectedIndex <= 0) {
61 alert('Please select a referral source!');
62 return false;
64 <?php } ?>
65 <?php if (getLayoutUOR('DEM', 'sex') == 2) { ?>
66 if (f.sex.selectedIndex <= 0) {
67 alert('Please select a value for sex!');
68 return false;
70 <?php } ?>
71 <?php if (getLayoutUOR('DEM', 'DOB') == 2) { ?>
72 if (f.DOB.value.length == 0) {
73 alert('Please select a birth date!');
74 return false;
76 <?php } ?>
77 top.restoreSession();
78 return true;
81 $(document).ready(function(){
82 $('.datepicker').datetimepicker({
83 <?php $datetimepicker_timepicker = false; ?>
84 <?php $datetimepicker_showseconds = false; ?>
85 <?php $datetimepicker_formatInput = true; ?>
86 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
87 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
88 });
89 $('.datetimepicker').datetimepicker({
90 <?php $datetimepicker_timepicker = true; ?>
91 <?php $datetimepicker_showseconds = false; ?>
92 <?php $datetimepicker_formatInput = true; ?>
93 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
94 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
95 });
96 });
98 </script>
100 </head>
102 <body class="body_top" onload="javascript:document.new_patient.fname.focus();">
104 <form name='new_patient' method='post' action="new_patient_save.php"
105 onsubmit='return validate()'>
106 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
108 <span class='title'><?php echo xlt('Add Patient Record'); ?></span>
110 <br><br>
112 <center>
114 <?php if ($GLOBALS['omit_employers']) { ?>
115 <input type='hidden' name='title' value='' />
116 <?php } ?>
118 <table border='0'>
120 <?php if (!$GLOBALS['omit_employers']) { ?>
121 <tr>
122 <td>
123 <span class='bold'><?php echo xlt('Title'); ?>: </span>
124 </td>
125 <td>
126 <select name='title'>
127 <?php
128 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
129 "WHERE list_id = 'titles' AND activity = 1 ORDER BY seq");
130 while ($orow = sqlFetchArray($ores)) {
131 echo " <option value='" . attr($orow['option_id']) . "'";
132 if ($orow['option_id'] == $form_title) {
133 echo " selected";
136 echo ">" . text($orow['title']) . "</option>\n";
139 </select>
140 </td>
141 </tr>
142 <?php } ?>
144 <tr>
145 <td>
146 <span class='bold'><?php echo xlt('First Name'); ?>: </span>
147 </td>
148 <td>
149 <input type='entry' size='15' name='fname' value='<?php echo attr($form_fname); ?>'>
150 </td>
151 </tr>
153 <tr>
154 <td>
155 <span class='bold'><?php echo xlt('Middle Name'); ?>: </span>
156 </td>
157 <td>
158 <input type='entry' size='15' name='mname' value='<?php echo attr($form_mname); ?>'>
159 </td>
160 </tr>
162 <tr>
163 <td>
164 <span class='bold'><?php echo xlt('Last Name'); ?>: </span>
165 </td>
166 <td>
167 <input type='entry' size='15' name='lname' value='<?php echo attr($form_lname); ?>'>
168 </td>
169 </tr>
171 <tr>
172 <td>
173 <span class='bold'><?php echo xlt('Sex'); ?>: </span>
174 </td>
175 <td>
176 <select name='sex'>
177 <option value=''>Unassigned</option>
178 <?php
179 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
180 "WHERE list_id = 'sex' AND activity = 1 ORDER BY seq");
181 while ($orow = sqlFetchArray($ores)) {
182 echo " <option value='" . attr($orow['option_id']) . "'";
183 if ($orow['option_id'] == $form_sex) {
184 echo " selected";
187 echo ">" . text($orow['title']) . "</option>\n";
190 </select>
191 </td>
192 </tr>
194 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
195 <tr>
196 <td>
197 <span class='bold'><?php echo xlt('Referral Source'); ?>: </span>
198 </td>
199 <td>
200 <select name='refsource'>
201 <option value=''>Unassigned</option>
202 <?php
203 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
204 "WHERE list_id = 'refsource' AND activity = 1 ORDER BY seq");
205 while ($orow = sqlFetchArray($ores)) {
206 echo " <option value='" . attr($orow['option_id']) . "'";
207 if ($orow['option_id'] == $form_refsource) {
208 echo " selected";
211 echo ">" . text($orow['title']) . "</option>\n";
214 </select>
215 </td>
216 </tr>
217 <?php } ?>
219 <tr>
220 <td>
221 <span class='bold'><?php echo xlt('Birth Date'); ?>: </span>
222 </td>
223 <td>
224 <input type='text' size='10' class='datepicker' name='DOB' id='DOB'
225 value='<?php echo attr($form_dob); ?>' />
226 </td>
227 </tr>
229 <tr<?php echo $regstyle ?>>
230 <td>
231 <span class='bold'><?php echo xlt('Registration Date'); ?>: </span>
232 </td>
233 <td>
234 <input type='text' size='10' class='datepicker' name='regdate' id='regdate'
235 value='<?php echo attr($form_regdate); ?>' />
236 </td>
237 </tr>
239 <tr>
240 <td>
241 <span class='bold'><?php echo xlt('Patient Number'); ?>: </span>
242 </td>
243 <td>
244 <input type='entry' size='5' name='pubpid' value='<?php echo attr($form_pubpid); ?>'>
245 <span class='text'><?php echo xlt('omit to autoassign'); ?> &nbsp; &nbsp; </span>
246 </td>
247 </tr>
249 <tr>
250 <td colspan='2'>
251 &nbsp;<br>
252 <input type='submit' name='form_create' value='<?php echo xla('Create New Patient'); ?>' />
253 </td>
254 <td>
255 </td>
256 </tr>
258 </table>
259 </center>
260 </form>
261 <script language="Javascript">
262 <?php
263 if ($form_pubpid) {
264 echo "alert(" . xlj('This patient ID is already in use!') . ");\n";
267 </script>
269 </body>
270 </html>