Skip to content

Commit

Permalink
Advance Directives addition by Thomas Wong's group
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller committed Dec 30, 2009
1 parent 7d70ed9 commit 8d4acf2
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 8 deletions.
3 changes: 3 additions & 0 deletions interface/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@
// Set a facility cookie, so browser keeps a default selected facility between logins.
$GLOBALS['set_facility_cookie'] = false;

// Control the display of Advance Directives in demographics page
$GLOBALS['advance_directives_warning'] = true;

// If you want Hylafax support then uncomment and customize the following
// statements, and also customize custom/faxcover.txt:
//
Expand Down
110 changes: 110 additions & 0 deletions interface/patient_file/summary/advancedirectives.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
include_once("../../globals.php");
include_once("$srcdir/sql.inc");
include_once("$srcdir/options.inc.php");
include_once("$srcdir/formdata.inc.php");
?>
<html>
<head>
<?php html_header_show();?>
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
<script type="text/javascript" src="../../../library/dialog.js"></script>
<script type="text/javascript" src="../../../library/textformat.js"></script>
<script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
<script type="text/javascript" src="../../../library/dynarch_calendar_en.js"></script>
<script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/js/jquery.js"></script>
<SCRIPT LANGUAGE="JavaScript">
var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
function validate(f) {
if (f.form_adreviewed.value == "")
{
alert("<?php xl('Please enter a date for Last Reviewed.','e'); ?>");
f.form_adreviewed.focus();
return false;
}
return true;
}
$(document).ready(function(){
$("#cancel").click(function() { window.close(); });
});
</script>
</head>

<body class="body_top">
<?php
if ($_POST['form_yesno'])
{
sqlQuery("UPDATE patient_data SET completed_ad='".formData('form_yesno','P',true)."', ad_reviewed='".formData('form_adreviewed','P',true)."' where pid='$pid'");
// Close this window and refresh the calendar display.
echo "<html>\n<body>\n<script language='JavaScript'>\n";
echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
echo " window.close();\n";
echo "</script>\n</body>\n</html>\n";
exit();
}
$sql = "select completed_ad, ad_reviewed from patient_data where pid='$pid'";
$myrow = sqlQuery($sql);
if ($myrow)
{
$form_completedad = $myrow['completed_ad'];
$form_adreviewed = $myrow['ad_reviewed'];
}
?>
<span class="title"><?php xl('Advance Directives','e'); ?></span>
<br><br>
<form action='advancedirectives.php' method='post' onsubmit='return validate(this)' enctype="multipart/form-data">
<table border=0 cellpadding=1 cellspacing=1>
<?php
echo "<tr><td class='required'>";
xl('Completed','e');
echo ":</td><td width=10></td><td class='text'>";
generate_form_field(array('data_type'=>1,'field_id'=>'yesno','list_id'=>'yesno','empty_title'=>'SKIP'), $form_completedad);
echo "</td></tr><tr><td class='required'>";
xl('Last Reviewed','e');
echo ":</td><td width=10></td><td class='text'>";
generate_form_field(array('data_type'=>4,'field_id'=>'adreviewed'), $form_adreviewed);
echo "<script language='JavaScript'>Calendar.setup({inputField:'form_adreviewed', ifFormat:'%Y-%m-%d', button:'img_adreviewed'});</script>";
echo "</td></tr>";
echo "<tr><td class=text colspan=2><br><input type=submit id=create value='" . xl('Save') . "' /> &nbsp; <input type=button id=cancel value='" . xl('Cancel') . "' /></td></tr>";
?>
</table></form>
<div>
<?php
$query = "SELECT id FROM categories WHERE name='Advance Directive'";
$myrow2 = sqlQuery($query);
if ($myrow2) {
$parentId = $myrow2['id'];
$query = "SELECT id, name FROM categories WHERE parent='$parentId'";
$resNew1 = sqlStatement($query);
while ($myrows3 = sqlFetchArray($resNew1)) {
$categoryId = $myrows3['id'];
$nameDoc = $myrows3['name'];
$query = "SELECT documents.date, documents.id " .
"FROM documents " .
"INNER JOIN categories_to_documents " .
"ON categories_to_documents.document_id=documents.id " .
"WHERE categories_to_documents.category_id='$categoryId' " .
"AND documents.foreign_id='$pid' " .
"ORDER BY documents.date DESC";
$resNew2 = sqlStatement($query);
$counterFlag = false; //flag used to check for empty categories
while ($myrows4 = sqlFetchArray($resNew2)) {
$dateTimeDoc = $myrows4['date'];
$idDoc = $myrows4['id'];
echo "<br>";
echo "<a href='$web_root/controller.php?document&retrieve&patient_id=$pid&document_id=".$idDoc."&as_file=true'>".xl_document_category($nameDoc)."</a> ".$dateTimeDoc;
$counterFlag = true;
}
// if no associated docs with category then show it's empty
if (!$counterFlag) {
echo "<br>";
echo $nameDoc . " <span style='color:red;'>[" . xl('EMPTY') . "]</span>";
}
}
}
?>
</div>
</body>
</html>
55 changes: 52 additions & 3 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function oldEvt(eventid) {
dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 270);
}

