From a3f83734bfc7d62d350f7585f5884c26b5855915 Mon Sep 17 00:00:00 2001 From: Tom Holt Date: Fri, 17 Jan 2025 14:35:06 +0000 Subject: [PATCH 1/3] add, location visit occurance and detail small fixes --- .../SUS/APC/Location/SusAPCLocation.xml | 1 - .../APC/VisitDetails/SusAPCVisitDetails.xml | 10 +-- .../SusAPCVisitOccurrenceWithSpell.xml | 27 ++++--- .../SusAPCVisitOccurrenceWithoutSpell.cs | 50 ------------ .../SusAPCVisitOccurrenceWithoutSpell.xml | 80 ------------------- ...SusAPCVisitOccurrenceWithoutSpellRecord.cs | 18 ----- 6 files changed, 17 insertions(+), 169 deletions(-) delete mode 100644 OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.cs delete mode 100644 OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.xml delete mode 100644 OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpellRecord.cs diff --git a/OmopTransformer/SUS/APC/Location/SusAPCLocation.xml b/OmopTransformer/SUS/APC/Location/SusAPCLocation.xml index a4a9267..32b5110 100644 --- a/OmopTransformer/SUS/APC/Location/SusAPCLocation.xml +++ b/OmopTransformer/SUS/APC/Location/SusAPCLocation.xml @@ -5,7 +5,6 @@ select Postcode, NHSNumber from omop_staging.sus_APC -where LocationClassAtEpisodeStartDate = '04' and ( Postcode is not null diff --git a/OmopTransformer/SUS/APC/VisitDetails/SusAPCVisitDetails.xml b/OmopTransformer/SUS/APC/VisitDetails/SusAPCVisitDetails.xml index 7310abc..945a4f3 100644 --- a/OmopTransformer/SUS/APC/VisitDetails/SusAPCVisitDetails.xml +++ b/OmopTransformer/SUS/APC/VisitDetails/SusAPCVisitDetails.xml @@ -35,17 +35,13 @@ VisitDetail as ( apc.GeneratedRecordIdentifier, - coalesce(apc.StartDateHospitalProviderSpell, apc.CDSActivityDate, apc.StartDateConsultantEpisode) as VisitStartDate, -- visit_start_date + coalesce(apc.StartDateConsultantEpisode, apc.StartDateHospitalProviderSpell, apc.CDSActivityDate) as VisitStartDate, coalesce(apc.StartTimeEpisode, apc.StartTimeHospitalProviderSpell, '000000') as VisitStartTime, -- visit_start_time - coalesce(apc.DischargeDateFromHospitalProviderSpell, apc.CDSActivityDate, apc.EndDateConsultantEpisode) as VisitEndDate, - +coalesce(apc.EndDateConsultantEpisode, apc.DischargeDateFromHospitalProviderSpell, apc.CDSActivityDate) as VisitEndDate, coalesce(apc.EndTimeEpisode, apc.DischargeTimeHospitalProviderSpell, '000000') as VisitEndTime, - case - when apc.CDSActivityDate is null and apc.DischargeDateFromHospitalProviderSpell is null and apc.StartDateConsultantEpisode is null and apc.PatientClassification = 1 then 32220 - else 32818 - end as VisitTypeConceptId, + 32818 as VisitTypeConceptId, case when apc.DischargeDateFromHospitalProviderSpell is null and apc.PatientClassification = 1 then 2 diff --git a/OmopTransformer/SUS/APC/VisitOccurrenceWithSpell/SusAPCVisitOccurrenceWithSpell.xml b/OmopTransformer/SUS/APC/VisitOccurrenceWithSpell/SusAPCVisitOccurrenceWithSpell.xml index 718cea6..d041674 100644 --- a/OmopTransformer/SUS/APC/VisitOccurrenceWithSpell/SusAPCVisitOccurrenceWithSpell.xml +++ b/OmopTransformer/SUS/APC/VisitOccurrenceWithSpell/SusAPCVisitOccurrenceWithSpell.xml @@ -3,46 +3,47 @@ select apc.NHSNumber, apc.HospitalProviderSpellNumber, - min (apc.CDSActivityDate) as EpisodeStartDate, - coalesce + min (apc.StartDateHospitalProviderSpell) as EpisodeStartDate, + coalesce ( - min (apc.StartTimeEpisode), + min (apc.StartTimeEpisode), '000000' ) as EpisodeStartTime, - coalesce + coalesce ( - max (apc.EndDateConsultantEpisode), + max (apc.DischargeDateFromHospitalProviderSpell), + max (apc.EndDateConsultantEpisode), max (apc.CDSActivityDate) ) as EpisodeEndDate, - coalesce + coalesce ( - max (apc.EndTimeEpisode), + max (apc.DischargeTimeHospitalProviderSpell), '000000' ) as EpisodeEndTime, --- apc.GeneratedRecordIdentifier, - case + apc.GeneratedRecordIdentifier, + case when max(apc.AdmissionMethodHospitalProviderSpell) in ('21','24') and max(apc.PatientClassification) = 1 then 262 when max(apc.AdmissionMethodHospitalProviderSpell) in ('21','24') then 9203 when max(apc.PatientClassification) in (1) then 9201 when max(apc.LocationClassAtEpisodeStartDate) in ('02') then 581476 else 9202 end as VisitOccurrenceConceptId, -- "visit_concept_id" - case + case when max(apc.EndDateConsultantEpisode) is null and max(apc.DischargeDestinationHospitalProviderSpell) is null then 32220 else 32818 end as VisitTypeConceptId, max (apc.SourceOfAdmissionHospitalProviderSpell) as SourceofAdmissionCode, max (apc.DischargeDestinationHospitalProviderSpell) as DischargeDestinationCode from [omop_staging].[sus_APC] apc - inner join dbo.Code c + inner join dbo.Code c on c.Code = apc.TreatmentFunctionCode where apc.UpdateType = 9 -- New/Modification (1 = Delete) and apc.NHSNumber is not null and c.CodeTypeId = 2 -- activity_treatment_function_code and apc.HospitalProviderSpellNumber is not null -group by +group by + apc.GeneratedRecordIdentifier, apc.NHSNumber, --- apc.GeneratedRecordIdentifier, apc.HospitalProviderSpellNumber; diff --git a/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.cs b/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.cs deleted file mode 100644 index b62acb9..0000000 --- a/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.cs +++ /dev/null @@ -1,50 +0,0 @@ -using OmopTransformer.Annotations; -using OmopTransformer.Omop.VisitOccurrence; -using OmopTransformer.Transformation; - -namespace OmopTransformer.SUS.APC.VisitOccurrenceWithoutSpell; - -[Notes( - "Assumptions", - "* `Emergency` covers a visit to A&E Within the given Hospital Provider, and hence covers Admission Code 21 and 24 only", - "* `Location Class` ID 24 is a Consultant Clinic Within the Health Care Provider.", - "* `Patient Classification` ID 1 is the only entry that covers 24 hours or more With the use of a bed, and whilst others may be a day/night only, they will be discounted because they are less than 24 hours. Also, maternity is also not taken as an `Inpatient` visit.", - "* No calculations to be made between Start and end visit date to try to calculate 24 hours, but instead the `Patient Classification` will be sufficient")] -internal class SusAPCVisitOccurrenceWithoutSpell : OmopVisitOccurrence -{ - [CopyValue(nameof(Source.NHSNumber))] - public override string? NhsNumber { get; set; } - - [CopyValue(nameof(Source.RecordConnectionIdentifier))] - public override string? RecordConnectionIdentifier { get; set; } - - [Transform(typeof(DateConverter), nameof(Source.EpisodeStartDate))] - public override DateTime? visit_start_date { get; set; } - - [Transform(typeof(DateAndTimeCombiner), nameof(Source.EpisodeStartDate), nameof(Source.EpisodeStartTime))] - public override DateTime? visit_start_datetime { get; set; } - - [Transform(typeof(DateConverter), nameof(Source.EpisodeEndDate))] - public override DateTime? visit_end_date { get; set; } - - [Transform(typeof(DateAndTimeCombiner), nameof(Source.EpisodeEndDate), nameof(Source.EpisodeEndTime))] - public override DateTime? visit_end_datetime { get; set; } - - [ConstantValue(9202, "`Outpatient Visit`")] - public override int? visit_concept_id { get; set; } - - [ConstantValue(32818, "`EHR Administration Record`")] - public override int? visit_type_concept_id { get; set; } - - [Transform(typeof(AdmittedSourceLookup), nameof(Source.SourceofAdmissionCode))] - public override int? admitted_from_concept_id { get; set; } - - [CopyValue(nameof(Source.SourceofAdmissionCode))] - public override string? admitted_from_source_value { get; set; } - - [Transform(typeof(DischargeDestinationLookup), nameof(Source.DischargeDestinationCode))] - public override int? discharged_to_concept_id { get; set; } - - [CopyValue(nameof(Source.DischargeDestinationCode))] - public override string? discharged_to_source_value { get; set; } -} \ No newline at end of file diff --git a/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.xml b/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.xml deleted file mode 100644 index 41eb93c..0000000 --- a/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpell.xml +++ /dev/null @@ -1,80 +0,0 @@ - - -with RecordConnectionIdentifierNHSNumberCombination as ( - select - distinct - apc.NHSNumber, - apc.GeneratedRecordIdentifier - from omop_staging.sus_APC apc -), - -RecordsWithVariableNhsNumber as ( -select - m1.GeneratedRecordIdentifier -from RecordConnectionIdentifierNHSNumberCombination m1 - inner join RecordConnectionIdentifierNHSNumberCombination m2 - on m1.NHSNumber != m2.NHSNumber -where m1.GeneratedRecordIdentifier = m2.GeneratedRecordIdentifier -) - -select - apc.NHSNumber, - apc.GeneratedRecordIdentifier, - min (apc.CDSActivityDate) as EpisodeStartDate, - '000000' as EpisodeStartTime, - max (apc.CDSActivityDate) as EpisodeEndDate, - '000000' as EpisodeEndTime, - max (apc.SourceOfAdmissionHospitalProviderSpell) as SourceofAdmissionCode, - max (apc.DischargeDestinationHospitalProviderSpell) as DischargeDestinationCode -from omop_staging.sus_APC apc - inner join dbo.Code c - on c.Code = apc.TreatmentFunctionCode -where apc.UpdateType = 9 -- New/Modification (1 = Delete) - and apc.NHSNumber is not null - and c.CodeTypeId = 2 -- activity_treatment_function_code - and apc.HospitalProviderSpellNumber is null - and not exists (select * from RecordsWithVariableNhsNumber rwvnn where rwvnn.GeneratedRecordIdentifier = apc.GeneratedRecordIdentifier) -group by - apc.NHSNumber, - apc.GeneratedRecordIdentifier; - - - - - CDS specific identifier that binds multiple CDS messages together. - CDS RECORD IDENTIFIER - - - Patient NHS Number - NHS NUMBER - - - - The earliest date in the message group. - CDS ACTIVITY DATE - - - - No data available, defaulted to midnight. - - - - The latest dte in the message group. - CDS ACTIVITY DATE - - - - No data available, defaulted to midnight. - - - - Admission Source. - ADMISSION SOURCE (HOSPITAL PROVIDER SPELL) - - - - Discharge Destination Code - DISCHARGE DESTINATION CODE (HOSPITAL PROVIDER SPELL) - - - \ No newline at end of file diff --git a/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpellRecord.cs b/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpellRecord.cs deleted file mode 100644 index a49487c..0000000 --- a/OmopTransformer/SUS/APC/VisitOccurrenceWithoutSpell/SusAPCVisitOccurrenceWithoutSpellRecord.cs +++ /dev/null @@ -1,18 +0,0 @@ -using OmopTransformer.Annotations; - -namespace OmopTransformer.SUS.APC.VisitOccurrenceWithoutSpell; - -[DataOrigin("SUS")] -[Description("SUS APC VisitOccurrenceWithoutSpell")] -[SourceQuery("SusAPCVisitOccurrenceWithoutSpell.xml")] -internal class SusAPCVisitOccurrenceWithoutSpellRecord -{ - public string? NHSNumber { get; set; } - public string? RecordConnectionIdentifier { get; set; } - public string? EpisodeStartDate { get; set; } - public string? EpisodeStartTime { get; set; } - public string? EpisodeEndDate { get; set; } - public string? EpisodeEndTime { get; set; } - public int? SourceofAdmissionCode { get; set; } - public int? DischargeDestinationCode { get; set; } -} \ No newline at end of file From 9106d16ffc4f19735e06eb53b68c94f439dd22bc Mon Sep 17 00:00:00 2001 From: holtyad Date: Fri, 17 Jan 2025 15:25:09 +0000 Subject: [PATCH 2/3] remove without spell --- OmopTransformer/SUS/APC/SusAPCTransformer.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/OmopTransformer/SUS/APC/SusAPCTransformer.cs b/OmopTransformer/SUS/APC/SusAPCTransformer.cs index ea99ef6..e9d4c47 100644 --- a/OmopTransformer/SUS/APC/SusAPCTransformer.cs +++ b/OmopTransformer/SUS/APC/SusAPCTransformer.cs @@ -3,7 +3,6 @@ using OmopTransformer.SUS.APC.Location; using OmopTransformer.SUS.APC.ConditionOccurrence; using OmopTransformer.SUS.APC.ProcedureOccurrence; -using OmopTransformer.SUS.APC.VisitOccurrenceWithoutSpell; using OmopTransformer.SUS.APC.VisitOccurrenceWithSpell; using OmopTransformer.SUS.APC.Observation.AnaestheticDuringLabourDelivery; using OmopTransformer.SUS.APC.Observation.AnaestheticGivenPostLabourDelivery; @@ -116,11 +115,6 @@ await Transform( - _visitOccurrenceRecorder.InsertUpdateVisitOccurrence, - "SUS APC VisitOccurrenceWithoutSpell", - cancellationToken); - await Transform( _observationRecorder.InsertUpdateObservations, "SUS APC AnaestheticDuringLabourDelivery", From 8fbef9258000b09fc6e6dfce02eaad2bbef4caba Mon Sep 17 00:00:00 2001 From: holtyad Date: Fri, 17 Jan 2025 15:26:17 +0000 Subject: [PATCH 3/3] remove references --- OmopTransformer/OmopTransformer.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/OmopTransformer/OmopTransformer.csproj b/OmopTransformer/OmopTransformer.csproj index 8f0cb0b..7326494 100644 --- a/OmopTransformer/OmopTransformer.csproj +++ b/OmopTransformer/OmopTransformer.csproj @@ -335,9 +335,6 @@ Always - - Always - Always