Sha256: feedf7adb69b00758a8d5eb13ee1a49896e3731d1a11f53633b0ab3511926592

Contents?: true

Size: 1.14 KB

Versions: 131

Compression:

Stored size: 1.14 KB

Contents

set SEARCH_PATH=renalware,public;
CREATE OR REPLACE FUNCTION renalware.update_research_study_participants_from_trigger() RETURNS TRIGGER AS $body$
/*
TC 05/06/2018
After a participant is added to a study, assign them an external_id, to be used when sending this
data for example to an external study application.
We use pseudo_encrypt() to generate a random id which is guaranteed to be unique as it is based
on the id. Its not the most secure however as, without a secret, the id can be reverse engineered
if our pseudo_encrypt sql function open source (which it is). If this is deemed to be a problem
(our intention at this point is rudimentary obfuscation), a hospital can override replace this
function with a more secure one.
An alternative to using a trigger is to use an after_ or before_save hook in Rails. The trigger
approach is chosen as, unlike a traditional Rails app, some direct data manipulation can be expected
in Renalware, even if that is just during migration.
*/
BEGIN
  IF (TG_OP = 'INSERT') THEN
    NEW.external_id = renalware.pseudo_encrypt(NEW.id::integer);
    RETURN NEW;
  END IF;
  RETURN NULL;
END $body$ LANGUAGE plpgsql VOLATILE COST 100;

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
renalware-core-2.1.1 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.1.0 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.167 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.166 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.165 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.164 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.163 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.162 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.161 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.160 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.159 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.158 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.157 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.156 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.155 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.153 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.152 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.151 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.149 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.148 db/functions/update_research_study_participants_from_trigger_v01.sql