2 //////////////////////////////////////////////////////////////////////
3 // ------------------ DO NOT MODIFY VIEW.PHP !!! ---------------------
4 // View.php is an exact duplicate of new.php. If you wish to make
5 // any changes, then change new.php and either (recommended) make
6 // view.php a symbolic link to new.php, or copy new.php to view.php.
8 // And if you check in a change to either module, be sure to check
9 // in the other (identical) module also.
11 // This nonsense can go away when we move to subversion.
12 //////////////////////////////////////////////////////////////////////
14 // Copyright (C) 2006 Rod Roark <rod@sunsetsystems.com>
16 // This program is free software; you can redistribute it and/or
17 // modify it under the terms of the GNU General Public License
18 // as published by the Free Software Foundation; either version 2
19 // of the License, or (at your option) any later version.
21 include_once("../../globals.php");
22 include_once("$srcdir/api.inc");
23 include_once("$srcdir/forms.inc");
24 include_once("lines.php");
26 if (! $encounter) { // comes from globals.php
27 die("Internal error: we do not seem to be in an encounter!");
30 $returnurl = $GLOBALS['concurrent_layout'] ?
'encounter_top.php' : 'patient_encounter.php';
32 function showExamLine($line_id, $description, &$linedbrow, $sysnamedisp) {
33 $dres = sqlStatement("SELECT * FROM form_physical_exam_diagnoses " .
34 "WHERE line_id = '$line_id' ORDER BY ordering, diagnosis");
37 echo " <td align='center'><input type='checkbox' name='form_obs[$line_id][wnl]' " .
38 "value='1'" . ($linedbrow['wnl'] ?
" checked" : "") . " /></td>\n";
39 echo " <td align='center'><input type='checkbox' name='form_obs[$line_id][abn]' " .
40 "value='1'" . ($linedbrow['abn'] ?
" checked" : "") . " /></td>\n";
41 echo " <td nowrap>$sysnamedisp</td>\n";
42 echo " <td nowrap>$description</td>\n";
44 echo " <td><select name='form_obs[$line_id][diagnosis]' onchange='seldiag(this, \"$line_id\")' style='width:100%'>\n";
45 echo " <option value=''></option>\n";
46 $diagnosis = $linedbrow['diagnosis'];
47 while ($drow = sqlFetchArray($dres)) {
49 $diag = $drow['diagnosis'];
50 if ($diagnosis && $diag == $diagnosis) {
54 echo " <option value='$diag' $sel>$diag</option>\n";
56 // If the diagnosis was not in the standard list then it must have been
57 // there before and then removed. In that case show it in parentheses.
59 echo " <option value='$diagnosis' selected>($diagnosis)</option>\n";
61 echo " <option value='*'>-- Edit --</option>\n";
62 echo " </select></td>\n";
64 echo " <td><input type='text' name='form_obs[$line_id][comments]' " .
65 "size='20' maxlength='250' style='width:100%' " .
66 "value='" . htmlentities($linedbrow['comments']) . "' /></td>\n";
70 function showTreatmentLine($line_id, $description, &$linedbrow) {
72 echo " <td align='center'><input type='checkbox' name='form_obs[$line_id][wnl]' " .
73 "value='1'" . ($linedbrow['wnl'] ?
" checked" : "") . " /></td>\n";
75 echo " <td colspan='2' nowrap>$description</td>\n";
76 echo " <td colspan='2'><input type='text' name='form_obs[$line_id][comments]' " .
77 "size='20' maxlength='250' style='width:100%' " .
78 "value='" . htmlentities($linedbrow['comments']) . "' /></td>\n";
82 $formid = $_GET['id'];
84 // If Save was clicked, save the info.
86 if ($_POST['bn_save']) {
88 // We are to update/insert multiple table rows for the form.
89 // Each has 2 checkboxes, a dropdown and a text input field.
90 // Skip rows that have no entries.
91 // There are also 3 special rows with just one checkbox and a text
92 // input field. Maybe also a diagnosis line, not clear.
95 $query = "DELETE FROM form_physical_exam WHERE forms_id = '$formid'";
99 $formid = addForm($encounter, "Physical Exam", 0, "physical_exam", $pid, $userauthorized);
100 $query = "UPDATE forms SET form_id = id WHERE id = '$formid' AND form_id = 0";
101 sqlStatement($query);
104 $form_obs = $_POST['form_obs'];
105 foreach ($form_obs as $line_id => $line_array) {
106 $wnl = $line_array['wnl'] ?
'1' : '0';
107 $abn = $line_array['abn'] ?
'1' : '0';
108 $diagnosis = $line_array['diagnosis'] ?
$line_array['diagnosis'] : '';
109 $comments = $line_array['comments'] ?
$line_array['comments'] : '';
110 if ($wnl ||
$abn ||
$diagnosis ||
$comments) {
111 $query = "INSERT INTO form_physical_exam ( " .
112 "forms_id, line_id, wnl, abn, diagnosis, comments " .
114 "'$formid', '$line_id', '$wnl', '$abn', '$diagnosis', '$comments' " .
120 if (! $_POST['form_refresh']) {
121 formHeader("Redirecting....");
128 // Load all existing rows for this form as a hash keyed on line_id.
132 $res = sqlStatement("SELECT * FROM form_physical_exam WHERE forms_id = '$formid'");
133 while ($row = sqlFetchArray($res)) {
134 $rows[$row['line_id']] = $row;
140 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
141 <script type
="text/javascript" src
="../../../library/dialog.js"></script
>
142 <script language
="JavaScript">
144 function seldiag(selobj
, line_id
) {
145 var i
= selobj
.selectedIndex
;
146 var opt
= selobj
.options
[i
];
147 if (opt
.value
== '*') {
148 selobj
.selectedIndex
= 0;
149 dlgopen('../../forms/physical_exam/edit_diagnoses.php?lineid=' + line_id
, '_blank', 500, 400);
153 function refreshme() {
154 var f
= document
.forms
[0];
155 f
.form_refresh
.value
= '1';
162 <body
<?
echo $top_bg_line;?
> topmargin
="0" rightmargin
="0" leftmargin
="2"
163 bottommargin
="0" marginwidth
="2" marginheight
="0">
164 <form method
="post" action
="<? echo $rootdir ?>/forms/physical_exam/new.php?id=<? echo $formid ?>">
169 <table border
='0' width
='98%'>
172 <td align
='center' width
='1%' nowrap
><b
>WNL
</b
></td
>
173 <td align
='center' width
='1%' nowrap
><b
>ABN1
</b
></td
>
174 <td align
='left' width
='1%' nowrap
><b
>System
</b
></td
>
175 <td align
='left' width
='1%' nowrap
><b
>Specific
</b
></td
>
176 <td align
='left' width
='1%' nowrap
><b
>Diagnosis
</b
></td
>
177 <td align
='left' width
='95%' nowrap
><b
>Comments
</b
></td
>
181 foreach ($pelines as $sysname => $sysarray) {
182 if ($sysname == '*') {
183 // TBD: Show any remaining entries in $rows (should not be any).
184 echo " <tr><td colspan='6'>\n";
185 echo " <br><b>Treatment:</b>\n";
186 echo " </td></tr>\n";
188 $sysnamedisp = $sysname;
189 foreach ($sysarray as $line_id => $description) {
190 if ($sysname != '*') {
191 showExamLine($line_id, $description, $rows[$line_id], $sysnamedisp);
193 showTreatmentLine($line_id, $description, $rows[$line_id]);
196 // TBD: Delete $rows[$line_id] if it exists.
198 } // end of system name
204 <input type
='hidden' name
='form_refresh' value
='' />
205 <input type
='submit' name
='bn_save' value
='Save' />
207 <input type
='button' value
='Cancel' onclick
="location='<? echo "$rootdir/patient_file
/encounter
/$returnurl" ?>'" />
214 // TBD: If $alertmsg, display it with a JavaScript alert().