Skip to content

Commit

Permalink
ensoftek_mu2_170.314.a8: Clinical Decision Support, take 2.
Browse files Browse the repository at this point in the history
Modified by Terry Hill and Brady Miller to integrate into OpenEMR codebase.
  • Loading branch information
ensoftek authored and bradymiller committed Sep 9, 2015
1 parent b265905 commit f64de84
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 39 deletions.
96 changes: 73 additions & 23 deletions interface/patient_file/rules/patient_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ function submitme() {
$form_result = $selectedEntry['result'];
}

if (isset($_GET['rule'])) {
$rule_title = getListItemTitle("clinical_rules",$_GET['rule']);
$ruleData = sqlQuery("SELECT `developer`, `funding_source`, `release_version` " .
"FROM `clinical_rules` " .
"WHERE `id`=? AND `pid`=0", array($_GET['rule']) );
$developer = $ruleData['developer'];
$funding_source = $ruleData['funding_source'];
$release = $ruleData['release_version'];
}

?>
<table cellspacing='0' cellpadding='0' border='0'>
<tr>
Expand All @@ -143,44 +153,44 @@ function submitme() {
</tr>
</table>

<br><br>
<br>
<form action='patient_data.php' name='patient_data' method='post' onsubmit='return top.restoreSession()'>
<table border=0 cellpadding=1 cellspacing=1>
<?php
<?php
echo "<tr><td class='required'>";
echo htmlspecialchars( xl('Date/Time'), ENT_NOQUOTES);
echo xlt('Date/Time');
echo ":</td><td class='text'>";
echo "<input type='text' size='16' name='form_date' id='form_date' " .
"value='" . htmlspecialchars( $form_date, ENT_QUOTES) . "' " .
"value='" . attr( $form_date) . "' " .
"onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' " .
"title='" . htmlspecialchars( xl('yyyy-mm-dd hh:mm:ss'), ENT_QUOTES) . "' />";
"title='" . xla('yyyy-mm-dd hh:mm:ss') . "' />";
echo "<img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'" .
"id='img_date' border='0' alt='[?]' style='cursor:pointer'" .
"title='" . htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES) . "' />";
"title='" . xla('Click here to choose a date') . "' />";
echo "<script language='JavaScript'>Calendar.setup({inputField:'form_date', ifFormat:'%Y-%m-%d %H:%M:%S', button:'img_date', showsTime:'true'});</script>";
echo "</td></tr>";

echo "<tr><td class='required'>";
echo htmlspecialchars( xl('Completed'), ENT_NOQUOTES);
echo xlt('Completed');
echo ":</td><td class='text'>";
generate_form_field(array('data_type'=>1,'field_id'=>'complete','list_id'=>'yesno','empty_title'=>'SKIP'), ($form_complete) ? $form_complete : "YES");
echo "</td></tr>";