function advdirconfigure() {
dlgopen('advancedirectives.php', '_blank', 500, 450);
}

function refreshme() {
top.restoreSession();
location.reload();
Expand Down Expand Up @@ -100,7 +104,6 @@ function sendimage(pid, what) {
'_blank', 500, 400);
return false;
}

</script>
</head>

Expand All @@ -123,7 +126,7 @@ function sendimage(pid, what) {

if ($thisauth == 'write') {
foreach (pic_array() as $var) {print $var;}
echo "<p><a href='demographics_full.php'";
echo "<table cellspacing=0 cellpadding=0 width=100%><tr><td><p><a href='demographics_full.php'";
if (! $GLOBALS['concurrent_layout']) echo " target='Main'";
echo " onclick='top.restoreSession()'><span class='title'>" .
xl('Demographics') . "</span>" .
Expand All @@ -132,7 +135,53 @@ function sendimage(pid, what) {
echo "&nbsp;&nbsp;<a href='' onclick='return deleteme()'>" .
"<span class='more' style='color:red'>(".xl('Delete').")</span></a>";
}
echo "</p>\n";
echo "</p></td><td align=right><div id=DEM><table cellspacing=0 cellpadding=0 width=100%><tr><td class='label'>";
if ($GLOBALS['advance_directives_warning'])
{
echo "<a title='" . xl('Click here to manage Advance Directives') . "' href='#' onclick='return advdirconfigure()'>";
echo xl('Advance Directives').":";
echo "</a>";
$counterFlag = false; //flag to record whether any categories contain ad records
$query = "SELECT id FROM categories WHERE name='Advance Directive'";
$myrow2 = sqlQuery($query);
if ($myrow2) {
$parentId = $myrow2['id'];
$query = "SELECT id, name FROM categories WHERE parent='$parentId'";
$resNew1 = sqlStatement($query);
while ($myrows3 = sqlFetchArray($resNew1)) {
$categoryId = $myrows3['id'];
$nameDoc = $myrows3['name'];
$query = "SELECT documents.date, documents.id " .
"FROM documents " .
"INNER JOIN categories_to_documents " .
"ON categories_to_documents.document_id=documents.id " .
"WHERE categories_to_documents.category_id='$categoryId' " .
"AND documents.foreign_id='$pid' " .
"ORDER BY documents.date DESC";
$resNew2 = sqlStatement($query);
$limitCounter = 0; // limit to one entry per category
while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
$dateTimeDoc = $myrows4['date'];
// remove time from datetime stamp
$tempParse = explode(" ",$dateTimeDoc);
$dateDoc = $tempParse[0];
$idDoc = $myrows4['id'];
echo "<br>";
echo "<a href='$web_root/controller.php?document&retrieve&patient_id=$pid&document_id=" .
$idDoc . "&as_file=true'>" . xl_document_category($nameDoc) . "</a> " . $dateDoc;
$limitCounter = $limitCounter + 1;
$counterFlag = true;
}
}
}
if (!$counterFlag) {
echo "<br>";
echo '<a title="' . xl("Click here to manage Advance Directives") .
'" href="#" onclick="return advdirconfigure()"><span style="color:red;">' .
xl("No Advance Directive Document Was Found"). '</span></a>';
}
}
echo "</td><td width=10></td></tr></table></div></td></tr></table><br>";
}

