Added ESign api and implemantion of ESign on forms and encounters
[openemr.git] / interface / patient_file / encounter / new_form.php
blob9b862459c1017754fe09588327e3953ec3d71fd4
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 include_once("../../globals.php");
8 require_once $GLOBALS['srcdir'].'/ESign/Api.php';
10 $esignApi = new Esign\Api();
12 <html>
13 <head>
14 <?php html_header_show();?>
15 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
17 <script language="JavaScript">
19 function openNewForm(sel) {
20 top.restoreSession();
21 <?php if ($GLOBALS['concurrent_layout']) { ?>
22 FormNameValueArray = sel.split('formname=');
23 if(FormNameValueArray[1] == 'newpatient')
25 parent.location.href = sel
27 else
29 parent.Forms.location.href = sel;
31 <?php } else { ?>
32 top.frames['Main'].location.href = sel;
33 <?php } ?>
35 function toggleFrame1(fnum) {
36 top.frames['left_nav'].document.forms[0].cb_top.checked=false;
37 top.window.parent.left_nav.toggleFrame(fnum);
39 </script>
40 <style type="text/css">
41 #sddm
42 { margin: 0;
43 padding: 0;
44 z-index: 30;
47 </style>
48 <script type="text/javascript" language="javascript">
50 var timeout = 500;
51 var closetimer = 0;
52 var ddmenuitem = 0;
53 var oldddmenuitem = 0;
54 var flag = 0;
56 // open hidden layer
57 function mopen(id)
59 // cancel close timer
60 //mcancelclosetime();
62 flag=10;
64 // close old layer
65 //if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
66 //if(ddmenuitem) ddmenuitem.style.display = 'none';
68 // get new layer and show it
69 oldddmenuitem = ddmenuitem;
70 ddmenuitem = document.getElementById(id);
71 if((ddmenuitem.style.visibility == '')||(ddmenuitem.style.visibility == 'hidden')){
72 if(oldddmenuitem) oldddmenuitem.style.visibility = 'hidden';
73 if(oldddmenuitem) oldddmenuitem.style.display = 'none';
74 ddmenuitem.style.visibility = 'visible';
75 ddmenuitem.style.display = 'block';
76 }else{
77 ddmenuitem.style.visibility = 'hidden';
78 ddmenuitem.style.display = 'none';
81 // close showed layer
82 function mclose()
84 if(flag==10)
86 flag=11;
87 return;
89 if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
90 if(ddmenuitem) ddmenuitem.style.display = 'none';
93 // close layer when click-out
94 document.onclick = mclose;
95 //=================================================
96 function findPosX(id)
98 obj=document.getElementById(id);
99 var curleft = 0;
100 if(obj.offsetParent)
101 while(1)
103 curleft += obj.offsetLeft;
104 if(!obj.offsetParent)
105 break;
106 obj = obj.offsetParent;
108 else if(obj.x)
109 curleft += obj.x;
110 PropertyWidth=document.getElementById(id).offsetWidth;
111 if(PropertyWidth>curleft)
113 document.getElementById(id).style.left=0;
117 function findPosY(obj)
119 var curtop = 0;
120 if(obj.offsetParent)
121 while(1)
123 curtop += obj.offsetTop;
124 if(!obj.offsetParent)
125 break;
126 obj = obj.offsetParent;
128 else if(obj.y)
129 curtop += obj.y;
130 return curtop;
132 </script>
134 </head>
135 <body class="bgcolor2">
136 <dl>
137 <?php //DYNAMIC FORM RETREIVAL
138 include_once("$srcdir/registry.inc");
140 function myGetRegistered($state="1", $limit="unlimited", $offset="0") {
141 $sql = "SELECT category, nickname, name, state, directory, id, sql_run, " .
142 "unpackaged, date FROM registry WHERE " .
143 "state LIKE \"$state\" ORDER BY category, priority, name";
144 if ($limit != "unlimited") $sql .= " limit $limit, $offset";
145 $res = sqlStatement($sql);
146 if ($res) {
147 for($iter=0; $row=sqlFetchArray($res); $iter++) {
148 $all[$iter] = $row;
151 else {
152 return false;
154 return $all;
157 $reg = myGetRegistered();
158 $old_category = '';
160 $DivId=1;
162 // To see if the encounter is locked. If it is, no new forms can be created
163 $encounterLocked = false;
164 if ( $esignApi->lockEncounters() &&
165 isset($GLOBALS['encounter']) &&
166 !empty($GLOBALS['encounter']) ) {
168 $esign = $esignApi->createEncounterESign( $GLOBALS['encounter'] );
169 if ( $esign->isLocked() ) {
170 $encounterLocked = true;
174 if (!empty($reg)) {
175 $StringEcho= '<ul id="sddm">';
176 if(isset($hide)){
177 $StringEcho.= "<li><a id='enc2' >" . htmlspecialchars( xl('Encounter Summary'),ENT_NOQUOTES) . "</a></li>";
178 }else{
179 $StringEcho.= "<li><a href='JavaScript:void(0);' id='enc2' onclick=\" return top.window.parent.left_nav.loadFrame2('enc2','RBot','patient_file/encounter/encounter_top.php')\">" . htmlspecialchars( xl('Encounter Summary'),ENT_NOQUOTES) . "</a></li>";
181 if ( $encounterLocked === false ) {
182 foreach ($reg as $entry) {
183 $new_category = trim($entry['category']);
184 $new_nickname = trim($entry['nickname']);
185 if ($new_category == '') {$new_category = htmlspecialchars(xl('Miscellaneous'),ENT_QUOTES);}
186 if ($new_nickname != '') {$nickname = $new_nickname;}
187 else {$nickname = $entry['name'];}
188 if ($old_category != $new_category) {
189 $new_category_ = $new_category;
190 $new_category_ = str_replace(' ','_',$new_category_);
191 if ($old_category != '') {$StringEcho.= "</table></div></li>";}
192 $StringEcho.= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('$DivId');\" >$new_category</a><div id='$DivId' ><table border='0' cellspacing='0' cellpadding='0'>";
193 $old_category = $new_category;
194 $DivId++;
196 $StringEcho.= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a onclick=\"openNewForm('" . $rootdir .'/patient_file/encounter/load_form.php?formname=' .urlencode($entry['directory']) .
197 "')\" href='JavaScript:void(0);'>" . xl_form_title($nickname) . "</a></td></tr>";
200 $StringEcho.= '</table></div></li>';
202 if($StringEcho){
203 $StringEcho2= '<div style="clear:both"></div>';
204 }else{
205 $StringEcho2="";
208 <!--<table style="border:solid 1px black" cellspacing="0" cellpadding="0">
209 <tr>
210 <td valign="top"><?php //echo $StringEcho; ?></td>
211 </tr>
212 </table>-->
213 <?php
214 //$StringEcho='';
215 // This shows Layout Based Form names just like the above.
217 if ( $encounterLocked === false ) {
218 $lres = sqlStatement("SELECT * FROM list_options " .
219 "WHERE list_id = 'lbfnames' ORDER BY seq, title");
220 if (sqlNumRows($lres)) {
221 if(!$StringEcho){
222 $StringEcho= '<ul id="sddm">';
224 $StringEcho.= "<li class=\"encounter-form-category-li\"><a href='JavaScript:void(0);' onClick=\"mopen('lbf');\" >".xl('Layout Based') ."</a><div id='lbf' ><table border='0' cellspacing='0' cellpadding='0'>";
225 while ($lrow = sqlFetchArray($lres)) {
226 $option_id = $lrow['option_id']; // should start with LBF
227 $title = $lrow['title'];
228 $StringEcho.= "<tr><td style='border-top: 1px solid #000000;padding:0px;'><a href='" . $rootdir .'/patient_file/encounter/load_form.php?formname='
229 .urlencode($option_id) ."' >" . xl_form_title($title) . "</a></td></tr>";
233 if($StringEcho){
234 $StringEcho.= "</table></div></li></ul>".$StringEcho2;
237 <table cellspacing="0" cellpadding="0" align="center">
238 <tr>
239 <td valign="top"><?php echo $StringEcho; ?></td>
240 </tr>
241 </table>
242 </dl>
244 </body>
245 </html>