device_exposure_start_datetime
SUS AE Device Exposure
Source columns StartDate
, StartTime
. Combines a date with a time of day.
-
StartDate
Start date of the episode. START DATE (EPISODE) -
StartTime
The earliest episode start time for the spell, or midnight if none are specified. START TIME (EPISODE)
select
ae.AEAttendanceNumber,
ae.NHSNumber,
coalesce(ae.ArrivalDate, ae.CDSActivityDate) as StartDate,
coalesce(ae.ArrivalTime, '000000') as StartTime,
coalesce(ae.AEDepartureDate, ae.AEAttendanceConclusionDate) as EndDate,
coalesce(ae.AEDepartureTime, ae.AEAttendanceConclusionTime, '000000') as EndTime,
i.AccidentAndEmergencyInvestigation
from omop_staging.sus_AE_investigation i
inner join omop_staging.sus_AE ae
on i.MessageId = ae.MessageId
where ae.NHSNumber is not null
and i.AccidentAndEmergencyInvestigation in ('01', '02', '08', '09', '10', '11', '12', '19')