Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Everyone,
I wanted to have like a one-year wash-out period in my analysis , i.e. if the same type of event occurs within one year then it is not included as an outcome event.
A sample of my data looks something like this
Patientkey |
Diagnosis date |
1123 |
21/11/2018 |
1123 |
01/01/2019 |
1123 |
22/05/2021 |
So for this patient, I want my count to be 2, as I will not be counting the 21/11/2018 as it occurs in less than 1 years of 01/01/2019.
I did this, but I am aware that it is not appropriate.
count(${<([DiagnosisDate]-Above [DiagnosisDate])>'365'>} [PatientKey])
Any help would be greatly appreciated.
Thanks
@ashtrik203 I have followed the same logic as above and got the desired output. Attaching the screen shot as well.
Please see the code used in the backend.
NoConcatenate
Temp:
Load Patientkey,
Condition,
Date(Date#([Diagnosis date],'DD/MM/YYYY'),'MM/DD/YYYY') as [Diagnosis date]
Inline [
Patientkey,Condition,Diagnosis date
1123,Headache,21/11/2018
1156,Stomach-ache,22/6/1994
1123,Headache,01/01/2019
1136,Headache,15/11/2002
1156,Fever,5/08/2005
1123,Headache,22/05/2021
];
NoConcatenate
Temp1:
Load *,
if(Previous(Patientkey)=Patientkey and Previous(Condition)=Condition and
(Interval([Diagnosis date]-Previous([Diagnosis date]),'DD'))>'365','1','0') as Flag
Resident Temp
order by Patientkey,Condition,[Diagnosis date];
Concatenate(Temp1)
Load Patientkey,
Condition,
Min([Diagnosis date]) as [Diagnosis date],
'1' as Flag
Resident Temp
group by Patientkey,Condition;
Drop table Temp;
exit script;
In the front end to count number of Patients I used: Count({<Flag={1}>}Patientkey)
This should resolve your issue, If yes please like and accept it as a solution.
You can try these formulas, hope it helps.
Thank you for the reply. Unfortunately, my count is coming to be '0'
Not sure what is not working
@ashtrik203 Could you please try the below logic:
In the back end the script would be as below:
NoConcatenate
Temp:
Load Patientkey,
Date(Date#([Diagnosis date],'DD/MM/YYYY'),'MM/DD/YYYY') as [Diagnosis date]
Inline [
Patientkey,Diagnosis date
1123,21/11/2018
1123,01/01/2019
1123,22/05/2021
];
NoConcatenate
Temp1:
Load *,
if(Previous(Patientkey)=Patientkey and
(Interval([Diagnosis date]-Previous([Diagnosis date]),'DD'))>'365','1','0') as Flag
Resident Temp
Order by Patientkey,[Diagnosis date];
Concatenate(Temp1)
Load Patientkey,
Min([Diagnosis date]) as [Diagnosis date],
'1' as Flag
Resident Temp
group by Patientkey;
Drop table Temp;
Exit Script;
In the front end the expression would be as:
Count({<Flag={'1'}>}Patientkey)
Let me know if this resolved your issue, if yes please like and accept it as a solution.
Thank you, @sidhiq91 .
Unfortunately, i cannot get it to work. The flags are not appropriately placed when I run it on my data. not sure why
Myabe to explain it further, I have multiple people in my record. I have to count all people who had say a headache. Among these patients, if someone had headache mutliple times, then I will only count them if they are more than I year apart. If there is only one date for headache for a person, then it's straight forward, I just count them once
Patientkey |
Condition |
Diagnosis date |
1123 |
Headache |
21/11/2018 |
1156 |
Stomach-ache |
22/6/1994 |
1123 |
Headache |
01/01/209 |
1136 |
Headache |
51/11/2002 |
1156 |
Fever |
5/08/2005 |
1123 |
Headache |
22/05/2021 |
Output
Total Headache- 3 (2 for 1123 and 1 for 1136)
Total fever- 1 (for 1156)
Total Stomach-ache- 1(for 1156)
Hope it's clearer now
Any help would be appreciated
@ashtrik203 I have followed the same logic as above and got the desired output. Attaching the screen shot as well.
Please see the code used in the backend.
NoConcatenate
Temp:
Load Patientkey,
Condition,
Date(Date#([Diagnosis date],'DD/MM/YYYY'),'MM/DD/YYYY') as [Diagnosis date]
Inline [
Patientkey,Condition,Diagnosis date
1123,Headache,21/11/2018
1156,Stomach-ache,22/6/1994
1123,Headache,01/01/2019
1136,Headache,15/11/2002
1156,Fever,5/08/2005
1123,Headache,22/05/2021
];
NoConcatenate
Temp1:
Load *,
if(Previous(Patientkey)=Patientkey and Previous(Condition)=Condition and
(Interval([Diagnosis date]-Previous([Diagnosis date]),'DD'))>'365','1','0') as Flag
Resident Temp
order by Patientkey,Condition,[Diagnosis date];
Concatenate(Temp1)
Load Patientkey,
Condition,
Min([Diagnosis date]) as [Diagnosis date],
'1' as Flag
Resident Temp
group by Patientkey,Condition;
Drop table Temp;
exit script;
In the front end to count number of Patients I used: Count({<Flag={1}>}Patientkey)
This should resolve your issue, If yes please like and accept it as a solution.