echo "<tr><td class='bold'>";
echo htmlspecialchars( xl('Results/Details'), ENT_NOQUOTES);
echo xlt('Results/Details');
echo ":</td><td class='text'>";
echo "<textarea name='form_result' cols='40' rows='3'>";
echo htmlspecialchars( $form_result, ENT_NOQUOTES);
echo attr($form_result);
echo "</textarea>";
echo "</td></tr>";
echo "</table>";
echo "<input type='hidden' name='form_category' value='" .
htmlspecialchars( $category, ENT_QUOTES) . "' />";
attr($category) . "' />";
echo "<input type='hidden' name='form_item' value='" .
htmlspecialchars( $item, ENT_QUOTES) . "' />";
attr($item) . "' />";
if (isset($entryID)) {
echo "<input type='hidden' name='form_entryID' value='" .
htmlspecialchars( $entryID, ENT_QUOTES) . "' />";
attr($entryID) . "' />";
}
?>
</form>
Expand All @@ -193,7 +203,6 @@ function submitme() {
"WHERE `category`=? AND `item`=? AND `pid`=? " .
"ORDER BY `date` DESC", array($category,$item,$pid) );
?>
<br>
<hr />
<br>
<div>
Expand All @@ -202,9 +211,9 @@ function submitme() {
<table class="showborder" cellspacing="0px" cellpadding="2px">
<tr class='showborder_head'>
<th>&nbsp;</th>
<th><?php echo htmlspecialchars( xl('Date/Time'), ENT_NOQUOTES); ?></th>
<th><?php echo htmlspecialchars( xl('Completed'), ENT_NOQUOTES); ?></th>
<th><?php echo htmlspecialchars( xl('Results/Details'), ENT_NOQUOTES); ?></th>
<th><?php echo xlt('Date/Time'); ?></th>
<th><?php echo xlt('Completed'); ?></th>
<th><?php echo xlt('Results/Details'); ?></th>
</tr>
<?php
while ($row = sqlFetchArray($res)) {
Expand All @@ -220,24 +229,65 @@ function submitme() {
}
else { // show the edit button
echo "<td><a href='patient_data.php?category=" .
htmlspecialchars( $category, ENT_QUOTES) . "&item=" .
htmlspecialchars( $item, ENT_QUOTES) . "&entryID=" .
htmlspecialchars( $row['id'], ENT_QUOTES) .
attr($category) . "&item=" .
attr($item) . "&entryID=" .
attr($row['id']) .
"' onclick='top.restoreSession()' class='css_button_small'>" .
"<span>" . htmlspecialchars( xl('Edit'), ENT_NOQUOTES) . "</span></a>" .
"<span>" . xlt('Edit') . "</span></a>" .
"</td>";
}
echo "<td>" . htmlspecialchars( $row['date'], ENT_NOQUOTES) . "</td>";
echo "<td align='center'>" . htmlspecialchars( $row['complete'], ENT_NOQUOTES) . "</td>";
echo "<td>" . text($row['date']) . "</td>";
echo "<td align='center'>" . text($row['complete']) . "</td>";
echo "<td>" . nl2br( htmlspecialchars( $row['result'], ENT_NOQUOTES) ) . "</td>";
echo "</tr>";
} ?>
</table>
<?php } //display table if statement
else { //no entries
echo "<p>" . htmlspecialchars( xl('No previous entries.'), ENT_NOQUOTES) . "</p>";
echo "<p>" . xlt('No previous entries.') . "</p>";
} ?>
</div>
<?php if (isset($_GET['rule'])) { ?>
<br>
<hr />
<br>
<?php echo "<p class='text'>" . xlt('See below for the details of the rule that created this action') . ":</p>"; ?>
<table border=0 cellpadding=1 cellspacing=1>
<?php
echo "<tr>";
echo "<td class='text'>";
echo xlt('Rule Title');
echo ":</td><td class='text'>";
echo text($rule_title);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td class='text'>";
echo xlt('Rule Developer');
echo ":</td><td class='text'>";
echo text($developer);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td class='text'>";
echo xlt('Rule Funding Source');
echo ":</td><td class='text'>";
echo text($funding_source);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td class='text'>";
echo xlt('Rule Release');
echo ":</td><td class='text'>";
echo text($release);
echo "</td>";
echo "</tr>";
?>
</table>
<?php } ?>

