URL:
<http://savannah.gnu.org/bugs/?44165>
Summary: Subtle bug in date of analysis for lab tests
Project: GNU Health
Submitted by: teffalump
Submitted on: Mon Feb 2 23:38:14 2015
Category: Functionality
Severity: 2 - Minor
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Release: None
Module: health_lab
_______________________________________________________
Details:
It is possible for lab tests to have values, but no date_analysis. Or
date_analysis to be set, and no values.
Simple solution: rename class method default_analysis (typo?) to
default_date_analysis. Still, no table checks.
Fuller solution: Something like this (forgive typos) on the results table....
// This creates a trigger on any updates on the result column
CREATE TRIGGER constrain_date_and_results AFTER UPDATE OF result ON
gnuhealth_lab_test_critearea FOR EACH ROW EXECUTE PROCEDURE
update_lab_date();
// This function updates the date, if not null, when a new result is not null
CREATE OR REPLACE FUNCTION update_lab_date() RETURNS trigger as $$ BEGIN IF
NEW.result IS NOT NULL THEN UPDATE gnuhealth_lab SET date_analysis =
COALESCE(date_analysis, now()) WHERE gnuhealth_lab.id = NEW.gnuhealth_lab_id;
END IF; RETURN; END; $$
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?44165>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/