Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiv cs tx continuity #451

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
17 changes: 9 additions & 8 deletions Scripts/REPORTING/HIVCaseSurveillance/load_cs_TxContinuity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ BEGIN
,Facility.County
,Facility.SubCounty
,Patient.PatientPKHash
,Patient.PatientKey
,Patient.Gender
,Patient.DOB
,[AgeGroup].DATIMAgeGroup
,FactARTHistory.AgeGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DennisGibz not sure, I thought since this is a Fact we should be using an AgeGroupKey?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DennisGibz please recheck on this.

,[Partner].PartnerName
,case
when ARTOutcome.ARTOutcomeDescription in ('LOSS TO FOLLOW UP','UNDOCUMENTED LOSS') Then 'IIT'
when ARTOutcome.ARTOutcomeDescription in ('DEAD') Then 'MORTALITY'
else ARTOutcome.ARTOutcomeDescription
end ARTOutcome
,asofdatekey

,[Date].[Date] As asofdate
,YEAR(TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2)) As CohortYear
,TRY_CAST(DateConfirmedHIVPositiveKey AS DATETIME2) As CohortYearMonth
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure the CohortYearMonth is set to EndofMonth for ease of filtering

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Marymary-dev this has since been addressed.

,cast(asofdatekey as datetime2) As OutcomeYearMonth
,COUNT(1) AS NoOfClients
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DennisGibz, do we need this column here since this is a patient level dataset ?

INTO [HIVCaseSurveillance].[dbo].[CsTxContinuity]
FROM [NDWH].[dbo].[FactARTHistory] FactARTHistory
Expand All @@ -36,10 +37,8 @@ BEGIN
on FactARTHistory.ARTOutcomeKey = ARTOutcome.ARTOutcomeKey
LEFT OUTER JOIN [NDWH].[dbo].[DimDate] [Date]
ON FactARTHistory.AsOfDateKey = [Date].[Date]
LEFT OUTER JOIN [NDWH].[dbo].[DimAgeGroup] [AgeGroup]
ON FactARTHistory.AgeGroup = [AgeGroup].DATIMAgeGroup
WHERE Facility.MFLCode IS NOT NULL AND FactARTHistory.ARTOutcomeKey in (2,3,6,8) -- MORTALITY{2="DEAD"},Txcurr{6="ACTIVE},IIT{8=UNDOCUMENTED LOSS" 3="LOSS TO FOLLOW UP"}
AND YEAR(AsOfDateKey) <= YEAR(GETDATE())
AND YEAR(AsOfDateKey) <= YEAR(GETDATE())
GROUP BY Facility.FacilityName
,Facility.MFLCode
,Facility.County
Expand All @@ -49,9 +48,11 @@ BEGIN
,Patient.DOB
,[Partner].PartnerName
,ARTOutcome.ARTOutcomeDescription
,asofdatekey
,[Date].[Date]
,Patient.PatientKey
,DateConfirmedHIVPositiveKey
,[AgeGroup].DATIMAgeGroup
,FactARTHistory.AgeGroup
ORDER BY DateConfirmedHIVPositiveKey DESC;
END