Page 1 of 1

Recall Interval

Posted: Tue Jun 16, 2015 11:28 am
by Mifa
What's the equation behind the RecallInterval field? The documentation says "The Interval struct combines years, months, weeks, and days into a single integer value." I would like to present the values in this field in a more readable format in one of my custom reports.

Thanks.

Re: Recall Interval

Posted: Tue Jun 16, 2015 1:41 pm
by jsalmon
It's easiest to think of it in binary. We split day, week, month, and year into 4 vectors of a 32bit integer. Each vector has a max value of 255. We do limit the year vector to 127, but this should not affect your algorithm.
With that in mind, an interval of 127y 200m 150w 100d is represented as 2143852132 in the database.
Break that number into binary and you'll get: 0111 1111, 1100 1000, 1001 0110, 0110 0100
0111 1111: year - 127
1100 1000: month - 200
1001 0110: week - 150
0110 0100: days - 100

Re: Recall Interval

Posted: Tue Jun 16, 2015 2:10 pm
by Mifa
Thanks Jason!

Re: Recall Interval

Posted: Tue Oct 04, 2016 2:35 pm
by nathansparks
Mifa, I know it has been a while, but in case you still care, this will pull your values,

for recall type table

SELECT
DefaultInterval,
(DefaultInterval>> 24) AS Years,
(DefaultInterval>>16<<16)-(DefaultInterval>>24<<24)>>16 AS Months,
(DefaultInterval>>8<<8)-(DefaultInterval>>16<<16)>>8 AS Weeks,
DefaultInterval-(DefaultInterval>>8<<8) AS Days
FROM recalltype;

Or if you are looking at the recall table

SELECT
PatNum,
RecallInterval,
(RecallInterval>> 24) AS Years,
(RecallInterval>>16<<16)-(RecallInterval>>24<<24)>>16 AS Months,
(RecallInterval>>8<<8)-(RecallInterval>>16<<16)>>8 AS Weeks,
RecallInterval-(RecallInterval>>8<<8) AS Days
FROM recall;

Re: Recall Interval

Posted: Tue Oct 04, 2016 5:07 pm
by Mifa
Thanks Nathan, I appreciate the feedback. I have implemented the solution suggested by Jason and it works just fine, so far! And you know the saying: if it's not broken, don't fix it! :D