added new datepicker to forms in contrib
[openemr.git] / contrib / forms / psychiatrySet / brief_aan_verwijzer / new.php
blobfc72e013eb36ad9166fed110e7fbce34d4d35344
1 <?php
2 /*
3 * brief_aan_verwijzer
4 * letter to verwijzer - Dutch specific form
5 * Version: 1.0 - 30-03-2008
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @author Larry Lart
20 * @link http://www.open-emr.org
23 include_once("../../globals.php");
24 include_once("$srcdir/api.inc");
25 include_once("$srcdir/patient.inc");
27 formHeader("Form: brief_aan_verwijzer");
28 $returnurl = 'encounter_top.php';
30 $result = getPatientData($pid, "fname,lname,pid,pubpid,phone_home,sex,pharmacy_id,DOB,DATE_FORMAT(DOB,'%Y%m%d') as DOB_YMD");
31 $provider_results = sqlQuery("select * from users where username='" . $_SESSION{"authUser"} . "'");
33 ////////////////////////////////////////////////////////////////////
34 // Function: getPatientDateOfLastEncounter
35 function getPatientDateOfLastEncounter( $nPid )
37 // get date of last encounter no codes
38 $strEventDate = sqlQuery("SELECT MAX(pc_eventDate) AS max
39 FROM openemr_postcalendar_events
40 WHERE pc_pid = $nPid
41 AND pc_apptstatus = '@'
42 AND pc_eventDate >= '2007-01-01'");
44 // now check if there was a previous encounter
45 if( $strEventDate['max'] != "" )
46 return( $strEventDate['max'] );
47 else
48 return( "00-00-0000" );
51 $m_strEventDate = getPatientDateOfLastEncounter( $result['pid'] );
53 // get last saved id for intakeverslag
54 $vectIntakeverslagQuery = sqlQuery( "SELECT id FROM form_intakeverslag
55 WHERE pid = ".$_SESSION["pid"].
56 " AND groupname='".$_SESSION["authProvider"].
57 "' AND user='".$_SESSION["authUser"]."' AND
58 authorized=$userauthorized AND activity=1
59 AND autosave_flag=0
60 ORDER by id DESC limit 1" );
62 // get autosave id for Psychiatrisch Onderzoek
63 $vectPO = sqlQuery( "SELECT id FROM form_psychiatrisch_onderzoek
64 WHERE pid = ".$_SESSION["pid"].
65 " AND groupname='".$_SESSION["authProvider"].
66 "' AND user='".$_SESSION["authUser"]."' AND
67 authorized=$userauthorized AND activity=1
68 AND autosave_flag=0
69 ORDER by id DESC limit 1" );
71 // get autosave id for Psychiatrisch Onderzoek
72 $vectAutosaveBAV = sqlQuery( "SELECT id, autosave_flag, autosave_datetime FROM form_brief_aan_verwijzer
73 WHERE pid = ".$_SESSION["pid"].
74 " AND groupname='".$_SESSION["authProvider"].
75 "' AND user='".$_SESSION["authUser"]."' AND
76 authorized=$userauthorized AND activity=1
77 AND autosave_flag=1
78 ORDER by id DESC limit 1" );
80 //fetch data from INTAKE-VERSLAG
81 $obj_iv = formFetch( "form_intakeverslag", $vectIntakeverslagQuery['id'] );
82 // fetch data from PSYCHIATRISCH ONDERZOEK
83 $obj_po = formFetch( "form_psychiatrisch_onderzoek", $vectPO['id'] );
84 // fetch data from brief_aan_verwijzer
85 $obj_bav = formFetch( "form_brief_aan_verwijzer", $vectAutosaveBAV['id'] );
87 /////////////////
88 // here we mix the data
90 // Introductie - local
91 // create the inroductie form
92 if( $obj_bav['introductie'] != '' )
93 $obj['introductie'] = $obj_bav['introductie'];
94 else
95 $obj['introductie'] = xl("Since","",""," ") . $m_strEventDate . xl("we have seen your above patient for evaluation and treatment at our outpatient psychiatry clinic. Thank you for this referral.",""," ");
97 // Reden van aanmelding
98 if( $obj_bav['reden_van_aanmelding'] != '' )
99 $obj['reden_van_aanmelding'] = $obj_bav['reden_van_aanmelding'];
100 elseif( $obj_iv['reden_van_aanmelding'] != '' )
101 $obj['reden_van_aanmelding'] = $obj_iv['reden_van_aanmelding'];
102 else
103 $obj['reden_van_aanmelding'] = '';
105 // Anamnese
106 if( $obj_bav['anamnese'] != '' )
107 $obj['anamnese'] = $obj_bav['anamnese'];
108 elseif( $obj_iv['klachten_probleemgebieden'] != '' )
109 $obj['anamnese'] = $obj_iv['klachten_probleemgebieden'];
110 else
111 $obj['anamnese'] = '';
113 // Psychiatrisch onderzoek
114 if( $obj_bav['psychiatrisch_onderzoek'] != '' )
115 $obj['psychiatrisch_onderzoek'] = $obj_bav['psychiatrisch_onderzoek'];
116 elseif( $obj_po['psychiatrisch_onderzoek'] != '' )
117 $obj['psychiatrisch_onderzoek'] = $obj_po['psychiatrisch_onderzoek'];
118 else
119 $obj['psychiatrisch_onderzoek'] = '';
121 // Beschrijvend conclusie
122 if( $obj_bav['beschrijvend_conclusie'] != '' )
123 $obj['beschrijvend_conclusie'] = $obj_bav['beschrijvend_conclusie'];
124 elseif( $obj_po['beschrijvende_conclusie'] != '' )
125 $obj['beschrijvend_conclusie'] = $obj_po['beschrijvende_conclusie'];
126 else
127 $obj['beschrijvend_conclusie'] = '';
129 // Advies/beleid
130 if( $obj_bav['advies_beleid'] != '' )
131 $obj['advies_beleid'] = $obj_bav['advies_beleid'];
132 elseif( $obj_po['behandelvoorstel'] != '' )
133 $obj['advies_beleid'] = $obj_po['behandelvoorstel'];
134 else
135 $obj['advies_beleid'] = '';
140 <html>
141 <head>
142 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
143 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
144 </head>
148 <body <?php echo $top_bg_line;?> topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
150 <style type="text/css">
151 body { font-family:sans-serif; font-size:10pt; font-weight:normal }
152 .dehead { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold;
153 padding-left:3px; padding-right:3px; }
154 .detail { color:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal;
155 padding-left:3px; padding-right:3px; }
156 </style>
158 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
159 <script type="text/javascript" src="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
160 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
161 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
163 <?php
165 if( $vectAutosaveBAV['id'] )
166 $brief_aan_verwijzer_id = $vectAutosaveBAV['id'];
167 else
168 $brief_aan_verwijzer_id = "0";
171 <script type="text/javascript">
172 $(document).ready(function(){
173 autosave();
174 $('.datepicker').datetimepicker({
175 <?php $datetimepicker_timepicker = false; ?>
176 <?php $datetimepicker_showseconds = false; ?>
177 <?php $datetimepicker_formatInput = false; ?>
178 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
179 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
183 function delete_autosave( )
185 if( confirm("<?php xl('Are you sure you want to completely remove this form?','e'); ?>") )
187 $.ajax(
189 type: "POST",
190 url: "../../forms/brief_aan_verwijzer/delete_autosave.php",
191 data: "id=" + <?php echo $brief_aan_verwijzer_id ?>
193 cache: false,
194 success: function( message )
196 $("#timestamp").empty().append(message);
199 return true;
201 } else
203 return false;
208 function autosave( )
210 var t = setTimeout("autosave()", 20000);
212 var a_introductie = $("#introductie").val();
213 var a_reden_van_aanmelding = $("#reden_van_aanmelding").val();
214 var a_anamnese = $("#anamnese").val();
215 var a_psychiatrisch_onderzoek = $("#psychiatrisch_onderzoek").val();
216 var a_beschrijvend_conclusie = $("#beschrijvend_conclusie").val();
217 var a_advies_beleid = $("#advies_beleid").val();
219 if( a_introductie.length > 0 || a_reden_van_aanmelding.length > 0 )
221 $.ajax(
223 type: "POST",
224 url: "../../forms/brief_aan_verwijzer/autosave.php",
225 data: "id=" + <?php echo $brief_aan_verwijzer_id ?> +
226 "&introductie=" + $("#introductie").val() +
227 "&reden_van_aanmelding=" + a_reden_van_aanmelding +
228 "&anamnese=" + a_anamnese +
229 "&psychiatrisch_onderzoek=" + a_psychiatrisch_onderzoek +
230 "&beschrijvend_conclusie=" + a_beschrijvend_conclusie +
231 "&advies_beleid=" + a_advies_beleid
233 cache: false,
234 success: function( message )
236 $("#timestamp").empty().append(message);
243 </script>
245 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
246 <form method=post action="<?php echo $rootdir;?>/forms/brief_aan_verwijzer/save.php?mode=new&saveid=<?php echo $brief_aan_verwijzer_id; ?>" name="my_form">
247 <span class="title"><?php xl('Psychiatric Brief Letter','e'); ?></span><br><br>
249 <br><span class=text><?php xl('Introduction','e'); ?></span><br>
250 <textarea cols=80 rows=3 wrap=virtual name="introductie" id="introductie"><?php echo stripslashes($obj{"introductie"});?></textarea><br>
252 <br><span class=text><?php xl('Reason for Visit','e'); ?></span><br>
253 <textarea cols=80 rows=5 wrap=virtual name="reden_van_aanmelding" id="reden_van_aanmelding"><?php echo stripslashes($obj{"reden_van_aanmelding"});?></textarea><br>
254 <br><span class=text><?php xl('History','e'); ?></span><br>
255 <textarea cols=80 rows=5 wrap=virtual name="anamnese" id="anamnese"><?php echo stripslashes($obj{"anamnese"});?></textarea><br>
256 <br><span class=text><?php xl('Psychiatric Examination','e'); ?></span><br>
257 <textarea cols=80 rows=5 wrap=virtual name="psychiatrisch_onderzoek" id="psychiatrisch_onderzoek"><?php echo stripslashes($obj{"psychiatrisch_onderzoek"});?></textarea><br>
258 <br><span class=text><?php xl('Conclusions','e'); ?></span><br>
259 <textarea cols=80 rows=5 wrap=virtual name="beschrijvend_conclusie" id="beschrijvend_conclusie"><?php echo stripslashes($obj{"beschrijvend_conclusie"});?></textarea><br>
260 <br><span class=text><?php xl('Treatment Plan','e'); ?></span><br>
261 <textarea cols=80 rows=5 wrap=virtual name="advies_beleid" id="advies_beleid"><?php echo stripslashes($obj{"advies_beleid"});?></textarea><br>
263 <table><tr>
265 <?php
266 // here we fill in the header above with patient name etc ? ??? - move above
269 </tr></table>
271 <br><br>
272 <a href="javascript:document.my_form.submit();" class="link_submit">[<?php xl('Save','e'); ?>]</a>
273 <br>
274 <a href="<?php echo "$rootdir/patient_file/encounter/$returnurl";?>" class="link_submit" onclick="delete_autosave();top.restoreSession()">[<?php xl('Don\'t Save','e'); ?>]</a>
275 </form>
278 <div id="timestamp"></div>
280 <?php
281 formFooter();