</body>
</html>
3 changes: 3 additions & 0 deletions interface/super/rules/controllers/detail/view/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class="action_link" id="edit_summary" onclick="top.restoreSession()">(<?php echo
<p><b><?php echo out( xl( $rule->title ) ); ?></b>
(<?php echo implode_funcs( ", ", $rule->getRuleTypeLabels(), array( 'xl', 'out' ) ); ?>)
</p>
<p><?php echo out( xl( 'Developer' ) ); ?><b>:</b>&nbsp;<?php echo out( $rule->developer ); ?></p>
<p><?php echo out( xl( 'Funding Source' ) ); ?><b>:</b>&nbsp;<?php echo out( $rule->funding_source ); ?></p>
<p><?php echo out( xl( 'Release' ) ); ?><b>:</b>&nbsp;<?php echo out( $rule->release ); ?></p>
</div>

<!-- -->
Expand Down
5 changes: 4 additions & 1 deletion interface/super/rules/controllers/edit/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ function _action_submit_summary() {
$ruleId = _post('id');
$types = _post('fld_ruleTypes');
$title = _post('fld_title');
$developer = _post('fld_developer');
$funding = _post('fld_funding_source');
$release = _post('fld_release');
if ( is_null($rule_id)) {
// its a new rule submit
$ruleId = $this->getRuleManager()->updateSummary( $ruleId, $types, $title );
$ruleId = $this->getRuleManager()->updateSummary( $ruleId, $types, $title, $developer, $funding, $release );

// redirect to the intervals page
$this->redirect("index.php?action=edit!intervals&id=$ruleId");
Expand Down
15 changes: 15 additions & 0 deletions interface/super/rules/controllers/edit/view/summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
</span>
</p>

<p class="row">
<span class="left_col colhead" data-fld="fld_developer"><?php echo out( xl( 'Developer' ) ); ?></span>
<span class="end_col"><input type="text" name="fld_developer" class="field" id="fld_developer" value="<?php echo out( $rule->developer ); ?>" maxlength="255"></span>
</p>

<p class="row">
<span class="left_col colhead" data-fld="fld_funding_source"><?php echo out( xl( 'Funding Source' ) ); ?></span>
<span class="end_col"><input type="text" name="fld_funding_source" class="field" id="fld_funding_source" value="<?php echo out( $rule->funding_source ); ?>" maxlength="255"></span>
</p>

<p class="row">
<span class="left_col colhead" data-fld="fld_release"><?php echo out( xl( 'Release' ) ); ?></span>
<span class="end_col"><input type="text" name="fld_release" class="field" id="fld_release" value="<?php echo out( $rule->release ); ?>" maxlength="255"></span>
</p>

</form>

</div>
Expand Down
17 changes: 16 additions & 1 deletion interface/super/rules/library/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class Rule {
var $ruleTypes;
var $id;
var $title;

var $developer;
var $funding_source;
var $release;
/**
* @var ReminderIntervals
*/
Expand All @@ -48,6 +50,18 @@ function getTitle() {
return $this->title;
}

function setDeveloper($s) {
$this->developer = $s;
}

function setFunding($s) {
$this->funding_source = $s;
}

function setRelease($s) {
$this->release = $s;
}

/**
* @param RuleType $ruleType
*/
Expand Down Expand Up @@ -136,5 +150,6 @@ function getRuleTypeLabels() {
}
return $labels;
}

}
?>
28 changes: 21 additions & 7 deletions interface/super/rules/library/RuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ class RuleManager {
passive_alert_flag = ?,
cqm_flag = ?,
amc_flag = ?,
patient_reminder_flag = ?
patient_reminder_flag = ?,
developer = ?,
funding_source = ?,
release_version = ?
WHERE id = ? AND pid = 0";

const SQL_UPDATE_TITLE =
"UPDATE list_options
SET title = ?
SET title = ?
WHERE list_id = 'clinical_rules' AND option_id = ?";

const SQL_REMOVE_INTERVALS =
Expand Down Expand Up @@ -130,6 +133,11 @@ function getRule($id, $pid = 0) {
}

$rule = new Rule($id, $ruleResult['title']);

$rule->setDeveloper($ruleResult['developer']);
$rule->setFunding($ruleResult['funding_source']);
$rule->setRelease($ruleResult['release_version']);

$this->fillRuleTypes( $rule, $ruleResult );
$this->fillRuleReminderIntervals( $rule );
$this->fillRuleFilterCriteria( $rule );
Expand Down Expand Up @@ -429,23 +437,26 @@ function deleteRuleFilter( $rule, $guid ) {
sqlStatement( "DELETE FROM rule_filter WHERE PASSWORD(CONCAT( id, include_flag, required_flag, method, method_detail, value )) = '". $guid . "'" );
}

function updateSummary( $ruleId, $types, $title ) {
function updateSummary( $ruleId, $types, $title, $developer, $funding, $release ) {
$rule = $this->getRule( $ruleId );

if ( is_null($rule) ) {
// add
$result = sqlQuery( "select count(*)+1 AS id from clinical_rules" );
$ruleId = "rule_" . $result['id'];
sqlStatement( "INSERT INTO clinical_rules (id, pid, active_alert_flag, passive_alert_flag, cqm_flag, amc_flag, patient_reminder_flag ) " .
"VALUES (?,?,?,?,?,?,?) ",
sqlStatement( "INSERT INTO clinical_rules (id, pid, active_alert_flag, passive_alert_flag, cqm_flag, amc_flag, patient_reminder_flag, developer, funding_source, release_version ) " .
"VALUES (?,?,?,?,?,?,?,?,?,?) ",
array(
$ruleId,
0,
in_array(RuleType::ActiveAlert, $types) ? 1 : 0,
in_array(RuleType::PassiveAlert, $types) ? 1 : 0,
in_array(RuleType::CQM, $types) ? 1 : 0,
in_array(RuleType::AMC, $types) ? 1 : 0,
in_array(RuleType::PatientReminder, $types) ? 1 : 0
in_array(RuleType::PatientReminder, $types) ? 1 : 0,
$developer,
$funding,
$release
)
);

Expand All @@ -461,6 +472,9 @@ function updateSummary( $ruleId, $types, $title ) {
in_array(RuleType::CQM, $types) ? 1 : 0,
in_array(RuleType::AMC, $types) ? 1 : 0,
in_array(RuleType::PatientReminder, $types) ? 1 : 0,
$developer,
$funding,
$release,
$rule->id )
);

Expand Down Expand Up @@ -710,7 +724,7 @@ function updateRuleAction( $action ) {
}
}

private function doRuleLabel( $exists, $listId, $optionId, $title ) {
private function doRuleLabel( $exists, $listId, $optionId, $title) {
if ( $exists) {
// edit
sqlStatement( "UPDATE list_options SET title = ? WHERE list_id = ? AND option_id = ?", array(
Expand Down
2 changes: 1 addition & 1 deletion interface/super/rules/www/css/rules.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ root {
}

.rule_detail.edit.summry .left_col {
width: 60px;
width: 120px;
text-align: right;
margin-right: 10px;
font-weight: bold;
Expand Down
13 changes: 9 additions & 4 deletions library/clinical_rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ function clinical_summary_widget($patient_id,$mode,$dateTarget='',$organize_mode

if ($action['custom_flag']) {
// Start link for reminders that use the custom rules input screen
echo "<a href='../rules/patient_data.php?category=" .
htmlspecialchars( $action['category'], ENT_QUOTES) . "&item=" .
htmlspecialchars( $action['item'], ENT_QUOTES) .
"' class='iframe medium_modal' onclick='top.restoreSession()'>";
$url = "../rules/patient_data.php?category=".htmlspecialchars( $action['category'], ENT_QUOTES);
$url .= "&item=".htmlspecialchars( $action['item'], ENT_QUOTES);
if(!empty($action['rule_id']))
$url .= "&rule=".htmlspecialchars( $action['rule_id'], ENT_QUOTES);
echo "<a href='".$url."' class='iframe medium_modal' onclick='top.restoreSession()'>";
}
else if ($action['clin_rem_link']) {
// Start link for reminders that use the custom rules input screen
Expand Down Expand Up @@ -599,6 +600,7 @@ function test_rules_clinic($provider='',$type='',$dateTarget='',$mode='',$patien
$action_plus = $action;
$action_plus['due_status'] = "not_due";
$action_plus['pid'] = $rowPatient['pid'];
$action_plus['rule_id'] = $rowRule['id'];
$results = reminder_results_integrate($results, $action_plus);
}
}
Expand All @@ -613,6 +615,7 @@ function test_rules_clinic($provider='',$type='',$dateTarget='',$mode='',$patien
$action_plus = $action;
$action_plus['due_status'] = $reminder_due;
$action_plus['pid'] = $rowPatient['pid'];
$action_plus['rule_id'] = $rowRule['id'];
$results = reminder_results_integrate($results, $action_plus);
}
}
Expand Down Expand Up @@ -721,6 +724,7 @@ function test_rules_clinic($provider='',$type='',$dateTarget='',$mode='',$patien
$action_plus = $action;
$action_plus['due_status'] = "not_due";
$action_plus['pid'] = $rowPatient['pid'];
$action_plus['rule_id'] = $rowRule['id'];
$results = reminder_results_integrate($results, $action_plus);
}
}
Expand All @@ -735,6 +739,7 @@ function test_rules_clinic($provider='',$type='',$dateTarget='',$mode='',$patien
$action_plus = $action;
$action_plus['due_status'] = $reminder_due;
$action_plus['pid'] = $rowPatient['pid'];
$action_plus['rule_id'] = $rowRule['id'];
$results = reminder_results_integrate($results, $action_plus);
}
}
Expand Down

0 comments on commit f64de84

Please sign in to comment.