Some change to prior PR#7429 (#7447)
[openemr.git] / interface / new / new.php
blob6895902684e696b648718a7de0e08a34a079ce19
1 <?php
3 /**
4 * new.php
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
15 use OpenEMR\Common\Csrf\CsrfUtils;
16 use OpenEMR\Core\Header;
18 if ($GLOBALS['full_new_patient_form']) {
19 require("new_comprehensive.php");
20 exit;
23 // For a layout field return 0=unused, 1=optional, 2=mandatory.
24 function getLayoutUOR($form_id, $field_id)
26 $crow = sqlQuery("SELECT uor FROM layout_options WHERE " .
27 "form_id = ? AND field_id = ? LIMIT 1", array($form_id, $field_id));
28 return 0 + $crow['uor'];
31 // Determine if the registration date should be requested.
32 $regstyle = getLayoutUOR('DEM', 'regdate') ? "" : " style='display:none'";
34 $form_pubpid = $_POST['pubpid' ] ? trim($_POST['pubpid' ]) : '';
35 $form_title = $_POST['title' ] ? trim($_POST['title' ]) : '';
36 $form_fname = $_POST['fname' ] ? trim($_POST['fname' ]) : '';
37 $form_mname = $_POST['mname' ] ? trim($_POST['mname' ]) : '';
38 $form_lname = $_POST['lname' ] ? trim($_POST['lname' ]) : '';
39 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
40 $form_sex = $_POST['sex' ] ? trim($_POST['sex' ]) : '';
41 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
42 $form_dob = $_POST['DOB' ] ? trim($_POST['DOB' ]) : '';
43 $form_regdate = $_POST['regdate' ] ? trim($_POST['regdate' ]) : date('Y-m-d');
45 <html>
47 <head>
49 <?php
50 Header::setupHeader('datetime-picker');
51 include_once($GLOBALS['srcdir'] . "/options.js.php");
54 <script>
56 function validate() {
57 var f = document.forms[0];
58 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
59 if (f.refsource.selectedIndex <= 0) {
60 alert('Please select a referral source!');
61 return false;
63 <?php } ?>
64 <?php if (getLayoutUOR('DEM', 'sex') == 2) { ?>
65 if (f.sex.selectedIndex <= 0) {
66 alert('Please select a value for sex!');
67 return false;
69 <?php } ?>
70 <?php if (getLayoutUOR('DEM', 'DOB') == 2) { ?>
71 if (f.DOB.value.length == 0) {
72 alert('Please select a birth date!');
73 return false;
75 <?php } ?>
76 top.restoreSession();
77 return true;
80 $(function () {
81 $('.datepicker').datetimepicker({
82 <?php $datetimepicker_timepicker = false; ?>
83 <?php $datetimepicker_showseconds = false; ?>
84 <?php $datetimepicker_formatInput = true; ?>
85 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
86 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
87 });
88 $('.datetimepicker').datetimepicker({
89 <?php $datetimepicker_timepicker = true; ?>
90 <?php $datetimepicker_showseconds = false; ?>
91 <?php $datetimepicker_formatInput = true; ?>
92 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
93 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
94 });
95 });
97 </script>
99 </head>
101 <body class="body_top" onload="javascript:document.new_patient.fname.focus();">
103 <form name='new_patient' method='post' action="new_patient_save.php"
104 onsubmit='return validate()'>
105 <input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
107 <span class='title'><?php echo xlt('Add Patient Record'); ?></span>
109 <br /><br />
111 <center>
113 <?php if ($GLOBALS['omit_employers']) { ?>
114 <input type='hidden' name='title' value='' />
115 <?php } ?>
117 <table class="border-0">
119 <?php if (!$GLOBALS['omit_employers']) { ?>
120 <tr>
121 <td>
122 <span class='font-weight-bold'><?php echo xlt('Title'); ?>:</span>
123 </td>
124 <td>
125 <select name='title'>
126 <?php
127 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
128 "WHERE list_id = 'titles' AND activity = 1 ORDER BY seq");
129 while ($orow = sqlFetchArray($ores)) {
130 echo " <option value='" . attr($orow['option_id']) . "'";
131 if ($orow['option_id'] == $form_title) {
132 echo " selected";
135 echo ">" . text($orow['title']) . "</option>\n";
138 </select>
139 </td>
140 </tr>
141 <?php } ?>
143 <tr>
144 <td>
145 <span class='font-weight-bold'><?php echo xlt('First Name'); ?>: </span>
146 </td>
147 <td>
148 <input type='entry' size='15' name='fname' value='<?php echo attr($form_fname); ?>' />
149 </td>
150 </tr>
152 <tr>
153 <td>
154 <span class='font-weight-bold'><?php echo xlt('Middle Name'); ?>: </span>
155 </td>
156 <td>
157 <input type='entry' size='15' name='mname' value='<?php echo attr($form_mname); ?>' />
158 </td>
159 </tr>
161 <tr>
162 <td>
163 <span class='font-weight-bold'><?php echo xlt('Last Name'); ?>: </span>
164 </td>
165 <td>
166 <input type='entry' size='15' name='lname' value='<?php echo attr($form_lname); ?>' />
167 </td>
168 </tr>
170 <tr>
171 <td>
172 <span class='font-weight-bold'><?php echo xlt('Sex'); ?>: </span>
173 </td>
174 <td>
175 <select name='sex'>
176 <option value=''>Unassigned</option>
177 <?php
178 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
179 "WHERE list_id = 'sex' AND activity = 1 ORDER BY seq");
180 while ($orow = sqlFetchArray($ores)) {
181 echo " <option value='" . attr($orow['option_id']) . "'";
182 if ($orow['option_id'] == $form_sex) {
183 echo " selected";
186 echo ">" . text($orow['title']) . "</option>\n";
189 </select>
190 </td>
191 </tr>
193 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
194 <tr>
195 <td>
196 <span class='font-weight-bold'><?php echo xlt('Referral Source'); ?>: </span>
197 </td>
198 <td>
199 <select name='refsource'>
200 <option value=''><?php echo xlt("Unassigned"); ?></option>
201 <?php
202 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
203 "WHERE list_id = 'refsource' AND activity = 1 ORDER BY seq");
204 while ($orow = sqlFetchArray($ores)) {
205 echo " <option value='" . attr($orow['option_id']) . "'";
206 if ($orow['option_id'] == $form_refsource) {
207 echo " selected";
210 echo ">" . text($orow['title']) . "</option>\n";
213 </select>
214 </td>
215 </tr>
216 <?php } ?>
218 <tr>
219 <td>
220 <span class='font-weight-bold'><?php echo xlt('Birth Date'); ?>:</span>
221 </td>
222 <td>
223 <input type='text' size='10' class='datepicker' name='DOB' id='DOB'
224 value='<?php echo attr($form_dob); ?>' />
225 </td>
226 </tr>
228 <tr<?php echo $regstyle ?>>
229 <td>
230 <span class='font-weight-bold'><?php echo xlt('Registration Date'); ?>: </span>
231 </td>
232 <td>
233 <input type='text' size='10' class='datepicker' name='regdate' id='regdate'
234 value='<?php echo attr($form_regdate); ?>' />
235 </td>
236 </tr>
238 <tr>
239 <td>
240 <span class='font-weight-bold'><?php echo xlt('Patient Number'); ?>: </span>
241 </td>
242 <td>
243 <input type='entry' size='5' name='pubpid' value='<?php echo attr($form_pubpid); ?>' />
244 <span class='text'><?php echo xlt('omit to autoassign'); ?> &nbsp; &nbsp; </span>
245 </td>
246 </tr>
248 <tr>
249 <td colspan='2'>
250 &nbsp;<br />
251 <input type='submit' name='form_create' value='<?php echo xla('Create New Patient'); ?>' />
252 </td>
253 <td>
254 </td>
255 </tr>
257 </table>
258 </center>
259 </form>
260 <script>
261 <?php
262 if ($form_pubpid) {
263 echo "alert(" . xlj('This patient ID is already in use!') . ");\n";
266 </script>
268 </body>
269 </html>