forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial support for layout-based encounter forms
- Loading branch information
sunsetsystems
committed
Jul 24, 2009
1 parent
daadaa2
commit 5aac1d1
Showing
17 changed files
with
624 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,277 @@ | ||
<?php | ||
// Copyright (C) 2009 Rod Roark <[email protected]> | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// as published by the Free Software Foundation; either version 2 | ||
// of the License, or (at your option) any later version. | ||
|
||
require_once("../../globals.php"); | ||
require_once("$srcdir/api.inc"); | ||
require_once("$srcdir/forms.inc"); | ||
require_once("$srcdir/options.inc.php"); | ||
require_once("$srcdir/patient.inc"); | ||
require_once("$srcdir/formdata.inc.php"); | ||
|
||
$CPR = 4; // cells per row | ||
|
||
$pprow = array(); | ||
|
||
if (! $encounter) { // comes from globals.php | ||
die("Internal error: we do not seem to be in an encounter!"); | ||
} | ||
|
||
function end_cell() { | ||
global $item_count, $cell_count; | ||
if ($item_count > 0) { | ||
echo "</td>"; | ||
$item_count = 0; | ||
} | ||
} | ||
|
||
function end_row() { | ||
global $cell_count, $CPR; | ||
end_cell(); | ||
if ($cell_count > 0) { | ||
for (; $cell_count < $CPR; ++$cell_count) echo "<td></td>"; | ||
echo "</tr>\n"; | ||
$cell_count = 0; | ||
} | ||
} | ||
|
||
function end_group() { | ||
global $last_group; | ||
if (strlen($last_group) > 0) { | ||
end_row(); | ||
echo " </table>\n"; | ||
echo "</div>\n"; | ||
} | ||
} | ||
|
||
$formname = formData('formname', 'G'); | ||
$formid = 0 + formData('id', 'G'); | ||
|
||
$tmp = sqlQuery("SELECT title FROM list_options WHERE list_id = 'lbfnames'"); | ||
$formtitle = $tmp['title']; | ||
|
||
$newid = 0; | ||
|
||
// If Save was clicked, save the info. | ||
// | ||
if ($_POST['bn_save']) { | ||
$sets = ""; | ||
$fres = sqlStatement("SELECT * FROM layout_options " . | ||
"WHERE form_id = '$formname' AND uor > 0 AND field_id != '' AND " . | ||
"edit_options != 'H' " . | ||
"ORDER BY group_name, seq"); | ||
while ($frow = sqlFetchArray($fres)) { | ||
$field_id = $frow['field_id']; | ||
$value = get_layout_form_value($frow); | ||
if ($formid) { // existing form | ||
if ($value === '') { | ||
$query = "DELETE FROM lbf_data WHERE " . | ||
"form_id = '$formid' AND field_id = '$field_id'"; | ||
} | ||
else { | ||
$query = "REPLACE INTO lbf_data SET field_value = '$value', " . | ||
"form_id = '$formid', field_id = '$field_id'"; | ||
} | ||
sqlStatement($query); | ||
} | ||
else { // new form | ||
if ($value !== '') { | ||
if ($newid) { | ||
sqlStatement("INSERT INTO lbf_data " . | ||
"( form_id, field_id, field_value ) " . | ||
" VALUES ( '$newid', '$field_id', '$value' )"); | ||
} | ||
else { | ||
$newid = sqlInsert("INSERT INTO lbf_data " . | ||
"( field_id, field_value ) " . | ||
" VALUES ( '$field_id', '$value' )"); | ||
} | ||
} | ||
// Note that a completely empty form will not be created at all! | ||
} | ||
} | ||
|
||
if (!$formid && $newid) { | ||
addForm($encounter, $formtitle, $newid, $formname, $pid, $userauthorized); | ||
} | ||
|
||
formHeader("Redirecting...."); | ||
formJump(); | ||
formFooter(); | ||
exit; | ||
} | ||
|
||
$enrow = sqlQuery("SELECT p.fname, p.mname, p.lname, fe.date FROM " . | ||
"form_encounter AS fe, forms AS f, patient_data AS p WHERE " . | ||
"p.pid = '$pid' AND f.pid = '$pid' AND f.encounter = '$encounter' AND " . | ||
"f.formdir = 'newpatient' AND f.deleted = 0 AND " . | ||
"fe.id = f.form_id LIMIT 1"); | ||
|
||
// if ($formid) { | ||
// $pprow = sqlQuery("SELECT * FROM lbf_data WHERE " . | ||
// "form_id = '$formid'"); | ||
// } | ||
?> | ||
<html> | ||
<head> | ||
<?php html_header_show();?> | ||
<link rel=stylesheet href="<?echo $css_header;?>" type="text/css"> | ||
<style> | ||
|
||
td, input, select, textarea { | ||
font-family: Arial, Helvetica, sans-serif; | ||
font-size: 10pt; | ||
} | ||
|
||
div.section { | ||
border: solid; | ||
border-width: 1px; | ||
border-color: #0000ff; | ||
margin: 0 0 0 10pt; | ||
padding: 5pt; | ||
} | ||
|
||
</style> | ||
|
||
<script type="text/javascript" src="../../../library/dialog.js"></script> | ||
|
||
<script language="JavaScript"> | ||
|
||
// Supports customizable forms (currently just for IPPF). | ||
function divclick(cb, divid) { | ||
var divstyle = document.getElementById(divid).style; | ||
if (cb.checked) { | ||
divstyle.display = 'block'; | ||
} else { | ||
divstyle.display = 'none'; | ||
} | ||
return true; | ||
} | ||
|
||
</script> | ||
</head> | ||
|
||
<body <?php echo $top_bg_line; ?> topmargin="0" rightmargin="0" leftmargin="2" bottommargin="0" marginwidth="2" marginheight="0"> | ||
<form method="post" action="<?php echo $rootdir ?>/forms/LBF/new.php?formname=<?php echo $formname ?>&id=<?php echo $formid ?>" | ||
onsubmit="return top.restoreSession()"> | ||
|
||
<p class='title' style='margin-top:8px;margin-bottom:8px;text-align:center'> | ||
<?php | ||
echo "$formtitle " . xl('for') . ' '; | ||
echo $enrow['fname'] . ' ' . $enrow['mname'] . ' ' . $enrow['lname']; | ||
echo ' ' . xl('on') . ' ' . substr($enrow['date'], 0, 10); | ||
?> | ||
</p> | ||
|
||
<?php | ||
$shrow = getHistoryData($pid); | ||
|
||
// echo "<div id='ippf_srh' style='display:none'>\n"; | ||
|
||
$fres = sqlStatement("SELECT * FROM layout_options " . | ||
"WHERE form_id = '$formname' AND uor > 0 " . | ||
"ORDER BY group_name, seq"); | ||
$last_group = ''; | ||
$cell_count = 0; | ||
$item_count = 0; | ||
$display_style = 'block'; | ||
|
||
while ($frow = sqlFetchArray($fres)) { | ||
$this_group = $frow['group_name']; | ||
$titlecols = $frow['titlecols']; | ||
$datacols = $frow['datacols']; | ||
$data_type = $frow['data_type']; | ||
$field_id = $frow['field_id']; | ||
$list_id = $frow['list_id']; | ||
|
||
$currvalue = ''; | ||
|
||
if ($frow['edit_options'] == 'H') { | ||
// This data comes from static history | ||
if (isset($shrow[$field_id])) $currvalue = $shrow[$field_id]; | ||
} else { | ||
if ($formid) { | ||
$pprow = sqlQuery("SELECT field_value FROM lbf_data WHERE " . | ||
"form_id = '$formid' AND field_id = '$field_id'"); | ||
if (!empty($pprow)) $currvalue = $pprow['field_value']; | ||
} | ||
} | ||
|
||
// Handle a data category (group) change. | ||
if (strcmp($this_group, $last_group) != 0) { | ||
end_group(); | ||
$group_seq = 'lbf' . substr($this_group, 0, 1); | ||
$group_name = substr($this_group, 1); | ||
$last_group = $this_group; | ||
echo "<br /><span class='bold'><input type='checkbox' name='form_cb_$group_seq' value='1' " . | ||
"onclick='return divclick(this,\"div_$group_seq\");'"; | ||
if ($display_style == 'block') echo " checked"; | ||
echo " /><b>$group_name</b></span>\n"; | ||
echo "<div id='div_$group_seq' class='section' style='display:$display_style;'>\n"; | ||
echo " <table border='0' cellpadding='0' width='100%'>\n"; | ||
$display_style = 'none'; | ||
} | ||
|
||
// Handle starting of a new row. | ||
if (($titlecols > 0 && $cell_count >= $CPR) || $cell_count == 0) { | ||
end_row(); | ||
echo " <tr>"; | ||
} | ||
|
||
if ($item_count == 0 && $titlecols == 0) $titlecols = 1; | ||
|
||
// Handle starting of a new label cell. | ||
if ($titlecols > 0) { | ||
end_cell(); | ||
echo "<td valign='top' colspan='$titlecols' width='1%' nowrap"; | ||
echo ($frow['uor'] == 2) ? " class='required'" : " class='bold'"; | ||
if ($cell_count == 2) echo " style='padding-left:10pt'"; | ||
echo ">"; | ||
$cell_count += $titlecols; | ||
} | ||
++$item_count; | ||
|
||
echo "<b>"; | ||
if ($frow['title']) echo $frow['title'] . ":"; else echo " "; | ||
echo "</b>"; | ||
|
||
// Handle starting of a new data cell. | ||
if ($datacols > 0) { | ||
end_cell(); | ||
echo "<td valign='top' colspan='$datacols' class='text'"; | ||
if ($cell_count > 0) echo " style='padding-left:5pt'"; | ||
echo ">"; | ||
$cell_count += $datacols; | ||
} | ||
|
||
++$item_count; | ||
|
||
if ($frow['edit_options'] == 'H') | ||
echo generate_display_field($frow, $currvalue); | ||
else | ||
generate_form_field($frow, $currvalue); | ||
} | ||
|
||
end_group(); | ||
// echo "</div>\n"; | ||
?> | ||
|
||
<p style='text-align:center'> | ||
<input type='submit' name='bn_save' value='Save' /> | ||
| ||
<input type='button' value='Cancel' onclick="top.restoreSession();location='<?php echo $GLOBALS['form_exit_url']; ?>'" /> | ||
| ||
</p> | ||
|
||
</form> | ||
<?php | ||
|
||
// TBD: If $alertmsg, display it with a JavaScript alert(). | ||
|
||
?> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
// Copyright (C) 2009 Rod Roark <[email protected]> | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// as published by the Free Software Foundation; either version 2 | ||
// of the License, or (at your option) any later version. | ||
|
||
include_once("../../globals.php"); | ||
include_once($GLOBALS["srcdir"] . "/api.inc"); | ||
|
||
// This function is invoked from printPatientForms in report.inc | ||
// when viewing a "comprehensive patient report". Also from | ||
// interface/patient_file/encounter/forms.php. | ||
// | ||
function lbf_report($pid, $encounter, $cols, $id, $formname) { | ||
require_once($GLOBALS["srcdir"] . "/options.inc.php"); | ||
echo "<table>\n"; | ||
|
||
$arr = array(); | ||
$fres = sqlStatement("SELECT field_id, field_value FROM lbf_data WHERE form_id = '$id'"); | ||
while ($frow = sqlFetchArray($fres)) { | ||
$arr[$frow['field_id']] = $frow['field_value']; | ||
} | ||
display_layout_rows($formname, $arr); | ||
|
||
echo "</table>\n"; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
require("new.php"); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.