Skip to content

Commit

Permalink
cms122 laboratory test performed issues (openemr#5392)
Browse files Browse the repository at this point in the history
* ignore deleted procedures

* php8 warning

* add result date,end date to pending review form and  procedure_result, relevantPeriod to lab test svc

* grab date_end

* fix date var names
  • Loading branch information
stephenwaite committed May 30, 2022
1 parent f84268a commit f44df6c
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
24 changes: 21 additions & 3 deletions interface/orders/orders_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function oresData($name, $index)
function QuotedOrNull($fld)
{
if (empty($fld)) {
return "NULL";
return "null";
}

return "'$fld'";
Expand Down Expand Up @@ -136,13 +136,15 @@ function QuotedOrNull($fld)
"procedure_report_id = '" . add_escape_custom($current_report_id) . "', " .
"result_code = '" . oresData("form_result_code", $lino) . "', " .
"result_text = '" . oresData("form_result_text", $lino) . "', " .
"`date` = " . QuotedOrNull(oresData("form_result_date", $lino)) . ", " .
"abnormal = '" . oresData("form_result_abnormal", $lino) . "', " .
"result = '" . oresData("form_result_result", $lino) . "', " .
"`range` = '" . oresData("form_result_range", $lino) . "', " .
"units = '" . oresData("form_result_units", $lino) . "', " .
"facility = '" . oresData("form_facility", $lino) . "', " .
"comments = '" . $form_comments . "', " .
"result_status = '" . oresData("form_result_status", $lino) . "'";
"result_status = '" . oresData("form_result_status", $lino) . "', " .
"`date_end` = " . QuotedOrNull(oresData("form_result_date_end", $lino));
if ($result_id) { // result already exists
sqlStatement("UPDATE procedure_result SET $sets " .
"WHERE procedure_result_id = '" . add_escape_custom($result_id) . "'");
Expand Down Expand Up @@ -376,6 +378,8 @@ function validate(f) {
<td><?php echo xlt('Status'); ?></td>
<td><?php echo xlt('Code'); ?></td>
<td><?php echo xlt('Name'); ?></td>
<td><?php echo xlt('Date'); ?></td>
<td><?php echo xlt('End Date'); ?></td>
<td><?php echo xlt('Abn'); ?></td>
<td><?php echo xlt('Value'); ?></td>
<td><?php echo xlt('Units'); ?></td>
Expand Down Expand Up @@ -470,7 +474,7 @@ function validate(f) {
$selects = "pt2.procedure_type, pt2.procedure_code, ll.title AS pt2_units, " .
"pt2.range AS pt2_range, pt2.procedure_type_id AS procedure_type_id, " .
"pt2.name AS name, pt2.description, pt2.seq AS seq, " .
"ps.procedure_result_id, ps.result_code AS result_code, ps.result_text, ps.abnormal, ps.result, " .
"ps.procedure_result_id, ps.result_code AS result_code, ps.result_text, ps.date, ps.date_end, ps.abnormal, ps.result, " .
"ps.range, ps.result_status, ps.facility, ps.comments, ps.units, ps.comments";

// procedure_type_id for order:
Expand Down Expand Up @@ -507,6 +511,8 @@ function validate(f) {
$result_id = empty($rrow['procedure_result_id']) ? 0 : ($rrow['procedure_result_id'] + 0);
$result_code = empty($rrow['result_code']) ? $restyp_code : $rrow['result_code'];
$result_text = empty($rrow['result_text']) ? $restyp_name : $rrow['result_text'];
$result_date = empty($rrow['date']) ? '' : $rrow['date'];
$result_date_end = empty($rrow['date_end']) ? '' : $rrow['date_end'];
$result_abnormal = empty($rrow['abnormal']) ? '' : $rrow['abnormal'];
$result_result = empty($rrow['result']) ? '' : $rrow['result'];
$result_units = empty($rrow['units']) ? $restyp_units : $rrow['units'];
Expand Down Expand Up @@ -616,6 +622,18 @@ class='form-control'
class='form-control'
value='<?php echo attr($result_text); ?>' />
</td>
<td class="text-nowrap">
<input type='text' size='13' name='form_result_date[<?php echo attr($lino); ?>]'
id='form_result_date[<?php echo attr($lino); ?>]'
class='form-control datetimepicker' value='<?php echo attr($result_date); ?>'
title='<?php echo xla('Date and time of this result'); ?>' />
</td>
<td class="text-nowrap">
<input type='text' size='13' name='form_result_date_end[<?php echo attr($lino); ?>]'
id='form_result_date_end[<?php echo attr($lino); ?>]'
class='form-control datetimepicker' value='<?php echo attr($result_date_end); ?>'
title='<?php echo xla('End date and time of this result'); ?>' />
</td>
<td>
<?php echo generate_select_list(
"form_result_abnormal[$lino]",
Expand Down
12 changes: 7 additions & 5 deletions interface/patient_file/summary/demographics_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,12 +1001,14 @@ class='text'>(<?php echo xlt('Browse'); ?>)</a>
<div class="col-md-9">
<select class='form-control form-control-sm mb-1 sel2' name='i<?php echo attr($i); ?>policy_type'>
<?php
foreach ($policy_types as $key => $value) {
echo " <option value ='" . attr($key) . "'";
if (!empty($result3['policy_type']) && ($key == $result3['policy_type'])) {
echo " selected";
if (!empty($policy_types)) {
foreach ($policy_types as $key => $value) {
echo " <option value ='" . attr($key) . "'";
if (!empty($result3['policy_type']) && ($key == $result3['policy_type'])) {
echo " selected";
}
echo ">" . text($value) . "</option>\n";
}
echo ">" . text($value) . "</option>\n";
}
?>
</select>
Expand Down
6 changes: 5 additions & 1 deletion sql/6_1_0-to-7_0_0_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -713,4 +713,8 @@ INSERT INTO list_options (list_id,option_id,title,seq,is_default,activity) VALUE
#IfRow3D list_options list_id immunization_refusal_reason option_id parental_decision seq 10
UPDATE list_options SET seq=40 WHERE list_id="immunization_refusal_reason" AND option_id="parental_decision";
UPDATE list_options SET seq=10 WHERE list_id="immunization_refusal_reason" AND option_id="patient_decision";
#EndIf
#EndIf

#IfMissingColumn procedure_result date_end
ALTER TABLE `procedure_result` ADD `date_end` datetime DEFAULT NULL COMMENT 'lab-provided end date specific to this result';
#EndIf
1 change: 1 addition & 0 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9386,6 +9386,7 @@ CREATE TABLE `procedure_result` (
`comments` text COMMENT 'comments from the lab',
`document_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'references documents.id if this result is a document',
`result_status` varchar(31) NOT NULL DEFAULT '' COMMENT 'preliminary, cannot be done, final, corrected, incomplete...etc.',
`date_end` datetime DEFAULT NULL COMMENT 'lab-provided end date specific to this result',
PRIMARY KEY (`procedure_result_id`),
UNIQUE KEY `uuid` (`uuid`),
KEY procedure_report_id (procedure_report_id)
Expand Down
22 changes: 18 additions & 4 deletions src/Services/Qdm/Services/LaboratoryTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

namespace OpenEMR\Services\Qdm\Services;

use OpenEMR\Cqm\Qdm\BaseTypes\DateTime;
use OpenEMR\Cqm\Qdm\BaseTypes\Quantity;
use OpenEMR\Cqm\Qdm\BaseTypes\{
DateTime,
Interval,
Quantity
};
use OpenEMR\Cqm\Qdm\LaboratoryTestPerformed;
use OpenEMR\Services\Qdm\Interfaces\QdmServiceInterface;
use OpenEMR\Services\Qdm\QdmRecord;
Expand All @@ -29,12 +32,13 @@ public function getSqlStatement()
RES.result_code,
RES.result,
RES.units,
RES.date
RES.date,
RES.date_end
FROM procedure_result RES
JOIN procedure_report REP ON RES.procedure_report_id = REP.procedure_report_id
JOIN procedure_order O ON REP.procedure_order_id = O.procedure_order_id
JOIN procedure_order_code OC ON O.procedure_order_id = OC.procedure_order_id
WHERE O.procedure_order_type = 'laboratory_test'
WHERE O.procedure_order_type = 'laboratory_test' AND O.activity != 0
";

return $sql;
Expand Down Expand Up @@ -63,6 +67,16 @@ public function makeQdmModel(QdmRecord $recordObj)
'relevantDatetime' => new DateTime([
'date' => $record['date']
]),
'relevantPeriod' => new Interval([
'low' => new DateTime([
'date' => $record['date']
]),
'high' => new DateTime([
'date' => $record['date_end'] ?: null
]),
'lowClosed' => $record['date'] ? true : false,
'highClosed' => $this->validDateOrNull($record['date_end']) ? true : false
]),
'result' => $result,
'resultDatetime' => new DateTime([
'date' => $record['date']
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// is a database change in the course of development. It is used
// internally to determine when a database upgrade is needed.
//
$v_database = 460;
$v_database = 461;

// Access control version identifier, this is to be incremented whenever there
// is a access control change in the course of development. It is used
Expand Down

0 comments on commit f44df6c

Please sign in to comment.