     audit_json                  mediumtext null comment 'Used for Audit Purposes',
     CONSTRAINT pk_procedure_SURCP PRIMARY KEY (exchange_id, surgical_case_procedure_id)
 );
+
+-- index to make it easier to find last checksum for a record
+CREATE INDEX ix_procedure_SURCP_checksum_helper on procedure_SURCP (surgical_case_procedure_id, dt_received);
+
+
 
 create table procedure_SURCP_latest
 (

-- drop table if exists procedure_ecds_tail;
drop table if exists procedure_target;
drop table if exists procedure_target_latest;

-- records from sus inpatient, outpatient and emergency files are written to this table, with a record PER procedure
create table procedure_cds

    CONSTRAINT pk_procedure_procedure PRIMARY KEY (exchange_id, encounter_id, proc_dt_tm, proc_cd)
);

-- index to make it easier to find last checksum for a record
CREATE INDEX ix_procedure_procedure_checksum_helper on procedure_procedure (encounter_id, proc_dt_tm, proc_cd, dt_received);


create table procedure_procedure_latest
(
    exchange_id                     char(36)    NOT NULL COMMENT 'links to audit.exchange table (but on a different server)',
