Sha256: 0a7adfee6577d4c78834e1f72d7d3ee63c71384aac86d78dc1f2573e04c6d2a0

Contents?: true

Size: 1.24 KB

Versions: 161

Compression:

Stored size: 1.24 KB

Contents

/* Create a function for the trigger to call */
CREATE OR REPLACE FUNCTION preprocess_hl7_message() RETURNS trigger AS
$body$
BEGIN
  /*
  Mirth inserts a row into delayed job when a new HL7 message needs to be processed by Renalware.
  The SQL it uses looks like this:
    insert into renalware.delayed_jobs (handler, run_at)
    values(E'--- !ruby/struct:FeedJob\nraw_message: |\n  ' || REPLACE(${message.rawData},E'\r',E'\n  '), NOW());
  This works unless there is a 10^12 value in the unit of measurement segment for an OBX (e.g.
  for WBC or HGB). Then Mirth encodes the ^ as \S\ because ^ is a significant character in Mirth
  (field separator). Unfortunately this creates the combination
  10\S\12 and S\12 is converted to \n when the handler's payload is loaded in by the delayed_job worker.
  To get around this we need to convert instances of \S\ with another escape sequence eg «
  and manually map this back to a ^ in the job handler ruby code.

  So here, if this delayed_job is destined to be picked up by a Feed job handler
  make sure we convert the Mirth escape sequence \S\ to \\S\\
  */
  IF position('Feed' in NEW.handler) > 0 THEN
    NEW.handler = replace(NEW.handler, E'\\S\\', E'\\\\S\\\\');
  END IF;

  RETURN NEW;
END

$body$
LANGUAGE plpgsql;

Version data entries

161 entries across 161 versions & 1 rubygems

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