     audit_json                   mediumtext  null comment 'Used for Audit Purposes',
     CONSTRAINT pk_procedure_cds_tail PRIMARY KEY (exchange_id, cds_unique_identifier, sus_record_type)
 );
+
+-- index to make it easier to find last checksum for a record
+CREATE INDEX ix_procedure_cds_tail_checksum_helper on procedure_cds_tail (cds_unique_identifier, sus_record_type, dt_received);
 
 create table procedure_cds_tail_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_SURCC PRIMARY KEY (exchange_id, surgical_case_id)
);

-- index to make it easier to find last checksum for a record
CREATE INDEX ix_procedure_SURCC_checksum_helper on procedure_SURCC (surgical_case_id, dt_received);


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