Highway to PSR2
[openemr.git] / interface / new / new.php
blobc69365511b93c0ac24ea5eebe7c95ead2fff4c0f
1 <?php
2 /**
4 * LICENSE: This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
15 * @package OpenEMR
16 * @author Brady Miller <brady.g.miller@gmail.com>
17 * @link http://www.open-emr.org
20 include_once("../globals.php");
22 if ($GLOBALS['full_new_patient_form']) {
23 require("new_comprehensive.php");
24 exit;
27 // For a layout field return 0=unused, 1=optional, 2=mandatory.
28 function getLayoutUOR($form_id, $field_id)
30 $crow = sqlQuery("SELECT uor FROM layout_options WHERE " .
31 "form_id = '$form_id' AND field_id = '$field_id' LIMIT 1");
32 return 0 + $crow['uor'];
35 // Determine if the registration date should be requested.
36 $regstyle = getLayoutUOR('DEM', 'regdate') ? "" : " style='display:none'";
38 $form_pubpid = $_POST['pubpid' ] ? trim($_POST['pubpid' ]) : '';
39 $form_title = $_POST['title' ] ? trim($_POST['title' ]) : '';
40 $form_fname = $_POST['fname' ] ? trim($_POST['fname' ]) : '';
41 $form_mname = $_POST['mname' ] ? trim($_POST['mname' ]) : '';
42 $form_lname = $_POST['lname' ] ? trim($_POST['lname' ]) : '';
43 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
44 $form_sex = $_POST['sex' ] ? trim($_POST['sex' ]) : '';
45 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
46 $form_dob = $_POST['DOB' ] ? trim($_POST['DOB' ]) : '';
47 $form_regdate = $_POST['regdate' ] ? trim($_POST['regdate' ]) : date('Y-m-d');
49 <html>
51 <head>
52 <?php html_header_show(); ?>
53 <link rel="stylesheet" href="<?php echo xl($css_header, 'e');?>" type="text/css">
54 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
56 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
57 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
58 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
60 <?php include_once("{$GLOBALS['srcdir']}/options.js.php"); ?>
62 <script LANGUAGE="JavaScript">
64 var mypcc = '1';
66 function validate() {
67 var f = document.forms[0];
68 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
69 if (f.refsource.selectedIndex <= 0) {
70 alert('Please select a referral source!');
71 return false;
73 <?php } ?>
74 <?php if (getLayoutUOR('DEM', 'sex') == 2) { ?>
75 if (f.sex.selectedIndex <= 0) {
76 alert('Please select a value for sex!');
77 return false;
79 <?php } ?>
80 <?php if (getLayoutUOR('DEM', 'DOB') == 2) { ?>
81 if (f.DOB.value.length == 0) {
82 alert('Please select a birth date!');
83 return false;
85 <?php } ?>
86 top.restoreSession();
87 return true;
90 $(document).ready(function(){
91 $('.datepicker').datetimepicker({
92 <?php $datetimepicker_timepicker = false; ?>
93 <?php $datetimepicker_showseconds = false; ?>
94 <?php $datetimepicker_formatInput = false; ?>
95 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
96 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
97 });
98 $('.datetimepicker').datetimepicker({
99 <?php $datetimepicker_timepicker = true; ?>
100 <?php $datetimepicker_showseconds = false; ?>
101 <?php $datetimepicker_formatInput = false; ?>
102 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
103 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
107 </script>
109 </head>
111 <body class="body_top" onload="javascript:document.new_patient.fname.focus();">
113 <form name='new_patient' method='post' action="new_patient_save.php"
114 onsubmit='return validate()'>
115 <span class='title'><?php xl('Add Patient Record', 'e');?></span>
117 <br><br>
119 <center>
121 <?php if ($GLOBALS['omit_employers']) { ?>
122 <input type='hidden' name='title' value='' />
123 <?php } ?>
125 <table border='0'>
127 <?php if (!$GLOBALS['omit_employers']) { ?>
128 <tr>
129 <td>
130 <span class='bold'><?php xl('Title', 'e');?>: </span>
131 </td>
132 <td>
133 <select name='title'>
134 <?php
135 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
136 "WHERE list_id = 'titles' AND activity = 1 ORDER BY seq");
137 while ($orow = sqlFetchArray($ores)) {
138 echo " <option value='" . $orow['option_id'] . "'";
139 if ($orow['option_id'] == $form_title) {
140 echo " selected";
143 echo ">" . $orow['title'] . "</option>\n";
146 </select>
147 </td>
148 </tr>
149 <?php } ?>
151 <tr>
152 <td>
153 <span class='bold'><?php xl('First Name', 'e');?>: </span>
154 </td>
155 <td>
156 <input type='entry' size='15' name='fname' value='<?php echo $form_fname; ?>'>
157 </td>
158 </tr>
160 <tr>
161 <td>
162 <span class='bold'><?php xl('Middle Name', 'e');?>: </span>
163 </td>
164 <td>
165 <input type='entry' size='15' name='mname' value='<?php echo $form_mname; ?>'>
166 </td>
167 </tr>
169 <tr>
170 <td>
171 <span class='bold'><?php xl('Last Name', 'e');?>: </span>
172 </td>
173 <td>
174 <input type='entry' size='15' name='lname' value='<?php echo $form_lname; ?>'>
175 </td>
176 </tr>
178 <tr>
179 <td>
180 <span class='bold'><?php xl('Sex', 'e'); ?>: </span>
181 </td>
182 <td>
183 <select name='sex'>
184 <option value=''>Unassigned</option>
185 <?php
186 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
187 "WHERE list_id = 'sex' AND activity = 1 ORDER BY seq");
188 while ($orow = sqlFetchArray($ores)) {
189 echo " <option value='" . $orow['option_id'] . "'";
190 if ($orow['option_id'] == $form_sex) {
191 echo " selected";
194 echo ">" . $orow['title'] . "</option>\n";
197 </select>
198 </td>
199 </tr>
201 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
202 <tr>
203 <td>
204 <span class='bold'><?php xl('Referral Source', 'e'); ?>: </span>
205 </td>
206 <td>
207 <select name='refsource'>
208 <option value=''>Unassigned</option>
209 <?php
210 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
211 "WHERE list_id = 'refsource' AND activity = 1 ORDER BY seq");
212 while ($orow = sqlFetchArray($ores)) {
213 echo " <option value='" . $orow['option_id'] . "'";
214 if ($orow['option_id'] == $form_refsource) {
215 echo " selected";
218 echo ">" . $orow['title'] . "</option>\n";
221 </select>
222 </td>
223 </tr>
224 <?php } ?>
226 <tr>
227 <td>
228 <span class='bold'><?php xl('Birth Date', 'e');?>: </span>
229 </td>
230 <td>
231 <input type='text' size='10' class='datepicker' name='DOB' id='DOB'
232 value='<?php echo $form_dob; ?>'
233 title='yyyy-mm-dd' />
234 </td>
235 </tr>
237 <tr<?php echo $regstyle ?>>
238 <td>
239 <span class='bold'><?php xl('Registration Date', 'e');?>: </span>
240 </td>
241 <td>
242 <input type='text' size='10' class='datepicker' name='regdate' id='regdate'
243 value='<?php echo $form_regdate; ?>'
244 title='yyyy-mm-dd' />
245 </td>
246 </tr>
248 <tr>
249 <td>
250 <span class='bold'><?php xl('Patient Number', 'e');?>: </span>
251 </td>
252 <td>
253 <input type='entry' size='5' name='pubpid' value='<?php echo $form_pubpid; ?>'>
254 <span class='text'><?php xl('omit to autoassign', 'e');?> &nbsp; &nbsp; </span>
255 </td>
256 </tr>
258 <tr>
259 <td colspan='2'>
260 &nbsp;<br>
261 <input type='submit' name='form_create' value=<?php xl('Create New Patient', 'e'); ?> />
262 </td>
263 <td>
264 </td>
265 </tr>
267 </table>
268 </center>
269 </form>
270 <script language="Javascript">
271 <?php
272 if ($form_pubpid) {
273 echo "alert('" . xl('This patient ID is already in use!') . "');\n";
276 </script>
278 </body>
279 </html>