// Get the document ID of the patient ID card if access to it is wanted here.
Expand Down
14 changes: 14 additions & 0 deletions sql/3_2_0-to-3_3_0_upgrade.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#IfNotRow categories name Advance Directive
INSERT INTO categories select (select MAX(id) from categories) + 1, 'Advance Directive', '', 1, rght, rght + 7 from categories where name = 'Categories';
INSERT INTO categories select (select MAX(id) from categories) + 1, 'Do Not Resuscitate Order', '', (select id from categories where name = 'Advance Directive'), rght + 1, rght + 2 from categories where name = 'Categories';
INSERT INTO categories select (select MAX(id) from categories) + 1, 'Durable Power of Attorney', '', (select id from categories where name = 'Advance Directive'), rght + 3, rght + 4 from categories where name = 'Categories';
INSERT INTO categories select (select MAX(id) from categories) + 1, 'Living Will', '', (select id from categories where name = 'Advance Directive'), rght + 5, rght + 6 from categories where name = 'Categories';
UPDATE categories SET rght = rght + 8 WHERE name = 'Categories';
UPDATE categories_seq SET id = (select MAX(id) from categories);
#EndIf

#IfMissingColumn patient_data completed_ad
ALTER TABLE patient_data
ADD completed_ad VARCHAR(3) NOT NULL DEFAULT 'NO',
ADD ad_reviewed date DEFAULT NULL;
#EndIf
16 changes: 11 additions & 5 deletions sql/database.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--
--
-- Database: `openemr`
--

Expand Down Expand Up @@ -113,11 +113,15 @@ CREATE TABLE `categories` (
-- Dumping data for table `categories`
--

INSERT INTO `categories` VALUES (1, 'Categories', '', 0, 0, 9);
INSERT INTO `categories` VALUES (1, 'Categories', '', 0, 0, 17);
INSERT INTO `categories` VALUES (2, 'Lab Report', '', 1, 1, 2);
INSERT INTO `categories` VALUES (3, 'Medical Record', '', 1, 3, 4);
INSERT INTO `categories` VALUES (4, 'Patient Information', '', 1, 5, 8);
INSERT INTO `categories` VALUES (5, 'Patient ID card', '', 4, 6, 7);
INSERT INTO `categories` VALUES (6, 'Advance Directive', '', 1, 9, 16);
INSERT INTO `categories` VALUES (7, 'Do Not Resuscitate Order', '', 6, 10, 11);
INSERT INTO `categories` VALUES (8, 'Durable Power of Attorney', '', 6, 12, 13);
INSERT INTO `categories` VALUES (9, 'Living Will', '', 6, 14, 15);

-- --------------------------------------------------------

Expand All @@ -135,7 +139,7 @@ CREATE TABLE `categories_seq` (
-- Dumping data for table `categories_seq`
--

INSERT INTO `categories_seq` VALUES (5);
INSERT INTO `categories_seq` VALUES (9);

-- --------------------------------------------------------

Expand Down Expand Up @@ -2316,8 +2320,8 @@ CREATE TABLE `patient_data` (
`hipaa_voice` varchar(3) NOT NULL default '',
`hipaa_notice` varchar(3) NOT NULL default '',
`hipaa_message` varchar(20) NOT NULL default '',
`hipaa_allowsms` VARCHAR( 3 ) NOT NULL DEFAULT 'NO',
`hipaa_allowemail` VARCHAR( 3 ) NOT NULL DEFAULT 'NO',
`hipaa_allowsms` VARCHAR(3) NOT NULL DEFAULT 'NO',
`hipaa_allowemail` VARCHAR(3) NOT NULL DEFAULT 'NO',
`squad` varchar(32) NOT NULL default '',
`fitness` int(11) NOT NULL default '0',
`referral_source` varchar(30) NOT NULL default '',
Expand All @@ -2339,6 +2343,8 @@ CREATE TABLE `patient_data` (
`pricelevel` varchar(255) NOT NULL default 'standard',
`regdate` date DEFAULT NULL COMMENT 'Registration Date',
`contrastart` date DEFAULT NULL COMMENT 'Date contraceptives initially used',
`completed_ad` VARCHAR(3) NOT NULL DEFAULT 'NO',
`ad_reviewed` date DEFAULT NULL,
UNIQUE KEY `pid` (`pid`),
KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
Expand Down

0 comments on commit 8d4acf2

Please sign in to comment.