NhsNumber

SUS Outpatient Death

  • Value copied from nhs_number

  • nhs_number Patient NHS Number NHS NUMBER

	select
		NHSNumber as nhs_number,
		coalesce(max(ReferralToTreatmentPeriodEndDate), max(CDSActivityDate)) as death_date
	from omop_staging.sus_OP
	where ReferralToTreatmentPeriodStatus = 36
		and (CDSActivityDate is not null or ReferralToTreatmentPeriodEndDate is not null)
		and NHSNumber is not null
	group by NHSNumber
	

Comment or raise an issue for this mapping.

SUS Inpatient Death

  • Value copied from nhs_number

  • nhs_number Patient NHS Number NHS NUMBER

;with primarydiagnosis as (
	select *
	from omop_staging.sus_ICDDiagnosis
	where IsPrimaryDiagnosis = 1
)

select
	apc.NHSNumber as nhs_number,
	max(apc.DischargeDateFromHospitalProviderSpell) as death_date,
	max(apc.DischargeTimeHospitalProviderSpell) as death_time,
	max(d.DiagnosisICD) as DiagnosisICD
from omop_staging.sus_APC apc
	left join primarydiagnosis d
		on apc.MessageId = d.MessageId
where
	apc.NHSNumber is not null and
	apc.DischargeDateFromHospitalProviderSpell is not null and
	apc.DischargeMethodHospitalProviderSpell = '4' -- "Patient died"

group by apc.NHSNumber
	

Comment or raise an issue for this mapping.

SUS A&E Death

  • Value copied from nhs_number

  • nhs_number Patient NHS Number NHS NUMBER

select
	NHSNumber as nhs_number,
	coalesce(max(ReferralToTreatmentPeriodEndDate), max(CDSActivityDate)) as death_date
from omop_staging.sus_AE
where ((ReferralToTreatmentPeriodStatus = 36) --PATIENT died before treatment
	or (AEPatientGroup = 70) -- PATIENT brought in dead
	or (AEAttendanceDisposal = 10))  --PATIENT died in AE
	and (CDSActivityDate is not null or ReferralToTreatmentPeriodEndDate is not null)
	and NHSNumber is not null
group by NHSNumber
	

Comment or raise an issue for this mapping.

Oxford Spine Death

  • Value copied from patient_identifier_Value

  • patient_identifier_Value Patient NHS Number

select
	patient_identifier_value,
	DECEASED_DT_TM
from ##duckdb_source##
	

Comment or raise an issue for this mapping.

Oxford GP Death

  • Value copied from NHSNumber

  • NHSNumber Patient NHS Number NHS NUMBER

select
	distinct
		NHSNumber,
		DateofDeath
from omop_staging.oxford_gp_demographic
where DateofDeath is not null
order by
	NHSNumber,
	DateofDeath
	

Comment or raise an issue for this mapping.

COSD v9 DeathDischargeDestination

  • Value copied from NhsNumber

  • NhsNumber Patient NHS Number NHS NUMBER

select distinct
    Record ->> '$.LinkagePatientId.NhsNumber.@extension' as NhsNumber,
    coalesce(
        cast(Record ->> '$.Treatment.DischargeDateHospitalProviderSpell' as date),
        make_date(
            cast(extract(year from cast(Record ->> '$.Treatment.TreatmentStartDateCancer' as date)) as integer),
            12,
            31
        )
    ) as DeathDate
from omop_staging.cosd_staging_901
where (Record ->> '$.Treatment.DischargeDestinationHospitalProviderSpell.@code') = '79';-- Not applicable - PATIENT died or stillbirth
	

Comment or raise an issue for this mapping.

COSD v9 BasisOfDiagnosisCancer

  • Value copied from NhsNumber

  • NhsNumber Patient NHS Number NHS NUMBER

-- fail
	    with cosddates as (
    select
        Record ->> '$.LinkagePatientId.NhsNumber.@extension' as NhsNumber,
        cast(Record ->> '$.Treatment.TreatmentStartDateCancer' as date) as TreatmentStartDateCancer,
        cast(Record ->> '$.CancerCarePlan.MultidisciplinaryTeamDiscussionDateCancer' as date) as MultidisciplinaryTeamDiscussionDateCancer,
        cast(Record ->> '$.PrimaryPathway.Staging.StageDateFinalPretreatmentStage' as date) as StageDateFinalPretreatmentStage,
        cast(Record ->> '$.PrimaryPathway.LinkageDiagnosticDetails.DateOfPrimaryDiagnosisClinicallyAgreed' as date) as DateOfPrimaryDiagnosisClinicallyAgreed
    from omop_staging.cosd_staging_901
    where type = 'CO'
      and (Record ->> '$.PrimaryPathway.Diagnosis.BasisOfDiagnosisCancer.@code') in ('0', '1')
), dates as (
    select NhsNumber, TreatmentStartDateCancer as "Date" from cosddates where TreatmentStartDateCancer is not null
    union
    select NhsNumber, MultidisciplinaryTeamDiscussionDateCancer as "Date" from cosddates where MultidisciplinaryTeamDiscussionDateCancer is not null
    union
    select NhsNumber, StageDateFinalPretreatmentStage as "Date" from cosddates where StageDateFinalPretreatmentStage is not null
    union
    select NhsNumber, DateOfPrimaryDiagnosisClinicallyAgreed as "Date" from cosddates where DateOfPrimaryDiagnosisClinicallyAgreed is not null
)
select
    NhsNumber,
    make_date(cast(extract(year from max("Date")) as integer), 12, 31) as DeathDate
from dates
group by NhsNumber;
	

Comment or raise an issue for this mapping.

COSD v8 Death

  • Value copied from NhsNumber

  • NhsNumber Patient NHS Number NHS NUMBER

select 
	distinct
		Record ->> '$..NHSNumber..@extension' ->> 0 as NhsNumber,
  		Record ->> '$..PersonDeathDate' ->> 0 as DeathDate
from omop_staging.cosd_staging_81
where DeathDate is not null

Comment or raise an issue for this mapping.