Skip to content

Commit

Permalink
Merge pull request #434 from NewtonMutugi/dev
Browse files Browse the repository at this point in the history
Added ODS DQC scripts
  • Loading branch information
NewtonMutugi authored Jun 13, 2024
2 parents ae45a26 + c631083 commit e593306
Show file tree
Hide file tree
Showing 31 changed files with 165 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_ARTPatients.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_ARTPatients]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_AdverseEvents.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT SiteCode,Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_AdverseEvents]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] =0
GROUP BY SiteCode
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_AllergiesChronicIllness]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_ArtFastTrack.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_ArtFastTrack]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [Sitecode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_CancerScreening]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [Voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_CervicalCancerScreening]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [Voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_ContactListing]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_Covid.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_Covid]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_DefaulterTracing]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_DepressionScreening]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_DrugAlcoholScreening]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_EnhancedAdherenceCounselling]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_FacilityManifest]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [Voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_GbvScreening.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_GbvScreening]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_IITRiskScores.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_IITRiskScores]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [Voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_Ipt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_Ipt]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_Otz.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_Otz]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_Ovc.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_Ovc]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_Patient.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_Patient]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_PatientBaselines]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_PatientLabs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_PatientLabs]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_PatientPharmacy]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_PatientStatus.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_PatientStatus]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_PatientVisits.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_PatientVisits]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_PatientVisits_Opt]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL
GROUP BY [SiteCode]
HAVING Count(1) > 1
5 changes: 5 additions & 0 deletions Scripts/ODS/DQC/Get_Voided_Null_Patients/CT_Relationships.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT [SiteCode],Count(1)NullPatientPK_IDHash
FROM [ODS].[dbo].[CT_Relationships]
WHERE PatientPKHash IS NULL OR PatientIDHash IS NULL AND [Voided] = 0
GROUP BY [SiteCode]
HAVING Count(1) > 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UPDATE ap
SET ap.voided = 1
FROM [ODS].[dbo].[CT_ARTPatients] ap
LEFT JOIN [ODS].[dbo].[CT_Patient] p
ON ap.PatientIDHash = p.PatientIDHash AND ap.PatientPKHash = p.PatientPKHash
WHERE (ap.PatientIDHash IS NULL OR ap.PatientPKHash IS NULL)
AND ap.voided = 0;
7 changes: 7 additions & 0 deletions Scripts/ODS/DQC/Update_Voided_Null_Patients/CT_Ipt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UPDATE ap
SET ap.voided = 1
FROM [ODS].[dbo].[CT_Ipt] ap
LEFT JOIN [ODS].[dbo].[CT_Patient] p
ON ap.PatientIDHash = p.PatientIDHash AND ap.PatientPKHash = p.PatientPKHash
WHERE (ap.PatientIDHash IS NULL OR ap.PatientPKHash IS NULL)
AND ap.voided = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UPDATE ap
SET ap.voided = 1
FROM [ODS].[dbo].[CT_PatientBaselines] ap
LEFT JOIN [ODS].[dbo].[CT_Patient] p
ON ap.PatientIDHash = p.PatientIDHash AND ap.PatientPKHash = p.PatientPKHash
WHERE (ap.PatientIDHash IS NULL OR ap.PatientPKHash IS NULL)
AND ap.voided = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UPDATE ap
SET ap.voided = 1
FROM [ODS].[dbo].[CT_PatientLabs] ap
LEFT JOIN [ODS].[dbo].[CT_Patient] p
ON ap.PatientIDHash = p.PatientIDHash AND ap.PatientPKHash = p.PatientPKHash
WHERE (ap.PatientIDHash IS NULL OR ap.PatientPKHash IS NULL)
AND ap.voided = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UPDATE ap
SET ap.voided = 1
FROM [ODS].[dbo].[CT_PatientPharmacy] ap
LEFT JOIN [ODS].[dbo].[CT_Patient] p
ON ap.PatientIDHash = p.PatientIDHash AND ap.PatientPKHash = p.PatientPKHash
WHERE (ap.PatientIDHash IS NULL OR ap.PatientPKHash IS NULL)
AND ap.voided = 0;

0 comments on commit e593306

Please sign in to comment.