Skip to content

Commit

Permalink
Merge pull request #95 from answerdigital/fix/visits-location-qa
Browse files Browse the repository at this point in the history
add location, visit_occurrence and visit_detail fixes
  • Loading branch information
holtyad authored Jan 20, 2025
2 parents 81c480f + 8fbef92 commit a1a970b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 178 deletions.
3 changes: 0 additions & 3 deletions OmopTransformer/OmopTransformer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@
<None Update="SUS\APC\VisitDetails\SusAPCVisitDetails.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="SUS\APC\VisitOccurrenceWithoutSpell\SusAPCVisitOccurrenceWithoutSpell.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="SUS\APC\VisitOccurrenceWithSpell\SusAPCVisitOccurrenceWithSpell.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
1 change: 0 additions & 1 deletion OmopTransformer/SUS/APC/Location/SusAPCLocation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ select
Postcode,
NHSNumber
from omop_staging.sus_APC
where LocationClassAtEpisodeStartDate = '04'
and
(
Postcode is not null
Expand Down
6 changes: 0 additions & 6 deletions OmopTransformer/SUS/APC/SusAPCTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,11 +115,6 @@ await Transform<SusAPCVisitOccurrenceWithSpellRecord, SusAPCVisitOccurrenceWithS
"SUS APC VisitOccurrenceWithSpell",
cancellationToken);

await Transform<SusAPCVisitOccurrenceWithoutSpellRecord, SusAPCVisitOccurrenceWithoutSpell>(
_visitOccurrenceRecorder.InsertUpdateVisitOccurrence,
"SUS APC VisitOccurrenceWithoutSpell",
cancellationToken);

await Transform<SusAPCAnaestheticDuringLabourDeliveryRecord, SusAPCAnaestheticDuringLabourDelivery>(
_observationRecorder.InsertUpdateObservations,
"SUS APC AnaestheticDuringLabourDelivery",
Expand Down
10 changes: 3 additions & 7 deletions OmopTransformer/SUS/APC/VisitDetails/SusAPCVisitDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
</Sql>

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit a1a970b

Please sign in to comment.