Fixes for switching encounters
[openemr.git] / interface / new / new.php
blob4cea16f8fb32a1c3eaaee2c5184123f844cb065b
1 <?php
2 include_once("../globals.php");
4 if ($GLOBALS['full_new_patient_form']) {
5 require("new_comprehensive.php");
6 exit;
9 // For a layout field return 0=unused, 1=optional, 2=mandatory.
10 function getLayoutUOR($form_id, $field_id) {
11 $crow = sqlQuery("SELECT uor FROM layout_options WHERE " .
12 "form_id = '$form_id' AND field_id = '$field_id' LIMIT 1");
13 return 0 + $crow['uor'];
16 // Determine if the registration date should be requested.
17 $regstyle = getLayoutUOR('DEM','regdate') ? "" : " style='display:none'";
19 $form_pubpid = $_POST['pubpid' ] ? trim($_POST['pubpid' ]) : '';
20 $form_title = $_POST['title' ] ? trim($_POST['title' ]) : '';
21 $form_fname = $_POST['fname' ] ? trim($_POST['fname' ]) : '';
22 $form_mname = $_POST['mname' ] ? trim($_POST['mname' ]) : '';
23 $form_lname = $_POST['lname' ] ? trim($_POST['lname' ]) : '';
24 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
25 $form_sex = $_POST['sex' ] ? trim($_POST['sex' ]) : '';
26 $form_refsource = $_POST['refsource'] ? trim($_POST['refsource']) : '';
27 $form_dob = $_POST['DOB' ] ? trim($_POST['DOB' ]) : '';
28 $form_regdate = $_POST['regdate' ] ? trim($_POST['regdate' ]) : date('Y-m-d');
30 <html>
32 <head>
33 <?php html_header_show(); ?>
34 <link rel="stylesheet" href="<?php echo xl($css_header,'e');?>" type="text/css">
35 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
37 <script type="text/javascript" src="../../library/textformat.js"></script>
38 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
39 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
40 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
42 <script LANGUAGE="JavaScript">
44 var mypcc = '1';
46 function validate() {
47 var f = document.forms[0];
48 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
49 if (f.refsource.selectedIndex <= 0) {
50 alert('Please select a referral source!');
51 return false;
53 <?php } ?>
54 <?php if (getLayoutUOR('DEM','sex') == 2) { ?>
55 if (f.sex.selectedIndex <= 0) {
56 alert('Please select a value for sex!');
57 return false;
59 <?php } ?>
60 <?php if (getLayoutUOR('DEM','DOB') == 2) { ?>
61 if (f.DOB.value.length == 0) {
62 alert('Please select a birth date!');
63 return false;
65 <?php } ?>
66 top.restoreSession();
67 return true;
70 </script>
72 </head>
74 <body class="body_top" onload="javascript:document.new_patient.fname.focus();">
76 <?php if ($GLOBALS['concurrent_layout']) { ?>
77 <form name='new_patient' method='post' action="new_patient_save.php"
78 onsubmit='return validate()'>
79 <span class='title'><?php xl('Add Patient Record','e');?></span>
80 <?php } else { ?>
81 <form name='new_patient' method='post' action="new_patient_save.php"
82 target='_top' onsubmit='return validate()'>
83 <a class="title" href="../main/main_screen.php" target="_top" onclick="top.restoreSession()">
84 <?php xl('Add Patient Record','e');?></a>
85 <?php } ?>
87 <br><br>
89 <center>
91 <?php if ($GLOBALS['omit_employers']) { ?>
92 <input type='hidden' name='title' value='' />
93 <?php } ?>
95 <table border='0'>
97 <?php if (!$GLOBALS['omit_employers']) { ?>
98 <tr>
99 <td>
100 <span class='bold'><?php xl('Title','e');?>: </span>
101 </td>
102 <td>
103 <select name='title'>
104 <?php
105 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
106 "WHERE list_id = 'titles' ORDER BY seq");
107 while ($orow = sqlFetchArray($ores)) {
108 echo " <option value='" . $orow['option_id'] . "'";
109 if ($orow['option_id'] == $form_title) echo " selected";
110 echo ">" . $orow['title'] . "</option>\n";
113 </select>
114 </td>
115 </tr>
116 <?php } ?>
118 <tr>
119 <td>
120 <span class='bold'><?php xl('First Name','e');?>: </span>
121 </td>
122 <td>
123 <input type='entry' size='15' name='fname' value='<?php echo $form_fname; ?>'>
124 </td>
125 </tr>
127 <tr>
128 <td>
129 <span class='bold'><?php xl('Middle Name','e');?>: </span>
130 </td>
131 <td>
132 <input type='entry' size='15' name='mname' value='<?php echo $form_mname; ?>'>
133 </td>
134 </tr>
136 <tr>
137 <td>
138 <span class='bold'><?php xl('Last Name','e');?>: </span>
139 </td>
140 <td>
141 <input type='entry' size='15' name='lname' value='<?php echo $form_lname; ?>'>
142 </td>
143 </tr>
145 <tr>
146 <td>
147 <span class='bold'><?php xl('Sex','e'); ?>: </span>
148 </td>
149 <td>
150 <select name='sex'>
151 <option value=''>Unassigned</option>
152 <?php
153 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
154 "WHERE list_id = 'sex' ORDER BY seq");
155 while ($orow = sqlFetchArray($ores)) {
156 echo " <option value='" . $orow['option_id'] . "'";
157 if ($orow['option_id'] == $form_sex) echo " selected";
158 echo ">" . $orow['title'] . "</option>\n";
161 </select>
162 </td>
163 </tr>
165 <?php if ($GLOBALS['inhouse_pharmacy']) { ?>
166 <tr>
167 <td>
168 <span class='bold'><?php xl('Referral Source','e'); ?>: </span>
169 </td>
170 <td>
171 <select name='refsource'>
172 <option value=''>Unassigned</option>
173 <?php
174 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
175 "WHERE list_id = 'refsource' ORDER BY seq");
176 while ($orow = sqlFetchArray($ores)) {
177 echo " <option value='" . $orow['option_id'] . "'";
178 if ($orow['option_id'] == $form_refsource) echo " selected";
179 echo ">" . $orow['title'] . "</option>\n";
182 </select>
183 </td>
184 </tr>
185 <?php } ?>
187 <tr>
188 <td>
189 <span class='bold'><?php xl('Birth Date','e');?>: </span>
190 </td>
191 <td>
192 <input type='text' size='10' name='DOB' id='DOB'
193 value='<?php echo $form_dob; ?>'
194 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
195 title='yyyy-mm-dd' />
196 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
197 id='img_dob' border='0' alt='[?]' style='cursor:pointer'
198 title='Click here to choose a date'>
199 <script LANGUAGE="JavaScript">
200 Calendar.setup({inputField:"DOB", ifFormat:"%Y-%m-%d", button:"img_dob"});
201 </script>
202 </td>
203 </tr>
205 <tr<?php echo $regstyle ?>>
206 <td>
207 <span class='bold'><?php xl('Registration Date','e');?>: </span>
208 </td>
209 <td>
210 <input type='text' size='10' name='regdate' id='regdate'
211 value='<?php echo $form_regdate; ?>'
212 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)'
213 title='yyyy-mm-dd' />
214 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
215 id='img_regdate' border='0' alt='[?]' style='cursor:pointer'
216 title='Click here to choose a date'>
217 <script LANGUAGE="JavaScript">
218 Calendar.setup({inputField:"regdate", ifFormat:"%Y-%m-%d", button:"img_regdate"});
219 </script>
220 </td>
221 </tr>
223 <tr>
224 <td>
225 <span class='bold'><?php xl('Patient Number','e');?>: </span>
226 </td>
227 <td>
228 <input type='entry' size='5' name='pubpid' value='<?php echo $form_pubpid; ?>'>
229 <span class='text'><?php xl('omit to autoassign','e');?> &nbsp; &nbsp; </span>
230 </td>
231 </tr>
233 <tr>
234 <td colspan='2'>
235 &nbsp;<br>
236 <input type='submit' name='form_create' value=<?php xl('Create New Patient','e'); ?> />
237 </td>
238 <td>
239 </td>
240 </tr>
242 </table>
243 </center>
244 </form>
245 <script language="Javascript">
246 <?php
247 if ($form_pubpid) {
248 echo "alert('" . xl('This patient ID is already in use!') . "');\n";
251 </script>
253 </body>
254 </html>