PKB SQL

This needs to be adding to the Data Repository repo once Nick Jones' branch has been merged in.

The WHERE criteria in the following will need changing for date based criteria.

CREATE OR REPLACE VIEW VWE_PKB_CHANGES AS
SELECT
  PID,
  NULL AS ID,
  'ADT_A28' AS MSG_TYPE
FROM
  PATIENTRECORD
WHERE
  PID = '1000000004'

UNION ALL

SELECT
  ID AS PID,
  NULL AS ID,
  'MDM_T02' AS MSG_TYPE
FROM
  PVDATA
WHERE
  ID = '1000000004'

UNION ALL

SELECT
  PID,
  ID,
  'ORU^R01' AS MSG_TYPE
FROM
  LABORDER
WHERE
  PID = '1000000004';


The following needs to be run before running PKB Identify Changes for the first time.

INSERT INTO EVENTCONTROL (eventtype, eventdate) VALUES ('PKBEXTRACT', '1900-01-01');