updated interface, allow forms to be deleted
[openemr.git] / interface / patient_file / encounter / forms.php
blobae6213809be558ec3486a35b3de8e8f2fb05faec
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/forms.inc");
4 include_once("$srcdir/calendar.inc");
5 include_once("$srcdir/acl.inc");
6 ?>
7 <html>
9 <head>
10 <?php html_header_show();?>
11 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
12 <script type="text/javascript" src="../../../library/dialog.js"></script>
14 <script language="JavaScript">
16 // Process click on Delete link.
17 function deleteme() {
18 dlgopen('../deleter.php?encounterid=<?php echo $encounter; ?>', '_blank', 500, 450);
19 return false;
22 // Called by the deleter.php window on a successful delete.
23 function imdeleted() {
24 <?php if ($GLOBALS['concurrent_layout']) { ?>
25 parent.parent.left_nav.clearEncounter();
26 <?php } else { ?>
27 top.restoreSession();
28 top.Title.location.href = '../patient_file/encounter/encounter_title.php';
29 top.Main.location.href = '../patient_file/encounter/patient_encounter.php?mode=new';
30 <?php } ?>
33 </script>
35 </head>
37 <body class="body_top">
39 <span class="title"><?php xl('This Encounter','e'); ?></span>
40 <?php
41 $auth_notes_a = acl_check('encounters', 'notes_a');
42 $auth_notes = acl_check('encounters', 'notes');
43 $auth_relaxed = acl_check('encounters', 'relaxed');
45 if (is_numeric($pid)) {
46 // Check for no access to the patient's squad.
47 $result = getPatientData($pid, "fname,lname,squad");
48 echo " for " . $result['fname'] . " " . $result['lname'];
49 if ($result['squad'] && ! acl_check('squads', $result['squad'])) {
50 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
52 // Check for no access to the encounter's sensitivity level.
53 $result = sqlQuery("SELECT sensitivity FROM form_encounter WHERE " .
54 "pid = '$pid' AND encounter = '$encounter' LIMIT 1");
55 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
56 $auth_notes_a = $auth_notes = $auth_relaxed = 0;
60 echo ":";
61 if (acl_check('admin', 'super')) {
62 echo "&nbsp;&nbsp;<a href='' onclick='return deleteme()'>" .
63 "<font class='more' style='color:red'>(Delete)</font></a>";
65 echo "<br>\n";
67 if ($result = getFormByEncounter($pid, $encounter, "id, date, form_id, form_name, formdir, user, deleted")) {
68 echo "<table style='border-collapse:collapse; width:100%;'>";
69 echo "<tr><th>User</th><th>Form</th><th></th></tr>";
70 foreach ($result as $iter) {
71 $formdir = $iter['formdir'];
73 // skip forms whose 'deleted' flag is set to 1
74 if ($iter['deleted'] == 1) continue;
76 // Skip forms that we are not authorized to see.
77 if (($auth_notes_a) ||
78 ($auth_notes && $iter['user'] == $_SESSION['authUser']) ||
79 ($auth_relaxed && ($formdir == 'sports_fitness' || $formdir == 'podiatry'))) ;
80 else continue;
82 // $form_info = getFormInfoById($iter['id']);
83 echo '<tr style="vertical-align:top; border-bottom:1px solid black;">';
84 $user = getNameFromUsername($iter['user']);
86 $form_name = ($formdir == 'newpatient') ? "Patient Encounter" : $iter['form_name'];
88 echo '<td style="border-top:1px solid black;" class="text"><span style="font-weight:bold;">' .
89 $user['fname'] . " " . $user['lname'] .'</span></td>';
90 echo "<td style='vertical-align:top; border-top:1px solid black; text-align:center;' >";
92 // a link to edit the form
93 echo "<a target='".
94 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
95 "' href='$rootdir/patient_file/encounter/view_form.php?" .
96 "formname=" . $formdir . "&id=" . $iter['form_id'] .
97 "' class='text' onclick='top.restoreSession()'>$form_name</a>";
99 if (acl_check('admin', 'super')) {
100 // a link to delete the form from the encounter
101 echo "<span class='small'> (<a target='".
102 ($GLOBALS['concurrent_layout'] ? "_parent" : "Main") .
103 "' href='$rootdir/patient_file/encounter/delete_form.php?" .
104 "formname=" . $formdir .
105 "&id=" . $iter['id'] .
106 "&encounter=". $encounter.
107 "&pid=".$pid.
108 "' class='small' title='Delete this form' onclick='top.restoreSession()'>Delete</a>)</span>";
111 echo "</td>\n" .
112 "<td style='border-top:1px solid black; width: 25px'>&nbsp;</td>\n" .
113 "<td style='border-top:1px solid black; vertical-align:top;'>";
115 // Use the form's report.php for display.
117 include_once($GLOBALS['incdir'] . "/forms/$formdir/report.php");
118 call_user_func($formdir . "_report", $pid, $iter['encounter'], 2, $iter['form_id']);
120 echo "</td></tr>";
122 echo "</table>";
126 <?php if ($GLOBALS['athletic_team'] && $GLOBALS['concurrent_layout'] == 2) { ?>
127 <script language='JavaScript'>
128 // If this is the top frame then show the encounters list in the bottom frame.
129 var n = parent.parent.left_nav;
130 var nf = n.document.forms[0];
131 if (parent.window.name == 'RTop' && nf.cb_bot.checked) {
132 var othername = 'RBot';
133 n.setRadio(othername, 'ens');
134 n.loadFrame('ens1', othername, 'patient_file/history/encounters.php');
136 </script>
137 <?php } ?>
139 </body>
140 </html>