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.0.84 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.83 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.82 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.81 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.80 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.79 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.78 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.77 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.76 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.75 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.74 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.73 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.72 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.71 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.70 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.69 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.68 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.67 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.64 db/functions/update_research_study_participants_from_trigger_v01.sql
renalware-core-2.0.63 db/functions/update_research_study_participants_from_trigger_v01.sql