Skip to content

Commit

Permalink
fix: clinical rules - fix the optional/required setting (openemr#7154)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanksterr7 authored Jan 12, 2024
1 parent d2c332c commit 38df906
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
13 changes: 10 additions & 3 deletions interface/super/rules/controllers/edit/helper/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,24 @@
<!-- -->
<!-- -->
<!-- -->

<!--
HR: I inverted the meaning of these radios to match what gets saved in db. Db meaning controls logic.
Db field is "required_flag", and its label says has value 0 for required, and 1 for optional. but this is inverted.
If field's value is 1, logic treats as "required"
-->

<?php function common_fields($args)
{
?>
<?php $criteria = $args['criteria']; ?>
<p class="form-row">
<span class="left_col colhead req" data-field="fld_optional"><?php echo xlt('Optional'); ?></span>
<span class="end_col">
<input id="fld_optional" type="radio" name="fld_optional" class="field" value="yes"
<?php echo $criteria->optional ? "CHECKED" : ""?>> <?php echo xlt('Yes'); ?>
<input id="fld_optional" type="radio" name="fld_optional" class="field" value="no"
<?php echo !$criteria->optional ? "CHECKED" : ""?>> <?php echo xlt('No'); ?>
<?php echo !$criteria->optional ? "CHECKED" : ""?>> <?php echo xlt('Yes');?>
<input id="fld_optional" type="radio" name="fld_optional" class="field" value="yes"
<?php echo $criteria->optional ? "CHECKED" : ""?>> <?php echo xlt('No'); ?>
</span>
</p>

Expand Down
4 changes: 3 additions & 1 deletion interface/super/rules/controllers/edit/view/diagnosis.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<?php } else { ?>
<link rel="stylesheet" href="<?php echo $GLOBALS['themes_static_relative']; ?>/misc/rules.css?v=<?php echo $GLOBALS['v_js_includes']; ?>" />
<?php } ?>
<script src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>

<script src="../../../library/dialog.js?v=<?php echo $GLOBALS['v_js_includes']; ?>"></script>

<script>
// This invokes the find-code popup.
function sel_diagnosis() {
Expand Down
6 changes: 5 additions & 1 deletion interface/super/rules/library/RuleCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ abstract class RuleCriteria
{
/**
* if true, then criteria is optional; required otherwise
*
* @var boolean
*/
var $optional;

/**
* if true, then criteira is an inclusion; exclusion otherwise
*
* @var boolean
*/
var $inclusion = true;
Expand All @@ -38,6 +40,7 @@ abstract class RuleCriteria

/**
* uniquely identifies this criteria
*
* @var string
*/
var $guid;
Expand All @@ -52,7 +55,8 @@ abstract class RuleCriteria

function getCharacteristics()
{
$characteristics = $this->optional ? xl("Optional") : xl("Required");
// HR: reverse this to match logic behavior
$characteristics = $this->optional ? xl("Required") : xl("Optional");
$characteristics .= " ";
$characteristics .= $this->inclusion ? xl("Inclusion") : xl("Exclusion");

Expand Down
2 changes: 1 addition & 1 deletion sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8053,7 +8053,7 @@ DROP TABLE IF EXISTS `rule_filter`;
CREATE TABLE `rule_filter` (
`id` varchar(31) NOT NULL DEFAULT '' COMMENT 'Maps to the id column in the clinical_rules table',
`include_flag` tinyint(1) NOT NULL default 0 COMMENT '0 is exclude and 1 is include',
`required_flag` tinyint(1) NOT NULL default 0 COMMENT '0 is required and 1 is optional',
`required_flag` tinyint(1) NOT NULL default 0 COMMENT '0 is optional and 1 is required',
`method` varchar(31) NOT NULL DEFAULT '' COMMENT 'Maps to list_options list rule_filters',
`method_detail` varchar(31) NOT NULL DEFAULT '' COMMENT 'Maps to list_options lists rule__intervals',
`value` varchar(255) NOT NULL DEFAULT '',
Expand Down

0 comments on commit 38df906

Please sign in to comment.